Skip to content

Commit 19e9200

Browse files
build: use bazel build (#90)
1 parent 001e386 commit 19e9200

13 files changed

Lines changed: 6371 additions & 1536 deletions

File tree

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
// Copyright 2020 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+
15+
syntax = "proto3";
16+
17+
package google.cloud.recommender.v1;
18+
19+
import "google/api/resource.proto";
20+
import "google/protobuf/duration.proto";
21+
import "google/protobuf/struct.proto";
22+
import "google/protobuf/timestamp.proto";
23+
24+
option csharp_namespace = "Google.Cloud.Recommender.V1";
25+
option go_package = "google.golang.org/genproto/googleapis/cloud/recommender/v1;recommender";
26+
option java_multiple_files = true;
27+
option java_outer_classname = "InsightProto";
28+
option java_package = "com.google.cloud.recommender.v1";
29+
option objc_class_prefix = "CREC";
30+
option (google.api.resource_definition) = {
31+
type: "recommender.googleapis.com/InsightType"
32+
pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}"
33+
};
34+
35+
// An insight along with the information used to derive the insight. The insight
36+
// may have associated recomendations as well.
37+
message Insight {
38+
option (google.api.resource) = {
39+
type: "recommender.googleapis.com/Insight"
40+
pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}"
41+
};
42+
43+
// Reference to an associated recommendation.
44+
message RecommendationReference {
45+
// Recommendation resource name, e.g.
46+
// projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID]
47+
string recommendation = 1;
48+
}
49+
50+
// Insight category.
51+
enum Category {
52+
// Unspecified category.
53+
CATEGORY_UNSPECIFIED = 0;
54+
55+
// The insight is related to cost.
56+
COST = 1;
57+
58+
// The insight is related to security.
59+
SECURITY = 2;
60+
61+
// The insight is related to performance.
62+
PERFORMANCE = 3;
63+
64+
// This insight is related to manageability.
65+
MANAGEABILITY = 4;
66+
}
67+
68+
// Name of the insight.
69+
string name = 1;
70+
71+
// Free-form human readable summary in English. The maximum length is 500
72+
// characters.
73+
string description = 2;
74+
75+
// Fully qualified resource names that this insight is targeting.
76+
repeated string target_resources = 9;
77+
78+
// Insight subtype. Insight content schema will be stable for a given subtype.
79+
string insight_subtype = 10;
80+
81+
// A struct of custom fields to explain the insight.
82+
// Example: "grantedPermissionsCount": "1000"
83+
google.protobuf.Struct content = 3;
84+
85+
// Timestamp of the latest data used to generate the insight.
86+
google.protobuf.Timestamp last_refresh_time = 4;
87+
88+
// Observation period that led to the insight. The source data used to
89+
// generate the insight ends at last_refresh_time and begins at
90+
// (last_refresh_time - observation_period).
91+
google.protobuf.Duration observation_period = 5;
92+
93+
// Information state and metadata.
94+
InsightStateInfo state_info = 6;
95+
96+
// Category being targeted by the insight.
97+
Category category = 7;
98+
99+
// Fingerprint of the Insight. Provides optimistic locking when updating
100+
// states.
101+
string etag = 11;
102+
103+
// Recommendations derived from this insight.
104+
repeated RecommendationReference associated_recommendations = 8;
105+
}
106+
107+
// Information related to insight state.
108+
message InsightStateInfo {
109+
// Represents insight state.
110+
enum State {
111+
// Unspecified state.
112+
STATE_UNSPECIFIED = 0;
113+
114+
// Insight is active. Content for ACTIVE insights can be updated by Google.
115+
// ACTIVE insights can be marked DISMISSED OR ACCEPTED.
116+
ACTIVE = 1;
117+
118+
// Some action has been taken based on this insight. Insights become
119+
// accepted when a recommendation derived from the insight has been marked
120+
// CLAIMED, SUCCEEDED, or FAILED. ACTIVE insights can also be marked
121+
// ACCEPTED explicitly. Content for ACCEPTED insights is immutable. ACCEPTED
122+
// insights can only be marked ACCEPTED (which may update state metadata).
123+
ACCEPTED = 2;
124+
125+
// Insight is dismissed. Content for DISMISSED insights can be updated by
126+
// Google. DISMISSED insights can be marked as ACTIVE.
127+
DISMISSED = 3;
128+
}
129+
130+
// Insight state.
131+
State state = 1;
132+
133+
// A map of metadata for the state, provided by user or automations systems.
134+
map<string, string> state_metadata = 2;
135+
}

packages/google-cloud-recommender/protos/google/cloud/recommender/v1/recommendation.proto

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 Google LLC.
1+
// Copyright 2020 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -11,7 +11,6 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
//
1514

