recommendation.proto 13 KB

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