// // DO NOT EDIT. // // Generated by the protocol buffer compiler. // Source: google/cloud/language/v1/language_service.proto // // // Copyright 2018, gRPC Authors All rights reserved. // // 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 // // http://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. // import Foundation import GRPC import NIO import NIOHTTP1 import SwiftProtobuf /// Usage: instantiate Google_Cloud_Language_V1_LanguageServiceServiceClient, then call methods of this protocol to make API calls. internal protocol Google_Cloud_Language_V1_LanguageServiceService { func analyzeSentiment(_ request: Google_Cloud_Language_V1_AnalyzeSentimentRequest, callOptions: CallOptions?) -> UnaryCall func analyzeEntities(_ request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest, callOptions: CallOptions?) -> UnaryCall func analyzeEntitySentiment(_ request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, callOptions: CallOptions?) -> UnaryCall func analyzeSyntax(_ request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest, callOptions: CallOptions?) -> UnaryCall func classifyText(_ request: Google_Cloud_Language_V1_ClassifyTextRequest, callOptions: CallOptions?) -> UnaryCall func annotateText(_ request: Google_Cloud_Language_V1_AnnotateTextRequest, callOptions: CallOptions?) -> UnaryCall } internal final class Google_Cloud_Language_V1_LanguageServiceServiceClient: GRPCClient, Google_Cloud_Language_V1_LanguageServiceService { internal let connection: ClientConnection internal var defaultCallOptions: CallOptions /// Creates a client for the google.cloud.language.v1.LanguageService service. /// /// - Parameters: /// - connection: `ClientConnection` to the service host. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. internal init(connection: ClientConnection, defaultCallOptions: CallOptions = CallOptions()) { self.connection = connection self.defaultCallOptions = defaultCallOptions } /// Asynchronous unary call to AnalyzeSentiment. /// /// - Parameters: /// - request: Request to send to AnalyzeSentiment. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. internal func analyzeSentiment(_ request: Google_Cloud_Language_V1_AnalyzeSentimentRequest, callOptions: CallOptions? = nil) -> UnaryCall { return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/AnalyzeSentiment", request: request, callOptions: callOptions ?? self.defaultCallOptions) } /// Asynchronous unary call to AnalyzeEntities. /// /// - Parameters: /// - request: Request to send to AnalyzeEntities. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. internal func analyzeEntities(_ request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest, callOptions: CallOptions? = nil) -> UnaryCall { return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/AnalyzeEntities", request: request, callOptions: callOptions ?? self.defaultCallOptions) } /// Asynchronous unary call to AnalyzeEntitySentiment. /// /// - Parameters: /// - request: Request to send to AnalyzeEntitySentiment. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. internal func analyzeEntitySentiment(_ request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, callOptions: CallOptions? = nil) -> UnaryCall { return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/AnalyzeEntitySentiment", request: request, callOptions: callOptions ?? self.defaultCallOptions) } /// Asynchronous unary call to AnalyzeSyntax. /// /// - Parameters: /// - request: Request to send to AnalyzeSyntax. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. internal func analyzeSyntax(_ request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest, callOptions: CallOptions? = nil) -> UnaryCall { return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/AnalyzeSyntax", request: request, callOptions: callOptions ?? self.defaultCallOptions) } /// Asynchronous unary call to ClassifyText. /// /// - Parameters: /// - request: Request to send to ClassifyText. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. internal func classifyText(_ request: Google_Cloud_Language_V1_ClassifyTextRequest, callOptions: CallOptions? = nil) -> UnaryCall { return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/ClassifyText", request: request, callOptions: callOptions ?? self.defaultCallOptions) } /// Asynchronous unary call to AnnotateText. /// /// - Parameters: /// - request: Request to send to AnnotateText. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. internal func annotateText(_ request: Google_Cloud_Language_V1_AnnotateTextRequest, callOptions: CallOptions? = nil) -> UnaryCall { return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/AnnotateText", request: request, callOptions: callOptions ?? self.defaultCallOptions) } } /// To build a server, implement a class that conforms to this protocol. internal protocol Google_Cloud_Language_V1_LanguageServiceProvider: CallHandlerProvider { func analyzeSentiment(request: Google_Cloud_Language_V1_AnalyzeSentimentRequest, context: StatusOnlyCallContext) -> EventLoopFuture func analyzeEntities(request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest, context: StatusOnlyCallContext) -> EventLoopFuture func analyzeEntitySentiment(request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, context: StatusOnlyCallContext) -> EventLoopFuture func analyzeSyntax(request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest, context: StatusOnlyCallContext) -> EventLoopFuture func classifyText(request: Google_Cloud_Language_V1_ClassifyTextRequest, context: StatusOnlyCallContext) -> EventLoopFuture func annotateText(request: Google_Cloud_Language_V1_AnnotateTextRequest, context: StatusOnlyCallContext) -> EventLoopFuture } extension Google_Cloud_Language_V1_LanguageServiceProvider { internal var serviceName: String { return "google.cloud.language.v1.LanguageService" } /// Determines, calls and returns the appropriate request handler, depending on the request's method. /// Returns nil for methods not handled by this service. internal func handleMethod(_ methodName: String, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? { switch methodName { case "AnalyzeSentiment": return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in return { request in self.analyzeSentiment(request: request, context: context) } } case "AnalyzeEntities": return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in return { request in self.analyzeEntities(request: request, context: context) } } case "AnalyzeEntitySentiment": return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in return { request in self.analyzeEntitySentiment(request: request, context: context) } } case "AnalyzeSyntax": return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in return { request in self.analyzeSyntax(request: request, context: context) } } case "ClassifyText": return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in return { request in self.classifyText(request: request, context: context) } } case "AnnotateText": return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in return { request in self.annotateText(request: request, context: context) } } default: return nil } } }