google-cloud-storage_transfer-v1 0.8.0 → 1.4.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.
@@ -26,6 +26,12 @@ module Google
26
26
  module Rest
27
27
  # Service that implements Longrunning Operations API.
28
28
  class Operations
29
+ # @private
30
+ API_VERSION = ""
31
+
32
+ # @private
33
+ DEFAULT_ENDPOINT_TEMPLATE = "storagetransfer.$UNIVERSE_DOMAIN$"
34
+
29
35
  # @private
30
36
  attr_reader :operations_stub
31
37
 
@@ -60,6 +66,15 @@ module Google
60
66
  @config
61
67
  end
62
68
 
69
+ ##
70
+ # The effective universe domain
71
+ #
72
+ # @return [String]
73
+ #
74
+ def universe_domain
75
+ @operations_stub.universe_domain
76
+ end
77
+
63
78
  ##
64
79
  # Create a new Operations client object.
65
80
  #
@@ -84,8 +99,10 @@ module Google
84
99
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
85
100
 
86
101
  @operations_stub = OperationsServiceStub.new(
87
- endpoint: @config.endpoint,
88
- credentials: credentials
102
+ endpoint: @config.endpoint,
103
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
104
+ universe_domain: @config.universe_domain,
105
+ credentials: credentials
89
106
  )
90
107
 
91
108
  # Used by an LRO wrapper for some methods of this service
@@ -98,14 +115,6 @@ module Google
98
115
  # Lists operations that match the specified filter in the request. If the
99
116
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
100
117
  #
101
- # NOTE: the `name` binding allows API services to override the binding
102
- # to use different resource name schemes, such as `users/*/operations`. To
103
- # override the binding, API services can add a binding such as
104
- # `"/v1/{name=users/*}/operations"` to their service configuration.
105
- # For backwards compatibility, the default name includes the operations
106
- # collection id, however overriding users must ensure the name binding
107
- # is the parent resource, without the operations collection id.
108
- #
109
118
  # @overload list_operations(request, options = nil)
110
119
  # Pass arguments to `list_operations` via a request object, either of type
111
120
  # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
@@ -167,12 +176,13 @@ module Google
167
176
  # Customize the options with defaults
168
177
  call_metadata = @config.rpcs.list_operations.metadata.to_h
169
178
 
170
- # Set x-goog-api-client and x-goog-user-project headers
179
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
171
180
  call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
172
181
  lib_name: @config.lib_name, lib_version: @config.lib_version,
173
182
  gapic_version: ::Google::Cloud::StorageTransfer::V1::VERSION,
174
183
  transports_version_send: [:rest]
175
184
 
185
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
176
186
  call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
177
187
 
178
188
  options.apply_defaults timeout: @config.rpcs.list_operations.timeout,
@@ -186,7 +196,7 @@ module Google
186
196
  @operations_stub.list_operations request, options do |result, operation|
187
197
  result = ::Gapic::Rest::PagedEnumerable.new @operations_stub, :list_operations, "operations", request, result, options
188
198
  yield result, operation if block_given?
189
- return result
199
+ throw :response, result
190
200
  end
191
201
  rescue ::Gapic::Rest::Error => e
192
202
  raise ::Google::Cloud::Error.from_error(e)
@@ -255,12 +265,13 @@ module Google
255
265
  # Customize the options with defaults
256
266
  call_metadata = @config.rpcs.get_operation.metadata.to_h
257
267
 
258
- # Set x-goog-api-client and x-goog-user-project headers
268
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
259
269
  call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
260
270
  lib_name: @config.lib_name, lib_version: @config.lib_version,
261
271
  gapic_version: ::Google::Cloud::StorageTransfer::V1::VERSION,
262
272
  transports_version_send: [:rest]
263
273
 
274
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
264
275
  call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
265
276
 
266
277
  options.apply_defaults timeout: @config.rpcs.get_operation.timeout,
@@ -274,7 +285,7 @@ module Google
274
285
  @operations_stub.get_operation request, options do |result, operation|
275
286
  result = ::Gapic::Operation.new result, @operations_client, options: options
276
287
  yield result, operation if block_given?
277
- return result
288
+ throw :response, result
278
289
  end
279
290
  rescue ::Gapic::Rest::Error => e
280
291
  raise ::Google::Cloud::Error.from_error(e)
@@ -337,12 +348,13 @@ module Google
337
348
  # Customize the options with defaults
