google-cloud-gke_backup-v1 0.10.1 → 0.12.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.
@@ -249,15 +249,27 @@ module Google
249
249
  endpoint: @config.endpoint,
250
250
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
251
251
  universe_domain: @config.universe_domain,
252
- credentials: credentials
252
+ credentials: credentials,
253
+ logger: @config.logger
253
254
  )
254
255
 
256
+ @backup_for_gke_stub.logger(stub: true)&.info do |entry|
257
+ entry.set_system_name
258
+ entry.set_service
259
+ entry.message = "Created client for #{entry.service}"
260
+ entry.set_credentials_fields credentials
261
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
262
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
263
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
264
+ end
265
+
255
266
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
256
267
  config.credentials = credentials
257
268
  config.quota_project = @quota_project_id
258
269
  config.endpoint = @backup_for_gke_stub.endpoint
259
270
  config.universe_domain = @backup_for_gke_stub.universe_domain
260
271
  config.bindings_override = @config.bindings_override
272
+ config.logger = @backup_for_gke_stub.logger if config.respond_to? :logger=
261
273
  end
262
274
 
263
275
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config|
@@ -266,6 +278,7 @@ module Google
266
278
  config.endpoint = @backup_for_gke_stub.endpoint
267
279
  config.universe_domain = @backup_for_gke_stub.universe_domain
268
280
  config.bindings_override = @config.bindings_override
281
+ config.logger = @backup_for_gke_stub.logger if config.respond_to? :logger=
269
282
  end
270
283
  end
271
284
 
@@ -290,6 +303,15 @@ module Google
290
303
  #
291
304
  attr_reader :iam_policy_client
292
305
 
306
+ ##
307
+ # The logger used for request/response debug logging.
308
+ #
309
+ # @return [Logger]
310
+ #
311
+ def logger
312
+ @backup_for_gke_stub.logger
313
+ end
314
+
293
315
  # Service calls
294
316
 
295
317
  ##
@@ -385,7 +407,7 @@ module Google
385
407
  @backup_for_gke_stub.create_backup_plan request, options do |result, operation|
386
408
  result = ::Gapic::Operation.new result, @operations_client, options: options
387
409
  yield result, operation if block_given?
388
- return result
410
+ throw :response, result
389
411
  end
390
412
  rescue ::Gapic::Rest::Error => e
391
413
  raise ::Google::Cloud::Error.from_error(e)
@@ -487,7 +509,6 @@ module Google
487
509
 
488
510
  @backup_for_gke_stub.list_backup_plans request, options do |result, operation|
489
511
  yield result, operation if block_given?
490
- return result
491
512
  end
492
513
  rescue ::Gapic::Rest::Error => e
493
514
  raise ::Google::Cloud::Error.from_error(e)
@@ -567,7 +588,6 @@ module Google
567
588
 
568
589
  @backup_for_gke_stub.get_backup_plan request, options do |result, operation|
569
590
  yield result, operation if block_given?
570
- return result
571
591
  end
572
592
  rescue ::Gapic::Rest::Error => e
573
593
  raise ::Google::Cloud::Error.from_error(e)
@@ -665,7 +685,7 @@ module Google
665
685
  @backup_for_gke_stub.update_backup_plan request, options do |result, operation|
666
686
  result = ::Gapic::Operation.new result, @operations_client, options: options
667
687
  yield result, operation if block_given?
668
- return result
688
+ throw :response, result
669
689
  end
670
690
  rescue ::Gapic::Rest::Error => e
671
691
  raise ::Google::Cloud::Error.from_error(e)
@@ -757,7 +777,7 @@ module Google
757
777
  @backup_for_gke_stub.delete_backup_plan request, options do |result, operation|
758
778
  result = ::Gapic::Operation.new result, @operations_client, options: options
759
779
  yield result, operation if block_given?
760
- return result
780
+ throw :response, result
761
781
  end
762
782
  rescue ::Gapic::Rest::Error => e
763
783
  raise ::Google::Cloud::Error.from_error(e)
@@ -856,7 +876,7 @@ module Google
856
876
  @backup_for_gke_stub.create_backup request, options do |result, operation|
857
877
  result = ::Gapic::Operation.new result, @operations_client, options: options
858
878
  yield result, operation if block_given?
