google-cloud-assured_workloads-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,723 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 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/assuredworkloads/v1/assuredworkloads_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module AssuredWorkloads
25
+ module V1
26
+ module AssuredWorkloadsService
27
+ ##
28
+ # Client for the AssuredWorkloadsService service.
29
+ #
30
+ # Service to manage AssuredWorkloads.
31
+ #
32
+ class Client
33
+ include Paths
34
+
35
+ # @private
36
+ attr_reader :assured_workloads_service_stub
37
+
38
+ ##
39
+ # Configure the AssuredWorkloadsService Client class.
40
+ #
41
+ # See {::Google::Cloud::AssuredWorkloads::V1::AssuredWorkloadsService::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # @example
45
+ #
46
+ # # Modify the configuration for all AssuredWorkloadsService clients
47
+ # ::Google::Cloud::AssuredWorkloads::V1::AssuredWorkloadsService::Client.configure do |config|
48
+ # config.timeout = 10.0
49
+ # end
50
+ #
51
+ # @yield [config] Configure the Client client.
52
+ # @yieldparam config [Client::Configuration]
53
+ #
54
+ # @return [Client::Configuration]
55
+ #
56
+ def self.configure
57
+ @configure ||= begin
58
+ namespace = ["Google", "Cloud", "AssuredWorkloads", "V1"]
59
+ parent_config = while namespace.any?
60
+ parent_name = namespace.join "::"
61
+ parent_const = const_get parent_name
62
+ break parent_const.configure if parent_const.respond_to? :configure
63
+ namespace.pop
64
+ end
65
+ default_config = Client::Configuration.new parent_config
66
+
67
+ default_config.timeout = 60.0
68
+
69
+ default_config
70
+ end
71
+ yield @configure if block_given?
72
+ @configure
73
+ end
74
+
75
+ ##
76
+ # Configure the AssuredWorkloadsService Client instance.
77
+ #
78
+ # The configuration is set to the derived mode, meaning that values can be changed,
79
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
80
+ # should be made on {Client.configure}.
81
+ #
82
+ # See {::Google::Cloud::AssuredWorkloads::V1::AssuredWorkloadsService::Client::Configuration}
83
+ # for a description of the configuration fields.
84
+ #
85
+ # @yield [config] Configure the Client client.
86
+ # @yieldparam config [Client::Configuration]
87
+ #
88
+ # @return [Client::Configuration]
89
+ #
90
+ def configure
91
+ yield @config if block_given?
92
+ @config
93
+ end
94
+
95
+ ##
96
+ # Create a new AssuredWorkloadsService client object.
97
+ #
98
+ # @example
99
+ #
100
+ # # Create a client using the default configuration
101
+ # client = ::Google::Cloud::AssuredWorkloads::V1::AssuredWorkloadsService::Client.new
102
+ #
103
+ # # Create a client using a custom configuration
104
+ # client = ::Google::Cloud::AssuredWorkloads::V1::AssuredWorkloadsService::Client.new do |config|
105
+ # config.timeout = 10.0
106
+ # end
107
+ #
108
+ # @yield [config] Configure the AssuredWorkloadsService client.
109
+ # @yieldparam config [Client::Configuration]
110
+ #
111
+ def initialize
112
+ # These require statements are intentionally placed here to initialize
113
+ # the gRPC module only when it's required.
114
+ # See https://github.com/googleapis/toolkit/issues/446
115
+ require "gapic/grpc"
116
+ require "google/cloud/assuredworkloads/v1/assuredworkloads_services_pb"
117
+
118
+ # Create the configuration object
119
+ @config = Configuration.new Client.configure
120
+
121
+ # Yield the configuration if needed
122
+ yield @config if block_given?
123
+
124
+ # Create credentials
125
+ credentials = @config.credentials
126
+ # Use self-signed JWT if the endpoint is unchanged from default,
127
+ # but only if the default endpoint does not have a region prefix.
128
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
129
+ !@config.endpoint.split(".").first.include?("-")
130
+ credentials ||= Credentials.default scope: @config.scope,
131
+ enable_self_signed_jwt: enable_self_signed_jwt
132
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
133
+ credentials = Credentials.new credentials, scope: @config.scope
134
+ end
135
+ @quota_project_id = @config.quota_project
136
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
137
+
138
+ @operations_client = Operations.new do |config|
139
+ config.credentials = credentials
140
+ config.endpoint = @config.endpoint
141
+ end
142
+
143
+ @assured_workloads_service_stub = ::Gapic::ServiceStub.new(
144
+ ::Google::Cloud::AssuredWorkloads::V1::AssuredWorkloadsService::Stub,
145
+ credentials: credentials,
146
+ endpoint: @config.endpoint,
147
+ channel_args: @config.channel_args,
148
+ interceptors: @config.interceptors
149
+ )
150
+ end
151
+
152
+ ##
153
+ # Get the associated client for long-running operations.
154
+ #
155
+ # @return [::Google::Cloud::AssuredWorkloads::V1::AssuredWorkloadsService::Operations]
156
+ #
157
+ attr_reader :operations_client
158
+
159
+ # Service calls
160
+
161
+ ##
162
+ # Creates Assured Workload.
163
+ #
164
+ # @overload create_workload(request, options = nil)
165
+ # Pass arguments to `create_workload` via a request object, either of type
166
+ # {::Google::Cloud::AssuredWorkloads::V1::CreateWorkloadRequest} or an equivalent Hash.
167
+ #
168
+ # @param request [::Google::Cloud::AssuredWorkloads::V1::CreateWorkloadRequest, ::Hash]
169
+ # A request object representing the call parameters. Required. To specify no
170
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
171
+ # @param options [::Gapic::CallOptions, ::Hash]
172
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
173
+ #
174
+ # @overload create_workload(parent: nil, workload: nil, external_id: nil)
175
+ # Pass arguments to `create_workload` via keyword arguments. Note that at
176
+ # least one keyword argument is required. To specify no parameters, or to keep all
177
+ # the default parameter values, pass an empty Hash as a request object (see above).
178
+ #
179
+ # @param parent [::String]
180
+ # Required. The resource name of the new Workload's parent.
181
+ # Must be of the form `organizations/{org_id}/locations/{location_id}`.
182
+ # @param workload [::Google::Cloud::AssuredWorkloads::V1::Workload, ::Hash]
183
+ # Required. Assured Workload to create
184
+ # @param external_id [::String]
185
+ # Optional. A identifier associated with the workload and underlying projects which
186
+ # allows for the break down of billing costs for a workload. The value
187
+ # provided for the identifier will add a label to the workload and contained
188
+ # projects with the identifier as the value.
189
+ #
190
+ # @yield [response, operation] Access the result along with the RPC operation
191
+ # @yieldparam response [::Gapic::Operation]
192
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
193
+ #
194
+ # @return [::Gapic::Operation]
195
+ #
196
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
197
+ #
198
+ def create_workload request, options = nil
199
+ raise ::ArgumentError, "request must be provided" if request.nil?
200
+
201
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AssuredWorkloads::V1::CreateWorkloadRequest
202
+
203
+ # Converts hash and nil to an options object
204
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
205
+
206
+ # Customize the options with defaults
207
+ metadata = @config.rpcs.create_workload.metadata.to_h
208
+
209
+ # Set x-goog-api-client and x-goog-user-project headers
210
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
211
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
212
+ gapic_version: ::Google::Cloud::AssuredWorkloads::V1::VERSION
213
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
214
+
215
+ header_params = {
216
+ "parent" => request.parent
217
+ }
218
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
219
+ metadata[:"x-goog-request-params"] ||= request_params_header
220
+
221
+ options.apply_defaults timeout: @config.rpcs.create_workload.timeout,
222
+ metadata: metadata,
223
+ retry_policy: @config.rpcs.create_workload.retry_policy
224
+
225
+ options.apply_defaults timeout: @config.timeout,
226
+ metadata: @config.metadata,
227
+ retry_policy: @config.retry_policy
228
+
229
+ @assured_workloads_service_stub.call_rpc :create_workload, request, options: options do |response, operation|
230
+ response = ::Gapic::Operation.new response, @operations_client, options: options
231
+ yield response, operation if block_given?
232
+ return response
233
+ end
234
+ rescue ::GRPC::BadStatus => e
235
+ raise ::Google::Cloud::Error.from_error(e)
236
+ end
237
+
238
+ ##
239
+ # Updates an existing workload.
240
+ # Currently allows updating of workload display_name and labels.
241
+ # For force updates don't set etag field in the Workload.
242
+ # Only one update operation per workload can be in progress.
243
+ #
244
+ # @overload update_workload(request, options = nil)
245
+ # Pass arguments to `update_workload` via a request object, either of type
246
+ # {::Google::Cloud::AssuredWorkloads::V1::UpdateWorkloadRequest} or an equivalent Hash.
247
+ #
248
+ # @param request [::Google::Cloud::AssuredWorkloads::V1::UpdateWorkloadRequest, ::Hash]
249
+ # A request object representing the call parameters. Required. To specify no
250
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
251
+ # @param options [::Gapic::CallOptions, ::Hash]
252
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
253
+ #
254
+ # @overload update_workload(workload: nil, update_mask: nil)
255
+ # Pass arguments to `update_workload` via keyword arguments. Note that at
256
+ # least one keyword argument is required. To specify no parameters, or to keep all
257
+ # the default parameter values, pass an empty Hash as a request object (see above).
258
+ #
259
+ # @param workload [::Google::Cloud::AssuredWorkloads::V1::Workload, ::Hash]
260
+ # Required. The workload to update.
261
+ # The workload’s `name` field is used to identify the workload to be updated.
262
+ # Format:
263
+ # organizations/\\{org_id}/locations/\\{location_id}/workloads/\\{workload_id}
264
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
265
+ # Required. The list of fields to be updated.
266
+ #
267
+ # @yield [response, operation] Access the result along with the RPC operation
268
+ # @yieldparam response [::Google::Cloud::AssuredWorkloads::V1::Workload]
269
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
270
+ #
271
+ # @return [::Google::Cloud::AssuredWorkloads::V1::Workload]
272
+ #
273
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
274
+ #
275
+ def update_workload request, options = nil
276
+ raise ::ArgumentError, "request must be provided" if request.nil?
277
+
278
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AssuredWorkloads::V1::UpdateWorkloadRequest
279
+
280
+ # Converts hash and nil to an options object
281
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
282
+
283
+ # Customize the options with defaults
284
+ metadata = @config.rpcs.update_workload.metadata.to_h
285
+
286
+ # Set x-goog-api-client and x-goog-user-project headers
287
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
288
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
289
+ gapic_version: ::Google::Cloud::AssuredWorkloads::V1::VERSION
290
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
291
+
292
+ header_params = {
293
+ "workload.name" => request.workload.name
294
+ }
295
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
296
+ metadata[:"x-goog-request-params"] ||= request_params_header
297
+
298
+ options.apply_defaults timeout: @config.rpcs.update_workload.timeout,
299
+ metadata: metadata,
300
+ retry_policy: @config.rpcs.update_workload.retry_policy
301
+
302
+ options.apply_defaults timeout: @config.timeout,
303
+ metadata: @config.metadata,
304
+ retry_policy: @config.retry_policy
305
+
306
+ @assured_workloads_service_stub.call_rpc :update_workload, request, options: options do |response, operation|
307
+ yield response, operation if block_given?
308
+ return response
309
+ end
310
+ rescue ::GRPC::BadStatus => e
311
+ raise ::Google::Cloud::Error.from_error(e)
312
+ end
313
+
314
+ ##
315
+ # Deletes the workload. Make sure that workload's direct children are already
316
+ # in a deleted state, otherwise the request will fail with a
317
+ # FAILED_PRECONDITION error.
318
+ #
319
+ # @overload delete_workload(request, options = nil)
320
+ # Pass arguments to `delete_workload` via a request object, either of type
321
+ # {::Google::Cloud::AssuredWorkloads::V1::DeleteWorkloadRequest} or an equivalent Hash.
322
+ #
323
+ # @param request [::Google::Cloud::AssuredWorkloads::V1::DeleteWorkloadRequest, ::Hash]
324
+ # A request object representing the call parameters. Required. To specify no
325
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
326
+ # @param options [::Gapic::CallOptions, ::Hash]
327
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
328
+ #
329
+ # @overload delete_workload(name: nil, etag: nil)
330
+ # Pass arguments to `delete_workload` via keyword arguments. Note that at
331
+ # least one keyword argument is required. To specify no parameters, or to keep all
332
+ # the default parameter values, pass an empty Hash as a request object (see above).
333
+ #
334
+ # @param name [::String]
335
+ # Required. The `name` field is used to identify the workload.
336
+ # Format:
337
+ # organizations/\\{org_id}/locations/\\{location_id}/workloads/\\{workload_id}
338
+ # @param etag [::String]
339
+ # Optional. The etag of the workload.
340
+ # If this is provided, it must match the server's etag.
341
+ #
342
+ # @yield [response, operation] Access the result along with the RPC operation
343
+ # @yieldparam response [::Google::Protobuf::Empty]
344
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
345
+ #
346
+ # @return [::Google::Protobuf::Empty]
347
+ #
348
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
349
+ #
350
+ def delete_workload request, options = nil
351
+ raise ::ArgumentError, "request must be provided" if request.nil?
352
+
353
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AssuredWorkloads::V1::DeleteWorkloadRequest
354
+
355
+ # Converts hash and nil to an options object
356
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
357
+
358
+ # Customize the options with defaults
359
+ metadata = @config.rpcs.delete_workload.metadata.to_h
360
+
361
+ # Set x-goog-api-client and x-goog-user-project headers
362
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
363
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
364
+ gapic_version: ::Google::Cloud::AssuredWorkloads::V1::VERSION
365
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
366
+
367
+ header_params = {
368
+ "name" => request.name
369
+ }
370
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
371
+ metadata[:"x-goog-request-params"] ||= request_params_header
372
+
373
+ options.apply_defaults timeout: @config.rpcs.delete_workload.timeout,
374
+ metadata: metadata,
375
+ retry_policy: @config.rpcs.delete_workload.retry_policy
376
+
377
+ options.apply_defaults timeout: @config.timeout,
378
+ metadata: @config.metadata,
379
+ retry_policy: @config.retry_policy
380
+
381
+ @assured_workloads_service_stub.call_rpc :delete_workload, request, options: options do |response, operation|
382
+ yield response, operation if block_given?
383
+ return response
384
+ end
385
+ rescue ::GRPC::BadStatus => e
386
+ raise ::Google::Cloud::Error.from_error(e)
387
+ end
388
+
389
+ ##
390
+ # Gets Assured Workload associated with a CRM Node
391
+ #
392
+ # @overload get_workload(request, options = nil)
393
+ # Pass arguments to `get_workload` via a request object, either of type
394
+ # {::Google::Cloud::AssuredWorkloads::V1::GetWorkloadRequest} or an equivalent Hash.
395
+ #
396
+ # @param request [::Google::Cloud::AssuredWorkloads::V1::GetWorkloadRequest, ::Hash]
397
+ # A request object representing the call parameters. Required. To specify no
398
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
399
+ # @param options [::Gapic::CallOptions, ::Hash]
400
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
401
+ #
402
+ # @overload get_workload(name: nil)
403
+ # Pass arguments to `get_workload` via keyword arguments. Note that at
404
+ # least one keyword argument is required. To specify no parameters, or to keep all
405
+ # the default parameter values, pass an empty Hash as a request object (see above).
406
+ #
407
+ # @param name [::String]
408
+ # Required. The resource name of the Workload to fetch. This is the workloads's
409
+ # relative path in the API, formatted as
410
+ # "organizations/\\{organization_id}/locations/\\{location_id}/workloads/\\{workload_id}".
411
+ # For example,
412
+ # "organizations/123/locations/us-east1/workloads/assured-workload-1".
413
+ #
414
+ # @yield [response, operation] Access the result along with the RPC operation
415
+ # @yieldparam response [::Google::Cloud::AssuredWorkloads::V1::Workload]
416
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
417
+ #
418
+ # @return [::Google::Cloud::AssuredWorkloads::V1::Workload]
419
+ #
420
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
421
+ #
422
+ def get_workload request, options = nil
423
+ raise ::ArgumentError, "request must be provided" if request.nil?
424
+
425
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AssuredWorkloads::V1::GetWorkloadRequest
426
+
427
+ # Converts hash and nil to an options object
428
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
429
+
430
+ # Customize the options with defaults
431
+ metadata = @config.rpcs.get_workload.metadata.to_h
432
+
433
+ # Set x-goog-api-client and x-goog-user-project headers
434
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
435
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
436
+ gapic_version: ::Google::Cloud::AssuredWorkloads::V1::VERSION
437
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
438
+
439
+ header_params = {
440
+ "name" => request.name
441
+ }
442
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
443
+ metadata[:"x-goog-request-params"] ||= request_params_header
444
+
445
+ options.apply_defaults timeout: @config.rpcs.get_workload.timeout,
446
+ metadata: metadata,
447
+ retry_policy: @config.rpcs.get_workload.retry_policy
448
+
449
+ options.apply_defaults timeout: @config.timeout,
450
+ metadata: @config.metadata,
451
+ retry_policy: @config.retry_policy
452
+
453
+ @assured_workloads_service_stub.call_rpc :get_workload, request, options: options do |response, operation|
454
+ yield response, operation if block_given?
455
+ return response
456
+ end
457
+ rescue ::GRPC::BadStatus => e
458
+ raise ::Google::Cloud::Error.from_error(e)
459
+ end
460
+
461
+ ##
462
+ # Lists Assured Workloads under a CRM Node.
463
+ #
464
+ # @overload list_workloads(request, options = nil)
465
+ # Pass arguments to `list_workloads` via a request object, either of type
466
+ # {::Google::Cloud::AssuredWorkloads::V1::ListWorkloadsRequest} or an equivalent Hash.
467
+ #
468
+ # @param request [::Google::Cloud::AssuredWorkloads::V1::ListWorkloadsRequest, ::Hash]
469
+ # A request object representing the call parameters. Required. To specify no
470
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
471
+ # @param options [::Gapic::CallOptions, ::Hash]
472
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
473
+ #
474
+ # @overload list_workloads(parent: nil, page_size: nil, page_token: nil, filter: nil)
475
+ # Pass arguments to `list_workloads` via keyword arguments. Note that at
476
+ # least one keyword argument is required. To specify no parameters, or to keep all
477
+ # the default parameter values, pass an empty Hash as a request object (see above).
478
+ #
479
+ # @param parent [::String]
480
+ # Required. Parent Resource to list workloads from.
481
+ # Must be of the form `organizations/{org_id}/locations/{location}`.
482
+ # @param page_size [::Integer]
483
+ # Page size.
484
+ # @param page_token [::String]
485
+ # Page token returned from previous request. Page token contains context from
486
+ # previous request. Page token needs to be passed in the second and following
487
+ # requests.
488
+ # @param filter [::String]
489
+ # A custom filter for filtering by properties of a workload. At this time,
490
+ # only filtering by labels is supported.
491
+ #
492
+ # @yield [response, operation] Access the result along with the RPC operation
493
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::AssuredWorkloads::V1::Workload>]
494
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
495
+ #
496
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::AssuredWorkloads::V1::Workload>]
497
+ #
498
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
499
+ #
500
+ def list_workloads request, options = nil
501
+ raise ::ArgumentError, "request must be provided" if request.nil?
502
+
503
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AssuredWorkloads::V1::ListWorkloadsRequest
504
+
505
+ # Converts hash and nil to an options object
506
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
507
+
508
+ # Customize the options with defaults
509
+ metadata = @config.rpcs.list_workloads.metadata.to_h
510
+
511
+ # Set x-goog-api-client and x-goog-user-project headers
512
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
513
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
514
+ gapic_version: ::Google::Cloud::AssuredWorkloads::V1::VERSION
515
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
516
+
517
+ header_params = {
518
+ "parent" => request.parent
519
+ }
520
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
521
+ metadata[:"x-goog-request-params"] ||= request_params_header
522
+
523
+ options.apply_defaults timeout: @config.rpcs.list_workloads.timeout,
524
+ metadata: metadata,
525
+ retry_policy: @config.rpcs.list_workloads.retry_policy
526
+
527
+ options.apply_defaults timeout: @config.timeout,
528
+ metadata: @config.metadata,
529
+ retry_policy: @config.retry_policy
530
+
531
+ @assured_workloads_service_stub.call_rpc :list_workloads, request, options: options do |response, operation|
532
+ response = ::Gapic::PagedEnumerable.new @assured_workloads_service_stub, :list_workloads, request, response, operation, options
533
+ yield response, operation if block_given?
534
+ return response
535
+ end
536
+ rescue ::GRPC::BadStatus => e
537
+ raise ::Google::Cloud::Error.from_error(e)
538
+ end
539
+
540
+ ##
541
+ # Configuration class for the AssuredWorkloadsService API.
542
+ #
543
+ # This class represents the configuration for AssuredWorkloadsService,
544
+ # providing control over timeouts, retry behavior, logging, transport
545
+ # parameters, and other low-level controls. Certain parameters can also be
546
+ # applied individually to specific RPCs. See
547
+ # {::Google::Cloud::AssuredWorkloads::V1::AssuredWorkloadsService::Client::Configuration::Rpcs}
548
+ # for a list of RPCs that can be configured independently.
549
+ #
550
+ # Configuration can be applied globally to all clients, or to a single client
551
+ # on construction.
552
+ #
553
+ # @example
554
+ #
555
+ # # Modify the global config, setting the timeout for
556
+ # # create_workload to 20 seconds,
557
+ # # and all remaining timeouts to 10 seconds.
558
+ # ::Google::Cloud::AssuredWorkloads::V1::AssuredWorkloadsService::Client.configure do |config|
559
+ # config.timeout = 10.0
560
+ # config.rpcs.create_workload.timeout = 20.0
561
+ # end
562
+ #
563
+ # # Apply the above configuration only to a new client.
564
+ # client = ::Google::Cloud::AssuredWorkloads::V1::AssuredWorkloadsService::Client.new do |config|
565
+ # config.timeout = 10.0
566
+ # config.rpcs.create_workload.timeout = 20.0
567
+ # end
568
+ #
569
+ # @!attribute [rw] endpoint
570
+ # The hostname or hostname:port of the service endpoint.
571
+ # Defaults to `"assuredworkloads.googleapis.com"`.
572
+ # @return [::String]
573
+ # @!attribute [rw] credentials
574
+ # Credentials to send with calls. You may provide any of the following types:
575
+ # * (`String`) The path to a service account key file in JSON format
576
+ # * (`Hash`) A service account key as a Hash
577
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
578
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
579
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
580
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
581
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
582
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
583
+ # * (`nil`) indicating no credentials
584
+ # @return [::Object]
585
+ # @!attribute [rw] scope
586
+ # The OAuth scopes
587
+ # @return [::Array<::String>]
588
+ # @!attribute [rw] lib_name
589
+ # The library name as recorded in instrumentation and logging
590
+ # @return [::String]
591
+ # @!attribute [rw] lib_version
592
+ # The library version as recorded in instrumentation and logging
593
+ # @return [::String]
594
+ # @!attribute [rw] channel_args
595
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
596
+ # `GRPC::Core::Channel` object is provided as the credential.
597
+ # @return [::Hash]
598
+ # @!attribute [rw] interceptors
599
+ # An array of interceptors that are run before calls are executed.
600
+ # @return [::Array<::GRPC::ClientInterceptor>]
601
+ # @!attribute [rw] timeout
602
+ # The call timeout in seconds.
603
+ # @return [::Numeric]
604
+ # @!attribute [rw] metadata
605
+ # Additional gRPC headers to be sent with the call.
606
+ # @return [::Hash{::Symbol=>::String}]
607
+ # @!attribute [rw] retry_policy
608
+ # The retry policy. The value is a hash with the following keys:
609
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
610
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
611
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
612
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
613
+ # trigger a retry.
614
+ # @return [::Hash]
615
+ # @!attribute [rw] quota_project
616
+ # A separate project against which to charge quota.
617
+ # @return [::String]
618
+ #
619
+ class Configuration
620
+ extend ::Gapic::Config
621
+
622
+ config_attr :endpoint, "assuredworkloads.googleapis.com", ::String
623
+ config_attr :credentials, nil do |value|
624
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
625
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
626
+ allowed.any? { |klass| klass === value }
627
+ end
628
+ config_attr :scope, nil, ::String, ::Array, nil
629
+ config_attr :lib_name, nil, ::String, nil
630
+ config_attr :lib_version, nil, ::String, nil
631
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
632
+ config_attr :interceptors, nil, ::Array, nil
633
+ config_attr :timeout, nil, ::Numeric, nil
634
+ config_attr :metadata, nil, ::Hash, nil
635
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
636
+ config_attr :quota_project, nil, ::String, nil
637
+
638
+ # @private
639
+ def initialize parent_config = nil
640
+ @parent_config = parent_config unless parent_config.nil?
641
+
642
+ yield self if block_given?
643
+ end
644
+
645
+ ##
646
+ # Configurations for individual RPCs
647
+ # @return [Rpcs]
648
+ #
649
+ def rpcs
650
+ @rpcs ||= begin
651
+ parent_rpcs = nil
652
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
653
+ Rpcs.new parent_rpcs
654
+ end
655
+ end
656
+
657
+ ##
658
+ # Configuration RPC class for the AssuredWorkloadsService API.
659
+ #
660
+ # Includes fields providing the configuration for each RPC in this service.
661
+ # Each configuration object is of type `Gapic::Config::Method` and includes
662
+ # the following configuration fields:
663
+ #
664
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
665
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
666
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
667
+ # include the following keys:
668
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
669
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
670
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
671
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
672
+ # trigger a retry.
673
+ #
674
+ class Rpcs
675
+ ##
676
+ # RPC-specific configuration for `create_workload`
677
+ # @return [::Gapic::Config::Method]
678
+ #
679
+ attr_reader :create_workload
680
+ ##
681
+ # RPC-specific configuration for `update_workload`
682
+ # @return [::Gapic::Config::Method]
683
+ #
684
+ attr_reader :update_workload
685
+ ##
686
+ # RPC-specific configuration for `delete_workload`
687
+ # @return [::Gapic::Config::Method]
688
+ #
689
+ attr_reader :delete_workload
690
+ ##
691
+ # RPC-specific configuration for `get_workload`
692
+ # @return [::Gapic::Config::Method]
693
+ #
694
+ attr_reader :get_workload
695
+ ##
696
+ # RPC-specific configuration for `list_workloads`
697
+ # @return [::Gapic::Config::Method]
698
+ #
699
+ attr_reader :list_workloads
700
+
701
+ # @private
702
+ def initialize parent_rpcs = nil
703
+ create_workload_config = parent_rpcs.create_workload if parent_rpcs.respond_to? :create_workload
704
+ @create_workload = ::Gapic::Config::Method.new create_workload_config
705
+ update_workload_config = parent_rpcs.update_workload if parent_rpcs.respond_to? :update_workload
706
+ @update_workload = ::Gapic::Config::Method.new update_workload_config
707
+ delete_workload_config = parent_rpcs.delete_workload if parent_rpcs.respond_to? :delete_workload
708
+ @delete_workload = ::Gapic::Config::Method.new delete_workload_config
709
+ get_workload_config = parent_rpcs.get_workload if parent_rpcs.respond_to? :get_workload
710
+ @get_workload = ::Gapic::Config::Method.new get_workload_config
711
+ list_workloads_config = parent_rpcs.list_workloads if parent_rpcs.respond_to? :list_workloads
712
+ @list_workloads = ::Gapic::Config::Method.new list_workloads_config
713
+
714
+ yield self if block_given?
715
+ end
716
+ end
717
+ end
718
+ end
719
+ end
720
+ end
721
+ end
722
+ end
723
+ end