google-cloud-storage_batch_operations-v1 0.a → 0.1.1

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +12 -0
  3. data/AUTHENTICATION.md +122 -0
  4. data/README.md +154 -8
  5. data/lib/google/cloud/storage_batch_operations/v1/bindings_override.rb +102 -0
  6. data/lib/google/cloud/storage_batch_operations/v1/rest.rb +38 -0
  7. data/lib/google/cloud/storage_batch_operations/v1/storage_batch_operations/client.rb +928 -0
  8. data/lib/google/cloud/storage_batch_operations/v1/storage_batch_operations/credentials.rb +47 -0
  9. data/lib/google/cloud/storage_batch_operations/v1/storage_batch_operations/operations.rb +813 -0
  10. data/lib/google/cloud/storage_batch_operations/v1/storage_batch_operations/paths.rb +90 -0
  11. data/lib/google/cloud/storage_batch_operations/v1/storage_batch_operations/rest/client.rb +875 -0
  12. data/lib/google/cloud/storage_batch_operations/v1/storage_batch_operations/rest/operations.rb +914 -0
  13. data/lib/google/cloud/storage_batch_operations/v1/storage_batch_operations/rest/service_stub.rb +388 -0
  14. data/lib/google/cloud/storage_batch_operations/v1/storage_batch_operations/rest.rb +57 -0
  15. data/lib/google/cloud/storage_batch_operations/v1/storage_batch_operations.rb +59 -0
  16. data/lib/google/cloud/storage_batch_operations/v1/version.rb +7 -2
  17. data/lib/google/cloud/storage_batch_operations/v1.rb +45 -0
  18. data/lib/google/cloud/storagebatchoperations/v1/storage_batch_operations_pb.rb +60 -0
  19. data/lib/google/cloud/storagebatchoperations/v1/storage_batch_operations_services_pb.rb +56 -0
  20. data/lib/google/cloud/storagebatchoperations/v1/storage_batch_operations_types_pb.rb +64 -0
  21. data/lib/google-cloud-storage_batch_operations-v1.rb +21 -0
  22. data/proto_docs/README.md +4 -0
  23. data/proto_docs/google/api/client.rb +473 -0
  24. data/proto_docs/google/api/field_behavior.rb +85 -0
  25. data/proto_docs/google/api/launch_stage.rb +71 -0
  26. data/proto_docs/google/api/resource.rb +227 -0
  27. data/proto_docs/google/cloud/storagebatchoperations/v1/storage_batch_operations.rb +167 -0
  28. data/proto_docs/google/cloud/storagebatchoperations/v1/storage_batch_operations_types.rb +372 -0
  29. data/proto_docs/google/longrunning/operations.rb +173 -0
  30. data/proto_docs/google/protobuf/any.rb +145 -0
  31. data/proto_docs/google/protobuf/duration.rb +98 -0
  32. data/proto_docs/google/protobuf/empty.rb +34 -0
  33. data/proto_docs/google/protobuf/timestamp.rb +127 -0
  34. data/proto_docs/google/rpc/code.rb +185 -0
  35. data/proto_docs/google/rpc/status.rb +48 -0
  36. metadata +95 -9
