google-cloud-apigee_registry-v1 0.8.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,7 +30,8 @@ module Google
30
30
  # including transcoding, making the REST call, and deserialing the response.
31
31
  #
32
32
  class ServiceStub
33
- def initialize endpoint:, endpoint_template:, universe_domain:, credentials:
33
+ # @private
34
+ def initialize endpoint:, endpoint_template:, universe_domain:, credentials:, logger:
34
35
  # These require statements are intentionally placed here to initialize
35
36
  # the REST modules only when it's required.
36
37
  require "gapic/rest"
@@ -40,7 +41,9 @@ module Google
40
41
  universe_domain: universe_domain,
41
42
  credentials: credentials,
42
43
  numeric_enums: true,
43
- raise_faraday_errors: false
44
+ service_name: self.class,
45
+ raise_faraday_errors: false,
46
+ logger: logger
44
47
  end
45
48
 
46
49
  ##
@@ -61,6 +64,15 @@ module Google
61
64
  @client_stub.endpoint
62
65
  end
63
66
 
67
+ ##
68
+ # The logger used for request/response debug logging.
69
+ #
70
+ # @return [Logger]
71
+ #
72
+ def logger stub: false
73
+ stub ? @client_stub.stub_logger : @client_stub.logger
74
+ end
75
+
64
76
  ##
65
77
  # Baseline implementation for the create_instance REST call
66
78
  #
@@ -87,16 +99,18 @@ module Google
87
99
 
88
100
  response = @client_stub.make_http_request(
89
101
  verb,
90
- uri: uri,
91
- body: body || "",
92
- params: query_string_params,
102
+ uri: uri,
103
+ body: body || "",
104
+ params: query_string_params,
105
+ method_name: "create_instance",
93
106
  options: options
94
107
  )
95
108
  operation = ::Gapic::Rest::TransportOperation.new response
96
109
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
97
-
98
- yield result, operation if block_given?
99
- result
110
+ catch :response do
111
+ yield result, operation if block_given?
112
+ result
113
+ end
100
114
  end
101
115
 
102
116
  ##
@@ -125,16 +139,18 @@ module Google
125
139
 
126
140
  response = @client_stub.make_http_request(
127
141
  verb,
128
- uri: uri,
129
- body: body || "",
130
- params: query_string_params,
142
+ uri: uri,
143
+ body: body || "",
144
+ params: query_string_params,
145
+ method_name: "delete_instance",
131
146
  options: options
132
147
  )
133
148
  operation = ::Gapic::Rest::TransportOperation.new response
134
149
  result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
135
-
136
- yield result, operation if block_given?
137
- result
150
+ catch :response do
151
+ yield result, operation if block_given?
152
+ result
153
+ end
138
154
  end
139
155
 
140
156
  ##
@@ -163,16 +179,18 @@ module Google
163
179
 
164
180
  response = @client_stub.make_http_request(
165
181
  verb,
166
- uri: uri,
167
- body: body || "",
168
- params: query_string_params,
182
+ uri: uri,
183
+ body: body || "",
184
+ params: query_string_params,
185
+ method_name: "get_instance",
169
186
  options: options
170
187
  )
171
188
  operation = ::Gapic::Rest::TransportOperation.new response
172
189
  result = ::Google::Cloud::ApigeeRegistry::V1::Instance.decode_json response.body, ignore_unknown_fields: true
173
-
174
- yield result, operation if block_given?
175
- result
190
+ catch :response do
191
+ yield result, operation if block_given?
192
+ result
193
+ end
176
194
  end
177
195
 
178
196
  ##
@@ -328,14 +328,26 @@ module Google
328
328
  universe_domain: @config.universe_domain,
329
329
  channel_args: @config.channel_args,
330
330
  interceptors: @config.interceptors,
331
- channel_pool_config: @config.channel_pool
331
+ channel_pool_config: @config.channel_pool,
332
+ logger: @config.logger
332
333
  )
333
334
 
335
+ @registry_stub.stub_logger&.info do |entry|
336
+ entry.set_system_name
337
+ entry.set_service
338
+ entry.message = "Created client for #{entry.service}"
339
+ entry.set_credentials_fields credentials
340
+ entry.set "customEndpoint", @config.endpoint if @config.endpoint
341
+ entry.set "defaultTimeout", @config.timeout if @config.timeout
342
+ entry.set "quotaProject", @quota_project_id if @quota_project_id
343
+ end
344
+
334
345
  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
