lib/google/cloud/automl/v1beta1/prediction_service/client.rb in google-cloud-automl-v1beta1-0.5.2 vs lib/google/cloud/automl/v1beta1/prediction_service/client.rb in google-cloud-automl-v1beta1-0.5.3
- old
+ new
@@ -42,18 +42,17 @@
# Configure the PredictionService Client class.
#
# See {::Google::Cloud::AutoML::V1beta1::PredictionService::Client::Configuration}
# for a description of the configuration fields.
#
- # ## Example
+ # @example
#
- # To modify the configuration for all PredictionService clients:
+ # # Modify the configuration for all PredictionService clients
+ # ::Google::Cloud::AutoML::V1beta1::PredictionService::Client.configure do |config|
+ # config.timeout = 10.0
+ # end
#
- # ::Google::Cloud::AutoML::V1beta1::PredictionService::Client.configure do |config|
- # config.timeout = 10.0
- # end
- #
# @yield [config] Configure the Client client.
# @yieldparam config [Client::Configuration]
#
# @return [Client::Configuration]
#
@@ -99,24 +98,20 @@
end
##
# Create a new PredictionService client object.
#
- # ## Examples
+ # @example
#
- # To create a new PredictionService client with the default
- # configuration:
+ # # Create a client using the default configuration
+ # client = ::Google::Cloud::AutoML::V1beta1::PredictionService::Client.new
#
- # client = ::Google::Cloud::AutoML::V1beta1::PredictionService::Client.new
+ # # Create a client using a custom configuration
+ # client = ::Google::Cloud::AutoML::V1beta1::PredictionService::Client.new do |config|
+ # config.timeout = 10.0
+ # end
#
- # To create a new PredictionService client with a custom
- # configuration:
- #
- # client = ::Google::Cloud::AutoML::V1beta1::PredictionService::Client.new do |config|
- # config.timeout = 10.0
- # end
- #
# @yield [config] Configure the PredictionService client.
# @yieldparam config [Client::Configuration]
#
def initialize
# These require statements are intentionally placed here to initialize
@@ -131,14 +126,13 @@
# Yield the configuration if needed
yield @config if block_given?
# Create credentials
credentials = @config.credentials
- # Use self-signed JWT if the scope and endpoint are unchanged from default,
+ # Use self-signed JWT if the endpoint is unchanged from default,
# but only if the default endpoint does not have a region prefix.
- enable_self_signed_jwt = @config.scope == Client.configure.scope &&
- @config.endpoint == Client.configure.endpoint &&
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
!@config.endpoint.split(".").first.include?("-")
credentials ||= Credentials.default scope: @config.scope,
enable_self_signed_jwt: enable_self_signed_jwt
if credentials.is_a?(::String) || credentials.is_a?(::Hash)
credentials = Credentials.new credentials, scope: @config.scope
@@ -264,11 +258,13 @@
metadata[:"x-goog-request-params"] ||= request_params_header
options.apply_defaults timeout: @config.rpcs.predict.timeout,
metadata: metadata,
retry_policy: @config.rpcs.predict.retry_policy
- options.apply_defaults metadata: @config.metadata,
+
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata,
retry_policy: @config.retry_policy
@prediction_service_stub.call_rpc :predict, request, options: options do |response, operation|
yield response, operation if block_given?
return response
@@ -417,11 +413,13 @@
metadata[:"x-goog-request-params"] ||= request_params_header
options.apply_defaults timeout: @config.rpcs.batch_predict.timeout,
metadata: metadata,
retry_policy: @config.rpcs.batch_predict.retry_policy
- options.apply_defaults metadata: @config.metadata,
+
+ options.apply_defaults timeout: @config.timeout,
+ metadata: @config.metadata,
retry_policy: @config.retry_policy
@prediction_service_stub.call_rpc :batch_predict, request, options: options do |response, operation|
response = ::Gapic::Operation.new response, @operations_client, options: options
yield response, operation if block_given?
@@ -442,25 +440,24 @@
# for a list of RPCs that can be configured independently.
#
# Configuration can be applied globally to all clients, or to a single client
# on construction.
#
- # # Examples
+ # @example
#
- # To modify the global config, setting the timeout for predict
- # to 20 seconds, and all remaining timeouts to 10 seconds:
+ # # Modify the global config, setting the timeout for
+ # # predict to 20 seconds,
+ # # and all remaining timeouts to 10 seconds.
+ # ::Google::Cloud::AutoML::V1beta1::PredictionService::Client.configure do |config|
+ # config.timeout = 10.0
+ # config.rpcs.predict.timeout = 20.0
+ # end
#
- # ::Google::Cloud::AutoML::V1beta1::PredictionService::Client.configure do |config|
- # config.timeout = 10.0
- # config.rpcs.predict.timeout = 20.0
- # end
- #
- # To apply the above configuration only to a new client:
- #
- # client = ::Google::Cloud::AutoML::V1beta1::PredictionService::Client.new do |config|
- # config.timeout = 10.0
- # config.rpcs.predict.timeout = 20.0
- # end
+ # # Apply the above configuration only to a new client.
+ # client = ::Google::Cloud::AutoML::V1beta1::PredictionService::Client.new do |config|
+ # config.timeout = 10.0
+ # config.rpcs.predict.timeout = 20.0
+ # end
#
# @!attribute [rw] endpoint
# The hostname or hostname:port of the service endpoint.
# Defaults to `"automl.googleapis.com"`.
# @return [::String]