// 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/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 = "PluggableDatabaseProto";
option java_package = "com.google.cloud.oracledatabase.v1";
option php_namespace = "Google\\Cloud\\OracleDatabase\\V1";
option ruby_package = "Google::Cloud::OracleDatabase::V1";

// The PluggableDatabase resource.
// https://docs.oracle.com/en-us/iaas/api/#/en/database/20160918/PluggableDatabase/
message PluggableDatabase {
  option (google.api.resource) = {
    type: "oracledatabase.googleapis.com/PluggableDatabase"
    pattern: "projects/{project}/locations/{location}/pluggableDatabases/{pluggable_database}"
    plural: "pluggableDatabases"
    singular: "pluggableDatabase"
  };

  // Identifier. The name of the PluggableDatabase resource in the following
  // format:
  // projects/{project}/locations/{region}/pluggableDatabases/{pluggable_database}
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Optional. The properties of the PluggableDatabase.
  PluggableDatabaseProperties properties = 2
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. HTTPS link to OCI resources exposed to Customer via UI
  // Interface.
  string oci_url = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

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

// The properties of a PluggableDatabase.
message PluggableDatabaseProperties {
  // Wrapper message for the value of a defined tag.
  message DefinedTagValue {
    // The tags within the namespace.
    map<string, string> tags = 1;
  }

  // The various lifecycle states of the PluggableDatabase.
  enum PluggableDatabaseLifecycleState {
    // The lifecycle state is unspecified.
    PLUGGABLE_DATABASE_LIFECYCLE_STATE_UNSPECIFIED = 0;

    // The pluggable database is provisioning.
    PROVISIONING = 1;

    // The pluggable database is available.
    AVAILABLE = 2;

    // The pluggable database is terminating.
    TERMINATING = 3;

    // The pluggable database is terminated.
    TERMINATED = 4;

    // The pluggable database is updating.
    UPDATING = 5;

    // The pluggable database is in a failed state.
    FAILED = 6;

    // The pluggable database is relocating.
    RELOCATING = 7;

    // The pluggable database is relocated.
    RELOCATED = 8;

    // The pluggable database is refreshing.
    REFRESHING = 9;

    // The pluggable database is restoring.
    RESTORE_IN_PROGRESS = 10;

    // The pluggable database restore failed.
    RESTORE_FAILED = 11;

    // The pluggable database is backing up.
    BACKUP_IN_PROGRESS = 12;

    // The pluggable database is disabled.
    DISABLED = 13;
  }

  // The status of Operations Insights for this Database.
  enum OperationsInsightsState {
    // The status is not specified.
    OPERATIONS_INSIGHTS_STATE_UNSPECIFIED = 0;

    // Operations Insights is enabling.
    ENABLING = 1;

    // Operations Insights is enabled.
    ENABLED = 2;

    // Operations Insights is disabling.
    DISABLING = 3;

    // Operations Insights is not enabled.
    NOT_ENABLED = 4;

    // Operations Insights failed to enable.
    FAILED_ENABLING = 5;

    // Operations Insights failed to disable.
    FAILED_DISABLING = 6;
  }

  // Required. The OCID of the compartment.
  string compartment_id = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. The Connection strings used to connect to the Oracle Database.
  PluggableDatabaseConnectionStrings connection_strings = 2
      [(google.api.field_behavior) = OPTIONAL];

  // Required. The OCID of the CDB.
  string container_database_ocid = 3 [(google.api.field_behavior) = REQUIRED];

  // Optional. Defined tags for this resource. Each key is predefined and scoped
  // to a namespace.
  map<string, DefinedTagValue> defined_tags = 4
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Free-form tags for this resource. Each tag is a simple key-value
  // pair with no predefined name, type, or namespace.
  map<string, string> freeform_tags = 5
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The OCID of the pluggable database.
  string ocid = 6 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The restricted mode of the pluggable database. If a pluggable
  // database is opened in restricted mode, the user needs both create a session
  // and have restricted session privileges to connect to it.
  bool is_restricted = 7 [(google.api.field_behavior) = OPTIONAL];

  // Output only. Additional information about the current lifecycle state.
  string lifecycle_details = 8 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The current state of the pluggable database.
  PluggableDatabaseLifecycleState lifecycle_state = 9
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Required. The database name.
  string pdb_name = 10 [(google.api.field_behavior) = REQUIRED];

  // Optional. Pluggable Database Node Level Details
  repeated PluggableDatabaseNodeLevelDetails pdb_node_level_details = 11
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The configuration of the Database Management service.
  DatabaseManagementConfig database_management_config = 13
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The status of Operations Insights for this Database.
  OperationsInsightsState operations_insights_state = 14
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The connection strings used to connect to the Oracle Database.
message PluggableDatabaseConnectionStrings {
  // Optional. All connection strings to use to connect to the pluggable
  // database.
  map<string, string> all_connection_strings = 1
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The default connection string to use to connect to the pluggable
  // database.
  string pdb_default = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The default connection string to use to connect to the pluggable
  // database using IP.
  string pdb_ip_default = 3 [(google.api.field_behavior) = OPTIONAL];
}

// The Pluggable Database Node Level Details.
message PluggableDatabaseNodeLevelDetails {
  // The mode that the pluggable database is in to open it.
  enum PluggableDatabaseOpenMode {
    // The open mode is unspecified.
    PLUGGABLE_DATABASE_OPEN_MODE_UNSPECIFIED = 0;

    // The pluggable database is opened in read-only mode.
    READ_ONLY = 1;

    // The pluggable database is opened in read-write mode.
    READ_WRITE = 2;

    // The pluggable database is mounted.
    MOUNTED = 3;

    // The pluggable database is migrated.
    MIGRATE = 4;
  }

  // Required. The Node name of the Database home.
  string node_name = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. The mode that the pluggable database is in to open it.
  PluggableDatabaseOpenMode open_mode = 2
      [(google.api.field_behavior) = REQUIRED];

  // Required. The OCID of the Pluggable Database.
  string pluggable_database_id = 3 [(google.api.field_behavior) = REQUIRED];
}

// The configuration of the Database Management service.
message DatabaseManagementConfig {
  // The status of the Database Management service.
  enum ManagementState {
    // The status is not specified.
    MANAGEMENT_STATE_UNSPECIFIED = 0;

    // The Database Management service is enabling.
    ENABLING = 1;

    // The Database Management service is enabled.
    ENABLED = 2;

    // The Database Management service is disabling.
    DISABLING = 3;

    // The Database Management service is disabled.
    DISABLED = 4;

    // The Database Management service is updating.
    UPDATING = 5;

    // The Database Management service failed to enable.
    FAILED_ENABLING = 6;

    // The Database Management service failed to disable.
    FAILED_DISABLING = 7;

    // The Database Management service failed to update.
    FAILED_UPDATING = 8;
  }

  // The Database Management type.
  enum ManagementType {
    // The type is not specified.
    MANAGEMENT_TYPE_UNSPECIFIED = 0;

    // Basic Database Management.
    BASIC = 1;

    // Advanced Database Management.
    ADVANCED = 2;
  }

  // Output only. The status of the Database Management service.
  ManagementState management_state = 1
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The Database Management type.
  ManagementType management_type = 2
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The request for `PluggableDatabase.Get`.
message GetPluggableDatabaseRequest {
  // Required. The name of the PluggableDatabase resource in the following
  // format:
  // projects/{project}/locations/{region}/pluggableDatabases/{pluggable_database}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/PluggableDatabase"
    }
  ];
}

// The request for `PluggableDatabase.List`.
message ListPluggableDatabasesRequest {
  // Required. The parent, which owns this collection of PluggableDatabases.
  // Format: projects/{project}/locations/{location}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "oracledatabase.googleapis.com/PluggableDatabase"
    }
  ];

  // Optional. The maximum number of PluggableDatabases to return. The service
  // may return fewer than this value.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

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

  // Optional. An expression for filtering the results of the request. List for
  // pluggable databases is supported only with a valid container database (full
  // resource name) filter in this format:
  // `database="projects/{project}/locations/{location}/databases/{database}"`
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];
}

// The response for `PluggableDatabase.List`.
message ListPluggableDatabasesResponse {
  // The list of PluggableDatabases.
  repeated PluggableDatabase pluggable_databases = 1;

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