google-cloud-recommendation_engine-v1beta1 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -20
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service/client.rb +29 -7
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service/operations.rb +12 -15
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service/rest/client.rb +29 -7
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service/rest/operations.rb +43 -38
- data/lib/google/cloud/recommendation_engine/v1beta1/catalog_service/rest/service_stub.rb +62 -38
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_api_key_registry/client.rb +28 -4
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_api_key_registry/rest/client.rb +28 -4
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_api_key_registry/rest/service_stub.rb +38 -20
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_service/client.rb +28 -2
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_service/rest/client.rb +28 -2
- data/lib/google/cloud/recommendation_engine/v1beta1/prediction_service/rest/service_stub.rb +22 -8
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service/client.rb +30 -6
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service/operations.rb +12 -15
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service/rest/client.rb +30 -6
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service/rest/operations.rb +43 -38
- data/lib/google/cloud/recommendation_engine/v1beta1/user_event_service/rest/service_stub.rb +54 -32
- data/lib/google/cloud/recommendation_engine/v1beta1/version.rb +1 -1
- data/proto_docs/google/api/client.rb +39 -0
- data/proto_docs/google/longrunning/operations.rb +19 -14
- metadata +5 -5
@@ -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
|
-
|
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
|
-
|
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_catalog_item 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:
|
91
|
-
body:
|
92
|
-
params:
|
102
|
+
uri: uri,
|
103
|
+
body: body || "",
|
104
|
+
params: query_string_params,
|
105
|
+
method_name: "create_catalog_item",
|
93
106
|
options: options
|
94
107
|
)
|
95
108
|
operation = ::Gapic::Rest::TransportOperation.new response
|
96
109
|
result = ::Google::Cloud::RecommendationEngine::V1beta1::CatalogItem.decode_json response.body, ignore_unknown_fields: true
|
97
|
-
|
98
|
-
|
99
|
-
|
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:
|
129
|
-
body:
|
130
|
-
params:
|
142
|
+
uri: uri,
|
143
|
+
body: body || "",
|
144
|
+
params: query_string_params,
|
145
|
+
method_name: "get_catalog_item",
|
131
146
|
options: options
|
132
147
|
)
|
133
148
|
operation = ::Gapic::Rest::TransportOperation.new response
|
134
149
|
result = ::Google::Cloud::RecommendationEngine::V1beta1::CatalogItem.decode_json response.body, ignore_unknown_fields: true
|
135
|
-
|
136
|
-
|
137
|
-
|
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:
|
167
|
-
body:
|
168
|
-
params:
|
182
|
+
uri: uri,
|
183
|
+
body: body || "",
|
184
|
+
params: query_string_params,
|
185
|
+
method_name: "list_catalog_items",
|
169
186
|
options: options
|
170
187
|
)
|
171
188
|
operation = ::Gapic::Rest::TransportOperation.new response
|
172
189
|
result = ::Google::Cloud::RecommendationEngine::V1beta1::ListCatalogItemsResponse.decode_json response.body, ignore_unknown_fields: true
|
173
|
-
|
174
|
-
|
175
|
-
|
190
|
+
catch :response do
|
191
|
+
yield result, operation if block_given?
|
192
|
+
result
|
193
|
+
end
|
176
194
|
end
|
177
195
|
|
178
196
|
##
|
@@ -201,16 +219,18 @@ module Google
|
|
201
219
|
|
202
220
|
response = @client_stub.make_http_request(
|
203
221
|
verb,
|
204
|
-
uri:
|
205
|
-
body:
|
206
|
-
params:
|
222
|
+
uri: uri,
|
223
|
+
body: body || "",
|
224
|
+
params: query_string_params,
|
225
|
+
method_name: "update_catalog_item",
|
207
226
|
options: options
|
208
227
|
)
|
209
228
|
operation = ::Gapic::Rest::TransportOperation.new response
|
210
229
|
result = ::Google::Cloud::RecommendationEngine::V1beta1::CatalogItem.decode_json response.body, ignore_unknown_fields: true
|
211
|
-
|
212
|
-
|
213
|
-
|
230
|
+
catch :response do
|
231
|
+
yield result, operation if block_given?
|
232
|
+
result
|
233
|
+
end
|
214
234
|
end
|
215
235
|
|
216
236
|
##
|
@@ -239,16 +259,18 @@ module Google
|
|
239
259
|
|
240
260
|
response = @client_stub.make_http_request(
|
241
261
|
verb,
|
242
|
-
uri:
|
243
|
-
body:
|
244
|
-
params:
|
262
|
+
uri: uri,
|
263
|
+
body: body || "",
|
264
|
+
params: query_string_params,
|
265
|
+
method_name: "delete_catalog_item",
|
245
266
|
options: options
|
246
267
|
)
|
247
268
|
operation = ::Gapic::Rest::TransportOperation.new response
|
248
269
|
result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
|
249
|
-
|
250
|
-
|
251
|
-
|
270
|
+
catch :response do
|
271
|
+
yield result, operation if block_given?
|
272
|
+
result
|
273
|
+
end
|
252
274
|
end
|
253
275
|
|
254
276
|
##
|
@@ -277,16 +299,18 @@ module Google
|
|
277
299
|
|
278
300
|
response = @client_stub.make_http_request(
|
279
301
|
verb,
|
280
|
-
uri:
|
281
|
-
body:
|
282
|
-
params:
|
302
|
+
uri: uri,
|
303
|
+
body: body || "",
|
304
|
+
params: query_string_params,
|
305
|
+
method_name: "import_catalog_items",
|
283
306
|
options: options
|
284
307
|
)
|
285
308
|
operation = ::Gapic::Rest::TransportOperation.new response
|
286
309
|
result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true
|
287
|
-
|
288
|
-
|
289
|
-
|
310
|
+
catch :response do
|
311
|
+
yield result, operation if block_given?
|
312
|
+
result
|
313
|
+
end
|
290
314
|
end
|
291
315
|
|
292
316
|
##
|
@@ -176,8 +176,28 @@ module Google
|
|
176
176
|
universe_domain: @config.universe_domain,
|
177
177
|
channel_args: @config.channel_args,
|
178
178
|
interceptors: @config.interceptors,
|
179
|
-
channel_pool_config: @config.channel_pool
|
179
|
+
channel_pool_config: @config.channel_pool,
|
180
|
+
logger: @config.logger
|
180
181
|
)
|
182
|
+
|
183
|
+
@prediction_api_key_registry_stub.stub_logger&.info do |entry|
|
184
|
+
entry.set_system_name
|
185
|
+
entry.set_service
|
186
|
+
entry.message = "Created client for #{entry.service}"
|
187
|
+
entry.set_credentials_fields credentials
|
188
|
+
entry.set "customEndpoint", @config.endpoint if @config.endpoint
|
189
|
+
entry.set "defaultTimeout", @config.timeout if @config.timeout
|
190
|
+
entry.set "quotaProject", @quota_project_id if @quota_project_id
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
##
|
195
|
+
# The logger used for request/response debug logging.
|
196
|
+
#
|
197
|
+
# @return [Logger]
|
198
|
+
#
|
199
|
+
def logger
|
200
|
+
@prediction_api_key_registry_stub.logger
|
181
201
|
end
|
182
202
|
|
183
203
|
# Service calls
|
@@ -265,7 +285,6 @@ module Google
|
|
265
285
|
|
266
286
|
@prediction_api_key_registry_stub.call_rpc :create_prediction_api_key_registration, request, options: options do |response, operation|
|
267
287
|
yield response, operation if block_given?
|
268
|
-
return response
|
269
288
|
end
|
270
289
|
rescue ::GRPC::BadStatus => e
|
271
290
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -362,7 +381,7 @@ module Google
|
|
362
381
|
@prediction_api_key_registry_stub.call_rpc :list_prediction_api_key_registrations, request, options: options do |response, operation|
|
363
382
|
response = ::Gapic::PagedEnumerable.new @prediction_api_key_registry_stub, :list_prediction_api_key_registrations, request, response, operation, options
|
364
383
|
yield response, operation if block_given?
|
365
|
-
|
384
|
+
throw :response, response
|
366
385
|
end
|
367
386
|
rescue ::GRPC::BadStatus => e
|
368
387
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -449,7 +468,6 @@ module Google
|
|
449
468
|
|
450
469
|
@prediction_api_key_registry_stub.call_rpc :delete_prediction_api_key_registration, request, options: options do |response, operation|
|
451
470
|
yield response, operation if block_given?
|
452
|
-
return response
|
453
471
|
end
|
454
472
|
rescue ::GRPC::BadStatus => e
|
455
473
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -538,6 +556,11 @@ module Google
|
|
538
556
|
# default endpoint URL. The default value of nil uses the environment
|
539
557
|
# universe (usually the default "googleapis.com" universe).
|
540
558
|
# @return [::String,nil]
|
559
|
+
# @!attribute [rw] logger
|
560
|
+
# A custom logger to use for request/response debug logging, or the value
|
561
|
+
# `:default` (the default) to construct a default logger, or `nil` to
|
562
|
+
# explicitly disable logging.
|
563
|
+
# @return [::Logger,:default,nil]
|
541
564
|
#
|
542
565
|
class Configuration
|
543
566
|
extend ::Gapic::Config
|
@@ -562,6 +585,7 @@ module Google
|
|
562
585
|
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
563
586
|
config_attr :quota_project, nil, ::String, nil
|
564
587
|
config_attr :universe_domain, nil, ::String, nil
|
588
|
+
config_attr :logger, :default, ::Logger, nil, :default
|
565
589
|
|
566
590
|
# @private
|
567
591
|
def initialize parent_config = nil
|
data/lib/google/cloud/recommendation_engine/v1beta1/prediction_api_key_registry/rest/client.rb
CHANGED
@@ -169,8 +169,28 @@ module Google
|
|
169
169
|
endpoint: @config.endpoint,
|
170
170
|
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
|
171
171
|
universe_domain: @config.universe_domain,
|
172
|
-
credentials: credentials
|
172
|
+
credentials: credentials,
|
173
|
+
logger: @config.logger
|
173
174
|
)
|
175
|
+
|
176
|
+
@prediction_api_key_registry_stub.logger(stub: true)&.info do |entry|
|
177
|
+
entry.set_system_name
|
178
|
+
entry.set_service
|
179
|
+
entry.message = "Created client for #{entry.service}"
|
180
|
+
entry.set_credentials_fields credentials
|
181
|
+
entry.set "customEndpoint", @config.endpoint if @config.endpoint
|
182
|
+
entry.set "defaultTimeout", @config.timeout if @config.timeout
|
183
|
+
entry.set "quotaProject", @quota_project_id if @quota_project_id
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
##
|
188
|
+
# The logger used for request/response debug logging.
|
189
|
+
#
|
190
|
+
# @return [Logger]
|
191
|
+
#
|
192
|
+
def logger
|
193
|
+
@prediction_api_key_registry_stub.logger
|
174
194
|
end
|
175
195
|
|
176
196
|
# Service calls
|
@@ -251,7 +271,6 @@ module Google
|
|
251
271
|
|
252
272
|
@prediction_api_key_registry_stub.create_prediction_api_key_registration request, options do |result, operation|
|
253
273
|
yield result, operation if block_given?
|
254
|
-
return result
|
255
274
|
end
|
256
275
|
rescue ::Gapic::Rest::Error => e
|
257
276
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -341,7 +360,7 @@ module Google
|
|
341
360
|
@prediction_api_key_registry_stub.list_prediction_api_key_registrations request, options do |result, operation|
|
342
361
|
result = ::Gapic::Rest::PagedEnumerable.new @prediction_api_key_registry_stub, :list_prediction_api_key_registrations, "prediction_api_key_registrations", request, result, options
|
343
362
|
yield result, operation if block_given?
|
344
|
-
|
363
|
+
throw :response, result
|
345
364
|
end
|
346
365
|
rescue ::Gapic::Rest::Error => e
|
347
366
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -421,7 +440,6 @@ module Google
|
|
421
440
|
|
422
441
|
@prediction_api_key_registry_stub.delete_prediction_api_key_registration request, options do |result, operation|
|
423
442
|
yield result, operation if block_given?
|
424
|
-
return result
|
425
443
|
end
|
426
444
|
rescue ::Gapic::Rest::Error => e
|
427
445
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -501,6 +519,11 @@ module Google
|
|
501
519
|
# default endpoint URL. The default value of nil uses the environment
|
502
520
|
# universe (usually the default "googleapis.com" universe).
|
503
521
|
# @return [::String,nil]
|
522
|
+
# @!attribute [rw] logger
|
523
|
+
# A custom logger to use for request/response debug logging, or the value
|
524
|
+
# `:default` (the default) to construct a default logger, or `nil` to
|
525
|
+
# explicitly disable logging.
|
526
|
+
# @return [::Logger,:default,nil]
|
504
527
|
#
|
505
528
|
class Configuration
|
506
529
|
extend ::Gapic::Config
|
@@ -522,6 +545,7 @@ module Google
|
|
522
545
|
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
523
546
|
config_attr :quota_project, nil, ::String, nil
|
524
547
|
config_attr :universe_domain, nil, ::String, nil
|
548
|
+
config_attr :logger, :default, ::Logger, nil, :default
|
525
549
|
|
526
550
|
# @private
|
527
551
|
def initialize parent_config = nil
|
data/lib/google/cloud/recommendation_engine/v1beta1/prediction_api_key_registry/rest/service_stub.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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_prediction_api_key_registration 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:
|
91
|
-
body:
|
92
|
-
params:
|
102
|
+
uri: uri,
|
103
|
+
body: body || "",
|
104
|
+
params: query_string_params,
|
105
|
+
method_name: "create_prediction_api_key_registration",
|
93
106
|
options: options
|
94
107
|
)
|
95
108
|
operation = ::Gapic::Rest::TransportOperation.new response
|
96
109
|
result = ::Google::Cloud::RecommendationEngine::V1beta1::PredictionApiKeyRegistration.decode_json response.body, ignore_unknown_fields: true
|
97
|
-
|
98
|
-
|
99
|
-
|
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:
|
129
|
-
body:
|
130
|
-
params:
|
142
|
+
uri: uri,
|
143
|
+
body: body || "",
|
144
|
+
params: query_string_params,
|
145
|
+
method_name: "list_prediction_api_key_registrations",
|
131
146
|
options: options
|
132
147
|
)
|
133
148
|
operation = ::Gapic::Rest::TransportOperation.new response
|
134
149
|
result = ::Google::Cloud::RecommendationEngine::V1beta1::ListPredictionApiKeyRegistrationsResponse.decode_json response.body, ignore_unknown_fields: true
|
135
|
-
|
136
|
-
|
137
|
-
|
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:
|
167
|
-
body:
|
168
|
-
params:
|
182
|
+
uri: uri,
|
183
|
+
body: body || "",
|
184
|
+
params: query_string_params,
|
185
|
+
method_name: "delete_prediction_api_key_registration",
|
169
186
|
options: options
|
170
187
|
)
|
171
188
|
operation = ::Gapic::Rest::TransportOperation.new response
|
172
189
|
result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
|
173
|
-
|
174
|
-
|
175
|
-
|
190
|
+
catch :response do
|
191
|
+
yield result, operation if block_given?
|
192
|
+
result
|
193
|
+
end
|
176
194
|
end
|
177
195
|
|
178
196
|
##
|
@@ -162,8 +162,28 @@ module Google
|
|
162
162
|
universe_domain: @config.universe_domain,
|
163
163
|
channel_args: @config.channel_args,
|
164
164
|
interceptors: @config.interceptors,
|
165
|
-
channel_pool_config: @config.channel_pool
|
165
|
+
channel_pool_config: @config.channel_pool,
|
166
|
+
logger: @config.logger
|
166
167
|
)
|
168
|
+
|
169
|
+
@prediction_service_stub.stub_logger&.info do |entry|
|
170
|
+
entry.set_system_name
|
171
|
+
entry.set_service
|
172
|
+
entry.message = "Created client for #{entry.service}"
|
173
|
+
entry.set_credentials_fields credentials
|
174
|
+
entry.set "customEndpoint", @config.endpoint if @config.endpoint
|
175
|
+
entry.set "defaultTimeout", @config.timeout if @config.timeout
|
176
|
+
entry.set "quotaProject", @quota_project_id if @quota_project_id
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
##
|
181
|
+
# The logger used for request/response debug logging.
|
182
|
+
#
|
183
|
+
# @return [Logger]
|
184
|
+
#
|
185
|
+
def logger
|
186
|
+
@prediction_service_stub.logger
|
167
187
|
end
|
168
188
|
|
169
189
|
# Service calls
|
@@ -343,7 +363,7 @@ module Google
|
|
343
363
|
@prediction_service_stub.call_rpc :predict, request, options: options do |response, operation|
|
344
364
|
response = ::Gapic::PagedEnumerable.new @prediction_service_stub, :predict, request, response, operation, options
|
345
365
|
yield response, operation if block_given?
|
346
|
-
|
366
|
+
throw :response, response
|
347
367
|
end
|
348
368
|
rescue ::GRPC::BadStatus => e
|
349
369
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -432,6 +452,11 @@ module Google
|
|
432
452
|
# default endpoint URL. The default value of nil uses the environment
|
433
453
|
# universe (usually the default "googleapis.com" universe).
|
434
454
|
# @return [::String,nil]
|
455
|
+
# @!attribute [rw] logger
|
456
|
+
# A custom logger to use for request/response debug logging, or the value
|
457
|
+
# `:default` (the default) to construct a default logger, or `nil` to
|
458
|
+
# explicitly disable logging.
|
459
|
+
# @return [::Logger,:default,nil]
|
435
460
|
#
|
436
461
|
class Configuration
|
437
462
|
extend ::Gapic::Config
|
@@ -456,6 +481,7 @@ module Google
|
|
456
481
|
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
457
482
|
config_attr :quota_project, nil, ::String, nil
|
458
483
|
config_attr :universe_domain, nil, ::String, nil
|
484
|
+
config_attr :logger, :default, ::Logger, nil, :default
|
459
485
|
|
460
486
|
# @private
|
461
487
|
def initialize parent_config = nil
|
@@ -155,8 +155,28 @@ module Google
|
|
155
155
|
endpoint: @config.endpoint,
|
156
156
|
endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
|
157
157
|
universe_domain: @config.universe_domain,
|
158
|
-
credentials: credentials
|
158
|
+
credentials: credentials,
|
159
|
+
logger: @config.logger
|
159
160
|
)
|
161
|
+
|
162
|
+
@prediction_service_stub.logger(stub: true)&.info do |entry|
|
163
|
+
entry.set_system_name
|
164
|
+
entry.set_service
|
165
|
+
entry.message = "Created client for #{entry.service}"
|
166
|
+
entry.set_credentials_fields credentials
|
167
|
+
entry.set "customEndpoint", @config.endpoint if @config.endpoint
|
168
|
+
entry.set "defaultTimeout", @config.timeout if @config.timeout
|
169
|
+
entry.set "quotaProject", @quota_project_id if @quota_project_id
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
##
|
174
|
+
# The logger used for request/response debug logging.
|
175
|
+
#
|
176
|
+
# @return [Logger]
|
177
|
+
#
|
178
|
+
def logger
|
179
|
+
@prediction_service_stub.logger
|
160
180
|
end
|
161
181
|
|
162
182
|
# Service calls
|
@@ -329,7 +349,7 @@ module Google
|
|
329
349
|
@prediction_service_stub.predict request, options do |result, operation|
|
330
350
|
result = ::Gapic::Rest::PagedEnumerable.new @prediction_service_stub, :predict, "metadata", request, result, options
|
331
351
|
yield result, operation if block_given?
|
332
|
-
|
352
|
+
throw :response, result
|
333
353
|
end
|
334
354
|
rescue ::Gapic::Rest::Error => e
|
335
355
|
raise ::Google::Cloud::Error.from_error(e)
|
@@ -409,6 +429,11 @@ module Google
|
|
409
429
|
# default endpoint URL. The default value of nil uses the environment
|
410
430
|
# universe (usually the default "googleapis.com" universe).
|
411
431
|
# @return [::String,nil]
|
432
|
+
# @!attribute [rw] logger
|
433
|
+
# A custom logger to use for request/response debug logging, or the value
|
434
|
+
# `:default` (the default) to construct a default logger, or `nil` to
|
435
|
+
# explicitly disable logging.
|
436
|
+
# @return [::Logger,:default,nil]
|
412
437
|
#
|
413
438
|
class Configuration
|
414
439
|
extend ::Gapic::Config
|
@@ -430,6 +455,7 @@ module Google
|
|
430
455
|
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
431
456
|
config_attr :quota_project, nil, ::String, nil
|
432
457
|
config_attr :universe_domain, nil, ::String, nil
|
458
|
+
config_attr :logger, :default, ::Logger, nil, :default
|
433
459
|
|
434
460
|
# @private
|
435
461
|
def initialize parent_config = nil
|
@@ -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
|
-
|
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
|
-
|
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 predict 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:
|
91
|
-
body:
|
92
|
-
params:
|
102
|
+
uri: uri,
|
103
|
+
body: body || "",
|
104
|
+
params: query_string_params,
|
105
|
+
method_name: "predict",
|
93
106
|
options: options
|
94
107
|
)
|
95
108
|
operation = ::Gapic::Rest::TransportOperation.new response
|
96
109
|
result = ::Google::Cloud::RecommendationEngine::V1beta1::PredictResponse.decode_json response.body, ignore_unknown_fields: true
|
97
|
-
|
98
|
-
|
99
|
-
|
110
|
+
catch :response do
|
111
|
+
yield result, operation if block_given?
|
112
|
+
result
|
113
|
+
end
|
100
114
|
end
|
101
115
|
|
102
116
|
##
|