// 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/cloud/oracledatabase/v1/pluggable_database.proto";
import "google/protobuf/timestamp.proto";
import "google/type/dayofweek.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 = "DatabaseProto";
option java_package = "com.google.cloud.oracledatabase.v1";
option php_namespace = "Google\\Cloud\\OracleDatabase\\V1";
option ruby_package = "Google::Cloud::OracleDatabase::V1";

// Details of the Database resource.
// https://docs.oracle.com/en-us/iaas/api/#/en/database/20160918/Database/
message Database {
  option (google.api.resource) = {
    type: "oracledatabase.googleapis.com/Database"
    pattern: "projects/{project}/locations/{location}/databases/{database}"
    plural: "databases"
    singular: "database"
  };

  // The Status of Operations Insights for this Database.
  enum OperationsInsightsStatus {
    // Default unspecified value.
    OPERATIONS_INSIGHTS_STATUS_UNSPECIFIED = 0;

    // Indicates that the operations insights are being enabled.
    ENABLING = 1;

    // Indicates that the operations insights are enabled.
    ENABLED = 2;

    // Indicates that the operations insights are being disabled.
    DISABLING = 3;

    // Indicates that the operations insights are not enabled.
    NOT_ENABLED = 4;

    // Indicates that the operations insights failed to enable.
    FAILED_ENABLING = 5;

    // Indicates that the operations insights failed to disable.
    FAILED_DISABLING = 6;
  }

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

  // Optional. The database name. The name must begin with an alphabetic
  // character and can contain a maximum of eight alphanumeric characters.
  // Special characters are not permitted.
  string db_name = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The DB_UNIQUE_NAME of the Oracle Database being backed up.
  string db_unique_name = 3 [(google.api.field_behavior) = OPTIONAL];

  // Required. The password for the default ADMIN user.
  string admin_password = 4 [(google.api.field_behavior) = REQUIRED];

  // Optional. The TDE wallet password for the database.
  string tde_wallet_password = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The character set for the database. The default is AL32UTF8.
  string character_set = 6 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The national character set for the database. The default is
  // AL16UTF16.
  string ncharacter_set = 7 [(google.api.field_behavior) = OPTIONAL];

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

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

  // Optional. The properties of the Database.
  DatabaseProperties properties = 10 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The database ID of the Database.
  string database_id = 11 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The name of the DbHome resource associated with the Database.
  string db_home_name = 12 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The GCP Oracle zone where the Database is created.
  string gcp_oracle_zone = 13 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The Status of Operations Insights for this Database.
  OperationsInsightsStatus ops_insights_status = 14
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The properties of a Database.
message DatabaseProperties {
  // The various lifecycle states of the Database.
  enum DatabaseLifecycleState {
    // Default unspecified value.
    DATABASE_LIFECYCLE_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 updating state.
    UPDATING = 3;

    // Indicates that the resource is in backup in progress state.
    BACKUP_IN_PROGRESS = 4;

    // Indicates that the resource is in upgrading state.
    UPGRADING = 5;

    // Indicates that the resource is in converting state.
    CONVERTING = 6;

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

    // Indicates that the resource is in terminated state.
    TERMINATED = 8;

    // Indicates that the resource is in restore failed state.
    RESTORE_FAILED = 9;

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

  // Output only. State of the Database.
  DatabaseLifecycleState state = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Required. The Oracle Database version.
  string db_version = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. Backup options for the Database.
  DbBackupConfig db_backup_config = 3 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The Database Management config.
  DatabaseManagementConfig database_management_config = 4
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Backup Options for the Database.
message DbBackupConfig {
  // The details of the database backup destination.
  message BackupDestinationDetails {
    // Optional. The type of the database backup destination.
    BackupDestinationType type = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // The type of the database backup destination.
  enum BackupDestinationType {
    // Default unspecified value.
    BACKUP_DESTINATION_TYPE_UNSPECIFIED = 0;

    // Backup destination type is NFS.
    NFS = 1;

    // Backup destination type is Recovery Appliance.
    RECOVERY_APPLIANCE = 2;

    // Backup destination type is Object Store.
    OBJECT_STORE = 3;

    // Backup destination type is Local.
    LOCAL = 4;

    // Backup destination type is DBRS.
    DBRS = 5;
  }

  // The 2 hour window in which the backup should be performed on the database.
  enum BackupWindow {
    // Default unspecified value.
    BACKUP_WINDOW_UNSPECIFIED = 0;

    // 12:00 AM - 2:00 AM
    SLOT_ONE = 1;

    // 2:00 AM - 4:00 AM
    SLOT_TWO = 2;

    // 4:00 AM - 6:00 AM
    SLOT_THREE = 3;

    // 6:00 AM - 8:00 AM
    SLOT_FOUR = 4;

    // 8:00 AM - 10:00 AM
    SLOT_FIVE = 5;

    // 10:00 AM - 12:00 PM
    SLOT_SIX = 6;

    // 12:00 PM - 2:00 PM
    SLOT_SEVEN = 7;

    // 2:00 PM - 4:00 PM
    SLOT_EIGHT = 8;

    // 4:00 PM - 6:00 PM
    SLOT_NINE = 9;

    // 6:00 PM - 8:00 PM
    SLOT_TEN = 10;

    // 8:00 PM - 10:00 PM
    SLOT_ELEVEN = 11;

    // 10:00 PM - 12:00 AM
    SLOT_TWELVE = 12;
  }

  // This defines when the backups will be deleted after Database termination.
  enum BackupDeletionPolicy {
    // Default unspecified value.
    BACKUP_DELETION_POLICY_UNSPECIFIED = 0;

    // Keeps the backup for predefined time
    // i.e. 72 hours and then delete permanently.
    DELETE_IMMEDIATELY = 1;

    // Keeps the backups as per the policy defined
    // for database backups.
    DELETE_AFTER_RETENTION_PERIOD = 2;
  }

  // Optional. If set to true, enables automatic backups on the database.
  bool auto_backup_enabled = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Details of the database backup destinations.
  repeated BackupDestinationDetails backup_destination_details = 2
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The number of days an automatic backup is retained before being
  // automatically deleted. This value determines the earliest point in time to
  // which a database can be restored. Min: 1, Max: 60.
  int32 retention_period_days = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. This defines when the backups will be deleted after Database
  // termination.
  BackupDeletionPolicy backup_deletion_policy = 4
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The day of the week on which the full backup should be performed
  // on the database. If no value is provided, it will default to Sunday.
  google.type.DayOfWeek auto_full_backup_day = 5
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The window in which the full backup should be performed on the
  // database. If no value is provided, the default is anytime.
  BackupWindow auto_full_backup_window = 6
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. The window in which the incremental backup should be performed on
  // the database. If no value is provided, the default is anytime except the
  // auto full backup day.
  BackupWindow auto_incremental_backup_window = 7
      [(google.api.field_behavior) = OPTIONAL];
}

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

// The request for `Database.List`.
message ListDatabasesRequest {
  // Required. The parent resource name in the following format:
  // projects/{project}/locations/{region}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "oracledatabase.googleapis.com/Database"
    }
  ];

  // Optional. The maximum number of items to return.
  // If unspecified, a maximum of 50 Databases will be returned.
  // The maximum value is 1000; values above 1000 will be reset to 1000.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A token identifying the requested page of results to return. All
  // fields except the filter should remain the same as in the request that
  // provided this page token.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

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

// The response for `Database.List`.
message ListDatabasesResponse {
  // The list of Databases.
  repeated Database databases = 1;

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