Skip to content

Commit

Permalink
feat: Add support for "billingAccounts" as another parent resource na…
Browse files Browse the repository at this point in the history
…me for recommendations and insights APIs. (#138)

BREAKING CHANGE: resource path helper recommenderPath has been removed
  • Loading branch information
yoshi-automation authored Jan 7, 2021
1 parent aecf574 commit 80384c0
Show file tree
Hide file tree
Showing 11 changed files with 1,168 additions and 220 deletions.
2 changes: 1 addition & 1 deletion packages/google-cloud-recommender/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async function listRecommendations() {
// recommenderId = 'google.compute.instance.MachineTypeRecommender';

const [recommendations] = await recommender.listRecommendations({
parent: recommender.recommenderPath(project, 'global', recommenderId),
parent: recommender.projectLocationRecommenderPath(project, 'global', recommenderId),
});
console.info(`recommendations for ${recommenderId}:`);
for (const recommendation of recommendations) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ option objc_class_prefix = "CREC";
option (google.api.resource_definition) = {
type: "recommender.googleapis.com/InsightType"
pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}"
pattern: "billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}"
};

// An insight along with the information used to derive the insight. The insight
Expand All @@ -38,6 +39,7 @@ message Insight {
option (google.api.resource) = {
type: "recommender.googleapis.com/Insight"
pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}/insights/{insight}"
pattern: "billingAccounts/{billing_account}/locations/{location}/insightTypes/{insight_type}/insights/{insight}"
};

// Reference to an associated recommendation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ option objc_class_prefix = "CREC";
option (google.api.resource_definition) = {
type: "recommender.googleapis.com/Recommender"
pattern: "projects/{project}/locations/{location}/recommenders/{recommender}"
pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}"
};

// A recommendation along with a suggested action. E.g., a rightsizing
Expand All @@ -38,6 +39,7 @@ message Recommendation {
option (google.api.resource) = {
type: "recommender.googleapis.com/Recommendation"
pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}"
pattern: "billingAccounts/{billing_account}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}"
};

// Reference to an associated insight.
Expand Down Expand Up @@ -170,12 +172,12 @@ message Operation {
// "/versions/*/targetSize/percent": 20
// }
// * Example: {
// "/bindings/*/role": "roles/admin"
// "/bindings/*/role": "roles/owner"
// "/bindings/*/condition" : null
// }
// * Example: {
// "/bindings/*/role": "roles/admin"
// "/bindings/*/members/*" : ["x@google.com", "y@google.com"]
// "/bindings/*/role": "roles/owner"
// "/bindings/*/members/*" : ["x@example.com", "y@example.com"]
// }
// When both path_filters and path_value_matchers are set, an implicit AND
// must be performed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ service Recommender {
rpc ListInsights(ListInsightsRequest) returns (ListInsightsResponse) {
option (google.api.http) = {
get: "/v1/{parent=projects/*/locations/*/insightTypes/*}/insights"
additional_bindings {
get: "/v1/{parent=billingAccounts/*/locations/*/insightTypes/*}/insights"
}
};
option (google.api.method_signature) = "parent";
}
Expand All @@ -52,6 +55,9 @@ service Recommender {
rpc GetInsight(GetInsightRequest) returns (Insight) {
option (google.api.http) = {
get: "/v1/{name=projects/*/locations/*/insightTypes/*/insights/*}"
additional_bindings {
get: "/v1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}"
}
};
option (google.api.method_signature) = "name";
}
Expand All @@ -66,6 +72,10 @@ service Recommender {
option (google.api.http) = {
post: "/v1/{name=projects/*/locations/*/insightTypes/*/insights/*}:markAccepted"
body: "*"
additional_bindings {
post: "/v1/{name=billingAccounts/*/locations/*/insightTypes/*/insights/*}:markAccepted"
body: "*"
}
};
option (google.api.method_signature) = "name,state_metadata,etag";
}
Expand All @@ -75,6 +85,9 @@ service Recommender {
rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse) {
option (google.api.http) = {
get: "/v1/{parent=projects/*/locations/*/recommenders/*}/recommendations"
additional_bindings {
get: "/v1/{parent=billingAccounts/*/locations/*/recommenders/*}/recommendations"
}
};
option (google.api.method_signature) = "parent";
option (google.api.method_signature) = "parent,filter";
Expand All @@ -85,6 +98,9 @@ service Recommender {
rpc GetRecommendation(GetRecommendationRequest) returns (Recommendation) {
option (google.api.http) = {
get: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}"
additional_bindings {
get: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}"
}
};
option (google.api.method_signature) = "name";
}
Expand All @@ -103,6 +119,10 @@ service Recommender {
option (google.api.http) = {
post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed"
body: "*"
additional_bindings {
post: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markClaimed"
body: "*"
}
};
option (google.api.method_signature) = "name,state_metadata,etag";
}
Expand All @@ -122,6 +142,10 @@ service Recommender {
option (google.api.http) = {
post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded"
body: "*"
additional_bindings {
post: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markSucceeded"
body: "*"
}
};
option (google.api.method_signature) = "name,state_metadata,etag";
}
Expand All @@ -141,6 +165,10 @@ service Recommender {
option (google.api.http) = {
post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed"
body: "*"
additional_bindings {
post: "/v1/{name=billingAccounts/*/locations/*/recommenders/*/recommendations/*}:markFailed"
body: "*"
}
};
option (google.api.method_signature) = "name,state_metadata,etag";
}
Expand All @@ -156,6 +184,8 @@ message ListInsightsRequest {
//
// LOCATION here refers to GCP Locations:
// https://cloud.google.com/about/locations/
// INSIGHT_TYPE_ID refers to supported insight types:
// https://cloud.google.com/recommender/docs/insights/insight-types.)
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
Expand Down Expand Up @@ -229,6 +259,8 @@ message ListRecommendationsRequest {
//
// LOCATION here refers to GCP Locations:
// https://cloud.google.com/about/locations/
// RECOMMENDER_ID refers to supported recommenders:
// https://cloud.google.com/recommender/docs/recommenders.
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
Expand Down
12 changes: 12 additions & 0 deletions packages/google-cloud-recommender/protos/protos.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 77 additions & 1 deletion packages/google-cloud-recommender/protos/protos.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 80384c0

Please sign in to comment.