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

        $ {command} <HEALTH_SOURCE_NAME> \
          --region=<REGION> \
          --source-type=BACKEND_SERVICE \
          --sources=my-backend-service \
          --health-aggregation-policy=my-health-aggregation-policy

  request:
    ALPHA:
      api_version: alpha
    collection: compute.regionHealthSources
    method: insert
    modify_request_hooks:
    - googlecloudsdk.api_lib.compute.health_sources.modify_request_hooks:add_name_to_payload
    - googlecloudsdk.api_lib.compute.health_sources.modify_request_hooks:parse_health_aggregation_policy_create
    - googlecloudsdk.api_lib.compute.health_sources.modify_request_hooks:parse_sources_create

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

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

    params:
    - arg_name: description
      api_field: healthSource.description
      help_text: |
        A textual description of the HealthSource.
      required: false

    - arg_name: health-aggregation-policy
      api_field: healthSource.healthAggregationPolicy
      help_text: |
        URL to the health aggregation policy resource. Must be set. Must be
        regional and in the same region as the HealthSource. Can be mutated.
      required: true

    - arg_name: source-type
      api_field: healthSource.sourceType
      help_text: |
        Specifies the type of the HealthSource. The only allowed value is
        BACKEND_SERVICE. Must be specified when the HealthSource is created,
        and cannot be mutated.
      choices:
      - arg_value: backend-service
        enum_value: BACKEND_SERVICE
      default: backend-service

    - arg_name: sources
      api_field: healthSource.sources
      help_text: |
        URLs to the source resources. Must be size 1. Must be a BackendService
        if the sourceType is BACKEND_SERVICE. The BackendService must have load
        balancing scheme INTERNAL or INTERNAL_MANAGED and must be regional and
        in the same region as the HealthSource (cross-region deployment for
        INTERNAL_MANAGED is not supported). The BackendService may use only IGs,
        MIGs, or NEGs of type GCE_VM_IP or GCE_VM_IP_PORT. The BackendService
        may not use haPolicy. Can be mutated.
      required: true