335
346
  config.credentials = credentials
336
347
  config.quota_project = @quota_project_id
337
348
  config.endpoint = @registry_stub.endpoint
338
349
  config.universe_domain = @registry_stub.universe_domain
350
+ config.logger = @registry_stub.logger if config.respond_to? :logger=
339
351
  end
340
352
 
341
353
  @iam_policy_client = Google::Iam::V1::IAMPolicy::Client.new do |config|
@@ -343,6 +355,7 @@ module Google
343
355
  config.quota_project = @quota_project_id
344
356
  config.endpoint = @registry_stub.endpoint
345
357
  config.universe_domain = @registry_stub.universe_domain
358
+ config.logger = @registry_stub.logger if config.respond_to? :logger=
346
359
  end
347
360
  end
348
361
 
@@ -360,6 +373,15 @@ module Google
360
373
  #
361
374
  attr_reader :iam_policy_client
362
375
 
376
+ ##
377
+ # The logger used for request/response debug logging.
378
+ #
379
+ # @return [Logger]
380
+ #
381
+ def logger
382
+ @registry_stub.logger
383
+ end
384
+
363
385
  # Service calls
364
386
 
365
387
  ##
@@ -462,7 +484,7 @@ module Google
462
484
  @registry_stub.call_rpc :list_apis, request, options: options do |response, operation|
463
485
  response = ::Gapic::PagedEnumerable.new @registry_stub, :list_apis, request, response, operation, options
464
486
  yield response, operation if block_given?
465
- return response
487
+ throw :response, response
466
488
  end
467
489
  rescue ::GRPC::BadStatus => e
468
490
  raise ::Google::Cloud::Error.from_error(e)
@@ -549,7 +571,6 @@ module Google
549
571
 
550
572
  @registry_stub.call_rpc :get_api, request, options: options do |response, operation|
551
573
  yield response, operation if block_given?
552
- return response
553
574
  end
554
575
  rescue ::GRPC::BadStatus => e
555
576
  raise ::Google::Cloud::Error.from_error(e)
@@ -646,7 +667,6 @@ module Google
646
667
 
647
668
  @registry_stub.call_rpc :create_api, request, options: options do |response, operation|
648
669
  yield response, operation if block_given?
649
- return response
650
670
  end
651
671
  rescue ::GRPC::BadStatus => e
652
672
  raise ::Google::Cloud::Error.from_error(e)
@@ -743,7 +763,6 @@ module Google
743
763
 
744
764
  @registry_stub.call_rpc :update_api, request, options: options do |response, operation|
745
765
  yield response, operation if block_given?
746
- return response
747
766
  end
748
767
  rescue ::GRPC::BadStatus => e
749
768
  raise ::Google::Cloud::Error.from_error(e)
@@ -834,7 +853,6 @@ module Google
834
853
 
835
854
  @registry_stub.call_rpc :delete_api, request, options: options do |response, operation|
836
855
  yield response, operation if block_given?
837
- return response
838
856
  end
839
857
  rescue ::GRPC::BadStatus => e
840
858
  raise ::Google::Cloud::Error.from_error(e)
@@ -940,7 +958,7 @@ module Google
940
958
  @registry_stub.call_rpc :list_api_versions, request, options: options do |response, operation|
941
959
  response = ::Gapic::PagedEnumerable.new @registry_stub, :list_api_versions, request, response, operation, options
942
960
  yield response, operation if block_given?
943
- return response
961
+ throw :response, response
944
962
  end
945
963
  rescue ::GRPC::BadStatus => e
946
964
  raise ::Google::Cloud::Error.from_error(e)
@@ -1027,7 +1045,6 @@ module Google
1027
1045
 
1028
1046
  @registry_stub.call_rpc :get_api_version, request, options: options do |response, operation|
1029
1047
  yield response, operation if block_given?
1030
- return response
1031
1048
  end
1032
1049
  rescue ::GRPC::BadStatus => e
1033
1050
  raise ::Google::Cloud::Error.from_error(e)
@@ -1124,7 +1141,6 @@ module Google
1124
1141
 
1125
1142
  @registry_stub.call_rpc :create_api_version, request, options: options do |response, operation|
1126
1143
  yield response, operation if block_given?
1127
- return response
1128
1144
  end
1129
1145
  rescue ::GRPC::BadStatus => e
1130
1146
  raise ::Google::Cloud::Error.from_error(e)
@@ -1221,7 +1237,6 @@ module Google
1221
1237
 
