google-cloud-recaptcha_enterprise-v1beta1 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d2b9b685918f1ddcc52586febf73554ff9f59c401314e96417466b960ec3e29
4
- data.tar.gz: f416b00e13330e2a7a2fb199b1cdd7f571056718dd6ce92d2a60d3bfc3f87896
3
+ metadata.gz: 0ce69755408fee0fb5f4516631f6333f667a3a779f9080e34894db0fff4476e4
4
+ data.tar.gz: 5fd0f9854353f11614b494d4bf49bf4342df1fbf732853046d882aa51d974a6f
5
5
  SHA512:
6
- metadata.gz: 294aea848ef458333a40d9ee2d10c6a2a99c3abf1aa13ad650b24daac11538cd48195f41683d9dec73d02b1425b37848f9d8905b7770b0241a4e3224be737445
7
- data.tar.gz: c436b82083e84f7fb9e4263afd117bf39cbbefc381dc8c16a3d0075d8e0a7f335d08ea3a0e61b6ba4734cf875024ab99247912578a6b8856fdfbdbd4f75883aa
6
+ metadata.gz: 506344e20c70c353ea04c4ff01e190e41ccea9ad71a2bdab96e81bc090372b560301a602be0b647c58abf8a83d707c1415d2b01666a26b88cf4f1255a0a0bcff
7
+ data.tar.gz: f21df9cac1a1f2fe0a7cd09babceda37214d15245cf5471f01cb977e605b3efd31f2efabd0179273cb6bc805c5ac538b28c53ca56142a0f036b5a04c7f4c6bd1
data/AUTHENTICATION.md CHANGED
@@ -114,7 +114,7 @@ credentials are discovered.
114
114
  To configure your system for this, simply:
115
115
 
