Class: Google::Cloud::Recommender::V1::Recommender::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/recommender/v1/recommender/client.rb

Overview

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.

Defined Under Namespace

Classes: Configuration

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#insight_path, #insight_type_config_path, #insight_type_path, #recommendation_path, #recommender_config_path, #recommender_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new Recommender client object.

Examples:


# 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

Yields:

  • (config)

    Configure the Recommender client.

Yield Parameters:



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 155

def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/cloud/recommender/v1/recommender_service_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint.nil? ||
                           (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-"))
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @recommender_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::Recommender::V1::Recommender::Stub,
    credentials: credentials,
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors,
    channel_pool_config: @config.channel_pool,
    logger: @config.logger
  )

  @recommender_stub.stub_logger&.info do |entry|
    entry.set_system_name
    entry.set_service
    entry.message = "Created client for #{entry.service}"
    entry.set_credentials_fields credentials
    entry.set "customEndpoint", @config.endpoint if @config.endpoint
    entry.set "defaultTimeout", @config.timeout if @config.timeout
    entry.set "quotaProject", @quota_project_id if @quota_project_id
  end
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the Recommender Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all Recommender clients
::Google::Cloud::Recommender::V1::Recommender::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 65

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "Recommender", "V1"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.rpcs.list_insights.timeout = 60.0
    default_config.rpcs.list_insights.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_insight.timeout = 60.0
    default_config.rpcs.get_insight.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.mark_insight_accepted.timeout = 60.0

    default_config.rpcs.list_recommendations.timeout = 60.0
    default_config.rpcs.list_recommendations.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.get_recommendation.timeout = 60.0
    default_config.rpcs.get_recommendation.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
    }

    default_config.rpcs.mark_recommendation_claimed.timeout = 60.0

    default_config.rpcs.mark_recommendation_succeeded.timeout = 60.0

    default_config.rpcs.mark_recommendation_failed.timeout = 60.0

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#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 configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



125
126
127
128
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 125

def configure
  yield @config if block_given?
  @config
end

#get_insight(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Insight #get_insight(name: nil) ⇒ ::Google::Cloud::Recommender::V1::Insight

Gets the requested insight. Requires the recommender.*.get IAM permission for the specified insight type.

Examples:

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

Overloads:

  • #get_insight(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Insight

    Pass arguments to get_insight via a request object, either of type GetInsightRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_insight(name: nil) ⇒ ::Google::Cloud::Recommender::V1::Insight

    Pass arguments to 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).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Name of the insight.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 408

def get_insight request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::GetInsightRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_insight..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_insight.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_insight.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :get_insight, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_insight_type_config(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::InsightTypeConfig #get_insight_type_config(name: nil) ⇒ ::Google::Cloud::Recommender::V1::InsightTypeConfig

Gets the requested InsightTypeConfig. There is only one instance of the config for each InsightType.

Examples:

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::GetInsightTypeConfigRequest.new

# Call the get_insight_type_config method.
result = client.get_insight_type_config request

# The returned object is of type Google::Cloud::Recommender::V1::InsightTypeConfig.
p result

Overloads:

  • #get_insight_type_config(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::InsightTypeConfig

    Pass arguments to get_insight_type_config via a request object, either of type GetInsightTypeConfigRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Recommender::V1::GetInsightTypeConfigRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_insight_type_config(name: nil) ⇒ ::Google::Cloud::Recommender::V1::InsightTypeConfig

    Pass arguments to get_insight_type_config 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).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Name of the InsightTypeConfig to get.

      Acceptable formats:

      • projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config

      • projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config

      • organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config

      • billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]/config

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 1418

