google-cloud-bigquery-reservation-v1 1.0.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -233,8 +233,28 @@ module Google
233
233
  endpoint: @config.endpoint,
234
234
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
235
235
  universe_domain: @config.universe_domain,
236
- credentials: credentials
236
+ credentials: credentials,
237
+ logger: @config.logger
237
238
  )
239
+
240
+ @reservation_service_stub.logger(stub: true)&.info do |entry|
241
+ entry.set_system_name
242
+ entry.set_service
243
+ entry.message = "Created client for #{entry.service}"
244
+ entry.set_credentials_fields credentials
245
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
246
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
247
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
248
+ end
249
+ end
250
+
251
+ ##
252
+ # The logger used for request/response debug logging.
253
+ #
254
+ # @return [Logger]
255
+ #
256
+ def logger
257
+ @reservation_service_stub.logger
238
258
  end
239
259
 
240
260
  # Service calls
@@ -319,7 +339,6 @@ module Google
319
339
 
320
340
  @reservation_service_stub.create_reservation request, options do |result, operation|
321
341
  yield result, operation if block_given?
322
- return result
323
342
  end
324
343
  rescue ::Gapic::Rest::Error => e
325
344
  raise ::Google::Cloud::Error.from_error(e)
@@ -408,7 +427,7 @@ module Google
408
427
  @reservation_service_stub.list_reservations request, options do |result, operation|
409
428
  result = ::Gapic::Rest::PagedEnumerable.new @reservation_service_stub, :list_reservations, "reservations", request, result, options
410
429
  yield result, operation if block_given?
411
- return result
430
+ throw :response, result
412
431
  end
413
432
  rescue ::Gapic::Rest::Error => e
414
433
  raise ::Google::Cloud::Error.from_error(e)
@@ -488,7 +507,6 @@ module Google
488
507
 
489
508
  @reservation_service_stub.get_reservation request, options do |result, operation|
490
509
  yield result, operation if block_given?
491
- return result
492
510
  end
493
511
  rescue ::Gapic::Rest::Error => e
494
512
  raise ::Google::Cloud::Error.from_error(e)
@@ -570,7 +588,6 @@ module Google
570
588
 
571
589
  @reservation_service_stub.delete_reservation request, options do |result, operation|
572
590
  yield result, operation if block_given?
573
- return result
574
591
  end
575
592
  rescue ::Gapic::Rest::Error => e
576
593
  raise ::Google::Cloud::Error.from_error(e)
@@ -651,7 +668,89 @@ module Google
651
668
 
652
669
  @reservation_service_stub.update_reservation request, options do |result, operation|
653
670
  yield result, operation if block_given?
