Class: Google::Cloud::AIPlatform::V1::PredictionService::Rest::ServiceStub

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb

Overview

REST service stub for the PredictionService service. Service stub contains baseline method implementations including transcoding, making the REST call, and deserialing the response.

Instance Method Summary collapse

Instance Method Details

#direct_predict(request_pb, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::AIPlatform::V1::DirectPredictResponse

Baseline implementation for the direct_predict REST call

Parameters:

  • request_pb (::Google::Cloud::AIPlatform::V1::DirectPredictRequest)

    A request object representing the call parameters. Required.

  • options (::Gapic::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::ArgumentError)


204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 204

def direct_predict request_pb, options = nil
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  verb, uri, query_string_params, body = ServiceStub.transcode_direct_predict_request request_pb
  query_string_params = if query_string_params.any?
                          query_string_params.to_h { |p| p.split "=", 2 }
                        else
                          {}
                        end

  response = @client_stub.make_http_request(
    verb,
    uri: uri,
    body: body || "",
    params: query_string_params,
    method_name: "direct_predict",
    options: options
  )
  operation = ::Gapic::Rest::TransportOperation.new response
  result = ::Google::Cloud::AIPlatform::V1::DirectPredictResponse.decode_json response.body, ignore_unknown_fields: true
  catch :response do
    yield result, operation if block_given?
    result
  end
end

#direct_raw_predict(request_pb, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::AIPlatform::V1::DirectRawPredictResponse

Baseline implementation for the direct_raw_predict REST call

Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::ArgumentError)


244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 244

def direct_raw_predict request_pb, options = nil
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  verb, uri, query_string_params, body = ServiceStub.transcode_direct_raw_predict_request request_pb
  query_string_params = if query_string_params.any?
                          query_string_params.to_h { |p| p.split "=", 2 }
                        else
                          {}
                        end

  response = @client_stub.make_http_request(
    verb,
    uri: uri,
    body: body || "",
    params: query_string_params,
    method_name: "direct_raw_predict",
    options: options
  )
  operation = ::Gapic::Rest::TransportOperation.new response
  result = ::Google::Cloud::AIPlatform::V1::DirectRawPredictResponse.decode_json response.body, ignore_unknown_fields: true
  catch :response do
    yield result, operation if block_given?
    result
  end
end

#embed_content(request_pb, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::AIPlatform::V1::EmbedContentResponse

Baseline implementation for the embed_content REST call

Parameters:

  • request_pb (::Google::Cloud::AIPlatform::V1::EmbedContentRequest)

    A request object representing the call parameters. Required.

  • options (::Gapic::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::ArgumentError)


432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 432

def embed_content request_pb, options = nil
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  verb, uri, query_string_params, body = ServiceStub.transcode_embed_content_request request_pb
  query_string_params = if query_string_params.any?
                          query_string_params.to_h { |p| p.split "=", 2 }
                        else
                          {}
                        end

  response = @client_stub.make_http_request(
    verb,
    uri: uri,
    body: body || "",
    params: query_string_params,
    method_name: "embed_content",
    options: options
  )
  operation = ::Gapic::Rest::TransportOperation.new response
  result = ::Google::Cloud::AIPlatform::V1::EmbedContentResponse.decode_json response.body, ignore_unknown_fields: true
  catch :response do
    yield result, operation if block_given?
    result
  end
end

#endpointString

The effective endpoint

Returns:

  • (String)


63
64
65
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 63

def endpoint
  @client_stub.endpoint
end

#explain(request_pb, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::AIPlatform::V1::ExplainResponse

Baseline implementation for the explain REST call

Parameters:

  • request_pb (::Google::Cloud::AIPlatform::V1::ExplainRequest)

    A request object representing the call parameters. Required.

  • options (::Gapic::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::ArgumentError)


318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 318

def explain request_pb, options = nil
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  verb, uri, query_string_params, body = ServiceStub.transcode_explain_request request_pb
  query_string_params = if query_string_params.any?
                          query_string_params.to_h { |p| p.split "=", 2 }
                        else
                          {}
                        end

  response = @client_stub.make_http_request(
    verb,
    uri: uri,
    body: body || "",
    params: query_string_params,
    method_name: "explain",
    options: options
  )
  operation = ::Gapic::Rest::TransportOperation.new response
  result = ::Google::Cloud::AIPlatform::V1::ExplainResponse.decode_json response.body, ignore_unknown_fields: true
  catch :response do
    yield result, operation if block_given?
    result
  end
end

#generate_content(request_pb, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::AIPlatform::V1::GenerateContentResponse

Baseline implementation for the generate_content REST call

Parameters:

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::ArgumentError)


358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 358

def generate_content request_pb, options = nil
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  verb, uri, query_string_params, body = ServiceStub.transcode_generate_content_request request_pb
  query_string_params = if query_string_params.any?
                          query_string_params.to_h { |p| p.split "=", 2 }
                        else
                          {}
                        end

  response = @client_stub.make_http_request(
    verb,
    uri: uri,
    body: body || "",
    params: query_string_params,
    method_name: "generate_content",
    options: options
  )
  operation = ::Gapic::Rest::TransportOperation.new response
  result = ::Google::Cloud::AIPlatform::V1::GenerateContentResponse.decode_json response.body, ignore_unknown_fields: true
  catch :response do
    yield result, operation if block_given?
    result
  end
end

#logger(stub: false) ⇒ Logger

The logger used for request/response debug logging.

Returns:

  • (Logger)


72
73
74
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 72