1615
syntax = "proto3";
1716

@@ -41,6 +40,13 @@ message Recommendation {
4140
pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}"
4241
};
4342

43+
// Reference to an associated insight.
44+
message InsightReference {
45+
// Insight resource name, e.g.
46+
// projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/insights/[INSIGHT_ID]
47+
string insight = 1;
48+
}
49+
4450
// Name of recommendation.
4551
string name = 1;
4652

@@ -81,6 +87,9 @@ message Recommendation {
8187
// Fingerprint of the Recommendation. Provides optimistic locking when
8288
// updating states.
8389
string etag = 11;
90+
91+
// Insights that led to this recommendation.
92+
repeated InsightReference associated_insights = 14;
8493
}
8594

8695
// Contains what resources are changing and how they are changing.
@@ -233,7 +242,7 @@ message Impact {
233242

234243
// Information for state. Contains state and metadata.
235244
message RecommendationStateInfo {
236-
// Represents Recommendation State
245+
// Represents Recommendation State.
237246
enum State {
238247
// Default state. Don't use directly.
239248
STATE_UNSPECIFIED = 0;

packages/google-cloud-recommender/protos/google/cloud/recommender/v1/recommender_service.proto

Lines changed: 119 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019 Google LLC.
1+
// Copyright 2020 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -11,7 +11,6 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
//
1514

1615
syntax = "proto3";
1716

@@ -21,6 +20,7 @@ import "google/api/annotations.proto";
2120
import "google/api/client.proto";
2221
import "google/api/field_behavior.proto";
2322
import "google/api/resource.proto";
23+
import "google/cloud/recommender/v1/insight.proto";
2424
import "google/cloud/recommender/v1/recommendation.proto";
2525

2626
option csharp_namespace = "Google.Cloud.Recommender.V1";
@@ -30,14 +30,46 @@ option java_outer_classname = "RecommenderProto";
3030
option java_package = "com.google.cloud.recommender.v1";
3131
option objc_class_prefix = "CREC";
3232

33-
// Provides recommendations for cloud customers for various categories like
34-
// performance optimization, cost savings, reliability, feature discovery, etc.
35-
// These recommendations are generated automatically based on analysis of user
36-
// resources, configuration and monitoring metrics.
33+
// Provides insights and recommendations for cloud customers for various
34+
// categories like performance optimization, cost savings, reliability, feature
35+
// discovery, etc. Insights and recommendations are generated automatically
36+
// based on analysis of user resources, configuration and monitoring metrics.
3737
service Recommender {
3838
option (google.api.default_host) = "recommender.googleapis.com";
3939
option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
4040

41+
// Lists insights for a Cloud project. Requires the recommender.*.list IAM
42+
// permission for the specified insight type.
43+
rpc ListInsights(ListInsightsRequest) returns (ListInsightsResponse) {
44+
option (google.api.http) = {
45+
get: "/v1/{parent=projects/*/locations/*/insightTypes/*}/insights"
46+
};
47+
option (google.api.method_signature) = "parent";
48+
}
49+
50+
// Gets the requested insight. Requires the recommender.*.get IAM permission
51+
// for the specified insight type.
52+
rpc GetInsight(GetInsightRequest) returns (Insight) {
53+
option (google.api.http) = {
54+
get: "/v1/{name=projects/*/locations/*/insightTypes/*/insights/*}"
55+
};
56+
option (google.api.method_signature) = "name";
57+
}
58+
59+
// Marks the Insight State as Accepted. Users can use this method to
60+
// indicate to the Recommender API that they have applied some action based
61+
// on the insight. This stops the insight content from being updated.
62+
//
63+
// MarkInsightAccepted can be applied to insights in ACTIVE state. Requires
64+
// the recommender.*.update IAM permission for the specified insight.
65+
rpc MarkInsightAccepted(MarkInsightAcceptedRequest) returns (Insight) {
66+
option (google.api.http) = {
67+
post: "/v1/{name=projects/*/locations/*/insightTypes/*/insights/*}:markAccepted"
68+
body: "*"
69+
};
70+
option (google.api.method_signature) = "name,state_metadata,etag";
71+
}
72+
4173
// Lists recommendations for a Cloud project. Requires the recommender.*.list
4274
// IAM permission for the specified recommender.
4375
rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse) {
@@ -57,10 +89,10 @@ service Recommender {
5789
option (google.api.method_signature) = "name";
5890
}
5991

60-
// Mark the Recommendation State as Claimed. Users can use this method to
92+
// Marks the Recommendation State as Claimed. Users can use this method to
6193
// indicate to the Recommender API that they are starting to apply the
6294
// recommendation themselves. This stops the recommendation content from being
63-
// updated.
95+
// updated. Associated insights are frozen and placed in the ACCEPTED state.
6496
//
6597
// MarkRecommendationClaimed can be applied to recommendations in CLAIMED,
6698
// SUCCEEDED, FAILED, or ACTIVE state.
@@ -75,10 +107,11 @@ service Recommender {
75107
option (google.api.method_signature) = "name,state_metadata,etag";
76108
}
77109

78-
// Mark the Recommendation State as Succeeded. Users can use this method to
110+
// Marks the Recommendation State as Succeeded. Users can use this method to
79111
// indicate to the Recommender API that they have applied the recommendation
80112
// themselves, and the operation was successful. This stops the recommendation
81-
// content from being updated.
113+
// content from being updated. Associated insights are frozen and placed in
114+
// the ACCEPTED state.
82115
//
83116
// MarkRecommendationSucceeded can be applied to recommendations in ACTIVE,
84117
// CLAIMED, SUCCEEDED, or FAILED state.
@@ -93,10 +126,11 @@ service Recommender {
93126
option (google.api.method_signature) = "name,state_metadata,etag";
94127
}
95128

96-
// Mark the Recommendation State as Failed. Users can use this method to
129+
// Marks the Recommendation State as Failed. Users can use this method to
97130
// indicate to the Recommender API that they have applied the recommendation
98131
// themselves, and the operation failed. This stops the recommendation content
99-
// from being updated.
132+
// from being updated. Associated insights are frozen and placed in the
133+
// ACCEPTED state.
100134
//
101135
// MarkRecommendationFailed can be applied to recommendations in ACTIVE,
102136
// CLAIMED, SUCCEEDED, or FAILED state.
@@ -112,6 +146,79 @@ service Recommender {
112146
}
113147
}
114148

149+
// Request for the `ListInsights` method.
150+
message ListInsightsRequest {
151+
// Required. The container resource on which to execute the request.
152+
// Acceptable formats:
153+
//
154+
// 1.
155+
// "projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]",
156+
//
157+
// LOCATION here refers to GCP Locations:
158+
// https://cloud.google.com/about/locations/
159+
string parent = 1 [
160+
(google.api.field_behavior) = REQUIRED,
161+
(google.api.resource_reference) = {
162+
type: "recommender.googleapis.com/InsightType"
163+
}
164+
];
165+
166+
// Optional. The maximum number of results to return from this request. Non-positive
167+
// values are ignored. If not specified, the server will determine the number
168+
// of results to return.
169+
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
170+
171+
// Optional. If present, retrieves the next batch of results from the preceding call to
172+
// this method. `page_token` must be the value of `next_page_token` from the
173+
// previous response. The values of other method parameters must be identical
174+
// to those in the previous call.
175+
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
176+
177+
// Optional. Filter expression to restrict the insights returned. Supported
178+
// filter fields: state
179+
// Eg: `state:"DISMISSED" or state:"ACTIVE"
180+
string filter = 4 [(google.api.field_behavior) = OPTIONAL];
181+
}
182+
183+
// Response to the `ListInsights` method.
184+
message ListInsightsResponse {
185+
// The set of insights for the `parent` resource.
186+
repeated Insight insights = 1;
187+
188+
// A token that can be used to request the next page of results. This field is
189+
// empty if there are no additional results.
190+
string next_page_token = 2;
191+
}
192+
193+
// Request to the `GetInsight` method.
194+
message GetInsightRequest {
195+
// Required. Name of the insight.
196+
string name = 1 [
197+
(google.api.field_behavior) = REQUIRED,
198+
(google.api.resource_reference) = {
199+
type: "recommender.googleapis.com/Insight"
200+
}
201+
];
202+
}
203+
204+
// Request for the `MarkInsightAccepted` method.
205+
message MarkInsightAcceptedRequest {
206+
// Required. Name of the insight.
207+
string name = 1 [
208+
(google.api.field_behavior) = REQUIRED,
209+
(google.api.resource_reference) = {
210+
type: "recommender.googleapis.com/Insight"
211+
}
212+
];
213+
214+
// Optional. State properties user wish to include with this state. Full replace of the
215+
// current state_metadata.
216+
map<string, string> state_metadata = 2 [(google.api.field_behavior) = OPTIONAL];
217+
218+
// Required. Fingerprint of the Insight. Provides optimistic locking.
219+
string etag = 3 [(google.api.field_behavior) = REQUIRED];
220+
}
221+
115222
// Request for the `ListRecommendations` method.
116223
message ListRecommendationsRequest {
117224
// Required. The container resource on which to execute the request.

0 commit comments

Comments
 (0)