ServersClient

class ServersClient(client: Client)[source]
actions: ResourceActionsClient

Servers scoped actions client

Type:

ResourceActionsClient

add_to_placement_group(server: Server | BoundServer, placement_group: PlacementGroup | BoundPlacementGroup) BoundAction[source]

Adds a server to a placement group.

Parameters:
Returns:

BoundAction

attach_iso(server: Server | BoundServer, iso: Iso | BoundIso) BoundAction[source]

Attaches an ISO to a server.

Parameters:
Returns:

BoundAction

attach_to_network(server: Server | BoundServer, network: Network | BoundNetwork, ip: str | None = None, alias_ips: list[str] | None = None) BoundAction[source]

Attaches a server to a network

Parameters:
  • serverBoundServer or Server

  • networkBoundNetwork or Network

  • ip – str IP to request to be assigned to this server

  • alias_ips – List[str] New alias IPs to set for this server.

Returns:

BoundAction

change_alias_ips(server: Server | BoundServer, network: Network | BoundNetwork, alias_ips: list[str]) BoundAction[source]

Changes the alias IPs of an already attached network.

Parameters:
Returns:

BoundAction

change_dns_ptr(server: Server | BoundServer, ip: str, dns_ptr: str | None) BoundAction[source]

Changes the hostname that will appear when getting the hostname belonging to the primary IPs (ipv4 and ipv6) of this server.

Parameters:
  • serverBoundServer or Server

  • ip – str The IP address for which to set the reverse DNS entry

  • dns_ptr – Hostname to set as a reverse DNS PTR entry, will reset to original default value if None

Returns:

BoundAction

change_protection(server: Server | BoundServer, delete: bool | None = None, rebuild: bool | None = None) BoundAction[source]

Changes the protection configuration of the server.

Parameters:
  • serverBoundServer or Server

  • delete – boolean If true, prevents the server from being deleted (currently delete and rebuild attribute needs to have the same value)

  • rebuild – boolean If true, prevents the server from being rebuilt (currently delete and rebuild attribute needs to have the same value)

Returns:

BoundAction

change_type(server: Server | BoundServer, server_type: ServerType | BoundServerType, upgrade_disk: bool) BoundAction[source]

Changes the type (Cores, RAM and disk sizes) of a server.

Parameters:
  • serverBoundServer or Server

  • server_typeBoundServerType or ServerType Server type the server should migrate to

  • upgrade_disk – boolean If false, do not upgrade the disk. This allows downgrading the server type later.

Returns:

BoundAction

create(name: str, server_type: ServerType | BoundServerType, image: Image, ssh_keys: list[SSHKey | BoundSSHKey] | None = None, volumes: list[Volume | BoundVolume] | None = None, firewalls: list[Firewall | BoundFirewall] | None = None, networks: list[Network | BoundNetwork] | None = None, user_data: str | None = None, labels: dict[str, str] | None = None, location: Location | BoundLocation | None = None, datacenter: Datacenter | BoundDatacenter | None = None, start_after_create: bool | None = True, automount: bool | None = None, placement_group: PlacementGroup | BoundPlacementGroup | None = None, public_net: ServerCreatePublicNetwork | None = None) CreateServerResponse[source]

Creates a new server. Returns preliminary information about the server as well as an action that covers progress of creation.

Parameters:
  • name – str Name of the server to create (must be unique per project and a valid hostname as per RFC 1123)

  • server_typeBoundServerType or ServerType Server type this server should be created with

  • imageBoundImage or Image Image the server is created from

  • ssh_keys – List[BoundSSHKey or SSHKey] (optional) SSH keys which should be injected into the server at creation time

  • volumes – List[BoundVolume or Volume] (optional) Volumes which should be attached to the server at the creation time. Volumes must be in the same location.

  • networks – List[BoundNetwork or Network] (optional) Networks which should be attached to the server at the creation time.

  • user_data – str (optional) Cloud-Init user data to use during server creation. This field is limited to 32KiB.

  • labels – Dict[str,str] (optional) User-defined labels (key-value pairs)

  • locationBoundLocation or Location

  • datacenterBoundDatacenter or Datacenter

  • start_after_create – boolean (optional) Start Server right after creation. Defaults to True.

  • automount – boolean (optional) Auto mount volumes after attach.

  • placement_groupBoundPlacementGroup or Location Placement Group where server should be added during creation

  • public_netServerCreatePublicNetwork Options to configure the public network of a server on creation

