Migrate Recommender v1beta1 to GAPIC v2.

Committer: @lukesneeringer
PiperOrigin-RevId: 288713066
This commit is contained in:
Google APIs 2020-01-08 09:28:41 -08:00 committed by Copybara-Service
parent 94f986afd3
commit 5ef42bcd36
6 changed files with 257 additions and 201 deletions

View File

@ -8,6 +8,7 @@ common:
- .
service_yaml: recommender_v1beta1.yaml
gapic_yaml: recommender_gapic.yaml
proto_package: google.cloud.recommender.v1beta1
samples: samples
artifacts:
- name: gapic_config

View File

@ -17,6 +17,7 @@ syntax = "proto3";
package google.cloud.recommender.v1beta1;
import "google/api/resource.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
@ -27,14 +28,20 @@ option go_package = "google.golang.org/genproto/googleapis/cloud/recommender/v1b
option java_multiple_files = true;
option java_package = "com.google.cloud.recommender.v1beta1";
option objc_class_prefix = "CREC";
option (google.api.resource_definition) = {
type: "recommender.googleapis.com/Recommender"
pattern: "projects/{project}/locations/{location}/recommenders/{recommender}"
};
// A recommendation along with a suggested action. E.g., a rightsizing
// recommendation for an underutilized VM, IAM role recommendations, etc
message Recommendation {
option (google.api.resource) = {
type: "recommender.googleapis.com/Recommendation"
pattern: "projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}"
};
// Name of recommendation.
//
// A project recommendation is represented as
// projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/recommendations/[RECOMMENDATION_ID]
string name = 1;
// Free-form human readable summary in English. The maximum length is 500

View File

@ -0,0 +1,178 @@
type: com.google.api.codegen.ConfigProto
config_schema_version: 1.0.0
# The settings of generated code in a specific language.
language_settings:
java:
package_name: com.google.cloud.recommender.v1beta1
python:
package_name: google.cloud.recommender_v1beta1.gapic
go:
package_name: cloud.google.com/go/recommender/apiv1beta1
csharp:
package_name: Google.Cloud.Recommender.V1Beta1
ruby:
package_name: Google::Cloud::Recommender::V1beta1
php:
package_name: Google\Cloud\Recommender\V1beta1
nodejs:
package_name: recommender.v1beta1
# A list of API interface configurations.
interfaces:
# The fully qualified name of the API interface.
- name: google.cloud.recommender.v1beta1.Recommender
# A list of resource collection configurations.
# Consists of a name_pattern and an entity_name.
# The name_pattern is a pattern to describe the names of the resources of this
# collection, using the platform's conventions for URI patterns. A generator
# may use this to generate methods to compose and decompose such names. The
# pattern should use named placeholders as in `shelves/{shelf}/books/{book}`;
# those will be taken as hints for the parameter names of the generated
# methods. If empty, no name methods are generated.
# The entity_name is the name to be used as a basis for generated methods and
# classes.
collections:
- name_pattern: projects/{project}/locations/{location}/recommenders/{recommender}
entity_name: recommender
- name_pattern: projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}
entity_name: recommendation
# Definition for retryable codes.
retry_codes_def:
- name: idempotent
retry_codes:
- DEADLINE_EXCEEDED
- UNAVAILABLE
- name: non_idempotent
retry_codes: []
# Definition for retry/backoff parameters.
retry_params_def:
- name: default
initial_retry_delay_millis: 100
retry_delay_multiplier: 1.3
max_retry_delay_millis: 60000
initial_rpc_timeout_millis: 20000
rpc_timeout_multiplier: 1
max_rpc_timeout_millis: 20000
total_timeout_millis: 600000
# A list of method configurations.
# Common properties:
#
# name - The simple name of the method.
#
# flattening - Specifies the configuration for parameter flattening.
# Describes the parameter groups for which a generator should produce method
# overloads which allow a client to directly pass request message fields as
# method parameters. This information may or may not be used, depending on
# the target language.
# Consists of groups, which each represent a list of parameters to be
# flattened. Each parameter listed must be a field of the request message.
#
# required_fields - Fields that are always required for a request to be
# valid.
#
# page_streaming - Specifies the configuration for paging.
# Describes information for generating a method which transforms a paging
# list RPC into a stream of resources.
# Consists of a request and a response.
# The request specifies request information of the list method. It defines
# which fields match the paging pattern in the request. The request consists
# of a page_size_field and a token_field. The page_size_field is the name of
# the optional field specifying the maximum number of elements to be
# returned in the response. The token_field is the name of the field in the
# request containing the page token.
# The response specifies response information of the list method. It defines
# which fields match the paging pattern in the response. The response
# consists of a token_field and a resources_field. The token_field is the
# name of the field in the response containing the next page token. The
# resources_field is the name of the field in the response containing the
# list of resources belonging to the page.
#
# retry_codes_name - Specifies the configuration for retryable codes. The
# name must be defined in interfaces.retry_codes_def.
#
# retry_params_name - Specifies the configuration for retry/backoff
# parameters. The name must be defined in interfaces.retry_params_def.
#
# field_name_patterns - Maps the field name of the request type to
# entity_name of interfaces.collections.
# Specifies the string pattern that the field must follow.
#
# timeout_millis - Specifies the default timeout for a non-retrying call. If
# the call is retrying, refer to retry_params_name instead.
methods:
- name: ListRecommendations
flattening:
groups:
- parameters:
- parent
- filter
required_fields:
- parent
page_streaming:
request:
page_size_field: page_size
token_field: page_token
response:
token_field: next_page_token
resources_field: recommendations
retry_codes_name: idempotent
retry_params_name: default
field_name_patterns:
parent: recommender
timeout_millis: 60000
- name: GetRecommendation
flattening:
groups:
- parameters:
- name
required_fields:
- name
retry_codes_name: idempotent
retry_params_name: default
field_name_patterns:
name: recommendation
timeout_millis: 60000
- name: MarkRecommendationClaimed
flattening:
groups:
- parameters:
- name
- state_metadata
- etag
required_fields:
- name
- etag
retry_codes_name: non_idempotent
retry_params_name: default
field_name_patterns:
name: recommendation
timeout_millis: 60000
- name: MarkRecommendationSucceeded
flattening:
groups:
- parameters:
- name
- state_metadata
- etag
required_fields:
- name
- etag
retry_codes_name: non_idempotent
retry_params_name: default
field_name_patterns:
name: recommendation
timeout_millis: 60000
- name: MarkRecommendationFailed
flattening:
groups:
- parameters:
- name
- state_metadata
- etag
required_fields:
- name
- etag
retry_codes_name: non_idempotent
retry_params_name: default
field_name_patterns:
name: recommendation
timeout_millis: 60000

