// 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.capacityplanner.v1beta;

import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.CapacityPlanner.V1Beta";
option go_package = "cloud.google.com/go/capacityplanner/apiv1beta/capacityplannerpb;capacityplannerpb";
option java_multiple_files = true;
option java_outer_classname = "AllocationProto";
option java_package = "com.google.cloud.capacityplanner.v1beta";
option php_namespace = "Google\\Cloud\\CapacityPlanner\\V1beta";
option ruby_package = "Google::Cloud::CapacityPlanner::V1beta";

// Repesents Allocation which is part of aggregated
// reservations data response of "QueryReservations".
message Allocation {
  // This reservation type allows to pre allocate specific instance
  // configuration.
  message SpecificSKUAllocation {
    // Properties of the SKU instances being reserved.
    message AllocatedInstanceProperties {
      // A specification of the type and number of accelerator cards attached to
      // the instance.
      message AcceleratorConfig {
        // Accelerator name.
        // See https://cloud.google.com/compute/docs/gpus/#introduction for a
        // full list of accelerator types.
        string type = 1;

        // The number of the guest accelerator cards exposed to this instance.
        int32 count = 2;
      }

      // A specification of the interface and size of disk attached to
      // the instance.
      message AllocatedDisk {
        // guest device interface options to use for the disk.
        enum DiskInterface {
          // Default value. This value is unused.
          DISK_INTERFACE_UNSPECIFIED = 0;

          // SCSI disk interface.
          SCSI = 1;

          // NVME disk interface.
          NVME = 2;

          // NVDIMM disk interface.
          NVDIMM = 3;

          // ISCSI disk interface.
          ISCSI = 4;
        }

        // Specifies the size of the disk in base-2 GB.
        int64 disk_size_gb = 1;

        // Specifies the disk interface to use for attaching this disk, which is
        // either SCSI or NVME. The default is SCSI.
        DiskInterface disk_interface = 2;
      }

      // Specifies type of machine (name only) which has fixed number of vCPUs
      // and fixed amount of memory. This also includes specifying custom
      // machine type following custom-NUMBER_OF_CPUS-AMOUNT_OF_MEMORY pattern.
      string machine_type = 1;

      // Specifies accelerator type and count.
      repeated AcceleratorConfig guest_accelerator = 2;

      // Minimum cpu platform the reservation.
      string min_cpu_platform = 3;

      // Specifies amount of local ssd to reserve with each instance. The type
      // of disk is local-ssd.
      repeated AllocatedDisk local_ssd = 4;
    }

    // The instance properties for the reservation.
    AllocatedInstanceProperties instance_properties = 1;

    // Specifies the number of resources that are allocated.
    int64 count = 2;

    // Indicates how many instances are in use.
    int64 used_count = 3;

    // Indicates how many instances are actually usable currently.
    int64 assured_count = 4;
  }

  // The share setting for reservation.
  message ShareSettings {
    // Possible scope in which the reservation can be shared. More granularity
    // can be added in future.
    enum ShareType {
      // Default value. This value is unused.
      SHARE_TYPE_UNSPECIFIED = 0;

      // Shared-reservation is open to entire Organization
      ORGANIZATION = 1;

      // Shared-reservation is open to specific projects
      SPECIFIC_PROJECTS = 2;

      // Default value.
      LOCAL = 3;

      // Shared-reservation is open to direct child projects of specific
      // folders.
      DIRECT_PROJECTS_UNDER_SPECIFIC_FOLDERS = 4;
    }

    // Type of sharing for this shared-reservation
    ShareType share_type = 1;

    // A List of Project names to specify consumer projects for this
    // shared-reservation. This is only valid when share_type's value is
    // SPECIFIC_PROJECTS.
    repeated string projects = 2;
  }

  // The status of the reservation.
  enum Status {
    // Default value. This value is unused.
    STATUS_UNSPECIFIED = 0;

    // Invalid Reservation
    INVALID = 1;

    // Resources are being allocated for the reservation.
    CREATING = 2;

    // Reservation has allocated all its resources.
    READY = 3;

    // Reservation is currently being deleted.
    DELETING = 4;

    // Reservation is currently being resized.
    UPDATING = 5;
  }

  // The type of the reservation which can only be for a specific SKU for now.
  oneof type {
    // Reservation for instances with specific machine shapes.
    SpecificSKUAllocation specific_allocation = 6;
  }

  // The unique identifier for the resource. This identifier is
  // defined by the server.
  int64 id = 1;

  // The creation timestamp for this allocation.
  google.protobuf.Timestamp create_time = 2;

  // Zone in which the reservation resides.
  string zone = 3;

  // A description while creating reservation.
  string description = 4;

  // The reservation resource name.
  string allocation = 5;

  string owner_project_id = 10;

  // The status of the reservation.
  Status status = 7;

  // Specify share-settings to create a shared reservation.
  ShareSettings share_settings = 8;

  // Absolute time in future when the reservation will be
  // auto-deleted by Compute Engine.
  google.protobuf.Timestamp auto_delete_time = 9;
}
