google-cloud-compute-v1 2.20.0 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,661 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2025 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/compute/v1/compute_pb"
21
+ require "google/cloud/compute/v1/reservation_blocks/rest/service_stub"
22
+ require "google/cloud/compute/v1/zone_operations/rest"
23
+
24
+ module Google
25
+ module Cloud
26
+ module Compute
27
+ module V1
28
+ module ReservationBlocks
29
+ module Rest
30
+ ##
31
+ # REST client for the ReservationBlocks service.
32
+ #
33
+ # The ReservationBlocks API.
34
+ #
35
+ class Client
36
+ # @private
37
+ API_VERSION = ""
38
+
39
+ # @private
40
+ DEFAULT_ENDPOINT_TEMPLATE = "compute.$UNIVERSE_DOMAIN$"
41
+
42
+ # @private
43
+ attr_reader :reservation_blocks_stub
44
+
45
+ ##
46
+ # Configure the ReservationBlocks Client class.
47
+ #
48
+ # See {::Google::Cloud::Compute::V1::ReservationBlocks::Rest::Client::Configuration}
49
+ # for a description of the configuration fields.
50
+ #
51
+ # @example
52
+ #
53
+ # # Modify the configuration for all ReservationBlocks clients
54
+ # ::Google::Cloud::Compute::V1::ReservationBlocks::Rest::Client.configure do |config|
55
+ # config.timeout = 10.0
56
+ # end
57
+ #
58
+ # @yield [config] Configure the Client client.
59
+ # @yieldparam config [Client::Configuration]
60
+ #
61
+ # @return [Client::Configuration]
62
+ #
63
+ def self.configure
64
+ @configure ||= begin
65
+ namespace = ["Google", "Cloud", "Compute", "V1"]
66
+ parent_config = while namespace.any?
67
+ parent_name = namespace.join "::"
68
+ parent_const = const_get parent_name
69
+ break parent_const.configure if parent_const.respond_to? :configure
70
+ namespace.pop
71
+ end
72
+ default_config = Client::Configuration.new parent_config
73
+
74
+ default_config.rpcs.get.timeout = 600.0
75
+ default_config.rpcs.get.retry_policy = {
76
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
77
+ }
78
+
79
+ default_config.rpcs.list.timeout = 600.0
80
+ default_config.rpcs.list.retry_policy = {
81
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
82
+ }
83
+
84
+ default_config.rpcs.perform_maintenance.timeout = 600.0
85
+
86
+ default_config
87
+ end
88
+ yield @configure if block_given?
89
+ @configure
90
+ end
91
+
92
+ ##
93
+ # Configure the ReservationBlocks Client instance.
94
+ #
95
+ # The configuration is set to the derived mode, meaning that values can be changed,
96
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
97
+ # should be made on {Client.configure}.
98
+ #
99
+ # See {::Google::Cloud::Compute::V1::ReservationBlocks::Rest::Client::Configuration}
100
+ # for a description of the configuration fields.
101
+ #
102
+ # @yield [config] Configure the Client client.
103
+ # @yieldparam config [Client::Configuration]
104
+ #
105
+ # @return [Client::Configuration]
106
+ #
107
+ def configure
108
+ yield @config if block_given?
109
+ @config
110
+ end
111
+
112
+ ##
113
+ # The effective universe domain
114
+ #
115
+ # @return [String]
116
+ #
117
+ def universe_domain
118
+ @reservation_blocks_stub.universe_domain
119
+ end
120
+
121
+ ##
122
+ # Create a new ReservationBlocks REST client object.
123
+ #
124
+ # @example
125
+ #
126
+ # # Create a client using the default configuration
127
+ # client = ::Google::Cloud::Compute::V1::ReservationBlocks::Rest::Client.new
128
+ #
129
+ # # Create a client using a custom configuration
130
+ # client = ::Google::Cloud::Compute::V1::ReservationBlocks::Rest::Client.new do |config|
131
+ # config.timeout = 10.0
132
+ # end
133
+ #
134
+ # @yield [config] Configure the ReservationBlocks client.
135
+ # @yieldparam config [Client::Configuration]
136
+ #
137
+ def initialize
138
+ # Create the configuration object
139
+ @config = Configuration.new Client.configure
140
+
141
+ # Yield the configuration if needed
142
+ yield @config if block_given?
143
+
144
+ # Create credentials
145
+ credentials = @config.credentials
146
+ # Use self-signed JWT if the endpoint is unchanged from default,
147
+ # but only if the default endpoint does not have a region prefix.
148
+ enable_self_signed_jwt = @config.endpoint.nil? ||
149
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
150
+ !@config.endpoint.split(".").first.include?("-"))
151
+ credentials ||= Credentials.default scope: @config.scope,
152
+ enable_self_signed_jwt: enable_self_signed_jwt
153
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
154
+ credentials = Credentials.new credentials, scope: @config.scope
155
+ end
156
+
157
+ @quota_project_id = @config.quota_project
158
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
159
+
160
+ @zone_operations = ::Google::Cloud::Compute::V1::ZoneOperations::Rest::Client.new do |config|
161
+ config.credentials = credentials
162
+ config.quota_project = @quota_project_id
163
+ config.endpoint = @config.endpoint
164
+ config.universe_domain = @config.universe_domain
165
+ end
166
+
167
+ @reservation_blocks_stub = ::Google::Cloud::Compute::V1::ReservationBlocks::Rest::ServiceStub.new(
168
+ endpoint: @config.endpoint,
169
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
170
+ universe_domain: @config.universe_domain,
171
+ credentials: credentials,
172
+ logger: @config.logger
173
+ )
174
+
175
+ @reservation_blocks_stub.logger(stub: true)&.info do |entry|
176
+ entry.set_system_name
177
+ entry.set_service
178
+ entry.message = "Created client for #{entry.service}"
179
+ entry.set_credentials_fields credentials
180
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
181
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
182
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
183
+ end
184
+ end
185
+
186
+ ##
187
+ # Get the associated client for long-running operations via ZoneOperations.
188
+ #
189
+ # @return [::Google::Cloud::Compute::V1::ZoneOperations::Rest::Client]
190
+ #
191
+ attr_reader :zone_operations
192
+
193
+ ##
194
+ # The logger used for request/response debug logging.
195
+ #
196
+ # @return [Logger]
197
+ #
198
+ def logger
199
+ @reservation_blocks_stub.logger
200
+ end
201
+
202
+ # Service calls
203
+
204
+ ##
205
+ # Retrieves information about the specified reservation block.
206
+ #
207
+ # @overload get(request, options = nil)
208
+ # Pass arguments to `get` via a request object, either of type
209
+ # {::Google::Cloud::Compute::V1::GetReservationBlockRequest} or an equivalent Hash.
210
+ #
211
+ # @param request [::Google::Cloud::Compute::V1::GetReservationBlockRequest, ::Hash]
212
+ # A request object representing the call parameters. Required. To specify no
213
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
214
+ # @param options [::Gapic::CallOptions, ::Hash]
215
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
216
+ #
217
+ # @overload get(project: nil, reservation: nil, reservation_block: nil, zone: nil)
218
+ # Pass arguments to `get` via keyword arguments. Note that at
219
+ # least one keyword argument is required. To specify no parameters, or to keep all
220
+ # the default parameter values, pass an empty Hash as a request object (see above).
221
+ #
222
+ # @param project [::String]
223
+ # Project ID for this request.
224
+ # @param reservation [::String]
225
+ # The name of the reservation. Name should conform to RFC1035 or be a resource ID.
226
+ # @param reservation_block [::String]
227
+ # The name of the reservation block. Name should conform to RFC1035 or be a resource ID.
228
+ # @param zone [::String]
229
+ # Name of the zone for this request. Zone name should conform to RFC1035.
230
+ # @yield [result, operation] Access the result along with the TransportOperation object
231
+ # @yieldparam result [::Google::Cloud::Compute::V1::ReservationBlocksGetResponse]
232
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
233
+ #
234
+ # @return [::Google::Cloud::Compute::V1::ReservationBlocksGetResponse]
235
+ #
236
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
237
+ #
238
+ # @example Basic example
239
+ # require "google/cloud/compute/v1"
240
+ #
241
+ # # Create a client object. The client can be reused for multiple calls.
242
+ # client = Google::Cloud::Compute::V1::ReservationBlocks::Rest::Client.new
243
+ #
244
+ # # Create a request. To set request fields, pass in keyword arguments.
245
+ # request = Google::Cloud::Compute::V1::GetReservationBlockRequest.new
246
+ #
247
+ # # Call the get method.
248
+ # result = client.get request
249
+ #
250
+ # # The returned object is of type Google::Cloud::Compute::V1::ReservationBlocksGetResponse.
251
+ # p result
252
+ #
253
+ def get request, options = nil
254
+ raise ::ArgumentError, "request must be provided" if request.nil?
255
+
256
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Compute::V1::GetReservationBlockRequest
257
+
258
+ # Converts hash and nil to an options object
259
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
260
+
261
+ # Customize the options with defaults
262
+ call_metadata = @config.rpcs.get.metadata.to_h
263
+
264
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
265
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
266
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
267
+ gapic_version: ::Google::Cloud::Compute::V1::VERSION,
268
+ transports_version_send: [:rest]
269
+
270
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
271
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
272
+
273
+ options.apply_defaults timeout: @config.rpcs.get.timeout,
274
+ metadata: call_metadata,
275
+ retry_policy: @config.rpcs.get.retry_policy
276
+
277
+ options.apply_defaults timeout: @config.timeout,
278
+ metadata: @config.metadata,
279
+ retry_policy: @config.retry_policy
280
+
281
+ @reservation_blocks_stub.get request, options do |result, operation|
282
+ yield result, operation if block_given?
283
+ end
284
+ rescue ::Gapic::Rest::Error => e
285
+ raise ::Google::Cloud::Error.from_error(e)
286
+ end
287
+
288
+ ##
289
+ # Retrieves a list of reservation blocks under a single reservation.
290
+ #
291
+ # @overload list(request, options = nil)
292
+ # Pass arguments to `list` via a request object, either of type
293
+ # {::Google::Cloud::Compute::V1::ListReservationBlocksRequest} or an equivalent Hash.
294
+ #
295
+ # @param request [::Google::Cloud::Compute::V1::ListReservationBlocksRequest, ::Hash]
296
+ # A request object representing the call parameters. Required. To specify no
297
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
298
+ # @param options [::Gapic::CallOptions, ::Hash]
299
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
300
+ #
301
+ # @overload list(filter: nil, max_results: nil, order_by: nil, page_token: nil, project: nil, reservation: nil, return_partial_success: nil, zone: nil)
302
+ # Pass arguments to `list` via keyword arguments. Note that at
303
+ # least one keyword argument is required. To specify no parameters, or to keep all
304
+ # the default parameter values, pass an empty Hash as a request object (see above).
305
+ #
306
+ # @param filter [::String]
307
+ # A filter expression that filters resources listed in the response. Most Compute resources support two types of filter expressions: expressions that support regular expressions and expressions that follow API improvement proposal AIP-160. These two types of filter expressions cannot be mixed in one request. If you want to use AIP-160, your expression must specify the field name, an operator, and the value that you want to use for filtering. The value must be a string, a number, or a boolean. The operator must be either `=`, `!=`, `>`, `<`, `<=`, `>=` or `:`. For example, if you are filtering Compute Engine instances, you can exclude instances named `example-instance` by specifying `name != example-instance`. The `:*` comparison can be used to test whether a key has been defined. For example, to find all objects with `owner` label use: ``` labels.owner:* ``` You can also filter nested fields. For example, you could specify `scheduling.automaticRestart = false` to include instances only if they are not scheduled for automatic restarts. You can use filtering on nested fields to filter based on resource labels. To filter on multiple expressions, provide each separate expression within parentheses. For example: ``` (scheduling.automaticRestart = true) (cpuPlatform = "Intel Skylake") ``` By default, each expression is an `AND` expression. However, you can include `AND` and `OR` expressions explicitly. For example: ``` (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") AND (scheduling.automaticRestart = true) ``` If you want to use a regular expression, use the `eq` (equal) or `ne` (not equal) operator against a single un-parenthesized expression with or without quotes or against multiple parenthesized expressions. Examples: `fieldname eq unquoted literal` `fieldname eq 'single quoted literal'` `fieldname eq "double quoted literal"` `(fieldname1 eq literal) (fieldname2 ne "literal")` The literal value is interpreted as a regular expression using Google RE2 library syntax. The literal value must match the entire field. For example, to filter for instances that do not end with name "instance", you would use `name ne .*instance`. You cannot combine constraints on multiple fields using regular expressions.
308
+ # @param max_results [::Integer]
309
+ # The maximum number of results per page that should be returned. If the number of available results is larger than `maxResults`, Compute Engine returns a `nextPageToken` that can be used to get the next page of results in subsequent list requests. Acceptable values are `0` to `500`, inclusive. (Default: `500`)
310
+ # @param order_by [::String]
311
+ # Sorts list results by a certain order. By default, results are returned in alphanumerical order based on the resource name. You can also sort results in descending order based on the creation timestamp using `orderBy="creationTimestamp desc"`. This sorts results based on the `creationTimestamp` field in reverse chronological order (newest result first). Use this to sort resources like operations so that the newest operation is returned first. Currently, only sorting by `name` or `creationTimestamp desc` is supported.
312
+ # @param page_token [::String]
313
+ # Specifies a page token to use. Set `pageToken` to the `nextPageToken` returned by a previous list request to get the next page of results.
314
+ # @param project [::String]
315
+ # Project ID for this request.
316
+ # @param reservation [::String]
317
+ # The name of the reservation. Name should conform to RFC1035 or be a resource ID.
318
+ # @param return_partial_success [::Boolean]
319
+ # Opt-in for partial success behavior which provides partial results in case of failure. The default value is false. For example, when partial success behavior is enabled, aggregatedList for a single zone scope either returns all resources in the zone or no resources, with an error code.
320
+ # @param zone [::String]
321
+ # Name of the zone for this request. Zone name should conform to RFC1035.
322
+ # @yield [result, operation] Access the result along with the TransportOperation object
323
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::ReservationBlock>]
324
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
325
+ #
326
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Compute::V1::ReservationBlock>]
327
+ #
328
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
329
+ #
330
+ # @example Basic example
331
+ # require "google/cloud/compute/v1"
332
+ #
333
+ # # Create a client object. The client can be reused for multiple calls.
334
+ # client = Google::Cloud::Compute::V1::ReservationBlocks::Rest::Client.new
335
+ #
336
+ # # Create a request. To set request fields, pass in keyword arguments.
337
+ # request = Google::Cloud::Compute::V1::ListReservationBlocksRequest.new
338
+ #
339
+ # # Call the list method.
340
+ # result = client.list request
341
+ #
342
+ # # The returned object is of type Google::Cloud::Compute::V1::ReservationBlocksListResponse.
343
+ # p result
344
+ #
345
+ def list request, options = nil
346
+ raise ::ArgumentError, "request must be provided" if request.nil?
347
+
348
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Compute::V1::ListReservationBlocksRequest
349
+
350
+ # Converts hash and nil to an options object
351
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
352
+
353
+ # Customize the options with defaults
354
+ call_metadata = @config.rpcs.list.metadata.to_h
355
+
356
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
357
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
358
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
359
+ gapic_version: ::Google::Cloud::Compute::V1::VERSION,
360
+ transports_version_send: [:rest]
361
+
362
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
363
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
364
+
365
+ options.apply_defaults timeout: @config.rpcs.list.timeout,
366
+ metadata: call_metadata,
367
+ retry_policy: @config.rpcs.list.retry_policy
368
+
369
+ options.apply_defaults timeout: @config.timeout,
370
+ metadata: @config.metadata,
371
+ retry_policy: @config.retry_policy
372
+
373
+ @reservation_blocks_stub.list request, options do |result, operation|
374
+ result = ::Gapic::Rest::PagedEnumerable.new @reservation_blocks_stub, :list, "items", request, result, options
375
+ yield result, operation if block_given?
376
+ throw :response, result
377
+ end
378
+ rescue ::Gapic::Rest::Error => e
379
+ raise ::Google::Cloud::Error.from_error(e)
380
+ end
381
+
382
+ ##
383
+ # Allows customers to perform maintenance on a reservation block
384
+ #
385
+ # @overload perform_maintenance(request, options = nil)
386
+ # Pass arguments to `perform_maintenance` via a request object, either of type
387
+ # {::Google::Cloud::Compute::V1::PerformMaintenanceReservationBlockRequest} or an equivalent Hash.
388
+ #
389
+ # @param request [::Google::Cloud::Compute::V1::PerformMaintenanceReservationBlockRequest, ::Hash]
390
+ # A request object representing the call parameters. Required. To specify no
391
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
392
+ # @param options [::Gapic::CallOptions, ::Hash]
393
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
394
+ #
395
+ # @overload perform_maintenance(project: nil, request_id: nil, reservation: nil, reservation_block: nil, reservations_blocks_perform_maintenance_request_resource: nil, zone: nil)
396
+ # Pass arguments to `perform_maintenance` via keyword arguments. Note that at
397
+ # least one keyword argument is required. To specify no parameters, or to keep all
398
+ # the default parameter values, pass an empty Hash as a request object (see above).
399
+ #
400
+ # @param project [::String]
401
+ # Project ID for this request.
402
+ # @param request_id [::String]
403
+ # An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server will know to ignore the request if it has already been completed. For example, consider a situation where you make an initial request and the request times out. If you make the request again with the same request ID, the server can check if original operation with the same request ID was received, and if so, will ignore the second request. This prevents clients from accidentally creating duplicate commitments. The request ID must be a valid UUID with the exception that zero UUID is not supported ( 00000000-0000-0000-0000-000000000000).
404
+ # @param reservation [::String]
405
+ # The name of the reservation. Name should conform to RFC1035 or be a resource ID.
406
+ # @param reservation_block [::String]
407
+ # The name of the reservation block. Name should conform to RFC1035 or be a resource ID.
408
+ # @param reservations_blocks_perform_maintenance_request_resource [::Google::Cloud::Compute::V1::ReservationsBlocksPerformMaintenanceRequest, ::Hash]
409
+ # The body resource for this request
410
+ # @param zone [::String]
411
+ # Name of the zone for this request. Zone name should conform to RFC1035.
412
+ # @yield [result, operation] Access the result along with the TransportOperation object
413
+ # @yieldparam result [::Gapic::GenericLRO::Operation]
414
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
415
+ #
416
+ # @return [::Gapic::GenericLRO::Operation]
417
+ #
418
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
419
+ #
420
+ # @example Basic example
421
+ # require "google/cloud/compute/v1"
422
+ #
423
+ # # Create a client object. The client can be reused for multiple calls.
424
+ # client = Google::Cloud::Compute::V1::ReservationBlocks::Rest::Client.new
425
+ #
426
+ # # Create a request. To set request fields, pass in keyword arguments.
427
+ # request = Google::Cloud::Compute::V1::PerformMaintenanceReservationBlockRequest.new
428
+ #
429
+ # # Call the perform_maintenance method.
430
+ # result = client.perform_maintenance request
431
+ #
432
+ # # The returned object is of type Google::Cloud::Compute::V1::Operation.
433
+ # p result
434
+ #
435
+ def perform_maintenance request, options = nil
436
+ raise ::ArgumentError, "request must be provided" if request.nil?
437
+
438
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Compute::V1::PerformMaintenanceReservationBlockRequest
439
+
440
+ # Converts hash and nil to an options object
441
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
442
+
443
+ # Customize the options with defaults
444
+ call_metadata = @config.rpcs.perform_maintenance.metadata.to_h
445
+
446
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
447
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
448
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
449
+ gapic_version: ::Google::Cloud::Compute::V1::VERSION,
450
+ transports_version_send: [:rest]
451
+
452
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
453
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
454
+
455
+ options.apply_defaults timeout: @config.rpcs.perform_maintenance.timeout,
456
+ metadata: call_metadata,
457
+ retry_policy: @config.rpcs.perform_maintenance.retry_policy
458
+
459
+ options.apply_defaults timeout: @config.timeout,
460
+ metadata: @config.metadata,
461
+ retry_policy: @config.retry_policy
462
+
463
+ @reservation_blocks_stub.perform_maintenance request, options do |result, response|
464
+ result = ::Google::Cloud::Compute::V1::ZoneOperations::Rest::NonstandardLro.create_operation(
465
+ operation: result,
466
+ client: zone_operations,
467
+ request_values: {
468
+ "project" => request.project,
469
+ "zone" => request.zone
470
+ },
471
+ options: options
472
+ )
473
+ yield result, response if block_given?
474
+ throw :response, result
475
+ end
476
+ rescue ::Gapic::Rest::Error => e
477
+ raise ::Google::Cloud::Error.from_error(e)
478
+ end
479
+
480
+ ##
481
+ # Configuration class for the ReservationBlocks REST API.
482
+ #
483
+ # This class represents the configuration for ReservationBlocks REST,
484
+ # providing control over timeouts, retry behavior, logging, transport
485
+ # parameters, and other low-level controls. Certain parameters can also be
486
+ # applied individually to specific RPCs. See
487
+ # {::Google::Cloud::Compute::V1::ReservationBlocks::Rest::Client::Configuration::Rpcs}
488
+ # for a list of RPCs that can be configured independently.
489
+ #
490
+ # Configuration can be applied globally to all clients, or to a single client
491
+ # on construction.
492
+ #
493
+ # @example
494
+ #
495
+ # # Modify the global config, setting the timeout for
496
+ # # get to 20 seconds,
497
+ # # and all remaining timeouts to 10 seconds.
498
+ # ::Google::Cloud::Compute::V1::ReservationBlocks::Rest::Client.configure do |config|
499
+ # config.timeout = 10.0
500
+ # config.rpcs.get.timeout = 20.0
501
+ # end
502
+ #
503
+ # # Apply the above configuration only to a new client.
504
+ # client = ::Google::Cloud::Compute::V1::ReservationBlocks::Rest::Client.new do |config|
505
+ # config.timeout = 10.0
506
+ # config.rpcs.get.timeout = 20.0
507
+ # end
508
+ #
509
+ # @!attribute [rw] endpoint
510
+ # A custom service endpoint, as a hostname or hostname:port. The default is
511
+ # nil, indicating to use the default endpoint in the current universe domain.
512
+ # @return [::String,nil]
513
+ # @!attribute [rw] credentials
514
+ # Credentials to send with calls. You may provide any of the following types:
515
+ # * (`String`) The path to a service account key file in JSON format
516
+ # * (`Hash`) A service account key as a Hash
517
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
518
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
519
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
520
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
521
+ # * (`nil`) indicating no credentials
522
+ #
523
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
524
+ # external source for authentication to Google Cloud, you must validate it before
525
+ # providing it to a Google API client library. Providing an unvalidated credential
526
+ # configuration to Google APIs can compromise the security of your systems and data.
527
+ # For more information, refer to [Validate credential configurations from external
528
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
529
+ # @return [::Object]
530
+ # @!attribute [rw] scope
531
+ # The OAuth scopes
532
+ # @return [::Array<::String>]
533
+ # @!attribute [rw] lib_name
534
+ # The library name as recorded in instrumentation and logging
535
+ # @return [::String]
536
+ # @!attribute [rw] lib_version
537
+ # The library version as recorded in instrumentation and logging
538
+ # @return [::String]
539
+ # @!attribute [rw] timeout
540
+ # The call timeout in seconds.
541
+ # @return [::Numeric]
542
+ # @!attribute [rw] metadata
543
+ # Additional headers to be sent with the call.
544
+ # @return [::Hash{::Symbol=>::String}]
545
+ # @!attribute [rw] retry_policy
546
+ # The retry policy. The value is a hash with the following keys:
547
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
548
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
549
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
550
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
551
+ # trigger a retry.
552
+ # @return [::Hash]
553
+ # @!attribute [rw] quota_project
554
+ # A separate project against which to charge quota.
555
+ # @return [::String]
556
+ # @!attribute [rw] universe_domain
557
+ # The universe domain within which to make requests. This determines the
558
+ # default endpoint URL. The default value of nil uses the environment
559
+ # universe (usually the default "googleapis.com" universe).
560
+ # @return [::String,nil]
561
+ # @!attribute [rw] logger
562
+ # A custom logger to use for request/response debug logging, or the value
563
+ # `:default` (the default) to construct a default logger, or `nil` to
564
+ # explicitly disable logging.
565
+ # @return [::Logger,:default,nil]
566
+ #
567
+ class Configuration
568
+ extend ::Gapic::Config
569
+
570
+ # @private
571
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
572
+ DEFAULT_ENDPOINT = "compute.googleapis.com"
573
+
574
+ config_attr :endpoint, nil, ::String, nil
575
+ config_attr :credentials, nil do |value|
576
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
577
+ allowed.any? { |klass| klass === value }
578
+ end
579
+ config_attr :scope, nil, ::String, ::Array, nil
580
+ config_attr :lib_name, nil, ::String, nil
581
+ config_attr :lib_version, nil, ::String, nil
582
+ config_attr :timeout, nil, ::Numeric, nil
583
+ config_attr :metadata, nil, ::Hash, nil
584
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
585
+ config_attr :quota_project, nil, ::String, nil
586
+ config_attr :universe_domain, nil, ::String, nil
587
+ config_attr :logger, :default, ::Logger, nil, :default
588
+
589
+ # @private
590
+ def initialize parent_config = nil
591
+ @parent_config = parent_config unless parent_config.nil?
592
+
593
+ yield self if block_given?
594
+ end
595
+
596
+ ##
597
+ # Configurations for individual RPCs
598
+ # @return [Rpcs]
599
+ #
600
+ def rpcs
601
+ @rpcs ||= begin
602
+ parent_rpcs = nil
603
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
604
+ Rpcs.new parent_rpcs
605
+ end
606
+ end
607
+
608
+ ##
609
+ # Configuration RPC class for the ReservationBlocks API.
610
+ #
611
+ # Includes fields providing the configuration for each RPC in this service.
612
+ # Each configuration object is of type `Gapic::Config::Method` and includes
613
+ # the following configuration fields:
614
+ #
615
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
616
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
617
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
618
+ # include the following keys:
619
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
620
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
621
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
622
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
623
+ # trigger a retry.
624
+ #
625
+ class Rpcs
626
+ ##
627
+ # RPC-specific configuration for `get`
628
+ # @return [::Gapic::Config::Method]
629
+ #
630
+ attr_reader :get
631
+ ##
632
+ # RPC-specific configuration for `list`
633
+ # @return [::Gapic::Config::Method]
634
+ #
635
+ attr_reader :list
636
+ ##
637
+ # RPC-specific configuration for `perform_maintenance`
638
+ # @return [::Gapic::Config::Method]
639
+ #
640
+ attr_reader :perform_maintenance
641
+
642
+ # @private
643
+ def initialize parent_rpcs = nil
644
+ get_config = parent_rpcs.get if parent_rpcs.respond_to? :get
645
+ @get = ::Gapic::Config::Method.new get_config
646
+ list_config = parent_rpcs.list if parent_rpcs.respond_to? :list
647
+ @list = ::Gapic::Config::Method.new list_config
648
+ perform_maintenance_config = parent_rpcs.perform_maintenance if parent_rpcs.respond_to? :perform_maintenance
649
+ @perform_maintenance = ::Gapic::Config::Method.new perform_maintenance_config
650
+
651
+ yield self if block_given?
652
+ end
653
+ end
654
+ end
655
+ end
656
+ end
657
+ end
658
+ end
659
+ end
660
+ end
661
+ end