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

// ExadbVmCluster represents a cluster of VMs that are used to run Exadata
// workloads.
// https://docs.oracle.com/en-us/iaas/api/#/en/database/20160918/ExadbVmCluster/
message ExadbVmCluster {
  option (google.api.resource) = {
    type: "oracledatabase.googleapis.com/ExadbVmCluster"
    pattern: "projects/{project}/locations/{location}/exadbVmClusters/{exadb_vm_cluster}"
    plural: "exadbVmClusters"
    singular: "exadbVmCluster"
  };

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

  // Required. The properties of the ExadbVmCluster.
  ExadbVmClusterProperties properties = 2
      [(google.api.field_behavior) = REQUIRED];

  // Output only. Immutable. The GCP Oracle zone where Oracle ExadbVmCluster is
  // hosted. Example: us-east4-b-r2. During creation, the system will pick the
  // zone assigned to the ExascaleDbStorageVault.
  string gcp_oracle_zone = 3 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.field_behavior) = IMMUTABLE
  ];

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

  // Optional. Immutable. The name of the OdbNetwork associated with the
  // ExadbVmCluster. 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 = 6 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/OdbNetwork"
    }
  ];

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

  // Required. Immutable. The name of the backup OdbSubnet associated with the
  // ExadbVmCluster. Format:
  // projects/{project}/locations/{location}/odbNetworks/{odb_network}/odbSubnets/{odb_subnet}
  string backup_odb_subnet = 8 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/OdbSubnet"
    }
  ];

  // Required. Immutable. The display name for the ExadbVmCluster. The name does
  // not have to be unique within your project. The name must be 1-255
  // characters long and can only contain alphanumeric characters.
  string display_name = 9 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE
  ];

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

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

// The storage allocation for the exadbvmcluster, in gigabytes (GB).
message ExadbVmClusterStorageDetails {
  // Required. The storage allocation for the exadbvmcluster per node, in
  // gigabytes (GB). This field is used to calculate the total storage
  // allocation for the exadbvmcluster.
  int32 size_in_gbs_per_node = 2 [(google.api.field_behavior) = REQUIRED];
}

// The properties of an ExadbVmCluster.
message ExadbVmClusterProperties {
  // The Oracle license model that applies to the ExaScale VM cluster
  enum LicenseModel {
    // Unspecified.
    LICENSE_MODEL_UNSPECIFIED = 0;

    // Default is license included.
    LICENSE_INCLUDED = 1;

    // Bring your own license.
    BRING_YOUR_OWN_LICENSE = 2;
  }

  // The various lifecycle states of the VM cluster.
  enum ExadbVmClusterLifecycleState {
    // Default unspecified value.
    EXADB_VM_CLUSTER_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 is in maintenance in progress state.
    MAINTENANCE_IN_PROGRESS = 7;
  }

  // The shape attribute of the VM cluster. The type of Exascale storage used
  // for Exadata VM cluster. The default is SMART_STORAGE which supports Oracle
  // Database 23ai and later
  enum ShapeAttribute {
    // Default unspecified value.
    SHAPE_ATTRIBUTE_UNSPECIFIED = 0;

    // Indicates that the resource is in smart storage.
    SMART_STORAGE = 1;

    // Indicates that the resource is in block storage.
    BLOCK_STORAGE = 2;
  }

  // Optional. Immutable. The cluster name for Exascale vm cluster. The cluster
  // name must begin with an alphabetic character and may contain hyphens(-) but
  // can not contain underscores(_). It should be not more than 11 characters
  // and is not case sensitive. OCI Cluster name.
  string cluster_name = 1 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Required. Immutable. Grid Infrastructure Version.
  string grid_image_id = 2 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Required. The number of nodes/VMs in the ExadbVmCluster.
  int32 node_count = 3 [(google.api.field_behavior) = REQUIRED];

  // Required. Immutable. The number of ECPUs enabled per node for an exadata vm
  // cluster on exascale infrastructure.
  int32 enabled_ecpu_count_per_node = 20 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Optional. Immutable. The number of additional ECPUs per node for an Exadata
  // VM cluster on exascale infrastructure.
  int32 additional_ecpu_count_per_node = 21 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Required. Immutable. Total storage details for the ExadbVmCluster.
  ExadbVmClusterStorageDetails vm_file_system_storage = 6 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Optional. Immutable. The license type of the ExadbVmCluster.
  LicenseModel license_model = 7 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Required. Immutable. The name of ExascaleDbStorageVault associated with the
  // ExadbVmCluster. It can refer to an existing ExascaleDbStorageVault. Or a
  // new one can be created during the ExadbVmCluster creation (requires
  // storage_vault_properties to be set).
  // Format:
  // projects/{project}/locations/{location}/exascaleDbStorageVaults/{exascale_db_storage_vault}
  string exascale_db_storage_vault = 8 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "oracledatabase.googleapis.com/ExascaleDbStorageVault"
    }
  ];

  // Required. Immutable. Prefix for VM cluster host names.
  string hostname_prefix = 9 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE
  ];

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

  // Required. Immutable. The SSH public keys for the ExadbVmCluster.
  repeated string ssh_public_keys = 11 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Optional. Immutable. Indicates user preference for data collection options.
  DataCollectionOptionsCommon data_collection_options = 12 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Optional. Immutable. The time zone of the ExadbVmCluster.
  google.type.TimeZone time_zone = 13 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Output only. State of the cluster.
  ExadbVmClusterLifecycleState lifecycle_state = 14
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Required. Immutable. The shape attribute of the VM cluster. The type of
  // Exascale storage used for Exadata VM cluster. The default is SMART_STORAGE
  // which supports Oracle Database 23ai and later
  ShapeAttribute shape_attribute = 15 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Output only. Memory per VM (GB) (Read-only): Shows the amount of memory
  // allocated to each VM. Memory is calculated based on 2.75 GB per Total
  // ECPUs.
  int32 memory_size_gb = 16 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. Immutable. SCAN listener port - TCP
  int32 scan_listener_port_tcp = 17 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Output only. Deep link to the OCI console to view this resource.
  string oci_uri = 18 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The Oracle Grid Infrastructure (GI) software version.
  string gi_version = 19 [(google.api.field_behavior) = OUTPUT_ONLY];
}