def get_insight_type_config request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::GetInsightTypeConfigRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_insight_type_config..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_insight_type_config.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_insight_type_config.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :get_insight_type_config, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_recommendation(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation #get_recommendation(name: nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

Gets the requested recommendation. Requires the recommender.*.get IAM permission for the specified recommender.

Examples:

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

Overloads:

  • #get_recommendation(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

    Pass arguments to get_recommendation via a request object, either of type GetRecommendationRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_recommendation(name: nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

    Pass arguments to 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).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Name of the recommendation.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 735

def get_recommendation request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::GetRecommendationRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_recommendation..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_recommendation.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_recommendation.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :get_recommendation, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_recommender_config(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::RecommenderConfig #get_recommender_config(name: nil) ⇒ ::Google::Cloud::Recommender::V1::RecommenderConfig

Gets the requested Recommender Config. There is only one instance of the config for each Recommender.

Examples:

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::GetRecommenderConfigRequest.new

# Call the get_recommender_config method.
result = client.get_recommender_config request

# The returned object is of type Google::Cloud::Recommender::V1::RecommenderConfig.
p result

Overloads:

  • #get_recommender_config(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::RecommenderConfig

    Pass arguments to get_recommender_config via a request object, either of type GetRecommenderConfigRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Recommender::V1::GetRecommenderConfigRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_recommender_config(name: nil) ⇒ ::Google::Cloud::Recommender::V1::RecommenderConfig

    Pass arguments to get_recommender_config 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).

    Parameters:

    • name (::String) (defaults to: nil)

      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

      • billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 1231

def get_recommender_config request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::GetRecommenderConfigRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_recommender_config..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_recommender_config.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_recommender_config.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :get_recommender_config, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_insights(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Insight> #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.

Examples:

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 elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Recommender::V1::Insight.
  p item
end

Overloads:

  • #list_insights(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Insight>

    Pass arguments to list_insights via a request object, either of type ListInsightsRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_insights(parent: nil, page_size: nil, page_token: nil, filter: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Insight>

    Pass arguments to 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).

    Parameters:

    • parent (::String) (defaults to: nil)

      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) (defaults to: nil)

      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) (defaults to: nil)

      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.

    • filter (::String) (defaults to: nil)

      Optional. Filter expression to restrict the insights returned. Supported filter fields:

      • stateInfo.state

      • insightSubtype

      • severity

      • targetResources

      Examples:

      • stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED

      • insightSubtype = PERMISSIONS_USAGE

      • severity = CRITICAL OR severity = HIGH

      • targetResources : //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1

      • stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)

      The max allowed filter length is 500 characters.

      (These expressions are based on the filter language described at https://google.aip.dev/160)

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 320

def list_insights request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::ListInsightsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_insights..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_insights.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_insights.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :list_insights, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @recommender_stub, :list_insights, request, response, operation, options
    yield response, operation if block_given?
    throw :response, response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_recommendations(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Recommendation> #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.

Examples:

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 elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::Recommender::V1::Recommendation.
  p item
end

Overloads:

  • #list_recommendations(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Recommendation>

    Pass arguments to list_recommendations via a request object, either of type ListRecommendationsRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_recommendations(parent: nil, page_size: nil, page_token: nil, filter: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Recommender::V1::Recommendation>

    Pass arguments to 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).

    Parameters:

    • parent (::String) (defaults to: nil)

      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) (defaults to: nil)

      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) (defaults to: nil)

      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.

    • filter (::String) (defaults to: nil)

      Filter expression to restrict the recommendations returned. Supported filter fields:

      • state_info.state

      • recommenderSubtype

      • priority

      • targetResources

      Examples:

      • stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED

      • recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE

      • priority = P1 OR priority = P2

      • targetResources : //compute.googleapis.com/projects/1234/zones/us-central1-a/instances/instance-1

      • stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)

      The max allowed filter length is 500 characters.

      (These expressions are based on the filter language described at https://google.aip.dev/160)

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 647

def list_recommendations request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::ListRecommendationsRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_recommendations..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_recommendations.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_recommendations.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :list_recommendations, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @recommender_stub, :list_recommendations, request, response, operation, options
    yield response, operation if block_given?
    throw :response, response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#loggerLogger

The logger used for request/response debug logging.

Returns:

  • (Logger)


211
212
213
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 211

def logger
  @recommender_stub.logger
end

#mark_insight_accepted(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Insight #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.

Examples:

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

Overloads:

  • #mark_insight_accepted(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Insight

    Pass arguments to mark_insight_accepted via a request object, either of type MarkInsightAcceptedRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #mark_insight_accepted(name: nil, state_metadata: nil, etag: nil) ⇒ ::Google::Cloud::Recommender::V1::Insight

    Pass arguments to 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).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Name of the insight.

    • state_metadata (::Hash{::String => ::String}) (defaults to: nil)

      Optional. State properties user wish to include with this state. Full replace of the current state_metadata.

    • etag (::String) (defaults to: nil)

      Required. Fingerprint of the Insight. Provides optimistic locking.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 503

