release_tracks: [ALPHA, BETA, GA]

help_text:
  brief: |
    Update a service LB policy.
  description: |
    Update the detail of a service LB Policy.
  examples: |
    Update load-balancing-algorithm of a service LB policy named ``my-service-lb-policy'':

      $ {command} my-service-lb-policy
        --load-balancing-algorithm=waterfall-by-zone

arguments:
  resource:
    spec: !REF googlecloudsdk.command_lib.network_services.resources:serviceLbPolicy
    help_text: |
      Name of the service LB policy to be updated.
  params:
  - arg_name: load-balancing-algorithm
    api_field: serviceLbPolicy.loadBalancingAlgorithm
    help_text: |
      The global load balancing algorithm to be used.
    choices:
    - arg_value: waterfall-by-region
      help_text: |
        Direct traffic to the nearest region with endpoints and capacity before spilling over to
        other regions.
    - arg_value: waterfall-by-zone
      help_text:  |
        Attempt to keep traffic in a single zone closest to the client, before spilling over to
        other zones.
    - arg_value: spray-to-region
      help_text:  |
        Spread the traffic from each client to all the MIGs/NEGs in a region.
    - arg_value: spray-to-world
      help_text:  |
        Balance traffic across all backends across the world proportionally based on capacity.
    default: waterfall-by-region
  - arg_name: auto-capacity-drain
    api_field: serviceLbPolicy.autoCapacityDrain
    ALPHA:
      processor: googlecloudsdk.command_lib.network_services.util:AutoCapacityDrainHook:api_version=v1alpha1
    BETA:
      processor: googlecloudsdk.command_lib.network_services.util:AutoCapacityDrainHook:api_version=v1beta1
    GA:
      processor: googlecloudsdk.command_lib.network_services.util:AutoCapacityDrainHook:api_version=v1
    help_text: |
      If specified, an unhealthy MIG/NEG will be removed from Global load balancing and traffic
      routing for the service.
      A MIG/NEG is considered to be unhealthy if less than 25% of the instance/endpoints in the
      MIG/NEG are healthy.
      autoCapacityDrain will never drain more than 50% of the configured MIGs/NEGs of a Backend
      Service.
    type: bool
  - arg_name: failover-health-threshold
    api_field: serviceLbPolicy.failoverConfig
    ALPHA:
      processor: googlecloudsdk.command_lib.network_services.util:FailoverHealthThresholdHook:api_version=v1alpha1
    BETA:
      processor: googlecloudsdk.command_lib.network_services.util:FailoverHealthThresholdHook:api_version=v1beta1
    GA:
      processor: googlecloudsdk.command_lib.network_services.util:FailoverHealthThresholdHook:api_version=v1
    help_text: |
      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 Proxyless service mesh, and 70 for others.
    type: int
  - arg_name: isolation-config-granularity
    api_field: serviceLbPolicy.isolationConfig.isolationGranularity
    release_tracks: [ALPHA, BETA, GA]
    help_text: |
      The granularity of the isolation.
    choices:
    - enum_value: ISOLATION_GRANULARITY_UNSPECIFIED
      arg_value: unspecified
      help_text: |
        No isolation is configured for the backend service. Traffic can overflow
        based on the load balancing algorithm.
    - enum_value: REGION
      arg_value: region
      help_text:  |
        Traffic for this service will be isolated at the nearest cloud region.
    default: unspecified
  - arg_name: isolation-config-mode
    api_field: serviceLbPolicy.isolationConfig.isolationMode
    release_tracks: [ALPHA, BETA, GA]
    help_text: |
      The granularity of the isolation.
    choices:
    - enum_value: ISOLATION_MODE_UNSPECIFIED
      arg_value: unspecified
      help_text: |
        No isolation mode is configured for the backend service.
    - enum_value: NEAREST
      arg_value: nearest
      help_text:  |
        Traffic will be sent to the nearest location.
    - enum_value: STRICT
      arg_value: strict
      help_text:  |
        Traffic will fail if no serving backends are available in the same region as the load balancer.
    default: unspecified
  - arg_name: description
    api_field: serviceLbPolicy.description
    help_text: The description for the service LB policy.

async:
  collection: networkservices.projects.locations.operations

request:
  ALPHA:
    api_version: v1alpha1
  BETA:
    api_version: v1beta1
  GA:
    api_version: v1
  collection: networkservices.projects.locations.serviceLbPolicies
  method: patch
