# REST Resource: projects.locations.serviceLbPolicies

- [Resource: ServiceLbPolicy](https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#ServiceLbPolicy)
  - [JSON representation](https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#ServiceLbPolicy.SCHEMA_REPRESENTATION)
- [LoadBalancingAlgorithm](https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#LoadBalancingAlgorithm)
- [AutoCapacityDrain](https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#AutoCapacityDrain)
  - [JSON representation](https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#AutoCapacityDrain.SCHEMA_REPRESENTATION)
- [FailoverConfig](https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#FailoverConfig)
  - [JSON representation](https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#FailoverConfig.SCHEMA_REPRESENTATION)
- [Methods](https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#METHODS_SUMMARY)

## Resource: ServiceLbPolicy

ServiceLbPolicy holds global load balancing and traffic distribution configuration that can be applied to a BackendService.

| JSON representation |
|---|
| ``` { "name": string, "createTime": string, "updateTime": string, "labels": { string: string, ... }, "description": string, "loadBalancingAlgorithm": enum (`https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#LoadBalancingAlgorithm`), "autoCapacityDrain": { object (`https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#AutoCapacityDrain`) }, "failoverConfig": { object (`https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#FailoverConfig`) } } ``` |

| Fields ||
|---|---|
| `name` | `string` Identifier. Name of the ServiceLbPolicy resource. It matches pattern `projects/{project}/locations/{location}/serviceLbPolicies/{service_lb_policy_name}`. |
| `createTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. The timestamp when this resource was created. Uses RFC 3339, where generated output will always be Z-normalized and uses 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `updateTime` | ``string (`https://protobuf.dev/reference/protobuf/google.protobuf#timestamp` format)`` Output only. The timestamp when this resource was last updated. Uses RFC 3339, where generated output will always be Z-normalized and uses 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: `"2014-10-02T15:01:23Z"`, `"2014-10-02T15:01:23.045123456Z"` or `"2014-10-02T15:01:23+05:30"`. |
| `labels` | `map (key: string, value: string)` Optional. Set of label tags associated with the ServiceLbPolicy resource. An object containing a list of `"key": value` pairs. Example: `{ "name": "wrench", "mass": "1.3kg", "count": "3" }`. |
| `description` | `string` Optional. A free-text description of the resource. Max length 1024 characters. |
| `loadBalancingAlgorithm` | ``enum (`https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#LoadBalancingAlgorithm`)`` Optional. The type of load balancing algorithm to be used. The default behavior is WATERFALL_BY_REGION. |
| `autoCapacityDrain` | ``object (`https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#AutoCapacityDrain`)`` Optional. Configuration to automatically move traffic away for unhealthy IG/NEG for the associated Backend Service. |
| `failoverConfig` | ``object (`https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies#FailoverConfig`)`` Optional. Configuration related to health based failover. |

## LoadBalancingAlgorithm

The global load balancing algorithm to be used.

| Enums ||
|---|---|
| `LOAD_BALANCING_ALGORITHM_UNSPECIFIED` | The type of the loadbalancing algorithm is unspecified. |
| `SPRAY_TO_WORLD` | Balance traffic across all backends across the world proportionally based on capacity. |
| `SPRAY_TO_REGION` | Direct traffic to the nearest region with endpoints and capacity before spilling over to other regions and spread the traffic from each client to all the MIGs/NEGs in a region. |
| `WATERFALL_BY_REGION` | Direct traffic to the nearest region with endpoints and capacity before spilling over to other regions. All MIGs/NEGs within a region are evenly loaded but each client might not spread the traffic to all the MIGs/NEGs in the region. |
| `WATERFALL_BY_ZONE` | Attempt to keep traffic in a single zone closest to the client, before spilling over to other zones. |

## AutoCapacityDrain

Option to specify if an unhealthy IG/NEG should be considered for global load balancing and traffic routing.

| JSON representation |
|---|
| ``` { "enable": boolean } ``` |

| Fields ||
|---|---|
| `enable` | `boolean` Optional. If set to 'True', an unhealthy IG/NEG will be set as drained. - An IG/NEG is considered unhealthy if less than 25% of the instances/endpoints in the IG/NEG are healthy. - This option will never result in draining more than 50% of the configured IGs/NEGs for the Backend Service. |

## FailoverConfig

Option to specify health based failover behavior. This is not related to Network load balancer FailoverPolicy.

| JSON representation |
|---|
| ``` { "failoverHealthThreshold": integer } ``` |

| Fields ||
|---|---|
| `failoverHealthThreshold` | `integer` Optional. The percentage threshold that a load balancer will begin to send traffic to failover backends. If the percentage of endpoints in a MIG/NEG is smaller than this value, traffic would be sent to failover backends if possible. This field should be set to a value between 1 and 99. The default value is 50 for Global external HTTP(S) load balancer (classic) and Proxyless service mesh, and 70 for others. |

| ## Methods ||
|---|---|
| ### `https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies/create` | Creates a new ServiceLbPolicy in a given project and location. |
| ### `https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies/delete` | Deletes a single ServiceLbPolicy. |
| ### `https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies/get` | Gets details of a single ServiceLbPolicy. |
| ### `https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies/getIamPolicy` | Gets the access control policy for a resource. |
| ### `https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies/list` | Lists ServiceLbPolicies in a given project and location. |
| ### `https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies/patch` | Updates the parameters of a single ServiceLbPolicy. |
| ### `https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies/setIamPolicy` | Sets the access control policy on the specified resource. |
| ### `https://docs.cloud.google.com/service-mesh/v1.25/docs/reference/network-services/rest/v1beta1/projects.locations.serviceLbPolicies/testIamPermissions` | Returns permissions that a caller has on the specified resource. |