- release_tracks: [ALPHA, BETA, GA]
  help_text:
    brief: |
      Update a Dataproc Metastore federation.
    description: |
      Update the metadata and/or configuration parameters of a Dataproc Metastore federation.

      If run asynchronously with `--async`, exits after printing
      one operation name that can be used to poll the status of the
      update via:

        {top_command} metastore operations describe
    examples: |
      To update a Dataproc Metastore federation with the name `my-metastore-federation` in location
      `us-central` with two backends `dpms1` and `dpms2`, run:

          $ {command} my-metastore-federation --location=us-central1 --update-backends=1=dpms:dpms1,2=dpms:projects/my-project/locations/us-central1/services/dpms2

  request:
    ALPHA:
      api_version: v1alpha
    BETA:
      api_version: v1beta
    GA:
      api_version: v1
    modify_request_hooks:
    - googlecloudsdk.command_lib.metastore.validators:ValidateClearBackends
    - googlecloudsdk.command_lib.metastore.federations.util:GenerateUpdateBackends
    collection: metastore.projects.locations.federations

  arguments:
    resource:
      help_text: |
        Arguments and flags that specify the Dataproc Metastore federation
        you want to update.
      spec: !REF googlecloudsdk.command_lib.metastore.resources:federation
    params:
    - group:
        help_text: |
          Update the backend metastores by passing key-value pairs in through the flags.
        required: true
        params:
        - arg_name: update-backends
          metavar: RANK=BACKEND
          api_field: federation.backendMetastores
          processor: googlecloudsdk.command_lib.metastore.validators:ValidateBackendsAndReturnMetastoreDict
          help_text: |
              Comma-separated list of metastore backends specified as a list of `RANK=BACKEND` pairs. For example: `1=dpms:dpms1,2=dpms:projects/my-project/locations/us-central1/services/dpms2`.
              `RANK` represents the rank of the backend metastore and is used to resolve database name collisions.
              `BACKEND` is specified as `METASTORE_TYPE:METASTORE_NAME` where `METASTORE_TYPE` is the type of backend metastore and
              `METASTORE_NAME` is the relative resource name of the metastore. If only the name of the metastore is specified (e.g. `dpms1`),
               project and location will be inferred from the project and location used to create the federation.
        - group:
            mutex: true
            params:
            - arg_name: remove-backends
              metavar: RANK
              help_text: |
                Comma-separated list of metastore backend keys to remove with the form `RANK1,RANK2`. The Key represents the rank of the backend metastore and is used to resolve database name collisions.
                If a `RANK` does not exist then it is sliently ignored. If `--update-backends` is also specified, then `--remove-backends` is applied first.
            - arg_name: clear-backends
              action: store_true
              help_text: |
                Clear existing metastore backends. `--clear-backends` must be used with `--update-backends`.
    labels:
      api_field: federation.labels

  async:
    collection: metastore.projects.locations.operations
  update:
    read_modify_update: true
    disable_auto_field_mask: true