859
- return result
879
+ throw :response, result
860
880
  end
861
881
  rescue ::Gapic::Rest::Error => e
862
882
  raise ::Google::Cloud::Error.from_error(e)
@@ -959,7 +979,7 @@ module Google
959
979
  @backup_for_gke_stub.list_backups request, options do |result, operation|
960
980
  result = ::Gapic::Rest::PagedEnumerable.new @backup_for_gke_stub, :list_backups, "backups", request, result, options
961
981
  yield result, operation if block_given?
962
- return result
982
+ throw :response, result
963
983
  end
964
984
  rescue ::Gapic::Rest::Error => e
965
985
  raise ::Google::Cloud::Error.from_error(e)
@@ -1039,7 +1059,6 @@ module Google
1039
1059
 
1040
1060
  @backup_for_gke_stub.get_backup request, options do |result, operation|
1041
1061
  yield result, operation if block_given?
1042
- return result
1043
1062
  end
1044
1063
  rescue ::Gapic::Rest::Error => e
1045
1064
  raise ::Google::Cloud::Error.from_error(e)
@@ -1136,7 +1155,7 @@ module Google
1136
1155
  @backup_for_gke_stub.update_backup request, options do |result, operation|
1137
1156
  result = ::Gapic::Operation.new result, @operations_client, options: options
1138
1157
  yield result, operation if block_given?
1139
- return result
1158
+ throw :response, result
1140
1159
  end
1141
1160
  rescue ::Gapic::Rest::Error => e
1142
1161
  raise ::Google::Cloud::Error.from_error(e)
@@ -1232,7 +1251,7 @@ module Google
1232
1251
  @backup_for_gke_stub.delete_backup request, options do |result, operation|
1233
1252
  result = ::Gapic::Operation.new result, @operations_client, options: options
1234
1253
  yield result, operation if block_given?
1235
- return result
1254
+ throw :response, result
1236
1255
  end
1237
1256
  rescue ::Gapic::Rest::Error => e
1238
1257
  raise ::Google::Cloud::Error.from_error(e)
@@ -1335,7 +1354,7 @@ module Google
1335
1354
  @backup_for_gke_stub.list_volume_backups request, options do |result, operation|
1336
1355
  result = ::Gapic::Rest::PagedEnumerable.new @backup_for_gke_stub, :list_volume_backups, "volume_backups", request, result, options
1337
1356
  yield result, operation if block_given?
1338
- return result
1357
+ throw :response, result
1339
1358
  end
1340
1359
  rescue ::Gapic::Rest::Error => e
1341
1360
  raise ::Google::Cloud::Error.from_error(e)
@@ -1415,7 +1434,6 @@ module Google
1415
1434
 
1416
1435
  @backup_for_gke_stub.get_volume_backup request, options do |result, operation|
1417
1436
  yield result, operation if block_given?
1418
- return result
1419
1437
  end
1420
1438
  rescue ::Gapic::Rest::Error => e
1421
1439
  raise ::Google::Cloud::Error.from_error(e)
@@ -1514,7 +1532,7 @@ module Google
1514
1532
  @backup_for_gke_stub.create_restore_plan request, options do |result, operation|
1515
1533
  result = ::Gapic::Operation.new result, @operations_client, options: options
1516
1534
  yield result, operation if block_given?
1517
- return result
1535
+ throw :response, result
1518
1536
  end
1519
1537
  rescue ::Gapic::Rest::Error => e
1520
1538
  raise ::Google::Cloud::Error.from_error(e)
@@ -1616,7 +1634,6 @@ module Google
1616
1634
 
1617
1635
  @backup_for_gke_stub.list_restore_plans request, options do |result, operation|
1618
1636
  yield result, operation if block_given?
1619
- return result
1620
1637
  end
1621
1638
  rescue ::Gapic::Rest::Error => e
1622
1639
  raise ::Google::Cloud::Error.from_error(e)
@@ -1696,7 +1713,6 @@ module Google
1696
1713
 
1697
1714
  @backup_for_gke_stub.get_restore_plan request, options do |result, operation|
1698
1715
  yield result, operation if block_given?
1699
- return result
1700
1716
  end
1701
1717
  rescue ::Gapic::Rest::Error => e
1702
1718
  raise ::Google::Cloud::Error.from_error(e)
