Reference documentation and code samples for the Recommender V1 API class Google::Cloud::Recommender::V1::Recommender::Client.
Client for the Recommender service.
Provides insights and recommendations for cloud customers for various categories like performance optimization, cost savings, reliability, feature discovery, etc. Insights and recommendations are generated automatically based on analysis of user resources, configuration and monitoring metrics.
Inherits
- Object
Methods
.configure
def self.configure() { |config| ... } -> Client::Configuration
Configure the Recommender Client class.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
# Modify the configuration for all Recommender clients ::Google::Cloud::Recommender::V1::Recommender::Client.configure do |config| config.timeout = 10.0 end
#configure
def configure() { |config| ... } -> Client::Configuration
Configure the Recommender Client instance.
The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on Client.configure.
See Configuration for a description of the configuration fields.
- (config) — Configure the Client client.
- config (Client::Configuration)
#get_insight
def get_insight(request, options = nil) -> ::Google::Cloud::Recommender::V1::Insight
def get_insight(name: nil) -> ::Google::Cloud::Recommender::V1::Insight
Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.
def get_insight(request, options = nil) -> ::Google::Cloud::Recommender::V1::Insight
get_insight
via a request object, either of type
GetInsightRequest or an equivalent Hash.
- request (::Google::Cloud::Recommender::V1::GetInsightRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_insight(name: nil) -> ::Google::Cloud::Recommender::V1::Insight
get_insight
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- name (::String) — Required. Name of the insight.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Recommender::V1::Insight)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/recommender/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Recommender::V1::Recommender::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Recommender::V1::GetInsightRequest.new # Call the get_insight method. result = client.get_insight request # The returned object is of type Google::Cloud::Recommender::V1::Insight. p result
#get_recommendation
def get_recommendation(request, options = nil) -> ::Google::Cloud::Recommender::V1::Recommendation
def get_recommendation(name: nil) -> ::Google::Cloud::Recommender::V1::Recommendation
Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.
def get_recommendation(request, options = nil) -> ::Google::Cloud::Recommender::V1::Recommendation
get_recommendation
via a request object, either of type
GetRecommendationRequest or an equivalent Hash.
- request (::Google::Cloud::Recommender::V1::GetRecommendationRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_recommendation(name: nil) -> ::Google::Cloud::Recommender::V1::Recommendation
get_recommendation
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- name (::String) — Required. Name of the recommendation.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Recommender::V1::Recommendation)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/recommender/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Recommender::V1::Recommender::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Recommender::V1::GetRecommendationRequest.new # Call the get_recommendation method. result = client.get_recommendation request # The returned object is of type Google::Cloud::Recommender::V1::Recommendation. p result
#initialize
def initialize() { |config| ... } -> Client
Create a new Recommender client object.
- (config) — Configure the Recommender client.
- config (Client::Configuration)
- (Client) — a new instance of Client
# Create a client using the default configuration client = ::Google::Cloud::Recommender::V1::Recommender::Client.new # Create a client using a custom configuration client = ::Google::Cloud::Recommender::V1::Recommender::Client.new do |config| config.timeout = 10.0 end
#list_insights
def list_insights(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Insight>
def list_insights(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Insight>
Lists insights for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified insight type.
def list_insights(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Insight>
list_insights
via a request object, either of type
ListInsightsRequest or an equivalent Hash.
- request (::Google::Cloud::Recommender::V1::ListInsightsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_insights(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Insight>
list_insights
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Required. The container resource on which to execute the request.
Acceptable formats:
projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]
projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]
billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]
folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]
organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]
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.
- page_size (::Integer) — 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.
-
page_token (::String) — Optional. If present, retrieves the next batch of results from the preceding call to
this method.
page_token
must be the value ofnext_page_token
from the previous response. The values of other method parameters must be identical to those in the previous call. -
filter (::String) — Optional. Filter expression to restrict the insights returned. Supported
filter fields:
stateInfo.state
insightSubtype
severity
Examples:
stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED
insightSubtype = PERMISSIONS_USAGE
severity = CRITICAL OR severity = HIGH
stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)
(These expressions are based on the filter language described at https://google.aip.dev/160)
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Insight>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Insight>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/recommender/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Recommender::V1::Recommender::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Recommender::V1::ListInsightsRequest.new # Call the list_insights method. result = client.list_insights request # The returned object is of type Gapic::PagedEnumerable. You can # iterate over all elements by calling #each, and the enumerable # will lazily make API calls to fetch subsequent pages. Other # methods are also available for managing paging directly. result.each do |response| # Each element is of type ::Google::Cloud::Recommender::V1::Insight. p response end
#list_recommendations
def list_recommendations(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Recommendation>
def list_recommendations(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Recommendation>
Lists recommendations for the specified Cloud Resource. Requires the recommender.*.list IAM permission for the specified recommender.
def list_recommendations(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Recommendation>
list_recommendations
via a request object, either of type
ListRecommendationsRequest or an equivalent Hash.
- request (::Google::Cloud::Recommender::V1::ListRecommendationsRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def list_recommendations(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Recommendation>
list_recommendations
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
-
parent (::String) — Required. The container resource on which to execute the request.
Acceptable formats:
projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]
projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]
billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]
folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]
organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]
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.
- page_size (::Integer) — 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.
-
page_token (::String) — Optional. If present, retrieves the next batch of results from the preceding call to
this method.
page_token
must be the value ofnext_page_token
from the previous response. The values of other method parameters must be identical to those in the previous call. -
filter (::String) — Filter expression to restrict the recommendations returned. Supported
filter fields:
state_info.state
recommenderSubtype
priority
Examples:
stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED
recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE
priority = P1 OR priority = P2
stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)
(These expressions are based on the filter language described at https://google.aip.dev/160)
- (response, operation) — Access the result along with the RPC operation
- response (::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Recommendation>)
- operation (::GRPC::ActiveCall::Operation)
- (::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Recommendation>)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/recommender/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Recommender::V1::Recommender::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Recommender::V1::ListRecommendationsRequest.new # Call the list_recommendations method. result = client.list_recommendations request # The returned object is of type Gapic::PagedEnumerable. You can # iterate over all elements by calling #each, and the enumerable # will lazily make API calls to fetch subsequent pages. Other # methods are also available for managing paging directly. result.each do |response| # Each element is of type ::Google::Cloud::Recommender::V1::Recommendation. p response end
#mark_insight_accepted
def mark_insight_accepted(request, options = nil) -> ::Google::Cloud::Recommender::V1::Insight
def mark_insight_accepted(name: nil, state_metadata: nil, etag: nil) -> ::Google::Cloud::Recommender::V1::Insight
Marks the Insight State as Accepted. Users can use this method to indicate to the Recommender API that they have applied some action based on the insight. This stops the insight content from being updated.
MarkInsightAccepted can be applied to insights in ACTIVE state. Requires the recommender.*.update IAM permission for the specified insight.
def mark_insight_accepted(request, options = nil) -> ::Google::Cloud::Recommender::V1::Insight
mark_insight_accepted
via a request object, either of type
MarkInsightAcceptedRequest or an equivalent Hash.
- request (::Google::Cloud::Recommender::V1::MarkInsightAcceptedRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def mark_insight_accepted(name: nil, state_metadata: nil, etag: nil) -> ::Google::Cloud::Recommender::V1::Insight
mark_insight_accepted
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- name (::String) — Required. Name of the insight.
- state_metadata (::Hash{::String => ::String}) — Optional. State properties user wish to include with this state. Full replace of the current state_metadata.
- etag (::String) — Required. Fingerprint of the Insight. Provides optimistic locking.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Recommender::V1::Insight)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/recommender/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Recommender::V1::Recommender::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Recommender::V1::MarkInsightAcceptedRequest.new # Call the mark_insight_accepted method. result = client.mark_insight_accepted request # The returned object is of type Google::Cloud::Recommender::V1::Insight. p result
#mark_recommendation_claimed
def mark_recommendation_claimed(request, options = nil) -> ::Google::Cloud::Recommender::V1::Recommendation
def mark_recommendation_claimed(name: nil, state_metadata: nil, etag: nil) -> ::Google::Cloud::Recommender::V1::Recommendation
Marks the Recommendation State as Claimed. Users can use this method to indicate to the Recommender API that they are starting to apply the recommendation themselves. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state.
MarkRecommendationClaimed can be applied to recommendations in CLAIMED, SUCCEEDED, FAILED, or ACTIVE state.
Requires the recommender.*.update IAM permission for the specified recommender.
def mark_recommendation_claimed(request, options = nil) -> ::Google::Cloud::Recommender::V1::Recommendation
mark_recommendation_claimed
via a request object, either of type
MarkRecommendationClaimedRequest or an equivalent Hash.
- request (::Google::Cloud::Recommender::V1::MarkRecommendationClaimedRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def mark_recommendation_claimed(name: nil, state_metadata: nil, etag: nil) -> ::Google::Cloud::Recommender::V1::Recommendation
mark_recommendation_claimed
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- name (::String) — Required. Name of the recommendation.
-
state_metadata (::Hash{::String => ::String}) — 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}$/
. - etag (::String) — Required. Fingerprint of the Recommendation. Provides optimistic locking.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Recommender::V1::Recommendation)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/recommender/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Recommender::V1::Recommender::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Recommender::V1::MarkRecommendationClaimedRequest.new # Call the mark_recommendation_claimed method. result = client.mark_recommendation_claimed request # The returned object is of type Google::Cloud::Recommender::V1::Recommendation. p result
#mark_recommendation_failed
def mark_recommendation_failed(request, options = nil) -> ::Google::Cloud::Recommender::V1::Recommendation
def mark_recommendation_failed(name: nil, state_metadata: nil, etag: nil) -> ::Google::Cloud::Recommender::V1::Recommendation
Marks the Recommendation State as Failed. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation failed. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state.
MarkRecommendationFailed can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state.
Requires the recommender.*.update IAM permission for the specified recommender.
def mark_recommendation_failed(request, options = nil) -> ::Google::Cloud::Recommender::V1::Recommendation
mark_recommendation_failed
via a request object, either of type
MarkRecommendationFailedRequest or an equivalent Hash.
- request (::Google::Cloud::Recommender::V1::MarkRecommendationFailedRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def mark_recommendation_failed(name: nil, state_metadata: nil, etag: nil) -> ::Google::Cloud::Recommender::V1::Recommendation
mark_recommendation_failed
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- name (::String) — Required. Name of the recommendation.
-
state_metadata (::Hash{::String => ::String}) — 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}$/
. - etag (::String) — Required. Fingerprint of the Recommendation. Provides optimistic locking.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Recommender::V1::Recommendation)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/recommender/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Recommender::V1::Recommender::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Recommender::V1::MarkRecommendationFailedRequest.new # Call the mark_recommendation_failed method. result = client.mark_recommendation_failed request # The returned object is of type Google::Cloud::Recommender::V1::Recommendation. p result
#mark_recommendation_succeeded
def mark_recommendation_succeeded(request, options = nil) -> ::Google::Cloud::Recommender::V1::Recommendation
def mark_recommendation_succeeded(name: nil, state_metadata: nil, etag: nil) -> ::Google::Cloud::Recommender::V1::Recommendation
Marks the Recommendation State as Succeeded. Users can use this method to indicate to the Recommender API that they have applied the recommendation themselves, and the operation was successful. This stops the recommendation content from being updated. Associated insights are frozen and placed in the ACCEPTED state.
MarkRecommendationSucceeded can be applied to recommendations in ACTIVE, CLAIMED, SUCCEEDED, or FAILED state.
Requires the recommender.*.update IAM permission for the specified recommender.
def mark_recommendation_succeeded(request, options = nil) -> ::Google::Cloud::Recommender::V1::Recommendation
mark_recommendation_succeeded
via a request object, either of type
MarkRecommendationSucceededRequest or an equivalent Hash.
- request (::Google::Cloud::Recommender::V1::MarkRecommendationSucceededRequest, ::Hash) — A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.
- options (::Gapic::CallOptions, ::Hash) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def mark_recommendation_succeeded(name: nil, state_metadata: nil, etag: nil) -> ::Google::Cloud::Recommender::V1::Recommendation
mark_recommendation_succeeded
via keyword arguments. Note that at
least one keyword argument is required. To specify no parameters, or to keep all
the default parameter values, pass an empty Hash as a request object (see above).
- name (::String) — Required. Name of the recommendation.
-
state_metadata (::Hash{::String => ::String}) — 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}$/
. - etag (::String) — Required. Fingerprint of the Recommendation. Provides optimistic locking.
- (response, operation) — Access the result along with the RPC operation
- response (::Google::Cloud::Recommender::V1::Recommendation)
- operation (::GRPC::ActiveCall::Operation)
- (::Google::Cloud::Error) — if the RPC is aborted.
Basic example
require "google/cloud/recommender/v1" # Create a client object. The client can be reused for multiple calls. client = Google::Cloud::Recommender::V1::Recommender::Client.new # Create a request. To set request fields, pass in keyword arguments. request = Google::Cloud::Recommender::V1::MarkRecommendationSucceededRequest.new # Call the mark_recommendation_succeeded method. result = client.mark_recommendation_succeeded request # The returned object is of type Google::Cloud::Recommender::V1::Recommendation. p result