View File

@ -1,5 +1,5 @@
type: com.google.api.codegen.ConfigProto
config_schema_version: 1.0.0
config_schema_version: 2.0.0
# The settings of generated code in a specific language.
language_settings:
java:
@ -9,170 +9,10 @@ language_settings:
go:
package_name: cloud.google.com/go/recommender/apiv1beta1
csharp:
package_name: Google.Cloud.Recommender.V1beta1
package_name: Google.Cloud.Recommender.V1Beta1
ruby:
package_name: Google::Cloud::Recommender::V1beta1
php:
package_name: Google\Cloud\Recommender\V1beta1
nodejs:
package_name: recommender.v1beta1
# A list of API interface configurations.
interfaces:
# The fully qualified name of the API interface.
- name: google.cloud.recommender.v1beta1.Recommender
# A list of resource collection configurations.
# Consists of a name_pattern and an entity_name.
# The name_pattern is a pattern to describe the names of the resources of this
# collection, using the platform's conventions for URI patterns. A generator
# may use this to generate methods to compose and decompose such names. The
# pattern should use named placeholders as in `shelves/{shelf}/books/{book}`;
# those will be taken as hints for the parameter names of the generated
# methods. If empty, no name methods are generated.
# The entity_name is the name to be used as a basis for generated methods and
# classes.
collections:
- name_pattern: projects/{project}/locations/{location}/recommenders/{recommender}
entity_name: recommender
- name_pattern: projects/{project}/locations/{location}/recommenders/{recommender}/recommendations/{recommendation}
entity_name: recommendation
# Definition for retryable codes.
retry_codes_def:
- name: idempotent
retry_codes:
- DEADLINE_EXCEEDED
- UNAVAILABLE
- name: non_idempotent
retry_codes: []
# Definition for retry/backoff parameters.
retry_params_def:
- name: default
initial_retry_delay_millis: 100
retry_delay_multiplier: 1.3
max_retry_delay_millis: 60000
initial_rpc_timeout_millis: 20000
rpc_timeout_multiplier: 1
max_rpc_timeout_millis: 20000
total_timeout_millis: 600000
# A list of method configurations.
# Common properties:
#
# name - The simple name of the method.
#
# flattening - Specifies the configuration for parameter flattening.
# Describes the parameter groups for which a generator should produce method
# overloads which allow a client to directly pass request message fields as
# method parameters. This information may or may not be used, depending on
# the target language.
# Consists of groups, which each represent a list of parameters to be
# flattened. Each parameter listed must be a field of the request message.
#
# required_fields - Fields that are always required for a request to be
# valid.
#
# page_streaming - Specifies the configuration for paging.
# Describes information for generating a method which transforms a paging
# list RPC into a stream of resources.
# Consists of a request and a response.
# The request specifies request information of the list method. It defines
# which fields match the paging pattern in the request. The request consists
# of a page_size_field and a token_field. The page_size_field is the name of
# the optional field specifying the maximum number of elements to be
# returned in the response. The token_field is the name of the field in the
# request containing the page token.
# The response specifies response information of the list method. It defines
# which fields match the paging pattern in the response. The response
# consists of a token_field and a resources_field. The token_field is the
# name of the field in the response containing the next page token. The
# resources_field is the name of the field in the response containing the
# list of resources belonging to the page.
#
# retry_codes_name - Specifies the configuration for retryable codes. The
# name must be defined in interfaces.retry_codes_def.
#
# retry_params_name - Specifies the configuration for retry/backoff
# parameters. The name must be defined in interfaces.retry_params_def.
#
# field_name_patterns - Maps the field name of the request type to
# entity_name of interfaces.collections.
# Specifies the string pattern that the field must follow.
#
# timeout_millis - Specifies the default timeout for a non-retrying call. If
# the call is retrying, refer to retry_params_name instead.
methods:
- name: ListRecommendations
flattening:
groups:
- parameters:
- parent
- filter
required_fields:
- parent
page_streaming:
request:
page_size_field: page_size
token_field: page_token
response:
token_field: next_page_token
resources_field: recommendations
retry_codes_name: idempotent
retry_params_name: default
field_name_patterns:
parent: recommender
timeout_millis: 60000
- name: GetRecommendation
flattening:
groups:
- parameters:
- name
required_fields:
- name
retry_codes_name: idempotent
retry_params_name: default
field_name_patterns:
name: recommendation
timeout_millis: 60000
- name: MarkRecommendationClaimed
flattening:
groups:
- parameters:
- name
- state_metadata
- etag
required_fields:
- name
- etag
retry_codes_name: non_idempotent
retry_params_name: default
field_name_patterns:
name: recommendation
timeout_millis: 60000
- name: MarkRecommendationSucceeded
flattening:
groups:
- parameters:
- name
- state_metadata
- etag
required_fields:
- name
- etag
retry_codes_name: non_idempotent
retry_params_name: default
field_name_patterns:
name: recommendation
timeout_millis: 60000
- name: MarkRecommendationFailed
flattening:
groups:
- parameters:
- name
- state_metadata
- etag
required_fields:
- name
- etag
retry_codes_name: non_idempotent
retry_params_name: default
field_name_patterns:
name: recommendation
timeout_millis: 60000