Returns:

CreateServerResponse

create_image(server: Server | BoundServer, description: str | None = None, type: str | None = None, labels: dict[str, str] | None = None) CreateImageResponse[source]

Creates an image (snapshot) from a server by copying the contents of its disks.

Parameters:
  • serverBoundServer or Server

  • description – str (optional) Description of the image. If you do not set this we auto-generate one for you.

  • type – str (optional) Type of image to create (default: snapshot) Choices: snapshot, backup

  • labels – Dict[str, str] User-defined labels (key-value pairs)

Returns:

CreateImageResponse

delete(server: Server | BoundServer) BoundAction[source]

Deletes a server. This immediately removes the server from your account, and it is no longer accessible.

Parameters:

serverBoundServer or Server

Returns:

BoundAction

detach_from_network(server: Server | BoundServer, network: Network | BoundNetwork) BoundAction[source]

Detaches a server from a network.

Parameters:
Returns:

BoundAction

detach_iso(server: Server | BoundServer) BoundAction[source]

Detaches an ISO from a server.

Parameters:

serverBoundServer or Server

Returns:

BoundAction

disable_backup(server: Server | BoundServer) BoundAction[source]

Disables the automatic backup option and deletes all existing Backups for a Server.

Parameters:

serverBoundServer or Server

Returns:

BoundAction

disable_rescue(server: Server | BoundServer) BoundAction[source]

Disables the Hetzner Rescue System for a server.

Parameters:

serverBoundServer or Server

Returns:

BoundAction

enable_backup(server: Server | BoundServer) BoundAction[source]

Enables and configures the automatic daily backup option for the server. Enabling automatic backups will increase the price of the server by 20%.

Parameters:

serverBoundServer or Server

Returns:

BoundAction

enable_rescue(server: Server | BoundServer, type: str | None = None, ssh_keys: list[str] | None = None) EnableRescueResponse[source]

Enable the Hetzner Rescue System for this server.

Parameters:
  • serverBoundServer or Server

  • type – str Type of rescue system to boot (default: linux64) Choices: linux64, linux32, freebsd64

  • ssh_keys – List[str] Array of SSH key IDs which should be injected into the rescue system. Only available for types: linux64 and linux32.

Returns:

EnableRescueResponse

get_actions(server: Server | BoundServer, status: list[str] | None = None, sort: list[str] | None = None) list[BoundAction][source]

Returns all action objects for a server.

Parameters:
  • serverBoundServer or Server

  • status – List[str] (optional) Response will have only actions with specified statuses. Choices: running success error

  • sort – List[str] (optional) Specify how the results are sorted. Choices: id id:asc id:desc command command:asc command:desc status status:asc status:desc progress progress:asc progress:desc started started:asc started:desc finished finished:asc finished:desc

Returns:

List[BoundAction]

get_actions_list(server: Server | BoundServer, status: list[str] | None = None, sort: list[str] | None = None, page: int | None = None, per_page: int | None = None) ActionsPageResult[source]

Returns all action objects for a server.

Parameters:
  • serverBoundServer or Server

  • status – List[str] (optional) Response will have only actions with specified statuses. Choices: running success error

  • sort – List[str] (optional) Specify how the results are sorted. Choices: id id:asc id:desc command command:asc command:desc status status:asc status:desc progress progress:asc progress:desc started started:asc started:desc finished finished:asc finished:desc

  • page – int (optional) Specifies the page to fetch

  • per_page – int (optional) Specifies how many results are returned by page

Returns:

(List[BoundAction], Meta)

get_all(name: str | None = None, label_selector: str | None = None, status: list[str] | None = None) list[BoundServer][source]

Get all servers from this account

Parameters:
  • name – str (optional) Can be used to filter servers by their name.

  • label_selector – str (optional) Can be used to filter servers by labels. The response will only contain servers matching the label selector.

  • status – List[str] (optional) Can be used to filter servers by their status. The response will only contain servers matching the status.

