google-cloud-recommender-v1 0.11.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1324 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/recommender/v1/recommender_service_pb"
21
+ require "google/cloud/recommender/v1/recommender/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Recommender
26
+ module V1
27
+ module Recommender
28
+ module Rest
29
+ ##
30
+ # REST client for the Recommender service.
31
+ #
32
+ # Provides insights and recommendations for cloud customers for various
33
+ # categories like performance optimization, cost savings, reliability, feature
34
+ # discovery, etc. Insights and recommendations are generated automatically
35
+ # based on analysis of user resources, configuration and monitoring metrics.
36
+ #
37
+ class Client
38
+ include Paths
39
+
40
+ # @private
41
+ attr_reader :recommender_stub
42
+
43
+ ##
44
+ # Configure the Recommender Client class.
45
+ #
46
+ # See {::Google::Cloud::Recommender::V1::Recommender::Rest::Client::Configuration}
47
+ # for a description of the configuration fields.
48
+ #
49
+ # @example
50
+ #
51
+ # # Modify the configuration for all Recommender clients
52
+ # ::Google::Cloud::Recommender::V1::Recommender::Rest::Client.configure do |config|
53
+ # config.timeout = 10.0
54
+ # end
55
+ #
56
+ # @yield [config] Configure the Client client.
57
+ # @yieldparam config [Client::Configuration]
58
+ #
59
+ # @return [Client::Configuration]
60
+ #
61
+ def self.configure
62
+ @configure ||= begin
63
+ namespace = ["Google", "Cloud", "Recommender", "V1"]
64
+ parent_config = while namespace.any?
65
+ parent_name = namespace.join "::"
66
+ parent_const = const_get parent_name
67
+ break parent_const.configure if parent_const.respond_to? :configure
68
+ namespace.pop
69
+ end
70
+ default_config = Client::Configuration.new parent_config
71
+
72
+ default_config.rpcs.list_insights.timeout = 60.0
73
+ default_config.rpcs.list_insights.retry_policy = {
74
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
75
+ }
76
+
77
+ default_config.rpcs.get_insight.timeout = 60.0
78
+ default_config.rpcs.get_insight.retry_policy = {
79
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
80
+ }
81
+
82
+ default_config.rpcs.mark_insight_accepted.timeout = 60.0
83
+
84
+ default_config.rpcs.list_recommendations.timeout = 60.0
85
+ default_config.rpcs.list_recommendations.retry_policy = {
86
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
87
+ }
88
+
89
+ default_config.rpcs.get_recommendation.timeout = 60.0
90
+ default_config.rpcs.get_recommendation.retry_policy = {
91
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
92
+ }
93
+
94
+ default_config.rpcs.mark_recommendation_claimed.timeout = 60.0
95
+
96
+ default_config.rpcs.mark_recommendation_succeeded.timeout = 60.0
97
+
98
+ default_config.rpcs.mark_recommendation_failed.timeout = 60.0
99
+
100
+ default_config
101
+ end
102
+ yield @configure if block_given?
103
+ @configure
104
+ end
105
+
106
+ ##
107
+ # Configure the Recommender Client instance.
108
+ #
109
+ # The configuration is set to the derived mode, meaning that values can be changed,
110
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
111
+ # should be made on {Client.configure}.
112
+ #
113
+ # See {::Google::Cloud::Recommender::V1::Recommender::Rest::Client::Configuration}
114
+ # for a description of the configuration fields.
115
+ #
116
+ # @yield [config] Configure the Client client.
117
+ # @yieldparam config [Client::Configuration]
118
+ #
119
+ # @return [Client::Configuration]
120
+ #
121
+ def configure
122
+ yield @config if block_given?
123
+ @config
124
+ end
125
+
126
+ ##
127
+ # Create a new Recommender REST client object.
128
+ #
129
+ # @example
130
+ #
131
+ # # Create a client using the default configuration
132
+ # client = ::Google::Cloud::Recommender::V1::Recommender::Rest::Client.new
133
+ #
134
+ # # Create a client using a custom configuration
135
+ # client = ::Google::Cloud::Recommender::V1::Recommender::Rest::Client.new do |config|
136
+ # config.timeout = 10.0
137
+ # end
138
+ #
139
+ # @yield [config] Configure the Recommender client.
140
+ # @yieldparam config [Client::Configuration]
141
+ #
142
+ def initialize
143
+ # Create the configuration object
144
+ @config = Configuration.new Client.configure
145
+
146
+ # Yield the configuration if needed
147
+ yield @config if block_given?
148
+
149
+ # Create credentials
150
+ credentials = @config.credentials
151
+ # Use self-signed JWT if the endpoint is unchanged from default,
152
+ # but only if the default endpoint does not have a region prefix.
153
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
154
+ !@config.endpoint.split(".").first.include?("-")
155
+ credentials ||= Credentials.default scope: @config.scope,
156
+ enable_self_signed_jwt: enable_self_signed_jwt
157
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
158
+ credentials = Credentials.new credentials, scope: @config.scope
159
+ end
160
+
161
+ @quota_project_id = @config.quota_project
162
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
163
+
164
+ @recommender_stub = ::Google::Cloud::Recommender::V1::Recommender::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
165
+ end
166
+
167
+ # Service calls
168
+
169
+ ##
170
+ # Lists insights for the specified Cloud Resource. Requires the
171
+ # recommender.*.list IAM permission for the specified insight type.
172
+ #
173
+ # @overload list_insights(request, options = nil)
174
+ # Pass arguments to `list_insights` via a request object, either of type
175
+ # {::Google::Cloud::Recommender::V1::ListInsightsRequest} or an equivalent Hash.
176
+ #
177
+ # @param request [::Google::Cloud::Recommender::V1::ListInsightsRequest, ::Hash]
178
+ # A request object representing the call parameters. Required. To specify no
179
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
180
+ # @param options [::Gapic::CallOptions, ::Hash]
181
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
182
+ #
183
+ # @overload list_insights(parent: nil, page_size: nil, page_token: nil, filter: nil)
184
+ # Pass arguments to `list_insights` via keyword arguments. Note that at
185
+ # least one keyword argument is required. To specify no parameters, or to keep all
186
+ # the default parameter values, pass an empty Hash as a request object (see above).
187
+ #
188
+ # @param parent [::String]
189
+ # Required. The container resource on which to execute the request.
190
+ # Acceptable formats:
191
+ #
192
+ # * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]`
193
+ #
194
+ # * `projects/[PROJECT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]`
195
+ #
196
+ # * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]`
197
+ #
198
+ # * `folders/[FOLDER_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]`
199
+ #
200
+ # * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/insightTypes/[INSIGHT_TYPE_ID]`
201
+ #
202
+ # LOCATION here refers to GCP Locations:
203
+ # https://cloud.google.com/about/locations/
204
+ # INSIGHT_TYPE_ID refers to supported insight types:
205
+ # https://cloud.google.com/recommender/docs/insights/insight-types.
206
+ # @param page_size [::Integer]
207
+ # Optional. The maximum number of results to return from this request.
208
+ # Non-positive values are ignored. If not specified, the server will
209
+ # determine the number of results to return.
210
+ # @param page_token [::String]
211
+ # Optional. If present, retrieves the next batch of results from the
212
+ # preceding call to this method. `page_token` must be the value of
213
+ # `next_page_token` from the previous response. The values of other method
214
+ # parameters must be identical to those in the previous call.
215
+ # @param filter [::String]
216
+ # Optional. Filter expression to restrict the insights returned. Supported
217
+ # filter fields:
218
+ #
219
+ # * `stateInfo.state`
220
+ #
221
+ # * `insightSubtype`
222
+ #
223
+ # * `severity`
224
+ #
225
+ # Examples:
226
+ #
227
+ # * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED`
228
+ #
229
+ # * `insightSubtype = PERMISSIONS_USAGE`
230
+ #
231
+ # * `severity = CRITICAL OR severity = HIGH`
232
+ #
233
+ # * `stateInfo.state = ACTIVE AND (severity = CRITICAL OR severity = HIGH)`
234
+ #
235
+ # (These expressions are based on the filter language described at
236
+ # https://google.aip.dev/160)
237
+ # @yield [result, operation] Access the result along with the TransportOperation object
238
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Recommender::V1::Insight>]
239
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
240
+ #
241
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Recommender::V1::Insight>]
242
+ #
243
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
244
+ def list_insights request, options = nil
245
+ raise ::ArgumentError, "request must be provided" if request.nil?
246
+
247
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::ListInsightsRequest
248
+
249
+ # Converts hash and nil to an options object
250
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
251
+
252
+ # Customize the options with defaults
253
+ call_metadata = @config.rpcs.list_insights.metadata.to_h
254
+
255
+ # Set x-goog-api-client and x-goog-user-project headers
256
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
257
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
258
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
259
+ transports_version_send: [:rest]
260
+
261
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
262
+
263
+ options.apply_defaults timeout: @config.rpcs.list_insights.timeout,
264
+ metadata: call_metadata,
265
+ retry_policy: @config.rpcs.list_insights.retry_policy
266
+
267
+ options.apply_defaults timeout: @config.timeout,
268
+ metadata: @config.metadata,
269
+ retry_policy: @config.retry_policy
270
+
271
+ @recommender_stub.list_insights request, options do |result, operation|
272
+ result = ::Gapic::Rest::PagedEnumerable.new @recommender_stub, :list_insights, "insights", request, result, options
273
+ yield result, operation if block_given?
274
+ return result
275
+ end
276
+ rescue ::Gapic::Rest::Error => e
277
+ raise ::Google::Cloud::Error.from_error(e)
278
+ end
279
+
280
+ ##
281
+ # Gets the requested insight. Requires the recommender.*.get IAM permission
282
+ # for the specified insight type.
283
+ #
284
+ # @overload get_insight(request, options = nil)
285
+ # Pass arguments to `get_insight` via a request object, either of type
286
+ # {::Google::Cloud::Recommender::V1::GetInsightRequest} or an equivalent Hash.
287
+ #
288
+ # @param request [::Google::Cloud::Recommender::V1::GetInsightRequest, ::Hash]
289
+ # A request object representing the call parameters. Required. To specify no
290
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
291
+ # @param options [::Gapic::CallOptions, ::Hash]
292
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
293
+ #
294
+ # @overload get_insight(name: nil)
295
+ # Pass arguments to `get_insight` via keyword arguments. Note that at
296
+ # least one keyword argument is required. To specify no parameters, or to keep all
297
+ # the default parameter values, pass an empty Hash as a request object (see above).
298
+ #
299
+ # @param name [::String]
300
+ # Required. Name of the insight.
301
+ # @yield [result, operation] Access the result along with the TransportOperation object
302
+ # @yieldparam result [::Google::Cloud::Recommender::V1::Insight]
303
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
304
+ #
305
+ # @return [::Google::Cloud::Recommender::V1::Insight]
306
+ #
307
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
308
+ def get_insight request, options = nil
309
+ raise ::ArgumentError, "request must be provided" if request.nil?
310
+
311
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::GetInsightRequest
312
+
313
+ # Converts hash and nil to an options object
314
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
315
+
316
+ # Customize the options with defaults
317
+ call_metadata = @config.rpcs.get_insight.metadata.to_h
318
+
319
+ # Set x-goog-api-client and x-goog-user-project headers
320
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
321
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
322
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
323
+ transports_version_send: [:rest]
324
+
325
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
326
+
327
+ options.apply_defaults timeout: @config.rpcs.get_insight.timeout,
328
+ metadata: call_metadata,
329
+ retry_policy: @config.rpcs.get_insight.retry_policy
330
+
331
+ options.apply_defaults timeout: @config.timeout,
332
+ metadata: @config.metadata,
333
+ retry_policy: @config.retry_policy
334
+
335
+ @recommender_stub.get_insight request, options do |result, operation|
336
+ yield result, operation if block_given?
337
+ return result
338
+ end
339
+ rescue ::Gapic::Rest::Error => e
340
+ raise ::Google::Cloud::Error.from_error(e)
341
+ end
342
+
343
+ ##
344
+ # Marks the Insight State as Accepted. Users can use this method to
345
+ # indicate to the Recommender API that they have applied some action based
346
+ # on the insight. This stops the insight content from being updated.
347
+ #
348
+ # MarkInsightAccepted can be applied to insights in ACTIVE state. Requires
349
+ # the recommender.*.update IAM permission for the specified insight.
350
+ #
351
+ # @overload mark_insight_accepted(request, options = nil)
352
+ # Pass arguments to `mark_insight_accepted` via a request object, either of type
353
+ # {::Google::Cloud::Recommender::V1::MarkInsightAcceptedRequest} or an equivalent Hash.
354
+ #
355
+ # @param request [::Google::Cloud::Recommender::V1::MarkInsightAcceptedRequest, ::Hash]
356
+ # A request object representing the call parameters. Required. To specify no
357
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
358
+ # @param options [::Gapic::CallOptions, ::Hash]
359
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
360
+ #
361
+ # @overload mark_insight_accepted(name: nil, state_metadata: nil, etag: nil)
362
+ # Pass arguments to `mark_insight_accepted` via keyword arguments. Note that at
363
+ # least one keyword argument is required. To specify no parameters, or to keep all
364
+ # the default parameter values, pass an empty Hash as a request object (see above).
365
+ #
366
+ # @param name [::String]
367
+ # Required. Name of the insight.
368
+ # @param state_metadata [::Hash{::String => ::String}]
369
+ # Optional. State properties user wish to include with this state. Full
370
+ # replace of the current state_metadata.
371
+ # @param etag [::String]
372
+ # Required. Fingerprint of the Insight. Provides optimistic locking.
373
+ # @yield [result, operation] Access the result along with the TransportOperation object
374
+ # @yieldparam result [::Google::Cloud::Recommender::V1::Insight]
375
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
376
+ #
377
+ # @return [::Google::Cloud::Recommender::V1::Insight]
378
+ #
379
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
380
+ def mark_insight_accepted request, options = nil
381
+ raise ::ArgumentError, "request must be provided" if request.nil?
382
+
383
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::MarkInsightAcceptedRequest
384
+
385
+ # Converts hash and nil to an options object
386
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
387
+
388
+ # Customize the options with defaults
389
+ call_metadata = @config.rpcs.mark_insight_accepted.metadata.to_h
390
+
391
+ # Set x-goog-api-client and x-goog-user-project headers
392
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
393
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
394
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
395
+ transports_version_send: [:rest]
396
+
397
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
398
+
399
+ options.apply_defaults timeout: @config.rpcs.mark_insight_accepted.timeout,
400
+ metadata: call_metadata,
401
+ retry_policy: @config.rpcs.mark_insight_accepted.retry_policy
402
+
403
+ options.apply_defaults timeout: @config.timeout,
404
+ metadata: @config.metadata,
405
+ retry_policy: @config.retry_policy
406
+
407
+ @recommender_stub.mark_insight_accepted request, options do |result, operation|
408
+ yield result, operation if block_given?
409
+ return result
410
+ end
411
+ rescue ::Gapic::Rest::Error => e
412
+ raise ::Google::Cloud::Error.from_error(e)
413
+ end
414
+
415
+ ##
416
+ # Lists recommendations for the specified Cloud Resource. Requires the
417
+ # recommender.*.list IAM permission for the specified recommender.
418
+ #
419
+ # @overload list_recommendations(request, options = nil)
420
+ # Pass arguments to `list_recommendations` via a request object, either of type
421
+ # {::Google::Cloud::Recommender::V1::ListRecommendationsRequest} or an equivalent Hash.
422
+ #
423
+ # @param request [::Google::Cloud::Recommender::V1::ListRecommendationsRequest, ::Hash]
424
+ # A request object representing the call parameters. Required. To specify no
425
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
426
+ # @param options [::Gapic::CallOptions, ::Hash]
427
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
428
+ #
429
+ # @overload list_recommendations(parent: nil, page_size: nil, page_token: nil, filter: nil)
430
+ # Pass arguments to `list_recommendations` via keyword arguments. Note that at
431
+ # least one keyword argument is required. To specify no parameters, or to keep all
432
+ # the default parameter values, pass an empty Hash as a request object (see above).
433
+ #
434
+ # @param parent [::String]
435
+ # Required. The container resource on which to execute the request.
436
+ # Acceptable formats:
437
+ #
438
+ # * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]`
439
+ #
440
+ # * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]`
441
+ #
442
+ # * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]`
443
+ #
444
+ # * `folders/[FOLDER_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]`
445
+ #
446
+ # * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]`
447
+ #
448
+ # LOCATION here refers to GCP Locations:
449
+ # https://cloud.google.com/about/locations/
450
+ # RECOMMENDER_ID refers to supported recommenders:
451
+ # https://cloud.google.com/recommender/docs/recommenders.
452
+ # @param page_size [::Integer]
453
+ # Optional. The maximum number of results to return from this request.
454
+ # Non-positive values are ignored. If not specified, the server will
455
+ # determine the number of results to return.
456
+ # @param page_token [::String]
457
+ # Optional. If present, retrieves the next batch of results from the
458
+ # preceding call to this method. `page_token` must be the value of
459
+ # `next_page_token` from the previous response. The values of other method
460
+ # parameters must be identical to those in the previous call.
461
+ # @param filter [::String]
462
+ # Filter expression to restrict the recommendations returned. Supported
463
+ # filter fields:
464
+ #
465
+ # * `state_info.state`
466
+ #
467
+ # * `recommenderSubtype`
468
+ #
469
+ # * `priority`
470
+ #
471
+ # Examples:
472
+ #
473
+ # * `stateInfo.state = ACTIVE OR stateInfo.state = DISMISSED`
474
+ #
475
+ # * `recommenderSubtype = REMOVE_ROLE OR recommenderSubtype = REPLACE_ROLE`
476
+ #
477
+ # * `priority = P1 OR priority = P2`
478
+ #
479
+ # * `stateInfo.state = ACTIVE AND (priority = P1 OR priority = P2)`
480
+ #
481
+ # (These expressions are based on the filter language described at
482
+ # https://google.aip.dev/160)
483
+ # @yield [result, operation] Access the result along with the TransportOperation object
484
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Recommender::V1::Recommendation>]
485
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
486
+ #
487
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Recommender::V1::Recommendation>]
488
+ #
489
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
490
+ def list_recommendations request, options = nil
491
+ raise ::ArgumentError, "request must be provided" if request.nil?
492
+
493
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::ListRecommendationsRequest
494
+
495
+ # Converts hash and nil to an options object
496
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
497
+
498
+ # Customize the options with defaults
499
+ call_metadata = @config.rpcs.list_recommendations.metadata.to_h
500
+
501
+ # Set x-goog-api-client and x-goog-user-project headers
502
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
503
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
504
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
505
+ transports_version_send: [:rest]
506
+
507
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
508
+
509
+ options.apply_defaults timeout: @config.rpcs.list_recommendations.timeout,
510
+ metadata: call_metadata,
511
+ retry_policy: @config.rpcs.list_recommendations.retry_policy
512
+
513
+ options.apply_defaults timeout: @config.timeout,
514
+ metadata: @config.metadata,
515
+ retry_policy: @config.retry_policy
516
+
517
+ @recommender_stub.list_recommendations request, options do |result, operation|
518
+ result = ::Gapic::Rest::PagedEnumerable.new @recommender_stub, :list_recommendations, "recommendations", request, result, options
519
+ yield result, operation if block_given?
520
+ return result
521
+ end
522
+ rescue ::Gapic::Rest::Error => e
523
+ raise ::Google::Cloud::Error.from_error(e)
524
+ end
525
+
526
+ ##
527
+ # Gets the requested recommendation. Requires the recommender.*.get
528
+ # IAM permission for the specified recommender.
529
+ #
530
+ # @overload get_recommendation(request, options = nil)
531
+ # Pass arguments to `get_recommendation` via a request object, either of type
532
+ # {::Google::Cloud::Recommender::V1::GetRecommendationRequest} or an equivalent Hash.
533
+ #
534
+ # @param request [::Google::Cloud::Recommender::V1::GetRecommendationRequest, ::Hash]
535
+ # A request object representing the call parameters. Required. To specify no
536
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
537
+ # @param options [::Gapic::CallOptions, ::Hash]
538
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
539
+ #
540
+ # @overload get_recommendation(name: nil)
541
+ # Pass arguments to `get_recommendation` via keyword arguments. Note that at
542
+ # least one keyword argument is required. To specify no parameters, or to keep all
543
+ # the default parameter values, pass an empty Hash as a request object (see above).
544
+ #
545
+ # @param name [::String]
546
+ # Required. Name of the recommendation.
547
+ # @yield [result, operation] Access the result along with the TransportOperation object
548
+ # @yieldparam result [::Google::Cloud::Recommender::V1::Recommendation]
549
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
550
+ #
551
+ # @return [::Google::Cloud::Recommender::V1::Recommendation]
552
+ #
553
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
554
+ def get_recommendation request, options = nil
555
+ raise ::ArgumentError, "request must be provided" if request.nil?
556
+
557
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::GetRecommendationRequest
558
+
559
+ # Converts hash and nil to an options object
560
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
561
+
562
+ # Customize the options with defaults
563
+ call_metadata = @config.rpcs.get_recommendation.metadata.to_h
564
+
565
+ # Set x-goog-api-client and x-goog-user-project headers
566
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
567
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
568
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
569
+ transports_version_send: [:rest]
570
+
571
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
572
+
573
+ options.apply_defaults timeout: @config.rpcs.get_recommendation.timeout,
574
+ metadata: call_metadata,
575
+ retry_policy: @config.rpcs.get_recommendation.retry_policy
576
+
577
+ options.apply_defaults timeout: @config.timeout,
578
+ metadata: @config.metadata,
579
+ retry_policy: @config.retry_policy
580
+
581
+ @recommender_stub.get_recommendation request, options do |result, operation|
582
+ yield result, operation if block_given?
583
+ return result
584
+ end
585
+ rescue ::Gapic::Rest::Error => e
586
+ raise ::Google::Cloud::Error.from_error(e)
587
+ end
588
+
589
+ ##
590
+ # Marks the Recommendation State as Claimed. Users can use this method to
591
+ # indicate to the Recommender API that they are starting to apply the
592
+ # recommendation themselves. This stops the recommendation content from being
593
+ # updated. Associated insights are frozen and placed in the ACCEPTED state.
594
+ #
595
+ # MarkRecommendationClaimed can be applied to recommendations in CLAIMED,
596
+ # SUCCEEDED, FAILED, or ACTIVE state.
597
+ #
598
+ # Requires the recommender.*.update IAM permission for the specified
599
+ # recommender.
600
+ #
601
+ # @overload mark_recommendation_claimed(request, options = nil)
602
+ # Pass arguments to `mark_recommendation_claimed` via a request object, either of type
603
+ # {::Google::Cloud::Recommender::V1::MarkRecommendationClaimedRequest} or an equivalent Hash.
604
+ #
605
+ # @param request [::Google::Cloud::Recommender::V1::MarkRecommendationClaimedRequest, ::Hash]
606
+ # A request object representing the call parameters. Required. To specify no
607
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
608
+ # @param options [::Gapic::CallOptions, ::Hash]
609
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
610
+ #
611
+ # @overload mark_recommendation_claimed(name: nil, state_metadata: nil, etag: nil)
612
+ # Pass arguments to `mark_recommendation_claimed` via keyword arguments. Note that at
613
+ # least one keyword argument is required. To specify no parameters, or to keep all
614
+ # the default parameter values, pass an empty Hash as a request object (see above).
615
+ #
616
+ # @param name [::String]
617
+ # Required. Name of the recommendation.
618
+ # @param state_metadata [::Hash{::String => ::String}]
619
+ # State properties to include with this state. Overwrites any existing
620
+ # `state_metadata`.
621
+ # Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`.
622
+ # Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`.
623
+ # @param etag [::String]
624
+ # Required. Fingerprint of the Recommendation. Provides optimistic locking.
625
+ # @yield [result, operation] Access the result along with the TransportOperation object
626
+ # @yieldparam result [::Google::Cloud::Recommender::V1::Recommendation]
627
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
628
+ #
629
+ # @return [::Google::Cloud::Recommender::V1::Recommendation]
630
+ #
631
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
632
+ def mark_recommendation_claimed request, options = nil
633
+ raise ::ArgumentError, "request must be provided" if request.nil?
634
+
635
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::MarkRecommendationClaimedRequest
636
+
637
+ # Converts hash and nil to an options object
638
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
639
+
640
+ # Customize the options with defaults
641
+ call_metadata = @config.rpcs.mark_recommendation_claimed.metadata.to_h
642
+
643
+ # Set x-goog-api-client and x-goog-user-project headers
644
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
645
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
646
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
647
+ transports_version_send: [:rest]
648
+
649
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
650
+
651
+ options.apply_defaults timeout: @config.rpcs.mark_recommendation_claimed.timeout,
652
+ metadata: call_metadata,
653
+ retry_policy: @config.rpcs.mark_recommendation_claimed.retry_policy
654
+
655
+ options.apply_defaults timeout: @config.timeout,
656
+ metadata: @config.metadata,
657
+ retry_policy: @config.retry_policy
658
+
659
+ @recommender_stub.mark_recommendation_claimed request, options do |result, operation|
660
+ yield result, operation if block_given?
661
+ return result
662
+ end
663
+ rescue ::Gapic::Rest::Error => e
664
+ raise ::Google::Cloud::Error.from_error(e)
665
+ end
666
+
667
+ ##
668
+ # Marks the Recommendation State as Succeeded. Users can use this method to
669
+ # indicate to the Recommender API that they have applied the recommendation
670
+ # themselves, and the operation was successful. This stops the recommendation
671
+ # content from being updated. Associated insights are frozen and placed in
672
+ # the ACCEPTED state.
673
+ #
674
+ # MarkRecommendationSucceeded can be applied to recommendations in ACTIVE,
675
+ # CLAIMED, SUCCEEDED, or FAILED state.
676
+ #
677
+ # Requires the recommender.*.update IAM permission for the specified
678
+ # recommender.
679
+ #
680
+ # @overload mark_recommendation_succeeded(request, options = nil)
681
+ # Pass arguments to `mark_recommendation_succeeded` via a request object, either of type
682
+ # {::Google::Cloud::Recommender::V1::MarkRecommendationSucceededRequest} or an equivalent Hash.
683
+ #
684
+ # @param request [::Google::Cloud::Recommender::V1::MarkRecommendationSucceededRequest, ::Hash]
685
+ # A request object representing the call parameters. Required. To specify no
686
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
687
+ # @param options [::Gapic::CallOptions, ::Hash]
688
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
689
+ #
690
+ # @overload mark_recommendation_succeeded(name: nil, state_metadata: nil, etag: nil)
691
+ # Pass arguments to `mark_recommendation_succeeded` via keyword arguments. Note that at
692
+ # least one keyword argument is required. To specify no parameters, or to keep all
693
+ # the default parameter values, pass an empty Hash as a request object (see above).
694
+ #
695
+ # @param name [::String]
696
+ # Required. Name of the recommendation.
697
+ # @param state_metadata [::Hash{::String => ::String}]
698
+ # State properties to include with this state. Overwrites any existing
699
+ # `state_metadata`.
700
+ # Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`.
701
+ # Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`.
702
+ # @param etag [::String]
703
+ # Required. Fingerprint of the Recommendation. Provides optimistic locking.
704
+ # @yield [result, operation] Access the result along with the TransportOperation object
705
+ # @yieldparam result [::Google::Cloud::Recommender::V1::Recommendation]
706
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
707
+ #
708
+ # @return [::Google::Cloud::Recommender::V1::Recommendation]
709
+ #
710
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
711
+ def mark_recommendation_succeeded request, options = nil
712
+ raise ::ArgumentError, "request must be provided" if request.nil?
713
+
714
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::MarkRecommendationSucceededRequest
715
+
716
+ # Converts hash and nil to an options object
717
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
718
+
719
+ # Customize the options with defaults
720
+ call_metadata = @config.rpcs.mark_recommendation_succeeded.metadata.to_h
721
+
722
+ # Set x-goog-api-client and x-goog-user-project headers
723
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
724
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
725
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
726
+ transports_version_send: [:rest]
727
+
728
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
729
+
730
+ options.apply_defaults timeout: @config.rpcs.mark_recommendation_succeeded.timeout,
731
+ metadata: call_metadata,
732
+ retry_policy: @config.rpcs.mark_recommendation_succeeded.retry_policy
733
+
734
+ options.apply_defaults timeout: @config.timeout,
735
+ metadata: @config.metadata,
736
+ retry_policy: @config.retry_policy
737
+
738
+ @recommender_stub.mark_recommendation_succeeded request, options do |result, operation|
739
+ yield result, operation if block_given?
740
+ return result
741
+ end
742
+ rescue ::Gapic::Rest::Error => e
743
+ raise ::Google::Cloud::Error.from_error(e)
744
+ end
745
+
746
+ ##
747
+ # Marks the Recommendation State as Failed. Users can use this method to
748
+ # indicate to the Recommender API that they have applied the recommendation
749
+ # themselves, and the operation failed. This stops the recommendation content
750
+ # from being updated. Associated insights are frozen and placed in the
751
+ # ACCEPTED state.
752
+ #
753
+ # MarkRecommendationFailed can be applied to recommendations in ACTIVE,
754
+ # CLAIMED, SUCCEEDED, or FAILED state.
755
+ #
756
+ # Requires the recommender.*.update IAM permission for the specified
757
+ # recommender.
758
+ #
759
+ # @overload mark_recommendation_failed(request, options = nil)
760
+ # Pass arguments to `mark_recommendation_failed` via a request object, either of type
761
+ # {::Google::Cloud::Recommender::V1::MarkRecommendationFailedRequest} or an equivalent Hash.
762
+ #
763
+ # @param request [::Google::Cloud::Recommender::V1::MarkRecommendationFailedRequest, ::Hash]
764
+ # A request object representing the call parameters. Required. To specify no
765
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
766
+ # @param options [::Gapic::CallOptions, ::Hash]
767
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
768
+ #
769
+ # @overload mark_recommendation_failed(name: nil, state_metadata: nil, etag: nil)
770
+ # Pass arguments to `mark_recommendation_failed` via keyword arguments. Note that at
771
+ # least one keyword argument is required. To specify no parameters, or to keep all
772
+ # the default parameter values, pass an empty Hash as a request object (see above).
773
+ #
774
+ # @param name [::String]
775
+ # Required. Name of the recommendation.
776
+ # @param state_metadata [::Hash{::String => ::String}]
777
+ # State properties to include with this state. Overwrites any existing
778
+ # `state_metadata`.
779
+ # Keys must match the regex `/^[a-z0-9][a-z0-9_.-]{0,62}$/`.
780
+ # Values must match the regex `/^[a-zA-Z0-9_./-]{0,255}$/`.
781
+ # @param etag [::String]
782
+ # Required. Fingerprint of the Recommendation. Provides optimistic locking.
783
+ # @yield [result, operation] Access the result along with the TransportOperation object
784
+ # @yieldparam result [::Google::Cloud::Recommender::V1::Recommendation]
785
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
786
+ #
787
+ # @return [::Google::Cloud::Recommender::V1::Recommendation]
788
+ #
789
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
790
+ def mark_recommendation_failed request, options = nil
791
+ raise ::ArgumentError, "request must be provided" if request.nil?
792
+
793
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::MarkRecommendationFailedRequest
794
+
795
+ # Converts hash and nil to an options object
796
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
797
+
798
+ # Customize the options with defaults
799
+ call_metadata = @config.rpcs.mark_recommendation_failed.metadata.to_h
800
+
801
+ # Set x-goog-api-client and x-goog-user-project headers
802
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
803
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
804
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
805
+ transports_version_send: [:rest]
806
+
807
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
808
+
809
+ options.apply_defaults timeout: @config.rpcs.mark_recommendation_failed.timeout,
810
+ metadata: call_metadata,
811
+ retry_policy: @config.rpcs.mark_recommendation_failed.retry_policy
812
+
813
+ options.apply_defaults timeout: @config.timeout,
814
+ metadata: @config.metadata,
815
+ retry_policy: @config.retry_policy
816
+
817
+ @recommender_stub.mark_recommendation_failed request, options do |result, operation|
818
+ yield result, operation if block_given?
819
+ return result
820
+ end
821
+ rescue ::Gapic::Rest::Error => e
822
+ raise ::Google::Cloud::Error.from_error(e)
823
+ end
824
+
825
+ ##
826
+ # Gets the requested Recommender Config. There is only one instance of the
827
+ # config for each Recommender.
828
+ #
829
+ # @overload get_recommender_config(request, options = nil)
830
+ # Pass arguments to `get_recommender_config` via a request object, either of type
831
+ # {::Google::Cloud::Recommender::V1::GetRecommenderConfigRequest} or an equivalent Hash.
832
+ #
833
+ # @param request [::Google::Cloud::Recommender::V1::GetRecommenderConfigRequest, ::Hash]
834
+ # A request object representing the call parameters. Required. To specify no
835
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
836
+ # @param options [::Gapic::CallOptions, ::Hash]
837
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
838
+ #
839
+ # @overload get_recommender_config(name: nil)
840
+ # Pass arguments to `get_recommender_config` via keyword arguments. Note that at
841
+ # least one keyword argument is required. To specify no parameters, or to keep all
842
+ # the default parameter values, pass an empty Hash as a request object (see above).
843
+ #
844
+ # @param name [::String]
845
+ # Required. Name of the Recommendation Config to get.
846
+ #
847
+ # Acceptable formats:
848
+ #
849
+ # * `projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
850
+ #
851
+ # * `projects/[PROJECT_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
852
+ #
853
+ # * `organizations/[ORGANIZATION_ID]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]/config`
854
+ # @yield [result, operation] Access the result along with the TransportOperation object
855
+ # @yieldparam result [::Google::Cloud::Recommender::V1::RecommenderConfig]
856
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
857
+ #
858
+ # @return [::Google::Cloud::Recommender::V1::RecommenderConfig]
859
+ #
860
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
861
+ def get_recommender_config request, options = nil
862
+ raise ::ArgumentError, "request must be provided" if request.nil?
863
+
864
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::GetRecommenderConfigRequest
865
+
866
+ # Converts hash and nil to an options object
867
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
868
+
869
+ # Customize the options with defaults
870
+ call_metadata = @config.rpcs.get_recommender_config.metadata.to_h
871
+
872
+ # Set x-goog-api-client and x-goog-user-project headers
873
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
874
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
875
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
876
+ transports_version_send: [:rest]
877
+
878
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
879
+
880
+ options.apply_defaults timeout: @config.rpcs.get_recommender_config.timeout,
881
+ metadata: call_metadata,
882
+ retry_policy: @config.rpcs.get_recommender_config.retry_policy
883
+
884
+ options.apply_defaults timeout: @config.timeout,
885
+ metadata: @config.metadata,
886
+ retry_policy: @config.retry_policy
887
+
888
+ @recommender_stub.get_recommender_config request, options do |result, operation|
889
+ yield result, operation if block_given?
890
+ return result
891
+ end
892
+ rescue ::Gapic::Rest::Error => e
893
+ raise ::Google::Cloud::Error.from_error(e)
894
+ end
895
+
896
+ ##
897
+ # Updates a Recommender Config. This will create a new revision of the
898
+ # config.
899
+ #
900
+ # @overload update_recommender_config(request, options = nil)
901
+ # Pass arguments to `update_recommender_config` via a request object, either of type
902
+ # {::Google::Cloud::Recommender::V1::UpdateRecommenderConfigRequest} or an equivalent Hash.
903
+ #
904
+ # @param request [::Google::Cloud::Recommender::V1::UpdateRecommenderConfigRequest, ::Hash]
905
+ # A request object representing the call parameters. Required. To specify no
906
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
907
+ # @param options [::Gapic::CallOptions, ::Hash]
908
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
909
+ #
910
+ # @overload update_recommender_config(recommender_config: nil, update_mask: nil, validate_only: nil)
911
+ # Pass arguments to `update_recommender_config` via keyword arguments. Note that at
912
+ # least one keyword argument is required. To specify no parameters, or to keep all
913
+ # the default parameter values, pass an empty Hash as a request object (see above).
914
+ #
915
+ # @param recommender_config [::Google::Cloud::Recommender::V1::RecommenderConfig, ::Hash]
916
+ # Required. The RecommenderConfig to update.
917
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
918
+ # The list of fields to be updated.
919
+ # @param validate_only [::Boolean]
920
+ # If true, validate the request and preview the change, but do not actually
921
+ # update it.
922
+ # @yield [result, operation] Access the result along with the TransportOperation object
923
+ # @yieldparam result [::Google::Cloud::Recommender::V1::RecommenderConfig]
924
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
925
+ #
926
+ # @return [::Google::Cloud::Recommender::V1::RecommenderConfig]
927
+ #
928
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
929
+ def update_recommender_config request, options = nil
930
+ raise ::ArgumentError, "request must be provided" if request.nil?
931
+
932
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::UpdateRecommenderConfigRequest
933
+
934
+ # Converts hash and nil to an options object
935
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
936
+
937
+ # Customize the options with defaults
938
+ call_metadata = @config.rpcs.update_recommender_config.metadata.to_h
939
+
940
+ # Set x-goog-api-client and x-goog-user-project headers
941
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
942
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
943
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
944
+ transports_version_send: [:rest]
945
+
946
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
947
+
948
+ options.apply_defaults timeout: @config.rpcs.update_recommender_config.timeout,
949
+ metadata: call_metadata,
950
+ retry_policy: @config.rpcs.update_recommender_config.retry_policy
951
+
952
+ options.apply_defaults timeout: @config.timeout,
953
+ metadata: @config.metadata,
954
+ retry_policy: @config.retry_policy
955
+
956
+ @recommender_stub.update_recommender_config request, options do |result, operation|
957
+ yield result, operation if block_given?
958
+ return result
959
+ end
960
+ rescue ::Gapic::Rest::Error => e
961
+ raise ::Google::Cloud::Error.from_error(e)
962
+ end
963
+
964
+ ##
965
+ # Gets the requested InsightTypeConfig. There is only one instance of the
966
+ # config for each InsightType.
967
+ #
968
+ # @overload get_insight_type_config(request, options = nil)
969
+ # Pass arguments to `get_insight_type_config` via a request object, either of type
970
+ # {::Google::Cloud::Recommender::V1::GetInsightTypeConfigRequest} or an equivalent Hash.
971
+ #
972
+ # @param request [::Google::Cloud::Recommender::V1::GetInsightTypeConfigRequest, ::Hash]
973
+ # A request object representing the call parameters. Required. To specify no
974
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
975
+ # @param options [::Gapic::CallOptions, ::Hash]
976
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
977
+ #
978
+ # @overload get_insight_type_config(name: nil)
979
+ # Pass arguments to `get_insight_type_config` via keyword arguments. Note that at
980
+ # least one keyword argument is required. To specify no parameters, or to keep all
981
+ # the default parameter values, pass an empty Hash as a request object (see above).
982
+ #
983
+ # @param name [::String]
984
+ # Required. Name of the InsightTypeConfig to get.
985
+ #
986
+ # Acceptable formats:
987
+ #
988
+ # * `projects/[PROJECT_NUMBER]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config`
989
+ #
990
+ # * `projects/[PROJECT_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config`
991
+ #
992
+ # * `organizations/[ORGANIZATION_ID]/locations/global/recommenders/[INSIGHT_TYPE_ID]/config`
993
+ # @yield [result, operation] Access the result along with the TransportOperation object
994
+ # @yieldparam result [::Google::Cloud::Recommender::V1::InsightTypeConfig]
995
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
996
+ #
997
+ # @return [::Google::Cloud::Recommender::V1::InsightTypeConfig]
998
+ #
999
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1000
+ def get_insight_type_config request, options = nil
1001
+ raise ::ArgumentError, "request must be provided" if request.nil?
1002
+
1003
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::GetInsightTypeConfigRequest
1004
+
1005
+ # Converts hash and nil to an options object
1006
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1007
+
1008
+ # Customize the options with defaults
1009
+ call_metadata = @config.rpcs.get_insight_type_config.metadata.to_h
1010
+
1011
+ # Set x-goog-api-client and x-goog-user-project headers
1012
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1013
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1014
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
1015
+ transports_version_send: [:rest]
1016
+
1017
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1018
+
1019
+ options.apply_defaults timeout: @config.rpcs.get_insight_type_config.timeout,
1020
+ metadata: call_metadata,
1021
+ retry_policy: @config.rpcs.get_insight_type_config.retry_policy
1022
+
1023
+ options.apply_defaults timeout: @config.timeout,
1024
+ metadata: @config.metadata,
1025
+ retry_policy: @config.retry_policy
1026
+
1027
+ @recommender_stub.get_insight_type_config request, options do |result, operation|
1028
+ yield result, operation if block_given?
1029
+ return result
1030
+ end
1031
+ rescue ::Gapic::Rest::Error => e
1032
+ raise ::Google::Cloud::Error.from_error(e)
1033
+ end
1034
+
1035
+ ##
1036
+ # Updates an InsightTypeConfig change. This will create a new revision of the
1037
+ # config.
1038
+ #
1039
+ # @overload update_insight_type_config(request, options = nil)
1040
+ # Pass arguments to `update_insight_type_config` via a request object, either of type
1041
+ # {::Google::Cloud::Recommender::V1::UpdateInsightTypeConfigRequest} or an equivalent Hash.
1042
+ #
1043
+ # @param request [::Google::Cloud::Recommender::V1::UpdateInsightTypeConfigRequest, ::Hash]
1044
+ # A request object representing the call parameters. Required. To specify no
1045
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
1046
+ # @param options [::Gapic::CallOptions, ::Hash]
1047
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1048
+ #
1049
+ # @overload update_insight_type_config(insight_type_config: nil, update_mask: nil, validate_only: nil)
1050
+ # Pass arguments to `update_insight_type_config` via keyword arguments. Note that at
1051
+ # least one keyword argument is required. To specify no parameters, or to keep all
1052
+ # the default parameter values, pass an empty Hash as a request object (see above).
1053
+ #
1054
+ # @param insight_type_config [::Google::Cloud::Recommender::V1::InsightTypeConfig, ::Hash]
1055
+ # Required. The InsightTypeConfig to update.
1056
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
1057
+ # The list of fields to be updated.
1058
+ # @param validate_only [::Boolean]
1059
+ # If true, validate the request and preview the change, but do not actually
1060
+ # update it.
1061
+ # @yield [result, operation] Access the result along with the TransportOperation object
1062
+ # @yieldparam result [::Google::Cloud::Recommender::V1::InsightTypeConfig]
1063
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
1064
+ #
1065
+ # @return [::Google::Cloud::Recommender::V1::InsightTypeConfig]
1066
+ #
1067
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
1068
+ def update_insight_type_config request, options = nil
1069
+ raise ::ArgumentError, "request must be provided" if request.nil?
1070
+
1071
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Recommender::V1::UpdateInsightTypeConfigRequest
1072
+
1073
+ # Converts hash and nil to an options object
1074
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1075
+
1076
+ # Customize the options with defaults
1077
+ call_metadata = @config.rpcs.update_insight_type_config.metadata.to_h
1078
+
1079
+ # Set x-goog-api-client and x-goog-user-project headers
1080
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1081
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
1082
+ gapic_version: ::Google::Cloud::Recommender::V1::VERSION,
1083
+ transports_version_send: [:rest]
1084
+
1085
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1086
+
1087
+ options.apply_defaults timeout: @config.rpcs.update_insight_type_config.timeout,
1088
+ metadata: call_metadata,
1089
+ retry_policy: @config.rpcs.update_insight_type_config.retry_policy
1090
+
1091
+ options.apply_defaults timeout: @config.timeout,
1092
+ metadata: @config.metadata,
1093
+ retry_policy: @config.retry_policy
1094
+
1095
+ @recommender_stub.update_insight_type_config request, options do |result, operation|
1096
+ yield result, operation if block_given?
1097
+ return result
1098
+ end
1099
+ rescue ::Gapic::Rest::Error => e
1100
+ raise ::Google::Cloud::Error.from_error(e)
1101
+ end
1102
+
1103
+ ##
1104
+ # Configuration class for the Recommender REST API.
1105
+ #
1106
+ # This class represents the configuration for Recommender REST,
1107
+ # providing control over timeouts, retry behavior, logging, transport
1108
+ # parameters, and other low-level controls. Certain parameters can also be
1109
+ # applied individually to specific RPCs. See
1110
+ # {::Google::Cloud::Recommender::V1::Recommender::Rest::Client::Configuration::Rpcs}
1111
+ # for a list of RPCs that can be configured independently.
1112
+ #
1113
+ # Configuration can be applied globally to all clients, or to a single client
1114
+ # on construction.
1115
+ #
1116
+ # @example
1117
+ #
1118
+ # # Modify the global config, setting the timeout for
1119
+ # # list_insights to 20 seconds,
1120
+ # # and all remaining timeouts to 10 seconds.
1121
+ # ::Google::Cloud::Recommender::V1::Recommender::Rest::Client.configure do |config|
1122
+ # config.timeout = 10.0
1123
+ # config.rpcs.list_insights.timeout = 20.0
1124
+ # end
1125
+ #
1126
+ # # Apply the above configuration only to a new client.
1127
+ # client = ::Google::Cloud::Recommender::V1::Recommender::Rest::Client.new do |config|
1128
+ # config.timeout = 10.0
1129
+ # config.rpcs.list_insights.timeout = 20.0
1130
+ # end
1131
+ #
1132
+ # @!attribute [rw] endpoint
1133
+ # The hostname or hostname:port of the service endpoint.
1134
+ # Defaults to `"recommender.googleapis.com"`.
1135
+ # @return [::String]
1136
+ # @!attribute [rw] credentials
1137
+ # Credentials to send with calls. You may provide any of the following types:
1138
+ # * (`String`) The path to a service account key file in JSON format
1139
+ # * (`Hash`) A service account key as a Hash
1140
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
1141
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
1142
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
1143
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
1144
+ # * (`nil`) indicating no credentials
1145
+ # @return [::Object]
1146
+ # @!attribute [rw] scope
1147
+ # The OAuth scopes
1148
+ # @return [::Array<::String>]
1149
+ # @!attribute [rw] lib_name
1150
+ # The library name as recorded in instrumentation and logging
1151
+ # @return [::String]
1152
+ # @!attribute [rw] lib_version
1153
+ # The library version as recorded in instrumentation and logging
1154
+ # @return [::String]
1155
+ # @!attribute [rw] timeout
1156
+ # The call timeout in seconds.
1157
+ # @return [::Numeric]
1158
+ # @!attribute [rw] metadata
1159
+ # Additional headers to be sent with the call.
1160
+ # @return [::Hash{::Symbol=>::String}]
1161
+ # @!attribute [rw] retry_policy
1162
+ # The retry policy. The value is a hash with the following keys:
1163
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1164
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1165
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1166
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1167
+ # trigger a retry.
1168
+ # @return [::Hash]
1169
+ # @!attribute [rw] quota_project
1170
+ # A separate project against which to charge quota.
1171
+ # @return [::String]
1172
+ #
1173
+ class Configuration
1174
+ extend ::Gapic::Config
1175
+
1176
+ config_attr :endpoint, "recommender.googleapis.com", ::String
1177
+ config_attr :credentials, nil do |value|
1178
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
1179
+ allowed.any? { |klass| klass === value }
1180
+ end
1181
+ config_attr :scope, nil, ::String, ::Array, nil
1182
+ config_attr :lib_name, nil, ::String, nil
1183
+ config_attr :lib_version, nil, ::String, nil
1184
+ config_attr :timeout, nil, ::Numeric, nil
1185
+ config_attr :metadata, nil, ::Hash, nil
1186
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
1187
+ config_attr :quota_project, nil, ::String, nil
1188
+
1189
+ # @private
1190
+ def initialize parent_config = nil
1191
+ @parent_config = parent_config unless parent_config.nil?
1192
+
1193
+ yield self if block_given?
1194
+ end
1195
+
1196
+ ##
1197
+ # Configurations for individual RPCs
1198
+ # @return [Rpcs]
1199
+ #
1200
+ def rpcs
1201
+ @rpcs ||= begin
1202
+ parent_rpcs = nil
1203
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
1204
+ Rpcs.new parent_rpcs
1205
+ end
1206
+ end
1207
+
1208
+ ##
1209
+ # Configuration RPC class for the Recommender API.
1210
+ #
1211
+ # Includes fields providing the configuration for each RPC in this service.
1212
+ # Each configuration object is of type `Gapic::Config::Method` and includes
1213
+ # the following configuration fields:
1214
+ #
1215
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
1216
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
1217
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
1218
+ # include the following keys:
1219
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
1220
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
1221
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
1222
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
1223
+ # trigger a retry.
1224
+ #
1225
+ class Rpcs
1226
+ ##
1227
+ # RPC-specific configuration for `list_insights`
1228
+ # @return [::Gapic::Config::Method]
1229
+ #
1230
+ attr_reader :list_insights
1231
+ ##
1232
+ # RPC-specific configuration for `get_insight`
1233
+ # @return [::Gapic::Config::Method]
1234
+ #
1235
+ attr_reader :get_insight
1236
+ ##
1237
+ # RPC-specific configuration for `mark_insight_accepted`
1238
+ # @return [::Gapic::Config::Method]
1239
+ #
1240
+ attr_reader :mark_insight_accepted
1241
+ ##
1242
+ # RPC-specific configuration for `list_recommendations`
1243
+ # @return [::Gapic::Config::Method]
1244
+ #
1245
+ attr_reader :list_recommendations
1246
+ ##
1247
+ # RPC-specific configuration for `get_recommendation`
1248
+ # @return [::Gapic::Config::Method]
1249
+ #
1250
+ attr_reader :get_recommendation
1251
+ ##
1252
+ # RPC-specific configuration for `mark_recommendation_claimed`
1253
+ # @return [::Gapic::Config::Method]
1254
+ #
1255
+ attr_reader :mark_recommendation_claimed
1256
+ ##
1257
+ # RPC-specific configuration for `mark_recommendation_succeeded`
1258
+ # @return [::Gapic::Config::Method]
1259
+ #
1260
+ attr_reader :mark_recommendation_succeeded
1261
+ ##
1262
+ # RPC-specific configuration for `mark_recommendation_failed`
1263
+ # @return [::Gapic::Config::Method]
1264
+ #
1265
+ attr_reader :mark_recommendation_failed
1266
+ ##
1267
+ # RPC-specific configuration for `get_recommender_config`
1268
+ # @return [::Gapic::Config::Method]
1269
+ #
1270
+ attr_reader :get_recommender_config
1271
+ ##
1272
+ # RPC-specific configuration for `update_recommender_config`
1273
+ # @return [::Gapic::Config::Method]
1274
+ #
1275
+ attr_reader :update_recommender_config
1276
+ ##
1277
+ # RPC-specific configuration for `get_insight_type_config`
1278
+ # @return [::Gapic::Config::Method]
1279
+ #
1280
+ attr_reader :get_insight_type_config
1281
+ ##
1282
+ # RPC-specific configuration for `update_insight_type_config`
1283
+ # @return [::Gapic::Config::Method]
1284
+ #
1285
+ attr_reader :update_insight_type_config
1286
+
1287
+ # @private
1288
+ def initialize parent_rpcs = nil
1289
+ list_insights_config = parent_rpcs.list_insights if parent_rpcs.respond_to? :list_insights
1290
+ @list_insights = ::Gapic::Config::Method.new list_insights_config
1291
+ get_insight_config = parent_rpcs.get_insight if parent_rpcs.respond_to? :get_insight
1292
+ @get_insight = ::Gapic::Config::Method.new get_insight_config
1293
+ mark_insight_accepted_config = parent_rpcs.mark_insight_accepted if parent_rpcs.respond_to? :mark_insight_accepted
1294
+ @mark_insight_accepted = ::Gapic::Config::Method.new mark_insight_accepted_config
1295
+ list_recommendations_config = parent_rpcs.list_recommendations if parent_rpcs.respond_to? :list_recommendations
1296
+ @list_recommendations = ::Gapic::Config::Method.new list_recommendations_config
1297
+ get_recommendation_config = parent_rpcs.get_recommendation if parent_rpcs.respond_to? :get_recommendation
1298
+ @get_recommendation = ::Gapic::Config::Method.new get_recommendation_config
1299
+ mark_recommendation_claimed_config = parent_rpcs.mark_recommendation_claimed if parent_rpcs.respond_to? :mark_recommendation_claimed
1300
+ @mark_recommendation_claimed = ::Gapic::Config::Method.new mark_recommendation_claimed_config
1301
+ mark_recommendation_succeeded_config = parent_rpcs.mark_recommendation_succeeded if parent_rpcs.respond_to? :mark_recommendation_succeeded
1302
+ @mark_recommendation_succeeded = ::Gapic::Config::Method.new mark_recommendation_succeeded_config
1303
+ mark_recommendation_failed_config = parent_rpcs.mark_recommendation_failed if parent_rpcs.respond_to? :mark_recommendation_failed
1304
+ @mark_recommendation_failed = ::Gapic::Config::Method.new mark_recommendation_failed_config
1305
+ get_recommender_config_config = parent_rpcs.get_recommender_config if parent_rpcs.respond_to? :get_recommender_config
1306
+ @get_recommender_config = ::Gapic::Config::Method.new get_recommender_config_config
1307
+ update_recommender_config_config = parent_rpcs.update_recommender_config if parent_rpcs.respond_to? :update_recommender_config
1308
+ @update_recommender_config = ::Gapic::Config::Method.new update_recommender_config_config
1309
+ get_insight_type_config_config = parent_rpcs.get_insight_type_config if parent_rpcs.respond_to? :get_insight_type_config
1310
+ @get_insight_type_config = ::Gapic::Config::Method.new get_insight_type_config_config
1311
+ update_insight_type_config_config = parent_rpcs.update_insight_type_config if parent_rpcs.respond_to? :update_insight_type_config
1312
+ @update_insight_type_config = ::Gapic::Config::Method.new update_insight_type_config_config
1313
+
1314
+ yield self if block_given?
1315
+ end
1316
+ end
1317
+ end
1318
+ end
1319
+ end
1320
+ end
1321
+ end
1322
+ end
1323
+ end
1324
+ end