# Load Balancers ## Create `gpu_droplets.load_balancers.create(LoadBalancerCreateParams**kwargs) -> LoadBalancerCreateResponse` **post** `/v2/load_balancers` To create a new load balancer instance, send a POST request to `/v2/load_balancers`. You can specify the Droplets that will sit behind the load balancer using one of two methods: * Set `droplet_ids` to a list of specific Droplet IDs. * Set `tag` to the name of a tag. All Droplets with this tag applied will be assigned to the load balancer. Additional Droplets will be automatically assigned as they are tagged. These methods are mutually exclusive. ### Parameters - **forwarding\_rules:** `Iterable[ForwardingRuleParam]` An array of objects specifying the forwarding rules for a load balancer. - **entry\_port:** `int` An integer representing the port on which the load balancer instance will listen. - **entry\_protocol:** `Literal["http", "https", "http2", 3 more]` The protocol used for traffic to the load balancer. The possible values are: `http`, `https`, `http2`, `http3`, `tcp`, or `udp`. If you set the `entry_protocol` to `udp`, the `target_protocol` must be set to `udp`. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly. - `"http"` - `"https"` - `"http2"` - `"http3"` - `"tcp"` - `"udp"` - **target\_port:** `int` An integer representing the port on the backend Droplets to which the load balancer will send traffic. - **target\_protocol:** `Literal["http", "https", "http2", 2 more]` The protocol used for traffic from the load balancer to the backend Droplets. The possible values are: `http`, `https`, `http2`, `tcp`, or `udp`. If you set the `target_protocol` to `udp`, the `entry_protocol` must be set to `udp`. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly. - `"http"` - `"https"` - `"http2"` - `"tcp"` - `"udp"` - **certificate\_id:** `Optional[str]` The ID of the TLS certificate used for SSL termination if enabled. - **tls\_passthrough:** `Optional[bool]` A boolean value indicating whether SSL encrypted traffic will be passed through to the backend Droplets. - **algorithm:** `Literal["round_robin", "least_connections"]` This field has been deprecated. You can no longer specify an algorithm for load balancers. - `"round_robin"` - `"least_connections"` - **disable\_lets\_encrypt\_dns\_records:** `bool` A boolean value indicating whether to disable automatic DNS record creation for Let's Encrypt certificates that are added to the load balancer. - **domains:** `Iterable[DomainsParam]` An array of objects specifying the domain configurations for a Global load balancer. - **certificate\_id:** `Optional[str]` The ID of the TLS certificate used for SSL termination. - **is\_managed:** `Optional[bool]` A boolean value indicating if the domain is already managed by DigitalOcean. If true, all A and AAAA records required to enable Global load balancers will be automatically added. - **name:** `Optional[str]` FQDN to associate with a Global load balancer. - **droplet\_ids:** `Iterable[int]` An array containing the IDs of the Droplets assigned to the load balancer. - **enable\_backend\_keepalive:** `bool` A boolean value indicating whether HTTP keepalive connections are maintained to target Droplets. - **enable\_proxy\_protocol:** `bool` A boolean value indicating whether PROXY Protocol is in use. - **firewall:** `LbFirewallParam` An object specifying allow and deny rules to control traffic to the load balancer. - **glb\_settings:** `GlbSettingsParam` An object specifying forwarding configurations for a Global load balancer. - **health\_check:** `HealthCheckParam` An object specifying health check settings for the load balancer. - **http\_idle\_timeout\_seconds:** `int` An integer value which configures the idle timeout for HTTP requests to the target droplets. - **name:** `str` A human-readable name for a load balancer instance. - **network:** `Literal["EXTERNAL", "INTERNAL"]` A string indicating whether the load balancer should be external or internal. Internal load balancers have no public IPs and are only accessible to resources on the same VPC network. This property cannot be updated after creating the load balancer. - `"EXTERNAL"` - `"INTERNAL"` - **network\_stack:** `Literal["IPV4", "DUALSTACK"]` A string indicating whether the load balancer will support IPv4 or both IPv4 and IPv6 networking. This property cannot be updated after creating the load balancer. - `"IPV4"` - `"DUALSTACK"` - **project\_id:** `str` The ID of the project that the load balancer is associated with. If no ID is provided at creation, the load balancer associates with the user's default project. If an invalid project ID is provided, the load balancer will not be created. - **redirect\_http\_to\_https:** `bool` A boolean value indicating whether HTTP requests to the load balancer on port 80 will be redirected to HTTPS on port 443. - **region:** `Literal["ams1", "ams2", "ams3", 12 more]` The slug identifier for the region where the resource will initially be available. - `"ams1"` - `"ams2"` - `"ams3"` - `"blr1"` - `"fra1"` - `"lon1"` - `"nyc1"` - `"nyc2"` - `"nyc3"` - `"sfo1"` - `"sfo2"` - `"sfo3"` - `"sgp1"` - `"tor1"` - `"syd1"` - **size:** `Literal["lb-small", "lb-medium", "lb-large"]` This field has been replaced by the `size_unit` field for all regions except in AMS2, NYC2, and SFO1. Each available load balancer size now equates to the load balancer having a set number of nodes. * `lb-small` = 1 node * `lb-medium` = 3 nodes * `lb-large` = 6 nodes You can resize load balancers after creation up to once per hour. You cannot resize a load balancer within the first hour of its creation. - `"lb-small"` - `"lb-medium"` - `"lb-large"` - **size\_unit:** `int` How many nodes the load balancer contains. Each additional node increases the load balancer's ability to manage more connections. Load balancers can be scaled up or down, and you can change the number of nodes after creation up to once per hour. This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use the `size` field to scale load balancers that reside in these regions. - **sticky\_sessions:** `StickySessionsParam` An object specifying sticky sessions settings for the load balancer. - **target\_load\_balancer\_ids:** `List[str]` An array containing the UUIDs of the Regional load balancers to be used as target backends for a Global load balancer. - **tls\_cipher\_policy:** `Literal["DEFAULT", "STRONG"]` A string indicating the policy for the TLS cipher suites used by the load balancer. The possible values are `DEFAULT` or `STRONG`. The default value is `DEFAULT`. - `"DEFAULT"` - `"STRONG"` - **type:** `Literal["REGIONAL", "REGIONAL_NETWORK", "GLOBAL"]` A string indicating whether the load balancer should be a standard regional HTTP load balancer, a regional network load balancer that routes traffic at the TCP/UDP transport layer, or a global load balancer. - `"REGIONAL"` - `"REGIONAL_NETWORK"` - `"GLOBAL"` - **vpc\_uuid:** `str` A string specifying the UUID of the VPC to which the load balancer is assigned. ### Returns - `class LoadBalancerCreateResponse` - **load\_balancer:** `Optional[LoadBalancer]` ### Example ```python from gradient import Gradient client = Gradient() load_balancer = client.gpu_droplets.load_balancers.create( forwarding_rules=[{ "entry_protocol": "http", "entry_port": 80, "target_protocol": "http", "target_port": 80, }, { "entry_protocol": "https", "entry_port": 443, "target_protocol": "https", "target_port": 443, "tls_passthrough": True, }], droplet_ids=[3164444, 3164445], 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"], }, http_idle_timeout_seconds=60, name="example-lb-01", project_id="9cc10173-e9ea-4176-9dbc-a4cee4c4ff30", region="nyc3", ) print(load_balancer.load_balancer) ``` ## Retrieve `gpu_droplets.load_balancers.retrieve(strlb_id) -> LoadBalancerRetrieveResponse` **get** `/v2/load_balancers/{lb_id}` To show information about a load balancer instance, send a GET request to `/v2/load_balancers/$LOAD_BALANCER_ID`. ### Parameters - **lb\_id:** `str` ### Returns - `class LoadBalancerRetrieveResponse` - **load\_balancer:** `Optional[LoadBalancer]` ### Example ```python from gradient import Gradient client = Gradient() load_balancer = client.gpu_droplets.load_balancers.retrieve( "lb_id", ) print(load_balancer.load_balancer) ``` ## Update `gpu_droplets.load_balancers.update(strlb_id, LoadBalancerUpdateParams**kwargs) -> LoadBalancerUpdateResponse` **put** `/v2/load_balancers/{lb_id}` 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.** ### Parameters - **lb\_id:** `str` - **forwarding\_rules:** `Iterable[ForwardingRuleParam]` An array of objects specifying the forwarding rules for a load balancer. - **entry\_port:** `int` An integer representing the port on which the load balancer instance will listen. - **entry\_protocol:** `Literal["http", "https", "http2", 3 more]` The protocol used for traffic to the load balancer. The possible values are: `http`, `https`, `http2`, `http3`, `tcp`, or `udp`. If you set the `entry_protocol` to `udp`, the `target_protocol` must be set to `udp`. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly. - `"http"` - `"https"` - `"http2"` - `"http3"` - `"tcp"` - `"udp"` - **target\_port:** `int` An integer representing the port on the backend Droplets to which the load balancer will send traffic. - **target\_protocol:** `Literal["http", "https", "http2", 2 more]` The protocol used for traffic from the load balancer to the backend Droplets. The possible values are: `http`, `https`, `http2`, `tcp`, or `udp`. If you set the `target_protocol` to `udp`, the `entry_protocol` must be set to `udp`. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly. - `"http"` - `"https"` - `"http2"` - `"tcp"` - `"udp"` - **certificate\_id:** `Optional[str]` The ID of the TLS certificate used for SSL termination if enabled. - **tls\_passthrough:** `Optional[bool]` A boolean value indicating whether SSL encrypted traffic will be passed through to the backend Droplets. - **algorithm:** `Literal["round_robin", "least_connections"]` This field has been deprecated. You can no longer specify an algorithm for load balancers. - `"round_robin"` - `"least_connections"` - **disable\_lets\_encrypt\_dns\_records:** `bool` A boolean value indicating whether to disable automatic DNS record creation for Let's Encrypt certificates that are added to the load balancer. - **domains:** `Iterable[DomainsParam]` An array of objects specifying the domain configurations for a Global load balancer. - **certificate\_id:** `Optional[str]` The ID of the TLS certificate used for SSL termination. - **is\_managed:** `Optional[bool]` A boolean value indicating if the domain is already managed by DigitalOcean. If true, all A and AAAA records required to enable Global load balancers will be automatically added. - **name:** `Optional[str]` FQDN to associate with a Global load balancer. - **droplet\_ids:** `Iterable[int]` An array containing the IDs of the Droplets assigned to the load balancer. - **enable\_backend\_keepalive:** `bool` A boolean value indicating whether HTTP keepalive connections are maintained to target Droplets. - **enable\_proxy\_protocol:** `bool` A boolean value indicating whether PROXY Protocol is in use. - **firewall:** `LbFirewallParam` An object specifying allow and deny rules to control traffic to the load balancer. - **glb\_settings:** `GlbSettingsParam` An object specifying forwarding configurations for a Global load balancer. - **health\_check:** `HealthCheckParam` An object specifying health check settings for the load balancer. - **http\_idle\_timeout\_seconds:** `int` An integer value which configures the idle timeout for HTTP requests to the target droplets. - **name:** `str` A human-readable name for a load balancer instance. - **network:** `Literal["EXTERNAL", "INTERNAL"]` A string indicating whether the load balancer should be external or internal. Internal load balancers have no public IPs and are only accessible to resources on the same VPC network. This property cannot be updated after creating the load balancer. - `"EXTERNAL"` - `"INTERNAL"` - **network\_stack:** `Literal["IPV4", "DUALSTACK"]` A string indicating whether the load balancer will support IPv4 or both IPv4 and IPv6 networking. This property cannot be updated after creating the load balancer. - `"IPV4"` - `"DUALSTACK"` - **project\_id:** `str` The ID of the project that the load balancer is associated with. If no ID is provided at creation, the load balancer associates with the user's default project. If an invalid project ID is provided, the load balancer will not be created. - **redirect\_http\_to\_https:** `bool` A boolean value indicating whether HTTP requests to the load balancer on port 80 will be redirected to HTTPS on port 443. - **region:** `Literal["ams1", "ams2", "ams3", 12 more]` The slug identifier for the region where the resource will initially be available. - `"ams1"` - `"ams2"` - `"ams3"` - `"blr1"` - `"fra1"` - `"lon1"` - `"nyc1"` - `"nyc2"` - `"nyc3"` - `"sfo1"` - `"sfo2"` - `"sfo3"` - `"sgp1"` - `"tor1"` - `"syd1"` - **size:** `Literal["lb-small", "lb-medium", "lb-large"]` This field has been replaced by the `size_unit` field for all regions except in AMS2, NYC2, and SFO1. Each available load balancer size now equates to the load balancer having a set number of nodes. * `lb-small` = 1 node * `lb-medium` = 3 nodes * `lb-large` = 6 nodes You can resize load balancers after creation up to once per hour. You cannot resize a load balancer within the first hour of its creation. - `"lb-small"` - `"lb-medium"` - `"lb-large"` - **size\_unit:** `int` How many nodes the load balancer contains. Each additional node increases the load balancer's ability to manage more connections. Load balancers can be scaled up or down, and you can change the number of nodes after creation up to once per hour. This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use the `size` field to scale load balancers that reside in these regions. - **sticky\_sessions:** `StickySessionsParam` An object specifying sticky sessions settings for the load balancer. - **target\_load\_balancer\_ids:** `List[str]` An array containing the UUIDs of the Regional load balancers to be used as target backends for a Global load balancer. - **tls\_cipher\_policy:** `Literal["DEFAULT", "STRONG"]` A string indicating the policy for the TLS cipher suites used by the load balancer. The possible values are `DEFAULT` or `STRONG`. The default value is `DEFAULT`. - `"DEFAULT"` - `"STRONG"` - **type:** `Literal["REGIONAL", "REGIONAL_NETWORK", "GLOBAL"]` A string indicating whether the load balancer should be a standard regional HTTP load balancer, a regional network load balancer that routes traffic at the TCP/UDP transport layer, or a global load balancer. - `"REGIONAL"` - `"REGIONAL_NETWORK"` - `"GLOBAL"` - **vpc\_uuid:** `str` A string specifying the UUID of the VPC to which the load balancer is assigned. ### Returns - `class LoadBalancerUpdateResponse` - **load\_balancer:** `Optional[LoadBalancer]` ### Example ```python from gradient import Gradient client = Gradient() load_balancer = client.gpu_droplets.load_balancers.update( lb_id="4de7ac8b-495b-4884-9a69-1050c6793cd6", 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, }], algorithm="round_robin", droplet_ids=[3164444, 3164445], enable_backend_keepalive=True, enable_proxy_protocol=True, 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"], }, health_check={ "protocol": "http", "port": 80, "path": "/", "check_interval_seconds": 10, "response_timeout_seconds": 5, "healthy_threshold": 5, "unhealthy_threshold": 3, }, http_idle_timeout_seconds=60, name="updated-example-lb-01", project_id="9cc10173-e9ea-4176-9dbc-a4cee4c4ff30", redirect_http_to_https=False, region="nyc3", sticky_sessions={ "type": "none" }, vpc_uuid="c33931f2-a26a-4e61-b85c-4e95a2ec431b", ) print(load_balancer.load_balancer) ``` ## List `gpu_droplets.load_balancers.list(LoadBalancerListParams**kwargs) -> LoadBalancerListResponse` **get** `/v2/load_balancers` To list all of the load balancer instances on your account, send a GET request to `/v2/load_balancers`. ### Parameters - **page:** `int` Which 'page' of paginated results to return. - **per\_page:** `int` Number of items returned per page ### Returns - `class LoadBalancerListResponse` - **meta:** `MetaProperties` Information about the response itself. - **links:** `Optional[PageLinks]` - **load\_balancers:** `Optional[List[LoadBalancer]]` - **forwarding\_rules:** `List[ForwardingRule]` An array of objects specifying the forwarding rules for a load balancer. - **entry\_port:** `int` An integer representing the port on which the load balancer instance will listen. - **entry\_protocol:** `Literal["http", "https", "http2", 3 more]` The protocol used for traffic to the load balancer. The possible values are: `http`, `https`, `http2`, `http3`, `tcp`, or `udp`. If you set the `entry_protocol` to `udp`, the `target_protocol` must be set to `udp`. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly. - `"http"` - `"https"` - `"http2"` - `"http3"` - `"tcp"` - `"udp"` - **target\_port:** `int` An integer representing the port on the backend Droplets to which the load balancer will send traffic. - **target\_protocol:** `Literal["http", "https", "http2", 2 more]` The protocol used for traffic from the load balancer to the backend Droplets. The possible values are: `http`, `https`, `http2`, `tcp`, or `udp`. If you set the `target_protocol` to `udp`, the `entry_protocol` must be set to `udp`. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly. - `"http"` - `"https"` - `"http2"` - `"tcp"` - `"udp"` - **certificate\_id:** `Optional[str]` The ID of the TLS certificate used for SSL termination if enabled. - **tls\_passthrough:** `Optional[bool]` A boolean value indicating whether SSL encrypted traffic will be passed through to the backend Droplets. - **id:** `Optional[str]` A unique ID that can be used to identify and reference a load balancer. - **algorithm:** `Optional[Literal["round_robin", "least_connections"]]` This field has been deprecated. You can no longer specify an algorithm for load balancers. - `"round_robin"` - `"least_connections"` - **created\_at:** `Optional[datetime]` A time value given in ISO8601 combined date and time format that represents when the load balancer was created. - **disable\_lets\_encrypt\_dns\_records:** `Optional[bool]` A boolean value indicating whether to disable automatic DNS record creation for Let's Encrypt certificates that are added to the load balancer. - **domains:** `Optional[List[Domains]]` An array of objects specifying the domain configurations for a Global load balancer. - **certificate\_id:** `Optional[str]` The ID of the TLS certificate used for SSL termination. - **is\_managed:** `Optional[bool]` A boolean value indicating if the domain is already managed by DigitalOcean. If true, all A and AAAA records required to enable Global load balancers will be automatically added. - **name:** `Optional[str]` FQDN to associate with a Global load balancer. - **droplet\_ids:** `Optional[List[int]]` An array containing the IDs of the Droplets assigned to the load balancer. - **enable\_backend\_keepalive:** `Optional[bool]` A boolean value indicating whether HTTP keepalive connections are maintained to target Droplets. - **enable\_proxy\_protocol:** `Optional[bool]` A boolean value indicating whether PROXY Protocol is in use. - **firewall:** `Optional[LbFirewall]` An object specifying allow and deny rules to control traffic to the load balancer. - **glb\_settings:** `Optional[GlbSettings]` An object specifying forwarding configurations for a Global load balancer. - **health\_check:** `Optional[HealthCheck]` An object specifying health check settings for the load balancer. - **http\_idle\_timeout\_seconds:** `Optional[int]` An integer value which configures the idle timeout for HTTP requests to the target droplets. - **ip:** `Optional[str]` An attribute containing the public-facing IP address of the load balancer. - **ipv6:** `Optional[str]` An attribute containing the public-facing IPv6 address of the load balancer. - **name:** `Optional[str]` A human-readable name for a load balancer instance. - **network:** `Optional[Literal["EXTERNAL", "INTERNAL"]]` A string indicating whether the load balancer should be external or internal. Internal load balancers have no public IPs and are only accessible to resources on the same VPC network. This property cannot be updated after creating the load balancer. - `"EXTERNAL"` - `"INTERNAL"` - **network\_stack:** `Optional[Literal["IPV4", "DUALSTACK"]]` A string indicating whether the load balancer will support IPv4 or both IPv4 and IPv6 networking. This property cannot be updated after creating the load balancer. - `"IPV4"` - `"DUALSTACK"` - **project\_id:** `Optional[str]` The ID of the project that the load balancer is associated with. If no ID is provided at creation, the load balancer associates with the user's default project. If an invalid project ID is provided, the load balancer will not be created. - **redirect\_http\_to\_https:** `Optional[bool]` A boolean value indicating whether HTTP requests to the load balancer on port 80 will be redirected to HTTPS on port 443. - **region:** `Optional[Region]` The region where the load balancer instance is located. When setting a region, the value should be the slug identifier for the region. When you query a load balancer, an entire region object will be returned. - **size:** `Optional[Literal["lb-small", "lb-medium", "lb-large"]]` This field has been replaced by the `size_unit` field for all regions except in AMS2, NYC2, and SFO1. Each available load balancer size now equates to the load balancer having a set number of nodes. * `lb-small` = 1 node * `lb-medium` = 3 nodes * `lb-large` = 6 nodes You can resize load balancers after creation up to once per hour. You cannot resize a load balancer within the first hour of its creation. - `"lb-small"` - `"lb-medium"` - `"lb-large"` - **size\_unit:** `Optional[int]` How many nodes the load balancer contains. Each additional node increases the load balancer's ability to manage more connections. Load balancers can be scaled up or down, and you can change the number of nodes after creation up to once per hour. This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use the `size` field to scale load balancers that reside in these regions. - **status:** `Optional[Literal["new", "active", "errored"]]` A status string indicating the current state of the load balancer. This can be `new`, `active`, or `errored`. - `"new"` - `"active"` - `"errored"` - **sticky\_sessions:** `Optional[StickySessions]` An object specifying sticky sessions settings for the load balancer. - **tag:** `Optional[str]` The name of a Droplet tag corresponding to Droplets assigned to the load balancer. - **target\_load\_balancer\_ids:** `Optional[List[str]]` An array containing the UUIDs of the Regional load balancers to be used as target backends for a Global load balancer. - **tls\_cipher\_policy:** `Optional[Literal["DEFAULT", "STRONG"]]` A string indicating the policy for the TLS cipher suites used by the load balancer. The possible values are `DEFAULT` or `STRONG`. The default value is `DEFAULT`. - `"DEFAULT"` - `"STRONG"` - **type:** `Optional[Literal["REGIONAL", "REGIONAL_NETWORK", "GLOBAL"]]` A string indicating whether the load balancer should be a standard regional HTTP load balancer, a regional network load balancer that routes traffic at the TCP/UDP transport layer, or a global load balancer. - `"REGIONAL"` - `"REGIONAL_NETWORK"` - `"GLOBAL"` - **vpc\_uuid:** `Optional[str]` A string specifying the UUID of the VPC to which the load balancer is assigned. ### Example ```python from gradient import Gradient client = Gradient() load_balancers = client.gpu_droplets.load_balancers.list() print(load_balancers.meta) ``` ## Delete `gpu_droplets.load_balancers.delete(strlb_id)` **delete** `/v2/load_balancers/{lb_id}` To delete a load balancer instance, disassociating any Droplets assigned to it and removing it from your account, send a DELETE request to `/v2/load_balancers/$LOAD_BALANCER_ID`. A successful request will receive a 204 status code with no body in response. This indicates that the request was processed successfully. ### Parameters - **lb\_id:** `str` ### Example ```python from gradient import Gradient client = Gradient() client.gpu_droplets.load_balancers.delete( "lb_id", ) ``` ## Delete Cache `gpu_droplets.load_balancers.delete_cache(strlb_id)` **delete** `/v2/load_balancers/{lb_id}/cache` To delete a Global load balancer CDN cache, send a DELETE request to `/v2/load_balancers/$LOAD_BALANCER_ID/cache`. A successful request will receive a 204 status code with no body in response. This indicates that the request was processed successfully. ### Parameters - **lb\_id:** `str` ### Example ```python from gradient import Gradient client = Gradient() client.gpu_droplets.load_balancers.delete_cache( "lb_id", ) ``` ## Domain Types ### Domains - `class Domains` An object specifying domain configurations for a Global load balancer. - **certificate\_id:** `Optional[str]` The ID of the TLS certificate used for SSL termination. - **is\_managed:** `Optional[bool]` A boolean value indicating if the domain is already managed by DigitalOcean. If true, all A and AAAA records required to enable Global load balancers will be automatically added. - **name:** `Optional[str]` FQDN to associate with a Global load balancer. ### Forwarding Rule - `class ForwardingRule` An object specifying a forwarding rule for a load balancer. - **entry\_port:** `int` An integer representing the port on which the load balancer instance will listen. - **entry\_protocol:** `Literal["http", "https", "http2", 3 more]` The protocol used for traffic to the load balancer. The possible values are: `http`, `https`, `http2`, `http3`, `tcp`, or `udp`. If you set the `entry_protocol` to `udp`, the `target_protocol` must be set to `udp`. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly. - `"http"` - `"https"` - `"http2"` - `"http3"` - `"tcp"` - `"udp"` - **target\_port:** `int` An integer representing the port on the backend Droplets to which the load balancer will send traffic. - **target\_protocol:** `Literal["http", "https", "http2", 2 more]` The protocol used for traffic from the load balancer to the backend Droplets. The possible values are: `http`, `https`, `http2`, `tcp`, or `udp`. If you set the `target_protocol` to `udp`, the `entry_protocol` must be set to `udp`. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly. - `"http"` - `"https"` - `"http2"` - `"tcp"` - `"udp"` - **certificate\_id:** `Optional[str]` The ID of the TLS certificate used for SSL termination if enabled. - **tls\_passthrough:** `Optional[bool]` A boolean value indicating whether SSL encrypted traffic will be passed through to the backend Droplets. ### Glb Settings - `class GlbSettings` An object specifying forwarding configurations for a Global load balancer. - **cdn:** `Optional[Cdn]` An object specifying CDN configurations for a Global load balancer. - **is\_enabled:** `Optional[bool]` A boolean flag to enable CDN caching. - **failover\_threshold:** `Optional[int]` An integer value as a percentage to indicate failure threshold to decide how the regional priorities will take effect. A value of `50` would indicate that the Global load balancer will choose a lower priority region to forward traffic to once this failure threshold has been reached for the higher priority region. - **region\_priorities:** `Optional[Dict[str, int]]` A map of region string to an integer priority value indicating preference for which regional target a Global load balancer will forward traffic to. A lower value indicates a higher priority. - **target\_port:** `Optional[int]` An integer representing the port on the target backends which the load balancer will forward traffic to. - **target\_protocol:** `Optional[Literal["http", "https", "http2"]]` The protocol used for forwarding traffic from the load balancer to the target backends. The possible values are `http`, `https` and `http2`. - `"http"` - `"https"` - `"http2"` ### Health Check - `class HealthCheck` An object specifying health check settings for the load balancer. - **check\_interval\_seconds:** `Optional[int]` The number of seconds between between two consecutive health checks. - **healthy\_threshold:** `Optional[int]` The number of times a health check must pass for a backend Droplet to be marked "healthy" and be re-added to the pool. - **path:** `Optional[str]` The path on the backend Droplets to which the load balancer instance will send a request. - **port:** `Optional[int]` An integer representing the port on the backend Droplets on which the health check will attempt a connection. - **protocol:** `Optional[Literal["http", "https", "tcp"]]` The protocol used for health checks sent to the backend Droplets. The possible values are `http`, `https`, or `tcp`. - `"http"` - `"https"` - `"tcp"` - **response\_timeout\_seconds:** `Optional[int]` The number of seconds the load balancer instance will wait for a response until marking a health check as failed. - **unhealthy\_threshold:** `Optional[int]` The number of times a health check must fail for a backend Droplet to be marked "unhealthy" and be removed from the pool. ### Lb Firewall - `class LbFirewall` An object specifying allow and deny rules to control traffic to the load balancer. - **allow:** `Optional[List[str]]` the rules for allowing traffic to the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16') - **deny:** `Optional[List[str]]` the rules for denying traffic to the load balancer (in the form 'ip:1.2.3.4' or 'cidr:1.2.0.0/16') ### Load Balancer - `class LoadBalancer` - **forwarding\_rules:** `List[ForwardingRule]` An array of objects specifying the forwarding rules for a load balancer. - **entry\_port:** `int` An integer representing the port on which the load balancer instance will listen. - **entry\_protocol:** `Literal["http", "https", "http2", 3 more]` The protocol used for traffic to the load balancer. The possible values are: `http`, `https`, `http2`, `http3`, `tcp`, or `udp`. If you set the `entry_protocol` to `udp`, the `target_protocol` must be set to `udp`. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly. - `"http"` - `"https"` - `"http2"` - `"http3"` - `"tcp"` - `"udp"` - **target\_port:** `int` An integer representing the port on the backend Droplets to which the load balancer will send traffic. - **target\_protocol:** `Literal["http", "https", "http2", 2 more]` The protocol used for traffic from the load balancer to the backend Droplets. The possible values are: `http`, `https`, `http2`, `tcp`, or `udp`. If you set the `target_protocol` to `udp`, the `entry_protocol` must be set to `udp`. When using UDP, the load balancer requires that you set up a health check with a port that uses TCP, HTTP, or HTTPS to work properly. - `"http"` - `"https"` - `"http2"` - `"tcp"` - `"udp"` - **certificate\_id:** `Optional[str]` The ID of the TLS certificate used for SSL termination if enabled. - **tls\_passthrough:** `Optional[bool]` A boolean value indicating whether SSL encrypted traffic will be passed through to the backend Droplets. - **id:** `Optional[str]` A unique ID that can be used to identify and reference a load balancer. - **algorithm:** `Optional[Literal["round_robin", "least_connections"]]` This field has been deprecated. You can no longer specify an algorithm for load balancers. - `"round_robin"` - `"least_connections"` - **created\_at:** `Optional[datetime]` A time value given in ISO8601 combined date and time format that represents when the load balancer was created. - **disable\_lets\_encrypt\_dns\_records:** `Optional[bool]` A boolean value indicating whether to disable automatic DNS record creation for Let's Encrypt certificates that are added to the load balancer. - **domains:** `Optional[List[Domains]]` An array of objects specifying the domain configurations for a Global load balancer. - **certificate\_id:** `Optional[str]` The ID of the TLS certificate used for SSL termination. - **is\_managed:** `Optional[bool]` A boolean value indicating if the domain is already managed by DigitalOcean. If true, all A and AAAA records required to enable Global load balancers will be automatically added. - **name:** `Optional[str]` FQDN to associate with a Global load balancer. - **droplet\_ids:** `Optional[List[int]]` An array containing the IDs of the Droplets assigned to the load balancer. - **enable\_backend\_keepalive:** `Optional[bool]` A boolean value indicating whether HTTP keepalive connections are maintained to target Droplets. - **enable\_proxy\_protocol:** `Optional[bool]` A boolean value indicating whether PROXY Protocol is in use. - **firewall:** `Optional[LbFirewall]` An object specifying allow and deny rules to control traffic to the load balancer. - **glb\_settings:** `Optional[GlbSettings]` An object specifying forwarding configurations for a Global load balancer. - **health\_check:** `Optional[HealthCheck]` An object specifying health check settings for the load balancer. - **http\_idle\_timeout\_seconds:** `Optional[int]` An integer value which configures the idle timeout for HTTP requests to the target droplets. - **ip:** `Optional[str]` An attribute containing the public-facing IP address of the load balancer. - **ipv6:** `Optional[str]` An attribute containing the public-facing IPv6 address of the load balancer. - **name:** `Optional[str]` A human-readable name for a load balancer instance. - **network:** `Optional[Literal["EXTERNAL", "INTERNAL"]]` A string indicating whether the load balancer should be external or internal. Internal load balancers have no public IPs and are only accessible to resources on the same VPC network. This property cannot be updated after creating the load balancer. - `"EXTERNAL"` - `"INTERNAL"` - **network\_stack:** `Optional[Literal["IPV4", "DUALSTACK"]]` A string indicating whether the load balancer will support IPv4 or both IPv4 and IPv6 networking. This property cannot be updated after creating the load balancer. - `"IPV4"` - `"DUALSTACK"` - **project\_id:** `Optional[str]` The ID of the project that the load balancer is associated with. If no ID is provided at creation, the load balancer associates with the user's default project. If an invalid project ID is provided, the load balancer will not be created. - **redirect\_http\_to\_https:** `Optional[bool]` A boolean value indicating whether HTTP requests to the load balancer on port 80 will be redirected to HTTPS on port 443. - **region:** `Optional[Region]` The region where the load balancer instance is located. When setting a region, the value should be the slug identifier for the region. When you query a load balancer, an entire region object will be returned. - **size:** `Optional[Literal["lb-small", "lb-medium", "lb-large"]]` This field has been replaced by the `size_unit` field for all regions except in AMS2, NYC2, and SFO1. Each available load balancer size now equates to the load balancer having a set number of nodes. * `lb-small` = 1 node * `lb-medium` = 3 nodes * `lb-large` = 6 nodes You can resize load balancers after creation up to once per hour. You cannot resize a load balancer within the first hour of its creation. - `"lb-small"` - `"lb-medium"` - `"lb-large"` - **size\_unit:** `Optional[int]` How many nodes the load balancer contains. Each additional node increases the load balancer's ability to manage more connections. Load balancers can be scaled up or down, and you can change the number of nodes after creation up to once per hour. This field is currently not available in the AMS2, NYC2, or SFO1 regions. Use the `size` field to scale load balancers that reside in these regions. - **status:** `Optional[Literal["new", "active", "errored"]]` A status string indicating the current state of the load balancer. This can be `new`, `active`, or `errored`. - `"new"` - `"active"` - `"errored"` - **sticky\_sessions:** `Optional[StickySessions]` An object specifying sticky sessions settings for the load balancer. - **tag:** `Optional[str]` The name of a Droplet tag corresponding to Droplets assigned to the load balancer. - **target\_load\_balancer\_ids:** `Optional[List[str]]` An array containing the UUIDs of the Regional load balancers to be used as target backends for a Global load balancer. - **tls\_cipher\_policy:** `Optional[Literal["DEFAULT", "STRONG"]]` A string indicating the policy for the TLS cipher suites used by the load balancer. The possible values are `DEFAULT` or `STRONG`. The default value is `DEFAULT`. - `"DEFAULT"` - `"STRONG"` - **type:** `Optional[Literal["REGIONAL", "REGIONAL_NETWORK", "GLOBAL"]]` A string indicating whether the load balancer should be a standard regional HTTP load balancer, a regional network load balancer that routes traffic at the TCP/UDP transport layer, or a global load balancer. - `"REGIONAL"` - `"REGIONAL_NETWORK"` - `"GLOBAL"` - **vpc\_uuid:** `Optional[str]` A string specifying the UUID of the VPC to which the load balancer is assigned. ### Sticky Sessions - `class StickySessions` An object specifying sticky sessions settings for the load balancer. - **cookie\_name:** `Optional[str]` The name of the cookie sent to the client. This attribute is only returned when using `cookies` for the sticky sessions type. - **cookie\_ttl\_seconds:** `Optional[int]` The number of seconds until the cookie set by the load balancer expires. This attribute is only returned when using `cookies` for the sticky sessions type. - **type:** `Optional[Literal["cookies", "none"]]` An attribute indicating how and if requests from a client will be persistently served by the same backend Droplet. The possible values are `cookies` or `none`. - `"cookies"` - `"none"`