116
116
  1. [Download and install the Cloud SDK](https://cloud.google.com/sdk)
117
- 2. Authenticate using OAuth 2.0 `$ gcloud auth login`
117
+ 2. Authenticate using OAuth 2.0 `$ gcloud auth application-default login`
118
118
  3. Write code as if already authenticated.
119
119
 
120
120
  **NOTE:** This is _not_ recommended for running in production. The Cloud SDK
data/README.md CHANGED
@@ -46,7 +46,7 @@ for general usage information.
46
46
  ## Enabling Logging
47
47
 
48
48
  To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
49
- The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as shown below,
49
+ The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below,
50
50
  or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
51
51
  that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
52
52
  and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
@@ -0,0 +1,434 @@
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/errors"
20
+ require "google/cloud/recaptchaenterprise/v1beta1/recaptchaenterprise_pb"
21
+ require "google/cloud/recaptcha_enterprise/v1beta1/recaptcha_enterprise_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module RecaptchaEnterprise
26
+ module V1beta1
27
+ module RecaptchaEnterpriseService
28
+ module Rest
29
+ ##
30
+ # REST client for the RecaptchaEnterpriseService service.
31
+ #
32
+ # Service to determine the likelihood an event is legitimate.
33
+ #
34
+ class Client
35
+ include Paths
36
+
37
+ # @private
38
+ attr_reader :recaptcha_enterprise_service_stub
39
+
40
+ ##
41
+ # Configure the RecaptchaEnterpriseService Client class.
42
+ #
43
+ # See {::Google::Cloud::RecaptchaEnterprise::V1beta1::RecaptchaEnterpriseService::Rest::Client::Configuration}
44
+ # for a description of the configuration fields.
45
+ #
46
+ # @example
47
+ #
48
+ # # Modify the configuration for all RecaptchaEnterpriseService clients
49
+ # ::Google::Cloud::RecaptchaEnterprise::V1beta1::RecaptchaEnterpriseService::Rest::Client.configure do |config|
50
+ # config.timeout = 10.0
51
+ # end
52
+ #
53
+ # @yield [config] Configure the Client client.
54
+ # @yieldparam config [Client::Configuration]
55
+ #
56
+ # @return [Client::Configuration]
57
+ #
58
+ def self.configure
59
+ @configure ||= begin
60
+ namespace = ["Google", "Cloud", "RecaptchaEnterprise", "V1beta1"]
61
+ parent_config = while namespace.any?
62
+ parent_name = namespace.join "::"
63
+ parent_const = const_get parent_name
64
+ break parent_const.configure if parent_const.respond_to? :configure
65
+ namespace.pop
66
+ end
67
+ default_config = Client::Configuration.new parent_config
68
+
69
+ default_config.rpcs.create_assessment.timeout = 600.0
70
+
71
+ default_config.rpcs.annotate_assessment.timeout = 600.0
72
+
73
+ default_config
74
+ end
75
+ yield @configure if block_given?
76
+ @configure
77
+ end
78
+
79
+ ##
80
+ # Configure the RecaptchaEnterpriseService Client instance.
81
+ #
82
+ # The configuration is set to the derived mode, meaning that values can be changed,
83
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
84
+ # should be made on {Client.configure}.
85
+ #
86
+ # See {::Google::Cloud::RecaptchaEnterprise::V1beta1::RecaptchaEnterpriseService::Rest::Client::Configuration}
87
+ # for a description of the configuration fields.
88
+ #
89
+ # @yield [config] Configure the Client client.
90
+ # @yieldparam config [Client::Configuration]
91
+ #
92
+ # @return [Client::Configuration]
93
+ #
94
+ def configure
95
+ yield @config if block_given?
96
+ @config
97
+ end
98
+
99
+ ##
100
+ # Create a new RecaptchaEnterpriseService REST client object.
101
+ #
102
+ # @example
103
+ #
104
+ # # Create a client using the default configuration
105
+ # client = ::Google::Cloud::RecaptchaEnterprise::V1beta1::RecaptchaEnterpriseService::Rest::Client.new
106
+ #
107
+ # # Create a client using a custom configuration
108
+ # client = ::Google::Cloud::RecaptchaEnterprise::V1beta1::RecaptchaEnterpriseService::Rest::Client.new do |config|
109
+ # config.timeout = 10.0
110
+ # end
111
+ #
112
+ # @yield [config] Configure the RecaptchaEnterpriseService client.
113
+ # @yieldparam config [Client::Configuration]
114
+ #
115
+ def initialize
116
+ # Create the configuration object
117
+ @config = Configuration.new Client.configure
118
+
119
+ # Yield the configuration if needed
120
+ yield @config if block_given?
121
+
122
+ # Create credentials
123
+ credentials = @config.credentials
124
+ # Use self-signed JWT if the endpoint is unchanged from default,
125
+ # but only if the default endpoint does not have a region prefix.
126
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
127
+ !@config.endpoint.split(".").first.include?("-")
128
+ credentials ||= Credentials.default scope: @config.scope,
129
+ enable_self_signed_jwt: enable_self_signed_jwt
130
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
131
+ credentials = Credentials.new credentials, scope: @config.scope
132
+ end
133
+
134
+ @quota_project_id = @config.quota_project
135
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
136
+
137
+ @recaptcha_enterprise_service_stub = ::Google::Cloud::RecaptchaEnterprise::V1beta1::RecaptchaEnterpriseService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
138
+ end
139
+
140
+ # Service calls
141
+
142
+ ##
143
+ # Creates an Assessment of the likelihood an event is legitimate.
144
+ #
145
+ # @overload create_assessment(request, options = nil)
146
+ # Pass arguments to `create_assessment` via a request object, either of type
147
+ # {::Google::Cloud::RecaptchaEnterprise::V1beta1::CreateAssessmentRequest} or an equivalent Hash.
148
+ #
149
+ # @param request [::Google::Cloud::RecaptchaEnterprise::V1beta1::CreateAssessmentRequest, ::Hash]
150
+ # A request object representing the call parameters. Required. To specify no
151
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
152
+ # @param options [::Gapic::CallOptions, ::Hash]
153
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
154
+ #
155
+ # @overload create_assessment(parent: nil, assessment: nil)
156
+ # Pass arguments to `create_assessment` via keyword arguments. Note that at
157
+ # least one keyword argument is required. To specify no parameters, or to keep all
158
+ # the default parameter values, pass an empty Hash as a request object (see above).
159
+ #
160
+ # @param parent [::String]
161
+ # Required. The name of the project in which the assessment will be created,
162
+ # in the format "projects/\\{project_number}".
163
+ # @param assessment [::Google::Cloud::RecaptchaEnterprise::V1beta1::Assessment, ::Hash]
164
+ # Required. The assessment details.
165
+ # @yield [result, operation] Access the result along with the TransportOperation object
166
+ # @yieldparam result [::Google::Cloud::RecaptchaEnterprise::V1beta1::Assessment]
167
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
168
+ #
169
+ # @return [::Google::Cloud::RecaptchaEnterprise::V1beta1::Assessment]
170
+ #
171
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
172
+ def create_assessment request, options = nil
173
+ raise ::ArgumentError, "request must be provided" if request.nil?
174
+
175
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::RecaptchaEnterprise::V1beta1::CreateAssessmentRequest
176
+
177
+ # Converts hash and nil to an options object
178
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
179
+
180
+ # Customize the options with defaults
181
+ call_metadata = @config.rpcs.create_assessment.metadata.to_h
182
+
183
+ # Set x-goog-api-client and x-goog-user-project headers
184
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
185
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
186
+ gapic_version: ::Google::Cloud::RecaptchaEnterprise::V1beta1::VERSION,
187
+ transports_version_send: [:rest]
188
+
189
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
190
+
191
+ options.apply_defaults timeout: @config.rpcs.create_assessment.timeout,
192
+ metadata: call_metadata,
193
+ retry_policy: @config.rpcs.create_assessment.retry_policy
194
+
195
+ options.apply_defaults timeout: @config.timeout,
196
+ metadata: @config.metadata,
197
+ retry_policy: @config.retry_policy
198
+
199
+ @recaptcha_enterprise_service_stub.create_assessment request, options do |result, operation|
200
+ yield result, operation if block_given?
201
+ return result
202
+ end
203
+ rescue ::Gapic::Rest::Error => e
204
+ raise ::Google::Cloud::Error.from_error(e)
205
+ end
206
+
207
+ ##
208
+ # Annotates a previously created Assessment to provide additional information
209
+ # on whether the event turned out to be authentic or fradulent.
210
+ #
211
+ # @overload annotate_assessment(request, options = nil)
212
+ # Pass arguments to `annotate_assessment` via a request object, either of type
213
+ # {::Google::Cloud::RecaptchaEnterprise::V1beta1::AnnotateAssessmentRequest} or an equivalent Hash.
214
+ #
215
+ # @param request [::Google::Cloud::RecaptchaEnterprise::V1beta1::AnnotateAssessmentRequest, ::Hash]
216
+ # A request object representing the call parameters. Required. To specify no
217
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
218
+ # @param options [::Gapic::CallOptions, ::Hash]
219
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
220
+ #
221
+ # @overload annotate_assessment(name: nil, annotation: nil, reasons: nil, hashed_account_id: nil)
222
+ # Pass arguments to `annotate_assessment` via keyword arguments. Note that at
223
+ # least one keyword argument is required. To specify no parameters, or to keep all
224
+ # the default parameter values, pass an empty Hash as a request object (see above).
225
+ #
226
+ # @param name [::String]
227
+ # Required. The resource name of the Assessment, in the format
228
+ # "projects/\\{project_number}/assessments/\\{assessment_id}".
229
+ # @param annotation [::Google::Cloud::RecaptchaEnterprise::V1beta1::AnnotateAssessmentRequest::Annotation]
230
+ # Optional. The annotation that will be assigned to the Event. This field can be left
231
+ # empty to provide reasons that apply to an event without concluding whether
232
+ # the event is legitimate or fraudulent.
233
+ # @param reasons [::Array<::Google::Cloud::RecaptchaEnterprise::V1beta1::AnnotateAssessmentRequest::Reason>]
234
+ # Optional. Optional reasons for the annotation that will be assigned to the Event.
235
+ # @param hashed_account_id [::String]
236
+ # Optional. Optional unique stable hashed user identifier to apply to the assessment.
237
+ # This is an alternative to setting the hashed_account_id in
238
+ # CreateAssessment, for example when the account identifier is not yet known
239
+ # in the initial request. It is recommended that the identifier is hashed
240
+ # using hmac-sha256 with stable secret.
241
+ # @yield [result, operation] Access the result along with the TransportOperation object
242
+ # @yieldparam result [::Google::Cloud::RecaptchaEnterprise::V1beta1::AnnotateAssessmentResponse]
243
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
244
+ #
245
+ # @return [::Google::Cloud::RecaptchaEnterprise::V1beta1::AnnotateAssessmentResponse]
246
+ #
247
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
248
+ def annotate_assessment request, options = nil
249
+ raise ::ArgumentError, "request must be provided" if request.nil?
250
+
251
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::RecaptchaEnterprise::V1beta1::AnnotateAssessmentRequest
252
+
253
+ # Converts hash and nil to an options object
254
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
255
+
256
+ # Customize the options with defaults
257
+ call_metadata = @config.rpcs.annotate_assessment.metadata.to_h
258
+
259
+ # Set x-goog-api-client and x-goog-user-project headers
260
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
261
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
262
+ gapic_version: ::Google::Cloud::RecaptchaEnterprise::V1beta1::VERSION,
263
+ transports_version_send: [:rest]
264
+
265
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
266
+
267
+ options.apply_defaults timeout: @config.rpcs.annotate_assessment.timeout,
268
+ metadata: call_metadata,
269
+ retry_policy: @config.rpcs.annotate_assessment.retry_policy
270
+
271
+ options.apply_defaults timeout: @config.timeout,
272
+ metadata: @config.metadata,
273
+ retry_policy: @config.retry_policy
274
+
275
+ @recaptcha_enterprise_service_stub.annotate_assessment request, options do |result, operation|
276
+ yield result, operation if block_given?
277
+ return result
278
+ end
279
+ rescue ::Gapic::Rest::Error => e
280
+ raise ::Google::Cloud::Error.from_error(e)
281
+ end
282
+
283
+ ##
284
+ # Configuration class for the RecaptchaEnterpriseService REST API.
285
+ #
286
+ # This class represents the configuration for RecaptchaEnterpriseService REST,
287
+ # providing control over timeouts, retry behavior, logging, transport
288
+ # parameters, and other low-level controls. Certain parameters can also be
289
+ # applied individually to specific RPCs. See
290
+ # {::Google::Cloud::RecaptchaEnterprise::V1beta1::RecaptchaEnterpriseService::Rest::Client::Configuration::Rpcs}
291
+ # for a list of RPCs that can be configured independently.
292
+ #
293
+ # Configuration can be applied globally to all clients, or to a single client
294
+ # on construction.
295
+ #
296
+ # @example
297
+ #
298
+ # # Modify the global config, setting the timeout for
299
+ # # create_assessment to 20 seconds,
300
+ # # and all remaining timeouts to 10 seconds.
301
+ # ::Google::Cloud::RecaptchaEnterprise::V1beta1::RecaptchaEnterpriseService::Rest::Client.configure do |config|
302
+ # config.timeout = 10.0
303
+ # config.rpcs.create_assessment.timeout = 20.0
304
+ # end
305
+ #
306
+ # # Apply the above configuration only to a new client.
307
+ # client = ::Google::Cloud::RecaptchaEnterprise::V1beta1::RecaptchaEnterpriseService::Rest::Client.new do |config|
308
+ # config.timeout = 10.0
309
+ # config.rpcs.create_assessment.timeout = 20.0
310
+ # end
311
+ #
312
+ # @!attribute [rw] endpoint
313
+ # The hostname or hostname:port of the service endpoint.
314
+ # Defaults to `"recaptchaenterprise.googleapis.com"`.
315
+ # @return [::String]
316
+ # @!attribute [rw] credentials
317
+ # Credentials to send with calls. You may provide any of the following types:
318
+ # * (`String`) The path to a service account key file in JSON format
319
+ # * (`Hash`) A service account key as a Hash
320
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
321
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
322
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
323
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
324
+ # * (`nil`) indicating no credentials
325
+ # @return [::Object]
326
+ # @!attribute [rw] scope
327
+ # The OAuth scopes
328
+ # @return [::Array<::String>]
329
+ # @!attribute [rw] lib_name
330
+ # The library name as recorded in instrumentation and logging
331
+ # @return [::String]
332
+ # @!attribute [rw] lib_version
333
+ # The library version as recorded in instrumentation and logging
334
+ # @return [::String]
335
+ # @!attribute [rw] timeout
336
+ # The call timeout in seconds.
337
+ # @return [::Numeric]
338
+ # @!attribute [rw] metadata
339
+ # Additional headers to be sent with the call.
340
+ # @return [::Hash{::Symbol=>::String}]
341
+ # @!attribute [rw] retry_policy
342
+ # The retry policy. The value is a hash with the following keys:
343
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
344
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
345
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
346
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
347
+ # trigger a retry.
348
+ # @return [::Hash]
349
+ # @!attribute [rw] quota_project
350
+ # A separate project against which to charge quota.
351
+ # @return [::String]
352
+ #
353
+ class Configuration
354
+ extend ::Gapic::Config
355
+
356
+ config_attr :endpoint, "recaptchaenterprise.googleapis.com", ::String
357
+ config_attr :credentials, nil do |value|
358
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
359
+ allowed.any? { |klass| klass === value }
360
+ end
361
+ config_attr :scope, nil, ::String, ::Array, nil
362
+ config_attr :lib_name, nil, ::String, nil
363
+ config_attr :lib_version, nil, ::String, nil
364
+ config_attr :timeout, nil, ::Numeric, nil
365
+ config_attr :metadata, nil, ::Hash, nil
366
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
367
+ config_attr :quota_project, nil, ::String, nil
368
+
369
+ # @private
370
+ def initialize parent_config = nil
371
+ @parent_config = parent_config unless parent_config.nil?
372
+
373
+ yield self if block_given?
374
+ end
375
+
376
+ ##
377
+ # Configurations for individual RPCs
378
+ # @return [Rpcs]
379
+ #
380
+ def rpcs
381
+ @rpcs ||= begin
382
+ parent_rpcs = nil
383
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
384
+ Rpcs.new parent_rpcs
385
+ end
386
+ end
387
+
388
+ ##
389
+ # Configuration RPC class for the RecaptchaEnterpriseService API.
390
+ #
391
+ # Includes fields providing the configuration for each RPC in this service.
392
+ # Each configuration object is of type `Gapic::Config::Method` and includes
393
+ # the following configuration fields:
394
+ #
395
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
396
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
397
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
398
+ # include the following keys:
399
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
400
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
401
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
402
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
403
+ # trigger a retry.
404
+ #
405
+ class Rpcs
406
+ ##
407
+ # RPC-specific configuration for `create_assessment`
408
+ # @return [::Gapic::Config::Method]
409
+ #
410
+ attr_reader :create_assessment
411
+ ##
412
+ # RPC-specific configuration for `annotate_assessment`
413
+ # @return [::Gapic::Config::Method]
414
+ #
415
+ attr_reader :annotate_assessment
416
+
417
+ # @private
418
+ def initialize parent_rpcs = nil
419
+ create_assessment_config = parent_rpcs.create_assessment if parent_rpcs.respond_to? :create_assessment
420
+ @create_assessment = ::Gapic::Config::Method.new create_assessment_config
421
+ annotate_assessment_config = parent_rpcs.annotate_assessment if parent_rpcs.respond_to? :annotate_assessment
422
+ @annotate_assessment = ::Gapic::Config::Method.new annotate_assessment_config
423
+
424
+ yield self if block_given?
425
+ end
426
+ end
427
+ end
428
+ end
429
+ end
430
+ end
431
+ end
432
+ end
433
+ end
434
+ end
@@ -0,0 +1,168 @@
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/recaptchaenterprise/v1beta1/recaptchaenterprise_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module RecaptchaEnterprise
24
+ module V1beta1
25
+ module RecaptchaEnterpriseService
26
+ module Rest
27
+ ##
28
+ # REST service stub for the RecaptchaEnterpriseService 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 create_assessment REST call
45
+ #
46
+ # @param request_pb [::Google::Cloud::RecaptchaEnterprise::V1beta1::CreateAssessmentRequest]
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::RecaptchaEnterprise::V1beta1::Assessment]
53
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
54
+ #
55
+ # @return [::Google::Cloud::RecaptchaEnterprise::V1beta1::Assessment]
56
+ # A result object deserialized from the server's reply
57
+ def create_assessment 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_create_assessment_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::RecaptchaEnterprise::V1beta1::Assessment.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 annotate_assessment REST call
83
+ #
84
+ # @param request_pb [::Google::Cloud::RecaptchaEnterprise::V1beta1::AnnotateAssessmentRequest]
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::RecaptchaEnterprise::V1beta1::AnnotateAssessmentResponse]
91
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
92
+ #
93
+ # @return [::Google::Cloud::RecaptchaEnterprise::V1beta1::AnnotateAssessmentResponse]
94
+ # A result object deserialized from the server's reply
95
+ def annotate_assessment 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_annotate_assessment_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::RecaptchaEnterprise::V1beta1::AnnotateAssessmentResponse.decode_json response.body, ignore_unknown_fields: true
114
+
115
+ yield result, operation if block_given?
116
+ result
117
+ end
118
+
119
+ ##
120
+ # @private
121
+ #
122
+ # GRPC transcoding helper method for the create_assessment REST call
123
+ #
124
+ # @param request_pb [::Google::Cloud::RecaptchaEnterprise::V1beta1::CreateAssessmentRequest]
125
+ # A request object representing the call parameters. Required.
126
+ # @return [Array(String, [String, nil], Hash{String => String})]
127
+ # Uri, Body, Query string parameters
128
+ def self.transcode_create_assessment_request request_pb
129
+ transcoder = Gapic::Rest::GrpcTranscoder.new
130
+ .with_bindings(
131
+ uri_method: :post,
132
+ uri_template: "/v1beta1/{parent}/assessments",
133
+ body: "assessment",
134
+ matches: [
135
+ ["parent", %r{^projects/[^/]+/?$}, false]
136
+ ]
137
+ )
138
+ transcoder.transcode request_pb
139
+ end
140
+
141
+ ##
142
+ # @private
143
+ #
144
+ # GRPC transcoding helper method for the annotate_assessment REST call
145
+ #
146
+ # @param request_pb [::Google::Cloud::RecaptchaEnterprise::V1beta1::AnnotateAssessmentRequest]
147
+ # A request object representing the call parameters. Required.
148
+ # @return [Array(String, [String, nil], Hash{String => String})]
149
+ # Uri, Body, Query string parameters
150
+ def self.transcode_annotate_assessment_request request_pb
151
+ transcoder = Gapic::Rest::GrpcTranscoder.new
152
+ .with_bindings(
153
+ uri_method: :post,
154
+ uri_template: "/v1beta1/{name}:annotate",
155
+ body: "*",
156
+ matches: [
157
+ ["name", %r{^projects/[^/]+/assessments/[^/]+/?$}, false]
158
+ ]
159
+ )
160
+ transcoder.transcode request_pb
161
+ end
162
+ end
163
+ end
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end