google-cloud-recommender-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,98 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/recommender/v1/recommendation.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/resource_pb'
7
+ require 'google/protobuf/duration_pb'
8
+ require 'google/protobuf/struct_pb'
9
+ require 'google/protobuf/timestamp_pb'
10
+ require 'google/type/money_pb'
11
+ Google::Protobuf::DescriptorPool.generated_pool.build do
12
+ add_file("google/cloud/recommender/v1/recommendation.proto", :syntax => :proto3) do
13
+ add_message "google.cloud.recommender.v1.Recommendation" do
14
+ optional :name, :string, 1
15
+ optional :description, :string, 2
16
+ optional :recommender_subtype, :string, 12
17
+ optional :last_refresh_time, :message, 4, "google.protobuf.Timestamp"
18
+ optional :primary_impact, :message, 5, "google.cloud.recommender.v1.Impact"
19
+ repeated :additional_impact, :message, 6, "google.cloud.recommender.v1.Impact"
20
+ optional :content, :message, 7, "google.cloud.recommender.v1.RecommendationContent"
21
+ optional :state_info, :message, 10, "google.cloud.recommender.v1.RecommendationStateInfo"
22
+ optional :etag, :string, 11
23
+ end
24
+ add_message "google.cloud.recommender.v1.RecommendationContent" do
25
+ repeated :operation_groups, :message, 2, "google.cloud.recommender.v1.OperationGroup"
26
+ end
27
+ add_message "google.cloud.recommender.v1.OperationGroup" do
28
+ repeated :operations, :message, 1, "google.cloud.recommender.v1.Operation"
29
+ end
30
+ add_message "google.cloud.recommender.v1.Operation" do
31
+ optional :action, :string, 1
32
+ optional :resource_type, :string, 2
33
+ optional :resource, :string, 3
34
+ optional :path, :string, 4
35
+ optional :source_resource, :string, 5
36
+ optional :source_path, :string, 6
37
+ map :path_filters, :string, :message, 8, "google.protobuf.Value"
38
+ map :path_value_matchers, :string, :message, 11, "google.cloud.recommender.v1.ValueMatcher"
39
+ oneof :path_value do
40
+ optional :value, :message, 7, "google.protobuf.Value"
41
+ optional :value_matcher, :message, 10, "google.cloud.recommender.v1.ValueMatcher"
42
+ end
43
+ end
44
+ add_message "google.cloud.recommender.v1.ValueMatcher" do
45
+ oneof :match_variant do
46
+ optional :matches_pattern, :string, 1
47
+ end
48
+ end
49
+ add_message "google.cloud.recommender.v1.CostProjection" do
50
+ optional :cost, :message, 1, "google.type.Money"
51
+ optional :duration, :message, 2, "google.protobuf.Duration"
52
+ end
53
+ add_message "google.cloud.recommender.v1.Impact" do
54
+ optional :category, :enum, 1, "google.cloud.recommender.v1.Impact.Category"
55
+ oneof :projection do
56
+ optional :cost_projection, :message, 100, "google.cloud.recommender.v1.CostProjection"
57
+ end
58
+ end
59
+ add_enum "google.cloud.recommender.v1.Impact.Category" do
60
+ value :CATEGORY_UNSPECIFIED, 0
61
+ value :COST, 1
62
+ value :SECURITY, 2
63
+ value :PERFORMANCE, 3
64
+ value :MANAGEABILITY, 4
65
+ end
66
+ add_message "google.cloud.recommender.v1.RecommendationStateInfo" do
67
+ optional :state, :enum, 1, "google.cloud.recommender.v1.RecommendationStateInfo.State"
68
+ map :state_metadata, :string, :string, 2
69
+ end
70
+ add_enum "google.cloud.recommender.v1.RecommendationStateInfo.State" do
71
+ value :STATE_UNSPECIFIED, 0
72
+ value :ACTIVE, 1
73
+ value :CLAIMED, 6
74
+ value :SUCCEEDED, 3
75
+ value :FAILED, 4
76
+ value :DISMISSED, 5
77
+ end
78
+ end
79
+ end
80
+
81
+ module Google
82
+ module Cloud
83
+ module Recommender
84
+ module V1
85
+ Recommendation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.recommender.v1.Recommendation").msgclass
86
+ RecommendationContent = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.recommender.v1.RecommendationContent").msgclass
87
+ OperationGroup = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.recommender.v1.OperationGroup").msgclass
88
+ Operation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.recommender.v1.Operation").msgclass
89
+ ValueMatcher = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.recommender.v1.ValueMatcher").msgclass
90
+ CostProjection = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.recommender.v1.CostProjection").msgclass
91
+ Impact = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.recommender.v1.Impact").msgclass
92
+ Impact::Category = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.recommender.v1.Impact.Category").enummodule
93
+ RecommendationStateInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.recommender.v1.RecommendationStateInfo").msgclass
94
+ RecommendationStateInfo::State = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.recommender.v1.RecommendationStateInfo.State").enummodule
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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/recommender/v1/recommender/client"
20
+ require "google/cloud/recommender/v1/recommender/credentials"
@@ -0,0 +1,584 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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 "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/errors"
24
+ require "google/cloud/recommender/v1/version"
25
+ require "google/cloud/recommender/v1/recommender_service_pb"
26
+ require "google/cloud/recommender/v1/recommender/credentials"
27
+ require "google/cloud/recommender/v1/recommender/paths"
28
+
29
+
30
+ module Google
31
+ module Cloud
32
+ module Recommender
33
+ module V1
34
+ module Recommender
35
+ # Service that implements Recommender API.
36
+ class Client
37
+ include Paths
38
+
39
+ # @private
40
+ attr_reader :recommender_stub
41
+
42
+ ##
43
+ # Configuration for the Recommender Client API.
44
+ #
45
+ # @yield [config] Configure the Client client.
46
+ # @yieldparam config [Client::Configuration]
47
+ #
48
+ # @return [Client::Configuration]
49
+ #
50
+ def self.configure
51
+ @configure ||= begin
52
+ namespace = ["Google", "Cloud", "Recommender", "V1"]
53
+ parent_config = while namespace.any?
54
+ parent_name = namespace.join "::"
55
+ parent_const = const_get parent_name
56
+ break parent_const.configure if parent_const&.respond_to? :configure
57
+ namespace.pop
58
+ end
59
+ Client::Configuration.new parent_config
60
+ end
61
+ yield @configure if block_given?
62
+ @configure
63
+ end
64
+
65
+ ##
66
+ # Configure the Recommender Client instance.
67
+ #
68
+ # The configuration is set to the derived mode, meaning that values can be changed,
69
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
70
+ # should be made on {Client.configure}.
71
+ #
72
+ # @yield [config] Configure the Client client.
73
+ # @yieldparam config [Client::Configuration]
74
+ #
75
+ # @return [Client::Configuration]
76
+ #
77
+ def configure
78
+ yield @config if block_given?
79
+ @config
80
+ end
81
+
82
+ ##
83
+ # Create a new Client client object.
84
+ #
85
+ # @yield [config] Configure the Client client.
86
+ # @yieldparam config [Client::Configuration]
87
+ #
88
+ def initialize
89
+ # These require statements are intentionally placed here to initialize
90
+ # the gRPC module only when it's required.
91
+ # See https://github.com/googleapis/toolkit/issues/446
92
+ require "gapic/grpc"
93
+ require "google/cloud/recommender/v1/recommender_service_services_pb"
94
+
95
+ # Create the configuration object
96
+ @config = Configuration.new Client.configure
97
+
98
+ # Yield the configuration if needed
99
+ yield @config if block_given?
100
+
101
+ # Create credentials
102
+ credentials = @config.credentials
103
+ credentials ||= Credentials.default scope: @config.scope
104
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
105
+ credentials = Credentials.new credentials, scope: @config.scope
106
+ end
107
+
108
+
109
+ @recommender_stub = Gapic::ServiceStub.new(
110
+ Google::Cloud::Recommender::V1::Recommender::Stub,
111
+ credentials: credentials,
112
+ endpoint: @config.endpoint,
113
+ channel_args: @config.channel_args,
114
+ interceptors: @config.interceptors
115
+ )
116
+ end
117
+
118
+ # Service calls
119
+
120
+ ##
121
+ # Lists recommendations for a Cloud project. Requires the recommender.*.list
122
+ # IAM permission for the specified recommender.
123
+ #
124
+ # @overload list_recommendations(request, options = nil)
125
+ # @param request [Google::Cloud::Recommender::V1::ListRecommendationsRequest | Hash]
126
+ # Lists recommendations for a Cloud project. Requires the recommender.*.list
127
+ # IAM permission for the specified recommender.
128
+ # @param options [Gapic::CallOptions, Hash]
129
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
130
+ #
131
+ # @overload list_recommendations(parent: nil, page_size: nil, page_token: nil, filter: nil)
132
+ # @param parent [String]
133
+ # Required. The container resource on which to execute the request.
134
+ # Acceptable formats:
135
+ #
136
+ # 1.
137
+ # "projects/[PROJECT_NUMBER]/locations/[LOCATION]/recommenders/[RECOMMENDER_ID]",
138
+ #
139
+ # LOCATION here refers to GCP Locations:
140
+ # https://cloud.google.com/about/locations/
141
+ # @param page_size [Integer]
142
+ # Optional. The maximum number of results to return from this request. Non-positive
143
+ # values are ignored. If not specified, the server will determine the number
144
+ # of results to return.
145
+ # @param page_token [String]
146
+ # Optional. If present, retrieves the next batch of results from the preceding call to
147
+ # this method. `page_token` must be the value of `next_page_token` from the
148
+ # previous response. The values of other method parameters must be identical
149
+ # to those in the previous call.
150
+ # @param filter [String]
151
+ # Filter expression to restrict the recommendations returned. Supported
152
+ # filter fields: state_info.state
153
+ # Eg: `state_info.state:"DISMISSED" or state_info.state:"FAILED"
154
+ #
155
+ #
156
+ # @yield [response, operation] Access the result along with the RPC operation
157
+ # @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::Recommender::V1::Recommendation>]
158
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
159
+ #
160
+ # @return [Gapic::PagedEnumerable<Google::Cloud::Recommender::V1::Recommendation>]
161
+ #
162
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
163
+ #
164
+ def list_recommendations request, options = nil
165
+ raise ArgumentError, "request must be provided" if request.nil?
166
+
167
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Recommender::V1::ListRecommendationsRequest
168
+
169
+ # Converts hash and nil to an options object
170
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
171
+
172
+ # Customize the options with defaults
173
+ metadata = @config.rpcs.list_recommendations.metadata.to_h
174
+
175
+ # Set x-goog-api-client header
176
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
177
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
178
+ gapic_version: Google::Cloud::Recommender::V1::VERSION
179
+
180
+ header_params = {
181
+ "parent" => request.parent
182
+ }
183
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
184
+ metadata[:"x-goog-request-params"] ||= request_params_header
185
+
186
+ options.apply_defaults timeout: @config.rpcs.list_recommendations.timeout,
187
+ metadata: metadata,
188
+ retry_policy: @config.rpcs.list_recommendations.retry_policy
189
+ options.apply_defaults metadata: @config.metadata,
190
+ retry_policy: @config.retry_policy
191
+
192
+ @recommender_stub.call_rpc :list_recommendations, request, options: options do |response, operation|
193
+ response = Gapic::PagedEnumerable.new @recommender_stub, :list_recommendations, request, response, operation, options
194
+ yield response, operation if block_given?
195
+ return response
196
+ end
197
+ rescue GRPC::BadStatus => e
198
+ raise Google::Cloud::Error.from_error(e)
199
+ end
200
+
201
+ ##
202
+ # Gets the requested recommendation. Requires the recommender.*.get
203
+ # IAM permission for the specified recommender.
204
+ #
205
+ # @overload get_recommendation(request, options = nil)
206
+ # @param request [Google::Cloud::Recommender::V1::GetRecommendationRequest | Hash]
207
+ # Gets the requested recommendation. Requires the recommender.*.get
208
+ # IAM permission for the specified recommender.
209
+ # @param options [Gapic::CallOptions, Hash]
210
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
211
+ #
212
+ # @overload get_recommendation(name: nil)
213
+ # @param name [String]
214
+ # Required. Name of the recommendation.
215
+ #
216
+ #
217
+ # @yield [response, operation] Access the result along with the RPC operation
218
+ # @yieldparam response [Google::Cloud::Recommender::V1::Recommendation]
219
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
220
+ #
221
+ # @return [Google::Cloud::Recommender::V1::Recommendation]
222
+ #
223
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
224
+ #
225
+ def get_recommendation request, options = nil
226
+ raise ArgumentError, "request must be provided" if request.nil?
227
+
228
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Recommender::V1::GetRecommendationRequest
229
+
230
+ # Converts hash and nil to an options object
231
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
232
+
233
+ # Customize the options with defaults
234
+ metadata = @config.rpcs.get_recommendation.metadata.to_h
235
+
236
+ # Set x-goog-api-client header
237
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
238
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
239
+ gapic_version: Google::Cloud::Recommender::V1::VERSION
240
+
241
+ header_params = {
242
+ "name" => request.name
243
+ }
244
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
245
+ metadata[:"x-goog-request-params"] ||= request_params_header
246
+
247
+ options.apply_defaults timeout: @config.rpcs.get_recommendation.timeout,
248
+ metadata: metadata,
249
+ retry_policy: @config.rpcs.get_recommendation.retry_policy
250
+ options.apply_defaults metadata: @config.metadata,
251
+ retry_policy: @config.retry_policy
252
+
253
+ @recommender_stub.call_rpc :get_recommendation, request, options: options do |response, operation|
254
+ yield response, operation if block_given?
255
+ return response
256
+ end
257
+ rescue GRPC::BadStatus => e
258
+ raise Google::Cloud::Error.from_error(e)
259
+ end
260
+
261
+ ##
262
+ # Mark the Recommendation State as Claimed. Users can use this method to
263
+ # indicate to the Recommender API that they are starting to apply the
264
+ # recommendation themselves. This stops the recommendation content from being
265
+ # updated.
266
+ #
267
+ # MarkRecommendationClaimed can be applied to recommendations in CLAIMED,
268
+ # SUCCEEDED, FAILED, or ACTIVE state.
269
+ #
270
+ # Requires the recommender.*.update IAM permission for the specified
271
+ # recommender.
272
+ #
273
+ # @overload mark_recommendation_claimed(request, options = nil)
274
+ # @param request [Google::Cloud::Recommender::V1::MarkRecommendationClaimedRequest | Hash]
275
+ # Mark the Recommendation State as Claimed. Users can use this method to
276
+ # indicate to the Recommender API that they are starting to apply the
277
+ # recommendation themselves. This stops the recommendation content from being
278
+ # updated.
279
+ #
280
+ # MarkRecommendationClaimed can be applied to recommendations in CLAIMED,
281
+ # SUCCEEDED, FAILED, or ACTIVE state.
282
+ #
283
+ # Requires the recommender.*.update IAM permission for the specified
284
+ # recommender.
285
+ # @param options [Gapic::CallOptions, Hash]
286
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
287
+ #
288
+ # @overload mark_recommendation_claimed(name: nil, state_metadata: nil, etag: nil)
289
+ # @param name [String]
290
+ # Required. Name of the recommendation.
291
+ # @param state_metadata [Hash{String => String}]
292
+ # State properties to include with this state. Overwrites any existing
293
+ # `state_metadata`.
294
+ # Keys must match the regex /^[a-z0-9][a-z0-9_.-]\\\{0,62\}$/.
295
+ # Values must match the regex /^[a-zA-Z0-9_./-]\\\{0,255\}$/.
296
+ # @param etag [String]
297
+ # Required. Fingerprint of the Recommendation. Provides optimistic locking.
298
+ #
299
+ #
300
+ # @yield [response, operation] Access the result along with the RPC operation
301
+ # @yieldparam response [Google::Cloud::Recommender::V1::Recommendation]
302
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
303
+ #
304
+ # @return [Google::Cloud::Recommender::V1::Recommendation]
305
+ #
306
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
307
+ #
308
+ def mark_recommendation_claimed 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::MarkRecommendationClaimedRequest
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
+ metadata = @config.rpcs.mark_recommendation_claimed.metadata.to_h
318
+
319
+ # Set x-goog-api-client header
320
+ 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
+
324
+ header_params = {
325
+ "name" => request.name
326
+ }
327
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
328
+ metadata[:"x-goog-request-params"] ||= request_params_header
329
+
330
+ options.apply_defaults timeout: @config.rpcs.mark_recommendation_claimed.timeout,
331
+ metadata: metadata,
332
+ retry_policy: @config.rpcs.mark_recommendation_claimed.retry_policy
333
+ options.apply_defaults metadata: @config.metadata,
334
+ retry_policy: @config.retry_policy
335
+
336
+ @recommender_stub.call_rpc :mark_recommendation_claimed, request, options: options do |response, operation|
337
+ yield response, operation if block_given?
338
+ return response
339
+ end
340
+ rescue GRPC::BadStatus => e
341
+ raise Google::Cloud::Error.from_error(e)
342
+ end
343
+
344
+ ##
345
+ # Mark the Recommendation State as Succeeded. Users can use this method to
346
+ # indicate to the Recommender API that they have applied the recommendation
347
+ # themselves, and the operation was successful. This stops the recommendation
348
+ # content from being updated.
349
+ #
350
+ # MarkRecommendationSucceeded can be applied to recommendations in ACTIVE,
351
+ # CLAIMED, SUCCEEDED, or FAILED state.
352
+ #
353
+ # Requires the recommender.*.update IAM permission for the specified
354
+ # recommender.
355
+ #
356
+ # @overload mark_recommendation_succeeded(request, options = nil)
357
+ # @param request [Google::Cloud::Recommender::V1::MarkRecommendationSucceededRequest | Hash]
358
+ # Mark the Recommendation State as Succeeded. Users can use this method to
359
+ # indicate to the Recommender API that they have applied the recommendation
360
+ # themselves, and the operation was successful. This stops the recommendation
361
+ # content from being updated.
362
+ #
363
+ # MarkRecommendationSucceeded can be applied to recommendations in ACTIVE,
364
+ # CLAIMED, SUCCEEDED, or FAILED state.
365
+ #
366
+ # Requires the recommender.*.update IAM permission for the specified
367
+ # recommender.
368
+ # @param options [Gapic::CallOptions, Hash]
369
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
370
+ #
371
+ # @overload mark_recommendation_succeeded(name: nil, state_metadata: nil, etag: nil)
372
+ # @param name [String]
373
+ # Required. Name of the recommendation.
374
+ # @param state_metadata [Hash{String => String}]
375
+ # State properties to include with this state. Overwrites any existing
376
+ # `state_metadata`.
377
+ # Keys must match the regex /^[a-z0-9][a-z0-9_.-]\\\{0,62\}$/.
378
+ # Values must match the regex /^[a-zA-Z0-9_./-]\\\{0,255\}$/.
379
+ # @param etag [String]
380
+ # Required. Fingerprint of the Recommendation. Provides optimistic locking.
381
+ #
382
+ #
383
+ # @yield [response, operation] Access the result along with the RPC operation
384
+ # @yieldparam response [Google::Cloud::Recommender::V1::Recommendation]
385
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
386
+ #
387
+ # @return [Google::Cloud::Recommender::V1::Recommendation]
388
+ #
389
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
390
+ #
391
+ def mark_recommendation_succeeded request, options = nil
392
+ raise ArgumentError, "request must be provided" if request.nil?
393
+
394
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Recommender::V1::MarkRecommendationSucceededRequest
395
+
396
+ # Converts hash and nil to an options object
397
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
398
+
399
+ # Customize the options with defaults
400
+ metadata = @config.rpcs.mark_recommendation_succeeded.metadata.to_h
401
+
402
+ # Set x-goog-api-client header
403
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
404
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
405
+ gapic_version: Google::Cloud::Recommender::V1::VERSION
406
+
407
+ header_params = {
408
+ "name" => request.name
409
+ }
410
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
411
+ metadata[:"x-goog-request-params"] ||= request_params_header
412
+
413
+ options.apply_defaults timeout: @config.rpcs.mark_recommendation_succeeded.timeout,
414
+ metadata: metadata,
415
+ retry_policy: @config.rpcs.mark_recommendation_succeeded.retry_policy
416
+ options.apply_defaults metadata: @config.metadata,
417
+ retry_policy: @config.retry_policy
418
+
419
+ @recommender_stub.call_rpc :mark_recommendation_succeeded, request, options: options do |response, operation|
420
+ yield response, operation if block_given?
421
+ return response
422
+ end
423
+ rescue GRPC::BadStatus => e
424
+ raise Google::Cloud::Error.from_error(e)
425
+ end
426
+
427
+ ##
428
+ # Mark the Recommendation State as Failed. Users can use this method to
429
+ # indicate to the Recommender API that they have applied the recommendation
430
+ # themselves, and the operation failed. This stops the recommendation content
431
+ # from being updated.
432
+ #
433
+ # MarkRecommendationFailed can be applied to recommendations in ACTIVE,
434
+ # CLAIMED, SUCCEEDED, or FAILED state.
435
+ #
436
+ # Requires the recommender.*.update IAM permission for the specified
437
+ # recommender.
438
+ #
439
+ # @overload mark_recommendation_failed(request, options = nil)
440
+ # @param request [Google::Cloud::Recommender::V1::MarkRecommendationFailedRequest | Hash]
441
+ # Mark the Recommendation State as Failed. Users can use this method to
442
+ # indicate to the Recommender API that they have applied the recommendation
443
+ # themselves, and the operation failed. This stops the recommendation content
444
+ # from being updated.
445
+ #
446
+ # MarkRecommendationFailed can be applied to recommendations in ACTIVE,
447
+ # CLAIMED, SUCCEEDED, or FAILED state.
448
+ #
449
+ # Requires the recommender.*.update IAM permission for the specified
450
+ # recommender.
451
+ # @param options [Gapic::CallOptions, Hash]
452
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
453
+ #
454
+ # @overload mark_recommendation_failed(name: nil, state_metadata: nil, etag: nil)
455
+ # @param name [String]
456
+ # Required. Name of the recommendation.
457
+ # @param state_metadata [Hash{String => String}]
458
+ # State properties to include with this state. Overwrites any existing
459
+ # `state_metadata`.
460
+ # Keys must match the regex /^[a-z0-9][a-z0-9_.-]\\\{0,62\}$/.
461
+ # Values must match the regex /^[a-zA-Z0-9_./-]\\\{0,255\}$/.
462
+ # @param etag [String]
463
+ # Required. Fingerprint of the Recommendation. Provides optimistic locking.
464
+ #
465
+ #
466
+ # @yield [response, operation] Access the result along with the RPC operation
467
+ # @yieldparam response [Google::Cloud::Recommender::V1::Recommendation]
468
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
469
+ #
470
+ # @return [Google::Cloud::Recommender::V1::Recommendation]
471
+ #
472
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
473
+ #
474
+ def mark_recommendation_failed request, options = nil
475
+ raise ArgumentError, "request must be provided" if request.nil?
476
+
477
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::Recommender::V1::MarkRecommendationFailedRequest
478
+
479
+ # Converts hash and nil to an options object
480
+ options = Gapic::CallOptions.new options.to_h if options.respond_to? :to_h
481
+
482
+ # Customize the options with defaults
483
+ metadata = @config.rpcs.mark_recommendation_failed.metadata.to_h
484
+
485
+ # Set x-goog-api-client header
486
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
487
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
488
+ gapic_version: Google::Cloud::Recommender::V1::VERSION
489
+
490
+ header_params = {
491
+ "name" => request.name
492
+ }
493
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
494
+ metadata[:"x-goog-request-params"] ||= request_params_header
495
+
496
+ options.apply_defaults timeout: @config.rpcs.mark_recommendation_failed.timeout,
497
+ metadata: metadata,
498
+ retry_policy: @config.rpcs.mark_recommendation_failed.retry_policy
499
+ options.apply_defaults metadata: @config.metadata,
500
+ retry_policy: @config.retry_policy
501
+
502
+ @recommender_stub.call_rpc :mark_recommendation_failed, request, options: options do |response, operation|
503
+ yield response, operation if block_given?
504
+ return response
505
+ end
506
+ rescue GRPC::BadStatus => e
507
+ raise Google::Cloud::Error.from_error(e)
508
+ end
509
+
510
+ ##
511
+ # Configuration class for the Recommender API.
512
+ class Configuration
513
+ extend Gapic::Config
514
+
515
+ config_attr :endpoint, "recommender.googleapis.com", String
516
+ config_attr :credentials, nil do |value|
517
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
518
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
519
+ allowed.any? { |klass| klass === value }
520
+ end
521
+ config_attr :scope, nil, String, Array, nil
522
+ config_attr :lib_name, nil, String, nil
523
+ config_attr :lib_version, nil, String, nil
524
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
525
+ config_attr :interceptors, nil, Array, nil
526
+ config_attr :timeout, nil, Numeric, nil
527
+ config_attr :metadata, nil, Hash, nil
528
+ config_attr :retry_policy, nil, Hash, Proc, nil
529
+
530
+ def initialize parent_config = nil
531
+ @parent_config = parent_config unless parent_config.nil?
532
+
533
+ yield self if block_given?
534
+ end
535
+
536
+ def rpcs
537
+ @rpcs ||= begin
538
+ parent_rpcs = nil
539
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
540
+ Rpcs.new parent_rpcs
541
+ end
542
+ end
543
+
544
+ ##
545
+ # Configuration RPC class for the Recommender API.
546
+ class Rpcs
547
+ attr_reader :list_recommendations
548
+ attr_reader :get_recommendation
549
+ attr_reader :mark_recommendation_claimed
550
+ attr_reader :mark_recommendation_succeeded
551
+ attr_reader :mark_recommendation_failed
552
+
553
+ def initialize parent_rpcs = nil
554
+ list_recommendations_config = parent_rpcs&.list_recommendations if parent_rpcs&.respond_to? :list_recommendations
555
+ @list_recommendations = Gapic::Config::Method.new list_recommendations_config
556
+ get_recommendation_config = parent_rpcs&.get_recommendation if parent_rpcs&.respond_to? :get_recommendation
557
+ @get_recommendation = Gapic::Config::Method.new get_recommendation_config
558
+ mark_recommendation_claimed_config = parent_rpcs&.mark_recommendation_claimed if parent_rpcs&.respond_to? :mark_recommendation_claimed
559
+ @mark_recommendation_claimed = Gapic::Config::Method.new mark_recommendation_claimed_config
560
+ mark_recommendation_succeeded_config = parent_rpcs&.mark_recommendation_succeeded if parent_rpcs&.respond_to? :mark_recommendation_succeeded
561
+ @mark_recommendation_succeeded = Gapic::Config::Method.new mark_recommendation_succeeded_config
562
+ mark_recommendation_failed_config = parent_rpcs&.mark_recommendation_failed if parent_rpcs&.respond_to? :mark_recommendation_failed
563
+ @mark_recommendation_failed = Gapic::Config::Method.new mark_recommendation_failed_config
564
+
565
+ yield self if block_given?
566
+ end
567
+ end
568
+ end
569
+ end
570
+ end
571
+ end
572
+ end
573
+ end
574
+ end
575
+
576
+ # rubocop:disable Lint/HandleExceptions
577
+
578
+ # Once client is loaded, load helpers.rb if it exists.
579
+ begin
580
+ require "google/cloud/recommender/v1/recommender/helpers"
581
+ rescue LoadError
582
+ end
583
+
584
+ # rubocop:enable Lint/HandleExceptions