Returns:

List[BoundServer]

get_by_id(id: int) BoundServer[source]

Get a specific server

Parameters:

id – int

Returns:

BoundServer

get_by_name(name: str) BoundServer | None[source]

Get server by name

Parameters:

name – str Used to get server by name.

Returns:

BoundServer

get_list(name: str | None = None, label_selector: str | None = None, page: int | None = None, per_page: int | None = None, status: list[str] | None = None) ServersPageResult[source]

Get a list of servers from this account

Parameters:
  • name – str (optional) Can be used to filter servers by their name.

  • label_selector – str (optional) Can be used to filter servers by labels. The response will only contain servers matching the label selector.

  • status – List[str] (optional) Can be used to filter servers by their status. The response will only contain servers matching the status.

  • page – int (optional) Specifies the page to fetch

  • per_page – int (optional) Specifies how many results are returned by page

Returns:

(List[BoundServer], Meta)

get_metrics(server: Server | BoundServer, type: Literal['cpu', 'disk', 'network'] | list[Literal['cpu', 'disk', 'network']], start: datetime | str, end: datetime | str, step: float | None = None) GetMetricsResponse[source]

Get Metrics for a Server.

Parameters:
  • server – The Server to get the metrics for.

  • type – Type of metrics to get.

  • start – Start of period to get Metrics for (in ISO-8601 format).

  • end – End of period to get Metrics for (in ISO-8601 format).

  • step – Resolution of results in seconds.

power_off(server: Server | BoundServer) BoundAction[source]

Cuts power to the server. This forcefully stops it without giving the server operating system time to gracefully stop

Parameters:

serverBoundServer or Server

Returns:

BoundAction

power_on(server: Server | BoundServer) BoundAction[source]

Starts a server by turning its power on.

Parameters:

serverBoundServer or Server

Returns:

BoundAction

reboot(server: Server | BoundServer) BoundAction[source]

Reboots a server gracefully by sending an ACPI request.

Parameters:

serverBoundServer or Server

Returns:

BoundAction

rebuild(server: Server | BoundServer, image: Image | BoundImage, *, return_response: bool = False) RebuildResponse | BoundAction[source]

Rebuilds a server overwriting its disk with the content of an image, thereby destroying all data on the target server.

Parameters:
  • server – Server to rebuild

  • image – Image to use for the rebuilt server

  • return_response – Whether to return the full response or only the action.

remove_from_placement_group(server: Server | BoundServer) BoundAction[source]

Removes a server from a placement group.

Parameters:

serverBoundServer or Server

Returns:

BoundAction

request_console(server: Server | BoundServer) RequestConsoleResponse[source]

Requests credentials for remote access via vnc over websocket to keyboard, monitor, and mouse for a server.

Parameters:

serverBoundServer or Server

Returns:

RequestConsoleResponse

reset(server: Server | BoundServer) BoundAction[source]

Cuts power to a server and starts it again.

Parameters:

serverBoundServer or Server

Returns:

BoundAction

reset_password(server: Server | BoundServer) ResetPasswordResponse[source]

Resets the root password. Only works for Linux systems that are running the qemu guest agent.

Parameters:

serverBoundServer or Server

Returns:

ResetPasswordResponse

shutdown(server: Server | BoundServer) BoundAction[source]

Shuts down a server gracefully by sending an ACPI shutdown request.

Parameters:

serverBoundServer or Server

Returns:

BoundAction

update(server: Server | BoundServer, name: str | None = None, labels: dict[str, str] | None = None) BoundServer[source]

Updates a server. You can update a server’s name and a server’s labels.

Parameters:
  • serverBoundServer or Server

  • name – str (optional) New name to set

  • labels – Dict[str, str] (optional) User-defined labels (key-value pairs)

Returns:

BoundServer

class BoundServer(client: ServersClient, data: dict, complete: bool = True)[source]
add_to_placement_group(placement_group: PlacementGroup | BoundPlacementGroup) BoundAction[source]

Adds a server to a placement group.

Parameters:

placement_groupBoundPlacementGroup or Network

Returns:

BoundAction

