- release_tracks: [ALPHA]
  help_text:
    brief: "Create a health aggregation policy."
    description: "Create a health aggregation policy."
    examples: |
      The following command creates a new health aggregation policy:

        $ {command} <HEALTH_AGGREGATION_POLICY_NAME> \
          --region=<REGION> \
          --healthy-percent-threshold 60 \
          --min-healthy-threshold 2 \
          --policy-type=BACKEND_SERVICE_POLICY

  request:
    ALPHA:
      api_version: alpha

    collection: compute.regionHealthAggregationPolicies
    method: insert
    modify_request_hooks:
    - googlecloudsdk.api_lib.compute.health_aggregation_policies.modify_request_hooks:add_name_to_payload

  async:
    collection: compute.regionOperations
    response_name_field: selfLink
    state:
      field: status
      success_values: ['DONE']

  arguments:
    resource:
      help_text: The name of the health aggregation policy you want to create.
      spec: !REF googlecloudsdk.command_lib.compute.resources:health_aggregation_policy

    params:
    - arg_name: description
      api_field: healthAggregationPolicy.description
      help_text: |
        A textual description of the health aggregation policy.

    - arg_name: healthy-percent-threshold
      api_field: healthAggregationPolicy.healthyPercentThreshold
      help_text: |
        Can only be set if the policyType field is
        BACKEND_SERVICE_POLICY. Specifies the threshold (as a
        percentage) of healthy endpoints required in order to consider the
        aggregated health result HEALTHY. Defaults to 60. Must be in
        range [0, 100]. Not applicable if the policyType field is
         DNS_PUBLIC_IP_POLICY. Can be mutated. This field is optional,
        and will be set to the default if unspecified. Note that both this
        threshold and minHealthyThreshold must be satisfied in order
        for HEALTHY to be the aggregated result. "Endpoints" refers to network
        endpoints within a Network Endpoint Group or instances within an Instance
        Group.
      type: int
      default: 60

    - arg_name: min-healthy-threshold
      api_field: healthAggregationPolicy.minHealthyThreshold
      help_text: |
        Can only be set if the policyType field is
        BACKEND_SERVICE_POLICY. Specifies the minimum number of
        healthy endpoints required in order to consider the aggregated health
        result HEALTHY. Defaults to 1. Must be positive. Not
        applicable if the policyType field is
          DNS_PUBLIC_IP_POLICY. Can be mutated. This field is optional,
        and will be set to the default if unspecified. Note that both this
        threshold and healthyPercentThreshold must be satisfied in
        order for HEALTHY to be the aggregated result. "Endpoints" refers to
        network endpoints within a Network Endpoint Group or instances within an
        Instance Group.
      type: int
      default: 1

    - arg_name: policy-type
      api_field: healthAggregationPolicy.policyType
      help_text: |
        Specifies the type of the healthAggregationPolicy. The only allowed
        value for regional resources is BACKEND_SERVICE_POLICY. Must
        be specified when the healthAggregationPolicy is created, and cannot be
        mutated.
      choices:
      - arg_value: backend-service-policy
        enum_value: BACKEND_SERVICE_POLICY
      - arg_value: dns-public-ip-policy
        enum_value: DNS_PUBLIC_IP_POLICY
      default: backend-service-policy
