1// Copyright 2023 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.batch.v1alpha; 18 19import "google/api/field_behavior.proto"; 20import "google/api/field_info.proto"; 21import "google/api/resource.proto"; 22import "google/cloud/batch/v1alpha/notification.proto"; 23import "google/protobuf/timestamp.proto"; 24import "google/type/interval.proto"; 25 26option csharp_namespace = "Google.Cloud.Batch.V1Alpha"; 27option go_package = "cloud.google.com/go/batch/apiv1alpha/batchpb;batchpb"; 28option java_multiple_files = true; 29option java_outer_classname = "ResourceAllowanceProto"; 30option java_package = "com.google.cloud.batch.v1alpha"; 31option objc_class_prefix = "GCB"; 32option php_namespace = "Google\\Cloud\\Batch\\V1alpha"; 33option ruby_package = "Google::Cloud::Batch::V1alpha"; 34 35// A `CalendarPeriod` represents the abstract concept of a time period that 36// has a canonical start. All calendar times begin at 12 AM US and Canadian 37// Pacific Time (UTC-8). 38enum CalendarPeriod { 39 // Unspecified. 40 CALENDAR_PERIOD_UNSPECIFIED = 0; 41 42 // The month starts on the first date of the month and resets at the beginning 43 // of each month. 44 MONTH = 1; 45 46 // The quarter starts on dates January 1, April 1, July 1, and October 1 of 47 // each year and resets at the beginning of the next quarter. 48 QUARTER = 2; 49 50 // The year starts on January 1 and resets at the beginning of the next year. 51 YEAR = 3; 52 53 // The week period starts and resets every Monday. 54 WEEK = 4; 55 56 // The day starts at 12:00am. 57 DAY = 5; 58} 59 60// ResourceAllowance valid state. 61enum ResourceAllowanceState { 62 // Unspecified. 63 RESOURCE_ALLOWANCE_STATE_UNSPECIFIED = 0; 64 65 // ResourceAllowance is active and in use. 66 RESOURCE_ALLOWANCE_ACTIVE = 1; 67 68 // ResourceAllowance limit is reached. 69 RESOURCE_ALLOWANCE_DEPLETED = 2; 70} 71 72// The Resource Allowance description for Cloud Batch. 73// Only one Resource Allowance is supported now under a specific location and 74// project. 75message ResourceAllowance { 76 option (google.api.resource) = { 77 type: "batch.googleapis.com/ResourceAllowance" 78 pattern: "projects/{project}/locations/{location}/resourceAllowances/{resource_allowance}" 79 plural: "resourceAllowances" 80 singular: "resourceAllowance" 81 }; 82 83 // ResourceAllowance detail. 84 oneof resource_allowance { 85 // The detail of usage resource allowance. 86 UsageResourceAllowance usage_resource_allowance = 4; 87 } 88 89 // Identifier. ResourceAllowance name. 90 // For example: 91 // "projects/123456/locations/us-central1/resourceAllowances/resource-allowance-1". 92 string name = 1 [(google.api.field_behavior) = IDENTIFIER]; 93 94 // Output only. A system generated unique ID (in UUID4 format) for the 95 // ResourceAllowance. 96 string uid = 2 [ 97 (google.api.field_info).format = UUID4, 98 (google.api.field_behavior) = OUTPUT_ONLY 99 ]; 100 101 // Output only. Time when the ResourceAllowance was created. 102 google.protobuf.Timestamp create_time = 3 103 [(google.api.field_behavior) = OUTPUT_ONLY]; 104 105 // Optional. Labels are attributes that can be set and used by both the 106 // user and by Batch. Labels must meet the following constraints: 107 // 108 // * Keys and values can contain only lowercase letters, numeric characters, 109 // underscores, and dashes. 110 // * All characters must use UTF-8 encoding, and international characters are 111 // allowed. 112 // * Keys must start with a lowercase letter or international character. 113 // * Each resource is limited to a maximum of 64 labels. 114 // 115 // Both keys and values are additionally constrained to be <= 128 bytes. 116 map<string, string> labels = 5 [(google.api.field_behavior) = OPTIONAL]; 117 118 // Optional. Notification configurations. 119 repeated Notification notifications = 6 120 [(google.api.field_behavior) = OPTIONAL]; 121} 122 123// UsageResourceAllowance describes the detail of usage resource allowance. 124message UsageResourceAllowance { 125 // Required. Spec of a usage ResourceAllowance. 126 UsageResourceAllowanceSpec spec = 1 [(google.api.field_behavior) = REQUIRED]; 127 128 // Output only. Status of a usage ResourceAllowance. 129 UsageResourceAllowanceStatus status = 2 130 [(google.api.field_behavior) = OUTPUT_ONLY]; 131} 132 133// Spec of a usage ResourceAllowance. 134message UsageResourceAllowanceSpec { 135 // UsageResourceAllowance limitation. 136 message Limit { 137 oneof duration { 138 // Optional. A CalendarPeriod represents the abstract concept of a time 139 // period that has a canonical start. 140 CalendarPeriod calendar_period = 1 141 [(google.api.field_behavior) = OPTIONAL]; 142 } 143 144 // Required. Limit value of a UsageResourceAllowance within its one 145 // duration. 146 // 147 // Limit cannot be a negative value. Default is 0. 148 // For example, you can set `limit` as 10000.0 with duration of the current 149 // month by setting `calendar_period` field as monthly. That means in your 150 // current month, 10000.0 is the core hour limitation that your resources 151 // are allowed to consume. 152 optional double limit = 2 [(google.api.field_behavior) = REQUIRED]; 153 } 154 155 // Required. Spec type is unique for each usage ResourceAllowance. 156 // Batch now only supports type as "cpu-core-hours" for CPU usage consumption 157 // tracking. 158 string type = 1 [(google.api.field_behavior) = REQUIRED]; 159 160 // Required. Threshold of a UsageResourceAllowance limiting how many resources 161 // can be consumed for each type. 162 Limit limit = 2 [(google.api.field_behavior) = REQUIRED]; 163} 164 165// Status of a usage ResourceAllowance. 166message UsageResourceAllowanceStatus { 167 // UsageResourceAllowanceStatus detail about usage consumption. 168 message LimitStatus { 169 // Output only. The consumption interval. 170 google.type.Interval consumption_interval = 1 171 [(google.api.field_behavior) = OUTPUT_ONLY]; 172 173 // Output only. Limit value of a UsageResourceAllowance within its one 174 // duration. 175 optional double limit = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 176 177 // Output only. Accumulated consumption during `consumption_interval`. 178 optional double consumed = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; 179 } 180 181 message PeriodConsumption { 182 // Output only. The consumption interval. 183 google.type.Interval consumption_interval = 1 184 [(google.api.field_behavior) = OUTPUT_ONLY]; 185 186 // Output only. Accumulated consumption during `consumption_interval`. 187 optional double consumed = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 188 } 189 190 // ConsumptionReport is the report of ResourceAllowance consumptions in a time 191 // period. 192 message ConsumptionReport { 193 // Output only. ResourceAllowance consumptions in the latest calendar 194 // period. Key is the calendar period in string format. Batch currently 195 // supports HOUR, DAY, MONTH and YEAR. 196 map<string, PeriodConsumption> latest_period_consumptions = 1 197 [(google.api.field_behavior) = OUTPUT_ONLY]; 198 } 199 200 // Output only. ResourceAllowance state. 201 ResourceAllowanceState state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; 202 203 // Output only. ResourceAllowance consumption status for usage resources. 204 LimitStatus limit_status = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; 205 206 // Output only. The report of ResourceAllowance consumptions in a time period. 207 ConsumptionReport report = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; 208} 209