// 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.lustre.v1;

import "google/api/field_behavior.proto";
import "google/api/field_info.proto";
import "google/api/resource.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";

option go_package = "cloud.google.com/go/lustre/apiv1/lustrepb;lustrepb";
option java_multiple_files = true;
option java_outer_classname = "InstanceProto";
option java_package = "com.google.cloud.lustre.v1";

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

  // The possible states of an instance.
  enum State {
    // Not set.
    STATE_UNSPECIFIED = 0;

    // The instance is available for use.
    ACTIVE = 1;

    // The instance is being created and is not yet ready for use.
    CREATING = 2;

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

    // The instance is being upgraded.
    UPGRADING = 4;

    // The instance is being repaired.
    REPAIRING = 5;

    // The instance is stopped.
    STOPPED = 6;

    // The instance is being updated.
    UPDATING = 7;
  }

  // Identifier. The name of the instance.
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. Immutable. The filesystem name for this instance. This name is
  // used by client-side tools, including when mounting the instance. Must be
  // eight characters or less and can only contain letters and numbers.
  string filesystem = 10 [
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.field_behavior) = REQUIRED
  ];

  // Required. The storage capacity of the instance in gibibytes (GiB). Allowed
  // values are from `18000` to `954000`, in increments of 9000.
  int64 capacity_gib = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. Immutable. The full name of the VPC network to which the instance
  // is connected. Must be in the format
  // `projects/{project_id}/global/networks/{network_name}`.
  string network = 3 [
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "compute.googleapis.com/Network" }
  ];

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

  // Output only. Mount point of the instance in the format
  // `IP_ADDRESS@tcp:/FILESYSTEM`.
  string mount_point = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Timestamp when the instance was created.
  google.protobuf.Timestamp create_time = 6
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Timestamp when the instance was last updated.
  google.protobuf.Timestamp update_time = 7
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. A user-readable description of the instance.
  string description = 8 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Labels as key value pairs.
  map<string, string> labels = 9 [(google.api.field_behavior) = OPTIONAL];

  // Required. The throughput of the instance in MB/s/TiB.
  // Valid values are 125, 250, 500, 1000.
  int64 per_unit_storage_throughput = 11
      [(google.api.field_behavior) = REQUIRED];

  // Optional. Indicates whether you want to enable support for GKE clients. By
  // default, GKE clients are not supported. Deprecated. No longer required for
  // GKE instance creation.
  bool gke_support_enabled = 12
      [deprecated = true, (google.api.field_behavior) = OPTIONAL];
}

// Message for requesting list of Instances
message ListInstancesRequest {
  // Required. The project and location for which to retrieve a list of
  // instances, in the format `projects/{projectId}/locations/{location}`.
  //
  // To retrieve instance information for all locations, use "-" as the value
  // of `{location}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "lustre.googleapis.com/Instance"
    }
  ];

  // Optional. Requested page size. Server might return fewer items than
  // requested. If unspecified, the 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. Filtering results.
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Desired order of results.
  string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Message for response to listing Instances
message ListInstancesResponse {
  // Response from [ListInstances][google.cloud.lustre.v1.Lustre.ListInstances].
  repeated Instance instances = 1;

  // A token identifying a page of results the server should return.
  string next_page_token = 2;

  // Unordered list. Locations that could not be reached.
  repeated string unreachable = 3
      [(google.api.field_behavior) = UNORDERED_LIST];
}

// Message for getting a Instance
message GetInstanceRequest {
  // Required. The instance resource name, in the format
  // `projects/{projectId}/locations/{location}/instances/{instanceId}`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "lustre.googleapis.com/Instance" }
  ];
}

// Message for creating a Instance
message CreateInstanceRequest {
  // Required. The instance's project and location, in the format
  // `projects/{project}/locations/{location}`. Locations map to Google Cloud
  // zones; for example, `us-west1-b`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "lustre.googleapis.com/Instance"
    }
  ];

  // Required. The name of the Managed Lustre instance.
  //
  // * Must contain only lowercase letters, numbers, and hyphens.
  // * Must start with a letter.
  // * Must be between 1-63 characters.
  // * Must end with a number or a letter.
  string instance_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The resource being created
  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
  ];
}

// Message for updating a Instance
message UpdateInstanceRequest {
  // Optional. Specifies the fields to be overwritten in the instance resource
  // by the update.
  //
  // The fields specified in the update_mask are relative to the resource, not
  // the full request. A field will be overwritten if it is in the mask. If no
  // mask is provided then all fields present in the request are
  // overwritten.
  google.protobuf.FieldMask update_mask = 1
      [(google.api.field_behavior) = OPTIONAL];

  // Required. The resource name of the instance to update, in the format
  // `projects/{projectId}/locations/{location}/instances/{instanceId}`.
  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
  ];
}

// Message for deleting a Instance
message DeleteInstanceRequest {
  // Required. The resource name of the instance to delete, in the format
  // `projects/{projectId}/locations/{location}/instances/{instanceId}`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "lustre.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
  ];
}

// 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];
}