@@ -0,0 +1,928 @@
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/storagebatchoperations/v1/storage_batch_operations_pb"
21
+ require "google/cloud/location"
22
+
23
+ module Google
24
+ module Cloud
25
+ module StorageBatchOperations
26
+ module V1
27
+ module StorageBatchOperations
28
+ ##
29
+ # Client for the StorageBatchOperations service.
30
+ #
31
+ # Storage Batch Operations offers a managed experience to perform batch
32
+ # operations on millions of Cloud Storage objects in a serverless fashion. With
33
+ # this service, you can automate and simplify large scale API operations
34
+ # performed on Cloud Storage objects.
35
+ #
36
+ class Client
37
+ # @private
38
+ API_VERSION = ""
39
+
40
+ # @private
41
+ DEFAULT_ENDPOINT_TEMPLATE = "storagebatchoperations.$UNIVERSE_DOMAIN$"
42
+
43
+ include Paths
44
+
45
+ # @private
46
+ attr_reader :storage_batch_operations_stub
47
+
48
+ ##
49
+ # Configure the StorageBatchOperations Client class.
50
+ #
51
+ # See {::Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client::Configuration}
52
+ # for a description of the configuration fields.
53
+ #
54
+ # @example
55
+ #
56
+ # # Modify the configuration for all StorageBatchOperations clients
57
+ # ::Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client.configure do |config|
58
+ # config.timeout = 10.0
59
+ # end
60
+ #
61
+ # @yield [config] Configure the Client client.
62
+ # @yieldparam config [Client::Configuration]
63
+ #
64
+ # @return [Client::Configuration]
65
+ #
66
+ def self.configure
67
+ @configure ||= begin
68
+ namespace = ["Google", "Cloud", "StorageBatchOperations", "V1"]
69
+ parent_config = while namespace.any?
70
+ parent_name = namespace.join "::"
71
+ parent_const = const_get parent_name
72
+ break parent_const.configure if parent_const.respond_to? :configure
73
+ namespace.pop
74
+ end
75
+ default_config = Client::Configuration.new parent_config
76
+
77
+ default_config.rpcs.list_jobs.timeout = 60.0
78
+ default_config.rpcs.list_jobs.retry_policy = {
79
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 2, retry_codes: [14]
80
+ }
81
+
82
+ default_config.rpcs.get_job.timeout = 60.0
83
+ default_config.rpcs.get_job.retry_policy = {
84
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 2, retry_codes: [14]
85
+ }
86
+
87
+ default_config.rpcs.create_job.timeout = 60.0
88
+
89
+ default_config.rpcs.delete_job.timeout = 60.0
90
+
91
+ default_config.rpcs.cancel_job.timeout = 60.0
92
+ default_config.rpcs.cancel_job.retry_policy = {
93
+ initial_delay: 1.0, max_delay: 60.0, multiplier: 2, retry_codes: [14]
94
+ }
95
+
96
+ default_config
97
+ end
98
+ yield @configure if block_given?
99
+ @configure
100
+ end
101
+
102
+ ##
103
+ # Configure the StorageBatchOperations Client instance.
104
+ #
105
+ # The configuration is set to the derived mode, meaning that values can be changed,
106
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
107
+ # should be made on {Client.configure}.
108
+ #
109
+ # See {::Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client::Configuration}
110
+ # for a description of the configuration fields.
111
+ #
112
+ # @yield [config] Configure the Client client.
113
+ # @yieldparam config [Client::Configuration]
114
+ #
115
+ # @return [Client::Configuration]
116
+ #
117
+ def configure
118
+ yield @config if block_given?
119
+ @config
120
+ end
121
+
122
+ ##
123
+ # The effective universe domain
124
+ #
125
+ # @return [String]
126
+ #
127
+ def universe_domain
128
+ @storage_batch_operations_stub.universe_domain
129
+ end
130
+
131
+ ##
132
+ # Create a new StorageBatchOperations client object.
133
+ #
134
+ # @example
135
+ #
136
+ # # Create a client using the default configuration
137
+ # client = ::Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client.new
138
+ #
139
+ # # Create a client using a custom configuration
140
+ # client = ::Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client.new do |config|
141
+ # config.timeout = 10.0
142
+ # end
143
+ #
144
+ # @yield [config] Configure the StorageBatchOperations client.
145
+ # @yieldparam config [Client::Configuration]
146
+ #
147
+ def initialize
148
+ # These require statements are intentionally placed here to initialize
149
+ # the gRPC module only when it's required.
150
+ # See https://github.com/googleapis/toolkit/issues/446
151
+ require "gapic/grpc"
152
+ require "google/cloud/storagebatchoperations/v1/storage_batch_operations_services_pb"
153
+
154
+ # Create the configuration object
155
+ @config = Configuration.new Client.configure
156
+
157
+ # Yield the configuration if needed
158
+ yield @config if block_given?
159
+
160
+ # Create credentials
161
+ credentials = @config.credentials
162
+ # Use self-signed JWT if the endpoint is unchanged from default,
163
+ # but only if the default endpoint does not have a region prefix.
164
+ enable_self_signed_jwt = @config.endpoint.nil? ||
165
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
166
+ !@config.endpoint.split(".").first.include?("-"))
167
+ credentials ||= Credentials.default scope: @config.scope,
168
+ enable_self_signed_jwt: enable_self_signed_jwt
169
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
170
+ credentials = Credentials.new credentials, scope: @config.scope
171
+ end
172
+ @quota_project_id = @config.quota_project
173
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
174
+
175
+ @operations_client = Operations.new do |config|
176
+ config.credentials = credentials
177
+ config.quota_project = @quota_project_id
178
+ config.endpoint = @config.endpoint
179
+ config.universe_domain = @config.universe_domain
180
+ end
181
+
182
+ @storage_batch_operations_stub = ::Gapic::ServiceStub.new(
183
+ ::Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Stub,
184
+ credentials: credentials,
185
+ endpoint: @config.endpoint,
186
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
187
+ universe_domain: @config.universe_domain,
188
+ channel_args: @config.channel_args,
189
+ interceptors: @config.interceptors,
190
+ channel_pool_config: @config.channel_pool,
191
+ logger: @config.logger
192
+ )
193
+
194
+ @storage_batch_operations_stub.stub_logger&.info do |entry|
195
+ entry.set_system_name
196
+ entry.set_service
197
+ entry.message = "Created client for #{entry.service}"
198
+ entry.set_credentials_fields credentials
199
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
200
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
201
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
202
+ end
203
+
204
+ @location_client = Google::Cloud::Location::Locations::Client.new do |config|
205
+ config.credentials = credentials
206
+ config.quota_project = @quota_project_id
207
+ config.endpoint = @storage_batch_operations_stub.endpoint
208
+ config.universe_domain = @storage_batch_operations_stub.universe_domain
209
+ config.logger = @storage_batch_operations_stub.logger if config.respond_to? :logger=
210
+ end
211
+ end
212
+
213
+ ##
214
+ # Get the associated client for long-running operations.
215
+ #
216
+ # @return [::Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Operations]
217
+ #
218
+ attr_reader :operations_client
219
+
220
+ ##
221
+ # Get the associated client for mix-in of the Locations.
222
+ #
223
+ # @return [Google::Cloud::Location::Locations::Client]
224
+ #
225
+ attr_reader :location_client
226
+
227
+ ##
228
+ # The logger used for request/response debug logging.
229
+ #
230
+ # @return [Logger]
231
+ #
232
+ def logger
233
+ @storage_batch_operations_stub.logger
234
+ end
235
+
236
+ # Service calls
237
+
238
+ ##
239
+ # Lists Jobs in a given project and location.
240
+ #
241
+ # @overload list_jobs(request, options = nil)
242
+ # Pass arguments to `list_jobs` via a request object, either of type
243
+ # {::Google::Cloud::StorageBatchOperations::V1::ListJobsRequest} or an equivalent Hash.
244
+ #
245
+ # @param request [::Google::Cloud::StorageBatchOperations::V1::ListJobsRequest, ::Hash]
246
+ # A request object representing the call parameters. Required. To specify no
247
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
248
+ # @param options [::Gapic::CallOptions, ::Hash]
249
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
250
+ #
251
+ # @overload list_jobs(parent: nil, filter: nil, page_size: nil, page_token: nil, order_by: nil)
252
+ # Pass arguments to `list_jobs` via keyword arguments. Note that at
253
+ # least one keyword argument is required. To specify no parameters, or to keep all
254
+ # the default parameter values, pass an empty Hash as a request object (see above).
255
+ #
256
+ # @param parent [::String]
257
+ # Required. Format: projects/\\{project_id}/locations/\\{location_id} .
258
+ # @param filter [::String]
259
+ # Optional. Filters results as defined by https://google.aip.dev/160.
260
+ # @param page_size [::Integer]
261
+ # Optional. The list page size. default page size is 100.
262
+ # @param page_token [::String]
263
+ # Optional. The list page token.
264
+ # @param order_by [::String]
265
+ # Optional. Field to sort by. Supported fields are name, create_time.
266
+ #
267
+ # @yield [response, operation] Access the result along with the RPC operation
268
+ # @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::StorageBatchOperations::V1::Job>]
269
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
270
+ #
271
+ # @return [::Gapic::PagedEnumerable<::Google::Cloud::StorageBatchOperations::V1::Job>]
272
+ #
273
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
274
+ #
275
+ # @example Basic example
276
+ # require "google/cloud/storage_batch_operations/v1"
277
+ #
278
+ # # Create a client object. The client can be reused for multiple calls.
279
+ # client = Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client.new
280
+ #
281
+ # # Create a request. To set request fields, pass in keyword arguments.
282
+ # request = Google::Cloud::StorageBatchOperations::V1::ListJobsRequest.new
283
+ #
284
+ # # Call the list_jobs method.
285
+ # result = client.list_jobs request
286
+ #
287
+ # # The returned object is of type Gapic::PagedEnumerable. You can iterate
288
+ # # over elements, and API calls will be issued to fetch pages as needed.
289
+ # result.each do |item|
290
+ # # Each element is of type ::Google::Cloud::StorageBatchOperations::V1::Job.
291
+ # p item
292
+ # end
293
+ #
294
+ def list_jobs request, options = nil
295
+ raise ::ArgumentError, "request must be provided" if request.nil?
296
+
297
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::StorageBatchOperations::V1::ListJobsRequest
298
+
299
+ # Converts hash and nil to an options object
300
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
301
+
302
+ # Customize the options with defaults
303
+ metadata = @config.rpcs.list_jobs.metadata.to_h
304
+
305
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
306
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
307
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
308
+ gapic_version: ::Google::Cloud::StorageBatchOperations::V1::VERSION
309
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
310
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
311
+
312
+ header_params = {}
313
+ if request.parent
314
+ header_params["parent"] = request.parent
315
+ end
316
+
317
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
318
+ metadata[:"x-goog-request-params"] ||= request_params_header
319
+
320
+ options.apply_defaults timeout: @config.rpcs.list_jobs.timeout,
321
+ metadata: metadata,
322
+ retry_policy: @config.rpcs.list_jobs.retry_policy
323
+
324
+ options.apply_defaults timeout: @config.timeout,
325
+ metadata: @config.metadata,
326
+ retry_policy: @config.retry_policy
327
+
328
+ @storage_batch_operations_stub.call_rpc :list_jobs, request, options: options do |response, operation|
329
+ response = ::Gapic::PagedEnumerable.new @storage_batch_operations_stub, :list_jobs, request, response, operation, options
330
+ yield response, operation if block_given?
331
+ throw :response, response
332
+ end
333
+ rescue ::GRPC::BadStatus => e
334
+ raise ::Google::Cloud::Error.from_error(e)
335
+ end
336
+
337
+ ##
338
+ # Gets a batch job.
339
+ #
340
+ # @overload get_job(request, options = nil)
341
+ # Pass arguments to `get_job` via a request object, either of type
342
+ # {::Google::Cloud::StorageBatchOperations::V1::GetJobRequest} or an equivalent Hash.
343
+ #
344
+ # @param request [::Google::Cloud::StorageBatchOperations::V1::GetJobRequest, ::Hash]
345
+ # A request object representing the call parameters. Required. To specify no
346
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
347
+ # @param options [::Gapic::CallOptions, ::Hash]
348
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
349
+ #
350
+ # @overload get_job(name: nil)
351
+ # Pass arguments to `get_job` via keyword arguments. Note that at
352
+ # least one keyword argument is required. To specify no parameters, or to keep all
353
+ # the default parameter values, pass an empty Hash as a request object (see above).
354
+ #
355
+ # @param name [::String]
356
+ # Required. `name` of the job to retrieve.
357
+ # Format: projects/\\{project_id}/locations/\\{location_id}/jobs/\\{job_id} .
358
+ #
359
+ # @yield [response, operation] Access the result along with the RPC operation
360
+ # @yieldparam response [::Google::Cloud::StorageBatchOperations::V1::Job]
361
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
362
+ #
363
+ # @return [::Google::Cloud::StorageBatchOperations::V1::Job]
364
+ #
365
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
366
+ #
367
+ # @example Basic example
368
+ # require "google/cloud/storage_batch_operations/v1"
369
+ #
370
+ # # Create a client object. The client can be reused for multiple calls.
371
+ # client = Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client.new
372
+ #
373
+ # # Create a request. To set request fields, pass in keyword arguments.
374
+ # request = Google::Cloud::StorageBatchOperations::V1::GetJobRequest.new
375
+ #
376
+ # # Call the get_job method.
377
+ # result = client.get_job request
378
+ #
379
+ # # The returned object is of type Google::Cloud::StorageBatchOperations::V1::Job.
380
+ # p result
381
+ #
382
+ def get_job request, options = nil
383
+ raise ::ArgumentError, "request must be provided" if request.nil?
384
+
385
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::StorageBatchOperations::V1::GetJobRequest
386
+
387
+ # Converts hash and nil to an options object
388
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
389
+
390
+ # Customize the options with defaults
391
+ metadata = @config.rpcs.get_job.metadata.to_h
392
+
393
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
394
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
395
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
396
+ gapic_version: ::Google::Cloud::StorageBatchOperations::V1::VERSION
397
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
398
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
399
+
400
+ header_params = {}
401
+ if request.name
402
+ header_params["name"] = request.name
403
+ end
404
+
405
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
406
+ metadata[:"x-goog-request-params"] ||= request_params_header
407
+
408
+ options.apply_defaults timeout: @config.rpcs.get_job.timeout,
409
+ metadata: metadata,
410
+ retry_policy: @config.rpcs.get_job.retry_policy
411
+
412
+ options.apply_defaults timeout: @config.timeout,
413
+ metadata: @config.metadata,
414
+ retry_policy: @config.retry_policy
415
+
416
+ @storage_batch_operations_stub.call_rpc :get_job, request, options: options do |response, operation|
417
+ yield response, operation if block_given?
418
+ end
419
+ rescue ::GRPC::BadStatus => e
420
+ raise ::Google::Cloud::Error.from_error(e)
421
+ end
422
+
423
+ ##
424
+ # Creates a batch job.
425
+ #
426
+ # @overload create_job(request, options = nil)
427
+ # Pass arguments to `create_job` via a request object, either of type
428
+ # {::Google::Cloud::StorageBatchOperations::V1::CreateJobRequest} or an equivalent Hash.
429
+ #
430
+ # @param request [::Google::Cloud::StorageBatchOperations::V1::CreateJobRequest, ::Hash]
431
+ # A request object representing the call parameters. Required. To specify no
432
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
433
+ # @param options [::Gapic::CallOptions, ::Hash]
434
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
435
+ #
436
+ # @overload create_job(parent: nil, job_id: nil, job: nil, request_id: nil)
437
+ # Pass arguments to `create_job` via keyword arguments. Note that at
438
+ # least one keyword argument is required. To specify no parameters, or to keep all
439
+ # the default parameter values, pass an empty Hash as a request object (see above).
440
+ #
441
+ # @param parent [::String]
442
+ # Required. Value for parent.
443
+ # @param job_id [::String]
444
+ # Required. The optional `job_id` for this Job . If not
445
+ # specified, an id is generated. `job_id` should be no more than 128
446
+ # characters and must include only characters available in DNS names, as
447
+ # defined by RFC-1123.
448
+ # @param job [::Google::Cloud::StorageBatchOperations::V1::Job, ::Hash]
449
+ # Required. The resource being created
450
+ # @param request_id [::String]
451
+ # Optional. An optional request ID to identify requests. Specify a unique
452
+ # request ID in case you need to retry your request. Requests with same
453
+ # `request_id` will ignored for at least 60 minutes since the first request.
454
+ # The request ID must be a valid UUID with the exception that zero UUID is
455
+ # not supported (00000000-0000-0000-0000-000000000000).
456
+ #
457
+ # @yield [response, operation] Access the result along with the RPC operation
458
+ # @yieldparam response [::Gapic::Operation]
459
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
460
+ #
461
+ # @return [::Gapic::Operation]
462
+ #
463
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
464
+ #
465
+ # @example Basic example
466
+ # require "google/cloud/storage_batch_operations/v1"
467
+ #
468
+ # # Create a client object. The client can be reused for multiple calls.
469
+ # client = Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client.new
470
+ #
471
+ # # Create a request. To set request fields, pass in keyword arguments.
472
+ # request = Google::Cloud::StorageBatchOperations::V1::CreateJobRequest.new
473
+ #
474
+ # # Call the create_job method.
475
+ # result = client.create_job request
476
+ #
477
+ # # The returned object is of type Gapic::Operation. You can use it to
478
+ # # check the status of an operation, cancel it, or wait for results.
479
+ # # Here is how to wait for a response.
480
+ # result.wait_until_done! timeout: 60
481
+ # if result.response?
482
+ # p result.response
483
+ # else
484
+ # puts "No response received."
485
+ # end
486
+ #
487
+ def create_job request, options = nil
488
+ raise ::ArgumentError, "request must be provided" if request.nil?
489
+
490
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::StorageBatchOperations::V1::CreateJobRequest
491
+
492
+ # Converts hash and nil to an options object
493
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
494
+
495
+ # Customize the options with defaults
496
+ metadata = @config.rpcs.create_job.metadata.to_h
497
+
498
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
499
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
500
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
501
+ gapic_version: ::Google::Cloud::StorageBatchOperations::V1::VERSION
502
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
503
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
504
+
505
+ header_params = {}
506
+ if request.parent
507
+ header_params["parent"] = request.parent
508
+ end
509
+
510
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
511
+ metadata[:"x-goog-request-params"] ||= request_params_header
512
+
513
+ options.apply_defaults timeout: @config.rpcs.create_job.timeout,
514
+ metadata: metadata,
515
+ retry_policy: @config.rpcs.create_job.retry_policy
516
+
517
+ options.apply_defaults timeout: @config.timeout,
518
+ metadata: @config.metadata,
519
+ retry_policy: @config.retry_policy
520
+
521
+ @storage_batch_operations_stub.call_rpc :create_job, request, options: options do |response, operation|
522
+ response = ::Gapic::Operation.new response, @operations_client, options: options
523
+ yield response, operation if block_given?
524
+ throw :response, response
525
+ end
526
+ rescue ::GRPC::BadStatus => e
527
+ raise ::Google::Cloud::Error.from_error(e)
528
+ end
529
+
530
+ ##
531
+ # Deletes a batch job.
532
+ #
533
+ # @overload delete_job(request, options = nil)
534
+ # Pass arguments to `delete_job` via a request object, either of type
535
+ # {::Google::Cloud::StorageBatchOperations::V1::DeleteJobRequest} or an equivalent Hash.
536
+ #
537
+ # @param request [::Google::Cloud::StorageBatchOperations::V1::DeleteJobRequest, ::Hash]
538
+ # A request object representing the call parameters. Required. To specify no
539
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
540
+ # @param options [::Gapic::CallOptions, ::Hash]
541
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
542
+ #
543
+ # @overload delete_job(name: nil, request_id: nil)
544
+ # Pass arguments to `delete_job` via keyword arguments. Note that at
545
+ # least one keyword argument is required. To specify no parameters, or to keep all
546
+ # the default parameter values, pass an empty Hash as a request object (see above).
547
+ #
548
+ # @param name [::String]
549
+ # Required. The `name` of the job to delete.
550
+ # Format: projects/\\{project_id}/locations/\\{location_id}/jobs/\\{job_id} .
551
+ # @param request_id [::String]
552
+ # Optional. An optional request ID to identify requests. Specify a unique
553
+ # request ID in case you need to retry your request. Requests with same
554
+ # `request_id` will ignored for at least 60 minutes since the first request.
555
+ # The request ID must be a valid UUID with the exception that zero UUID is
556
+ # not supported (00000000-0000-0000-0000-000000000000).
557
+ #
558
+ # @yield [response, operation] Access the result along with the RPC operation
559
+ # @yieldparam response [::Google::Protobuf::Empty]
560
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
561
+ #
562
+ # @return [::Google::Protobuf::Empty]
563
+ #
564
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
565
+ #
566
+ # @example Basic example
567
+ # require "google/cloud/storage_batch_operations/v1"
568
+ #
569
+ # # Create a client object. The client can be reused for multiple calls.
570
+ # client = Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client.new
571
+ #
572
+ # # Create a request. To set request fields, pass in keyword arguments.
573
+ # request = Google::Cloud::StorageBatchOperations::V1::DeleteJobRequest.new
574
+ #
575
+ # # Call the delete_job method.
576
+ # result = client.delete_job request
577
+ #
578
+ # # The returned object is of type Google::Protobuf::Empty.
579
+ # p result
580
+ #
581
+ def delete_job request, options = nil
582
+ raise ::ArgumentError, "request must be provided" if request.nil?
583
+
584
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::StorageBatchOperations::V1::DeleteJobRequest
585
+
586
+ # Converts hash and nil to an options object
587
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
588
+
589
+ # Customize the options with defaults
590
+ metadata = @config.rpcs.delete_job.metadata.to_h
591
+
592
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
593
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
594
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
595
+ gapic_version: ::Google::Cloud::StorageBatchOperations::V1::VERSION
596
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
597
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
598
+
599
+ header_params = {}
600
+ if request.name
601
+ header_params["name"] = request.name
602
+ end
603
+
604
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
605
+ metadata[:"x-goog-request-params"] ||= request_params_header
606
+
607
+ options.apply_defaults timeout: @config.rpcs.delete_job.timeout,
608
+ metadata: metadata,
609
+ retry_policy: @config.rpcs.delete_job.retry_policy
610
+
611
+ options.apply_defaults timeout: @config.timeout,
612
+ metadata: @config.metadata,
613
+ retry_policy: @config.retry_policy
614
+
615
+ @storage_batch_operations_stub.call_rpc :delete_job, request, options: options do |response, operation|
616
+ yield response, operation if block_given?
617
+ end
618
+ rescue ::GRPC::BadStatus => e
619
+ raise ::Google::Cloud::Error.from_error(e)
620
+ end
621
+
622
+ ##
623
+ # Cancels a batch job.
624
+ #
625
+ # @overload cancel_job(request, options = nil)
626
+ # Pass arguments to `cancel_job` via a request object, either of type
627
+ # {::Google::Cloud::StorageBatchOperations::V1::CancelJobRequest} or an equivalent Hash.
628
+ #
629
+ # @param request [::Google::Cloud::StorageBatchOperations::V1::CancelJobRequest, ::Hash]
630
+ # A request object representing the call parameters. Required. To specify no
631
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
632
+ # @param options [::Gapic::CallOptions, ::Hash]
633
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
634
+ #
635
+ # @overload cancel_job(name: nil, request_id: nil)
636
+ # Pass arguments to `cancel_job` via keyword arguments. Note that at
637
+ # least one keyword argument is required. To specify no parameters, or to keep all
638
+ # the default parameter values, pass an empty Hash as a request object (see above).
639
+ #
640
+ # @param name [::String]
641
+ # Required. The `name` of the job to cancel.
642
+ # Format: projects/\\{project_id}/locations/\\{location_id}/jobs/\\{job_id}.
643
+ # @param request_id [::String]
644
+ # Optional. An optional request ID to identify requests. Specify a unique
645
+ # request ID in case you need to retry your request. Requests with same
646
+ # `request_id` will ignored for at least 60 minutes since the first request.
647
+ # The request ID must be a valid UUID with the exception that zero UUID is
648
+ # not supported (00000000-0000-0000-0000-000000000000).
649
+ #
650
+ # @yield [response, operation] Access the result along with the RPC operation
651
+ # @yieldparam response [::Google::Cloud::StorageBatchOperations::V1::CancelJobResponse]
652
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
653
+ #
654
+ # @return [::Google::Cloud::StorageBatchOperations::V1::CancelJobResponse]
655
+ #
656
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
657
+ #
658
+ # @example Basic example
659
+ # require "google/cloud/storage_batch_operations/v1"
660
+ #
661
+ # # Create a client object. The client can be reused for multiple calls.
662
+ # client = Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client.new
663
+ #
664
+ # # Create a request. To set request fields, pass in keyword arguments.
665
+ # request = Google::Cloud::StorageBatchOperations::V1::CancelJobRequest.new
666
+ #
667
+ # # Call the cancel_job method.
668
+ # result = client.cancel_job request
669
+ #
670
+ # # The returned object is of type Google::Cloud::StorageBatchOperations::V1::CancelJobResponse.
671
+ # p result
672
+ #
673
+ def cancel_job request, options = nil
674
+ raise ::ArgumentError, "request must be provided" if request.nil?
675
+
676
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::StorageBatchOperations::V1::CancelJobRequest
677
+
678
+ # Converts hash and nil to an options object
679
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
680
+
681
+ # Customize the options with defaults
682
+ metadata = @config.rpcs.cancel_job.metadata.to_h
683
+
684
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
685
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
686
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
687
+ gapic_version: ::Google::Cloud::StorageBatchOperations::V1::VERSION
688
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
689
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
690
+
691
+ header_params = {}
692
+ if request.name
693
+ header_params["name"] = request.name
694
+ end
695
+
696
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
697
+ metadata[:"x-goog-request-params"] ||= request_params_header
698
+
699
+ options.apply_defaults timeout: @config.rpcs.cancel_job.timeout,
700
+ metadata: metadata,
701
+ retry_policy: @config.rpcs.cancel_job.retry_policy
702
+
703
+ options.apply_defaults timeout: @config.timeout,
704
+ metadata: @config.metadata,
705
+ retry_policy: @config.retry_policy
706
+
707
+ @storage_batch_operations_stub.call_rpc :cancel_job, request, options: options do |response, operation|
708
+ yield response, operation if block_given?
709
+ end
710
+ rescue ::GRPC::BadStatus => e
711
+ raise ::Google::Cloud::Error.from_error(e)
712
+ end
713
+
714
+ ##
715
+ # Configuration class for the StorageBatchOperations API.
716
+ #
717
+ # This class represents the configuration for StorageBatchOperations,
718
+ # providing control over timeouts, retry behavior, logging, transport
719
+ # parameters, and other low-level controls. Certain parameters can also be
720
+ # applied individually to specific RPCs. See
721
+ # {::Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client::Configuration::Rpcs}
722
+ # for a list of RPCs that can be configured independently.
723
+ #
724
+ # Configuration can be applied globally to all clients, or to a single client
725
+ # on construction.
726
+ #
727
+ # @example
728
+ #
729
+ # # Modify the global config, setting the timeout for
730
+ # # list_jobs to 20 seconds,
731
+ # # and all remaining timeouts to 10 seconds.
732
+ # ::Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client.configure do |config|
733
+ # config.timeout = 10.0
734
+ # config.rpcs.list_jobs.timeout = 20.0
735
+ # end
736
+ #
737
+ # # Apply the above configuration only to a new client.
738
+ # client = ::Google::Cloud::StorageBatchOperations::V1::StorageBatchOperations::Client.new do |config|
739
+ # config.timeout = 10.0
740
+ # config.rpcs.list_jobs.timeout = 20.0
741
+ # end
742
+ #
743
+ # @!attribute [rw] endpoint
744
+ # A custom service endpoint, as a hostname or hostname:port. The default is
745
+ # nil, indicating to use the default endpoint in the current universe domain.
746
+ # @return [::String,nil]
747
+ # @!attribute [rw] credentials
748
+ # Credentials to send with calls. You may provide any of the following types:
749
+ # * (`String`) The path to a service account key file in JSON format
750
+ # * (`Hash`) A service account key as a Hash
751
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
752
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
753
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
754
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
755
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
756
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
757
+ # * (`nil`) indicating no credentials
758
+ #
759
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
760
+ # external source for authentication to Google Cloud, you must validate it before
761
+ # providing it to a Google API client library. Providing an unvalidated credential
762
+ # configuration to Google APIs can compromise the security of your systems and data.
763
+ # For more information, refer to [Validate credential configurations from external
764
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
765
+ # @return [::Object]
766
+ # @!attribute [rw] scope
767
+ # The OAuth scopes
768
+ # @return [::Array<::String>]
769
+ # @!attribute [rw] lib_name
770
+ # The library name as recorded in instrumentation and logging
771
+ # @return [::String]
772
+ # @!attribute [rw] lib_version
773
+ # The library version as recorded in instrumentation and logging
774
+ # @return [::String]
775
+ # @!attribute [rw] channel_args
776
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
777
+ # `GRPC::Core::Channel` object is provided as the credential.
778
+ # @return [::Hash]
779
+ # @!attribute [rw] interceptors
780
+ # An array of interceptors that are run before calls are executed.
781
+ # @return [::Array<::GRPC::ClientInterceptor>]
782
+ # @!attribute [rw] timeout
783
+ # The call timeout in seconds.
784
+ # @return [::Numeric]
785
+ # @!attribute [rw] metadata
786
+ # Additional gRPC headers to be sent with the call.
787
+ # @return [::Hash{::Symbol=>::String}]
788
+ # @!attribute [rw] retry_policy
789
+ # The retry policy. The value is a hash with the following keys:
790
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
791
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
792
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
793
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
794
+ # trigger a retry.
795
+ # @return [::Hash]
796
+ # @!attribute [rw] quota_project
797
+ # A separate project against which to charge quota.
798
+ # @return [::String]
799
+ # @!attribute [rw] universe_domain
800
+ # The universe domain within which to make requests. This determines the
801
+ # default endpoint URL. The default value of nil uses the environment
802
+ # universe (usually the default "googleapis.com" universe).
803
+ # @return [::String,nil]
804
+ # @!attribute [rw] logger
805
+ # A custom logger to use for request/response debug logging, or the value
806
+ # `:default` (the default) to construct a default logger, or `nil` to
807
+ # explicitly disable logging.
808
+ # @return [::Logger,:default,nil]
809
+ #
810
+ class Configuration
811
+ extend ::Gapic::Config
812
+
813
+ # @private
814
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
815
+ DEFAULT_ENDPOINT = "storagebatchoperations.googleapis.com"
816
+
817
+ config_attr :endpoint, nil, ::String, nil
818
+ config_attr :credentials, nil do |value|
819
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
820
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
821
+ allowed.any? { |klass| klass === value }
822
+ end
823
+ config_attr :scope, nil, ::String, ::Array, nil
824
+ config_attr :lib_name, nil, ::String, nil
825
+ config_attr :lib_version, nil, ::String, nil
826
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
827
+ config_attr :interceptors, nil, ::Array, nil
828
+ config_attr :timeout, nil, ::Numeric, nil
829
+ config_attr :metadata, nil, ::Hash, nil
830
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
831
+ config_attr :quota_project, nil, ::String, nil
832
+ config_attr :universe_domain, nil, ::String, nil
833
+ config_attr :logger, :default, ::Logger, nil, :default
834
+
835
+ # @private
836
+ def initialize parent_config = nil
837
+ @parent_config = parent_config unless parent_config.nil?
838
+
839
+ yield self if block_given?
840
+ end
841
+
842
+ ##
843
+ # Configurations for individual RPCs
844
+ # @return [Rpcs]
845
+ #
846
+ def rpcs
847
+ @rpcs ||= begin
848
+ parent_rpcs = nil
849
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
850
+ Rpcs.new parent_rpcs
851
+ end
852
+ end
853
+
854
+ ##
855
+ # Configuration for the channel pool
856
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
857
+ #
858
+ def channel_pool
859
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
860
+ end
861
+
862
+ ##
863
+ # Configuration RPC class for the StorageBatchOperations API.
864
+ #
865
+ # Includes fields providing the configuration for each RPC in this service.
866
+ # Each configuration object is of type `Gapic::Config::Method` and includes
867
+ # the following configuration fields:
868
+ #
869
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
870
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
871
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
872
+ # include the following keys:
873
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
874
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
875
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
876
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
877
+ # trigger a retry.
878
+ #
879
+ class Rpcs
880
+ ##
881
+ # RPC-specific configuration for `list_jobs`
882
+ # @return [::Gapic::Config::Method]
883
+ #
884
+ attr_reader :list_jobs
885
+ ##
886
+ # RPC-specific configuration for `get_job`
887
+ # @return [::Gapic::Config::Method]
888
+ #
889
+ attr_reader :get_job
890
+ ##
891
+ # RPC-specific configuration for `create_job`
892
+ # @return [::Gapic::Config::Method]
893
+ #
894
+ attr_reader :create_job
895
+ ##
896
+ # RPC-specific configuration for `delete_job`
897
+ # @return [::Gapic::Config::Method]
898
+ #
899
+ attr_reader :delete_job
900
+ ##
901
+ # RPC-specific configuration for `cancel_job`
902
+ # @return [::Gapic::Config::Method]
903
+ #
904
+ attr_reader :cancel_job
905
+
906
+ # @private
907
+ def initialize parent_rpcs = nil
908
+ list_jobs_config = parent_rpcs.list_jobs if parent_rpcs.respond_to? :list_jobs
909
+ @list_jobs = ::Gapic::Config::Method.new list_jobs_config
910
+ get_job_config = parent_rpcs.get_job if parent_rpcs.respond_to? :get_job
911
+ @get_job = ::Gapic::Config::Method.new get_job_config
912
+ create_job_config = parent_rpcs.create_job if parent_rpcs.respond_to? :create_job
913
+ @create_job = ::Gapic::Config::Method.new create_job_config
914
+ delete_job_config = parent_rpcs.delete_job if parent_rpcs.respond_to? :delete_job
915
+ @delete_job = ::Gapic::Config::Method.new delete_job_config
916
+ cancel_job_config = parent_rpcs.cancel_job if parent_rpcs.respond_to? :cancel_job
917
+ @cancel_job = ::Gapic::Config::Method.new cancel_job_config
918
+
919
+ yield self if block_given?
920
+ end
921
+ end
922
+ end
923
+ end
924
+ end
925
+ end
926
+ end
927
+ end
928
+ end