attach_iso(iso: Iso | BoundIso) BoundAction[source]

Attaches an ISO to a server.

Parameters:

isoBoundIso or Server

Returns:

BoundAction

attach_to_network(network: Network | BoundNetwork, ip: str | None = None, alias_ips: list[str] | None = None) BoundAction[source]

Attaches a server to a network

Parameters:
  • networkBoundNetwork or Network

  • ip – str IP to request to be assigned to this server

  • alias_ips – List[str] New alias IPs to set for this server.

Returns:

BoundAction

change_alias_ips(network: Network | BoundNetwork, alias_ips: list[str]) BoundAction[source]

Changes the alias IPs of an already attached network.

Parameters:
  • networkBoundNetwork or Network

  • alias_ips – List[str] New alias IPs to set for this server.

Returns:

BoundAction

change_dns_ptr(ip: str, dns_ptr: str | None) BoundAction[source]

Changes the hostname that will appear when getting the hostname belonging to the primary IPs (ipv4 and ipv6) of this server.

Parameters:
  • ip – str The IP address for which to set the reverse DNS entry

  • dns_ptr – Hostname to set as a reverse DNS PTR entry, will reset to original default value if None

Returns:

BoundAction

change_protection(delete: bool | None = None, rebuild: bool | None = None) BoundAction[source]

Changes the protection configuration of the server.

Parameters:
  • serverBoundServer or Server

  • delete – boolean If true, prevents the server from being deleted (currently delete and rebuild attribute needs to have the same value)

  • rebuild – boolean If true, prevents the server from being rebuilt (currently delete and rebuild attribute needs to have the same value)

Returns:

BoundAction

change_type(server_type: ServerType | BoundServerType, upgrade_disk: bool) BoundAction[source]

Changes the type (Cores, RAM and disk sizes) of a server.

Parameters:
  • server_typeBoundServerType or ServerType Server type the server should migrate to

  • upgrade_disk – boolean If false, do not upgrade the disk. This allows downgrading the server type later.

Returns:

BoundAction

create_image(description: str | None = None, type: str | None = None, labels: dict[str, str] | None = None) CreateImageResponse[source]

Creates an image (snapshot) from a server by copying the contents of its disks.

Parameters:
  • description – str (optional) Description of the image. If you do not set this we auto-generate one for you.

  • type – str (optional) Type of image to create (default: snapshot) Choices: snapshot, backup

  • labels – Dict[str, str] User-defined labels (key-value pairs)

Returns:

CreateImageResponse

delete() BoundAction[source]

Deletes a server. This immediately removes the server from your account, and it is no longer accessible.

Returns:

BoundAction

detach_from_network(network: Network | BoundNetwork) BoundAction[source]

Detaches a server from a network.

Parameters:

networkBoundNetwork or Network

Returns:

BoundAction

detach_iso() BoundAction[source]

Detaches an ISO from a server.

Returns:

BoundAction

disable_backup() BoundAction[source]

Disables the automatic backup option and deletes all existing Backups for a Server.

Returns:

BoundAction

disable_rescue() BoundAction[source]

Disables the Hetzner Rescue System for a server.

Returns:

BoundAction

enable_backup() BoundAction[source]

Enables and configures the automatic daily backup option for the server. Enabling automatic backups will increase the price of the server by 20%.

Returns:

BoundAction

enable_rescue(type: str | None = None, ssh_keys: list[str] | None = None) EnableRescueResponse[source]

Enable the Hetzner Rescue System for this server.

Parameters:
  • type – str Type of rescue system to boot (default: linux64) Choices: linux64, linux32, freebsd64

  • ssh_keys – List[str] Array of SSH key IDs which should be injected into the rescue system. Only available for types: linux64 and linux32.

Returns:

EnableRescueResponse

get_actions(status: list[str] | None = None, sort: list[str] | None = None) list[BoundAction][source]

Returns all action objects for a server.

Parameters:
  • status – List[str] (optional) Response will have only actions with specified statuses. Choices: running success error

  • sort – List[str] (optional) Specify how the results are sorted. Choices: id id:asc id:desc command command:asc command:desc status status:asc status:desc progress progress:asc progress:desc started started:asc started:desc finished finished:asc finished:desc