1222
1238
  @registry_stub.call_rpc :update_api_version, request, options: options do |response, operation|
1223
1239
  yield response, operation if block_given?
1224
- return response
1225
1240
  end
1226
1241
  rescue ::GRPC::BadStatus => e
1227
1242
  raise ::Google::Cloud::Error.from_error(e)
@@ -1312,7 +1327,6 @@ module Google
1312
1327
 
1313
1328
  @registry_stub.call_rpc :delete_api_version, request, options: options do |response, operation|
1314
1329
  yield response, operation if block_given?
1315
- return response
1316
1330
  end
1317
1331
  rescue ::GRPC::BadStatus => e
1318
1332
  raise ::Google::Cloud::Error.from_error(e)
@@ -1418,7 +1432,7 @@ module Google
1418
1432
  @registry_stub.call_rpc :list_api_specs, request, options: options do |response, operation|
1419
1433
  response = ::Gapic::PagedEnumerable.new @registry_stub, :list_api_specs, request, response, operation, options
1420
1434
  yield response, operation if block_given?
1421
- return response
1435
+ throw :response, response
1422
1436
  end
1423
1437
  rescue ::GRPC::BadStatus => e
1424
1438
  raise ::Google::Cloud::Error.from_error(e)
@@ -1505,7 +1519,6 @@ module Google
1505
1519
 
1506
1520
  @registry_stub.call_rpc :get_api_spec, request, options: options do |response, operation|
1507
1521
  yield response, operation if block_given?
1508
- return response
1509
1522
  end
1510
1523
  rescue ::GRPC::BadStatus => e
1511
1524
  raise ::Google::Cloud::Error.from_error(e)
@@ -1595,7 +1608,6 @@ module Google
1595
1608
 
1596
1609
  @registry_stub.call_rpc :get_api_spec_contents, request, options: options do |response, operation|
1597
1610
  yield response, operation if block_given?
1598
- return response
1599
1611
  end
1600
1612
  rescue ::GRPC::BadStatus => e
1601
1613
  raise ::Google::Cloud::Error.from_error(e)
@@ -1692,7 +1704,6 @@ module Google
1692
1704
 
1693
1705
  @registry_stub.call_rpc :create_api_spec, request, options: options do |response, operation|
1694
1706
  yield response, operation if block_given?
1695
- return response
1696
1707
  end
1697
1708
  rescue ::GRPC::BadStatus => e
1698
1709
  raise ::Google::Cloud::Error.from_error(e)
@@ -1789,7 +1800,6 @@ module Google
1789
1800
 
1790
1801
  @registry_stub.call_rpc :update_api_spec, request, options: options do |response, operation|
1791
1802
  yield response, operation if block_given?
1792
- return response
1793
1803
  end
1794
1804
  rescue ::GRPC::BadStatus => e
1795
1805
  raise ::Google::Cloud::Error.from_error(e)
@@ -1880,7 +1890,6 @@ module Google
1880
1890
 
1881
1891
  @registry_stub.call_rpc :delete_api_spec, request, options: options do |response, operation|
1882
1892
  yield response, operation if block_given?
1883
- return response
1884
1893
  end
1885
1894
  rescue ::GRPC::BadStatus => e
1886
1895
  raise ::Google::Cloud::Error.from_error(e)
@@ -1969,7 +1978,6 @@ module Google
1969
1978
 
1970
1979
  @registry_stub.call_rpc :tag_api_spec_revision, request, options: options do |response, operation|
1971
1980
  yield response, operation if block_given?
1972
- return response
1973
1981
  end
1974
1982
  rescue ::GRPC::BadStatus => e
1975
1983
  raise ::Google::Cloud::Error.from_error(e)
@@ -2066,7 +2074,7 @@ module Google
2066
2074
  @registry_stub.call_rpc :list_api_spec_revisions, request, options: options do |response, operation|
2067
2075
  response = ::Gapic::PagedEnumerable.new @registry_stub, :list_api_spec_revisions, request, response, operation, options
2068
2076
  yield response, operation if block_given?
2069
- return response
2077
+ throw :response, response
2070
2078
  end
2071
2079
  rescue ::GRPC::BadStatus => e
2072
2080
  raise ::Google::Cloud::Error.from_error(e)
@@ -2158,7 +2166,6 @@ module Google
2158
2166
 
2159
2167
  @registry_stub.call_rpc :rollback_api_spec, request, options: options do |response, operation|
