// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.cloud.memorystore.v1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/field_info.proto";
import "google/api/resource.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "google/type/dayofweek.proto";
import "google/type/timeofday.proto";

option csharp_namespace = "Google.Cloud.Memorystore.V1";
option go_package = "cloud.google.com/go/memorystore/apiv1/memorystorepb;memorystorepb";
option java_multiple_files = true;
option java_outer_classname = "V1mainProto";
option java_package = "com.google.cloud.memorystore.v1";
option php_namespace = "Google\\Cloud\\Memorystore\\V1";
option ruby_package = "Google::Cloud::Memorystore::V1";
option (google.api.resource_definition) = {
  type: "compute.googleapis.com/ForwardingRule"
  pattern: "projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}"
};
option (google.api.resource_definition) = {
  type: "compute.googleapis.com/Network"
  pattern: "projects/{project}/global/networks/{network}"
};
option (google.api.resource_definition) = {
  type: "compute.googleapis.com/ServiceAttachment"
  pattern: "projects/{project}/regions/{region}/serviceAttachments/{service_attachment}"
};
option (google.api.resource_definition) = {
  type: "cloudkms.googleapis.com/CryptoKey"
  pattern: "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}"
};

// Service describing handlers for resources
service Memorystore {
  option (google.api.default_host) = "memorystore.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Lists Instances in a given project and location.
  rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*}/instances"
    };
    option (google.api.method_signature) = "parent";
  }

  // Gets details of a single Instance.
  rpc GetInstance(GetInstanceRequest) returns (Instance) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/instances/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Creates a new Instance in a given project and location.
  rpc CreateInstance(CreateInstanceRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/instances"
      body: "instance"
    };
    option (google.api.method_signature) = "parent,instance,instance_id";
    option (google.longrunning.operation_info) = {
      response_type: "Instance"
      metadata_type: "OperationMetadata"
    };
  }

  // Updates the parameters of a single Instance.
  rpc UpdateInstance(UpdateInstanceRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      patch: "/v1/{instance.name=projects/*/locations/*/instances/*}"
      body: "instance"
    };
    option (google.api.method_signature) = "instance,update_mask";
    option (google.longrunning.operation_info) = {
      response_type: "Instance"
      metadata_type: "OperationMetadata"
    };
  }

  // Deletes a single Instance.
  rpc DeleteInstance(DeleteInstanceRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/instances/*}"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "google.protobuf.Empty"
      metadata_type: "OperationMetadata"
    };
  }

  // Gets details about the certificate authority for an Instance.
  rpc GetCertificateAuthority(GetCertificateAuthorityRequest)
      returns (CertificateAuthority) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/instances/*}/certificateAuthority"
    };
    option (google.api.method_signature) = "name";
  }

  // Reschedules upcoming maintenance event.
  rpc RescheduleMaintenance(RescheduleMaintenanceRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/instances/*}:rescheduleMaintenance"
      body: "*"
    };
    option (google.api.method_signature) = "name,reschedule_type,schedule_time";
    option (google.longrunning.operation_info) = {
      response_type: "Instance"
      metadata_type: "OperationMetadata"
    };
  }

  // Lists all backup collections owned by a consumer project in either the
  // specified location (region) or all locations.
  //
  // If `location_id` is specified as `-` (wildcard), then all regions
  // available to the project are queried, and the results are aggregated.
  rpc ListBackupCollections(ListBackupCollectionsRequest)
      returns (ListBackupCollectionsResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*}/backupCollections"
    };
    option (google.api.method_signature) = "parent";
  }

  // Get a backup collection.
  rpc GetBackupCollection(GetBackupCollectionRequest)
      returns (BackupCollection) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/backupCollections/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists all backups owned by a backup collection.
  rpc ListBackups(ListBackupsRequest) returns (ListBackupsResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*/backupCollections/*}/backups"
    };
    option (google.api.method_signature) = "parent";
  }

  // Gets the details of a specific backup.
  rpc GetBackup(GetBackupRequest) returns (Backup) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/backupCollections/*/backups/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Deletes a specific backup.
  rpc DeleteBackup(DeleteBackupRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/backupCollections/*/backups/*}"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "google.protobuf.Empty"
      metadata_type: "OperationMetadata"
    };
  }

  // Exports a specific backup to a customer target Cloud Storage URI.
  rpc ExportBackup(ExportBackupRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/backupCollections/*/backups/*}:export"
      body: "*"
    };
    option (google.longrunning.operation_info) = {
      response_type: "Backup"
      metadata_type: "OperationMetadata"
    };
  }

  // Backup Instance.
  // If this is the first time a backup is being created, a backup collection
  // will be created at the backend, and this backup belongs to this collection.
  // Both collection and backup will have a resource name. Backup will be
  // executed for each shard. A replica (primary if nonHA) will be selected to
  // perform the execution. Backup call will be rejected if there is an ongoing
  // backup or update operation. Be aware that during preview, if the instance's
  // internal software version is too old, critical update will be performed
  // before actual backup. Once the internal software version is updated to the
  // minimum version required by the backup feature, subsequent backups will not
  // require critical update. After preview, there will be no critical update
  // needed for backup.
  rpc BackupInstance(BackupInstanceRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/instances/*}:backup"
      body: "*"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "Instance"
      metadata_type: "OperationMetadata"
    };
  }
}

// Status of the PSC connection.
enum PscConnectionStatus {
  // PSC connection status is not specified.
  PSC_CONNECTION_STATUS_UNSPECIFIED = 0;

  // The connection is active
  ACTIVE = 1;

  // Connection not found
  NOT_FOUND = 2;
}

// Type of a PSC connection
enum ConnectionType {
  // Connection Type is not set
  CONNECTION_TYPE_UNSPECIFIED = 0;

  // Connection that will be used for topology discovery.
  CONNECTION_TYPE_DISCOVERY = 1;

  // Connection that will be used as primary endpoint to access primary.
  CONNECTION_TYPE_PRIMARY = 2;

  // Connection that will be used as reader endpoint to access replicas.
  CONNECTION_TYPE_READER = 3;
}

// A Memorystore instance.
message Instance {
  option (google.api.resource) = {
    type: "memorystore.googleapis.com/Instance"
    pattern: "projects/{project}/locations/{location}/instances/{instance}"
    plural: "instances"
    singular: "instance"
  };

  // Additional information about the state of the instance.
  message StateInfo {
    // Represents information about instance with state UPDATING.
    message UpdateInfo {
      // Output only. Target number of shards for the instance.
      optional int32 target_shard_count = 1
          [(google.api.field_behavior) = OUTPUT_ONLY];

      // Output only. Target number of replica nodes per shard for the instance.
      optional int32 target_replica_count = 2
          [(google.api.field_behavior) = OUTPUT_ONLY];

      // Output only. Target engine version for the instance.
      optional string target_engine_version = 3
          [(google.api.field_behavior) = OUTPUT_ONLY];

      // Output only. Target node type for the instance.
      optional NodeType target_node_type = 4
          [(google.api.field_behavior) = OUTPUT_ONLY];
    }

    oneof info {
      // Output only. Describes ongoing update when instance state is UPDATING.
      UpdateInfo update_info = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
    }
  }

  // Backups that stored in Cloud Storage buckets.
  // The Cloud Storage buckets need to be the same region as the instances.
  message GcsBackupSource {
    // Optional. Example: gs://bucket1/object1, gs://bucket2/folder2/object2
    repeated string uris = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // Backups that generated and managed by memorystore.
  message ManagedBackupSource {
    // Optional. Example:
    // //memorystore.googleapis.com/projects/{project}/locations/{location}/backupCollections/{collection}/backups/{backup}
    // A shorter version (without the prefix) of the backup name is also
    // supported, like
    // projects/{project}/locations/{location}/backupCollections/{collection}/backups/{backup_id}
    // In this case, it assumes the backup is under memorystore.googleapis.com.
    string backup = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // InstanceEndpoint consists of PSC connections that are created
  // as a group in each VPC network for accessing the instance. In each group,
  // there shall be one connection for each service attachment in the cluster.
  message InstanceEndpoint {
    // Optional. A group of PSC connections. They are created in the same VPC
    // network, one for each service attachment in the cluster.
    repeated ConnectionDetail connections = 1
        [(google.api.field_behavior) = OPTIONAL];
  }

  // Information of each PSC connection.
  message ConnectionDetail {
    // A PSC connection to an instance could either be created through Service
    // Connectivity Automation (auto connection) during the cluster creation,
    // or it could be created by customer themeslves (user-created connection).
    oneof connection {
      // Immutable. Detailed information of a PSC connection that is created
      // through service connectivity automation.
      PscAutoConnection psc_auto_connection = 1
          [(google.api.field_behavior) = IMMUTABLE];

      // Detailed information of a PSC connection that is created by the user.
      PscConnection psc_connection = 2;
    }
  }

  // Possible states of the instance.
  enum State {
    // Not set.
    STATE_UNSPECIFIED = 0;

    // Instance is being created.
    CREATING = 1;

    // Instance has been created and is usable.
    ACTIVE = 2;

    // Instance is being updated.
    UPDATING = 3;

    // Instance is being deleted.
    DELETING = 4;
  }

  // Possible authorization modes of the instance.
  enum AuthorizationMode {
    // Not set.
    AUTHORIZATION_MODE_UNSPECIFIED = 0;

    // Authorization disabled.
    AUTH_DISABLED = 1;

    // IAM basic authorization.
    IAM_AUTH = 2;
  }

  // Possible in-transit encryption modes of the instance.
  enum TransitEncryptionMode {
    // Not set.
    TRANSIT_ENCRYPTION_MODE_UNSPECIFIED = 0;

    // In-transit encryption is disabled.
    TRANSIT_ENCRYPTION_DISABLED = 1;

    // Server-managed encryption is used for in-transit encryption.
    SERVER_AUTHENTICATION = 2;
  }

  // Possible node types of the instance. See
  // https://cloud.google.com/memorystore/docs/valkey/instance-node-specification
  // for more information.
  enum NodeType {
    // Not set.
    NODE_TYPE_UNSPECIFIED = 0;

    // Shared core nano.
    SHARED_CORE_NANO = 1;

    // High memory medium.
    HIGHMEM_MEDIUM = 2;

    // High memory extra large.
    HIGHMEM_XLARGE = 3;

    // Standard small.
    STANDARD_SMALL = 4;
  }

  // The mode config, which is used to enable/disable cluster mode.
  enum Mode {
    // Mode is not specified.
    MODE_UNSPECIFIED = 0;

    // Deprecated: Use CLUSTER_DISABLED instead.
    STANDALONE = 1 [deprecated = true];

    // Instance is in cluster mode.
    CLUSTER = 2;

    // Cluster mode is disabled for the instance.
    CLUSTER_DISABLED = 4;
  }

  // The source to import from.
  oneof import_sources {
    // Optional. Immutable. Backups that stored in Cloud Storage buckets.
    // The Cloud Storage buckets need to be the same region as the instances.
    // Read permission is required to import from the provided Cloud Storage
    // Objects.
    GcsBackupSource gcs_source = 23 [
      (google.api.field_behavior) = OPTIONAL,
      (google.api.field_behavior) = IMMUTABLE
    ];

    // Optional. Immutable. Backups that generated and managed by memorystore
    // service.
    ManagedBackupSource managed_backup_source = 24 [
      (google.api.field_behavior) = OPTIONAL,
      (google.api.field_behavior) = IMMUTABLE
    ];
  }

  // Identifier. Unique name of the instance.
  // Format: projects/{project}/locations/{location}/instances/{instance}
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Output only. Creation timestamp of the instance.
  google.protobuf.Timestamp create_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Latest update timestamp of the instance.
  google.protobuf.Timestamp update_time = 3
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Labels to represent user-provided metadata.
  map<string, string> labels = 4 [(google.api.field_behavior) = OPTIONAL];

  // Output only. Current state of the instance.
  State state = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Additional information about the state of the instance.
  StateInfo state_info = 6 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. System assigned, unique identifier for the instance.
  string uid = 7 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Number of replica nodes per shard. If omitted the default is 0
  // replicas.
  optional int32 replica_count = 8 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Immutable. Authorization mode of the instance.
  AuthorizationMode authorization_mode = 9 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Optional. Immutable. In-transit encryption mode of the instance.
  TransitEncryptionMode transit_encryption_mode = 10 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Optional. Number of shards for the instance.
  int32 shard_count = 11 [(google.api.field_behavior) = OPTIONAL];

  // Output only. Deprecated: Use the endpoints.connections.psc_auto_connection
  // or endpoints.connections.psc_connection values instead.
  repeated DiscoveryEndpoint discovery_endpoints = 12
      [deprecated = true, (google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Machine type for individual nodes of the instance.
  NodeType node_type = 13 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Persistence configuration of the instance.
  PersistenceConfig persistence_config = 14
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Engine version of the instance.
  string engine_version = 15 [(google.api.field_behavior) = OPTIONAL];

  // Optional. User-provided engine configurations for the instance.
  map<string, string> engine_configs = 16
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. Configuration of individual nodes of the instance.
  NodeConfig node_config = 17 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Immutable. Zone distribution configuration of the instance for
  // node allocation.
  ZoneDistributionConfig zone_distribution_config = 18 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Optional. If set to true deletion of the instance will fail.
  optional bool deletion_protection_enabled = 19
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Immutable. Deprecated: Use the
  // endpoints.connections.psc_auto_connection value instead.
  repeated PscAutoConnection psc_auto_connections = 20 [
    deprecated = true,
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Output only. Service attachment details to configure PSC connections.
  repeated PscAttachmentDetail psc_attachment_details = 21
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Endpoints for the instance.
  repeated InstanceEndpoint endpoints = 25
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The mode config for the instance.
  Mode mode = 26 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Input only. Ondemand maintenance for the instance.
  optional bool ondemand_maintenance = 28 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = INPUT_ONLY
  ];

  // Optional. The maintenance policy for the instance. If not provided,
  // the maintenance event will be performed based on Memorystore
  // internal rollout schedule.
  MaintenancePolicy maintenance_policy = 31
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. Published maintenance schedule.
  MaintenanceSchedule maintenance_schedule = 32
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The config for cross instance replication.
  CrossInstanceReplicationConfig cross_instance_replication_config = 33
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. If true, instance endpoints that are created and registered by
  // customers can be deleted asynchronously. That is, such an instance endpoint
  // can be de-registered before the forwarding rules in the instance endpoint
  // are deleted.
  optional bool async_instance_endpoints_deletion_enabled = 44
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The backup collection full resource name. Example:
  // projects/{project}/locations/{location}/backupCollections/{collection}
  optional string backup_collection = 47 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/BackupCollection"
    }
  ];

  // Optional. The automated backup config for the instance.
  AutomatedBackupConfig automated_backup_config = 48
      [(google.api.field_behavior) = OPTIONAL];
}

// The automated backup config for an instance.
message AutomatedBackupConfig {
  // This schedule allows the backup to be triggered at a fixed frequency
  // (currently only daily is supported).
  message FixedFrequencySchedule {
    // Required. The start time of every automated backup in UTC. It must be set
    // to the start of an hour. This field is required.
    google.type.TimeOfDay start_time = 2
        [(google.api.field_behavior) = REQUIRED];
  }

  // The automated backup mode.
  enum AutomatedBackupMode {
    // Default value. Automated backup config is not specified.
    AUTOMATED_BACKUP_MODE_UNSPECIFIED = 0;

    // Automated backup config disabled.
    DISABLED = 1;

    // Automated backup config enabled.
    ENABLED = 2;
  }

  // The schedule of automated backups.
  oneof schedule {
    // Optional. Trigger automated backups at a fixed frequency.
    FixedFrequencySchedule fixed_frequency_schedule = 2
        [(google.api.field_behavior) = OPTIONAL];
  }

  // Optional. The automated backup mode. If the mode is disabled, the other
  // fields will be ignored.
  AutomatedBackupMode automated_backup_mode = 1
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. How long to keep automated backups before the backups are
  // deleted. The value should be between 1 day and 365 days. If not specified,
  // the default value is 35 days.
  google.protobuf.Duration retention = 3
      [(google.api.field_behavior) = OPTIONAL];
}

// BackupCollection of an instance.
message BackupCollection {
  option (google.api.resource) = {
    type: "memorystore.googleapis.com/BackupCollection"
    pattern: "projects/{project}/locations/{location}/backupCollections/{backup_collection}"
    plural: "backupCollections"
    singular: "backupCollection"
  };

  // Identifier. Full resource path of the backup collection.
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Output only. The instance uid of the backup collection.
  string instance_uid = 3 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Output only. The full resource path of the instance the backup collection
  // belongs to. Example:
  // projects/{project}/locations/{location}/instances/{instance}
  string instance = 4 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/Instance"
    }
  ];

  // Output only. The KMS key used to encrypt the backups under this backup
  // collection.
  string kms_key = 5 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "cloudkms.googleapis.com/CryptoKey"
    }
  ];

  // Output only. System assigned unique identifier of the backup collection.
  string uid = 6 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Output only. The time when the backup collection was created.
  google.protobuf.Timestamp create_time = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Backup of an instance.
message Backup {
  option (google.api.resource) = {
    type: "memorystore.googleapis.com/Backup"
    pattern: "projects/{project}/locations/{location}/backupCollections/{backup_collection}/backups/{backup}"
    plural: "backups"
    singular: "backup"
  };

  // Type of the backup.
  enum BackupType {
    // The default value, not set.
    BACKUP_TYPE_UNSPECIFIED = 0;

    // On-demand backup.
    ON_DEMAND = 1;

    // Automated backup.
    AUTOMATED = 2;
  }

  // State of the backup.
  enum State {
    // The default value, not set.
    STATE_UNSPECIFIED = 0;

    // The backup is being created.
    CREATING = 1;

    // The backup is active to be used.
    ACTIVE = 2;

    // The backup is being deleted.
    DELETING = 3;

    // The backup is currently suspended due to reasons like project deletion,
    // billing account closure, etc.
    SUSPENDED = 4;
  }

  // Identifier. Full resource path of the backup. the last part of the name is
  // the backup id with the following format: [YYYYMMDDHHMMSS]_[Shorted Instance
  // UID] OR customer specified while backup instance. Example:
  // 20240515123000_1234
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Output only. The time when the backup was created.
  google.protobuf.Timestamp create_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Instance resource path of this backup.
  string instance = 3 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/Instance"
    }
  ];

  // Output only. Instance uid of this backup.
  string instance_uid = 4 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Output only. Total size of the backup in bytes.
  int64 total_size_bytes = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time when the backup will expire.
  google.protobuf.Timestamp expire_time = 6
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. valkey-7.5/valkey-8.0, etc.
  string engine_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. List of backup files of the backup.
  repeated BackupFile backup_files = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Node type of the instance.
  Instance.NodeType node_type = 9 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Number of replicas for the instance.
  int32 replica_count = 10 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Number of shards for the instance.
  int32 shard_count = 11 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Type of the backup.
  BackupType backup_type = 12 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. State of the backup.
  State state = 13 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. System assigned unique identifier of the backup.
  string uid = 15 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];
}

// Backup is consisted of multiple backup files.
message BackupFile {
  // Output only. e.g: <shard-id>.rdb
  string file_name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Size of the backup file in bytes.
  int64 size_bytes = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time when the backup file was created.
  google.protobuf.Timestamp create_time = 3
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Cross instance replication config.
message CrossInstanceReplicationConfig {
  // Details of the remote instance associated with this instance in a cross
  // instance replication setup.
  message RemoteInstance {
    // Optional. The full resource path of the remote instance in
    // the format: projects/<project>/locations/<region>/instances/<instance-id>
    string instance = 1 [
      (google.api.field_behavior) = OPTIONAL,
      (google.api.resource_reference) = {
        type: "memorystore.googleapis.com/Instance"
      }
    ];

    // Output only. The unique identifier of the remote instance.
    string uid = 2 [
      (google.api.field_info).format = UUID4,
      (google.api.field_behavior) = OUTPUT_ONLY
    ];
  }

  // An output only view of all the member instances participating in the cross
  // instance replication.
  message Membership {
    // Output only. The primary instance that acts as the source of replication
    // for the secondary instances.
    RemoteInstance primary_instance = 1
        [(google.api.field_behavior) = OUTPUT_ONLY];

    // Output only. The list of secondary instances replicating from the primary
    // instance.
    repeated RemoteInstance secondary_instances = 2
        [(google.api.field_behavior) = OUTPUT_ONLY];
  }

  // The role of the instance in cross instance replication.
  enum InstanceRole {
    // instance role is not set.
    // The behavior is equivalent to NONE.
    INSTANCE_ROLE_UNSPECIFIED = 0;

    // This instance does not participate in cross instance replication. It is
    // an independent instance and does not replicate to or from any other
    // instances.
    NONE = 1;

    // A instance that allows both reads and writes. Any data written to this
    // instance is also replicated to the attached secondary instances.
    PRIMARY = 2;

    // A instance that allows only reads and replicates data from a primary
    // instance.
    SECONDARY = 3;
  }

  // Required. The role of the instance in cross instance replication.
  InstanceRole instance_role = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. Details of the primary instance that is used as the replication
  // source for this secondary instance.
  //
  // This field is only set for a secondary instance.
  RemoteInstance primary_instance = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. List of secondary instances that are replicating from this
  // primary instance.
  //
  // This field is only set for a primary instance.
  repeated RemoteInstance secondary_instances = 3
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The last time cross instance replication config was updated.
  google.protobuf.Timestamp update_time = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. An output only view of all the member instances participating
  // in the cross instance replication. This view will be provided by every
  // member instance irrespective of its instance role(primary or secondary).
  //
  // A primary instance can provide information about all the secondary
  // instances replicating from it. However, a secondary instance only knows
  // about the primary instance from which it is replicating. However, for
  // scenarios, where the primary instance is unavailable(e.g. regional outage),
  // a Getinstance request can be sent to any other member instance and this
  // field will list all the member instances participating in cross instance
  // replication.
  Membership membership = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Maintenance policy per instance.
message MaintenancePolicy {
  // Output only. The time when the policy was created.
  google.protobuf.Timestamp create_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time when the policy was updated.
  google.protobuf.Timestamp update_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Maintenance window that is applied to resources covered by this
  // policy. Minimum 1. For the current version, the maximum number of
  // weekly_window is expected to be one.
  repeated WeeklyMaintenanceWindow weekly_maintenance_window = 3
      [(google.api.field_behavior) = OPTIONAL];
}

// Time window specified for weekly operations.
message WeeklyMaintenanceWindow {
  // Optional. Allows to define schedule that runs specified day of the week.
  google.type.DayOfWeek day = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Start time of the window in UTC.
  google.type.TimeOfDay start_time = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Upcoming maintenance schedule.
message MaintenanceSchedule {
  // Output only. The start time of any upcoming scheduled maintenance for this
  // instance.
  google.protobuf.Timestamp start_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The end time of any upcoming scheduled maintenance for this
  // instance.
  google.protobuf.Timestamp end_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Configuration of a service attachment of the cluster, for creating PSC
// connections.
message PscAttachmentDetail {
  // Output only. Service attachment URI which your self-created PscConnection
  // should use as target.
  string service_attachment = 1 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "compute.googleapis.com/ServiceAttachment"
    }
  ];

  // Output only. Type of Psc endpoint.
  ConnectionType connection_type = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Details of consumer resources in a PSC connection.
message PscAutoConnection {
  // Ports of the exposed endpoint.
  oneof ports {
    // Optional. port will only be set for Primary/Reader or Discovery endpoint.
    int32 port = 9 [(google.api.field_behavior) = OPTIONAL];
  }

  // Output only. The PSC connection id of the forwarding rule connected to the
  // service attachment.
  string psc_connection_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The IP allocated on the consumer network for the PSC
  // forwarding rule.
  string ip_address = 2 [
    (google.api.field_info).format = IPV4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Output only. The URI of the consumer side forwarding rule.
  // Format:
  // projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}
  string forwarding_rule = 3 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "compute.googleapis.com/ForwardingRule"
    }
  ];

  // Required. The consumer project_id where PSC connections are established.
  // This should be the same project_id that the instance is being created in.
  string project_id = 4 [(google.api.field_behavior) = REQUIRED];

  // Required. The network where the PSC endpoints are created, in the form of
  // projects/{project_id}/global/networks/{network_id}.
  string network = 5 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "compute.googleapis.com/Network" }
  ];

  // Output only. The service attachment which is the target of the PSC
  // connection, in the form of
  // projects/{project-id}/regions/{region}/serviceAttachments/{service-attachment-id}.
  string service_attachment = 6 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "compute.googleapis.com/ServiceAttachment"
    }
  ];

  // Output only. The status of the PSC connection: whether a connection exists
  // and ACTIVE or it no longer exists. Please note that this value is updated
  // periodically. Please use Private Service Connect APIs for the latest
  // status.
  PscConnectionStatus psc_connection_status = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Type of the PSC connection.
  ConnectionType connection_type = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// User created Psc connection configuration.
message PscConnection {
  // Ports of the exposed endpoint.
  oneof ports {
    // Optional. port will only be set for Primary/Reader or Discovery endpoint.
    int32 port = 9 [(google.api.field_behavior) = OPTIONAL];
  }

  // Required. The PSC connection id of the forwarding rule connected to the
  // service attachment.
  string psc_connection_id = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. The IP allocated on the consumer network for the PSC forwarding
  // rule.
  string ip_address = 2 [
    (google.api.field_info).format = IPV4,
    (google.api.field_behavior) = REQUIRED
  ];

  // Required. The URI of the consumer side forwarding rule.
  // Format:
  // projects/{project}/regions/{region}/forwardingRules/{forwarding_rule}
  string forwarding_rule = 3 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "compute.googleapis.com/ForwardingRule"
    }
  ];

  // Output only. The consumer project_id where the forwarding rule is created
  // from.
  string project_id = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Required. The consumer network where the IP address resides, in the form of
  // projects/{project_id}/global/networks/{network_id}.
  string network = 5 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "compute.googleapis.com/Network" }
  ];

  // Required. The service attachment which is the target of the PSC connection,
  // in the form of
  // projects/{project-id}/regions/{region}/serviceAttachments/{service-attachment-id}.
  string service_attachment = 6 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "compute.googleapis.com/ServiceAttachment"
    }
  ];

  // Output only. The status of the PSC connection: whether a connection exists
  // and ACTIVE or it no longer exists. Please note that this value is updated
  // periodically. Please use Private Service Connect APIs for the latest
  // status.
  PscConnectionStatus psc_connection_status = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Type of the PSC connection.
  ConnectionType connection_type = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Represents an endpoint for clients to connect to the instance.
message DiscoveryEndpoint {
  // Output only. IP address of the exposed endpoint clients connect to.
  string address = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The port number of the exposed endpoint.
  int32 port = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The network where the IP address of the discovery endpoint
  // will be reserved, in the form of
  // projects/{network_project}/global/networks/{network_id}.
  string network = 4 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = { type: "compute.googleapis.com/Network" }
  ];
}

// Represents persistence configuration for a instance.
message PersistenceConfig {
  // Configuration for RDB based persistence.
  message RDBConfig {
    // Possible snapshot periods.
    enum SnapshotPeriod {
      // Not set.
      SNAPSHOT_PERIOD_UNSPECIFIED = 0;

      // One hour.
      ONE_HOUR = 1;

      // Six hours.
      SIX_HOURS = 2;

      // Twelve hours.
      TWELVE_HOURS = 3;

      // Twenty four hours.
      TWENTY_FOUR_HOURS = 4;
    }

    // Optional. Period between RDB snapshots.
    SnapshotPeriod rdb_snapshot_period = 1
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Time that the first snapshot was/will be attempted, and to
    // which future snapshots will be aligned. If not provided, the current time
    // will be used.
    google.protobuf.Timestamp rdb_snapshot_start_time = 2
        [(google.api.field_behavior) = OPTIONAL];
  }

  // Configuration for AOF based persistence.
  message AOFConfig {
    // Possible fsync modes.
    enum AppendFsync {
      // Not set. Default: EVERY_SEC
      APPEND_FSYNC_UNSPECIFIED = 0;

      // Never fsync. Normally Linux will flush data every 30 seconds with this
      // configuration, but it's up to the kernel's exact tuning.
      NEVER = 1;

      // Fsync every second. You may lose 1 second of data if there is a
      // disaster.
      EVERY_SEC = 2;

      // Fsync every time new write commands are appended to the AOF. The best
      // data loss protection at the cost of performance.
      ALWAYS = 3;
    }

    // Optional. The fsync mode.
    AppendFsync append_fsync = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // Possible persistence modes.
  enum PersistenceMode {
    // Not set.
    PERSISTENCE_MODE_UNSPECIFIED = 0;

    // Persistence is disabled, and any snapshot data is deleted.
    DISABLED = 1;

    // RDB based persistence is enabled.
    RDB = 2;

    // AOF based persistence is enabled.
    AOF = 3;
  }

  // Optional. Current persistence mode.
  PersistenceMode mode = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. RDB configuration. This field will be ignored if mode is not RDB.
  RDBConfig rdb_config = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. AOF configuration. This field will be ignored if mode is not AOF.
  AOFConfig aof_config = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Represents configuration for nodes of the instance.
message NodeConfig {
  // Output only. Memory size in GB of the node.
  double size_gb = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Zone distribution configuration for allocation of instance resources.
message ZoneDistributionConfig {
  // Possible zone distribution modes.
  enum ZoneDistributionMode {
    // Not Set. Default: MULTI_ZONE
    ZONE_DISTRIBUTION_MODE_UNSPECIFIED = 0;

    // Distribute resources across 3 zones picked at random within the
    // region.
    MULTI_ZONE = 1;

    // Provision resources in a single zone. Zone field must be specified.
    SINGLE_ZONE = 2;
  }

  // Optional. Defines zone where all resources will be allocated with
  // SINGLE_ZONE mode. Ignored for MULTI_ZONE mode.
  string zone = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Current zone distribution mode. Defaults to MULTI_ZONE.
  ZoneDistributionMode mode = 1 [(google.api.field_behavior) = OPTIONAL];
}

// Request for rescheduling instance maintenance.
message RescheduleMaintenanceRequest {
  // Reschedule options.
  enum RescheduleType {
    // Not set.
    RESCHEDULE_TYPE_UNSPECIFIED = 0;

    // If the user wants to schedule the maintenance to happen now.
    IMMEDIATE = 1;

    // If the user wants to reschedule the maintenance to a specific time.
    SPECIFIC_TIME = 3;
  }

  // Required. Name of the instance to reschedule maintenance for:
  // `projects/{project}/locations/{location_id}/instances/{instance}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/Instance"
    }
  ];

  // Required. If reschedule type is SPECIFIC_TIME, schedule_time must be set.
  RescheduleType reschedule_type = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. Timestamp when the maintenance shall be rescheduled to if
  // reschedule_type=SPECIFIC_TIME, in RFC 3339 format.
  // Example: `2012-11-15T16:19:00.094Z`.
  google.protobuf.Timestamp schedule_time = 3
      [(google.api.field_behavior) = OPTIONAL];
}

// Request message for [ListInstances][].
message ListInstancesRequest {
  // Required. The parent to list instances from.
  // Format: projects/{project}/locations/{location}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "memorystore.googleapis.com/Instance"
    }
  ];

  // Optional. Requested page size. Server may return fewer items than
  // requested. If unspecified, server will pick an appropriate default.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A token identifying a page of results the server should return.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Expression for filtering results.
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Sort results by a defined order. Supported values: "name",
  // "create_time".
  string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for [ListInstances][].
message ListInstancesResponse {
  // If the {location} requested was "-" the response contains a list of
  // instances from all locations. Instances in unreachable locations will be
  // omitted.
  repeated Instance instances = 1;

  // A token, which can be sent as `page_token` to retrieve the next page.
  // If this field is omitted, there are no subsequent pages.
  string next_page_token = 2;

  // Locations that could not be reached.
  repeated string unreachable = 3;
}

// Request message for [GetInstance][].
message GetInstanceRequest {
  // Required. The name of the instance to retrieve.
  // Format: projects/{project}/locations/{location}/instances/{instance}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/Instance"
    }
  ];
}

// Request message for [CreateInstance][].
message CreateInstanceRequest {
  // Required. The parent resource where this instance will be created.
  // Format: projects/{project}/locations/{location}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "memorystore.googleapis.com/Instance"
    }
  ];

  // Required. The ID to use for the instance, which will become the final
  // component of the instance's resource name.
  //
  // This value is subject to the following restrictions:
  //
  // * Must be 4-63 characters in length
  // * Must begin with a letter or digit
  // * Must contain only lowercase letters, digits, and hyphens
  // * Must not end with a hyphen
  // * Must be unique within a location
  string instance_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The instance to create.
  Instance instance = 3 [(google.api.field_behavior) = REQUIRED];

  // Optional. An optional request ID to identify requests. Specify a unique
  // request ID so that if you must retry your request, the server will know to
  // ignore the request if it has already been completed. The server will
  // guarantee that for at least 60 minutes since the first request.
  //
  // For example, consider a situation where you make an initial request and the
  // request times out. If you make the request again with the same request
  // ID, the server can check if original operation with the same request ID
  // was received, and if so, will ignore the second request. This prevents
  // clients from accidentally creating duplicate commitments.
  //
  // The request ID must be a valid UUID with the exception that zero UUID is
  // not supported (00000000-0000-0000-0000-000000000000).
  string request_id = 4 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OPTIONAL
  ];
}

// Request message for [UpdateInstance][].
message UpdateInstanceRequest {
  // Optional. The list of fields to be updated on the instance. At least one
  // field must be specified.
  google.protobuf.FieldMask update_mask = 1
      [(google.api.field_behavior) = OPTIONAL];

  // Required. The instance to update.
  Instance instance = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. An optional request ID to identify requests. Specify a unique
  // request ID so that if you must retry your request, the server will know to
  // ignore the request if it has already been completed. The server will
  // guarantee that for at least 60 minutes since the first request.
  //
  // For example, consider a situation where you make an initial request and the
  // request times out. If you make the request again with the same request
  // ID, the server can check if original operation with the same request ID
  // was received, and if so, will ignore the second request. This prevents
  // clients from accidentally creating duplicate commitments.
  //
  // The request ID must be a valid UUID with the exception that zero UUID is
  // not supported (00000000-0000-0000-0000-000000000000).
  string request_id = 3 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OPTIONAL
  ];
}

// Request message for [DeleteInstance][].
message DeleteInstanceRequest {
  // Required. The name of the instance to delete.
  // Format: projects/{project}/locations/{location}/instances/{instance}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/Instance"
    }
  ];

  // Optional. An optional request ID to identify requests. Specify a unique
  // request ID so that if you must retry your request, the server will know to
  // ignore the request if it has already been completed. The server will
  // guarantee that for at least 60 minutes after the first request.
  //
  // For example, consider a situation where you make an initial request and the
  // request times out. If you make the request again with the same request
  // ID, the server can check if original operation with the same request ID
  // was received, and if so, will ignore the second request. This prevents
  // clients from accidentally creating duplicate commitments.
  //
  // The request ID must be a valid UUID with the exception that zero UUID is
  // not supported (00000000-0000-0000-0000-000000000000).
  string request_id = 2 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OPTIONAL
  ];
}

// Request for [ListBackupCollections]
message ListBackupCollectionsRequest {
  // Required. The resource name of the backupCollection location using the
  // form:
  //     `projects/{project_id}/locations/{location_id}`
  // where `location_id` refers to a Google Cloud region.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "memorystore.googleapis.com/BackupCollection"
    }
  ];

  // Optional. The maximum number of items to return.
  //
  // If not specified, a default value of 1000 will be used by the service.
  // Regardless of the page_size value, the response may include a partial list
  // and a caller should only rely on response's
  // [`next_page_token`][google.cloud.memorystore.v1.ListBackupCollectionsResponse.next_page_token]
  // to determine if there are more clusters left to be queried.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The `next_page_token` value returned from a previous
  // [ListBackupCollections] request, if any.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response for [ListBackupCollections].
message ListBackupCollectionsResponse {
  // A list of backupCollections in the project.
  //
  // If the `location_id` in the parent field of the request is "-", all regions
  // available to the project are queried, and the results aggregated.
  // If in such an aggregated query a location is unavailable, a placeholder
  // backupCollection entry is included in the response with the `name` field
  // set to a value of the form
  // `projects/{project_id}/locations/{location_id}/backupCollections/`- and the
  // `status` field set to ERROR and `status_message` field set to "location not
  // available for ListBackupCollections".
  repeated BackupCollection backup_collections = 1;

  // Token to retrieve the next page of results, or empty if there are no more
  // results in the list.
  string next_page_token = 2;

  // Locations that could not be reached.
  repeated string unreachable = 3;
}

// Request for [GetBackupCollection].
message GetBackupCollectionRequest {
  // Required. Instance backupCollection resource name using the form:
  //     `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}`
  // where `location_id` refers to a Google Cloud region.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/BackupCollection"
    }
  ];
}

// Request for [ListBackups].
message ListBackupsRequest {
  // Required. The resource name of the backupCollection using the form:
  // `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "memorystore.googleapis.com/Backup"
    }
  ];

  // Optional. The maximum number of items to return.
  //
  // If not specified, a default value of 1000 will be used by the service.
  // Regardless of the page_size value, the response may include a partial list
  // and a caller should only rely on response's
  // [`next_page_token`][google.cloud.memorystore.v1.ListBackupsResponse.next_page_token]
  // to determine if there are more clusters left to be queried.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The `next_page_token` value returned from a previous
  // [ListBackupCollections] request, if any.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response for [ListBackups].
message ListBackupsResponse {
  // A list of backups in the project.
  repeated Backup backups = 1;

  // Token to retrieve the next page of results, or empty if there are no more
  // results in the list.
  string next_page_token = 2;

  // Backups that could not be reached.
  repeated string unreachable = 3;
}

// Request for [GetBackup].
message GetBackupRequest {
  // Required. Instance backup resource name using the form:
  // `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}/backups/{backup_id}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/Backup"
    }
  ];
}

// Request for [DeleteBackup].
message DeleteBackupRequest {
  // Required. Instance backup resource name using the form:
  // `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}/backups/{backup_id}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/Backup"
    }
  ];

  // Optional. Idempotent request UUID.
  string request_id = 2 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OPTIONAL
  ];
}

// Request for [ExportBackup].
message ExportBackupRequest {
  // Required. Specify destination to export a backup.
  oneof destination {
    // Google Cloud Storage bucket, like "my-bucket".
    string gcs_bucket = 2;
  }

  // Required. Instance backup resource name using the form:
  // `projects/{project_id}/locations/{location_id}/backupCollections/{backup_collection_id}/backups/{backup_id}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/Backup"
    }
  ];
}

// Request for [BackupInstance].
message BackupInstanceRequest {
  // Required. Instance resource name using the form:
  //  `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
  // where `location_id` refers to a Google Cloud region.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/Instance"
    }
  ];

  // Optional. TTL for the backup to expire. Value range is 1 day to 100 years.
  // If not specified, the default value is 100 years.
  google.protobuf.Duration ttl = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The id of the backup to be created. If not specified, the
  // default value ([YYYYMMDDHHMMSS]_[Shortened Instance UID] is used.
  optional string backup_id = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Request message for [GetCertificateAuthority][].
message GetCertificateAuthorityRequest {
  // Required. The name of the certificate authority.
  // Format:
  // projects/{project}/locations/{location}/instances/{instance}/certificateAuthority
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "memorystore.googleapis.com/Instance"
    }
  ];
}

// A certificate authority for an instance.
message CertificateAuthority {
  option (google.api.resource) = {
    type: "memorystore.googleapis.com/CertificateAuthority"
    pattern: "projects/{project}/locations/{location}/instances/{instance}/certificateAuthority"
    plural: "certificateAuthorities"
    singular: "certificateAuthority"
  };

  // A managed certificate authority.
  message ManagedCertificateAuthority {
    // A certificate chain.
    message CertChain {
      // The certificates that form the CA chain in order of leaf to root.
      repeated string certificates = 1;
    }

    // PEM encoded CA certificate chains for managed server authentication.
    repeated CertChain ca_certs = 1;
  }

  // Information about the server certificate authority.
  oneof server_ca {
    // A managed server certificate authority.
    ManagedCertificateAuthority managed_server_ca = 2;
  }

  // Identifier. Unique name of the certificate authority.
  // Format:
  // projects/{project}/locations/{location}/instances/{instance}
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];
}

// Represents the metadata of a long-running operation.
message OperationMetadata {
  // Output only. The time the operation was created.
  google.protobuf.Timestamp create_time = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time the operation finished running.
  google.protobuf.Timestamp end_time = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Server-defined resource path for the target of the operation.
  string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Name of the verb executed by the operation.
  string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Human-readable status of the operation, if any.
  string status_message = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Identifies whether the user has requested cancellation
  // of the operation. Operations that have been cancelled successfully
  // have [Operation.error][] value with a
  // [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to
  // `Code.CANCELLED`.
  bool requested_cancellation = 6 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. API version used to start the operation.
  string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
}
