# frozen_string_literal: true # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Auto-generated by gapic-generator-ruby. DO NOT EDIT! require "google/cloud/dialogflow/v2/participant_pb" module Google module Cloud module Dialogflow module V2 module Participants module Rest ## # REST service stub for the Participants service. # Service stub contains baseline method implementations # including transcoding, making the REST call, and deserialing the response. # class ServiceStub def initialize endpoint:, credentials: # These require statements are intentionally placed here to initialize # the REST modules only when it's required. require "gapic/rest" @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials, numeric_enums: true, raise_faraday_errors: false end ## # Baseline implementation for the create_participant REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::CreateParticipantRequest] # A request object representing the call parameters. Required. # @param options [::Gapic::CallOptions] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. # # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Dialogflow::V2::Participant] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Dialogflow::V2::Participant] # A result object deserialized from the server's reply def create_participant request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_create_participant_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, options: options ) operation = ::Gapic::Rest::TransportOperation.new response result = ::Google::Cloud::Dialogflow::V2::Participant.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the get_participant REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::GetParticipantRequest] # A request object representing the call parameters. Required. # @param options [::Gapic::CallOptions] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. # # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Dialogflow::V2::Participant] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Dialogflow::V2::Participant] # A result object deserialized from the server's reply def get_participant request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_get_participant_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, options: options ) operation = ::Gapic::Rest::TransportOperation.new response result = ::Google::Cloud::Dialogflow::V2::Participant.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the list_participants REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::ListParticipantsRequest] # A request object representing the call parameters. Required. # @param options [::Gapic::CallOptions] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. # # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Dialogflow::V2::ListParticipantsResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Dialogflow::V2::ListParticipantsResponse] # A result object deserialized from the server's reply def list_participants request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_list_participants_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, options: options ) operation = ::Gapic::Rest::TransportOperation.new response result = ::Google::Cloud::Dialogflow::V2::ListParticipantsResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the update_participant REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::UpdateParticipantRequest] # A request object representing the call parameters. Required. # @param options [::Gapic::CallOptions] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. # # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Dialogflow::V2::Participant] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Dialogflow::V2::Participant] # A result object deserialized from the server's reply def update_participant request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_update_participant_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, options: options ) operation = ::Gapic::Rest::TransportOperation.new response result = ::Google::Cloud::Dialogflow::V2::Participant.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the analyze_content REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::AnalyzeContentRequest] # A request object representing the call parameters. Required. # @param options [::Gapic::CallOptions] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. # # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Dialogflow::V2::AnalyzeContentResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Dialogflow::V2::AnalyzeContentResponse] # A result object deserialized from the server's reply def analyze_content request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_analyze_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, options: options ) operation = ::Gapic::Rest::TransportOperation.new response result = ::Google::Cloud::Dialogflow::V2::AnalyzeContentResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the suggest_articles REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::SuggestArticlesRequest] # A request object representing the call parameters. Required. # @param options [::Gapic::CallOptions] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. # # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Dialogflow::V2::SuggestArticlesResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Dialogflow::V2::SuggestArticlesResponse] # A result object deserialized from the server's reply def suggest_articles request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_suggest_articles_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, options: options ) operation = ::Gapic::Rest::TransportOperation.new response result = ::Google::Cloud::Dialogflow::V2::SuggestArticlesResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the suggest_faq_answers REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::SuggestFaqAnswersRequest] # A request object representing the call parameters. Required. # @param options [::Gapic::CallOptions] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. # # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Dialogflow::V2::SuggestFaqAnswersResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Dialogflow::V2::SuggestFaqAnswersResponse] # A result object deserialized from the server's reply def suggest_faq_answers request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_suggest_faq_answers_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, options: options ) operation = ::Gapic::Rest::TransportOperation.new response result = ::Google::Cloud::Dialogflow::V2::SuggestFaqAnswersResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the suggest_smart_replies REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::SuggestSmartRepliesRequest] # A request object representing the call parameters. Required. # @param options [::Gapic::CallOptions] # Overrides the default settings for this call, e.g, timeout, retries etc. Optional. # # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Dialogflow::V2::SuggestSmartRepliesResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Dialogflow::V2::SuggestSmartRepliesResponse] # A result object deserialized from the server's reply def suggest_smart_replies request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_suggest_smart_replies_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, options: options ) operation = ::Gapic::Rest::TransportOperation.new response result = ::Google::Cloud::Dialogflow::V2::SuggestSmartRepliesResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # @private # # GRPC transcoding helper method for the create_participant REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::CreateParticipantRequest] # A request object representing the call parameters. Required. # @return [Array(String, [String, nil], Hash{String => String})] # Uri, Body, Query string parameters def self.transcode_create_participant_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v2/{parent}/participants", body: "participant", matches: [ ["parent", %r{^projects/[^/]+/conversations/[^/]+/?$}, false] ] ) .with_bindings( uri_method: :post, uri_template: "/v2/{parent}/participants", body: "participant", matches: [ ["parent", %r{^projects/[^/]+/locations/[^/]+/conversations/[^/]+/?$}, false] ] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the get_participant REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::GetParticipantRequest] # A request object representing the call parameters. Required. # @return [Array(String, [String, nil], Hash{String => String})] # Uri, Body, Query string parameters def self.transcode_get_participant_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :get, uri_template: "/v2/{name}", matches: [ ["name", %r{^projects/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) .with_bindings( uri_method: :get, uri_template: "/v2/{name}", matches: [ ["name", %r{^projects/[^/]+/locations/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the list_participants REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::ListParticipantsRequest] # A request object representing the call parameters. Required. # @return [Array(String, [String, nil], Hash{String => String})] # Uri, Body, Query string parameters def self.transcode_list_participants_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :get, uri_template: "/v2/{parent}/participants", matches: [ ["parent", %r{^projects/[^/]+/conversations/[^/]+/?$}, false] ] ) .with_bindings( uri_method: :get, uri_template: "/v2/{parent}/participants", matches: [ ["parent", %r{^projects/[^/]+/locations/[^/]+/conversations/[^/]+/?$}, false] ] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the update_participant REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::UpdateParticipantRequest] # A request object representing the call parameters. Required. # @return [Array(String, [String, nil], Hash{String => String})] # Uri, Body, Query string parameters def self.transcode_update_participant_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :patch, uri_template: "/v2/{participant.name}", body: "participant", matches: [ ["participant.name", %r{^projects/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) .with_bindings( uri_method: :patch, uri_template: "/v2/{participant.name}", body: "participant", matches: [ ["participant.name", %r{^projects/[^/]+/locations/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the analyze_content REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::AnalyzeContentRequest] # A request object representing the call parameters. Required. # @return [Array(String, [String, nil], Hash{String => String})] # Uri, Body, Query string parameters def self.transcode_analyze_content_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v2/{participant}:analyzeContent", body: "*", matches: [ ["participant", %r{^projects/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) .with_bindings( uri_method: :post, uri_template: "/v2/{participant}:analyzeContent", body: "*", matches: [ ["participant", %r{^projects/[^/]+/locations/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the suggest_articles REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::SuggestArticlesRequest] # A request object representing the call parameters. Required. # @return [Array(String, [String, nil], Hash{String => String})] # Uri, Body, Query string parameters def self.transcode_suggest_articles_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v2/{parent}/suggestions:suggestArticles", body: "*", matches: [ ["parent", %r{^projects/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) .with_bindings( uri_method: :post, uri_template: "/v2/{parent}/suggestions:suggestArticles", body: "*", matches: [ ["parent", %r{^projects/[^/]+/locations/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the suggest_faq_answers REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::SuggestFaqAnswersRequest] # A request object representing the call parameters. Required. # @return [Array(String, [String, nil], Hash{String => String})] # Uri, Body, Query string parameters def self.transcode_suggest_faq_answers_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v2/{parent}/suggestions:suggestFaqAnswers", body: "*", matches: [ ["parent", %r{^projects/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) .with_bindings( uri_method: :post, uri_template: "/v2/{parent}/suggestions:suggestFaqAnswers", body: "*", matches: [ ["parent", %r{^projects/[^/]+/locations/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the suggest_smart_replies REST call # # @param request_pb [::Google::Cloud::Dialogflow::V2::SuggestSmartRepliesRequest] # A request object representing the call parameters. Required. # @return [Array(String, [String, nil], Hash{String => String})] # Uri, Body, Query string parameters def self.transcode_suggest_smart_replies_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v2/{parent}/suggestions:suggestSmartReplies", body: "*", matches: [ ["parent", %r{^projects/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) .with_bindings( uri_method: :post, uri_template: "/v2/{parent}/suggestions:suggestSmartReplies", body: "*", matches: [ ["parent", %r{^projects/[^/]+/locations/[^/]+/conversations/[^/]+/participants/[^/]+/?$}, false] ] ) transcoder.transcode request_pb end end end end end end end end