- release_tracks: [GA, BETA, ALPHA]

  help_text:
    brief: Update an existing Cloud Bigtable table.
    description: Update an existing new Cloud Bigtable table with the specified configuration.
    examples: |
      To enable deletion protection, run:

      $ {command} my-table --instance=my-instance --deletion-protection

      To disable deletion protection, run:

      $ {command} my-table --instance=my-instance --no-deletion-protection

      To enable a change stream with a retention period of 1 day, or to update your table's change stream retention period to 1 day, run:

      $ {command} my-table --instance=my-instance --change-stream-retention-period=1d

      To disable a change stream, run:

      $ {command} my-table --instance=my-instance --clear-change-stream-retention-period

      To enable the default automated backup policy on a table, or update a table to use the default policy (retention_period=7d, frequency=1d), run:

      $ {command} my-table --instance=my-instance --enable-automated-backup

      To disable automated backup: run:

      $ {command} my-table --instance=my-instance --disable-automated-backup

      To enable or update a custom automated backup policy and configure it to retain backups for 30 days, run:

      $ {command} my-table --instance=my-instance --automated-backup-retention_period=30d

  request:
    collection: bigtableadmin.projects.instances.tables
    method: patch
    modify_request_hooks:
    - googlecloudsdk.api_lib.bigtable.tables:HandleChangeStreamArgs
    - googlecloudsdk.api_lib.bigtable.tables:HandleAutomatedBackupPolicyUpdateTableArgs
    - googlecloudsdk.api_lib.bigtable.tables:HandleTieredStorageArgs
    - googlecloudsdk.api_lib.bigtable.tables:RefreshUpdateMask
    - googlecloudsdk.api_lib.bigtable.tables:HandleRowKeySchemaUpdateTableArgs

  arguments:
    resource:
      help_text: Cloud Bigtable table to update.
      spec: !REF googlecloudsdk.command_lib.bigtable.resources:table
    additional_arguments_hook: googlecloudsdk.api_lib.bigtable.tables:AddAdditionalArgsAlphaBeta
    GA:
      additional_arguments_hook: googlecloudsdk.api_lib.bigtable.tables:AddAdditionalArgs
    params:
    - api_field: table.deletionProtection
      arg_name: deletion-protection
      type: bool
      help_text: |
        Once specified, the table is deletion protected.
    - arg_name: row-key-schema-pre-encoded-bytes
      type: bool
      help_text: |
        By default, Base64 encoding is applied to all binary fields in the YAML/JSON file (for example,
        `encoding.delimitedBytes.delimiter`).

        Use this to indicate that all binary fields are already encoded in the YAML/JSON file and
        should not be encoded again.

        This field is only used when `row-key-schema-definition-file` is set. It is ignored if
        `clear-row-key-schema` is set.
    - group:
        help_text: |
          Whether to update or clear the row key schema in the updated table. Only one of these
          flags can be set.
        required: false
        mutex: true
        params:
        - arg_name: row-key-schema-definition-file
          help_text: |
            The row key schema for the table. The schema is defined in a YAML or JSON file, equivalent
            to the StructType protobuf message.

            Example YAML:

            ```yaml
            encoding:
              delimitedBytes:
                delimiter: '#'
            fields:
            - fieldName: field1
              type:
                bytesType:
                  encoding:
                    raw: {}
            - fieldName: field2
              type:
                bytesType:
                  encoding:
                    raw: {}
            ```

        - arg_name: clear-row-key-schema
          type: bool
          help_text: |
            Whether to clear the row key schema in the updated table.

  async:
    collection: bigtableadmin.operations