654
- return result
671
+ end
672
+ rescue ::Gapic::Rest::Error => e
673
+ raise ::Google::Cloud::Error.from_error(e)
674
+ end
675
+
676
+ ##
677
+ # Fail over a reservation to the secondary location. The operation should be
678
+ # done in the current secondary location, which will be promoted to the
679
+ # new primary location for the reservation.
680
+ # Attempting to failover a reservation in the current primary location will
681
+ # fail with the error code `google.rpc.Code.FAILED_PRECONDITION`.
682
+ #
683
+ # @overload failover_reservation(request, options = nil)
684
+ # Pass arguments to `failover_reservation` via a request object, either of type
685
+ # {::Google::Cloud::Bigquery::Reservation::V1::FailoverReservationRequest} or an equivalent Hash.
686
+ #
687
+ # @param request [::Google::Cloud::Bigquery::Reservation::V1::FailoverReservationRequest, ::Hash]
688
+ # A request object representing the call parameters. Required. To specify no
689
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
690
+ # @param options [::Gapic::CallOptions, ::Hash]
691
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
692
+ #
693
+ # @overload failover_reservation(name: nil)
694
+ # Pass arguments to `failover_reservation` via keyword arguments. Note that at
695
+ # least one keyword argument is required. To specify no parameters, or to keep all
696
+ # the default parameter values, pass an empty Hash as a request object (see above).
697
+ #
698
+ # @param name [::String]
699
+ # Required. Resource name of the reservation to failover. E.g.,
700
+ # `projects/myproject/locations/US/reservations/team1-prod`
701
+ # @yield [result, operation] Access the result along with the TransportOperation object
702
+ # @yieldparam result [::Google::Cloud::Bigquery::Reservation::V1::Reservation]
703
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
704
+ #
705
+ # @return [::Google::Cloud::Bigquery::Reservation::V1::Reservation]
706
+ #
707
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
708
+ #
709
+ # @example Basic example
710
+ # require "google/cloud/bigquery/reservation/v1"
711
+ #
712
+ # # Create a client object. The client can be reused for multiple calls.
713
+ # client = Google::Cloud::Bigquery::Reservation::V1::ReservationService::Rest::Client.new
714
+ #
715
+ # # Create a request. To set request fields, pass in keyword arguments.
716
+ # request = Google::Cloud::Bigquery::Reservation::V1::FailoverReservationRequest.new
717
+ #
718
+ # # Call the failover_reservation method.
719
+ # result = client.failover_reservation request
720
+ #
721
+ # # The returned object is of type Google::Cloud::Bigquery::Reservation::V1::Reservation.
722
+ # p result
723
+ #
724
+ def failover_reservation request, options = nil
725
+ raise ::ArgumentError, "request must be provided" if request.nil?
726
+
727
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigquery::Reservation::V1::FailoverReservationRequest
728
+
729
+ # Converts hash and nil to an options object
730
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
731
+
732
+ # Customize the options with defaults
733
+ call_metadata = @config.rpcs.failover_reservation.metadata.to_h
734
+
735
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
736
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
737
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
738
+ gapic_version: ::Google::Cloud::Bigquery::Reservation::V1::VERSION,
739
+ transports_version_send: [:rest]
740
+
741
+ call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
742
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
743
+
744
+ options.apply_defaults timeout: @config.rpcs.failover_reservation.timeout,
745
+ metadata: call_metadata,
746
+ retry_policy: @config.rpcs.failover_reservation.retry_policy
747
+
748
+ options.apply_defaults timeout: @config.timeout,
749
+ metadata: @config.metadata,
750
+ retry_policy: @config.retry_policy
751
+
752
+ @reservation_service_stub.failover_reservation request, options do |result, operation|
753
+ yield result, operation if block_given?
655
754
  end
656
755
  rescue ::Gapic::Rest::Error => e
657
756
  raise ::Google::Cloud::Error.from_error(e)
@@ -742,7 +841,6 @@ module Google
742
841
 
743
842
  @reservation_service_stub.create_capacity_commitment request, options do |result, operation|
744
843
  yield result, operation if block_given?
745
- return result
746
844
  end
747
845
  rescue ::Gapic::Rest::Error => e
748
846
  raise ::Google::Cloud::Error.from_error(e)
@@ -831,7 +929,7 @@ module Google
831
929
  @reservation_service_stub.list_capacity_commitments request, options do |result, operation|
832
930
  result = ::Gapic::Rest::PagedEnumerable.new @reservation_service_stub, :list_capacity_commitments, "capacity_commitments", request, result, options
833
931
  yield result, operation if block_given?
834
- return result
932
+ throw :response, result
835
933
  end
836
934
  rescue ::Gapic::Rest::Error => e
837
935
  raise ::Google::Cloud::Error.from_error(e)
@@ -911,7 +1009,6 @@ module Google
911
1009
 
912
1010
  @reservation_service_stub.get_capacity_commitment request, options do |result, operation|
913
1011
  yield result, operation if block_given?
914
- return result
915
1012
  end
916
1013
  rescue ::Gapic::Rest::Error => e
917
1014
  raise ::Google::Cloud::Error.from_error(e)
@@ -997,7 +1094,6 @@ module Google
997
1094
 
998
1095
  @reservation_service_stub.delete_capacity_commitment request, options do |result, operation|
