- release_tracks: [ALPHA, BETA, GA]

  help_text:
    brief: |
      Update Memorystore Redis instances.
    description: |
      Update the metadata and/or configuration parameters of a Redis instance.

      This command can fail for the following reasons:
        * The instance specified does not exist.
        * The active account does not have permission to update the given
          instance.
    examples: |
      To update a Redis instance with the name `my-redis-instance` to have the display name
      "Cache for Foo Service", and add the two labels, `env` and `service`, run:

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

  arguments:
    resource:
      spec: !REF googlecloudsdk.command_lib.redis.resources:instance
      help_text: |
        Arguments and flags that specify the Memorystore Redis instance you want
        to update.
    params:
    - arg_name: display-name
      api_field: instance.displayName
      help_text: |
        A human-readable name for the instance.
    - arg_name: size
      api_field: instance.memorySizeGb
      type: long
      help_text: |
        The memory size of the instance in GiB.
    - arg_name: enable-auth
      api_field: instance.authEnabled
      type: bool
      action: store_true
      help_text: |
        Enables Redis AUTH for the instance.
    - arg_name: persistence-mode
      api_field: instance.persistenceConfig.persistenceMode
      help_text: |
        Operation mode for automated persistence.
      choices:
      - enum_value: DISABLED
        arg_value: disabled
        help_text: RDB mode is disabled
      - enum_value: RDB
        arg_value: RDB
        help_text: Automatic RDB persistence
    - arg_name: rdb-snapshot-period
      api_field: instance.persistenceConfig.rdbSnapshotPeriod
      help_text: |
        The attempted period between RDB snapshots.
      choices:
      - enum_value: ONE_HOUR
        arg_value: 1h
        help_text: 1 hour
      - enum_value: SIX_HOURS
        arg_value: 6h
        help_text: 6 hours
      - enum_value: TWELVE_HOURS
        arg_value: 12h
        help_text: 12 hours
      - enum_value: TWENTY_FOUR_HOURS
        arg_value: 24h
        help_text: 24 hours
    - arg_name: rdb-snapshot-start-time
      api_field: instance.persistenceConfig.rdbSnapshotStartTime
      help_text: |
        Date and time of the first snapshot in the ISO 1801 format, and alignment time for future snapshots. For example, 2022-11-02T03:00:00Z.
    - arg_name: replica-count
      api_field: instance.replicaCount
      type: long
      help_text: |
        The replica count of the instance. Valid from 0 to 5.
    - arg_name: read-replicas-mode
      api_field: instance.readReplicasMode
      help_text: |
          Read replicas mode used by the instance. Only works against standard tier instances with
          5GB and above provisioned capacity and Redis version 5.0 and above.
          This is an irreversible update i.e. Read replicas can not be disabled for the instance
          once it is enabled. Also this update is exclusive and cannot be clubbed with other update
          operations.
      choices:  # Enum is mapped to keep READ-REPLICAS-MODE-UNSPECIFIED invisible from users.
      - enum_value: READ-REPLICAS-ENABLED
        arg_value: READ-REPLICAS-ENABLED
        help_text: |
            Read replica is enabled for the instance if not already enabled. Read endpoint will be
            provided and the instance can scale up and down the number of replicas.
      - enum_value: READ-REPLICAS-DISABLED
        arg_value: READ-REPLICAS-DISABLED
        help_text: |
            If read replica is not enabled on the instance, no changes are done. If read replica is
            enabled for the instance, update operation fails
    - arg_name: secondary-ip-range
      api_field: instance.secondaryIpRange
      help_text: |
        Required only when read-replicas-mode is enabled on the instance. The CIDR range of
        internal addresses that are reserved for this instance. For example, 10.0.0.0/28 or
        192.168.0.0/28. Range must be unique and non-overlapping with existing ranges in the
        network. If value 'auto' passed, the service will automatically pick an available range.
    - arg_name: maintenance-version
      api_field: instance.maintenanceVersion
      help_text: |
        Specifies which maintenance version to apply to your instance during self-service maintenance.
        To view the available maintenance versions for your instance, run `gcloud redis
        instances describe [INSTANCE_ID]`. Acceptable values for this flag are either `current_default` or
        one of the specific versions listed by the describe command. If you pass the value
        `current_default`, the Memorystore updates to the most recent available maintenance version during self service maintenance.
    - group:
        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
              api_field: instance.maintenancePolicy.weeklyMaintenanceWindow.day
              help_text: |
                Day of week for maintenance window, in UTC time zone.
                MAINTENANCE_WINDOW_DAY must be one of: SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY.
            - arg_name: maintenance-window-hour
              api_field: instance.maintenancePolicy.weeklyMaintenanceWindow.startTime.hours
              help_text: |
                Hour of day (0 to 23) for maintenance window, in UTC time zone.

    additional_arguments_hook: googlecloudsdk.command_lib.redis.util:AdditionalInstanceUpdateArguments
    labels:
      api_field: instance.labels

  async:
    collection: redis.projects.locations.operations

  request:
    ALPHA:
      api_version: v1alpha1
      modify_request_hooks:
      - googlecloudsdk.command_lib.redis.instances_update_util:CheckFieldsSpecifiedAlpha
      - googlecloudsdk.command_lib.redis.instances_update_util:AddDisplayName
      - googlecloudsdk.command_lib.redis.instances_update_util:AddSize
      - googlecloudsdk.command_lib.redis.instances_update_util:RemoveRedisConfigs
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceWindowAny
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceWindowDay
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceWindowHour
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateRedisConfigs
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateAuthEnabled
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdatePersistenceMode
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateRdbSnapshotPeriod
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateRdbSnapshotStartTime
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateReplicaCount
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateReadReplicasMode
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateSecondaryIpRange
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceVersion
    BETA:
      api_version: v1beta1
      modify_request_hooks:
      - googlecloudsdk.command_lib.redis.instances_update_util:CheckFieldsSpecifiedBeta
      - googlecloudsdk.command_lib.redis.instances_update_util:AddDisplayName
      - googlecloudsdk.command_lib.redis.instances_update_util:AddSize
      - googlecloudsdk.command_lib.redis.instances_update_util:RemoveRedisConfigs
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceWindowAny
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceWindowDay
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceWindowHour
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateRedisConfigs
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateAuthEnabled
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateReplicaCount
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdatePersistenceMode
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateRdbSnapshotPeriod
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateRdbSnapshotStartTime
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateReadReplicasMode
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateSecondaryIpRange
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceVersion
    GA:
      api_version: v1
      modify_request_hooks:
      - googlecloudsdk.command_lib.redis.instances_update_util:CheckFieldsSpecifiedGA
      - googlecloudsdk.command_lib.redis.instances_update_util:AddDisplayName
      - googlecloudsdk.command_lib.redis.instances_update_util:AddSize
      - googlecloudsdk.command_lib.redis.instances_update_util:RemoveRedisConfigs
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceWindowAny
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceWindowDay
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceWindowHour
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateRedisConfigs
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateAuthEnabled
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdatePersistenceMode
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateRdbSnapshotPeriod
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateRdbSnapshotStartTime
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateReplicaCount
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateReadReplicasMode
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateSecondaryIpRange
      - googlecloudsdk.command_lib.redis.instances_update_util:UpdateMaintenanceVersion
    collection: redis.projects.locations.instances


  update:
    read_modify_update: true
    disable_auto_field_mask: true
