feat: Implement configurable recommenders and update .bazel files

PiperOrigin-RevId: 457101611
pull/726/head
Google APIs 3 years ago committed by Copybara-Service
parent dfefc95a24
commit c13c88b193
  1. 5
      google/cloud/recommender/v1/BUILD.bazel
  2. 85
      google/cloud/recommender/v1/insight_type_config.proto
  3. 85
      google/cloud/recommender/v1/recommender_config.proto
  4. 175
      google/cloud/recommender/v1/recommender_service.proto
  5. 2
      google/cloud/recommender/v1beta1/BUILD.bazel

@ -22,7 +22,9 @@ proto_library(
name = "recommender_proto",
srcs = [
"insight.proto",
"insight_type_config.proto",
"recommendation.proto",
"recommender_config.proto",
"recommender_service.proto",
],
deps = [
@ -32,6 +34,7 @@ proto_library(
"//google/api:resource_proto",
"//google/type:money_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:field_mask_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
],
@ -173,6 +176,7 @@ py_gapic_library(
name = "recommender_py_gapic",
srcs = [":recommender_proto"],
grpc_service_config = "recommender_grpc_service_config.json",
service_yaml = "recommender_v1.yaml",
)
# Open Source Packages
@ -289,6 +293,7 @@ ruby_cloud_gapic_library(
grpc_service_config = "recommender_grpc_service_config.json",
ruby_cloud_description = "Recommender is a service on Google Cloud that provides usage recommendations for Cloud products and services.",
ruby_cloud_title = "Recommender V1",
service_yaml = "recommender_v1.yaml",
deps = [
":recommender_ruby_grpc",
":recommender_ruby_proto",

@ -0,0 +1,85 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.cloud.recommender.v1;
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
option csharp_namespace = "Google.Cloud.Recommender.V1";
option go_package = "google.golang.org/genproto/googleapis/cloud/recommender/v1;recommender";
option java_multiple_files = true;
option java_outer_classname = "InsightTypeConfigProto";
option java_package = "com.google.cloud.recommender.v1";
option objc_class_prefix = "CREC";
// Configuration for an InsightType.
message InsightTypeConfig {
option (google.api.resource) = {
type: "recommender.googleapis.com/InsightTypeConfig"
pattern: "projects/{project}/locations/{location}/insightTypes/{insight_type}/config"
pattern: "organizations/{organization}/locations/{location}/insightTypes/{insight_type}/config"
};
// Name of insight type config.
// Eg,
// projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config
string name = 1;
// InsightTypeGenerationConfig which configures the generation of
// insights for this insight type.
InsightTypeGenerationConfig insight_type_generation_config = 2;
// Fingerprint of the InsightTypeConfig. Provides optimistic locking when
// updating.
string etag = 3;
// Last time when the config was updated.
google.protobuf.Timestamp update_time = 4;
// Output only. Immutable. The revision ID of the config.
// A new revision is committed whenever the config is changed in any way.
// The format is an 8-character hexadecimal string.
string revision_id = 5 [
(google.api.field_behavior) = IMMUTABLE,
(google.api.field_behavior) = OUTPUT_ONLY
];
// Allows clients to store small amounts of arbitrary data. Annotations must
// follow the Kubernetes syntax.
// The total size of all keys and values combined is limited to 256k.
// Key can have 2 segments: prefix (optional) and name (required),
// separated by a slash (/).
// Prefix must be a DNS subdomain.
// Name must be 63 characters or less, begin and end with alphanumerics,
// with dashes (-), underscores (_), dots (.), and alphanumerics between.
map<string, string> annotations = 6;
// A user-settable field to provide a human-readable name to be used in user
// interfaces.
string display_name = 7;
}
// A configuration to customize the generation of insights.
// Eg, customizing the lookback period considered when generating a
// insight.
message InsightTypeGenerationConfig {
// Parameters for this InsightTypeGenerationConfig. These configs can be used
// by or are applied to all subtypes.
google.protobuf.Struct params = 1;
}

@ -0,0 +1,85 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.cloud.recommender.v1;
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
option csharp_namespace = "Google.Cloud.Recommender.V1";
option go_package = "google.golang.org/genproto/googleapis/cloud/recommender/v1;recommender";
option java_multiple_files = true;
option java_outer_classname = "RecommenderConfigProto";
option java_package = "com.google.cloud.recommender.v1";
option objc_class_prefix = "CREC";
// Configuration for a Recommender.
message RecommenderConfig {
option (google.api.resource) = {
type: "recommender.googleapis.com/RecommenderConfig"
pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/config"
pattern: "organizations/{organization}/locations/{location}/recommenders/{recommender}/config"
};
// Name of recommender config.
// Eg,
// projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config
string name = 1;
// RecommenderGenerationConfig which configures the Generation of
// recommendations for this recommender.
RecommenderGenerationConfig recommender_generation_config = 2;
// Fingerprint of the RecommenderConfig. Provides optimistic locking when
// updating.
string etag = 3;
// Last time when the config was updated.
google.protobuf.Timestamp update_time = 4;
// Output only. Immutable. The revision ID of the config.
// A new revision is committed whenever the config is changed in any way.
// The format is an 8-character hexadecimal string.
string revision_id = 5 [
(google.api.field_behavior) = IMMUTABLE,
(google.api.field_behavior) = OUTPUT_ONLY
];
// Allows clients to store small amounts of arbitrary data. Annotations must
// follow the Kubernetes syntax.
// The total size of all keys and values combined is limited to 256k.
// Key can have 2 segments: prefix (optional) and name (required),
// separated by a slash (/).
// Prefix must be a DNS subdomain.
// Name must be 63 characters or less, begin and end with alphanumerics,
// with dashes (-), underscores (_), dots (.), and alphanumerics between.
map<string, string> annotations = 6;
// A user-settable field to provide a human-readable name to be used in user
// interfaces.
string display_name = 7;
}
// A Configuration to customize the generation of recommendations.
// Eg, customizing the lookback period considered when generating a
// recommendation.
message RecommenderGenerationConfig {
// Parameters for this RecommenderGenerationConfig. These configs can be used
// by or are applied to all subtypes.
google.protobuf.Struct params = 1;
}

@ -21,7 +21,10 @@ import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/recommender/v1/insight.proto";
import "google/cloud/recommender/v1/insight_type_config.proto";
import "google/cloud/recommender/v1/recommendation.proto";
import "google/cloud/recommender/v1/recommender_config.proto";
import "google/protobuf/field_mask.proto";
option csharp_namespace = "Google.Cloud.Recommender.V1";
option go_package = "google.golang.org/genproto/googleapis/cloud/recommender/v1;recommender";
@ -36,7 +39,8 @@ option objc_class_prefix = "CREC";
// based on analysis of user resources, configuration and monitoring metrics.
service Recommender {
option (google.api.default_host) = "recommender.googleapis.com";
option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
option (google.api.oauth_scopes) =
"https://www.googleapis.com/auth/cloud-platform";
// Lists insights for the specified Cloud Resource. Requires the
// recommender.*.list IAM permission for the specified insight type.
@ -102,7 +106,8 @@ service Recommender {
// Lists recommendations for the specified Cloud Resource. Requires the
// recommender.*.list IAM permission for the specified recommender.
rpc ListRecommendations(ListRecommendationsRequest) returns (ListRecommendationsResponse) {
rpc ListRecommendations(ListRecommendationsRequest)
returns (ListRecommendationsResponse) {
option (google.api.http) = {
get: "/v1/{parent=projects/*/locations/*/recommenders/*}/recommendations"
additional_bindings {
@ -147,7 +152,8 @@ service Recommender {
//
// Requires the recommender.*.update IAM permission for the specified
// recommender.
rpc MarkRecommendationClaimed(MarkRecommendationClaimedRequest) returns (Recommendation) {
rpc MarkRecommendationClaimed(MarkRecommendationClaimedRequest)
returns (Recommendation) {
option (google.api.http) = {
post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed"
body: "*"
@ -178,7 +184,8 @@ service Recommender {
//
// Requires the recommender.*.update IAM permission for the specified
// recommender.
rpc MarkRecommendationSucceeded(MarkRecommendationSucceededRequest) returns (Recommendation) {
rpc MarkRecommendationSucceeded(MarkRecommendationSucceededRequest)
returns (Recommendation) {
option (google.api.http) = {
post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded"
body: "*"
@ -209,7 +216,8 @@ service Recommender {
//
// Requires the recommender.*.update IAM permission for the specified
// recommender.
rpc MarkRecommendationFailed(MarkRecommendationFailedRequest) returns (Recommendation) {
rpc MarkRecommendationFailed(MarkRecommendationFailedRequest)
returns (Recommendation) {
option (google.api.http) = {
post: "/v1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed"
body: "*"
@ -228,6 +236,62 @@ service Recommender {
};
option (google.api.method_signature) = "name,state_metadata,etag";
}
// Gets the requested Recommender Config. There is only one instance of the
// config for each Recommender.
rpc GetRecommenderConfig(GetRecommenderConfigRequest)
returns (RecommenderConfig) {
option (google.api.http) = {
get: "/v1/{name=projects/*/locations/*/recommenders/*/config}"
additional_bindings {
get: "/v1/{name=organizations/*/locations/*/recommenders/*/config}"
}
};
option (google.api.method_signature) = "name";
}
// Updates a Recommender Config. This will create a new revision of the
// config.
rpc UpdateRecommenderConfig(UpdateRecommenderConfigRequest)
returns (RecommenderConfig) {
option (google.api.http) = {
patch: "/v1/{recommender_config.name=projects/*/locations/*/recommenders/*/config}"
body: "recommender_config"
additional_bindings {
patch: "/v1/{recommender_config.name=organizations/*/locations/*/recommenders/*/config}"
body: "recommender_config"
}
};
option (google.api.method_signature) = "recommender_config,update_mask";
}
// Gets the requested InsightTypeConfig. There is only one instance of the
// config for each InsightType.
rpc GetInsightTypeConfig(GetInsightTypeConfigRequest)
returns (InsightTypeConfig) {
option (google.api.http) = {
get: "/v1/{name=projects/*/locations/*/insightTypes/*/config}"
additional_bindings {
get: "/v1/{name=organizations/*/locations/*/insightTypes/*/config}"
}
};
option (google.api.method_signature) = "name";
}
// Updates an InsightTypeConfig change. This will create a new revision of the
// config.
rpc UpdateInsightTypeConfig(UpdateInsightTypeConfigRequest)
returns (InsightTypeConfig) {
option (google.api.http) = {
patch: "/v1/{insight_type_config.name=projects/*/locations/*/insightTypes/*/config}"
body: "insight_type_config"
additional_bindings {
patch: "/v1/{insight_type_config.name=organizations/*/locations/*/insightTypes/*/config}"
body: "insight_type_config"
}
};
option (google.api.method_signature) = "insight_type_config,update_mask";
}
}
// Request for the `ListInsights` method.
@ -256,15 +320,15 @@ message ListInsightsRequest {
}
];
// Optional. The maximum number of results to return from this request. Non-positive
// values are ignored. If not specified, the server will determine the number
// of results to return.
// Optional. The maximum number of results to return from this request.
// Non-positive values are ignored. If not specified, the server will
// determine the number of results to return.
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
// Optional. If present, retrieves the next batch of results from the preceding call to
// this method. `page_token` must be the value of `next_page_token` from the
// previous response. The values of other method parameters must be identical
// to those in the previous call.
// Optional. If present, retrieves the next batch of results from the
// preceding call to this method. `page_token` must be the value of
// `next_page_token` from the previous response. The values of other method
// parameters must be identical to those in the previous call.
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
// Optional. Filter expression to restrict the insights returned. Supported
@ -322,9 +386,10 @@ message MarkInsightAcceptedRequest {
}
];
// Optional. State properties user wish to include with this state. Full replace of the
// current state_metadata.
map<string, string> state_metadata = 2 [(google.api.field_behavior) = OPTIONAL];
// Optional. State properties user wish to include with this state. Full
// replace of the current state_metadata.
map<string, string> state_metadata = 2
[(google.api.field_behavior) = OPTIONAL];
// Required. Fingerprint of the Insight. Provides optimistic locking.
string etag = 3 [(google.api.field_behavior) = REQUIRED];
@ -356,15 +421,15 @@ message ListRecommendationsRequest {
}
];
// Optional. The maximum number of results to return from this request. Non-positive
// values are ignored. If not specified, the server will determine the number
// of results to return.
// Optional. The maximum number of results to return from this request.
// Non-positive values are ignored. If not specified, the server will
// determine the number of results to return.
int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
// Optional. If present, retrieves the next batch of results from the preceding call to
// this method. `page_token` must be the value of `next_page_token` from the
// previous response. The values of other method parameters must be identical
// to those in the previous call.
// Optional. If present, retrieves the next batch of results from the
// preceding call to this method. `page_token` must be the value of
// `next_page_token` from the previous response. The values of other method
// parameters must be identical to those in the previous call.
string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
// Filter expression to restrict the recommendations returned. Supported
@ -471,3 +536,69 @@ message MarkRecommendationFailedRequest {
// Required. Fingerprint of the Recommendation. Provides optimistic locking.
string etag = 3 [(google.api.field_behavior) = REQUIRED];
}
// Request for the GetRecommenderConfig` method.
message GetRecommenderConfigRequest {
// Required. Name of the Recommendation Config to get.
//
// Acceptable formats:
//
// * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
//
// * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
//
// * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "recommender.googleapis.com/RecommenderConfig"
}
];
}
// Request for the `UpdateRecommenderConfig` method.
message UpdateRecommenderConfigRequest {
// Required. The RecommenderConfig to update.
RecommenderConfig recommender_config = 1
[(google.api.field_behavior) = REQUIRED];
// The list of fields to be updated.
google.protobuf.FieldMask update_mask = 2;
// If true, validate the request and preview the change, but do not actually
// update it.
bool validate_only = 3;
}
// Request for the GetInsightTypeConfig` method.
message GetInsightTypeConfigRequest {
// Required. Name of the InsightTypeConfig to get.
//
// Acceptable formats:
//
// * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config`
//
// * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config`
//
// * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config`
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "recommender.googleapis.com/InsightTypeConfig"
}
];
}
// Request for the `UpdateInsightTypeConfig` method.
message UpdateInsightTypeConfigRequest {
// Required. The InsightTypeConfig to update.
InsightTypeConfig insight_type_config = 1
[(google.api.field_behavior) = REQUIRED];
// The list of fields to be updated.
google.protobuf.FieldMask update_mask = 2;
// If true, validate the request and preview the change, but do not actually
// update it.
bool validate_only = 3;
}

@ -176,6 +176,7 @@ py_gapic_library(
name = "recommender_py_gapic",
srcs = [":recommender_proto"],
grpc_service_config = "recommender_grpc_service_config.json",
service_yaml = "recommender_v1beta1.yaml",
)
# Open Source Packages
@ -284,6 +285,7 @@ ruby_cloud_gapic_library(
srcs = [":recommender_proto_with_info"],
extra_protoc_parameters = ["ruby-cloud-gem-name=google-cloud-recommender-v1beta1"],
grpc_service_config = "recommender_grpc_service_config.json",
service_yaml = "recommender_v1beta1.yaml",
deps = [
":recommender_ruby_grpc",
":recommender_ruby_proto",

Loading…
Cancel
Save