# 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/language/v1beta2/language_service_pb" module Google module Cloud module Language module V1beta2 module LanguageService module Rest ## # REST service stub for the LanguageService 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 analyze_sentiment REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeSentimentRequest] # 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::Language::V1beta2::AnalyzeSentimentResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse] # A result object deserialized from the server's reply def analyze_sentiment request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_analyze_sentiment_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::Language::V1beta2::AnalyzeSentimentResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the analyze_entities REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeEntitiesRequest] # 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::Language::V1beta2::AnalyzeEntitiesResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse] # A result object deserialized from the server's reply def analyze_entities request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_analyze_entities_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::Language::V1beta2::AnalyzeEntitiesResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the analyze_entity_sentiment REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest] # 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::Language::V1beta2::AnalyzeEntitySentimentResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse] # A result object deserialized from the server's reply def analyze_entity_sentiment request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_analyze_entity_sentiment_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::Language::V1beta2::AnalyzeEntitySentimentResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the analyze_syntax REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest] # 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::Language::V1beta2::AnalyzeSyntaxResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse] # A result object deserialized from the server's reply def analyze_syntax request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_analyze_syntax_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::Language::V1beta2::AnalyzeSyntaxResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the classify_text REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::ClassifyTextRequest] # 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::Language::V1beta2::ClassifyTextResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Language::V1beta2::ClassifyTextResponse] # A result object deserialized from the server's reply def classify_text request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_classify_text_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::Language::V1beta2::ClassifyTextResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the moderate_text REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::ModerateTextRequest] # 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::Language::V1beta2::ModerateTextResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Language::V1beta2::ModerateTextResponse] # A result object deserialized from the server's reply def moderate_text request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_moderate_text_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::Language::V1beta2::ModerateTextResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # Baseline implementation for the annotate_text REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::AnnotateTextRequest] # 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::Language::V1beta2::AnnotateTextResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Language::V1beta2::AnnotateTextResponse] # A result object deserialized from the server's reply def annotate_text request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? verb, uri, query_string_params, body = ServiceStub.transcode_annotate_text_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::Language::V1beta2::AnnotateTextResponse.decode_json response.body, ignore_unknown_fields: true yield result, operation if block_given? result end ## # @private # # GRPC transcoding helper method for the analyze_sentiment REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeSentimentRequest] # 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_sentiment_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v1beta2/documents:analyzeSentiment", body: "*", matches: [] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the analyze_entities REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeEntitiesRequest] # 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_entities_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v1beta2/documents:analyzeEntities", body: "*", matches: [] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the analyze_entity_sentiment REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest] # 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_entity_sentiment_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v1beta2/documents:analyzeEntitySentiment", body: "*", matches: [] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the analyze_syntax REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest] # 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_syntax_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v1beta2/documents:analyzeSyntax", body: "*", matches: [] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the classify_text REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::ClassifyTextRequest] # A request object representing the call parameters. Required. # @return [Array(String, [String, nil], Hash{String => String})] # Uri, Body, Query string parameters def self.transcode_classify_text_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v1beta2/documents:classifyText", body: "*", matches: [] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the moderate_text REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::ModerateTextRequest] # A request object representing the call parameters. Required. # @return [Array(String, [String, nil], Hash{String => String})] # Uri, Body, Query string parameters def self.transcode_moderate_text_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v1beta2/documents:moderateText", body: "*", matches: [] ) transcoder.transcode request_pb end ## # @private # # GRPC transcoding helper method for the annotate_text REST call # # @param request_pb [::Google::Cloud::Language::V1beta2::AnnotateTextRequest] # A request object representing the call parameters. Required. # @return [Array(String, [String, nil], Hash{String => String})] # Uri, Body, Query string parameters def self.transcode_annotate_text_request request_pb transcoder = Gapic::Rest::GrpcTranscoder.new .with_bindings( uri_method: :post, uri_template: "/v1beta2/documents:annotateText", body: "*", matches: [] ) transcoder.transcode request_pb end end end end end end end end