338
349
  call_metadata = @config.rpcs.delete_operation.metadata.to_h
339
350
 
340
- # Set x-goog-api-client and x-goog-user-project headers
351
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
341
352
  call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
342
353
  lib_name: @config.lib_name, lib_version: @config.lib_version,
343
354
  gapic_version: ::Google::Cloud::StorageTransfer::V1::VERSION,
344
355
  transports_version_send: [:rest]
345
356
 
357
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
346
358
  call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
347
359
 
348
360
  options.apply_defaults timeout: @config.rpcs.delete_operation.timeout,
@@ -355,7 +367,6 @@ module Google
355
367
 
356
368
  @operations_stub.delete_operation request, options do |result, operation|
357
369
  yield result, operation if block_given?
358
- return result
359
370
  end
360
371
  rescue ::Gapic::Rest::Error => e
361
372
  raise ::Google::Cloud::Error.from_error(e)
@@ -370,8 +381,9 @@ module Google
370
381
  # other methods to check whether the cancellation succeeded or whether the
371
382
  # operation completed despite cancellation. On successful cancellation,
372
383
  # the operation is not deleted; instead, it becomes an operation with
373
- # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
374
- # corresponding to `Code.CANCELLED`.
384
+ # an {::Google::Longrunning::Operation#error Operation.error} value with a
385
+ # {::Google::Rpc::Status#code google.rpc.Status.code} of `1`, corresponding to
386
+ # `Code.CANCELLED`.
375
387
  #
376
388
  # @overload cancel_operation(request, options = nil)
377
389
  # Pass arguments to `cancel_operation` via a request object, either of type
@@ -424,12 +436,13 @@ module Google
424
436
  # Customize the options with defaults
425
437
  call_metadata = @config.rpcs.cancel_operation.metadata.to_h
426
438
 
427
- # Set x-goog-api-client and x-goog-user-project headers
439
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
428
440
  call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
429
441
  lib_name: @config.lib_name, lib_version: @config.lib_version,
430
442
  gapic_version: ::Google::Cloud::StorageTransfer::V1::VERSION,
431
443
  transports_version_send: [:rest]
432
444
 
445
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
433
446
  call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
434
447
 
435
448
  options.apply_defaults timeout: @config.rpcs.cancel_operation.timeout,
@@ -442,7 +455,6 @@ module Google
442
455
 
443
456
  @operations_stub.cancel_operation request, options do |result, operation|
444
457
  yield result, operation if block_given?
445
- return result
446
458
  end
447
459
  rescue ::Gapic::Rest::Error => e
448
460
  raise ::Google::Cloud::Error.from_error(e)
@@ -478,9 +490,9 @@ module Google
478
490
  # end
479
491
  #
480
492
  # @!attribute [rw] endpoint
481
- # The hostname or hostname:port of the service endpoint.
482
- # Defaults to `"storagetransfer.googleapis.com"`.
483
- # @return [::String]
493
+ # A custom service endpoint, as a hostname or hostname:port. The default is
494
+ # nil, indicating to use the default endpoint in the current universe domain.
495
+ # @return [::String,nil]
484
496
  # @!attribute [rw] credentials
485
497
  # Credentials to send with calls. You may provide any of the following types:
486
498
  # * (`String`) The path to a service account key file in JSON format
@@ -490,6 +502,13 @@ module Google
490
502
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
491
503
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
492
504
  # * (`nil`) indicating no credentials
505
+ #
506
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
507
+ # external source for authentication to Google Cloud, you must validate it before
508
+ # providing it to a Google API client library. Providing an unvalidated credential
509
+ # configuration to Google APIs can compromise the security of your systems and data.
510
+ # For more information, refer to [Validate credential configurations from external
511
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
493
512
  # @return [::Object]
494
513
  # @!attribute [rw] scope
495
514
  # The OAuth scopes
@@ -517,13 +536,25 @@ module Google
517
536
  # @!attribute [rw] quota_project
518
537
  # A separate project against which to charge quota.
519
538
  # @return [::String]
539
+ # @!attribute [rw] universe_domain
540
+ # The universe domain within which to make requests. This determines the
541
+ # default endpoint URL. The default value of nil uses the environment
542
+ # universe (usually the default "googleapis.com" universe).
543
+ # @return [::String,nil]
544
+ # @!attribute [rw] logger
545
+ # A custom logger to use for request/response debug logging, or the value
546
+ # `:default` (the default) to construct a default logger, or `nil` to
547
+ # explicitly disable logging.
548
+ # @return [::Logger,:default,nil]
520
549
  #
