language_service.grpc.swift 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. //
  2. // DO NOT EDIT.
  3. //
  4. // Generated by the protocol buffer compiler.
  5. // Source: google/cloud/language/v1/language_service.proto
  6. //
  7. //
  8. // Copyright 2018, gRPC Authors All rights reserved.
  9. //
  10. // Licensed under the Apache License, Version 2.0 (the "License");
  11. // you may not use this file except in compliance with the License.
  12. // You may obtain a copy of the License at
  13. //
  14. // http://www.apache.org/licenses/LICENSE-2.0
  15. //
  16. // Unless required by applicable law or agreed to in writing, software
  17. // distributed under the License is distributed on an "AS IS" BASIS,
  18. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. // See the License for the specific language governing permissions and
  20. // limitations under the License.
  21. //
  22. import Foundation
  23. import GRPC
  24. import NIO
  25. import NIOHTTP1
  26. import SwiftProtobuf
  27. /// Usage: instantiate Google_Cloud_Language_V1_LanguageServiceServiceClient, then call methods of this protocol to make API calls.
  28. internal protocol Google_Cloud_Language_V1_LanguageServiceService {
  29. func analyzeSentiment(_ request: Google_Cloud_Language_V1_AnalyzeSentimentRequest, callOptions: CallOptions?) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeSentimentRequest, Google_Cloud_Language_V1_AnalyzeSentimentResponse>
  30. func analyzeEntities(_ request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest, callOptions: CallOptions?) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeEntitiesRequest, Google_Cloud_Language_V1_AnalyzeEntitiesResponse>
  31. func analyzeEntitySentiment(_ request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, callOptions: CallOptions?) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse>
  32. func analyzeSyntax(_ request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest, callOptions: CallOptions?) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeSyntaxRequest, Google_Cloud_Language_V1_AnalyzeSyntaxResponse>
  33. func classifyText(_ request: Google_Cloud_Language_V1_ClassifyTextRequest, callOptions: CallOptions?) -> UnaryCall<Google_Cloud_Language_V1_ClassifyTextRequest, Google_Cloud_Language_V1_ClassifyTextResponse>
  34. func annotateText(_ request: Google_Cloud_Language_V1_AnnotateTextRequest, callOptions: CallOptions?) -> UnaryCall<Google_Cloud_Language_V1_AnnotateTextRequest, Google_Cloud_Language_V1_AnnotateTextResponse>
  35. }
  36. internal final class Google_Cloud_Language_V1_LanguageServiceServiceClient: GRPCClient, Google_Cloud_Language_V1_LanguageServiceService {
  37. internal let connection: ClientConnection
  38. internal var defaultCallOptions: CallOptions
  39. /// Creates a client for the google.cloud.language.v1.LanguageService service.
  40. ///
  41. /// - Parameters:
  42. /// - connection: `ClientConnection` to the service host.
  43. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  44. internal init(connection: ClientConnection, defaultCallOptions: CallOptions = CallOptions()) {
  45. self.connection = connection
  46. self.defaultCallOptions = defaultCallOptions
  47. }
  48. /// Asynchronous unary call to AnalyzeSentiment.
  49. ///
  50. /// - Parameters:
  51. /// - request: Request to send to AnalyzeSentiment.
  52. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  53. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  54. internal func analyzeSentiment(_ request: Google_Cloud_Language_V1_AnalyzeSentimentRequest, callOptions: CallOptions? = nil) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeSentimentRequest, Google_Cloud_Language_V1_AnalyzeSentimentResponse> {
  55. return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/AnalyzeSentiment",
  56. request: request,
  57. callOptions: callOptions ?? self.defaultCallOptions)
  58. }
  59. /// Asynchronous unary call to AnalyzeEntities.
  60. ///
  61. /// - Parameters:
  62. /// - request: Request to send to AnalyzeEntities.
  63. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  64. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  65. internal func analyzeEntities(_ request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest, callOptions: CallOptions? = nil) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeEntitiesRequest, Google_Cloud_Language_V1_AnalyzeEntitiesResponse> {
  66. return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/AnalyzeEntities",
  67. request: request,
  68. callOptions: callOptions ?? self.defaultCallOptions)
  69. }
  70. /// Asynchronous unary call to AnalyzeEntitySentiment.
  71. ///
  72. /// - Parameters:
  73. /// - request: Request to send to AnalyzeEntitySentiment.
  74. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  75. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  76. internal func analyzeEntitySentiment(_ request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, callOptions: CallOptions? = nil) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse> {
  77. return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/AnalyzeEntitySentiment",
  78. request: request,
  79. callOptions: callOptions ?? self.defaultCallOptions)
  80. }
  81. /// Asynchronous unary call to AnalyzeSyntax.
  82. ///
  83. /// - Parameters:
  84. /// - request: Request to send to AnalyzeSyntax.
  85. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  86. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  87. internal func analyzeSyntax(_ request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest, callOptions: CallOptions? = nil) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeSyntaxRequest, Google_Cloud_Language_V1_AnalyzeSyntaxResponse> {
  88. return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/AnalyzeSyntax",
  89. request: request,
  90. callOptions: callOptions ?? self.defaultCallOptions)
  91. }
  92. /// Asynchronous unary call to ClassifyText.
  93. ///
  94. /// - Parameters:
  95. /// - request: Request to send to ClassifyText.
  96. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  97. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  98. internal func classifyText(_ request: Google_Cloud_Language_V1_ClassifyTextRequest, callOptions: CallOptions? = nil) -> UnaryCall<Google_Cloud_Language_V1_ClassifyTextRequest, Google_Cloud_Language_V1_ClassifyTextResponse> {
  99. return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/ClassifyText",
  100. request: request,
  101. callOptions: callOptions ?? self.defaultCallOptions)
  102. }
  103. /// Asynchronous unary call to AnnotateText.
  104. ///
  105. /// - Parameters:
  106. /// - request: Request to send to AnnotateText.
  107. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  108. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  109. internal func annotateText(_ request: Google_Cloud_Language_V1_AnnotateTextRequest, callOptions: CallOptions? = nil) -> UnaryCall<Google_Cloud_Language_V1_AnnotateTextRequest, Google_Cloud_Language_V1_AnnotateTextResponse> {
  110. return self.makeUnaryCall(path: "/google.cloud.language.v1.LanguageService/AnnotateText",
  111. request: request,
  112. callOptions: callOptions ?? self.defaultCallOptions)
  113. }
  114. }
  115. /// To build a server, implement a class that conforms to this protocol.
  116. internal protocol Google_Cloud_Language_V1_LanguageServiceProvider: CallHandlerProvider {
  117. func analyzeSentiment(request: Google_Cloud_Language_V1_AnalyzeSentimentRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_AnalyzeSentimentResponse>
  118. func analyzeEntities(request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_AnalyzeEntitiesResponse>
  119. func analyzeEntitySentiment(request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse>
  120. func analyzeSyntax(request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_AnalyzeSyntaxResponse>
  121. func classifyText(request: Google_Cloud_Language_V1_ClassifyTextRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_ClassifyTextResponse>
  122. func annotateText(request: Google_Cloud_Language_V1_AnnotateTextRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_AnnotateTextResponse>
  123. }
  124. extension Google_Cloud_Language_V1_LanguageServiceProvider {
  125. internal var serviceName: String { return "google.cloud.language.v1.LanguageService" }
  126. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  127. /// Returns nil for methods not handled by this service.
  128. internal func handleMethod(_ methodName: String, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
  129. switch methodName {
  130. case "AnalyzeSentiment":
  131. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  132. return { request in
  133. self.analyzeSentiment(request: request, context: context)
  134. }
  135. }
  136. case "AnalyzeEntities":
  137. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  138. return { request in
  139. self.analyzeEntities(request: request, context: context)
  140. }
  141. }
  142. case "AnalyzeEntitySentiment":
  143. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  144. return { request in
  145. self.analyzeEntitySentiment(request: request, context: context)
  146. }
  147. }
  148. case "AnalyzeSyntax":
  149. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  150. return { request in
  151. self.analyzeSyntax(request: request, context: context)
  152. }
  153. }
  154. case "ClassifyText":
  155. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  156. return { request in
  157. self.classifyText(request: request, context: context)
  158. }
  159. }
  160. case "AnnotateText":
  161. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  162. return { request in
  163. self.annotateText(request: request, context: context)
  164. }
  165. }
  166. default: return nil
  167. }
  168. }
  169. }