View File

@ -14,7 +14,7 @@
"timeout": "60s",
"retryPolicy": {
"maxAttempts": 5,
"initialBackoff": "1s",
"initialBackoff": "0.100s",
"maxBackoff": "60s",
"backoffMultiplier": 1.3,
"retryableStatusCodes": [
@ -38,14 +38,7 @@
"method": "MarkRecommendationFailed"
}
],
"timeout": "60s",
"retryPolicy": {
"maxAttempts": 5,
"initialBackoff": "1s",
"maxBackoff": "60s",
"backoffMultiplier": 1.3,
"retryableStatusCodes": []
}
"timeout": "60s"
}
]
}
}

View File

@ -18,9 +18,10 @@ syntax = "proto3";
package google.cloud.recommender.v1beta1;
import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/cloud/recommender/v1beta1/recommendation.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/recommender/v1beta1/recommendation.proto";
option csharp_namespace = "Google.Cloud.Recommmender.V1Beta1";
option go_package = "google.golang.org/genproto/googleapis/cloud/recommender/v1beta1;recommender";
@ -43,6 +44,7 @@ service Recommender {
option (google.api.http) = {
get: "/v1beta1/{parent=projects/*/locations/*/recommenders/*}/recommendations"
};
option (google.api.method_signature) = "parent,filter";
}
// Gets the requested recommendation. Requires the recommender.*.get
@ -51,6 +53,7 @@ service Recommender {
option (google.api.http) = {
get: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}"
};
option (google.api.method_signature) = "name";
}
// Marks the Recommendation State as Claimed. Users can use this method to
@ -68,6 +71,7 @@ service Recommender {
post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markClaimed"
body: "*"
};
option (google.api.method_signature) = "name,state_metadata,etag";
}
// Marks the Recommendation State as Succeeded. Users can use this method to
@ -86,6 +90,7 @@ service Recommender {
post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markSucceeded"
body: "*"
};
option (google.api.method_signature) = "name,state_metadata,etag";
}
// Marks the Recommendation State as Failed. Users can use this method to
@ -104,6 +109,7 @@ service Recommender {
post: "/v1beta1/{name=projects/*/locations/*/recommenders/*/recommendations/*}:markFailed"
body: "*"
};
option (google.api.method_signature) = "name,state_metadata,etag";
}
}
@ -117,18 +123,23 @@ message ListRecommendationsRequest {
//
// LOCATION here refers to GCP Locations:
// https://cloud.google.com/about/locations/
string parent = 1;
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "recommender.googleapis.com/Recommender"
}
];
// 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;
// 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.
string page_token = 3;
// 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
// filter fields: state_info.state
@ -148,45 +159,71 @@ message ListRecommendationsResponse {
// Request to the `GetRecommendation` method.
message GetRecommendationRequest {
// Name of the recommendation.
string name = 1;
// Required. Name of the recommendation.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "recommender.googleapis.com/Recommendation"
}
];
}
// Request for the `MarkRecommendationClaimed` Method.
message MarkRecommendationClaimedRequest {
// Name of the recommendation.
string name = 1;
// Required. Name of the recommendation.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "recommender.googleapis.com/Recommendation"
}
];
// State properties to include with this state. Overwrites any existing
// `state_metadata`.
// Keys must match the regex /^[a-z0-9][a-z0-9_.-]{0,62}$/.
// Values must match the regex /^[a-zA-Z0-9_./-]{0,255}$/.
map<string, string> state_metadata = 2;
// Fingerprint of the Recommendation. Provides optimistic locking.
string etag = 3;
// Required. Fingerprint of the Recommendation. Provides optimistic locking.
string etag = 3 [(google.api.field_behavior) = REQUIRED];
}
// Request for the `MarkRecommendationSucceeded` Method.
message MarkRecommendationSucceededRequest {
// Name of the recommendation.
string name = 1;
// Required. Name of the recommendation.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "recommender.googleapis.com/Recommendation"
}
];
// State properties to include with this state. Overwrites any existing
// `state_metadata`.
// Keys must match the regex /^[a-z0-9][a-z0-9_.-]{0,62}$/.
// Values must match the regex /^[a-zA-Z0-9_./-]{0,255}$/.
map<string, string> state_metadata = 2;
// Fingerprint of the Recommendation. Provides optimistic locking.
string etag = 3;
// Required. Fingerprint of the Recommendation. Provides optimistic locking.
string etag = 3 [(google.api.field_behavior) = REQUIRED];
}
// Request for the `MarkRecommendationFailed` Method.
message MarkRecommendationFailedRequest {
// Name of the recommendation.
string name = 1;
// Required. Name of the recommendation.
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "recommender.googleapis.com/Recommendation"
}
];
// State properties to include with this state. Overwrites any existing
// `state_metadata`.
// Keys must match the regex /^[a-z0-9][a-z0-9_.-]{0,62}$/.
// Values must match the regex /^[a-zA-Z0-9_./-]{0,255}$/.
map<string, string> state_metadata = 2;
// Fingerprint of the Recommendation. Provides optimistic locking.
string etag = 3;
// Required. Fingerprint of the Recommendation. Provides optimistic locking.
string etag = 3 [(google.api.field_behavior) = REQUIRED];
}