google-cloud-app_hub-v1 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -258,15 +258,27 @@ module Google
258
258
  endpoint: @config.endpoint,
259
259
  endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
260
260
  universe_domain: @config.universe_domain,
261
- credentials: credentials
261
+ credentials: credentials,
262
+ logger: @config.logger
262
263
  )
263
264
 
265
+ @app_hub_stub.logger(stub: true)&.info do |entry|
266
+ entry.set_system_name
267
+ entry.set_service
268
+ entry.message = "Created client for #{entry.service}"
269
+ entry.set_credentials_fields credentials
270
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
271
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
272
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
273
+ end
274
+
264
275
  @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
265
276
  config.credentials = credentials
266
277
  config.quota_project = @quota_project_id
267
278
  config.endpoint = @app_hub_stub.endpoint
268
279
  config.universe_domain = @app_hub_stub.universe_domain
269
280
  config.bindings_override = @config.bindings_override
281
+ config.logger = @app_hub_stub.logger if config.respond_to? :logger=
270
282
  end
271
283
 
272
284
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config|
@@ -275,6 +287,7 @@ module Google
275
287
  config.endpoint = @app_hub_stub.endpoint
276
288
  config.universe_domain = @app_hub_stub.universe_domain
277
289
  config.bindings_override = @config.bindings_override
290
+ config.logger = @app_hub_stub.logger if config.respond_to? :logger=
278
291
  end
279
292
  end
280
293
 
@@ -299,6 +312,15 @@ module Google
299
312
  #
300
313
  attr_reader :iam_policy_client
301
314
 
315
+ ##
316
+ # The logger used for request/response debug logging.
317
+ #
318
+ # @return [Logger]
319
+ #
320
+ def logger
321
+ @app_hub_stub.logger
322
+ end
323
+
302
324
  # Service calls
303
325
 
304
326
  ##
@@ -377,7 +399,6 @@ module Google
377
399
 
378
400
  @app_hub_stub.lookup_service_project_attachment request, options do |result, operation|
379
401
  yield result, operation if block_given?
380
- return result
381
402
  end
382
403
  rescue ::Gapic::Rest::Error => e
383
404
  raise ::Google::Cloud::Error.from_error(e)
@@ -471,7 +492,6 @@ module Google
471
492
 
472
493
  @app_hub_stub.list_service_project_attachments request, options do |result, operation|
473
494
  yield result, operation if block_given?
474
- return result
475
495
  end
476
496
  rescue ::Gapic::Rest::Error => e
477
497
  raise ::Google::Cloud::Error.from_error(e)
@@ -580,7 +600,7 @@ module Google
580
600
  @app_hub_stub.create_service_project_attachment request, options do |result, operation|
581
601
  result = ::Gapic::Operation.new result, @operations_client, options: options
582
602
  yield result, operation if block_given?
583
- return result
603
+ throw :response, result
584
604
  end
585
605
  rescue ::Gapic::Rest::Error => e
586
606
  raise ::Google::Cloud::Error.from_error(e)
@@ -661,7 +681,6 @@ module Google
661
681
 
662
682
  @app_hub_stub.get_service_project_attachment request, options do |result, operation|
663
683
  yield result, operation if block_given?
664
- return result
665
684
  end
666
685
  rescue ::Gapic::Rest::Error => e
667
686
  raise ::Google::Cloud::Error.from_error(e)
@@ -764,7 +783,7 @@ module Google
764
783
  @app_hub_stub.delete_service_project_attachment request, options do |result, operation|
765
784
  result = ::Gapic::Operation.new result, @operations_client, options: options
766
785
  yield result, operation if block_given?
767
- return result
786
+ throw :response, result
768
787
  end
769
788
  rescue ::Gapic::Rest::Error => e
770
789
  raise ::Google::Cloud::Error.from_error(e)
@@ -847,7 +866,6 @@ module Google
847
866
 
848
867
  @app_hub_stub.detach_service_project_attachment request, options do |result, operation|
849
868
  yield result, operation if block_given?
850
- return result
851
869
  end
852
870
  rescue ::Gapic::Rest::Error => e
853
871
  raise ::Google::Cloud::Error.from_error(e)
@@ -941,7 +959,6 @@ module Google
941
959
 
942
960
  @app_hub_stub.list_discovered_services request, options do |result, operation|
943
961
  yield result, operation if block_given?
944
- return result
945
962
  end
946
963
  rescue ::Gapic::Rest::Error => e
