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

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

option csharp_namespace = "Google.Cloud.OracleDatabase.V1";
option go_package = "cloud.google.com/go/oracledatabase/apiv1/oracledatabasepb;oracledatabasepb";
option java_multiple_files = true;
option java_outer_classname = "OdbSubnetProto";
option java_package = "com.google.cloud.oracledatabase.v1";
option php_namespace = "Google\\Cloud\\OracleDatabase\\V1";
option ruby_package = "Google::Cloud::OracleDatabase::V1";

// Represents OdbSubnet resource.
message OdbSubnet {
  option (google.api.resource) = {
    type: "oracledatabase.googleapis.com/OdbSubnet"
    pattern: "projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}"
    plural: "odbSubnets"
    singular: "odbSubnet"
  };

  // Purpose available for the subnet.
  enum Purpose {
    // Default unspecified value.
    PURPOSE_UNSPECIFIED = 0;

    // Subnet to be used for client connections.
    CLIENT_SUBNET = 1;

    // Subnet to be used for backup.
    BACKUP_SUBNET = 2;
  }

  // The various lifecycle states of the ODB Subnet.
  enum State {
    // Default unspecified value.
    STATE_UNSPECIFIED = 0;

    // Indicates that the resource is in provisioning state.
    PROVISIONING = 1;

    // Indicates that the resource is in available state.
    AVAILABLE = 2;

    // Indicates that the resource is in terminating state.
    TERMINATING = 3;

    // Indicates that the resource is in failed state.
    FAILED = 4;
  }

  // Identifier. The name of the OdbSubnet resource in the following format:
  // projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. The CIDR range of the subnet.
  string cidr_range = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. Purpose of the subnet.
  Purpose purpose = 3 [(google.api.field_behavior) = REQUIRED];

  // Optional. Labels or tags associated with the resource.
  map<string, string> labels = 4 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The date and time that the OdbNetwork was created.
  google.protobuf.Timestamp create_time = 5
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. State of the ODB Subnet.
  State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The request for `OdbSubnet.Create`.
message CreateOdbSubnetRequest {
  // Required. The parent value for the OdbSubnet in the following format:
  // projects/{project}/locations/{location}/odbNetworks/{odb_network}.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "oracledatabase.googleapis.com/OdbSubnet"
    }
  ];

  // Required. The ID of the OdbSubnet to create. This value is restricted
  // to (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$) and must be a maximum of 63
  // characters in length. The value must start with a letter and end with
  // a letter or a number.
  string odb_subnet_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. Details of the OdbSubnet instance to create.
  OdbSubnet odb_subnet = 3 [(google.api.field_behavior) = REQUIRED];

  // Optional. An optional ID to identify the request. This value is used to
  // identify duplicate requests. If you make a request with the same request ID
  // and the original request is still in progress or completed, the server
  // ignores 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
  ];
}

// The request for `OdbSubnet.Delete`.
message DeleteOdbSubnetRequest {
  // Required. The name of the resource in the following format:
  // projects/{project}/locations/{region}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/OdbSubnet"
    }
  ];

  // Optional. An optional ID to identify the request. This value is used to
  // identify duplicate requests. If you make a request with the same request ID
  // and the original request is still in progress or completed, the server
  // ignores 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
  ];
}

// The request for `OdbSubnet.List`.
message ListOdbSubnetsRequest {
  // Required. The parent value for the OdbSubnet in the following format:
  // projects/{project}/locations/{location}/odbNetworks/{odb_network}.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "oracledatabase.googleapis.com/OdbSubnet"
    }
  ];

  // Optional. The maximum number of items to return.
  // If unspecified, at most 50 ODB Networks will be returned.
  // The maximum value is 1000; values above 1000 will be coerced to 1000.
  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. An expression for filtering the results of the request.
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. An expression for ordering the results of the request.
  string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
}

// The response for `OdbSubnet.List`.
message ListOdbSubnetsResponse {
  // The list of ODB Subnets.
  repeated OdbSubnet odb_subnets = 1;

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

  // Unreachable locations when listing resources across all locations using
  // wildcard location '-'.
  repeated string unreachable = 3;
}

// The request for `OdbSubnet.Get`.
message GetOdbSubnetRequest {
  // Required. The name of the OdbSubnet in the following format:
  // projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/OdbSubnet"
    }
  ];
}