def logger stub: false
  stub ? @client_stub.stub_logger : @client_stub.logger
end

#predict(request_pb, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::AIPlatform::V1::PredictResponse

Baseline implementation for the predict REST call

Parameters:

  • request_pb (::Google::Cloud::AIPlatform::V1::PredictRequest)

    A request object representing the call parameters. Required.

  • options (::Gapic::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::ArgumentError)


90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 90

def predict request_pb, options = nil
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  verb, uri, query_string_params, body = ServiceStub.transcode_predict_request request_pb
  query_string_params = if query_string_params.any?
                          query_string_params.to_h { |p| p.split "=", 2 }
                        else
                          {}
                        end

  response = @client_stub.make_http_request(
    verb,
    uri: uri,
    body: body || "",
    params: query_string_params,
    method_name: "predict",
    options: options
  )
  operation = ::Gapic::Rest::TransportOperation.new response
  result = ::Google::Cloud::AIPlatform::V1::PredictResponse.decode_json response.body, ignore_unknown_fields: true
  catch :response do
    yield result, operation if block_given?
    result
  end
end

#raw_predict(request_pb, options = nil) {|result, operation| ... } ⇒ ::Google::Api::HttpBody

Baseline implementation for the raw_predict REST call

Parameters:

  • request_pb (::Google::Cloud::AIPlatform::V1::RawPredictRequest)

    A request object representing the call parameters. Required.

  • options (::Gapic::CallOptions) (defaults to: nil)

    Overrides the default settings for this call, e.g, timeout, retries etc. Optional.

Yields:

  • (result, operation)

    Access the result along with the TransportOperation object

Yield Parameters:

Returns:

Raises:

  • (::ArgumentError)


130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 130

def raw_predict request_pb, options = nil
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  verb, uri, query_string_params, body = ServiceStub.transcode_raw_predict_request request_pb
  query_string_params = if query_string_params.any?
                          query_string_params.to_h { |p| p.split "=", 2 }
                        else
                          {}
                        end

  response = @client_stub.make_http_request(
    verb,
    uri: uri,
    body: body || "",
    params: query_string_params,
    method_name: "raw_predict",
    options: options
  )
  operation = ::Gapic::Rest::TransportOperation.new response
  result = ::Google::Api::HttpBody.decode_json response.body, ignore_unknown_fields: true
  catch :response do
    yield result, operation if block_given?
    result
  end
end

#server_streaming_predict(request_pb, options = nil) {|chunk| ... } ⇒ ::Gapic::Rest::TransportOperation

Baseline implementation for the server_streaming_predict REST call

Parameters:

Yield Parameters:

  • chunk (::String)

    The chunk of data received during server streaming.

Returns:

  • (::Gapic::Rest::TransportOperation)

Raises:

  • (::ArgumentError)


281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 281

def server_streaming_predict(request_pb, options = nil, &)
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  verb, uri, query_string_params, body = ServiceStub.transcode_server_streaming_predict_request request_pb
  query_string_params = if query_string_params.any?
                          query_string_params.to_h { |p| p.split "=", 2 }
                        else
                          {}
                        end

  response = @client_stub.make_http_request(
    verb,
    uri: uri,
    body: body || "",
    params: query_string_params,
    method_name: "server_streaming_predict",
    options: options,
    is_server_streaming: true,
    &
  )
  ::Gapic::Rest::TransportOperation.new response
end

#stream_generate_content(request_pb, options = nil) {|chunk| ... } ⇒ ::Gapic::Rest::TransportOperation

Baseline implementation for the stream_generate_content REST call

Parameters:

Yield Parameters:

  • chunk (::String)

    The chunk of data received during server streaming.

Returns:

  • (::Gapic::Rest::TransportOperation)

Raises:

  • (::ArgumentError)


395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 395

def stream_generate_content(request_pb, options = nil, &)
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  verb, uri, query_string_params, body = ServiceStub.transcode_stream_generate_content_request request_pb
  query_string_params = if query_string_params.any?
                          query_string_params.to_h { |p| p.split "=", 2 }
                        else
                          {}
                        end

  response = @client_stub.make_http_request(
    verb,
    uri: uri,
    body: body || "",
    params: query_string_params,
    method_name: "stream_generate_content",
    options: options,
    is_server_streaming: true,
    &
  )
  ::Gapic::Rest::TransportOperation.new response
end

#stream_raw_predict(request_pb, options = nil) {|chunk| ... } ⇒ ::Gapic::Rest::TransportOperation

Baseline implementation for the stream_raw_predict REST call

Parameters:

Yield Parameters:

  • chunk (::String)

    The chunk of data received during server streaming.

Returns:

  • (::Gapic::Rest::TransportOperation)

Raises:

  • (::ArgumentError)


167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 167

def stream_raw_predict(request_pb, options = nil, &)
  raise ::ArgumentError, "request must be provided" if request_pb.nil?

  verb, uri, query_string_params, body = ServiceStub.transcode_stream_raw_predict_request request_pb
  query_string_params = if query_string_params.any?
                          query_string_params.to_h { |p| p.split "=", 2 }
                        else
                          {}
                        end

  response = @client_stub.make_http_request(
    verb,
    uri: uri,
    body: body || "",
    params: query_string_params,
    method_name: "stream_raw_predict",
    options: options,
    is_server_streaming: true,
    &
  )
  ::Gapic::Rest::TransportOperation.new response
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


54
55
56
# File 'lib/google/cloud/ai_platform/v1/prediction_service/rest/service_stub.rb', line 54

def universe_domain
  @client_stub.universe_domain
end