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

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

Overview

REST 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 REST client object.

Examples:


# Create a client using the default configuration
client = ::Google::Cloud::Recommender::V1::Recommender::Rest::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::Recommender::V1::Recommender::Rest::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Recommender client.

Yield Parameters:



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
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 157

def initialize
  # 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 = ::Google::Cloud::Recommender::V1::Recommender::Rest::ServiceStub.new(
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    credentials: credentials
  )
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::Rest::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



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
109
110
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 67

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:



127
128
129
130
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 127

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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 373

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.get_insight request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call 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
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 1322

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.get_insight_type_config request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 681

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.get_recommendation request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



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
1175
1176
1177
1178
1179
1180
1181
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 1147

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.get_recommender_config request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

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

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 292

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.list_insights request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @recommender_stub, :list_insights, "insights", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

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

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 600

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.list_recommendations request, options do |result, operation|
    result = ::Gapic::Rest::PagedEnumerable.new @recommender_stub, :list_recommendations, "recommendations", request, result, options
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 462

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.mark_insight_accepted request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 865

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.mark_recommendation_claimed request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 770

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.mark_recommendation_dismissed request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 1057

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.mark_recommendation_failed request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 961

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.mark_recommendation_succeeded request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


137
138
139
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 137

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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 1407

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.update_insight_type_config request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => 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::Rest::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:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

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

    if the REST call is aborted.



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
# File 'lib/google/cloud/recommender/v1/recommender/rest/client.rb', line 1232

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,
    transports_version_send: [:rest]

  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  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.update_recommender_config request, options do |result, operation|
    yield result, operation if block_given?
    return result
  end
rescue ::Gapic::Rest::Error => e
  raise ::Google::Cloud::Error.from_error(e)
end