// 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/cloud/oracledatabase/v1/database.proto";
import "google/protobuf/timestamp.proto";
import "google/type/datetime.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 = "DbSystemProto";
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 DbSystem (BaseDB) resource.
// https://docs.oracle.com/en-us/iaas/api/#/en/database/20160918/DbSystem/
message DbSystem {
  option (google.api.resource) = {
    type: "oracledatabase.googleapis.com/DbSystem"
    pattern: "projects/{project}/locations/{location}/dbSystems/{db_system}"
    plural: "dbSystems"
    singular: "dbSystem"
  };

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

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

  // Optional. The GCP Oracle zone where Oracle DbSystem is hosted.
  // Example: us-east4-b-r2.
  // If not specified, the system will pick a zone based on availability.
  string gcp_oracle_zone = 3 [(google.api.field_behavior) = OPTIONAL];

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

  // Optional. The name of the OdbNetwork associated with the DbSystem.
  // Format: projects/{project}/locations/{location}/odbNetworks/{odb_network}
  // It is optional but if specified, this should match the parent ODBNetwork of
  // the OdbSubnet.
  string odb_network = 5 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/OdbNetwork"
    }
  ];

  // Required. The name of the OdbSubnet associated with the DbSystem for IP
  // allocation. Format:
  // projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}
  string odb_subnet = 6 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/OdbSubnet"
    }
  ];

  // Output only. The ID of the subscription entitlement associated with the
  // DbSystem
  string entitlement_id = 7 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Required. The display name for the System db. The name does not have to
  // be unique within your project.
  string display_name = 8 [(google.api.field_behavior) = REQUIRED];

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

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

// The properties of a DbSystem.
message DbSystemProperties {
  // The editions available for DbSystem.
  enum DbSystemDatabaseEdition {
    // The database edition is unspecified.
    DB_SYSTEM_DATABASE_EDITION_UNSPECIFIED = 0;

    // The database edition is Standard.
    STANDARD_EDITION = 1;

    // The database edition is Enterprise.
    ENTERPRISE_EDITION = 2;

    // The database edition is Enterprise Edition.
    ENTERPRISE_EDITION_HIGH_PERFORMANCE = 3;
  }

  // The license model of the DbSystem.
  enum LicenseModel {
    // The license model is unspecified.
    LICENSE_MODEL_UNSPECIFIED = 0;

    // The license model is included.
    LICENSE_INCLUDED = 1;

    // The license model is bring your own license.
    BRING_YOUR_OWN_LICENSE = 2;
  }

  // The various lifecycle states of the DbSystem.
  enum DbSystemLifecycleState {
    // Default unspecified value.
    DB_SYSTEM_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 terminating state.
    TERMINATING = 4;

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

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

    // Indicates that the resource has been migrated.
    MIGRATED = 7;

    // Indicates that the resource is in maintenance in progress state.
    MAINTENANCE_IN_PROGRESS = 8;

    // Indicates that the resource needs attention.
    NEEDS_ATTENTION = 9;

    // Indicates that the resource is upgrading.
    UPGRADING = 10;
  }

  // The compute model of the DbSystem.
  enum ComputeModel {
    // The compute model is unspecified.
    COMPUTE_MODEL_UNSPECIFIED = 0;

    // The compute model is virtual.
    ECPU = 1;

    // The compute model is physical.
    OCPU = 2;
  }

  // Required. Shape of DB System.
  string shape = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. The number of CPU cores to enable for the DbSystem.
  int32 compute_count = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The initial data storage size in GB.
  int32 initial_data_storage_size_gb = 3
      [(google.api.field_behavior) = REQUIRED];

  // Required. The database edition of the DbSystem.
  DbSystemDatabaseEdition database_edition = 4
      [(google.api.field_behavior) = REQUIRED];

  // Required. The license model of the DbSystem.
  LicenseModel license_model = 5 [(google.api.field_behavior) = REQUIRED];

  // Required. SSH public keys to be stored with the DbSystem.
  repeated string ssh_public_keys = 6 [(google.api.field_behavior) = REQUIRED];

  // Optional. Prefix for DB System host names.
  string hostname_prefix = 7 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The hostname of the DbSystem.
  string hostname = 8 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The private IP address of the DbSystem.
  string private_ip = 9 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Data collection options for diagnostics.
  DataCollectionOptionsDbSystem data_collection_options = 10
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Time zone of the DbSystem.
  google.type.TimeZone time_zone = 11 [(google.api.field_behavior) = OPTIONAL];

  // Output only. State of the DbSystem.
  DbSystemLifecycleState lifecycle_state = 12
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Details for creating a Database Home.
  DbHome db_home = 13 [(google.api.field_behavior) = OPTIONAL];

  // Output only. OCID of the DbSystem.
  string ocid = 14 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The memory size in GB.
  int32 memory_size_gb = 15 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The compute model of the DbSystem.
  ComputeModel compute_model = 16 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The data storage size in GB that is currently available to
  // DbSystems.
  int32 data_storage_size_gb = 17 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The reco/redo storage size in GB.
  int32 reco_storage_size_gb = 18 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The host domain name of the DbSystem.
  string domain = 19 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The number of nodes in the DbSystem.
  int32 node_count = 20 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The options for the DbSystem.
  DbSystemOptions db_system_options = 21
      [(google.api.field_behavior) = OPTIONAL];
}

// Data collection options for DbSystem.
message DataCollectionOptionsDbSystem {
  // Optional. Indicates whether to enable data collection for diagnostics.
  bool is_diagnostics_events_enabled = 1
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Indicates whether to enable incident logs and trace collection.
  bool is_incident_logs_enabled = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Details of the DbSystem Options.
message DbSystemOptions {
  // The storage option used in DB system.
  enum StorageManagement {
    // The storage management is unspecified.
    STORAGE_MANAGEMENT_UNSPECIFIED = 0;

    // Automatic storage management.
    ASM = 1;

    // Logical Volume management.
    LVM = 2;
  }

  // Optional. The storage option used in DB system.
  StorageManagement storage_management = 1
      [(google.api.field_behavior) = OPTIONAL];
}

// Details of the Database Home resource.
message DbHome {
  // Optional. The display name for the Database Home. The name does not have to
  // be unique within your project.
  string display_name = 1 [(google.api.field_behavior) = OPTIONAL];

  // Required. A valid Oracle Database version. For a list of supported
  // versions, use the ListDbVersions operation.
  string db_version = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The Database resource.
  Database database = 3 [(google.api.field_behavior) = REQUIRED];

  // Optional. Whether unified auditing is enabled for the Database Home.
  bool is_unified_auditing_enabled = 4 [(google.api.field_behavior) = OPTIONAL];
}

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

  // Required. The ID of the DbSystem 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 db_system_id = 2 [(google.api.field_behavior) = REQUIRED];

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

// The request for `DbSystem.Delete`.
message DeleteDbSystemRequest {
  // Required. The name of the DbSystem in the following format:
  // projects/{project}/locations/{location}/dbSystems/{db_system}.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/DbSystem"
    }
  ];

  // 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 `DbSystem.Get`.
message GetDbSystemRequest {
  // Required. The name of the DbSystem in the following format:
  // projects/{project}/locations/{location}/dbSystems/{db_system}.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/DbSystem"
    }
  ];
}

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

  // Optional. The maximum number of items to return.
  // If unspecified, at most 50 DbSystems 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 `DbSystem.List`.
message ListDbSystemsResponse {
  // The list of DbSystems.
  repeated DbSystem db_systems = 1;

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