@@ -1793,7 +1809,7 @@ module Google
1793
1809
  @backup_for_gke_stub.update_restore_plan request, options do |result, operation|
1794
1810
  result = ::Gapic::Operation.new result, @operations_client, options: options
1795
1811
  yield result, operation if block_given?
1796
- return result
1812
+ throw :response, result
1797
1813
  end
1798
1814
  rescue ::Gapic::Rest::Error => e
1799
1815
  raise ::Google::Cloud::Error.from_error(e)
@@ -1889,7 +1905,7 @@ module Google
1889
1905
  @backup_for_gke_stub.delete_restore_plan request, options do |result, operation|
1890
1906
  result = ::Gapic::Operation.new result, @operations_client, options: options
1891
1907
  yield result, operation if block_given?
1892
- return result
1908
+ throw :response, result
1893
1909
  end
1894
1910
  rescue ::Gapic::Rest::Error => e
1895
1911
  raise ::Google::Cloud::Error.from_error(e)
@@ -1988,7 +2004,7 @@ module Google
1988
2004
  @backup_for_gke_stub.create_restore request, options do |result, operation|
1989
2005
  result = ::Gapic::Operation.new result, @operations_client, options: options
1990
2006
  yield result, operation if block_given?
1991
- return result
2007
+ throw :response, result
1992
2008
  end
1993
2009
  rescue ::Gapic::Rest::Error => e
1994
2010
  raise ::Google::Cloud::Error.from_error(e)
@@ -2090,7 +2106,6 @@ module Google
2090
2106
 
2091
2107
  @backup_for_gke_stub.list_restores request, options do |result, operation|
2092
2108
  yield result, operation if block_given?
2093
- return result
2094
2109
  end
2095
2110
  rescue ::Gapic::Rest::Error => e
2096
2111
  raise ::Google::Cloud::Error.from_error(e)
@@ -2170,7 +2185,6 @@ module Google
2170
2185
 
2171
2186
  @backup_for_gke_stub.get_restore request, options do |result, operation|
2172
2187
  yield result, operation if block_given?
2173
- return result
2174
2188
  end
2175
2189
  rescue ::Gapic::Rest::Error => e
2176
2190
  raise ::Google::Cloud::Error.from_error(e)
@@ -2267,7 +2281,7 @@ module Google
2267
2281
  @backup_for_gke_stub.update_restore request, options do |result, operation|
2268
2282
  result = ::Gapic::Operation.new result, @operations_client, options: options
2269
2283
  yield result, operation if block_given?
2270
- return result
2284
+ throw :response, result
2271
2285
  end
2272
2286
  rescue ::Gapic::Rest::Error => e
2273
2287
  raise ::Google::Cloud::Error.from_error(e)
@@ -2363,7 +2377,7 @@ module Google
2363
2377
  @backup_for_gke_stub.delete_restore request, options do |result, operation|
2364
2378
  result = ::Gapic::Operation.new result, @operations_client, options: options
2365
2379
  yield result, operation if block_given?
2366
- return result
2380
+ throw :response, result
2367
2381
  end
2368
2382
  rescue ::Gapic::Rest::Error => e
2369
2383
  raise ::Google::Cloud::Error.from_error(e)
@@ -2466,7 +2480,7 @@ module Google
2466
2480
  @backup_for_gke_stub.list_volume_restores request, options do |result, operation|
2467
2481
  result = ::Gapic::Rest::PagedEnumerable.new @backup_for_gke_stub, :list_volume_restores, "volume_restores", request, result, options
2468
2482
  yield result, operation if block_given?
2469
- return result
2483
+ throw :response, result
2470
2484
  end
2471
2485
  rescue ::Gapic::Rest::Error => e
2472
2486
  raise ::Google::Cloud::Error.from_error(e)
@@ -2546,7 +2560,6 @@ module Google
2546
2560
 
2547
2561
  @backup_for_gke_stub.get_volume_restore request, options do |result, operation|
2548
2562
  yield result, operation if block_given?
2549
- return result
2550
2563
  end
2551
2564
  rescue ::Gapic::Rest::Error => e
2552
2565
  raise ::Google::Cloud::Error.from_error(e)
@@ -2627,7 +2640,6 @@ module Google
2627
2640
 
