ServersClient
- class ServersClient(client: Client)[source]
- actions: ResourceActionsClient
Servers scoped actions client
- Type:
- add_to_placement_group(server: Server | BoundServer, placement_group: PlacementGroup | BoundPlacementGroup) BoundAction [source]
Adds a server to a placement group.
- Parameters:
server –
BoundServer
orServer
placement_group –
BoundPlacementGroup
orNetwork
- Returns:
- attach_iso(server: Server | BoundServer, iso: Iso | BoundIso) BoundAction [source]
Attaches an ISO to a server.
- Parameters:
server –
BoundServer
orServer
- Returns:
- 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:
server –
BoundServer
orServer
network –
BoundNetwork
orNetwork
ip – str IP to request to be assigned to this server
alias_ips – List[str] New alias IPs to set for this server.
- Returns:
- 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:
server –
BoundServer
orServer
network –
BoundNetwork
orNetwork
alias_ips – List[str] New alias IPs to set for this server.
- Returns:
- 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:
server –
BoundServer
orServer
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:
- change_protection(server: Server | BoundServer, delete: bool | None = None, rebuild: bool | None = None) BoundAction [source]
Changes the protection configuration of the server.
- Parameters:
server –
BoundServer
orServer
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:
- 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:
server –
BoundServer
orServer
server_type –
BoundServerType
orServerType
Server type the server should migrate toupgrade_disk – boolean If false, do not upgrade the disk. This allows downgrading the server type later.
- Returns:
- 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_type –
BoundServerType
orServerType
Server type this server should be created withimage –
BoundImage
orImage
Image the server is created fromssh_keys – List[
BoundSSHKey
orSSHKey
] (optional) SSH keys which should be injected into the server at creation timevolumes – List[
BoundVolume
orVolume
] (optional) Volumes which should be attached to the server at the creation time. Volumes must be in the same location.networks – List[
BoundNetwork
orNetwork
] (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)
location –
BoundLocation
orLocation
datacenter –
BoundDatacenter
orDatacenter
start_after_create – boolean (optional) Start Server right after creation. Defaults to True.
automount – boolean (optional) Auto mount volumes after attach.
placement_group –
BoundPlacementGroup
orLocation
Placement Group where server should be added during creationpublic_net –
ServerCreatePublicNetwork
Options to configure the public network of a server on creation
- Returns:
- 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:
server –
BoundServer
orServer
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:
- delete(server: Server | BoundServer) BoundAction [source]
Deletes a server. This immediately removes the server from your account, and it is no longer accessible.
- Parameters:
server –
BoundServer
orServer
- Returns:
- detach_from_network(server: Server | BoundServer, network: Network | BoundNetwork) BoundAction [source]
Detaches a server from a network.
- Parameters:
server –
BoundServer
orServer
network –
BoundNetwork
orNetwork
- Returns:
- detach_iso(server: Server | BoundServer) BoundAction [source]
Detaches an ISO from a server.
- Parameters:
server –
BoundServer
orServer
- Returns:
- disable_backup(server: Server | BoundServer) BoundAction [source]
Disables the automatic backup option and deletes all existing Backups for a Server.
- Parameters:
server –
BoundServer
orServer
- Returns:
- disable_rescue(server: Server | BoundServer) BoundAction [source]
Disables the Hetzner Rescue System for a server.
- Parameters:
server –
BoundServer
orServer
- Returns:
- 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:
server –
BoundServer
orServer
- Returns:
- 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:
server –
BoundServer
orServer
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:
- 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:
server –
BoundServer
orServer
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:
server –
BoundServer
orServer
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:
- get_by_name(name: str) BoundServer | None [source]
Get server by name
- Parameters:
name – str Used to get server by name.
- Returns:
- 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:
server –
BoundServer
orServer
- Returns:
- power_on(server: Server | BoundServer) BoundAction [source]
Starts a server by turning its power on.
- Parameters:
server –
BoundServer
orServer
- Returns:
- reboot(server: Server | BoundServer) BoundAction [source]
Reboots a server gracefully by sending an ACPI request.
- Parameters:
server –
BoundServer
orServer
- Returns:
- 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:
server –
BoundServer
orServer
- Returns:
- 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:
server –
BoundServer
orServer
- Returns:
- reset(server: Server | BoundServer) BoundAction [source]
Cuts power to a server and starts it again.
- Parameters:
server –
BoundServer
orServer
- Returns:
- reset_password(server: Server | BoundServer) ResetPasswordResponse [source]
Resets the root password. Only works for Linux systems that are running the qemu guest agent.
- Parameters:
server –
BoundServer
orServer
- Returns:
- shutdown(server: Server | BoundServer) BoundAction [source]
Shuts down a server gracefully by sending an ACPI shutdown request.
- Parameters:
server –
BoundServer
orServer
- Returns:
- 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:
server –
BoundServer
orServer
name – str (optional) New name to set
labels – Dict[str, str] (optional) User-defined labels (key-value pairs)
- Returns:
- 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_group –
BoundPlacementGroup
orNetwork
- Returns:
- attach_iso(iso: Iso | BoundIso) BoundAction [source]
Attaches an ISO to a server.
- Parameters:
- Returns:
- 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:
network –
BoundNetwork
orNetwork
ip – str IP to request to be assigned to this server
alias_ips – List[str] New alias IPs to set for this server.
- Returns:
- change_alias_ips(network: Network | BoundNetwork, alias_ips: list[str]) BoundAction [source]
Changes the alias IPs of an already attached network.
- Parameters:
network –
BoundNetwork
orNetwork
alias_ips – List[str] New alias IPs to set for this server.
- Returns:
- 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:
- change_protection(delete: bool | None = None, rebuild: bool | None = None) BoundAction [source]
Changes the protection configuration of the server.
- Parameters:
server –
BoundServer
orServer
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:
- change_type(server_type: ServerType | BoundServerType, upgrade_disk: bool) BoundAction [source]
Changes the type (Cores, RAM and disk sizes) of a server.
- Parameters:
server_type –
BoundServerType
orServerType
Server type the server should migrate toupgrade_disk – boolean If false, do not upgrade the disk. This allows downgrading the server type later.
- Returns:
- 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:
- delete() BoundAction [source]
Deletes a server. This immediately removes the server from your account, and it is no longer accessible.
- Returns:
- detach_from_network(network: Network | BoundNetwork) BoundAction [source]
Detaches a server from a network.
- Parameters:
network –
BoundNetwork
orNetwork
- Returns:
- detach_iso() BoundAction [source]
Detaches an ISO from a server.
- Returns:
- disable_backup() BoundAction [source]
Disables the automatic backup option and deletes all existing Backups for a Server.
- Returns:
- disable_rescue() BoundAction [source]
Disables the Hetzner Rescue System for a server.
- Returns:
- 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:
- 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:
- 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.
- power_off() BoundAction [source]
Cuts power to the server. This forcefully stops it without giving the server operating system time to gracefully stop
- Returns:
- power_on() BoundAction [source]
Starts a server by turning its power on.
- Returns:
- reboot() BoundAction [source]
Reboots a server gracefully by sending an ACPI request.
- Returns:
- 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:
- request_console() RequestConsoleResponse [source]
Requests credentials for remote access via vnc over websocket to keyboard, monitor, and mouse for a server.
- Returns:
- reset() BoundAction [source]
Cuts power to a server and starts it again.
- Returns:
- reset_password() ResetPasswordResponse [source]
Resets the root password. Only works for Linux systems that are running the qemu guest agent.
- Returns:
- shutdown() BoundAction [source]
Shuts down a server gracefully by sending an ACPI shutdown request.
- Returns:
- 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:
- 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_net –
PublicNetwork
Public network information.server_type –
BoundServerType
datacenter –
BoundDatacenter
image –
BoundImage
, Noneiso –
BoundIso
, Nonerescue_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:
ipv4 –
IPv4Address
ipv6 –
IPv6Network
floating_ips – List[
BoundFloatingIP
]primary_ipv4 –
BoundPrimaryIP
primary_ipv6 –
BoundPrimaryIP
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:
server –
BoundServer
The created serveraction –
BoundAction
Shows the progress of the server creationnext_actions – List[
BoundAction
] Additional actions like a start_server action after the server creationroot_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
- class ResetPasswordResponse(action: BoundAction, root_password: str)[source]
Reset Password Response Domain
- Parameters:
action –
BoundAction
Shows the progress of the server passwort reset actionroot_password – str The root password of the server
- class EnableRescueResponse(action: BoundAction, root_password: str)[source]
Enable Rescue Response Domain
- Parameters:
action –
BoundAction
Shows the progress of the server enable rescue actionroot_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:
action –
BoundAction
Shows the progress of the server request console actionwss_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.