google-cloud-app_hub-v1 0.1.1 → 0.3.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.
@@ -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)
@@ -2910,6 +2916,13 @@ module Google
2910
2916
  # * (`Signet::OAuth2::Client`) A signet oauth2 client object
2911
2917
  # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
2912
2918
  # * (`nil`) indicating no credentials
2919
+ #
2920
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
2921
+ # external source for authentication to Google Cloud, you must validate it before
2922
+ # providing it to a Google API client library. Providing an unvalidated credential
2923
+ # configuration to Google APIs can compromise the security of your systems and data.
2924
+ # For more information, refer to [Validate credential configurations from external
2925
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
2913
2926
  # @return [::Object]
2914
2927
  # @!attribute [rw] scope
2915
2928
  # The OAuth scopes
@@ -2942,6 +2955,11 @@ module Google
2942
2955
  # default endpoint URL. The default value of nil uses the environment
2943
2956
  # universe (usually the default "googleapis.com" universe).
2944
2957
  # @return [::String,nil]
2958
+ # @!attribute [rw] logger
2959
+ # A custom logger to use for request/response debug logging, or the value
2960
+ # `:default` (the default) to construct a default logger, or `nil` to
2961
+ # explicitly disable logging.
2962
+ # @return [::Logger,:default,nil]
2945
2963
  #
2946
2964
  class Configuration
2947
2965
  extend ::Gapic::Config
@@ -2970,6 +2988,7 @@ module Google
2970
2988
  # by the host service.
2971
2989
  # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
2972
2990
  config_attr :bindings_override, {}, ::Hash, nil
2991
+ config_attr :logger, :default, ::Logger, nil, :default
2973
2992
 
2974
2993
  # @private
2975
2994
  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
  ##