2628
2641
  @backup_for_gke_stub.get_backup_index_download_url request, options do |result, operation|
2629
2642
  yield result, operation if block_given?
2630
- return result
2631
2643
  end
2632
2644
  rescue ::Gapic::Rest::Error => e
2633
2645
  raise ::Google::Cloud::Error.from_error(e)
@@ -2675,6 +2687,13 @@ module Google
2675
2687
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
2676
2688
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
2677
2689
  # * (`nil`) indicating no credentials
2690
+ #
2691
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
2692
+ # external source for authentication to Google Cloud, you must validate it before
2693
+ # providing it to a Google API client library. Providing an unvalidated credential
2694
+ # configuration to Google APIs can compromise the security of your systems and data.
2695
+ # For more information, refer to [Validate credential configurations from external
2696
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
2678
2697
  # @return [::Object]
2679
2698
  # @!attribute [rw] scope
2680
2699
  # The OAuth scopes
@@ -2707,6 +2726,11 @@ module Google
2707
2726
  # default endpoint URL. The default value of nil uses the environment
2708
2727
  # universe (usually the default "googleapis.com" universe).
2709
2728
  # @return [::String,nil]
2729
+ # @!attribute [rw] logger
2730
+ # A custom logger to use for request/response debug logging, or the value
2731
+ # `:default` (the default) to construct a default logger, or `nil` to
2732
+ # explicitly disable logging.
2733
+ # @return [::Logger,:default,nil]
2710
2734
  #
2711
2735
  class Configuration
2712
2736
  extend ::Gapic::Config
@@ -2735,6 +2759,7 @@ module Google
2735
2759
  # by the host service.
2736
2760
  # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
2737
2761
  config_attr :bindings_override, {}, ::Hash, nil
2762
+ config_attr :logger, :default, ::Logger, nil, :default
2738
2763
 
2739
2764
  # @private
2740
2765
  def initialize parent_config = nil
@@ -115,14 +115,6 @@ module Google
115
115
  # Lists operations that match the specified filter in the request. If the
116
116
  # server doesn't support this method, it returns `UNIMPLEMENTED`.
117
117
  #
118
- # NOTE: the `name` binding allows API services to override the binding
119
- # to use different resource name schemes, such as `users/*/operations`. To
120
- # override the binding, API services can add a binding such as
121
- # `"/v1/{name=users/*}/operations"` to their service configuration.
122
- # For backwards compatibility, the default name includes the operations
123
- # collection id, however overriding users must ensure the name binding
124
- # is the parent resource, without the operations collection id.
125
- #
126
118
  # @overload list_operations(request, options = nil)
127
119
  # Pass arguments to `list_operations` via a request object, either of type
128
120
  # {::Google::Longrunning::ListOperationsRequest} or an equivalent Hash.
@@ -204,7 +196,7 @@ module Google
204
196
  @operations_stub.list_operations request, options do |result, operation|
205
197
  result = ::Gapic::Rest::PagedEnumerable.new @operations_stub, :list_operations, "operations", request, result, options
206
198
  yield result, operation if block_given?
207
- return result
199
+ throw :response, result
208
200
  end
209
201
  rescue ::Gapic::Rest::Error => e
210
202
  raise ::Google::Cloud::Error.from_error(e)
@@ -293,7 +285,7 @@ module Google
293
285
  @operations_stub.get_operation request, options do |result, operation|
294
286
  result = ::Gapic::Operation.new result, @operations_client, options: options
295
287
  yield result, operation if block_given?
296
- return result
288
+ throw :response, result
297
289
  end
298
290
  rescue ::Gapic::Rest::Error => e
299
291
  raise ::Google::Cloud::Error.from_error(e)
@@ -375,7 +367,6 @@ module Google
375
367
 
376
368
  @operations_stub.delete_operation request, options do |result, operation|
377
369
  yield result, operation if block_given?
378
- return result
379
370
  end
380
371
  rescue ::Gapic::Rest::Error => e
381
372
  raise ::Google::Cloud::Error.from_error(e)
@@ -390,8 +381,9 @@ module Google
390
381
  # other methods to check whether the cancellation succeeded or whether the
391
382
  # operation completed despite cancellation. On successful cancellation,
392
383
  # the operation is not deleted; instead, it becomes an operation with
