language_service.grpc.swift 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  1. //
  2. // DO NOT EDIT.
  3. // swift-format-ignore-file
  4. //
  5. // Generated by the protocol buffer compiler.
  6. // Source: google/cloud/language/v1/language_service.proto
  7. //
  8. import GRPC
  9. import NIO
  10. import NIOConcurrencyHelpers
  11. import SwiftProtobuf
  12. /// Provides text analysis operations such as sentiment analysis and entity
  13. /// recognition.
  14. ///
  15. /// Usage: instantiate `Google_Cloud_Language_V1_LanguageServiceClient`, then call methods of this protocol to make API calls.
  16. internal protocol Google_Cloud_Language_V1_LanguageServiceClientProtocol: GRPCClient {
  17. var serviceName: String { get }
  18. var interceptors: Google_Cloud_Language_V1_LanguageServiceClientInterceptorFactoryProtocol? { get }
  19. func analyzeSentiment(
  20. _ request: Google_Cloud_Language_V1_AnalyzeSentimentRequest,
  21. callOptions: CallOptions?
  22. ) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeSentimentRequest, Google_Cloud_Language_V1_AnalyzeSentimentResponse>
  23. func analyzeEntities(
  24. _ request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest,
  25. callOptions: CallOptions?
  26. ) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeEntitiesRequest, Google_Cloud_Language_V1_AnalyzeEntitiesResponse>
  27. func analyzeEntitySentiment(
  28. _ request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest,
  29. callOptions: CallOptions?
  30. ) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse>
  31. func analyzeSyntax(
  32. _ request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest,
  33. callOptions: CallOptions?
  34. ) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeSyntaxRequest, Google_Cloud_Language_V1_AnalyzeSyntaxResponse>
  35. func classifyText(
  36. _ request: Google_Cloud_Language_V1_ClassifyTextRequest,
  37. callOptions: CallOptions?
  38. ) -> UnaryCall<Google_Cloud_Language_V1_ClassifyTextRequest, Google_Cloud_Language_V1_ClassifyTextResponse>
  39. func annotateText(
  40. _ request: Google_Cloud_Language_V1_AnnotateTextRequest,
  41. callOptions: CallOptions?
  42. ) -> UnaryCall<Google_Cloud_Language_V1_AnnotateTextRequest, Google_Cloud_Language_V1_AnnotateTextResponse>
  43. }
  44. extension Google_Cloud_Language_V1_LanguageServiceClientProtocol {
  45. internal var serviceName: String {
  46. return "google.cloud.language.v1.LanguageService"
  47. }
  48. /// Analyzes the sentiment of the provided text.
  49. ///
  50. /// - Parameters:
  51. /// - request: Request to send to AnalyzeSentiment.
  52. /// - callOptions: Call options.
  53. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  54. internal func analyzeSentiment(
  55. _ request: Google_Cloud_Language_V1_AnalyzeSentimentRequest,
  56. callOptions: CallOptions? = nil
  57. ) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeSentimentRequest, Google_Cloud_Language_V1_AnalyzeSentimentResponse> {
  58. return self.makeUnaryCall(
  59. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeSentiment.path,
  60. request: request,
  61. callOptions: callOptions ?? self.defaultCallOptions,
  62. interceptors: self.interceptors?.makeAnalyzeSentimentInterceptors() ?? []
  63. )
  64. }
  65. /// Finds named entities (currently proper names and common nouns) in the text
  66. /// along with entity types, salience, mentions for each entity, and
  67. /// other properties.
  68. ///
  69. /// - Parameters:
  70. /// - request: Request to send to AnalyzeEntities.
  71. /// - callOptions: Call options.
  72. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  73. internal func analyzeEntities(
  74. _ request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest,
  75. callOptions: CallOptions? = nil
  76. ) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeEntitiesRequest, Google_Cloud_Language_V1_AnalyzeEntitiesResponse> {
  77. return self.makeUnaryCall(
  78. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeEntities.path,
  79. request: request,
  80. callOptions: callOptions ?? self.defaultCallOptions,
  81. interceptors: self.interceptors?.makeAnalyzeEntitiesInterceptors() ?? []
  82. )
  83. }
  84. /// Finds entities, similar to
  85. /// [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities]
  86. /// in the text and analyzes sentiment associated with each entity and its
  87. /// mentions.
  88. ///
  89. /// - Parameters:
  90. /// - request: Request to send to AnalyzeEntitySentiment.
  91. /// - callOptions: Call options.
  92. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  93. internal func analyzeEntitySentiment(
  94. _ request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest,
  95. callOptions: CallOptions? = nil
  96. ) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse> {
  97. return self.makeUnaryCall(
  98. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeEntitySentiment.path,
  99. request: request,
  100. callOptions: callOptions ?? self.defaultCallOptions,
  101. interceptors: self.interceptors?.makeAnalyzeEntitySentimentInterceptors() ?? []
  102. )
  103. }
  104. /// Analyzes the syntax of the text and provides sentence boundaries and
  105. /// tokenization along with part of speech tags, dependency trees, and other
  106. /// properties.
  107. ///
  108. /// - Parameters:
  109. /// - request: Request to send to AnalyzeSyntax.
  110. /// - callOptions: Call options.
  111. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  112. internal func analyzeSyntax(
  113. _ request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest,
  114. callOptions: CallOptions? = nil
  115. ) -> UnaryCall<Google_Cloud_Language_V1_AnalyzeSyntaxRequest, Google_Cloud_Language_V1_AnalyzeSyntaxResponse> {
  116. return self.makeUnaryCall(
  117. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeSyntax.path,
  118. request: request,
  119. callOptions: callOptions ?? self.defaultCallOptions,
  120. interceptors: self.interceptors?.makeAnalyzeSyntaxInterceptors() ?? []
  121. )
  122. }
  123. /// Classifies a document into categories.
  124. ///
  125. /// - Parameters:
  126. /// - request: Request to send to ClassifyText.
  127. /// - callOptions: Call options.
  128. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  129. internal func classifyText(
  130. _ request: Google_Cloud_Language_V1_ClassifyTextRequest,
  131. callOptions: CallOptions? = nil
  132. ) -> UnaryCall<Google_Cloud_Language_V1_ClassifyTextRequest, Google_Cloud_Language_V1_ClassifyTextResponse> {
  133. return self.makeUnaryCall(
  134. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.classifyText.path,
  135. request: request,
  136. callOptions: callOptions ?? self.defaultCallOptions,
  137. interceptors: self.interceptors?.makeClassifyTextInterceptors() ?? []
  138. )
  139. }
  140. /// A convenience method that provides all the features that analyzeSentiment,
  141. /// analyzeEntities, and analyzeSyntax provide in one call.
  142. ///
  143. /// - Parameters:
  144. /// - request: Request to send to AnnotateText.
  145. /// - callOptions: Call options.
  146. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  147. internal func annotateText(
  148. _ request: Google_Cloud_Language_V1_AnnotateTextRequest,
  149. callOptions: CallOptions? = nil
  150. ) -> UnaryCall<Google_Cloud_Language_V1_AnnotateTextRequest, Google_Cloud_Language_V1_AnnotateTextResponse> {
  151. return self.makeUnaryCall(
  152. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.annotateText.path,
  153. request: request,
  154. callOptions: callOptions ?? self.defaultCallOptions,
  155. interceptors: self.interceptors?.makeAnnotateTextInterceptors() ?? []
  156. )
  157. }
  158. }
  159. #if compiler(>=5.6)
  160. @available(*, deprecated)
  161. extension Google_Cloud_Language_V1_LanguageServiceClient: @unchecked Sendable {}
  162. #endif // compiler(>=5.6)
  163. @available(*, deprecated, renamed: "Google_Cloud_Language_V1_LanguageServiceNIOClient")
  164. internal final class Google_Cloud_Language_V1_LanguageServiceClient: Google_Cloud_Language_V1_LanguageServiceClientProtocol {
  165. private let lock = Lock()
  166. private var _defaultCallOptions: CallOptions
  167. private var _interceptors: Google_Cloud_Language_V1_LanguageServiceClientInterceptorFactoryProtocol?
  168. internal let channel: GRPCChannel
  169. internal var defaultCallOptions: CallOptions {
  170. get { self.lock.withLock { return self._defaultCallOptions } }
  171. set { self.lock.withLockVoid { self._defaultCallOptions = newValue } }
  172. }
  173. internal var interceptors: Google_Cloud_Language_V1_LanguageServiceClientInterceptorFactoryProtocol? {
  174. get { self.lock.withLock { return self._interceptors } }
  175. set { self.lock.withLockVoid { self._interceptors = newValue } }
  176. }
  177. /// Creates a client for the google.cloud.language.v1.LanguageService service.
  178. ///
  179. /// - Parameters:
  180. /// - channel: `GRPCChannel` to the service host.
  181. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  182. /// - interceptors: A factory providing interceptors for each RPC.
  183. internal init(
  184. channel: GRPCChannel,
  185. defaultCallOptions: CallOptions = CallOptions(),
  186. interceptors: Google_Cloud_Language_V1_LanguageServiceClientInterceptorFactoryProtocol? = nil
  187. ) {
  188. self.channel = channel
  189. self._defaultCallOptions = defaultCallOptions
  190. self._interceptors = interceptors
  191. }
  192. }
  193. internal struct Google_Cloud_Language_V1_LanguageServiceNIOClient: Google_Cloud_Language_V1_LanguageServiceClientProtocol {
  194. internal var channel: GRPCChannel
  195. internal var defaultCallOptions: CallOptions
  196. internal var interceptors: Google_Cloud_Language_V1_LanguageServiceClientInterceptorFactoryProtocol?
  197. /// Creates a client for the google.cloud.language.v1.LanguageService service.
  198. ///
  199. /// - Parameters:
  200. /// - channel: `GRPCChannel` to the service host.
  201. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  202. /// - interceptors: A factory providing interceptors for each RPC.
  203. internal init(
  204. channel: GRPCChannel,
  205. defaultCallOptions: CallOptions = CallOptions(),
  206. interceptors: Google_Cloud_Language_V1_LanguageServiceClientInterceptorFactoryProtocol? = nil
  207. ) {
  208. self.channel = channel
  209. self.defaultCallOptions = defaultCallOptions
  210. self.interceptors = interceptors
  211. }
  212. }
  213. #if compiler(>=5.6)
  214. /// Provides text analysis operations such as sentiment analysis and entity
  215. /// recognition.
  216. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  217. internal protocol Google_Cloud_Language_V1_LanguageServiceAsyncClientProtocol: GRPCClient {
  218. static var serviceDescriptor: GRPCServiceDescriptor { get }
  219. var interceptors: Google_Cloud_Language_V1_LanguageServiceClientInterceptorFactoryProtocol? { get }
  220. func makeAnalyzeSentimentCall(
  221. _ request: Google_Cloud_Language_V1_AnalyzeSentimentRequest,
  222. callOptions: CallOptions?
  223. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_AnalyzeSentimentRequest, Google_Cloud_Language_V1_AnalyzeSentimentResponse>
  224. func makeAnalyzeEntitiesCall(
  225. _ request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest,
  226. callOptions: CallOptions?
  227. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_AnalyzeEntitiesRequest, Google_Cloud_Language_V1_AnalyzeEntitiesResponse>
  228. func makeAnalyzeEntitySentimentCall(
  229. _ request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest,
  230. callOptions: CallOptions?
  231. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse>
  232. func makeAnalyzeSyntaxCall(
  233. _ request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest,
  234. callOptions: CallOptions?
  235. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_AnalyzeSyntaxRequest, Google_Cloud_Language_V1_AnalyzeSyntaxResponse>
  236. func makeClassifyTextCall(
  237. _ request: Google_Cloud_Language_V1_ClassifyTextRequest,
  238. callOptions: CallOptions?
  239. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_ClassifyTextRequest, Google_Cloud_Language_V1_ClassifyTextResponse>
  240. func makeAnnotateTextCall(
  241. _ request: Google_Cloud_Language_V1_AnnotateTextRequest,
  242. callOptions: CallOptions?
  243. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_AnnotateTextRequest, Google_Cloud_Language_V1_AnnotateTextResponse>
  244. }
  245. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  246. extension Google_Cloud_Language_V1_LanguageServiceAsyncClientProtocol {
  247. internal static var serviceDescriptor: GRPCServiceDescriptor {
  248. return Google_Cloud_Language_V1_LanguageServiceClientMetadata.serviceDescriptor
  249. }
  250. internal var interceptors: Google_Cloud_Language_V1_LanguageServiceClientInterceptorFactoryProtocol? {
  251. return nil
  252. }
  253. internal func makeAnalyzeSentimentCall(
  254. _ request: Google_Cloud_Language_V1_AnalyzeSentimentRequest,
  255. callOptions: CallOptions? = nil
  256. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_AnalyzeSentimentRequest, Google_Cloud_Language_V1_AnalyzeSentimentResponse> {
  257. return self.makeAsyncUnaryCall(
  258. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeSentiment.path,
  259. request: request,
  260. callOptions: callOptions ?? self.defaultCallOptions,
  261. interceptors: self.interceptors?.makeAnalyzeSentimentInterceptors() ?? []
  262. )
  263. }
  264. internal func makeAnalyzeEntitiesCall(
  265. _ request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest,
  266. callOptions: CallOptions? = nil
  267. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_AnalyzeEntitiesRequest, Google_Cloud_Language_V1_AnalyzeEntitiesResponse> {
  268. return self.makeAsyncUnaryCall(
  269. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeEntities.path,
  270. request: request,
  271. callOptions: callOptions ?? self.defaultCallOptions,
  272. interceptors: self.interceptors?.makeAnalyzeEntitiesInterceptors() ?? []
  273. )
  274. }
  275. internal func makeAnalyzeEntitySentimentCall(
  276. _ request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest,
  277. callOptions: CallOptions? = nil
  278. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse> {
  279. return self.makeAsyncUnaryCall(
  280. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeEntitySentiment.path,
  281. request: request,
  282. callOptions: callOptions ?? self.defaultCallOptions,
  283. interceptors: self.interceptors?.makeAnalyzeEntitySentimentInterceptors() ?? []
  284. )
  285. }
  286. internal func makeAnalyzeSyntaxCall(
  287. _ request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest,
  288. callOptions: CallOptions? = nil
  289. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_AnalyzeSyntaxRequest, Google_Cloud_Language_V1_AnalyzeSyntaxResponse> {
  290. return self.makeAsyncUnaryCall(
  291. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeSyntax.path,
  292. request: request,
  293. callOptions: callOptions ?? self.defaultCallOptions,
  294. interceptors: self.interceptors?.makeAnalyzeSyntaxInterceptors() ?? []
  295. )
  296. }
  297. internal func makeClassifyTextCall(
  298. _ request: Google_Cloud_Language_V1_ClassifyTextRequest,
  299. callOptions: CallOptions? = nil
  300. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_ClassifyTextRequest, Google_Cloud_Language_V1_ClassifyTextResponse> {
  301. return self.makeAsyncUnaryCall(
  302. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.classifyText.path,
  303. request: request,
  304. callOptions: callOptions ?? self.defaultCallOptions,
  305. interceptors: self.interceptors?.makeClassifyTextInterceptors() ?? []
  306. )
  307. }
  308. internal func makeAnnotateTextCall(
  309. _ request: Google_Cloud_Language_V1_AnnotateTextRequest,
  310. callOptions: CallOptions? = nil
  311. ) -> GRPCAsyncUnaryCall<Google_Cloud_Language_V1_AnnotateTextRequest, Google_Cloud_Language_V1_AnnotateTextResponse> {
  312. return self.makeAsyncUnaryCall(
  313. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.annotateText.path,
  314. request: request,
  315. callOptions: callOptions ?? self.defaultCallOptions,
  316. interceptors: self.interceptors?.makeAnnotateTextInterceptors() ?? []
  317. )
  318. }
  319. }
  320. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  321. extension Google_Cloud_Language_V1_LanguageServiceAsyncClientProtocol {
  322. internal func analyzeSentiment(
  323. _ request: Google_Cloud_Language_V1_AnalyzeSentimentRequest,
  324. callOptions: CallOptions? = nil
  325. ) async throws -> Google_Cloud_Language_V1_AnalyzeSentimentResponse {
  326. return try await self.performAsyncUnaryCall(
  327. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeSentiment.path,
  328. request: request,
  329. callOptions: callOptions ?? self.defaultCallOptions,
  330. interceptors: self.interceptors?.makeAnalyzeSentimentInterceptors() ?? []
  331. )
  332. }
  333. internal func analyzeEntities(
  334. _ request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest,
  335. callOptions: CallOptions? = nil
  336. ) async throws -> Google_Cloud_Language_V1_AnalyzeEntitiesResponse {
  337. return try await self.performAsyncUnaryCall(
  338. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeEntities.path,
  339. request: request,
  340. callOptions: callOptions ?? self.defaultCallOptions,
  341. interceptors: self.interceptors?.makeAnalyzeEntitiesInterceptors() ?? []
  342. )
  343. }
  344. internal func analyzeEntitySentiment(
  345. _ request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest,
  346. callOptions: CallOptions? = nil
  347. ) async throws -> Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse {
  348. return try await self.performAsyncUnaryCall(
  349. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeEntitySentiment.path,
  350. request: request,
  351. callOptions: callOptions ?? self.defaultCallOptions,
  352. interceptors: self.interceptors?.makeAnalyzeEntitySentimentInterceptors() ?? []
  353. )
  354. }
  355. internal func analyzeSyntax(
  356. _ request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest,
  357. callOptions: CallOptions? = nil
  358. ) async throws -> Google_Cloud_Language_V1_AnalyzeSyntaxResponse {
  359. return try await self.performAsyncUnaryCall(
  360. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeSyntax.path,
  361. request: request,
  362. callOptions: callOptions ?? self.defaultCallOptions,
  363. interceptors: self.interceptors?.makeAnalyzeSyntaxInterceptors() ?? []
  364. )
  365. }
  366. internal func classifyText(
  367. _ request: Google_Cloud_Language_V1_ClassifyTextRequest,
  368. callOptions: CallOptions? = nil
  369. ) async throws -> Google_Cloud_Language_V1_ClassifyTextResponse {
  370. return try await self.performAsyncUnaryCall(
  371. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.classifyText.path,
  372. request: request,
  373. callOptions: callOptions ?? self.defaultCallOptions,
  374. interceptors: self.interceptors?.makeClassifyTextInterceptors() ?? []
  375. )
  376. }
  377. internal func annotateText(
  378. _ request: Google_Cloud_Language_V1_AnnotateTextRequest,
  379. callOptions: CallOptions? = nil
  380. ) async throws -> Google_Cloud_Language_V1_AnnotateTextResponse {
  381. return try await self.performAsyncUnaryCall(
  382. path: Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.annotateText.path,
  383. request: request,
  384. callOptions: callOptions ?? self.defaultCallOptions,
  385. interceptors: self.interceptors?.makeAnnotateTextInterceptors() ?? []
  386. )
  387. }
  388. }
  389. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  390. internal struct Google_Cloud_Language_V1_LanguageServiceAsyncClient: Google_Cloud_Language_V1_LanguageServiceAsyncClientProtocol {
  391. internal var channel: GRPCChannel
  392. internal var defaultCallOptions: CallOptions
  393. internal var interceptors: Google_Cloud_Language_V1_LanguageServiceClientInterceptorFactoryProtocol?
  394. internal init(
  395. channel: GRPCChannel,
  396. defaultCallOptions: CallOptions = CallOptions(),
  397. interceptors: Google_Cloud_Language_V1_LanguageServiceClientInterceptorFactoryProtocol? = nil
  398. ) {
  399. self.channel = channel
  400. self.defaultCallOptions = defaultCallOptions
  401. self.interceptors = interceptors
  402. }
  403. }
  404. #endif // compiler(>=5.6)
  405. internal protocol Google_Cloud_Language_V1_LanguageServiceClientInterceptorFactoryProtocol: GRPCSendable {
  406. /// - Returns: Interceptors to use when invoking 'analyzeSentiment'.
  407. func makeAnalyzeSentimentInterceptors() -> [ClientInterceptor<Google_Cloud_Language_V1_AnalyzeSentimentRequest, Google_Cloud_Language_V1_AnalyzeSentimentResponse>]
  408. /// - Returns: Interceptors to use when invoking 'analyzeEntities'.
  409. func makeAnalyzeEntitiesInterceptors() -> [ClientInterceptor<Google_Cloud_Language_V1_AnalyzeEntitiesRequest, Google_Cloud_Language_V1_AnalyzeEntitiesResponse>]
  410. /// - Returns: Interceptors to use when invoking 'analyzeEntitySentiment'.
  411. func makeAnalyzeEntitySentimentInterceptors() -> [ClientInterceptor<Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse>]
  412. /// - Returns: Interceptors to use when invoking 'analyzeSyntax'.
  413. func makeAnalyzeSyntaxInterceptors() -> [ClientInterceptor<Google_Cloud_Language_V1_AnalyzeSyntaxRequest, Google_Cloud_Language_V1_AnalyzeSyntaxResponse>]
  414. /// - Returns: Interceptors to use when invoking 'classifyText'.
  415. func makeClassifyTextInterceptors() -> [ClientInterceptor<Google_Cloud_Language_V1_ClassifyTextRequest, Google_Cloud_Language_V1_ClassifyTextResponse>]
  416. /// - Returns: Interceptors to use when invoking 'annotateText'.
  417. func makeAnnotateTextInterceptors() -> [ClientInterceptor<Google_Cloud_Language_V1_AnnotateTextRequest, Google_Cloud_Language_V1_AnnotateTextResponse>]
  418. }
  419. internal enum Google_Cloud_Language_V1_LanguageServiceClientMetadata {
  420. internal static let serviceDescriptor = GRPCServiceDescriptor(
  421. name: "LanguageService",
  422. fullName: "google.cloud.language.v1.LanguageService",
  423. methods: [
  424. Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeSentiment,
  425. Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeEntities,
  426. Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeEntitySentiment,
  427. Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.analyzeSyntax,
  428. Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.classifyText,
  429. Google_Cloud_Language_V1_LanguageServiceClientMetadata.Methods.annotateText,
  430. ]
  431. )
  432. internal enum Methods {
  433. internal static let analyzeSentiment = GRPCMethodDescriptor(
  434. name: "AnalyzeSentiment",
  435. path: "/google.cloud.language.v1.LanguageService/AnalyzeSentiment",
  436. type: GRPCCallType.unary
  437. )
  438. internal static let analyzeEntities = GRPCMethodDescriptor(
  439. name: "AnalyzeEntities",
  440. path: "/google.cloud.language.v1.LanguageService/AnalyzeEntities",
  441. type: GRPCCallType.unary
  442. )
  443. internal static let analyzeEntitySentiment = GRPCMethodDescriptor(
  444. name: "AnalyzeEntitySentiment",
  445. path: "/google.cloud.language.v1.LanguageService/AnalyzeEntitySentiment",
  446. type: GRPCCallType.unary
  447. )
  448. internal static let analyzeSyntax = GRPCMethodDescriptor(
  449. name: "AnalyzeSyntax",
  450. path: "/google.cloud.language.v1.LanguageService/AnalyzeSyntax",
  451. type: GRPCCallType.unary
  452. )
  453. internal static let classifyText = GRPCMethodDescriptor(
  454. name: "ClassifyText",
  455. path: "/google.cloud.language.v1.LanguageService/ClassifyText",
  456. type: GRPCCallType.unary
  457. )
  458. internal static let annotateText = GRPCMethodDescriptor(
  459. name: "AnnotateText",
  460. path: "/google.cloud.language.v1.LanguageService/AnnotateText",
  461. type: GRPCCallType.unary
  462. )
  463. }
  464. }
  465. /// Provides text analysis operations such as sentiment analysis and entity
  466. /// recognition.
  467. ///
  468. /// To build a server, implement a class that conforms to this protocol.
  469. internal protocol Google_Cloud_Language_V1_LanguageServiceProvider: CallHandlerProvider {
  470. var interceptors: Google_Cloud_Language_V1_LanguageServiceServerInterceptorFactoryProtocol? { get }
  471. /// Analyzes the sentiment of the provided text.
  472. func analyzeSentiment(request: Google_Cloud_Language_V1_AnalyzeSentimentRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_AnalyzeSentimentResponse>
  473. /// Finds named entities (currently proper names and common nouns) in the text
  474. /// along with entity types, salience, mentions for each entity, and
  475. /// other properties.
  476. func analyzeEntities(request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_AnalyzeEntitiesResponse>
  477. /// Finds entities, similar to
  478. /// [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities]
  479. /// in the text and analyzes sentiment associated with each entity and its
  480. /// mentions.
  481. func analyzeEntitySentiment(request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse>
  482. /// Analyzes the syntax of the text and provides sentence boundaries and
  483. /// tokenization along with part of speech tags, dependency trees, and other
  484. /// properties.
  485. func analyzeSyntax(request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_AnalyzeSyntaxResponse>
  486. /// Classifies a document into categories.
  487. func classifyText(request: Google_Cloud_Language_V1_ClassifyTextRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_ClassifyTextResponse>
  488. /// A convenience method that provides all the features that analyzeSentiment,
  489. /// analyzeEntities, and analyzeSyntax provide in one call.
  490. func annotateText(request: Google_Cloud_Language_V1_AnnotateTextRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Google_Cloud_Language_V1_AnnotateTextResponse>
  491. }
  492. extension Google_Cloud_Language_V1_LanguageServiceProvider {
  493. internal var serviceName: Substring {
  494. return Google_Cloud_Language_V1_LanguageServiceServerMetadata.serviceDescriptor.fullName[...]
  495. }
  496. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  497. /// Returns nil for methods not handled by this service.
  498. internal func handle(
  499. method name: Substring,
  500. context: CallHandlerContext
  501. ) -> GRPCServerHandlerProtocol? {
  502. switch name {
  503. case "AnalyzeSentiment":
  504. return UnaryServerHandler(
  505. context: context,
  506. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_AnalyzeSentimentRequest>(),
  507. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_AnalyzeSentimentResponse>(),
  508. interceptors: self.interceptors?.makeAnalyzeSentimentInterceptors() ?? [],
  509. userFunction: self.analyzeSentiment(request:context:)
  510. )
  511. case "AnalyzeEntities":
  512. return UnaryServerHandler(
  513. context: context,
  514. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_AnalyzeEntitiesRequest>(),
  515. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_AnalyzeEntitiesResponse>(),
  516. interceptors: self.interceptors?.makeAnalyzeEntitiesInterceptors() ?? [],
  517. userFunction: self.analyzeEntities(request:context:)
  518. )
  519. case "AnalyzeEntitySentiment":
  520. return UnaryServerHandler(
  521. context: context,
  522. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest>(),
  523. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse>(),
  524. interceptors: self.interceptors?.makeAnalyzeEntitySentimentInterceptors() ?? [],
  525. userFunction: self.analyzeEntitySentiment(request:context:)
  526. )
  527. case "AnalyzeSyntax":
  528. return UnaryServerHandler(
  529. context: context,
  530. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_AnalyzeSyntaxRequest>(),
  531. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_AnalyzeSyntaxResponse>(),
  532. interceptors: self.interceptors?.makeAnalyzeSyntaxInterceptors() ?? [],
  533. userFunction: self.analyzeSyntax(request:context:)
  534. )
  535. case "ClassifyText":
  536. return UnaryServerHandler(
  537. context: context,
  538. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_ClassifyTextRequest>(),
  539. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_ClassifyTextResponse>(),
  540. interceptors: self.interceptors?.makeClassifyTextInterceptors() ?? [],
  541. userFunction: self.classifyText(request:context:)
  542. )
  543. case "AnnotateText":
  544. return UnaryServerHandler(
  545. context: context,
  546. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_AnnotateTextRequest>(),
  547. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_AnnotateTextResponse>(),
  548. interceptors: self.interceptors?.makeAnnotateTextInterceptors() ?? [],
  549. userFunction: self.annotateText(request:context:)
  550. )
  551. default:
  552. return nil
  553. }
  554. }
  555. }
  556. #if compiler(>=5.6)
  557. /// Provides text analysis operations such as sentiment analysis and entity
  558. /// recognition.
  559. ///
  560. /// To implement a server, implement an object which conforms to this protocol.
  561. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  562. internal protocol Google_Cloud_Language_V1_LanguageServiceAsyncProvider: CallHandlerProvider {
  563. static var serviceDescriptor: GRPCServiceDescriptor { get }
  564. var interceptors: Google_Cloud_Language_V1_LanguageServiceServerInterceptorFactoryProtocol? { get }
  565. /// Analyzes the sentiment of the provided text.
  566. @Sendable func analyzeSentiment(
  567. request: Google_Cloud_Language_V1_AnalyzeSentimentRequest,
  568. context: GRPCAsyncServerCallContext
  569. ) async throws -> Google_Cloud_Language_V1_AnalyzeSentimentResponse
  570. /// Finds named entities (currently proper names and common nouns) in the text
  571. /// along with entity types, salience, mentions for each entity, and
  572. /// other properties.
  573. @Sendable func analyzeEntities(
  574. request: Google_Cloud_Language_V1_AnalyzeEntitiesRequest,
  575. context: GRPCAsyncServerCallContext
  576. ) async throws -> Google_Cloud_Language_V1_AnalyzeEntitiesResponse
  577. /// Finds entities, similar to
  578. /// [AnalyzeEntities][google.cloud.language.v1.LanguageService.AnalyzeEntities]
  579. /// in the text and analyzes sentiment associated with each entity and its
  580. /// mentions.
  581. @Sendable func analyzeEntitySentiment(
  582. request: Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest,
  583. context: GRPCAsyncServerCallContext
  584. ) async throws -> Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse
  585. /// Analyzes the syntax of the text and provides sentence boundaries and
  586. /// tokenization along with part of speech tags, dependency trees, and other
  587. /// properties.
  588. @Sendable func analyzeSyntax(
  589. request: Google_Cloud_Language_V1_AnalyzeSyntaxRequest,
  590. context: GRPCAsyncServerCallContext
  591. ) async throws -> Google_Cloud_Language_V1_AnalyzeSyntaxResponse
  592. /// Classifies a document into categories.
  593. @Sendable func classifyText(
  594. request: Google_Cloud_Language_V1_ClassifyTextRequest,
  595. context: GRPCAsyncServerCallContext
  596. ) async throws -> Google_Cloud_Language_V1_ClassifyTextResponse
  597. /// A convenience method that provides all the features that analyzeSentiment,
  598. /// analyzeEntities, and analyzeSyntax provide in one call.
  599. @Sendable func annotateText(
  600. request: Google_Cloud_Language_V1_AnnotateTextRequest,
  601. context: GRPCAsyncServerCallContext
  602. ) async throws -> Google_Cloud_Language_V1_AnnotateTextResponse
  603. }
  604. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
  605. extension Google_Cloud_Language_V1_LanguageServiceAsyncProvider {
  606. internal static var serviceDescriptor: GRPCServiceDescriptor {
  607. return Google_Cloud_Language_V1_LanguageServiceServerMetadata.serviceDescriptor
  608. }
  609. internal var serviceName: Substring {
  610. return Google_Cloud_Language_V1_LanguageServiceServerMetadata.serviceDescriptor.fullName[...]
  611. }
  612. internal var interceptors: Google_Cloud_Language_V1_LanguageServiceServerInterceptorFactoryProtocol? {
  613. return nil
  614. }
  615. internal func handle(
  616. method name: Substring,
  617. context: CallHandlerContext
  618. ) -> GRPCServerHandlerProtocol? {
  619. switch name {
  620. case "AnalyzeSentiment":
  621. return GRPCAsyncServerHandler(
  622. context: context,
  623. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_AnalyzeSentimentRequest>(),
  624. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_AnalyzeSentimentResponse>(),
  625. interceptors: self.interceptors?.makeAnalyzeSentimentInterceptors() ?? [],
  626. wrapping: self.analyzeSentiment(request:context:)
  627. )
  628. case "AnalyzeEntities":
  629. return GRPCAsyncServerHandler(
  630. context: context,
  631. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_AnalyzeEntitiesRequest>(),
  632. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_AnalyzeEntitiesResponse>(),
  633. interceptors: self.interceptors?.makeAnalyzeEntitiesInterceptors() ?? [],
  634. wrapping: self.analyzeEntities(request:context:)
  635. )
  636. case "AnalyzeEntitySentiment":
  637. return GRPCAsyncServerHandler(
  638. context: context,
  639. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest>(),
  640. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse>(),
  641. interceptors: self.interceptors?.makeAnalyzeEntitySentimentInterceptors() ?? [],
  642. wrapping: self.analyzeEntitySentiment(request:context:)
  643. )
  644. case "AnalyzeSyntax":
  645. return GRPCAsyncServerHandler(
  646. context: context,
  647. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_AnalyzeSyntaxRequest>(),
  648. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_AnalyzeSyntaxResponse>(),
  649. interceptors: self.interceptors?.makeAnalyzeSyntaxInterceptors() ?? [],
  650. wrapping: self.analyzeSyntax(request:context:)
  651. )
  652. case "ClassifyText":
  653. return GRPCAsyncServerHandler(
  654. context: context,
  655. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_ClassifyTextRequest>(),
  656. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_ClassifyTextResponse>(),
  657. interceptors: self.interceptors?.makeClassifyTextInterceptors() ?? [],
  658. wrapping: self.classifyText(request:context:)
  659. )
  660. case "AnnotateText":
  661. return GRPCAsyncServerHandler(
  662. context: context,
  663. requestDeserializer: ProtobufDeserializer<Google_Cloud_Language_V1_AnnotateTextRequest>(),
  664. responseSerializer: ProtobufSerializer<Google_Cloud_Language_V1_AnnotateTextResponse>(),
  665. interceptors: self.interceptors?.makeAnnotateTextInterceptors() ?? [],
  666. wrapping: self.annotateText(request:context:)
  667. )
  668. default:
  669. return nil
  670. }
  671. }
  672. }
  673. #endif // compiler(>=5.6)
  674. internal protocol Google_Cloud_Language_V1_LanguageServiceServerInterceptorFactoryProtocol {
  675. /// - Returns: Interceptors to use when handling 'analyzeSentiment'.
  676. /// Defaults to calling `self.makeInterceptors()`.
  677. func makeAnalyzeSentimentInterceptors() -> [ServerInterceptor<Google_Cloud_Language_V1_AnalyzeSentimentRequest, Google_Cloud_Language_V1_AnalyzeSentimentResponse>]
  678. /// - Returns: Interceptors to use when handling 'analyzeEntities'.
  679. /// Defaults to calling `self.makeInterceptors()`.
  680. func makeAnalyzeEntitiesInterceptors() -> [ServerInterceptor<Google_Cloud_Language_V1_AnalyzeEntitiesRequest, Google_Cloud_Language_V1_AnalyzeEntitiesResponse>]
  681. /// - Returns: Interceptors to use when handling 'analyzeEntitySentiment'.
  682. /// Defaults to calling `self.makeInterceptors()`.
  683. func makeAnalyzeEntitySentimentInterceptors() -> [ServerInterceptor<Google_Cloud_Language_V1_AnalyzeEntitySentimentRequest, Google_Cloud_Language_V1_AnalyzeEntitySentimentResponse>]
  684. /// - Returns: Interceptors to use when handling 'analyzeSyntax'.
  685. /// Defaults to calling `self.makeInterceptors()`.
  686. func makeAnalyzeSyntaxInterceptors() -> [ServerInterceptor<Google_Cloud_Language_V1_AnalyzeSyntaxRequest, Google_Cloud_Language_V1_AnalyzeSyntaxResponse>]
  687. /// - Returns: Interceptors to use when handling 'classifyText'.
  688. /// Defaults to calling `self.makeInterceptors()`.
  689. func makeClassifyTextInterceptors() -> [ServerInterceptor<Google_Cloud_Language_V1_ClassifyTextRequest, Google_Cloud_Language_V1_ClassifyTextResponse>]
  690. /// - Returns: Interceptors to use when handling 'annotateText'.
  691. /// Defaults to calling `self.makeInterceptors()`.
  692. func makeAnnotateTextInterceptors() -> [ServerInterceptor<Google_Cloud_Language_V1_AnnotateTextRequest, Google_Cloud_Language_V1_AnnotateTextResponse>]
  693. }
  694. internal enum Google_Cloud_Language_V1_LanguageServiceServerMetadata {
  695. internal static let serviceDescriptor = GRPCServiceDescriptor(
  696. name: "LanguageService",
  697. fullName: "google.cloud.language.v1.LanguageService",
  698. methods: [
  699. Google_Cloud_Language_V1_LanguageServiceServerMetadata.Methods.analyzeSentiment,
  700. Google_Cloud_Language_V1_LanguageServiceServerMetadata.Methods.analyzeEntities,
  701. Google_Cloud_Language_V1_LanguageServiceServerMetadata.Methods.analyzeEntitySentiment,
  702. Google_Cloud_Language_V1_LanguageServiceServerMetadata.Methods.analyzeSyntax,
  703. Google_Cloud_Language_V1_LanguageServiceServerMetadata.Methods.classifyText,
  704. Google_Cloud_Language_V1_LanguageServiceServerMetadata.Methods.annotateText,
  705. ]
  706. )
  707. internal enum Methods {
  708. internal static let analyzeSentiment = GRPCMethodDescriptor(
  709. name: "AnalyzeSentiment",
  710. path: "/google.cloud.language.v1.LanguageService/AnalyzeSentiment",
  711. type: GRPCCallType.unary
  712. )
  713. internal static let analyzeEntities = GRPCMethodDescriptor(
  714. name: "AnalyzeEntities",
  715. path: "/google.cloud.language.v1.LanguageService/AnalyzeEntities",
  716. type: GRPCCallType.unary
  717. )
  718. internal static let analyzeEntitySentiment = GRPCMethodDescriptor(
  719. name: "AnalyzeEntitySentiment",
  720. path: "/google.cloud.language.v1.LanguageService/AnalyzeEntitySentiment",
  721. type: GRPCCallType.unary
  722. )
  723. internal static let analyzeSyntax = GRPCMethodDescriptor(
  724. name: "AnalyzeSyntax",
  725. path: "/google.cloud.language.v1.LanguageService/AnalyzeSyntax",
  726. type: GRPCCallType.unary
  727. )
  728. internal static let classifyText = GRPCMethodDescriptor(
  729. name: "ClassifyText",
  730. path: "/google.cloud.language.v1.LanguageService/ClassifyText",
  731. type: GRPCCallType.unary
  732. )
  733. internal static let annotateText = GRPCMethodDescriptor(
  734. name: "AnnotateText",
  735. path: "/google.cloud.language.v1.LanguageService/AnnotateText",
  736. type: GRPCCallType.unary
  737. )
  738. }
  739. }