2160
2168
  yield response, operation if block_given?
2161
- return response
2162
2169
  end
2163
2170
  rescue ::GRPC::BadStatus => e
2164
2171
  raise ::Google::Cloud::Error.from_error(e)
@@ -2248,7 +2255,6 @@ module Google
2248
2255
 
2249
2256
  @registry_stub.call_rpc :delete_api_spec_revision, request, options: options do |response, operation|
2250
2257
  yield response, operation if block_given?
2251
- return response
2252
2258
  end
2253
2259
  rescue ::GRPC::BadStatus => e
2254
2260
  raise ::Google::Cloud::Error.from_error(e)
@@ -2354,7 +2360,7 @@ module Google
2354
2360
  @registry_stub.call_rpc :list_api_deployments, request, options: options do |response, operation|
2355
2361
  response = ::Gapic::PagedEnumerable.new @registry_stub, :list_api_deployments, request, response, operation, options
2356
2362
  yield response, operation if block_given?
2357
- return response
2363
+ throw :response, response
2358
2364
  end
2359
2365
  rescue ::GRPC::BadStatus => e
2360
2366
  raise ::Google::Cloud::Error.from_error(e)
@@ -2441,7 +2447,6 @@ module Google
2441
2447
 
2442
2448
  @registry_stub.call_rpc :get_api_deployment, request, options: options do |response, operation|
2443
2449
  yield response, operation if block_given?
2444
- return response
2445
2450
  end
2446
2451
  rescue ::GRPC::BadStatus => e
2447
2452
  raise ::Google::Cloud::Error.from_error(e)
@@ -2538,7 +2543,6 @@ module Google
2538
2543
 
2539
2544
  @registry_stub.call_rpc :create_api_deployment, request, options: options do |response, operation|
2540
2545
  yield response, operation if block_given?
2541
- return response
2542
2546
  end
2543
2547
  rescue ::GRPC::BadStatus => e
2544
2548
  raise ::Google::Cloud::Error.from_error(e)
@@ -2635,7 +2639,6 @@ module Google
2635
2639
 
2636
2640
  @registry_stub.call_rpc :update_api_deployment, request, options: options do |response, operation|
2637
2641
  yield response, operation if block_given?
2638
- return response
2639
2642
  end
2640
2643
  rescue ::GRPC::BadStatus => e
2641
2644
  raise ::Google::Cloud::Error.from_error(e)
@@ -2726,7 +2729,6 @@ module Google
2726
2729
 
2727
2730
  @registry_stub.call_rpc :delete_api_deployment, request, options: options do |response, operation|
2728
2731
  yield response, operation if block_given?
2729
- return response
2730
2732
  end
2731
2733
  rescue ::GRPC::BadStatus => e
2732
2734
  raise ::Google::Cloud::Error.from_error(e)
@@ -2816,7 +2818,6 @@ module Google
2816
2818
 
2817
2819
  @registry_stub.call_rpc :tag_api_deployment_revision, request, options: options do |response, operation|
2818
2820
  yield response, operation if block_given?
2819
- return response
2820
2821
  end
2821
2822
  rescue ::GRPC::BadStatus => e
2822
2823
  raise ::Google::Cloud::Error.from_error(e)
@@ -2913,7 +2914,7 @@ module Google
2913
2914
  @registry_stub.call_rpc :list_api_deployment_revisions, request, options: options do |response, operation|
2914
2915
  response = ::Gapic::PagedEnumerable.new @registry_stub, :list_api_deployment_revisions, request, response, operation, options
2915
2916
  yield response, operation if block_given?
2916
- return response
2917
+ throw :response, response
2917
2918
  end
2918
2919
  rescue ::GRPC::BadStatus => e
2919
2920
  raise ::Google::Cloud::Error.from_error(e)
@@ -3005,7 +3006,6 @@ module Google
3005
3006
 
3006
3007
  @registry_stub.call_rpc :rollback_api_deployment, request, options: options do |response, operation|
3007
3008
  yield response, operation if block_given?
3008
- return response
3009
3009
  end
3010
3010
  rescue ::GRPC::BadStatus => e
3011
3011
  raise ::Google::Cloud::Error.from_error(e)
@@ -3095,7 +3095,6 @@ module Google
3095
3095
 
3096
3096
  @registry_stub.call_rpc :delete_api_deployment_revision, request, options: options do |response, operation|
3097
3097
  yield response, operation if block_given?
3098
- return response
3099
3098
  end
