LoadBalancerClient
- class LoadBalancersClient(client: Client)[source]
- actions: ResourceActionsClient
Load Balancers scoped actions client
- Type:
- add_service(load_balancer: LoadBalancer | BoundLoadBalancer, service: LoadBalancerService) BoundAction [source]
Adds a service to a Load Balancer.
- Parameters:
load_balancer –
BoundLoadBalancer
orLoadBalancer
service –
LoadBalancerService
The LoadBalancerService you want to add to the Load Balancer
- Returns:
- add_target(load_balancer: LoadBalancer | BoundLoadBalancer, target: LoadBalancerTarget) BoundAction [source]
Adds a target to a Load Balancer.
- Parameters:
load_balancer –
BoundLoadBalancer
orLoadBalancer
target –
LoadBalancerTarget
The LoadBalancerTarget you want to add to the Load Balancer
- Returns:
- attach_to_network(load_balancer: LoadBalancer | BoundLoadBalancer, network: Network | BoundNetwork, ip: str | None = None) BoundAction [source]
Attach a Load Balancer to a Network.
- Parameters:
load_balancer – :class:` <hcloud.load_balancers.client.BoundLoadBalancer>` or
LoadBalancer
network –
BoundNetwork
orNetwork
ip – str IP to request to be assigned to this Load Balancer
- Returns:
- change_algorithm(load_balancer: LoadBalancer | BoundLoadBalancer, algorithm: LoadBalancerAlgorithm) BoundAction [source]
Changes the algorithm used by the Load Balancer
- Parameters:
load_balancer – :class:` <hcloud.load_balancers.client.BoundLoadBalancer>` or
LoadBalancer
algorithm –
LoadBalancerAlgorithm
The LoadBalancerSubnet you want to add to the Load Balancer
- Returns:
- change_dns_ptr(load_balancer: LoadBalancer | BoundLoadBalancer, ip: str, dns_ptr: str) BoundAction [source]
Changes the hostname that will appear when getting the hostname belonging to the public IPs (IPv4 and IPv6) of this Load Balancer.
- Parameters:
ip – str The IP address for which to set the reverse DNS entry
dns_ptr – str Hostname to set as a reverse DNS PTR entry, will reset to original default value if None
- Returns:
- change_protection(load_balancer: LoadBalancer | BoundLoadBalancer, delete: bool | None = None) BoundAction [source]
Changes the protection configuration of a Load Balancer.
- Parameters:
load_balancer – :class:` <hcloud.load_balancers.client.BoundLoadBalancer>` or
LoadBalancer
delete – boolean If True, prevents the Load Balancer from being deleted
- Returns:
- change_type(load_balancer: LoadBalancer | BoundLoadBalancer, load_balancer_type: LoadBalancerType | BoundLoadBalancerType) BoundAction [source]
Changes the type of a Load Balancer.
- Parameters:
load_balancer –
BoundLoadBalancer
orLoadBalancer
load_balancer_type –
BoundLoadBalancerType
orLoadBalancerType
Load Balancer type the Load Balancer should migrate to
- Returns:
- create(name: str, load_balancer_type: LoadBalancerType | BoundLoadBalancerType, algorithm: LoadBalancerAlgorithm | None = None, services: list[LoadBalancerService] | None = None, targets: list[LoadBalancerTarget] | None = None, labels: dict[str, str] | None = None, location: Location | BoundLocation | None = None, network_zone: str | None = None, public_interface: bool | None = None, network: Network | BoundNetwork | None = None) CreateLoadBalancerResponse [source]
Creates a Load Balancer .
- Parameters:
name – str Name of the Load Balancer
load_balancer_type – LoadBalancerType Type of the Load Balancer
labels – Dict[str, str] (optional) User-defined labels (key-value pairs)
location – Location Location of the Load Balancer
network_zone – str Network Zone of the Load Balancer
algorithm – LoadBalancerAlgorithm (optional) The algorithm the Load Balancer is currently using
services – LoadBalancerService The services the Load Balancer is currently serving
targets – LoadBalancerTarget The targets the Load Balancer is currently serving
public_interface – bool Enable or disable the public interface of the Load Balancer
network – Network Adds the Load Balancer to a Network
- Returns:
CreateLoadBalancerResponse
- delete(load_balancer: LoadBalancer | BoundLoadBalancer) bool [source]
Deletes a Load Balancer.
- Parameters:
load_balancer –
BoundLoadBalancer
orLoadBalancer
- Returns:
boolean
- delete_service(load_balancer: LoadBalancer | BoundLoadBalancer, service: LoadBalancerService) BoundAction [source]
Deletes a service from a Load Balancer.
- Parameters:
load_balancer –
BoundLoadBalancer
orLoadBalancer
service –
LoadBalancerService
The LoadBalancerService you want to delete from the Load Balancer
- Returns:
- detach_from_network(load_balancer: LoadBalancer | BoundLoadBalancer, network: Network | BoundNetwork) BoundAction [source]
Detaches a Load Balancer from a Network.
- Parameters:
load_balancer – :class:` <hcloud.load_balancers.client.BoundLoadBalancer>` or
LoadBalancer
network –
BoundNetwork
orNetwork
- Returns:
- disable_public_interface(load_balancer: LoadBalancer | BoundLoadBalancer) BoundAction [source]
Disables the public interface of a Load Balancer.
- Parameters:
load_balancer – :class:` <hcloud.load_balancers.client.BoundLoadBalancer>` or
LoadBalancer
- Returns:
- enable_public_interface(load_balancer: LoadBalancer | BoundLoadBalancer) BoundAction [source]
Enables the public interface of a Load Balancer.
- Parameters:
load_balancer – :class:` <hcloud.load_balancers.client.BoundLoadBalancer>` or
LoadBalancer
- Returns:
- get_actions(load_balancer: LoadBalancer | BoundLoadBalancer, status: list[str] | None = None, sort: list[str] | None = None) list[BoundAction] [source]
Returns all action objects for a Load Balancer.
- Parameters:
load_balancer –
BoundLoadBalancer
orLoadBalancer
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(load_balancer: LoadBalancer | BoundLoadBalancer, 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 Load Balancer.
- Parameters:
load_balancer –
BoundLoadBalancer
orLoadBalancer
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) list[BoundLoadBalancer] [source]
Get all Load Balancers from this account
- Parameters:
name – str (optional) Can be used to filter Load Balancers by their name.
label_selector – str (optional) Can be used to filter Load Balancers by labels. The response will only contain Load Balancers matching the label selector.
- Returns:
List[
BoundLoadBalancer
]
- get_by_id(id: int) BoundLoadBalancer [source]
Get a specific Load Balancer
- Parameters:
id – int
- Returns:
- get_by_name(name: str) BoundLoadBalancer | None [source]
Get Load Balancer by name
- Parameters:
name – str Used to get Load Balancer by name.
- Returns:
- get_list(name: str | None = None, label_selector: str | None = None, page: int | None = None, per_page: int | None = None) LoadBalancersPageResult [source]
Get a list of Load Balancers from this account
- Parameters:
name – str (optional) Can be used to filter Load Balancers by their name.
label_selector – str (optional) Can be used to filter Load Balancers by labels. The response will only contain Load Balancers matching the label selector.
page – int (optional) Specifies the page to fetch
per_page – int (optional) Specifies how many results are returned by page
- Returns:
(List[
BoundLoadBalancer
],Meta
)
- get_metrics(load_balancer: LoadBalancer | BoundLoadBalancer, type: Literal['open_connections', 'connections_per_second', 'requests_per_second', 'bandwidth'] | list[Literal['open_connections', 'connections_per_second', 'requests_per_second', 'bandwidth']], start: datetime | str, end: datetime | str, step: float | None = None) GetMetricsResponse [source]
Get Metrics for a LoadBalancer.
- Parameters:
load_balancer – The Load Balancer 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.
- remove_target(load_balancer: LoadBalancer | BoundLoadBalancer, target: LoadBalancerTarget) BoundAction [source]
Removes a target from a Load Balancer.
- Parameters:
load_balancer –
BoundLoadBalancer
orLoadBalancer
target –
LoadBalancerTarget
The LoadBalancerTarget you want to remove from the Load Balancer
- Returns:
- update(load_balancer: LoadBalancer | BoundLoadBalancer, name: str | None = None, labels: dict[str, str] | None = None) BoundLoadBalancer [source]
Updates a LoadBalancer. You can update a LoadBalancer’s name and a LoadBalancer’s labels.
- Parameters:
load_balancer –
BoundLoadBalancer
orLoadBalancer
name – str (optional) New name to set
labels – Dict[str, str] (optional) User-defined labels (key-value pairs)
- Returns:
- update_service(load_balancer: LoadBalancer | BoundLoadBalancer, service: LoadBalancerService) BoundAction [source]
Updates a service of an Load Balancer.
- Parameters:
load_balancer –
BoundLoadBalancer
orLoadBalancer
service –
LoadBalancerService
The LoadBalancerService with updated values within for the Load Balancer
- Returns:
- class BoundLoadBalancer(client: LoadBalancersClient, data: dict, complete: bool = True)[source]
- add_service(service: LoadBalancerService) BoundAction [source]
Adds a service to a Load Balancer.
- Parameters:
service –
LoadBalancerService
The LoadBalancerService you want to add to the Load Balancer- Returns:
- add_target(target: LoadBalancerTarget) BoundAction [source]
Adds a target to a Load Balancer.
- Parameters:
target –
LoadBalancerTarget
The LoadBalancerTarget you want to add to the Load Balancer- Returns:
- attach_to_network(network: Network | BoundNetwork, ip: str | None = None) BoundAction [source]
Attaches a Load Balancer to a Network
- Parameters:
network –
BoundNetwork
orNetwork
ip – str IP to request to be assigned to this Load Balancer
- Returns:
- change_algorithm(algorithm: LoadBalancerAlgorithm) BoundAction [source]
Changes the algorithm used by the Load Balancer
- Parameters:
algorithm –
LoadBalancerAlgorithm
The LoadBalancerAlgorithm you want to use- Returns:
- change_dns_ptr(ip: str, dns_ptr: str) BoundAction [source]
Changes the hostname that will appear when getting the hostname belonging to the public IPs (IPv4 and IPv6) of this Load Balancer.
- Parameters:
ip – str The IP address for which to set the reverse DNS entry
dns_ptr – str Hostname to set as a reverse DNS PTR entry, will reset to original default value if None
- Returns:
- change_protection(delete: bool) BoundAction [source]
Changes the protection configuration of a Load Balancer.
- Parameters:
delete – boolean If True, prevents the Load Balancer from being deleted
- Returns:
- change_type(load_balancer_type: LoadBalancerType | BoundLoadBalancerType) BoundAction [source]
Changes the type of a Load Balancer.
- Parameters:
load_balancer_type –
BoundLoadBalancerType
orLoadBalancerType
Load Balancer type the Load Balancer should migrate to- Returns:
- delete_service(service: LoadBalancerService) BoundAction [source]
Deletes a service from a Load Balancer.
- Parameters:
service –
LoadBalancerService
The LoadBalancerService you want to delete from the Load Balancer- Returns:
- detach_from_network(network: Network | BoundNetwork) BoundAction [source]
Detaches a Load Balancer from a Network.
- Parameters:
network –
BoundNetwork
orNetwork
- Returns:
- disable_public_interface() BoundAction [source]
Disables the public interface of a Load Balancer.
- Returns:
- enable_public_interface() BoundAction [source]
Enables the public interface of a Load Balancer.
- Returns:
- get_actions(status: list[str] | None = None, sort: list[str] | None = None) list[BoundAction] [source]
Returns all action objects for a Load Balancer.
- 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 Load Balancer.
- 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['open_connections', 'connections_per_second', 'requests_per_second', 'bandwidth'], start: datetime | str, end: datetime | str, step: float | None = None) GetMetricsResponse [source]
Get Metrics for a LoadBalancer.
- Parameters:
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
LoadBalancer
- remove_target(target: LoadBalancerTarget) BoundAction [source]
Removes a target from a Load Balancer.
- Parameters:
target –
LoadBalancerTarget
The LoadBalancerTarget you want to remove from the Load Balancer- Returns:
- update(name: str | None = None, labels: dict[str, str] | None = None) BoundLoadBalancer [source]
Updates a Load Balancer. You can update a Load Balancers name and a Load Balancers labels.
- Parameters:
name – str (optional) New name to set
labels – Dict[str, str] (optional) User-defined labels (key-value pairs)
- Returns:
- update_service(service: LoadBalancerService) BoundAction [source]
Updates a service of an Load Balancer.
- Parameters:
service –
LoadBalancerService
The LoadBalancerService you want to update- Returns:
- class LoadBalancer(id: int, name: str | None = None, public_net: PublicNetwork | None = None, private_net: list[PrivateNet] | None = None, location: BoundLocation | None = None, algorithm: LoadBalancerAlgorithm | None = None, services: list[LoadBalancerService] | None = None, load_balancer_type: BoundLoadBalancerType | None = None, protection: dict | None = None, labels: dict[str, str] | None = None, targets: list[LoadBalancerTarget] | None = None, created: str | None = None, outgoing_traffic: int | None = None, ingoing_traffic: int | None = None, included_traffic: int | None = None)[source]
LoadBalancer Domain
- Parameters:
id – int ID of the Load Balancer
name – str Name of the Load Balancer (must be unique per project)
created – datetime Point in time when the Load Balancer was created
protection – dict Protection configuration for the Load Balancer
labels – dict User-defined labels (key-value pairs)
location – Location Location of the Load Balancer
public_net –
PublicNetwork
Public network information.private_net – List[
PrivateNet <hcloud.load_balancers.domain.PrivateNet
] Private networks information.algorithm – LoadBalancerAlgorithm The algorithm the Load Balancer is currently using
services – List[LoadBalancerService] The services the LoadBalancer is currently serving
targets – LoadBalancerTarget The targets the LoadBalancer is currently serving
load_balancer_type – LoadBalancerType The type of the Load Balancer
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
- class LoadBalancerService(protocol: str | None = None, listen_port: int | None = None, destination_port: int | None = None, proxyprotocol: bool | None = None, health_check: LoadBalancerHealthCheck | None = None, http: LoadBalancerServiceHttp | None = None)[source]
LoadBalancerService Domain
- Parameters:
protocol – str Protocol of the service Choices: tcp, http, https
listen_port – int Required when protocol is tcp, must be unique per Load Balancer.
destination_port – int Required when protocol is tcp
proxyprotocol – bool Enable proxyprotocol
health_check – LoadBalancerHealthCheck Configuration for health checks
http – LoadBalancerServiceHttp Configuration for http/https protocols, required when protocol is http/https
- class LoadBalancerServiceHttp(cookie_name: str | None = None, cookie_lifetime: str | None = None, certificates: list[BoundCertificate] | None = None, redirect_http: bool | None = None, sticky_sessions: bool | None = None)[source]
LoadBalancerServiceHttp Domain
- Parameters:
cookie_name – str Name of the cookie used for Session Stickness
cookie_lifetime – str Lifetime of the cookie used for Session Stickness
certificates – list IDs of the Certificates to use for TLS/SSL termination by the Load Balancer; empty for TLS/SSL passthrough or if protocol is “http”
redirect_http – bool Redirect traffic from http port 80 to port 443
sticky_sessions – bool Use sticky sessions. Only available if protocol is “http” or “https”.
- class LoadBalancerHealthCheck(protocol: str | None = None, port: int | None = None, interval: int | None = None, timeout: int | None = None, retries: int | None = None, http: LoadBalancerHealtCheckHttp | None = None)[source]
LoadBalancerHealthCheck Domain
- Parameters:
protocol – str Protocol of the service Choices: tcp, http, https
port – int Port the healthcheck will be performed on
interval – int Interval we trigger health check in
timeout – int Timeout in sec after a try is assumed as timeout
retries – int Retries we perform until we assume a target as unhealthy
http – LoadBalancerHealtCheckHttp HTTP Config
- class LoadBalancerHealtCheckHttp(domain: str | None = None, path: str | None = None, response: str | None = None, status_codes: list | None = None, tls: bool | None = None)[source]
LoadBalancerHealtCheckHttp Domain
- Parameters:
domain – str Domain name to send in HTTP request. Can be null: In that case we will not send a domain name
path – str HTTP Path send in Request
response – str Optional HTTP response to receive in order to pass the health check
status_codes – list List of HTTP status codes to receive in order to pass the health check
tls – bool Type of health check
- class LoadBalancerTarget(type: str | None = None, server: BoundServer | None = None, label_selector: LoadBalancerTargetLabelSelector | None = None, ip: LoadBalancerTargetIP | None = None, use_private_ip: bool | None = None, health_status: list[LoadBalancerTargetHealthStatus] | None = None)[source]
LoadBalancerTarget Domain
- Parameters:
type – str Type of the resource, can be server or label_selector
server – Server Target server
label_selector – LoadBalancerTargetLabelSelector Target label selector
ip – LoadBalancerTargetIP Target IP
use_private_ip – bool use the private IP instead of primary public IP
health_status – list List of health statuses of the services on this target. Only present for target types “server” and “ip”.
- class LoadBalancerTargetHealthStatus(listen_port: int | None = None, status: str | None = None)[source]
LoadBalancerTargetHealthStatus Domain
- Parameters:
listen_port – Load Balancer Target listen port
status – Load Balancer Target status. Choices: healthy, unhealthy, unknown
- class LoadBalancerTargetLabelSelector(selector: str | None = None)[source]
LoadBalancerTargetLabelSelector Domain
- Parameters:
selector – str Target label selector