File: //snap/google-cloud-cli/current/lib/surface/firestore/indexes/fields/update.yaml
- release_tracks: [ALPHA, BETA, GA]
  help_text:
    brief: Update the index configuration of the given field.
    description: |
      Update the index configuration of the given field.
      This creates an exemption for the field in question, allowing one to modify the field's index
      settings and override the defaults.
    # Note: currently all indexes are collection scoped; collection group scoped indexes are not yet
    # supported. When they are, these examples will need to be updated to include queryScope keys in
    # addition to order/arrayConfig.
    examples: |
      The following command creates an exemption for the `timestamp` field in the `Events`
      collection group, in which all indexes are disabled:
        $ {command} timestamp \
            --collection-group=Events
            --disable-indexes
        $ {command} timestamp \
            --database=(default)
            --collection-group=Events
            --disable-indexes
      The following command creates an exemption for the `timestamp` field in the `Events`
      collection group, in which the list of indexes is explicitly set to [ASCENDING, DESCENDING]:
        $ {command} timestamp \
            --collection-group=Events \
            --index=order=ASCENDING \
            --index=order=DESCENDING
      The following command clears the exemption on the `timestamp` field in the `Events` collection
      group, so that the field will return to inheriting its index settings from its ancestors:
        $ {command} timestamp \
            --collection-group=Events --clear-exemption
  request:
    collection: firestore.projects.databases.collectionGroups.fields
    static_fields:
      updateMask: indexConfig
    resource_method_params:
      googleFirestoreAdminV1Field.name: '{__relative_name__}'
    modify_request_hooks:
    - googlecloudsdk.command_lib.firestore.util:ValidateFieldUpdateRequest
    - googlecloudsdk.command_lib.firestore.util:AddIndexConfigToUpdateRequest
  async:
    collection: firestore.projects.databases.operations
    api_version: v1
  update:
    read_modify_update: false
    disable_auto_field_mask: true
  arguments:
    resource:
      help_text: Field to update.
      # Since it's currently not possible to update database default or collection group default
      # index settings, we use 'field' here instead of 'field_with_default'
      spec: !REF googlecloudsdk.command_lib.firestore.resources:field
    params:
    - group:
        mutex: true
        required: true
        params:
        - _REF_: googlecloudsdk.command_lib.firestore.flags:index
        - _REF_: googlecloudsdk.command_lib.firestore.flags:disable_indexes
        - _REF_: googlecloudsdk.command_lib.firestore.flags:clear_exemption