3100
3099
  rescue ::GRPC::BadStatus => e
3101
3100
  raise ::Google::Cloud::Error.from_error(e)
@@ -3201,7 +3200,7 @@ module Google
3201
3200
  @registry_stub.call_rpc :list_artifacts, request, options: options do |response, operation|
3202
3201
  response = ::Gapic::PagedEnumerable.new @registry_stub, :list_artifacts, request, response, operation, options
3203
3202
  yield response, operation if block_given?
3204
- return response
3203
+ throw :response, response
3205
3204
  end
3206
3205
  rescue ::GRPC::BadStatus => e
3207
3206
  raise ::Google::Cloud::Error.from_error(e)
@@ -3288,7 +3287,6 @@ module Google
3288
3287
 
3289
3288
  @registry_stub.call_rpc :get_artifact, request, options: options do |response, operation|
3290
3289
  yield response, operation if block_given?
3291
- return response
3292
3290
  end
3293
3291
  rescue ::GRPC::BadStatus => e
3294
3292
  raise ::Google::Cloud::Error.from_error(e)
@@ -3378,7 +3376,6 @@ module Google
3378
3376
 
3379
3377
  @registry_stub.call_rpc :get_artifact_contents, request, options: options do |response, operation|
3380
3378
  yield response, operation if block_given?
3381
- return response
3382
3379
  end
3383
3380
  rescue ::GRPC::BadStatus => e
3384
3381
  raise ::Google::Cloud::Error.from_error(e)
@@ -3475,7 +3472,6 @@ module Google
3475
3472
 
3476
3473
  @registry_stub.call_rpc :create_artifact, request, options: options do |response, operation|
3477
3474
  yield response, operation if block_given?
3478
- return response
3479
3475
  end
3480
3476
  rescue ::GRPC::BadStatus => e
3481
3477
  raise ::Google::Cloud::Error.from_error(e)
@@ -3564,7 +3560,6 @@ module Google
3564
3560
 
3565
3561
  @registry_stub.call_rpc :replace_artifact, request, options: options do |response, operation|
3566
3562
  yield response, operation if block_given?
3567
- return response
3568
3563
  end
3569
3564
  rescue ::GRPC::BadStatus => e
3570
3565
  raise ::Google::Cloud::Error.from_error(e)
@@ -3651,7 +3646,6 @@ module Google
3651
3646
 
3652
3647
  @registry_stub.call_rpc :delete_artifact, request, options: options do |response, operation|
3653
3648
  yield response, operation if block_given?
3654
- return response
3655
3649
  end
3656
3650
  rescue ::GRPC::BadStatus => e
3657
3651
  raise ::Google::Cloud::Error.from_error(e)
@@ -3701,6 +3695,13 @@ module Google
3701
3695
  # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
3702
3696
  # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
3703
3697
  # * (`nil`) indicating no credentials
3698
+ #
3699
+ # Warning: If you accept a credential configuration (JSON file or Hash) from an
3700
+ # external source for authentication to Google Cloud, you must validate it before
3701
+ # providing it to a Google API client library. Providing an unvalidated credential
3702
+ # configuration to Google APIs can compromise the security of your systems and data.
3703
+ # For more information, refer to [Validate credential configurations from external
3704
+ # sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
3704
3705
  # @return [::Object]
3705
3706
  # @!attribute [rw] scope
3706
3707
  # The OAuth scopes
@@ -3740,6 +3741,11 @@ module Google
3740
3741
  # default endpoint URL. The default value of nil uses the environment
3741
3742
  # universe (usually the default "googleapis.com" universe).
3742
3743
  # @return [::String,nil]
3744
+ # @!attribute [rw] logger
3745
+ # A custom logger to use for request/response debug logging, or the value
3746
+ # `:default` (the default) to construct a default logger, or `nil` to
3747
+ # explicitly disable logging.
3748
+ # @return [::Logger,:default,nil]
3743
3749
  #
3744
3750
  class Configuration
3745
3751
  extend ::Gapic::Config
@@ -3764,6 +3770,7 @@ module Google
3764
3770
  config_attr :retry_policy, nil, ::Hash, ::Proc, nil
3765
3771
  config_attr :quota_project, nil, ::String, nil
3766
3772
  config_attr :universe_domain, nil, ::String, nil
3773
+ config_attr :logger, :default, ::Logger, nil, :default
3767
3774
 
3768
3775
  # @private
3769
3776
  def initialize parent_config = nil