lib/google/cloud/dialogflow/v2/sessions/client.rb in google-cloud-dialogflow-v2-0.6.4 vs lib/google/cloud/dialogflow/v2/sessions/client.rb in google-cloud-dialogflow-v2-0.7.0

- old
+ new

@@ -25,15 +25,15 @@ module V2 module Sessions ## # Client for the Sessions service. # - # A session represents an interaction with a user. You retrieve user input - # and pass it to the {::Google::Cloud::Dialogflow::V2::Sessions::Client#detect_intent DetectIntent} (or - # {::Google::Cloud::Dialogflow::V2::Sessions::Client#streaming_detect_intent StreamingDetectIntent}) method to determine - # user intent and respond. + # A service used for session interactions. # + # For more information, see the [API interactions + # guide](https://cloud.google.com/dialogflow/docs/api-overview). + # class Client include Paths # @private attr_reader :sessions_stub @@ -61,29 +61,29 @@ @configure ||= begin namespace = ["Google", "Cloud", "Dialogflow", "V2"] parent_config = while namespace.any? parent_name = namespace.join "::" parent_const = const_get parent_name - break parent_const.configure if parent_const&.respond_to? :configure + break parent_const.configure if parent_const.respond_to? :configure namespace.pop end default_config = Client::Configuration.new parent_config default_config.timeout = 60.0 default_config.retry_policy = { initial_delay: 0.1, - max_delay: 60.0, - multiplier: 1.3, - retry_codes: ["UNAVAILABLE"] + max_delay: 60.0, + multiplier: 1.3, + retry_codes: [14] } default_config.rpcs.detect_intent.timeout = 220.0 default_config.rpcs.detect_intent.retry_policy = { initial_delay: 0.1, - max_delay: 60.0, - multiplier: 1.3, - retry_codes: ["UNAVAILABLE"] + max_delay: 60.0, + multiplier: 1.3, + retry_codes: [14] } default_config.rpcs.streaming_detect_intent.timeout = 220.0 default_config @@ -145,11 +145,17 @@ # Yield the configuration if needed yield @config if block_given? # Create credentials credentials = @config.credentials - credentials ||= Credentials.default scope: @config.scope + # Use self-signed JWT if the scope and endpoint are 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 && + !@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 end @quota_project_id = @config.quota_project @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id @@ -169,10 +175,14 @@ # Processes a natural language query and returns structured, actionable data # as a result. This method is not idempotent, because it may cause contexts # and session entity types to be updated, which in turn might affect # results of future queries. # + # Note: Always use agent versions for production traffic. + # See [Versions and + # environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). + # # @overload detect_intent(request, options = nil) # Pass arguments to `detect_intent` via a request object, either of type # {::Google::Cloud::Dialogflow::V2::DetectIntentRequest} or an equivalent Hash. # # @param request [::Google::Cloud::Dialogflow::V2::DetectIntentRequest, ::Hash] @@ -189,15 +199,23 @@ # @param session [::String] # Required. The name of the session this query is sent to. Format: # `projects/<Project ID>/agent/sessions/<Session ID>`, or # `projects/<Project ID>/agent/environments/<Environment ID>/users/<User # ID>/sessions/<Session ID>`. If `Environment ID` is not specified, we assume - # default 'draft' environment. If `User ID` is not specified, we are using - # "-". It's up to the API caller to choose an appropriate `Session ID` and - # `User Id`. They can be a random number or some type of user and session + # default 'draft' environment (`Environment ID` might be referred to as + # environment name at some places). If `User ID` is not specified, we are + # using "-". It's up to the API caller to choose an appropriate `Session ID` + # and `User Id`. They can be a random number or some type of user and session # identifiers (preferably hashed). The length of the `Session ID` and # `User ID` must not exceed 36 characters. + # + # For more information, see the [API interactions + # guide](https://cloud.google.com/dialogflow/docs/api-overview). + # + # Note: Always use agent versions for production traffic. + # See [Versions and + # environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). # @param query_params [::Google::Cloud::Dialogflow::V2::QueryParameters, ::Hash] # The parameters of this query. # @param query_input [::Google::Cloud::Dialogflow::V2::QueryInput, ::Hash] # Required. The input specification. It can be set to: # @@ -271,10 +289,14 @@ ## # Processes a natural language query in audio format in a streaming fashion # and returns structured, actionable data as a result. This method is only # available via the gRPC API (not REST). # + # Note: Always use agent versions for production traffic. + # See [Versions and + # environments](https://cloud.google.com/dialogflow/es/docs/agents-versions). + # # @param request [::Gapic::StreamInput, ::Enumerable<::Google::Cloud::Dialogflow::V2::StreamingDetectIntentRequest, ::Hash>] # An enumerable of {::Google::Cloud::Dialogflow::V2::StreamingDetectIntentRequest} instances. # @param options [::Gapic::CallOptions, ::Hash] # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional. # @@ -405,18 +427,18 @@ class Configuration extend ::Gapic::Config config_attr :endpoint, "dialogflow.googleapis.com", ::String config_attr :credentials, nil do |value| - allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] + allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC allowed.any? { |klass| klass === value } end config_attr :scope, nil, ::String, ::Array, nil config_attr :lib_name, nil, ::String, nil config_attr :lib_version, nil, ::String, nil - config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil) + config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil) config_attr :interceptors, nil, ::Array, nil config_attr :timeout, nil, ::Numeric, nil config_attr :metadata, nil, ::Hash, nil config_attr :retry_policy, nil, ::Hash, ::Proc, nil config_attr :quota_project, nil, ::String, nil @@ -433,11 +455,11 @@ # @return [Rpcs] # def rpcs @rpcs ||= begin parent_rpcs = nil - parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs) + parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) Rpcs.new parent_rpcs end end ## @@ -445,11 +467,11 @@ # # Includes fields providing the configuration for each RPC in this service. # Each configuration object is of type `Gapic::Config::Method` and includes # the following configuration fields: # - # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds + # * `timeout` (*type:* `Numeric`) - The call timeout in seconds # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields # include the following keys: # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. @@ -469,12 +491,12 @@ # attr_reader :streaming_detect_intent # @private def initialize parent_rpcs = nil - detect_intent_config = parent_rpcs&.detect_intent if parent_rpcs&.respond_to? :detect_intent + detect_intent_config = parent_rpcs.detect_intent if parent_rpcs.respond_to? :detect_intent @detect_intent = ::Gapic::Config::Method.new detect_intent_config - streaming_detect_intent_config = parent_rpcs&.streaming_detect_intent if parent_rpcs&.respond_to? :streaming_detect_intent + streaming_detect_intent_config = parent_rpcs.streaming_detect_intent if parent_rpcs.respond_to? :streaming_detect_intent @streaming_detect_intent = ::Gapic::Config::Method.new streaming_detect_intent_config yield self if block_given? end end