To update a load balancer’s settings, send a PUT request to
/v2/load_balancers/$LOAD_BALANCER_ID
. The request should contain a full
representation of the load balancer including existing attributes. It may
contain one of the droplets_ids
or tag
attributes as they are mutually
exclusive. Note that any attribute that is not provided will be reset to its
default value.
Name | Type | Required | Description | Default Value |
---|---|---|---|---|
lb_id |
string | True | A unique identifier for a load balancer. | |
body |
JSON or IO[bytes] | True |
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"name": "updated-example-lb-01",
"region": "nyc3",
"droplet_ids": [
3164444,
3164445
],
"algorithm": "round_robin",
"forwarding_rules": [
{
"entry_protocol": "http",
"entry_port": 80,
"target_protocol": "http",
"target_port": 80,
"certificate_id": "",
"tls_passthrough": false
},
{
"entry_protocol": "https",
"entry_port": 443,
"target_protocol": "https",
"target_port": 443,
"certificate_id": "",
"tls_passthrough": true
}
],
"health_check": {
"protocol": "http",
"port": 80,
"path": "/",
"check_interval_seconds": 10,
"response_timeout_seconds": 5,
"healthy_threshold": 5,
"unhealthy_threshold": 3
},
"sticky_sessions": {
"type": "none"
},
"redirect_http_to_https": False,
"enable_proxy_protocol": True,
"enable_backend_keepalive": True,
"vpc_uuid": "c33931f2-a26a-4e61-b85c-4e95a2ec431b",
"project_id": "9cc10173-e9ea-4176-9dbc-a4cee4c4ff30",
"http_idle_timeout_seconds": 60,
"firewall": {
"deny": [
"cidr:1.2.0.0/16",
"ip:2.3.4.5"
],
"allow": [
"ip:1.2.3.4",
"cidr:2.3.4.0/24"
]
}
}
resp = client.load_balancers.update(lb_id="fda9fda", body=req)
See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.