1// Copyright 2022 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.recommender.v1beta1; 18 19import "google/api/resource.proto"; 20import "google/protobuf/duration.proto"; 21import "google/protobuf/struct.proto"; 22import "google/protobuf/timestamp.proto"; 23import "google/type/money.proto"; 24 25option csharp_namespace = "Google.Cloud.Recommender.V1Beta1"; 26option go_package = "cloud.google.com/go/recommender/apiv1beta1/recommenderpb;recommenderpb"; 27option java_multiple_files = true; 28option java_package = "com.google.cloud.recommender.v1beta1"; 29option objc_class_prefix = "CREC"; 30 31// A recommendation along with a suggested action. E.g., a rightsizing 32// recommendation for an underutilized VM, IAM role recommendations, etc 33message Recommendation { 34 option (google.api.resource) = { 35 type: "recommender.googleapis.com/Recommendation" 36 pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" 37 pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" 38 pattern: "folders/{folder}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" 39 pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}" 40 }; 41 42 // Recommendation priority levels. 43 enum Priority { 44 // Recommendation has unspecified priority. 45 PRIORITY_UNSPECIFIED = 0; 46 47 // Recommendation has P4 priority (lowest priority). 48 P4 = 1; 49 50 // Recommendation has P3 priority (second lowest priority). 51 P3 = 2; 52 53 // Recommendation has P2 priority (second highest priority). 54 P2 = 3; 55 56 // Recommendation has P1 priority (highest priority). 57 P1 = 4; 58 } 59 60 // Reference to an associated insight. 61 message InsightReference { 62 // Insight resource name, e.g. 63 // projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/insights/[INSIGHT_ID] 64 string insight = 1; 65 } 66 67 // Name of recommendation. 68 string name = 1; 69 70 // Free-form human readable summary in English. The maximum length is 500 71 // characters. 72 string description = 2; 73 74 // Contains an identifier for a subtype of recommendations produced for the 75 // same recommender. Subtype is a function of content and impact, meaning a 76 // new subtype might be added when significant changes to `content` or 77 // `primary_impact.category` are introduced. See the Recommenders section 78 // to see a list of subtypes for a given Recommender. 79 // 80 // Examples: 81 // For recommender = "google.iam.policy.Recommender", 82 // recommender_subtype can be one of "REMOVE_ROLE"/"REPLACE_ROLE" 83 string recommender_subtype = 12; 84 85 // Last time this recommendation was refreshed by the system that created it 86 // in the first place. 87 google.protobuf.Timestamp last_refresh_time = 4; 88 89 // The primary impact that this recommendation can have while trying to 90 // optimize for one category. 91 Impact primary_impact = 5; 92 93 // Optional set of additional impact that this recommendation may have when 94 // trying to optimize for the primary category. These may be positive 95 // or negative. 96 repeated Impact additional_impact = 6; 97 98 // Recommendation's priority. 99 Priority priority = 17; 100 101 // Content of the recommendation describing recommended changes to resources. 102 RecommendationContent content = 7; 103 104 // Information for state. Contains state and metadata. 105 RecommendationStateInfo state_info = 10; 106 107 // Fingerprint of the Recommendation. Provides optimistic locking when 108 // updating states. 109 string etag = 11; 110 111 // Insights that led to this recommendation. 112 repeated InsightReference associated_insights = 14; 113 114 // Corresponds to a mutually exclusive group ID within a recommender. 115 // A non-empty ID indicates that the recommendation belongs to a mutually 116 // exclusive group. This means that only one recommendation within the group 117 // is suggested to be applied. 118 string xor_group_id = 18; 119} 120 121// Contains what resources are changing and how they are changing. 122message RecommendationContent { 123 // Operations to one or more Google Cloud resources grouped in such a way 124 // that, all operations within one group are expected to be performed 125 // atomically and in an order. 126 repeated OperationGroup operation_groups = 2; 127 128 // Condensed overview information about the recommendation. 129 google.protobuf.Struct overview = 3; 130} 131 132// Group of operations that need to be performed atomically. 133message OperationGroup { 134 // List of operations across one or more resources that belong to this group. 135 // Loosely based on RFC6902 and should be performed in the order they appear. 136 repeated Operation operations = 1; 137} 138 139// Contains an operation for a resource loosely based on the JSON-PATCH format 140// with support for: 141// 142// * Custom filters for describing partial array patch. 143// * Extended path values for describing nested arrays. 144// * Custom fields for describing the resource for which the operation is being 145// described. 146// * Allows extension to custom operations not natively supported by RFC6902. 147// See https://tools.ietf.org/html/rfc6902 for details on the original RFC. 148message Operation { 149 // Type of this operation. Contains one of 'add', 'remove', 'replace', 'move', 150 // 'copy', 'test' and 'custom' operations. This field is case-insensitive and 151 // always populated. 152 string action = 1; 153 154 // Type of GCP resource being modified/tested. This field is always populated. 155 // Example: cloudresourcemanager.googleapis.com/Project, 156 // compute.googleapis.com/Instance 157 string resource_type = 2; 158 159 // Contains the fully qualified resource name. This field is always populated. 160 // ex: //cloudresourcemanager.googleapis.com/projects/foo. 161 string resource = 3; 162 163 // Path to the target field being operated on. If the operation is at the 164 // resource level, then path should be "/". This field is always populated. 165 string path = 4; 166 167 // Can be set with action 'copy' to copy resource configuration across 168 // different resources of the same type. Example: A resource clone can be 169 // done via action = 'copy', path = "/", from = "/", 170 // source_resource = <source> and resource_name = <target>. 171 // This field is empty for all other values of `action`. 172 string source_resource = 5; 173 174 // Can be set with action 'copy' or 'move' to indicate the source field within 175 // resource or source_resource, ignored if provided for other operation types. 176 string source_path = 6; 177 178 // One of the fields in the following block will be set and intend to 179 // describe a value for 'path' field. 180 oneof path_value { 181 // Value for the `path` field. Will be set for actions:'add'/'replace'. 182 // Maybe set for action: 'test'. Either this or `value_matcher` will be set 183 // for 'test' operation. An exact match must be performed. 184 google.protobuf.Value value = 7; 185 186 // Can be set for action 'test' for advanced matching for the value of 187 // 'path' field. Either this or `value` will be set for 'test' operation. 188 ValueMatcher value_matcher = 10; 189 } 190 191 // Set of filters to apply if `path` refers to array elements or nested array 192 // elements in order to narrow down to a single unique element that is being 193 // tested/modified. 194 // This is intended to be an exact match per filter. To perform advanced 195 // matching, use path_value_matchers. 196 // 197 // * Example: 198 // ``` 199 // { 200 // "/versions/*/name" : "it-123" 201 // "/versions/*/targetSize/percent": 20 202 // } 203 // ``` 204 // * Example: 205 // ``` 206 // { 207 // "/bindings/*/role": "roles/owner" 208 // "/bindings/*/condition" : null 209 // } 210 // ``` 211 // * Example: 212 // ``` 213 // { 214 // "/bindings/*/role": "roles/owner" 215 // "/bindings/*/members/*" : ["[email protected]", "[email protected]"] 216 // } 217 // ``` 218 // When both path_filters and path_value_matchers are set, an implicit AND 219 // must be performed. 220 map<string, google.protobuf.Value> path_filters = 8; 221 222 // Similar to path_filters, this contains set of filters to apply if `path` 223 // field refers to array elements. This is meant to support value matching 224 // beyond exact match. To perform exact match, use path_filters. 225 // When both path_filters and path_value_matchers are set, an implicit AND 226 // must be performed. 227 map<string, ValueMatcher> path_value_matchers = 11; 228} 229 230// Contains various matching options for values for a GCP resource field. 231message ValueMatcher { 232 oneof match_variant { 233 // To be used for full regex matching. The regular expression is using the 234 // Google RE2 syntax (https://github.com/google/re2/wiki/Syntax), so to be 235 // used with RE2::FullMatch 236 string matches_pattern = 1; 237 } 238} 239 240// Contains metadata about how much money a recommendation can save or incur. 241message CostProjection { 242 // An approximate projection on amount saved or amount incurred. Negative cost 243 // units indicate cost savings and positive cost units indicate increase. 244 // See google.type.Money documentation for positive/negative units. 245 // 246 // A user's permissions may affect whether the cost is computed using list 247 // prices or custom contract prices. 248 google.type.Money cost = 1; 249 250 // Duration for which this cost applies. 251 google.protobuf.Duration duration = 2; 252} 253 254// Contains various ways of describing the impact on Security. 255message SecurityProjection { 256 // This field can be used by the recommender to define details specific to 257 // security impact. 258 google.protobuf.Struct details = 2; 259} 260 261// Contains metadata about how much sustainability a recommendation can save or 262// incur. 263message SustainabilityProjection { 264 // Carbon Footprint generated in kg of CO2 equivalent. 265 // Chose kg_c_o2e so that the name renders correctly in camelCase (kgCO2e). 266 double kg_c_o2e = 1; 267 268 // Duration for which this sustanability applies. 269 google.protobuf.Duration duration = 2; 270} 271 272// Contains the impact a recommendation can have for a given category. 273message Impact { 274 // The category of the impact. 275 enum Category { 276 // Default unspecified category. Don't use directly. 277 CATEGORY_UNSPECIFIED = 0; 278 279 // Indicates a potential increase or decrease in cost. 280 COST = 1; 281 282 // Indicates a potential increase or decrease in security. 283 SECURITY = 2; 284 285 // Indicates a potential increase or decrease in performance. 286 PERFORMANCE = 3; 287 288 // Indicates a potential increase or decrease in manageability. 289 MANAGEABILITY = 4; 290 291 // Indicates a potential increase or decrease in sustainability. 292 SUSTAINABILITY = 5; 293 } 294 295 // Category that is being targeted. 296 Category category = 1; 297 298 // Contains projections (if any) for this category. 299 oneof projection { 300 // Use with CategoryType.COST 301 CostProjection cost_projection = 100; 302 303 // Use with CategoryType.SECURITY 304 SecurityProjection security_projection = 101; 305 306 // Use with CategoryType.SUSTAINABILITY 307 SustainabilityProjection sustainability_projection = 102; 308 } 309} 310 311// Information for state. Contains state and metadata. 312message RecommendationStateInfo { 313 // Represents Recommendation State. 314 enum State { 315 // Default state. Don't use directly. 316 STATE_UNSPECIFIED = 0; 317 318 // Recommendation is active and can be applied. Recommendations content can 319 // be updated by Google. 320 // 321 // ACTIVE recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. 322 ACTIVE = 1; 323 324 // Recommendation is in claimed state. Recommendations content is 325 // immutable and cannot be updated by Google. 326 // 327 // CLAIMED recommendations can be marked as CLAIMED, SUCCEEDED, or FAILED. 328 CLAIMED = 6; 329 330 // Recommendation is in succeeded state. Recommendations content is 331 // immutable and cannot be updated by Google. 332 // 333 // SUCCEEDED recommendations can be marked as SUCCEEDED, or FAILED. 334 SUCCEEDED = 3; 335 336 // Recommendation is in failed state. Recommendations content is immutable 337 // and cannot be updated by Google. 338 // 339 // FAILED recommendations can be marked as SUCCEEDED, or FAILED. 340 FAILED = 4; 341 342 // Recommendation is in dismissed state. Recommendation content can be 343 // updated by Google. 344 // 345 // DISMISSED recommendations can be marked as ACTIVE. 346 DISMISSED = 5; 347 } 348 349 // The state of the recommendation, Eg ACTIVE, SUCCEEDED, FAILED. 350 State state = 1; 351 352 // A map of metadata for the state, provided by user or automations systems. 353 map<string, string> state_metadata = 2; 354} 355 356// The type of a recommender. 357message RecommenderType { 358 option (google.api.resource) = { 359 type: "recommender.googleapis.com/Recommender" 360 pattern: "projects/{project}/locations/{location}/recommenders/{recommender}" 361 pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}" 362 pattern: "folders/{folder}/locations/{location}/recommenders/{recommender}" 363 pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}" 364 pattern: "recommenders/{recommender}" 365 }; 366 367 // The recommender's name in format RecommenderTypes/{recommender_type} 368 // eg: recommenderTypes/google.iam.policy.Recommender 369 string name = 1; 370} 371