947
964
  raise ::Google::Cloud::Error.from_error(e)
@@ -1022,7 +1039,6 @@ module Google
1022
1039
 
1023
1040
  @app_hub_stub.get_discovered_service request, options do |result, operation|
1024
1041
  yield result, operation if block_given?
1025
- return result
1026
1042
  end
1027
1043
  rescue ::Gapic::Rest::Error => e
1028
1044
  raise ::Google::Cloud::Error.from_error(e)
@@ -1107,7 +1123,6 @@ module Google
1107
1123
 
1108
1124
  @app_hub_stub.lookup_discovered_service request, options do |result, operation|
1109
1125
  yield result, operation if block_given?
1110
- return result
1111
1126
  end
1112
1127
  rescue ::Gapic::Rest::Error => e
1113
1128
  raise ::Google::Cloud::Error.from_error(e)
@@ -1201,7 +1216,6 @@ module Google
1201
1216
 
1202
1217
  @app_hub_stub.list_services request, options do |result, operation|
1203
1218
  yield result, operation if block_given?
1204
- return result
1205
1219
  end
1206
1220
  rescue ::Gapic::Rest::Error => e
1207
1221
  raise ::Google::Cloud::Error.from_error(e)
@@ -1311,7 +1325,7 @@ module Google
1311
1325
  @app_hub_stub.create_service request, options do |result, operation|
1312
1326
  result = ::Gapic::Operation.new result, @operations_client, options: options
1313
1327
  yield result, operation if block_given?
1314
- return result
1328
+ throw :response, result
1315
1329
  end
1316
1330
  rescue ::Gapic::Rest::Error => e
1317
1331
  raise ::Google::Cloud::Error.from_error(e)
@@ -1392,7 +1406,6 @@ module Google
1392
1406
 
1393
1407
  @app_hub_stub.get_service request, options do |result, operation|
1394
1408
  yield result, operation if block_given?
1395
- return result
1396
1409
  end
1397
1410
  rescue ::Gapic::Rest::Error => e
1398
1411
  raise ::Google::Cloud::Error.from_error(e)
@@ -1503,7 +1516,7 @@ module Google
1503
1516
  @app_hub_stub.update_service request, options do |result, operation|
1504
1517
  result = ::Gapic::Operation.new result, @operations_client, options: options
1505
1518
  yield result, operation if block_given?
1506
- return result
1519
+ throw :response, result
1507
1520
  end
1508
1521
  rescue ::Gapic::Rest::Error => e
1509
1522
  raise ::Google::Cloud::Error.from_error(e)
@@ -1606,7 +1619,7 @@ module Google
1606
1619
  @app_hub_stub.delete_service request, options do |result, operation|
1607
1620
  result = ::Gapic::Operation.new result, @operations_client, options: options
1608
1621
  yield result, operation if block_given?
1609
- return result
1622
+ throw :response, result
1610
1623
  end
1611
1624
  rescue ::Gapic::Rest::Error => e
1612
1625
  raise ::Google::Cloud::Error.from_error(e)
@@ -1700,7 +1713,6 @@ module Google
1700
1713
 
1701
1714
  @app_hub_stub.list_discovered_workloads request, options do |result, operation|
1702
1715
  yield result, operation if block_given?
1703
- return result
1704
1716
  end
1705
1717
  rescue ::Gapic::Rest::Error => e
1706
1718
  raise ::Google::Cloud::Error.from_error(e)
@@ -1781,7 +1793,6 @@ module Google
1781
1793
 
1782
1794
  @app_hub_stub.get_discovered_workload request, options do |result, operation|
1783
1795
  yield result, operation if block_given?
1784
- return result
1785
1796
  end
1786
1797
  rescue ::Gapic::Rest::Error => e
1787
1798
  raise ::Google::Cloud::Error.from_error(e)
@@ -1866,7 +1877,6 @@ module Google
1866
1877
 
1867
1878
  @app_hub_stub.lookup_discovered_workload request, options do |result, operation|
1868
1879
  yield result, operation if block_given?
1869
- return result
1870
1880
  end
1871
1881
  rescue ::Gapic::Rest::Error => e
1872
1882
  raise ::Google::Cloud::Error.from_error(e)
@@ -1960,7 +1970,6 @@ module Google
1960
1970
 
1961
1971
  @app_hub_stub.list_workloads request, options do |result, operation|
1962
1972
  yield result, operation if block_given?