393
- # an {::Google::Longrunning::Operation#error Operation.error} value with a {::Google::Rpc::Status#code google.rpc.Status.code} of 1,
394
- # 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`.
395
387
  #
396
388
  # @overload cancel_operation(request, options = nil)
397
389
  # Pass arguments to `cancel_operation` via a request object, either of type
@@ -463,7 +455,6 @@ module Google
463
455
 
464
456
  @operations_stub.cancel_operation request, options do |result, operation|
465
457
  yield result, operation if block_given?
466
- return result
467
458
  end
468
459
  rescue ::Gapic::Rest::Error => e
469
460
  raise ::Google::Cloud::Error.from_error(e)
@@ -511,6 +502,13 @@ module Google
511
502
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
512
503
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
513
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).
514
512
  # @return [::Object]
515
513
  # @!attribute [rw] scope
516
514
  # The OAuth scopes
@@ -543,6 +541,11 @@ module Google
543
541
  # default endpoint URL. The default value of nil uses the environment
544
542
  # universe (usually the default "googleapis.com" universe).
545
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]
546
549
  #
547
550
  class Configuration
548
551
  extend ::Gapic::Config
@@ -564,6 +567,7 @@ module Google
564
567
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
565
568
  config_attr :quota_project, nil, ::String, nil
566
569
  config_attr :universe_domain, nil, ::String, nil
570
+ config_attr :logger, :default, ::Logger, nil, :default
567
571
 
568
572
  # @private
569
573
  def initialize parent_config = nil
@@ -683,16 +687,18 @@ module Google
683
687
 
684
688
  response = @client_stub.make_http_request(
685
689
  verb,
686
- uri: uri,
687
- body: body || "",
688
- params: query_string_params,
690
+ uri: uri,
691
+ body: body || "",
692
+ params: query_string_params,
693
+ method_name: "list_operations",
689
694
  options: options
690
695
  )
691
696
  operation = ::Gapic::Rest::TransportOperation.new response
692
697
  result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
693
-
694
- yield result, operation if block_given?
695
- result
698
+ catch :response do
699
+ yield result, operation if block_given?
700
+ result
701
+ end
696
702
  end
697
703
 
698
704
  ##
@@ -721,16 +727,18 @@ module Google
721
727
 
722
728
  response = @client_stub.make_http_request(
723
729
  verb,
724
- uri: uri,
725
- body: body || "",
726
- params: query_string_params,
730
+ uri: uri,
731
+ body: body || "",
732
+ params: query_string_params,
733
+ method_name: "get_operation",
727
734
  options: options
728
735
  )
729
736
  operation = ::Gapic::Rest::TransportOperation.new response
730
737
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
731
-
732
- yield result, operation if block_given?
733
- result
738
+ catch :response do
739
+ yield result, operation if block_given?
740
+ result
741
+ end
734
742
  end
735
743
 
736
744
  ##
@@ -759,16 +767,18 @@ module Google
759
767
 
760
768
  response = @client_stub.make_http_request(
761
769
  verb,
762
- uri: uri,
763
- body: body || "",
764
- params: query_string_params,
770
+ uri: uri,
771
+ body: body || "",
772
+ params: query_string_params,
773
+ method_name: "delete_operation",
765
774
  options: options
766
775
  )
767
776
  operation = ::Gapic::Rest::TransportOperation.new response
768
777
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
769
-
770
- yield result, operation if block_given?
771
- result
778
+ catch :response do
779
+ yield result, operation if block_given?
780
+ result
781
+ end
772
782
  end
773
783
 
774
784
  ##
@@ -797,16 +807,18 @@ module Google
797
807
 
798
808
  response = @client_stub.make_http_request(
799
809
  verb,
800
- uri: uri,
801
- body: body || "",
802
- params: query_string_params,
810
+ uri: uri,
811
+ body: body || "",
812
+ params: query_string_params,
813
+ method_name: "cancel_operation",
803
814
  options: options
804
815
  )
805
816
  operation = ::Gapic::Rest::TransportOperation.new response
806
817
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
807
-
808
- yield result, operation if block_given?
809
- result
818
+ catch :response do
819
+ yield result, operation if block_given?
820
+ result
821
+ end
810
822
  end
811
823
 
812
824
  ##