google-cloud-language-v1beta2 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,454 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/language/v1beta2/language_service_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Language
24
+ module V1beta2
25
+ module LanguageService
26
+ module Rest
27
+ ##
28
+ # REST service stub for the LanguageService service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ def initialize endpoint:, credentials:
34
+ # These require statements are intentionally placed here to initialize
35
+ # the REST modules only when it's required.
36
+ require "gapic/rest"
37
+
38
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
39
+ numeric_enums: true,
40
+ raise_faraday_errors: false
41
+ end
42
+
43
+ ##
44
+ # Baseline implementation for the analyze_sentiment REST call
45
+ #
46
+ # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeSentimentRequest]
47
+ # A request object representing the call parameters. Required.
48
+ # @param options [::Gapic::CallOptions]
49
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
50
+ #
51
+ # @yield [result, operation] Access the result along with the TransportOperation object
52
+ # @yieldparam result [::Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse]
53
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
54
+ #
55
+ # @return [::Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse]
56
+ # A result object deserialized from the server's reply
57
+ def analyze_sentiment request_pb, options = nil
58
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
59
+
60
+ verb, uri, query_string_params, body = ServiceStub.transcode_analyze_sentiment_request request_pb
61
+ query_string_params = if query_string_params.any?
62
+ query_string_params.to_h { |p| p.split("=", 2) }
63
+ else
64
+ {}
65
+ end
66
+
67
+ response = @client_stub.make_http_request(
68
+ verb,
69
+ uri: uri,
70
+ body: body || "",
71
+ params: query_string_params,
72
+ options: options
73
+ )
74
+ operation = ::Gapic::Rest::TransportOperation.new response
75
+ result = ::Google::Cloud::Language::V1beta2::AnalyzeSentimentResponse.decode_json response.body, ignore_unknown_fields: true
76
+
77
+ yield result, operation if block_given?
78
+ result
79
+ end
80
+
81
+ ##
82
+ # Baseline implementation for the analyze_entities REST call
83
+ #
84
+ # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeEntitiesRequest]
85
+ # A request object representing the call parameters. Required.
86
+ # @param options [::Gapic::CallOptions]
87
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
88
+ #
89
+ # @yield [result, operation] Access the result along with the TransportOperation object
90
+ # @yieldparam result [::Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse]
91
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
92
+ #
93
+ # @return [::Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse]
94
+ # A result object deserialized from the server's reply
95
+ def analyze_entities request_pb, options = nil
96
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
97
+
98
+ verb, uri, query_string_params, body = ServiceStub.transcode_analyze_entities_request request_pb
99
+ query_string_params = if query_string_params.any?
100
+ query_string_params.to_h { |p| p.split("=", 2) }
101
+ else
102
+ {}
103
+ end
104
+
105
+ response = @client_stub.make_http_request(
106
+ verb,
107
+ uri: uri,
108
+ body: body || "",
109
+ params: query_string_params,
110
+ options: options
111
+ )
112
+ operation = ::Gapic::Rest::TransportOperation.new response
113
+ result = ::Google::Cloud::Language::V1beta2::AnalyzeEntitiesResponse.decode_json response.body, ignore_unknown_fields: true
114
+
115
+ yield result, operation if block_given?
116
+ result
117
+ end
118
+
119
+ ##
120
+ # Baseline implementation for the analyze_entity_sentiment REST call
121
+ #
122
+ # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest]
123
+ # A request object representing the call parameters. Required.
124
+ # @param options [::Gapic::CallOptions]
125
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
126
+ #
127
+ # @yield [result, operation] Access the result along with the TransportOperation object
128
+ # @yieldparam result [::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse]
129
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
130
+ #
131
+ # @return [::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse]
132
+ # A result object deserialized from the server's reply
133
+ def analyze_entity_sentiment request_pb, options = nil
134
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
135
+
136
+ verb, uri, query_string_params, body = ServiceStub.transcode_analyze_entity_sentiment_request request_pb
137
+ query_string_params = if query_string_params.any?
138
+ query_string_params.to_h { |p| p.split("=", 2) }
139
+ else
140
+ {}
141
+ end
142
+
143
+ response = @client_stub.make_http_request(
144
+ verb,
145
+ uri: uri,
146
+ body: body || "",
147
+ params: query_string_params,
148
+ options: options
149
+ )
150
+ operation = ::Gapic::Rest::TransportOperation.new response
151
+ result = ::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentResponse.decode_json response.body, ignore_unknown_fields: true
152
+
153
+ yield result, operation if block_given?
154
+ result
155
+ end
156
+
157
+ ##
158
+ # Baseline implementation for the analyze_syntax REST call
159
+ #
160
+ # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest]
161
+ # A request object representing the call parameters. Required.
162
+ # @param options [::Gapic::CallOptions]
163
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
164
+ #
165
+ # @yield [result, operation] Access the result along with the TransportOperation object
166
+ # @yieldparam result [::Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse]
167
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
168
+ #
169
+ # @return [::Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse]
170
+ # A result object deserialized from the server's reply
171
+ def analyze_syntax request_pb, options = nil
172
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
173
+
174
+ verb, uri, query_string_params, body = ServiceStub.transcode_analyze_syntax_request request_pb
175
+ query_string_params = if query_string_params.any?
176
+ query_string_params.to_h { |p| p.split("=", 2) }
177
+ else
178
+ {}
179
+ end
180
+
181
+ response = @client_stub.make_http_request(
182
+ verb,
183
+ uri: uri,
184
+ body: body || "",
185
+ params: query_string_params,
186
+ options: options
187
+ )
188
+ operation = ::Gapic::Rest::TransportOperation.new response
189
+ result = ::Google::Cloud::Language::V1beta2::AnalyzeSyntaxResponse.decode_json response.body, ignore_unknown_fields: true
190
+
191
+ yield result, operation if block_given?
192
+ result
193
+ end
194
+
195
+ ##
196
+ # Baseline implementation for the classify_text REST call
197
+ #
198
+ # @param request_pb [::Google::Cloud::Language::V1beta2::ClassifyTextRequest]
199
+ # A request object representing the call parameters. Required.
200
+ # @param options [::Gapic::CallOptions]
201
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
202
+ #
203
+ # @yield [result, operation] Access the result along with the TransportOperation object
204
+ # @yieldparam result [::Google::Cloud::Language::V1beta2::ClassifyTextResponse]
205
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
206
+ #
207
+ # @return [::Google::Cloud::Language::V1beta2::ClassifyTextResponse]
208
+ # A result object deserialized from the server's reply
209
+ def classify_text request_pb, options = nil
210
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
211
+
212
+ verb, uri, query_string_params, body = ServiceStub.transcode_classify_text_request request_pb
213
+ query_string_params = if query_string_params.any?
214
+ query_string_params.to_h { |p| p.split("=", 2) }
215
+ else
216
+ {}
217
+ end
218
+
219
+ response = @client_stub.make_http_request(
220
+ verb,
221
+ uri: uri,
222
+ body: body || "",
223
+ params: query_string_params,
224
+ options: options
225
+ )
226
+ operation = ::Gapic::Rest::TransportOperation.new response
227
+ result = ::Google::Cloud::Language::V1beta2::ClassifyTextResponse.decode_json response.body, ignore_unknown_fields: true
228
+
229
+ yield result, operation if block_given?
230
+ result
231
+ end
232
+
233
+ ##
234
+ # Baseline implementation for the moderate_text REST call
235
+ #
236
+ # @param request_pb [::Google::Cloud::Language::V1beta2::ModerateTextRequest]
237
+ # A request object representing the call parameters. Required.
238
+ # @param options [::Gapic::CallOptions]
239
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
240
+ #
241
+ # @yield [result, operation] Access the result along with the TransportOperation object
242
+ # @yieldparam result [::Google::Cloud::Language::V1beta2::ModerateTextResponse]
243
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
244
+ #
245
+ # @return [::Google::Cloud::Language::V1beta2::ModerateTextResponse]
246
+ # A result object deserialized from the server's reply
247
+ def moderate_text request_pb, options = nil
248
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
249
+
250
+ verb, uri, query_string_params, body = ServiceStub.transcode_moderate_text_request request_pb
251
+ query_string_params = if query_string_params.any?
252
+ query_string_params.to_h { |p| p.split("=", 2) }
253
+ else
254
+ {}
255
+ end
256
+
257
+ response = @client_stub.make_http_request(
258
+ verb,
259
+ uri: uri,
260
+ body: body || "",
261
+ params: query_string_params,
262
+ options: options
263
+ )
264
+ operation = ::Gapic::Rest::TransportOperation.new response
265
+ result = ::Google::Cloud::Language::V1beta2::ModerateTextResponse.decode_json response.body, ignore_unknown_fields: true
266
+
267
+ yield result, operation if block_given?
268
+ result
269
+ end
270
+
271
+ ##
272
+ # Baseline implementation for the annotate_text REST call
273
+ #
274
+ # @param request_pb [::Google::Cloud::Language::V1beta2::AnnotateTextRequest]
275
+ # A request object representing the call parameters. Required.
276
+ # @param options [::Gapic::CallOptions]
277
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
278
+ #
279
+ # @yield [result, operation] Access the result along with the TransportOperation object
280
+ # @yieldparam result [::Google::Cloud::Language::V1beta2::AnnotateTextResponse]
281
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
282
+ #
283
+ # @return [::Google::Cloud::Language::V1beta2::AnnotateTextResponse]
284
+ # A result object deserialized from the server's reply
285
+ def annotate_text request_pb, options = nil
286
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
287
+
288
+ verb, uri, query_string_params, body = ServiceStub.transcode_annotate_text_request request_pb
289
+ query_string_params = if query_string_params.any?
290
+ query_string_params.to_h { |p| p.split("=", 2) }
291
+ else
292
+ {}
293
+ end
294
+
295
+ response = @client_stub.make_http_request(
296
+ verb,
297
+ uri: uri,
298
+ body: body || "",
299
+ params: query_string_params,
300
+ options: options
301
+ )
302
+ operation = ::Gapic::Rest::TransportOperation.new response
303
+ result = ::Google::Cloud::Language::V1beta2::AnnotateTextResponse.decode_json response.body, ignore_unknown_fields: true
304
+
305
+ yield result, operation if block_given?
306
+ result
307
+ end
308
+
309
+ ##
310
+ # @private
311
+ #
312
+ # GRPC transcoding helper method for the analyze_sentiment REST call
313
+ #
314
+ # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeSentimentRequest]
315
+ # A request object representing the call parameters. Required.
316
+ # @return [Array(String, [String, nil], Hash{String => String})]
317
+ # Uri, Body, Query string parameters
318
+ def self.transcode_analyze_sentiment_request request_pb
319
+ transcoder = Gapic::Rest::GrpcTranscoder.new
320
+ .with_bindings(
321
+ uri_method: :post,
322
+ uri_template: "/v1beta2/documents:analyzeSentiment",
323
+ body: "*",
324
+ matches: []
325
+ )
326
+ transcoder.transcode request_pb
327
+ end
328
+
329
+ ##
330
+ # @private
331
+ #
332
+ # GRPC transcoding helper method for the analyze_entities REST call
333
+ #
334
+ # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeEntitiesRequest]
335
+ # A request object representing the call parameters. Required.
336
+ # @return [Array(String, [String, nil], Hash{String => String})]
337
+ # Uri, Body, Query string parameters
338
+ def self.transcode_analyze_entities_request request_pb
339
+ transcoder = Gapic::Rest::GrpcTranscoder.new
340
+ .with_bindings(
341
+ uri_method: :post,
342
+ uri_template: "/v1beta2/documents:analyzeEntities",
343
+ body: "*",
344
+ matches: []
345
+ )
346
+ transcoder.transcode request_pb
347
+ end
348
+
349
+ ##
350
+ # @private
351
+ #
352
+ # GRPC transcoding helper method for the analyze_entity_sentiment REST call
353
+ #
354
+ # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeEntitySentimentRequest]
355
+ # A request object representing the call parameters. Required.
356
+ # @return [Array(String, [String, nil], Hash{String => String})]
357
+ # Uri, Body, Query string parameters
358
+ def self.transcode_analyze_entity_sentiment_request request_pb
359
+ transcoder = Gapic::Rest::GrpcTranscoder.new
360
+ .with_bindings(
361
+ uri_method: :post,
362
+ uri_template: "/v1beta2/documents:analyzeEntitySentiment",
363
+ body: "*",
364
+ matches: []
365
+ )
366
+ transcoder.transcode request_pb
367
+ end
368
+
369
+ ##
370
+ # @private
371
+ #
372
+ # GRPC transcoding helper method for the analyze_syntax REST call
373
+ #
374
+ # @param request_pb [::Google::Cloud::Language::V1beta2::AnalyzeSyntaxRequest]
375
+ # A request object representing the call parameters. Required.
376
+ # @return [Array(String, [String, nil], Hash{String => String})]
377
+ # Uri, Body, Query string parameters
378
+ def self.transcode_analyze_syntax_request request_pb
379
+ transcoder = Gapic::Rest::GrpcTranscoder.new
380
+ .with_bindings(
381
+ uri_method: :post,
382
+ uri_template: "/v1beta2/documents:analyzeSyntax",
383
+ body: "*",
384
+ matches: []
385
+ )
386
+ transcoder.transcode request_pb
387
+ end
388
+
389
+ ##
390
+ # @private
391
+ #
392
+ # GRPC transcoding helper method for the classify_text REST call
393
+ #
394
+ # @param request_pb [::Google::Cloud::Language::V1beta2::ClassifyTextRequest]
395
+ # A request object representing the call parameters. Required.
396
+ # @return [Array(String, [String, nil], Hash{String => String})]
397
+ # Uri, Body, Query string parameters
398
+ def self.transcode_classify_text_request request_pb
399
+ transcoder = Gapic::Rest::GrpcTranscoder.new
400
+ .with_bindings(
401
+ uri_method: :post,
402
+ uri_template: "/v1beta2/documents:classifyText",
403
+ body: "*",
404
+ matches: []
405
+ )
406
+ transcoder.transcode request_pb
407
+ end
408
+
409
+ ##
410
+ # @private
411
+ #
412
+ # GRPC transcoding helper method for the moderate_text REST call
413
+ #
414
+ # @param request_pb [::Google::Cloud::Language::V1beta2::ModerateTextRequest]
415
+ # A request object representing the call parameters. Required.
416
+ # @return [Array(String, [String, nil], Hash{String => String})]
417
+ # Uri, Body, Query string parameters
418
+ def self.transcode_moderate_text_request request_pb
419
+ transcoder = Gapic::Rest::GrpcTranscoder.new
420
+ .with_bindings(
421
+ uri_method: :post,
422
+ uri_template: "/v1beta2/documents:moderateText",
423
+ body: "*",
424
+ matches: []
425
+ )
426
+ transcoder.transcode request_pb
427
+ end
428
+
429
+ ##
430
+ # @private
431
+ #
432
+ # GRPC transcoding helper method for the annotate_text REST call
433
+ #
434
+ # @param request_pb [::Google::Cloud::Language::V1beta2::AnnotateTextRequest]
435
+ # A request object representing the call parameters. Required.
436
+ # @return [Array(String, [String, nil], Hash{String => String})]
437
+ # Uri, Body, Query string parameters
438
+ def self.transcode_annotate_text_request request_pb
439
+ transcoder = Gapic::Rest::GrpcTranscoder.new
440
+ .with_bindings(
441
+ uri_method: :post,
442
+ uri_template: "/v1beta2/documents:annotateText",
443
+ body: "*",
444
+ matches: []
445
+ )
446
+ transcoder.transcode request_pb
447
+ end
448
+ end
449
+ end
450
+ end
451
+ end
452
+ end
453
+ end
454
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/rest"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/language/v1beta2/version"
24
+
25
+ require "google/cloud/language/v1beta2/language_service/credentials"
26
+ require "google/cloud/language/v1beta2/language_service/rest/client"
27
+
28
+ module Google
29
+ module Cloud
30
+ module Language
31
+ module V1beta2
32
+ ##
33
+ # Provides text analysis operations such as sentiment analysis and entity
34
+ # recognition.
35
+ #
36
+ # To load this service and instantiate a REST client:
37
+ #
38
+ # require "google/cloud/language/v1beta2/language_service/rest"
39
+ # client = ::Google::Cloud::Language::V1beta2::LanguageService::Rest::Client.new
40
+ #
41
+ module LanguageService
42
+ # Client for the REST transport
43
+ module Rest
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ helper_path = ::File.join __dir__, "rest", "helpers.rb"
52
+ require "google/cloud/language/v1beta2/language_service/rest/helpers" if ::File.file? helper_path
@@ -24,6 +24,7 @@ require "google/cloud/language/v1beta2/version"
24
24
 
25
25
  require "google/cloud/language/v1beta2/language_service/credentials"
26
26
  require "google/cloud/language/v1beta2/language_service/client"
27
+ require "google/cloud/language/v1beta2/language_service/rest"
27
28
 
28
29
  module Google
29
30
  module Cloud
@@ -33,11 +34,16 @@ module Google
33
34
  # Provides text analysis operations such as sentiment analysis and entity
34
35
  # recognition.
35
36
  #
36
- # To load this service and instantiate a client:
37
+ # @example Load this service and instantiate a gRPC client
37
38
  #
38
39
  # require "google/cloud/language/v1beta2/language_service"
39
40
  # client = ::Google::Cloud::Language::V1beta2::LanguageService::Client.new
40
41
  #
42
+ # @example Load this service and instantiate a REST client
43
+ #
44
+ # require "google/cloud/language/v1beta2/language_service/rest"
45
+ # client = ::Google::Cloud::Language::V1beta2::LanguageService::Rest::Client.new
46
+ #
41
47
  module LanguageService
42
48
  end
43
49
  end