521
550
  class Configuration
522
551
  extend ::Gapic::Config
523
552
 
553
+ # @private
554
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
524
555
  DEFAULT_ENDPOINT = "storagetransfer.googleapis.com"
525
556
 
526
- config_attr :endpoint, DEFAULT_ENDPOINT, ::String
557
+ config_attr :endpoint, nil, ::String, nil
527
558
  config_attr :credentials, nil do |value|
528
559
  allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
529
560
  allowed.any? { |klass| klass === value }
@@ -535,6 +566,8 @@ module Google
535
566
  config_attr :metadata, nil, ::Hash, nil
536
567
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
537
568
  config_attr :quota_project, nil, ::String, nil
569
+ config_attr :universe_domain, nil, ::String, nil
570
+ config_attr :logger, :default, ::Logger, nil, :default
538
571
 
539
572
  # @private
540
573
  def initialize parent_config = nil
@@ -617,12 +650,15 @@ module Google
617
650
  # Service stub contains baseline method implementations
618
651
  # including transcoding, making the REST call, and deserialing the response.
619
652
  class OperationsServiceStub
620
- def initialize endpoint:, credentials:
653
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
621
654
  # These require statements are intentionally placed here to initialize
622
655
  # the REST modules only when it's required.
623
656
  require "gapic/rest"
624
657
 
625
- @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials
658
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint,
659
+ endpoint_template: endpoint_template,
660
+ universe_domain: universe_domain,
661
+ credentials: credentials
626
662
  end
627
663
 
628
664
  ##
@@ -651,16 +687,18 @@ module Google
651
687
 
652
688
  response = @client_stub.make_http_request(
653
689
  verb,
654
- uri: uri,
655
- body: body || "",
656
- params: query_string_params,
690
+ uri: uri,
691
+ body: body || "",
692
+ params: query_string_params,
693
+ method_name: "list_operations",
657
694
  options: options
658
695
  )
659
696
  operation = ::Gapic::Rest::TransportOperation.new response
660
697
  result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
661
-
662
- yield result, operation if block_given?
663
- result
698
+ catch :response do
699
+ yield result, operation if block_given?
700
+ result
701
+ end
664
702
  end
665
703
 
666
704
  ##
@@ -689,16 +727,18 @@ module Google
689
727
 
690
728
  response = @client_stub.make_http_request(
691
729
  verb,
692
- uri: uri,
693
- body: body || "",
694
- params: query_string_params,
730
+ uri: uri,
731
+ body: body || "",
732
+ params: query_string_params,
733
+ method_name: "get_operation",
695
734
  options: options
696
735
  )
697
736
  operation = ::Gapic::Rest::TransportOperation.new response
698
737
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
699
-
700
- yield result, operation if block_given?
701
- result
738
+ catch :response do
739
+ yield result, operation if block_given?
740
+ result
741
+ end
702
742
  end
703
743
 
704
744
  ##
@@ -727,16 +767,18 @@ module Google
727
767
 
728
768
  response = @client_stub.make_http_request(
729
769
  verb,
730
- uri: uri,
731
- body: body || "",
732
- params: query_string_params,
770
+ uri: uri,
771
+ body: body || "",
772
+ params: query_string_params,
773
+ method_name: "delete_operation",
733
774
  options: options
734
775
  )
735
776
  operation = ::Gapic::Rest::TransportOperation.new response
736
777
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
737
-
738
- yield result, operation if block_given?
739
- result
778
+ catch :response do
779
+ yield result, operation if block_given?
780
+ result
781
+ end
740
782
  end
741
783
 
742
784
  ##
@@ -765,16 +807,18 @@ module Google
765
807
 
766
808
  response = @client_stub.make_http_request(
767
809
  verb,
768
- uri: uri,
769
- body: body || "",
770
- params: query_string_params,
810
+ uri: uri,
811
+ body: body || "",
812
+ params: query_string_params,
813
+ method_name: "cancel_operation",
771
814
  options: options
772
815
  )
773
816
  operation = ::Gapic::Rest::TransportOperation.new response
774
817
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
775
-
776
- yield result, operation if block_given?
777
- result
818
+ catch :response do
819
+ yield result, operation if block_given?
820
+ result
821
+ end
778
822
  end
779
823
 
780
824
  ##