lib/google/cloud/dialogflow/v2/participants/rest/client.rb in google-cloud-dialogflow-v2-1.0.0 vs lib/google/cloud/dialogflow/v2/participants/rest/client.rb in google-cloud-dialogflow-v2-1.1.0

- old
+ new

@@ -915,10 +915,106 @@ rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end ## + # Gets knowledge assist suggestions based on historical messages. + # + # @overload suggest_knowledge_assist(request, options = nil) + # Pass arguments to `suggest_knowledge_assist` via a request object, either of type + # {::Google::Cloud::Dialogflow::V2::SuggestKnowledgeAssistRequest} or an equivalent Hash. + # + # @param request [::Google::Cloud::Dialogflow::V2::SuggestKnowledgeAssistRequest, ::Hash] + # A request object representing the call parameters. Required. To specify no + # parameters, or to keep all the default parameter values, pass an empty Hash. + # @param options [::Gapic::CallOptions, ::Hash] + # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. + # + # @overload suggest_knowledge_assist(parent: nil, latest_message: nil, context_size: nil, previous_suggested_query: nil) + # Pass arguments to `suggest_knowledge_assist` via keyword arguments. Note that at + # least one keyword argument is required. To specify no parameters, or to keep all + # the default parameter values, pass an empty Hash as a request object (see above). + # + # @param parent [::String] + # Required. The name of the participant to fetch suggestions for. + # Format: `projects/<Project ID>/locations/<Location + # ID>/conversations/<Conversation ID>/participants/<Participant ID>`. + # @param latest_message [::String] + # Optional. The name of the latest conversation message to compile + # suggestions for. If empty, it will be the latest message of the + # conversation. Format: `projects/<Project ID>/locations/<Location + # ID>/conversations/<Conversation ID>/messages/<Message ID>`. + # @param context_size [::Integer] + # Optional. Max number of messages prior to and including + # {::Google::Cloud::Dialogflow::V2::SuggestKnowledgeAssistRequest#latest_message latest_message} + # to use as context when compiling the suggestion. The context size is by + # default 100 and at most 100. + # @param previous_suggested_query [::String] + # Optional. The previously suggested query for the given conversation. This + # helps identify whether the next suggestion we generate is resonably + # different from the previous one. This is useful to avoid similar + # suggestions within the conversation. + # @yield [result, operation] Access the result along with the TransportOperation object + # @yieldparam result [::Google::Cloud::Dialogflow::V2::SuggestKnowledgeAssistResponse] + # @yieldparam operation [::Gapic::Rest::TransportOperation] + # + # @return [::Google::Cloud::Dialogflow::V2::SuggestKnowledgeAssistResponse] + # + # @raise [::Google::Cloud::Error] if the REST call is aborted. + # + # @example Basic example + # require "google/cloud/dialogflow/v2" + # + # # Create a client object. The client can be reused for multiple calls. + # client = Google::Cloud::Dialogflow::V2::Participants::Rest::Client.new + # + # # Create a request. To set request fields, pass in keyword arguments. + # request = Google::Cloud::Dialogflow::V2::SuggestKnowledgeAssistRequest.new + # + # # Call the suggest_knowledge_assist method. + # result = client.suggest_knowledge_assist request + # + # # The returned object is of type Google::Cloud::Dialogflow::V2::SuggestKnowledgeAssistResponse. + # p result + # + def suggest_knowledge_assist request, options = nil + raise ::ArgumentError, "request must be provided" if request.nil? + + request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Dialogflow::V2::SuggestKnowledgeAssistRequest + + # Converts hash and nil to an options object + options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h + + # Customize the options with defaults + call_metadata = @config.rpcs.suggest_knowledge_assist.metadata.to_h + + # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers + call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \ + lib_name: @config.lib_name, lib_version: @config.lib_version, + gapic_version: ::Google::Cloud::Dialogflow::V2::VERSION, + transports_version_send: [:rest] + + call_metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? + call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id + + options.apply_defaults timeout: @config.rpcs.suggest_knowledge_assist.timeout, + metadata: call_metadata, + retry_policy: @config.rpcs.suggest_knowledge_assist.retry_policy + + options.apply_defaults timeout: @config.timeout, + metadata: @config.metadata, + retry_policy: @config.retry_policy + + @participants_stub.suggest_knowledge_assist request, options do |result, operation| + yield result, operation if block_given? + return result + end + rescue ::Gapic::Rest::Error => e + raise ::Google::Cloud::Error.from_error(e) + end + + ## # Configuration class for the Participants REST API. # # This class represents the configuration for Participants REST, # providing control over timeouts, retry behavior, logging, transport # parameters, and other low-level controls. Certain parameters can also be @@ -1094,10 +1190,15 @@ ## # RPC-specific configuration for `suggest_smart_replies` # @return [::Gapic::Config::Method] # attr_reader :suggest_smart_replies + ## + # RPC-specific configuration for `suggest_knowledge_assist` + # @return [::Gapic::Config::Method] + # + attr_reader :suggest_knowledge_assist # @private def initialize parent_rpcs = nil create_participant_config = parent_rpcs.create_participant if parent_rpcs.respond_to? :create_participant @create_participant = ::Gapic::Config::Method.new create_participant_config @@ -1113,9 +1214,11 @@ @suggest_articles = ::Gapic::Config::Method.new suggest_articles_config suggest_faq_answers_config = parent_rpcs.suggest_faq_answers if parent_rpcs.respond_to? :suggest_faq_answers @suggest_faq_answers = ::Gapic::Config::Method.new suggest_faq_answers_config suggest_smart_replies_config = parent_rpcs.suggest_smart_replies if parent_rpcs.respond_to? :suggest_smart_replies @suggest_smart_replies = ::Gapic::Config::Method.new suggest_smart_replies_config + suggest_knowledge_assist_config = parent_rpcs.suggest_knowledge_assist if parent_rpcs.respond_to? :suggest_knowledge_assist + @suggest_knowledge_assist = ::Gapic::Config::Method.new suggest_knowledge_assist_config yield self if block_given? end end end