- release_tracks: [ALPHA, BETA, GA]
  help_text:
    brief: |
      Add more cluster endpoints.
    description: |
      This is required to enable multi-vpc for Redis cluster.

      To add one cluster endpoint to an existing Redis cluster, two PSC connections MUST be added as a pair: one for the Redis cluster's discovery service attachment and the other for the additional service attachment.

      Multiple cluster endpoints COULD be added simultaneously.

      This command can fail for the following reasons:
        * The cluster specified does not exist.
        * The number of connections provided to a cluster endpoint are not in pairs.
        * One of the connections is not found.
    examples: |
      To connect redis cluster to one additional VPC, run:

        $ {command} my-redis-cluster add-cluster-endpoints --cluster-endpoint='["psc-connection":[{"psc-connection-id":"$ID","address":"$IP","network":"projects/$PROJECT/global/networks/$NETWORK","forwarding-rule":"projects/$PROJECT/regions/us-east1/forwardingRules/$FR_NAME","service-attachment":"projects/$PROJECT/regions/$REGION/serviceAttachments/$SA_NAME"},{$ADDITIONAL_PSC_CONNECTION}]]' --cluster_endpoint=$ADDITIONAL_CLUSTER_ENDPOINT
        $PSCConnectionID SHOULD be extracted from forwarding rules. E.g. 75311697652483351

  arguments:
    resource:
      spec: !REF googlecloudsdk.command_lib.redis.resources:cluster
      help_text: |
        Arguments and flags that specify the Memorystore Redis cluster you want to update.
    params:
    - arg_name: cluster-endpoint
      api_field: cluster.clusterEndpoints
      repeated: true
      required: true
      help_text: |
        Resource details of a redis cluster endpoint
      type: arg_object
      spec:
      - api_field: connections
        json_name: psc-connection
        type: arg_object
        spec:
        - api_field: pscConnection.pscConnectionId
          json_name: psc-connection-id
        - api_field: pscConnection.network
          json_name: network
        - api_field: pscConnection.address
          json_name: address
        - api_field: pscConnection.forwardingRule
          json_name: forwarding-rule
        - api_field: pscConnection.serviceAttachment
          json_name: service-attachment

  async:
    collection: redis.projects.locations.operations

  request:
    ALPHA:
      api_version: v1alpha1
    BETA:
      api_version: v1beta1
    GA:
      api_version: v1
    modify_request_hooks:
    - googlecloudsdk.command_lib.redis.psc_update_util:UpdateClusterEndpoints
    collection: redis.projects.locations.clusters
    method: patch