1963
- return result
1964
1973
  end
1965
1974
  rescue ::Gapic::Rest::Error => e
1966
1975
  raise ::Google::Cloud::Error.from_error(e)
@@ -2070,7 +2079,7 @@ module Google
2070
2079
  @app_hub_stub.create_workload request, options do |result, operation|
2071
2080
  result = ::Gapic::Operation.new result, @operations_client, options: options
2072
2081
  yield result, operation if block_given?
2073
- return result
2082
+ throw :response, result
2074
2083
  end
2075
2084
  rescue ::Gapic::Rest::Error => e
2076
2085
  raise ::Google::Cloud::Error.from_error(e)
@@ -2151,7 +2160,6 @@ module Google
2151
2160
 
2152
2161
  @app_hub_stub.get_workload request, options do |result, operation|
2153
2162
  yield result, operation if block_given?
2154
- return result
2155
2163
  end
2156
2164
  rescue ::Gapic::Rest::Error => e
2157
2165
  raise ::Google::Cloud::Error.from_error(e)
@@ -2262,7 +2270,7 @@ module Google
2262
2270
  @app_hub_stub.update_workload request, options do |result, operation|
2263
2271
  result = ::Gapic::Operation.new result, @operations_client, options: options
2264
2272
  yield result, operation if block_given?
2265
- return result
2273
+ throw :response, result
2266
2274
  end
2267
2275
  rescue ::Gapic::Rest::Error => e
2268
2276
  raise ::Google::Cloud::Error.from_error(e)
@@ -2365,7 +2373,7 @@ module Google
2365
2373
  @app_hub_stub.delete_workload request, options do |result, operation|
2366
2374
  result = ::Gapic::Operation.new result, @operations_client, options: options
2367
2375
  yield result, operation if block_given?
2368
- return result
2376
+ throw :response, result
2369
2377
  end
2370
2378
  rescue ::Gapic::Rest::Error => e
2371
2379
  raise ::Google::Cloud::Error.from_error(e)
@@ -2458,7 +2466,6 @@ module Google
2458
2466
 
2459
2467
  @app_hub_stub.list_applications request, options do |result, operation|
2460
2468
  yield result, operation if block_given?
2461
- return result
2462
2469
  end
2463
2470
  rescue ::Gapic::Rest::Error => e
2464
2471
  raise ::Google::Cloud::Error.from_error(e)
@@ -2567,7 +2574,7 @@ module Google
2567
2574
  @app_hub_stub.create_application request, options do |result, operation|
2568
2575
  result = ::Gapic::Operation.new result, @operations_client, options: options
2569
2576
  yield result, operation if block_given?
2570
- return result
2577
+ throw :response, result
2571
2578
  end
2572
2579
  rescue ::Gapic::Rest::Error => e
2573
2580
  raise ::Google::Cloud::Error.from_error(e)
@@ -2648,7 +2655,6 @@ module Google
2648
2655
 
2649
2656
  @app_hub_stub.get_application request, options do |result, operation|
2650
2657
  yield result, operation if block_given?
2651
- return result
2652
2658
  end
2653
2659
  rescue ::Gapic::Rest::Error => e
2654
2660
  raise ::Google::Cloud::Error.from_error(e)
@@ -2759,7 +2765,7 @@ module Google
2759
2765
  @app_hub_stub.update_application request, options do |result, operation|
2760
2766
  result = ::Gapic::Operation.new result, @operations_client, options: options
2761
2767
  yield result, operation if block_given?
2762
- return result
2768
+ throw :response, result
2763
2769
  end
2764
2770
  rescue ::Gapic::Rest::Error => e
2765
2771
  raise ::Google::Cloud::Error.from_error(e)
@@ -2862,7 +2868,7 @@ module Google
2862
2868
  @app_hub_stub.delete_application request, options do |result, operation|
2863
2869
  result = ::Gapic::Operation.new result, @operations_client, options: options
2864
2870
  yield result, operation if block_given?
2865
- return result
2871
+ throw :response, result
2866
2872
  end
2867
2873
  rescue ::Gapic::Rest::Error => e
2868
2874
  raise ::Google::Cloud::Error.from_error(e)
@@ -2942,6 +2948,11 @@ module Google
2942
2948
  # default endpoint URL. The default value of nil uses the environment
2943
2949
  # universe (usually the default "googleapis.com" universe).
2944
2950
  # @return [::String,nil]
