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