Returns:

List[BoundAction]

get_actions_list(status: list[str] | None = None, sort: list[str] | None = None, page: int | None = None, per_page: int | None = None) ActionsPageResult[source]

Returns all action objects for a server.

Parameters:
  • status – List[str] (optional) Response will have only actions with specified statuses. Choices: running success error

  • sort – List[str] (optional) Specify how the results are sorted. Choices: id id:asc id:desc command command:asc command:desc status status:asc status:desc progress progress:asc progress:desc started started:asc started:desc finished finished:asc finished:desc

  • page – int (optional) Specifies the page to fetch

  • per_page – int (optional) Specifies how many results are returned by page

Returns:

(List[BoundAction], Meta)

get_metrics(type: Literal['cpu', 'disk', 'network'] | list[Literal['cpu', 'disk', 'network']], start: datetime | str, end: datetime | str, step: float | None = None) GetMetricsResponse[source]

Get Metrics for a Server.

Parameters:
  • server – The Server to get the metrics for.

  • type – Type of metrics to get.

  • start – Start of period to get Metrics for (in ISO-8601 format).

  • end – End of period to get Metrics for (in ISO-8601 format).

  • step – Resolution of results in seconds.

model

alias of Server

power_off() BoundAction[source]

Cuts power to the server. This forcefully stops it without giving the server operating system time to gracefully stop

Returns:

BoundAction

power_on() BoundAction[source]

Starts a server by turning its power on.

Returns:

BoundAction

reboot() BoundAction[source]

Reboots a server gracefully by sending an ACPI request.

Returns:

BoundAction

rebuild(image: Image | BoundImage, *, return_response: bool = False) RebuildResponse | BoundAction[source]

Rebuilds a server overwriting its disk with the content of an image, thereby destroying all data on the target server.

Parameters:
  • image – Image to use for the rebuilt server

  • return_response – Whether to return the full response or only the action.

remove_from_placement_group() BoundAction[source]

Removes a server from a placement group.

Returns:

BoundAction

request_console() RequestConsoleResponse[source]

Requests credentials for remote access via vnc over websocket to keyboard, monitor, and mouse for a server.

Returns:

RequestConsoleResponse

reset() BoundAction[source]

Cuts power to a server and starts it again.

Returns:

BoundAction

reset_password() ResetPasswordResponse[source]

Resets the root password. Only works for Linux systems that are running the qemu guest agent.

Returns:

ResetPasswordResponse

shutdown() BoundAction[source]

Shuts down a server gracefully by sending an ACPI shutdown request.

Returns:

BoundAction

update(name: str | None = None, labels: dict[str, str] | None = None) BoundServer[source]

Updates a server. You can update a server’s name and a server’s labels.

Parameters:
  • name – str (optional) New name to set

  • labels – Dict[str, str] (optional) User-defined labels (key-value pairs)

Returns:

BoundServer

class Server(id: int, name: str | None = None, status: str | None = None, created: str | None = None, public_net: PublicNetwork | None = None, server_type: BoundServerType | None = None, datacenter: BoundDatacenter | None = None, image: BoundImage | None = None, iso: BoundIso | None = None, rescue_enabled: bool | None = None, locked: bool | None = None, backup_window: str | None = None, outgoing_traffic: int | None = None, ingoing_traffic: int | None = None, included_traffic: int | None = None, protection: dict | None = None, labels: dict[str, str] | None = None, volumes: list[BoundVolume] | None = None, private_net: list[PrivateNet] | None = None, primary_disk_size: int | None = None, placement_group: BoundPlacementGroup | None = None)[source]

Server Domain

