google-cloud-assured_workloads-v1 0.5.0 → 0.6.0

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