def mark_insight_accepted request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::MarkInsightAcceptedRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.mark_insight_accepted..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.mark_insight_accepted.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.mark_insight_accepted.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :mark_insight_accepted, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#mark_recommendation_claimed(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation #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.

Examples:

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

Overloads:

  • #mark_recommendation_claimed(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

    Pass arguments to mark_recommendation_claimed via a request object, either of type MarkRecommendationClaimedRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #mark_recommendation_claimed(name: nil, state_metadata: nil, etag: nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

    Pass arguments to 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).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Name of the recommendation.

    • state_metadata (::Hash{::String => ::String}) (defaults to: nil)

      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) (defaults to: nil)

      Required. Fingerprint of the Recommendation. Provides optimistic locking.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 931

def mark_recommendation_claimed request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::MarkRecommendationClaimedRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.mark_recommendation_claimed..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.mark_recommendation_claimed.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.mark_recommendation_claimed.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :mark_recommendation_claimed, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#mark_recommendation_dismissed(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation #mark_recommendation_dismissed(name: nil, etag: nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

Mark the Recommendation State as Dismissed. Users can use this method to indicate to the Recommender API that an ACTIVE recommendation has to be marked back as DISMISSED.

MarkRecommendationDismissed can be applied to recommendations in ACTIVE state.

Requires the recommender.*.update IAM permission for the specified recommender.

Examples:

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::MarkRecommendationDismissedRequest.new

# Call the mark_recommendation_dismissed method.
result = client.mark_recommendation_dismissed request

# The returned object is of type Google::Cloud::Recommender::V1::Recommendation.
p result

Overloads:

  • #mark_recommendation_dismissed(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

    Pass arguments to mark_recommendation_dismissed via a request object, either of type MarkRecommendationDismissedRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Recommender::V1::MarkRecommendationDismissedRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #mark_recommendation_dismissed(name: nil, etag: nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

    Pass arguments to mark_recommendation_dismissed 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).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Name of the recommendation.

    • etag (::String) (defaults to: nil)

      Fingerprint of the Recommendation. Provides optimistic locking.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 830

def mark_recommendation_dismissed request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::MarkRecommendationDismissedRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.mark_recommendation_dismissed..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.mark_recommendation_dismissed.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.mark_recommendation_dismissed.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :mark_recommendation_dismissed, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#mark_recommendation_failed(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation #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.

Examples:

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

Overloads:

  • #mark_recommendation_failed(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

    Pass arguments to mark_recommendation_failed via a request object, either of type MarkRecommendationFailedRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #mark_recommendation_failed(name: nil, state_metadata: nil, etag: nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

    Pass arguments to 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).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Name of the recommendation.

    • state_metadata (::Hash{::String => ::String}) (defaults to: nil)

      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) (defaults to: nil)

      Required. Fingerprint of the Recommendation. Provides optimistic locking.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 1135

def mark_recommendation_failed request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::MarkRecommendationFailedRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.mark_recommendation_failed..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.mark_recommendation_failed.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.mark_recommendation_failed.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :mark_recommendation_failed, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#mark_recommendation_succeeded(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation #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.