Parameters:
  • id – int ID of the server

  • name – str Name of the server (must be unique per project and a valid hostname as per RFC 1123)

  • status – str Status of the server Choices: running, initializing, starting, stopping, off, deleting, migrating, rebuilding, unknown

  • created – datetime Point in time when the server was created

  • public_netPublicNetwork Public network information.

  • server_typeBoundServerType

  • datacenterBoundDatacenter

  • imageBoundImage, None

  • isoBoundIso, None

  • rescue_enabled – bool True if rescue mode is enabled: Server will then boot into rescue system on next reboot.

  • locked – bool True if server has been locked and is not available to user.

  • backup_window – str, None Time window (UTC) in which the backup will run, or None if the backups are not enabled

  • outgoing_traffic – int, None Outbound Traffic for the current billing period in bytes

  • ingoing_traffic – int, None Inbound Traffic for the current billing period in bytes

  • included_traffic – int Free Traffic for the current billing period in bytes

  • primary_disk_size – int Size of the primary Disk

  • protection – dict Protection configuration for the server

  • labels – dict User-defined labels (key-value pairs)

  • volumes – List[BoundVolume] Volumes assigned to this server.

  • private_net – List[PrivateNet] Private networks information.

STATUS_DELETING = 'deleting'

Server Status deleting

STATUS_INIT = 'initializing'

Server Status initializing

STATUS_MIGRATING = 'migrating'

Server Status migrating

STATUS_OFF = 'off'

Server Status off

STATUS_REBUILDING = 'rebuilding'

Server Status rebuilding

STATUS_RUNNING = 'running'

Server Status running

STATUS_STARTING = 'starting'

Server Status starting

STATUS_STOPPING = 'stopping'

Server Status stopping

STATUS_UNKNOWN = 'unknown'

Server Status unknown

class PublicNetwork(ipv4: IPv4Address, ipv6: IPv6Network, floating_ips: list[BoundFloatingIP], primary_ipv4: BoundPrimaryIP | None, primary_ipv6: BoundPrimaryIP | None, firewalls: list[PublicNetworkFirewall] | None = None)[source]

Public Network Domain

Parameters:
  • ipv4IPv4Address

  • ipv6IPv6Network

  • floating_ips – List[BoundFloatingIP]

  • primary_ipv4BoundPrimaryIP

  • primary_ipv6BoundPrimaryIP

  • firewalls – List[PublicNetworkFirewall]

class IPv4Address(ip: str, blocked: bool, dns_ptr: str)[source]

IPv4 Address Domain

Parameters:
  • ip – str The IPv4 Address

  • blocked – bool Determine if the IP is blocked

  • dns_ptr – str DNS PTR for the ip

class IPv6Network(ip: str, blocked: bool, dns_ptr: list)[source]

IPv6 Network Domain

Parameters:
  • ip – str The IPv6 Network as CIDR Notation

  • blocked – bool Determine if the Network is blocked

  • dns_ptr – dict DNS PTR Records for the Network as Dict

  • network – str The network without the network mask

  • network_mask – str The network mask

class CreateServerResponse(server: BoundServer, action: BoundAction, next_actions: list[BoundAction], root_password: str | None)[source]

Create Server Response Domain

Parameters:
  • serverBoundServer The created server

  • actionBoundAction Shows the progress of the server creation

  • next_actions – List[BoundAction] Additional actions like a start_server action after the server creation

  • root_password – str, None The root password of the server if no SSH-Key was given on server creation

class ServerCreatePublicNetwork(ipv4: PrimaryIP | None = None, ipv6: PrimaryIP | None = None, enable_ipv4: bool = True, enable_ipv6: bool = True)[source]

Server Create Public Network Domain

Parameters:
  • ipv4 – Optional[PrimaryIP]

  • ipv6 – Optional[PrimaryIP]

  • enable_ipv4 – bool

  • enable_ipv6 – bool

class ResetPasswordResponse(action: BoundAction, root_password: str)[source]

Reset Password Response Domain

Parameters:
  • actionBoundAction Shows the progress of the server passwort reset action

  • root_password – str The root password of the server

class EnableRescueResponse(action: BoundAction, root_password: str)[source]

Enable Rescue Response Domain

Parameters:
  • actionBoundAction Shows the progress of the server enable rescue action

  • root_password – str The root password of the server in the rescue mode

class RequestConsoleResponse(action: BoundAction, wss_url: str, password: str)[source]

Request Console Response Domain

Parameters:
  • actionBoundAction Shows the progress of the server request console action

  • wss_url – str URL of websocket proxy to use. This includes a token which is valid for a limited time only.

  • password – str VNC password to use for this connection. This password only works in combination with a wss_url with valid token.