999
1096
  yield result, operation if block_given?
1000
- return result
1001
1097
  end
1002
1098
  rescue ::Gapic::Rest::Error => e
1003
1099
  raise ::Google::Cloud::Error.from_error(e)
@@ -1084,7 +1180,6 @@ module Google
1084
1180
 
1085
1181
  @reservation_service_stub.update_capacity_commitment request, options do |result, operation|
1086
1182
  yield result, operation if block_given?
1087
- return result
1088
1183
  end
1089
1184
  rescue ::Gapic::Rest::Error => e
1090
1185
  raise ::Google::Cloud::Error.from_error(e)
@@ -1173,7 +1268,6 @@ module Google
1173
1268
 
1174
1269
  @reservation_service_stub.split_capacity_commitment request, options do |result, operation|
1175
1270
  yield result, operation if block_given?
1176
- return result
1177
1271
  end
1178
1272
  rescue ::Gapic::Rest::Error => e
1179
1273
  raise ::Google::Cloud::Error.from_error(e)
@@ -1265,7 +1359,6 @@ module Google
1265
1359
 
1266
1360
  @reservation_service_stub.merge_capacity_commitments request, options do |result, operation|
1267
1361
  yield result, operation if block_given?
1268
- return result
1269
1362
  end
1270
1363
  rescue ::Gapic::Rest::Error => e
1271
1364
  raise ::Google::Cloud::Error.from_error(e)
@@ -1386,7 +1479,6 @@ module Google
1386
1479
 
1387
1480
  @reservation_service_stub.create_assignment request, options do |result, operation|
1388
1481
  yield result, operation if block_given?
1389
- return result
1390
1482
  end
1391
1483
  rescue ::Gapic::Rest::Error => e
1392
1484
  raise ::Google::Cloud::Error.from_error(e)
@@ -1500,7 +1592,7 @@ module Google
1500
1592
  @reservation_service_stub.list_assignments request, options do |result, operation|
1501
1593
  result = ::Gapic::Rest::PagedEnumerable.new @reservation_service_stub, :list_assignments, "assignments", request, result, options
1502
1594
  yield result, operation if block_given?
1503
- return result
1595
+ throw :response, result
1504
1596
  end
1505
1597
  rescue ::Gapic::Rest::Error => e
1506
1598
  raise ::Google::Cloud::Error.from_error(e)
@@ -1594,7 +1686,6 @@ module Google
1594
1686
 
1595
1687
  @reservation_service_stub.delete_assignment request, options do |result, operation|
1596
1688
  yield result, operation if block_given?
1597
- return result
1598
1689
  end
1599
1690
  rescue ::Gapic::Rest::Error => e
1600
1691
  raise ::Google::Cloud::Error.from_error(e)
@@ -1714,7 +1805,7 @@ module Google
1714
1805
  @reservation_service_stub.search_assignments request, options do |result, operation|
1715
1806
  result = ::Gapic::Rest::PagedEnumerable.new @reservation_service_stub, :search_assignments, "assignments", request, result, options
1716
1807
  yield result, operation if block_given?
1717
- return result
1808
+ throw :response, result
1718
1809
  end
1719
1810
  rescue ::Gapic::Rest::Error => e
1720
1811
  raise ::Google::Cloud::Error.from_error(e)
@@ -1831,7 +1922,7 @@ module Google
1831
1922
  @reservation_service_stub.search_all_assignments request, options do |result, operation|
1832
1923
  result = ::Gapic::Rest::PagedEnumerable.new @reservation_service_stub, :search_all_assignments, "assignments", request, result, options
1833
1924
  yield result, operation if block_given?
1834
- return result
1925
+ throw :response, result
1835
1926
  end
1836
1927
  rescue ::Gapic::Rest::Error => e
1837
1928
  raise ::Google::Cloud::Error.from_error(e)
@@ -1925,7 +2016,6 @@ module Google
1925
2016
 
