// Copyright 2026 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";

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

// A directory policy for a Managed Lustre instance.
message DirectoryPolicy {
  option (google.api.resource) = {
    type: "lustre.googleapis.com/DirectoryPolicy"
    pattern: "projects/{project}/locations/{location}/instances/{instance}/directoryPolicies/{directory_policy}"
    plural: "directoryPolicies"
    singular: "directoryPolicy"
  };

  // State of the directory policy.
  enum State {
    // State is unspecified.
    STATE_UNSPECIFIED = 0;

    // Directory policy is being created.
    CREATING = 1;

    // Directory policy is active and ready to be used.
    ACTIVE = 2;

    // Directory policy is being deleted.
    DELETING = 3;
  }

  // Immutable. Identifier. The resource name of the directory policy.
  // DirectoryPolicy names have the form
  // `projects/{project}/locations/{location}/instances/{instance}/directoryPolicies/{id}`.
  // {id} is user provided.
  string name = 1 [
    (google.api.field_behavior) = IDENTIFIER,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Required. Immutable. The lustre instance filesystem full path of the
  // directory. It must start with a slash. e.g. /lustre/testFolder
  string directory_path = 2 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Output only. The lustre project ID assigned for the directory by the
  // service. This read-only ID can be used to manage quotas. See more details
  // in
  // https://docs.cloud.google.com/managed-lustre/docs/file-system-quotas#set_quotas
  int64 lustre_project_id = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Unique ID of the resource.
  string uid = 4 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Output only. The current state of the directory policy.
  State state = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Request message for CreateDirectoryPolicy.
message CreateDirectoryPolicyRequest {
  // Required. The parent instance.
  // It must be in the format of
  // `projects/{project}/locations/{location}/instances/{instance}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "lustre.googleapis.com/DirectoryPolicy"
    }
  ];

  // Required. The ID for the DirectoryPolicy to create.
  string directory_policy_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The directory policy to create.
  DirectoryPolicy directory_policy = 3 [(google.api.field_behavior) = REQUIRED];
}

// Request message for DeleteDirectoryPolicy.
message DeleteDirectoryPolicyRequest {
  // Required. The resource name of the directory policy.
  // DirectoryPolicy names have the form
  // `projects/{project}/locations/{location}/instances/{instance}/directoryPolicies/{id}`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "lustre.googleapis.com/DirectoryPolicy"
    }
  ];
}

// Request message for GetDirectoryPolicy.
message GetDirectoryPolicyRequest {
  // Required. The resource name of the directory policy.
  // DirectoryPolicy names have the form
  // `projects/{project}/locations/{location}/instances/{instance}/directoryPolicies/{id}`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "lustre.googleapis.com/DirectoryPolicy"
    }
  ];
}

// Request message for ListDirectoryPolicies.
message ListDirectoryPoliciesRequest {
  // Required. The parent instance.
  // It must be in the format of
  // `projects/{project}/locations/{location}/instances/{instance}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "lustre.googleapis.com/DirectoryPolicy"
    }
  ];

  // Optional. Requested page size. Server might return fewer items than
  // requested. If unspecified, the server will pick an appropriate default. The
  // maximum value is 1000; values above 1000 will be coerced to 1000.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A page token, received from a previous `ListDirectoryPolicies`
  // call. Provide this to retrieve the subsequent page. When paginating, all
  // other parameters provided to `ListDirectoryPolicies` must match the call
  // that provided the page token.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for ListDirectoryPolicies.
message ListDirectoryPoliciesResponse {
  // The list of DirectoryPolicies.
  repeated DirectoryPolicy directory_policies = 1;

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