2951
+ # @!attribute [rw] logger
2952
+ # A custom logger to use for request/response debug logging, or the value
2953
+ # `:default` (the default) to construct a default logger, or `nil` to
2954
+ # explicitly disable logging.
2955
+ # @return [::Logger,:default,nil]
2945
2956
  #
2946
2957
  class Configuration
2947
2958
  extend ::Gapic::Config
@@ -2970,6 +2981,7 @@ module Google
2970
2981
  # by the host service.
2971
2982
  # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
2972
2983
  config_attr :bindings_override, {}, ::Hash, nil
2984
+ config_attr :logger, :default, ::Logger, nil, :default
2973
2985
 
2974
2986
  # @private
2975
2987
  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)
@@ -543,6 +534,11 @@ module Google
543
534
  # default endpoint URL. The default value of nil uses the environment
544
535
  # universe (usually the default "googleapis.com" universe).
545
536
  # @return [::String,nil]
537
+ # @!attribute [rw] logger
538
+ # A custom logger to use for request/response debug logging, or the value
539
+ # `:default` (the default) to construct a default logger, or `nil` to
540
+ # explicitly disable logging.
541
+ # @return [::Logger,:default,nil]
546
542
  #
547
543
  class Configuration
548
544
  extend ::Gapic::Config
@@ -564,6 +560,7 @@ module Google
564
560
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
565
561
  config_attr :quota_project, nil, ::String, nil
566
562
  config_attr :universe_domain, nil, ::String, nil
563
+ config_attr :logger, :default, ::Logger, nil, :default
567
564
 
568
565
  # @private
569
566
  def initialize parent_config = nil
@@ -683,16 +680,18 @@ module Google
683
680
 
684
681
  response = @client_stub.make_http_request(
685
682
  verb,
686
- uri: uri,
687
- body: body || "",
688
- params: query_string_params,
683
+ uri: uri,
684
+ body: body || "",
685
+ params: query_string_params,
686
+ method_name: "list_operations",
689
687
  options: options
690
688
  )
691
689
  operation = ::Gapic::Rest::TransportOperation.new response
692
690
  result = ::Google::Longrunning::ListOperationsResponse.decode_json response.body, ignore_unknown_fields: true
693
-
694
- yield result, operation if block_given?
695
- result
691
+ catch :response do
692
+ yield result, operation if block_given?
693
+ result
694
+ end
696
695
  end
697
696
 
698
697
  ##
@@ -721,16 +720,18 @@ module Google
721
720
 
722
721
  response = @client_stub.make_http_request(
723
722
  verb,
724
- uri: uri,
725
- body: body || "",
726
- params: query_string_params,
723
+ uri: uri,
724
+ body: body || "",
725
+ params: query_string_params,
726
+ method_name: "get_operation",
727
727
  options: options
728
728
  )
729
729
  operation = ::Gapic::Rest::TransportOperation.new response
730
730
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
731
-
732
- yield result, operation if block_given?
733
- result
731
+ catch :response do
732
+ yield result, operation if block_given?
733
+ result
734
+ end
734
735
  end
735
736
 
736
737
  ##
@@ -759,16 +760,18 @@ module Google
759
760
 
760
761
  response = @client_stub.make_http_request(
761
762
  verb,
762
- uri: uri,
763
- body: body || "",
764
- params: query_string_params,
763
+ uri: uri,
764
+ body: body || "",
765
+ params: query_string_params,
766
+ method_name: "delete_operation",
765
767
  options: options
766
768
  )
767
769
  operation = ::Gapic::Rest::TransportOperation.new response
768
770
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
769
-
770
- yield result, operation if block_given?
771
- result
771
+ catch :response do
772
+ yield result, operation if block_given?
773
+ result
774
+ end
772
775
  end
773
776
 
774
777
  ##
@@ -797,16 +800,18 @@ module Google
797
800
 
798
801
  response = @client_stub.make_http_request(
799
802
  verb,
800
- uri: uri,
801
- body: body || "",
802
- params: query_string_params,
803
+ uri: uri,
804
+ body: body || "",
805
+ params: query_string_params,
806
+ method_name: "cancel_operation",
803
807
  options: options
804
808
  )
805
809
  operation = ::Gapic::Rest::TransportOperation.new response
806
810
  result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
807
-
808
- yield result, operation if block_given?
809
- result
811
+ catch :response do
812
+ yield result, operation if block_given?
813
+ result
814
+ end
810
815
  end
811
816
 
812
817
  ##