1926
2017
  @reservation_service_stub.move_assignment request, options do |result, operation|
1927
2018
  yield result, operation if block_given?
1928
- return result
1929
2019
  end
1930
2020
  rescue ::Gapic::Rest::Error => e
1931
2021
  raise ::Google::Cloud::Error.from_error(e)
@@ -2008,7 +2098,6 @@ module Google
2008
2098
 
2009
2099
  @reservation_service_stub.update_assignment request, options do |result, operation|
2010
2100
  yield result, operation if block_given?
2011
- return result
2012
2101
  end
2013
2102
  rescue ::Gapic::Rest::Error => e
2014
2103
  raise ::Google::Cloud::Error.from_error(e)
@@ -2088,7 +2177,6 @@ module Google
2088
2177
 
2089
2178
  @reservation_service_stub.get_bi_reservation request, options do |result, operation|
2090
2179
  yield result, operation if block_given?
2091
- return result
2092
2180
  end
2093
2181
  rescue ::Gapic::Rest::Error => e
2094
2182
  raise ::Google::Cloud::Error.from_error(e)
@@ -2176,7 +2264,6 @@ module Google
2176
2264
 
2177
2265
  @reservation_service_stub.update_bi_reservation request, options do |result, operation|
2178
2266
  yield result, operation if block_given?
2179
- return result
2180
2267
  end
2181
2268
  rescue ::Gapic::Rest::Error => e
2182
2269
  raise ::Google::Cloud::Error.from_error(e)
@@ -2256,6 +2343,11 @@ module Google
2256
2343
  # default endpoint URL. The default value of nil uses the environment
2257
2344
  # universe (usually the default "googleapis.com" universe).
2258
2345
  # @return [::String,nil]
2346
+ # @!attribute [rw] logger
2347
+ # A custom logger to use for request/response debug logging, or the value
2348
+ # `:default` (the default) to construct a default logger, or `nil` to
2349
+ # explicitly disable logging.
2350
+ # @return [::Logger,:default,nil]
2259
2351
  #
2260
2352
  class Configuration
2261
2353
  extend ::Gapic::Config
@@ -2277,6 +2369,7 @@ module Google
2277
2369
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
2278
2370
  config_attr :quota_project, nil, ::String, nil
2279
2371
  config_attr :universe_domain, nil, ::String, nil
2372
+ config_attr :logger, :default, ::Logger, nil, :default
2280
2373
 
2281
2374
  # @private
2282
2375
  def initialize parent_config = nil
@@ -2341,6 +2434,11 @@ module Google
2341
2434
  #
2342
2435
  attr_reader :update_reservation
2343
2436
  ##
2437
+ # RPC-specific configuration for `failover_reservation`
2438
+ # @return [::Gapic::Config::Method]
2439
+ #
2440
+ attr_reader :failover_reservation
2441
+ ##
2344
2442
  # RPC-specific configuration for `create_capacity_commitment`
2345
2443
  # @return [::Gapic::Config::Method]
2346
2444
  #
@@ -2433,6 +2531,8 @@ module Google
2433
2531
  @delete_reservation = ::Gapic::Config::Method.new delete_reservation_config
2434
2532
  update_reservation_config = parent_rpcs.update_reservation if parent_rpcs.respond_to? :update_reservation
2435
2533
  @update_reservation = ::Gapic::Config::Method.new update_reservation_config
2534
+ failover_reservation_config = parent_rpcs.failover_reservation if parent_rpcs.respond_to? :failover_reservation
2535
+ @failover_reservation = ::Gapic::Config::Method.new failover_reservation_config
2436
2536
  create_capacity_commitment_config = parent_rpcs.create_capacity_commitment if parent_rpcs.respond_to? :create_capacity_commitment
2437
2537
  @create_capacity_commitment = ::Gapic::Config::Method.new create_capacity_commitment_config
2438
2538
  list_capacity_commitments_config = parent_rpcs.list_capacity_commitments if parent_rpcs.respond_to? :list_capacity_commitments