- release_tracks: [ALPHA, BETA, GA]
  help_text:
    brief: |
      Update a Memorystore Memcached instance.
    description: |
      Update a Memcached instance with one or more of the following actions:
        * Scale up or down the number of nodes in the instance.
        * Stage an update to instance configuration parameters.
        * Update the instance metadata (display name, labels).

      Updating parameters cannot be combined with any other update actions in the same call.
      All other update actions can be combined in the same call.
    examples: |
      To scale a Memcached instance named 'my-memcache-instance' in region 'us-central1' to have
      3 nodes, run:

        $ {command} my-memcache-instance --node-count=3 --region=us-central1

      To stage an update to the parameters 'protocol' and 'track-sizes' for a Memcached instance
      named 'my-memcache-instance' in region 'us-central1', run:

        $ {command} my-memcache-instance --parameters="protocol=ascii,track-sizes=true" \
            --region=us-central1

      To update a Memcached instance named 'my-memcache-instance' in region 'us-central1' to
      have the display name "Foo Cache Service" and the labels 'env' and 'service', run:

        $ {command} my-memcache-instance --display-name="Foo Cache Service" \
            --labels="env=test,service=foo"

  arguments:
    resource:
      spec: !REF googlecloudsdk.command_lib.memcache.resources:instance
      help_text: |
        Arguments and flags that specify the Memcached instance to update.
    params:
    - group:
        mutex: true
        required: true
        params:
        - group:
            params:
            - arg_name: display-name
              api_field: instance.displayName
              help_text: An arbitrary and optional user provided name for the instance.
            - arg_name: labels
              api_field: instance.labels.additionalProperties
              metavar: KEY=VALUE
              help_text: |
                List of label KEY=VALUE pairs to add.
              type:
                arg_dict:
                  flatten: true
                  spec:
                  - api_field: key
                  - api_field: value
            - arg_name: node-count
              api_field: instance.nodeCount
              help_text: |
                Number of memcache nodes in this instance. Valid values range from 1 to 20.
            - group:
                release_tracks: [ALPHA, BETA, GA]
                mutex: true
                params:
                - arg_name: maintenance-window-any
                  action: store_true
                  help_text: |
                    Removes the user-specified maintenance window.
                - group:
                    params:
                    - arg_name: maintenance-window-day
                      release_tracks: [ALPHA, BETA, GA]
                      api_field: instance.maintenancePolicy.weeklyMaintenanceWindow.day
                      choices:
                      - arg_value: monday
                        enum_value: MONDAY
                      - arg_value: tuesday
                        enum_value: TUESDAY
                      - arg_value: wednesday
                        enum_value: WEDNESDAY
                      - arg_value: thursday
                        enum_value: THURSDAY
                      - arg_value: friday
                        enum_value: FRIDAY
                      - arg_value: saturday
                        enum_value: SATURDAY
                      - arg_value: sunday
                        enum_value: SUNDAY
                      help_text: |
                        The day of week when the window starts, e.g. 'sunday'.
                    - arg_name: maintenance-window-start-time
                      release_tracks: [ALPHA, BETA, GA]
                      api_field: instance.maintenancePolicy.weeklyMaintenanceWindow.startTime.hours
                      help_text: |
                        Hour of day (0 to 23) for the start of maintenance window, in UTC time zone.
                    - arg_name: maintenance-window-duration
                      release_tracks: [ALPHA, BETA, GA]
                      type: int
                      api_field: instance.maintenancePolicy.weeklyMaintenanceWindow.duration
                      processor: googlecloudsdk.command_lib.memcache.instances_util:ConvertDurationToJsonFormat
                      help_text: |
                        Duration in integer hours (`3` to `8`) of the maintenance window.
        - arg_name: parameters
          metavar: KEY=VALUE
          help_text: |
            User defined parameters to apply to the memcached process on each node. Possible attributes include:

            *listen-backlog*::: The backlog queue limit for the instance.

            *disable-flush-all*::: If enabled, flush_all command will be disabled. Applicable to
            1.4.24 and higher.

            *max-item-size*::: Max bytes of the instnace. Must at least be equal to slab_chunk_max
            (which defaults to 524288 bytes) and less than 134217728 bytes. Additionally it must
            be a multiple of slab_chunk_max.

            *slab-min-size*::: This is an integer in the range [1, 1024].

            *slab-growth-factor*::: This is a float in the range [1.01, 100].

            *protocol*::: This is an enum with acceptable values of ["ascii", "auto"].

            *disable-cas*::: This is a boolean value.

            *disable-evictions*::: This is a boolean value.

            *max-reqs-per-event*::: This is an integer in the range [1, 1000].

            *track-sizes*::: This is a boolean value.

            *worker-logbuf-size*::: This is an integer in the range [48, 524288].

            *watcher-logbuf-size*::: This is an integer in the range [0, 2097151].

            *lru-crawler*::: This is a boolean value.

            *idle-timeout*::: This is an integer in the range [1,86400].

            *lru-maintainer*::: This is a boolean value.

            *maxconns-fast*::: This is a boolean value.

            *hash-algorithm*::: This is an enum with accepted values of ["jenkins", "murmur3"].
          type: "googlecloudsdk.command_lib.memcache.instances_util:Parameters"

  async:
    collection: memcache.projects.locations.operations

  request:
    ALPHA:
      api_version: v1beta2
    BETA:
      api_version: v1beta2
    GA:
      api_version: v1
    method: patch
    # --parameters flag uses the method `updateParameters`, all other flags use method `patch`
    modify_method_hook: googlecloudsdk.command_lib.memcache.instances_update_util:ChooseUpdateMethod
    modify_request_hooks:
    - googlecloudsdk.command_lib.memcache.instances_update_util:ModifyMaintenanceMask
    - googlecloudsdk.command_lib.memcache.instances_update_util:ModifyParams
    collection: memcache.projects.locations.instances