Examples:

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

Overloads:

  • #mark_recommendation_succeeded(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

    Pass arguments to mark_recommendation_succeeded via a request object, either of type MarkRecommendationSucceededRequest or an equivalent Hash.

    Parameters:

    • 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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #mark_recommendation_succeeded(name: nil, state_metadata: nil, etag: nil) ⇒ ::Google::Cloud::Recommender::V1::Recommendation

    Pass arguments to 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).

    Parameters:

    • name (::String) (defaults to: nil)

      Required. Name of the recommendation.

    • state_metadata (::Hash{::String => ::String}) (defaults to: nil)

      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) (defaults to: nil)

      Required. Fingerprint of the Recommendation. Provides optimistic locking.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 1033

def mark_recommendation_succeeded request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::MarkRecommendationSucceededRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.mark_recommendation_succeeded..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.mark_recommendation_succeeded.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.mark_recommendation_succeeded.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :mark_recommendation_succeeded, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


135
136
137
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 135

def universe_domain
  @recommender_stub.universe_domain
end

#update_insight_type_config(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::InsightTypeConfig #update_insight_type_config(insight_type_config: nil, update_mask: nil, validate_only: nil) ⇒ ::Google::Cloud::Recommender::V1::InsightTypeConfig

Updates an InsightTypeConfig change. This will create a new revision of the config.

Examples:

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::UpdateInsightTypeConfigRequest.new

# Call the update_insight_type_config method.
result = client.update_insight_type_config request

# The returned object is of type Google::Cloud::Recommender::V1::InsightTypeConfig.
p result

Overloads:

  • #update_insight_type_config(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::InsightTypeConfig

    Pass arguments to update_insight_type_config via a request object, either of type UpdateInsightTypeConfigRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Recommender::V1::UpdateInsightTypeConfigRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_insight_type_config(insight_type_config: nil, update_mask: nil, validate_only: nil) ⇒ ::Google::Cloud::Recommender::V1::InsightTypeConfig

    Pass arguments to update_insight_type_config 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).

    Parameters:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 1509

def update_insight_type_config request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::UpdateInsightTypeConfigRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_insight_type_config..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.insight_type_config&.name
    header_params["insight_type_config.name"] = request.insight_type_config.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_insight_type_config.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_insight_type_config.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :update_insight_type_config, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#update_recommender_config(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::RecommenderConfig #update_recommender_config(recommender_config: nil, update_mask: nil, validate_only: nil) ⇒ ::Google::Cloud::Recommender::V1::RecommenderConfig

Updates a Recommender Config. This will create a new revision of the config.

Examples:

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::UpdateRecommenderConfigRequest.new

# Call the update_recommender_config method.
result = client.update_recommender_config request

# The returned object is of type Google::Cloud::Recommender::V1::RecommenderConfig.
p result

Overloads:

  • #update_recommender_config(request, options = nil) ⇒ ::Google::Cloud::Recommender::V1::RecommenderConfig

    Pass arguments to update_recommender_config via a request object, either of type UpdateRecommenderConfigRequest or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::Recommender::V1::UpdateRecommenderConfigRequest, ::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) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #update_recommender_config(recommender_config: nil, update_mask: nil, validate_only: nil) ⇒ ::Google::Cloud::Recommender::V1::RecommenderConfig

    Pass arguments to update_recommender_config 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).

    Parameters:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
# File 'lib/google/cloud/recommender/v1/recommender/client.rb', line 1322

def update_recommender_config request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::UpdateRecommenderConfigRequest

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_recommender_config..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::Recommender::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.recommender_config&.name
    header_params["recommender_config.name"] = request.recommender_config.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_recommender_config.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_recommender_config.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @recommender_stub.call_rpc :update_recommender_config, request, options: options do |response, operation|
    yield response, operation if block_given?
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end