google-cloud-web_risk-v1 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,709 @@
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/webrisk/v1/webrisk_pb"
21
+ require "google/cloud/web_risk/v1/web_risk_service/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module WebRisk
26
+ module V1
27
+ module WebRiskService
28
+ module Rest
29
+ ##
30
+ # REST client for the WebRiskService service.
31
+ #
32
+ # Web Risk API defines an interface to detect malicious URLs on your
33
+ # website and in client applications.
34
+ #
35
+ class Client
36
+ include Paths
37
+
38
+ # @private
39
+ attr_reader :web_risk_service_stub
40
+
41
+ ##
42
+ # Configure the WebRiskService Client class.
43
+ #
44
+ # See {::Google::Cloud::WebRisk::V1::WebRiskService::Rest::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # @example
48
+ #
49
+ # # Modify the configuration for all WebRiskService clients
50
+ # ::Google::Cloud::WebRisk::V1::WebRiskService::Rest::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "WebRisk", "V1"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config.rpcs.compute_threat_list_diff.timeout = 600.0
71
+ default_config.rpcs.compute_threat_list_diff.retry_policy = {
72
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
73
+ }
74
+
75
+ default_config.rpcs.search_uris.timeout = 600.0
76
+ default_config.rpcs.search_uris.retry_policy = {
77
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
78
+ }
79
+
80
+ default_config.rpcs.search_hashes.timeout = 600.0
81
+ default_config.rpcs.search_hashes.retry_policy = {
82
+ initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [4, 14]
83
+ }
84
+
85
+ default_config.rpcs.create_submission.timeout = 600.0
86
+
87
+ default_config
88
+ end
89
+ yield @configure if block_given?
90
+ @configure
91
+ end
92
+
93
+ ##
94
+ # Configure the WebRiskService Client instance.
95
+ #
96
+ # The configuration is set to the derived mode, meaning that values can be changed,
97
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
98
+ # should be made on {Client.configure}.
99
+ #
100
+ # See {::Google::Cloud::WebRisk::V1::WebRiskService::Rest::Client::Configuration}
101
+ # for a description of the configuration fields.
102
+ #
103
+ # @yield [config] Configure the Client client.
104
+ # @yieldparam config [Client::Configuration]
105
+ #
106
+ # @return [Client::Configuration]
107
+ #
108
+ def configure
109
+ yield @config if block_given?
110
+ @config
111
+ end
112
+
113
+ ##
114
+ # Create a new WebRiskService REST client object.
115
+ #
116
+ # @example
117
+ #
118
+ # # Create a client using the default configuration
119
+ # client = ::Google::Cloud::WebRisk::V1::WebRiskService::Rest::Client.new
120
+ #
121
+ # # Create a client using a custom configuration
122
+ # client = ::Google::Cloud::WebRisk::V1::WebRiskService::Rest::Client.new do |config|
123
+ # config.timeout = 10.0
124
+ # end
125
+ #
126
+ # @yield [config] Configure the WebRiskService client.
127
+ # @yieldparam config [Client::Configuration]
128
+ #
129
+ def initialize
130
+ # Create the configuration object
131
+ @config = Configuration.new Client.configure
132
+
133
+ # Yield the configuration if needed
134
+ yield @config if block_given?
135
+
136
+ # Create credentials
137
+ credentials = @config.credentials
138
+ # Use self-signed JWT if the endpoint is unchanged from default,
139
+ # but only if the default endpoint does not have a region prefix.
140
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
141
+ !@config.endpoint.split(".").first.include?("-")
142
+ credentials ||= Credentials.default scope: @config.scope,
143
+ enable_self_signed_jwt: enable_self_signed_jwt
144
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
145
+ credentials = Credentials.new credentials, scope: @config.scope
146
+ end
147
+
148
+ @quota_project_id = @config.quota_project
149
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
150
+
151
+ @operations_client = ::Google::Cloud::WebRisk::V1::WebRiskService::Rest::Operations.new do |config|
152
+ config.credentials = credentials
153
+ config.quota_project = @quota_project_id
154
+ config.endpoint = @config.endpoint
155
+ end
156
+
157
+ @web_risk_service_stub = ::Google::Cloud::WebRisk::V1::WebRiskService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
158
+ end
159
+
160
+ ##
161
+ # Get the associated client for long-running operations.
162
+ #
163
+ # @return [::Google::Cloud::WebRisk::V1::WebRiskService::Rest::Operations]
164
+ #
165
+ attr_reader :operations_client
166
+
167
+ # Service calls
168
+
169
+ ##
170
+ # Gets the most recent threat list diffs. These diffs should be applied to
171
+ # a local database of hashes to keep it up-to-date. If the local database is
172
+ # empty or excessively out-of-date, a complete snapshot of the database will
173
+ # be returned. This Method only updates a single ThreatList at a time. To
174
+ # update multiple ThreatList databases, this method needs to be called once
175
+ # for each list.
176
+ #
177
+ # @overload compute_threat_list_diff(request, options = nil)
178
+ # Pass arguments to `compute_threat_list_diff` via a request object, either of type
179
+ # {::Google::Cloud::WebRisk::V1::ComputeThreatListDiffRequest} or an equivalent Hash.
180
+ #
181
+ # @param request [::Google::Cloud::WebRisk::V1::ComputeThreatListDiffRequest, ::Hash]
182
+ # A request object representing the call parameters. Required. To specify no
183
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
184
+ # @param options [::Gapic::CallOptions, ::Hash]
185
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
186
+ #
187
+ # @overload compute_threat_list_diff(threat_type: nil, version_token: nil, constraints: nil)
188
+ # Pass arguments to `compute_threat_list_diff` via keyword arguments. Note that at
189
+ # least one keyword argument is required. To specify no parameters, or to keep all
190
+ # the default parameter values, pass an empty Hash as a request object (see above).
191
+ #
192
+ # @param threat_type [::Google::Cloud::WebRisk::V1::ThreatType]
193
+ # Required. The threat list to update. Only a single ThreatType should be
194
+ # specified per request. If you want to handle multiple ThreatTypes, you must
195
+ # make one request per ThreatType.
196
+ # @param version_token [::String]
197
+ # The current version token of the client for the requested list (the
198
+ # client version that was received from the last successful diff).
199
+ # If the client does not have a version token (this is the first time calling
200
+ # ComputeThreatListDiff), this may be left empty and a full database
201
+ # snapshot will be returned.
202
+ # @param constraints [::Google::Cloud::WebRisk::V1::ComputeThreatListDiffRequest::Constraints, ::Hash]
203
+ # Required. The constraints associated with this request.
204
+ # @yield [result, operation] Access the result along with the TransportOperation object
205
+ # @yieldparam result [::Google::Cloud::WebRisk::V1::ComputeThreatListDiffResponse]
206
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
207
+ #
208
+ # @return [::Google::Cloud::WebRisk::V1::ComputeThreatListDiffResponse]
209
+ #
210
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
211
+ def compute_threat_list_diff request, options = nil
212
+ raise ::ArgumentError, "request must be provided" if request.nil?
213
+
214
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::WebRisk::V1::ComputeThreatListDiffRequest
215
+
216
+ # Converts hash and nil to an options object
217
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
218
+
219
+ # Customize the options with defaults
220
+ call_metadata = @config.rpcs.compute_threat_list_diff.metadata.to_h
221
+
222
+ # Set x-goog-api-client and x-goog-user-project headers
223
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
224
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
225
+ gapic_version: ::Google::Cloud::WebRisk::V1::VERSION,
226
+ transports_version_send: [:rest]
227
+
228
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
229
+
230
+ options.apply_defaults timeout: @config.rpcs.compute_threat_list_diff.timeout,
231
+ metadata: call_metadata,
232
+ retry_policy: @config.rpcs.compute_threat_list_diff.retry_policy
233
+
234
+ options.apply_defaults timeout: @config.timeout,
235
+ metadata: @config.metadata,
236
+ retry_policy: @config.retry_policy
237
+
238
+ @web_risk_service_stub.compute_threat_list_diff request, options do |result, operation|
239
+ yield result, operation if block_given?
240
+ return result
241
+ end
242
+ rescue ::Gapic::Rest::Error => e
243
+ raise ::Google::Cloud::Error.from_error(e)
244
+ end
245
+
246
+ ##
247
+ # This method is used to check whether a URI is on a given threatList.
248
+ # Multiple threatLists may be searched in a single query.
249
+ # The response will list all requested threatLists the URI was found to
250
+ # match. If the URI is not found on any of the requested ThreatList an
251
+ # empty response will be returned.
252
+ #
253
+ # @overload search_uris(request, options = nil)
254
+ # Pass arguments to `search_uris` via a request object, either of type
255
+ # {::Google::Cloud::WebRisk::V1::SearchUrisRequest} or an equivalent Hash.
256
+ #
257
+ # @param request [::Google::Cloud::WebRisk::V1::SearchUrisRequest, ::Hash]
258
+ # A request object representing the call parameters. Required. To specify no
259
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
260
+ # @param options [::Gapic::CallOptions, ::Hash]
261
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
262
+ #
263
+ # @overload search_uris(uri: nil, threat_types: nil)
264
+ # Pass arguments to `search_uris` via keyword arguments. Note that at
265
+ # least one keyword argument is required. To specify no parameters, or to keep all
266
+ # the default parameter values, pass an empty Hash as a request object (see above).
267
+ #
268
+ # @param uri [::String]
269
+ # Required. The URI to be checked for matches.
270
+ # @param threat_types [::Array<::Google::Cloud::WebRisk::V1::ThreatType>]
271
+ # Required. The ThreatLists to search in. Multiple ThreatLists may be
272
+ # specified.
273
+ # @yield [result, operation] Access the result along with the TransportOperation object
274
+ # @yieldparam result [::Google::Cloud::WebRisk::V1::SearchUrisResponse]
275
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
276
+ #
277
+ # @return [::Google::Cloud::WebRisk::V1::SearchUrisResponse]
278
+ #
279
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
280
+ def search_uris request, options = nil
281
+ raise ::ArgumentError, "request must be provided" if request.nil?
282
+
283
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::WebRisk::V1::SearchUrisRequest
284
+
285
+ # Converts hash and nil to an options object
286
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
287
+
288
+ # Customize the options with defaults
289
+ call_metadata = @config.rpcs.search_uris.metadata.to_h
290
+
291
+ # Set x-goog-api-client and x-goog-user-project headers
292
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
293
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
294
+ gapic_version: ::Google::Cloud::WebRisk::V1::VERSION,
295
+ transports_version_send: [:rest]
296
+
297
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
298
+
299
+ options.apply_defaults timeout: @config.rpcs.search_uris.timeout,
300
+ metadata: call_metadata,
301
+ retry_policy: @config.rpcs.search_uris.retry_policy
302
+
303
+ options.apply_defaults timeout: @config.timeout,
304
+ metadata: @config.metadata,
305
+ retry_policy: @config.retry_policy
306
+
307
+ @web_risk_service_stub.search_uris request, options do |result, operation|
308
+ yield result, operation if block_given?
309
+ return result
310
+ end
311
+ rescue ::Gapic::Rest::Error => e
312
+ raise ::Google::Cloud::Error.from_error(e)
313
+ end
314
+
315
+ ##
316
+ # Gets the full hashes that match the requested hash prefix.
317
+ # This is used after a hash prefix is looked up in a threatList
318
+ # and there is a match. The client side threatList only holds partial hashes
319
+ # so the client must query this method to determine if there is a full
320
+ # hash match of a threat.
321
+ #
322
+ # @overload search_hashes(request, options = nil)
323
+ # Pass arguments to `search_hashes` via a request object, either of type
324
+ # {::Google::Cloud::WebRisk::V1::SearchHashesRequest} or an equivalent Hash.
325
+ #
326
+ # @param request [::Google::Cloud::WebRisk::V1::SearchHashesRequest, ::Hash]
327
+ # A request object representing the call parameters. Required. To specify no
328
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
329
+ # @param options [::Gapic::CallOptions, ::Hash]
330
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
331
+ #
332
+ # @overload search_hashes(hash_prefix: nil, threat_types: nil)
333
+ # Pass arguments to `search_hashes` via keyword arguments. Note that at
334
+ # least one keyword argument is required. To specify no parameters, or to keep all
335
+ # the default parameter values, pass an empty Hash as a request object (see above).
336
+ #
337
+ # @param hash_prefix [::String]
338
+ # A hash prefix, consisting of the most significant 4-32 bytes of a SHA256
339
+ # hash. For JSON requests, this field is base64-encoded.
340
+ # Note that if this parameter is provided by a URI, it must be encoded using
341
+ # the web safe base64 variant (RFC 4648).
342
+ # @param threat_types [::Array<::Google::Cloud::WebRisk::V1::ThreatType>]
343
+ # Required. The ThreatLists to search in. Multiple ThreatLists may be
344
+ # specified.
345
+ # @yield [result, operation] Access the result along with the TransportOperation object
346
+ # @yieldparam result [::Google::Cloud::WebRisk::V1::SearchHashesResponse]
347
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
348
+ #
349
+ # @return [::Google::Cloud::WebRisk::V1::SearchHashesResponse]
350
+ #
351
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
352
+ def search_hashes request, options = nil
353
+ raise ::ArgumentError, "request must be provided" if request.nil?
354
+
355
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::WebRisk::V1::SearchHashesRequest
356
+
357
+ # Converts hash and nil to an options object
358
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
359
+
360
+ # Customize the options with defaults
361
+ call_metadata = @config.rpcs.search_hashes.metadata.to_h
362
+
363
+ # Set x-goog-api-client and x-goog-user-project headers
364
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
365
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
366
+ gapic_version: ::Google::Cloud::WebRisk::V1::VERSION,
367
+ transports_version_send: [:rest]
368
+
369
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
370
+
371
+ options.apply_defaults timeout: @config.rpcs.search_hashes.timeout,
372
+ metadata: call_metadata,
373
+ retry_policy: @config.rpcs.search_hashes.retry_policy
374
+
375
+ options.apply_defaults timeout: @config.timeout,
376
+ metadata: @config.metadata,
377
+ retry_policy: @config.retry_policy
378
+
379
+ @web_risk_service_stub.search_hashes request, options do |result, operation|
380
+ yield result, operation if block_given?
381
+ return result
382
+ end
383
+ rescue ::Gapic::Rest::Error => e
384
+ raise ::Google::Cloud::Error.from_error(e)
385
+ end
386
+
387
+ ##
388
+ # Creates a Submission of a URI suspected of containing phishing content to
389
+ # be reviewed. If the result verifies the existence of malicious phishing
390
+ # content, the site will be added to the [Google's Social Engineering
391
+ # lists](https://support.google.com/webmasters/answer/6350487/) in order to
392
+ # protect users that could get exposed to this threat in the future. Only
393
+ # allowlisted projects can use this method during Early Access. Please reach
394
+ # out to Sales or your customer engineer to obtain access.
395
+ #
396
+ # @overload create_submission(request, options = nil)
397
+ # Pass arguments to `create_submission` via a request object, either of type
398
+ # {::Google::Cloud::WebRisk::V1::CreateSubmissionRequest} or an equivalent Hash.
399
+ #
400
+ # @param request [::Google::Cloud::WebRisk::V1::CreateSubmissionRequest, ::Hash]
401
+ # A request object representing the call parameters. Required. To specify no
402
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
403
+ # @param options [::Gapic::CallOptions, ::Hash]
404
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
405
+ #
406
+ # @overload create_submission(parent: nil, submission: nil)
407
+ # Pass arguments to `create_submission` via keyword arguments. Note that at
408
+ # least one keyword argument is required. To specify no parameters, or to keep all
409
+ # the default parameter values, pass an empty Hash as a request object (see above).
410
+ #
411
+ # @param parent [::String]
412
+ # Required. The name of the project that is making the submission. This
413
+ # string is in the format "projects/\\{project_number}".
414
+ # @param submission [::Google::Cloud::WebRisk::V1::Submission, ::Hash]
415
+ # Required. The submission that contains the content of the phishing report.
416
+ # @yield [result, operation] Access the result along with the TransportOperation object
417
+ # @yieldparam result [::Google::Cloud::WebRisk::V1::Submission]
418
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
419
+ #
420
+ # @return [::Google::Cloud::WebRisk::V1::Submission]
421
+ #
422
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
423
+ def create_submission request, options = nil
424
+ raise ::ArgumentError, "request must be provided" if request.nil?
425
+
426
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::WebRisk::V1::CreateSubmissionRequest
427
+
428
+ # Converts hash and nil to an options object
429
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
430
+
431
+ # Customize the options with defaults
432
+ call_metadata = @config.rpcs.create_submission.metadata.to_h
433
+
434
+ # Set x-goog-api-client and x-goog-user-project headers
435
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
436
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
437
+ gapic_version: ::Google::Cloud::WebRisk::V1::VERSION,
438
+ transports_version_send: [:rest]
439
+
440
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
441
+
442
+ options.apply_defaults timeout: @config.rpcs.create_submission.timeout,
443
+ metadata: call_metadata,
444
+ retry_policy: @config.rpcs.create_submission.retry_policy
445
+
446
+ options.apply_defaults timeout: @config.timeout,
447
+ metadata: @config.metadata,
448
+ retry_policy: @config.retry_policy
449
+
450
+ @web_risk_service_stub.create_submission request, options do |result, operation|
451
+ yield result, operation if block_given?
452
+ return result
453
+ end
454
+ rescue ::Gapic::Rest::Error => e
455
+ raise ::Google::Cloud::Error.from_error(e)
456
+ end
457
+
458
+ ##
459
+ # Submits a URI suspected of containing malicious content to be reviewed.
460
+ # Returns a google.longrunning.Operation which, once the review is complete,
461
+ # is updated with its result. You can use the [Pub/Sub API]
462
+ # (https://cloud.google.com/pubsub) to receive notifications for the returned
463
+ # Operation. If the result verifies the existence of malicious content, the
464
+ # site will be added to the [Google's Social Engineering lists]
465
+ # (https://support.google.com/webmasters/answer/6350487/) in order to
466
+ # protect users that could get exposed to this threat in the future. Only
467
+ # allowlisted projects can use this method during Early Access. Please reach
468
+ # out to Sales or your customer engineer to obtain access.
469
+ #
470
+ # @overload submit_uri(request, options = nil)
471
+ # Pass arguments to `submit_uri` via a request object, either of type
472
+ # {::Google::Cloud::WebRisk::V1::SubmitUriRequest} or an equivalent Hash.
473
+ #
474
+ # @param request [::Google::Cloud::WebRisk::V1::SubmitUriRequest, ::Hash]
475
+ # A request object representing the call parameters. Required. To specify no
476
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
477
+ # @param options [::Gapic::CallOptions, ::Hash]
478
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
479
+ #
480
+ # @overload submit_uri(parent: nil, submission: nil, threat_info: nil, threat_discovery: nil)
481
+ # Pass arguments to `submit_uri` via keyword arguments. Note that at
482
+ # least one keyword argument is required. To specify no parameters, or to keep all
483
+ # the default parameter values, pass an empty Hash as a request object (see above).
484
+ #
485
+ # @param parent [::String]
486
+ # Required. The name of the project that is making the submission. This
487
+ # string is in the format "projects/\\{project_number}".
488
+ # @param submission [::Google::Cloud::WebRisk::V1::Submission, ::Hash]
489
+ # Required. The submission that contains the URI to be scanned.
490
+ # @param threat_info [::Google::Cloud::WebRisk::V1::ThreatInfo, ::Hash]
491
+ # Provides additional information about the submission.
492
+ # @param threat_discovery [::Google::Cloud::WebRisk::V1::ThreatDiscovery, ::Hash]
493
+ # Provides additional information about how the submission was discovered.
494
+ # @yield [result, operation] Access the result along with the TransportOperation object
495
+ # @yieldparam result [::Gapic::Operation]
496
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
497
+ #
498
+ # @return [::Gapic::Operation]
499
+ #
500
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
501
+ def submit_uri request, options = nil
502
+ raise ::ArgumentError, "request must be provided" if request.nil?
503
+
504
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::WebRisk::V1::SubmitUriRequest
505
+
506
+ # Converts hash and nil to an options object
507
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
508
+
509
+ # Customize the options with defaults
510
+ call_metadata = @config.rpcs.submit_uri.metadata.to_h
511
+
512
+ # Set x-goog-api-client and x-goog-user-project headers
513
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
514
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
515
+ gapic_version: ::Google::Cloud::WebRisk::V1::VERSION,
516
+ transports_version_send: [:rest]
517
+
518
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
519
+
520
+ options.apply_defaults timeout: @config.rpcs.submit_uri.timeout,
521
+ metadata: call_metadata,
522
+ retry_policy: @config.rpcs.submit_uri.retry_policy
523
+
524
+ options.apply_defaults timeout: @config.timeout,
525
+ metadata: @config.metadata,
526
+ retry_policy: @config.retry_policy
527
+
528
+ @web_risk_service_stub.submit_uri request, options do |result, operation|
529
+ result = ::Gapic::Operation.new result, @operations_client, options: options
530
+ yield result, operation if block_given?
531
+ return result
532
+ end
533
+ rescue ::Gapic::Rest::Error => e
534
+ raise ::Google::Cloud::Error.from_error(e)
535
+ end
536
+
537
+ ##
538
+ # Configuration class for the WebRiskService REST API.
539
+ #
540
+ # This class represents the configuration for WebRiskService REST,
541
+ # providing control over timeouts, retry behavior, logging, transport
542
+ # parameters, and other low-level controls. Certain parameters can also be
543
+ # applied individually to specific RPCs. See
544
+ # {::Google::Cloud::WebRisk::V1::WebRiskService::Rest::Client::Configuration::Rpcs}
545
+ # for a list of RPCs that can be configured independently.
546
+ #
547
+ # Configuration can be applied globally to all clients, or to a single client
548
+ # on construction.
549
+ #
550
+ # @example
551
+ #
552
+ # # Modify the global config, setting the timeout for
553
+ # # compute_threat_list_diff to 20 seconds,
554
+ # # and all remaining timeouts to 10 seconds.
555
+ # ::Google::Cloud::WebRisk::V1::WebRiskService::Rest::Client.configure do |config|
556
+ # config.timeout = 10.0
557
+ # config.rpcs.compute_threat_list_diff.timeout = 20.0
558
+ # end
559
+ #
560
+ # # Apply the above configuration only to a new client.
561
+ # client = ::Google::Cloud::WebRisk::V1::WebRiskService::Rest::Client.new do |config|
562
+ # config.timeout = 10.0
563
+ # config.rpcs.compute_threat_list_diff.timeout = 20.0
564
+ # end
565
+ #
566
+ # @!attribute [rw] endpoint
567
+ # The hostname or hostname:port of the service endpoint.
568
+ # Defaults to `"webrisk.googleapis.com"`.
569
+ # @return [::String]
570
+ # @!attribute [rw] credentials
571
+ # Credentials to send with calls. You may provide any of the following types:
572
+ # * (`String`) The path to a service account key file in JSON format
573
+ # * (`Hash`) A service account key as a Hash
574
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
575
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
576
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
577
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
578
+ # * (`nil`) indicating no credentials
579
+ # @return [::Object]
580
+ # @!attribute [rw] scope
581
+ # The OAuth scopes
582
+ # @return [::Array<::String>]
583
+ # @!attribute [rw] lib_name
584
+ # The library name as recorded in instrumentation and logging
585
+ # @return [::String]
586
+ # @!attribute [rw] lib_version
587
+ # The library version as recorded in instrumentation and logging
588
+ # @return [::String]
589
+ # @!attribute [rw] timeout
590
+ # The call timeout in seconds.
591
+ # @return [::Numeric]
592
+ # @!attribute [rw] metadata
593
+ # Additional headers to be sent with the call.
594
+ # @return [::Hash{::Symbol=>::String}]
595
+ # @!attribute [rw] retry_policy
596
+ # The retry policy. The value is a hash with the following keys:
597
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
598
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
599
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
600
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
601
+ # trigger a retry.
602
+ # @return [::Hash]
603
+ # @!attribute [rw] quota_project
604
+ # A separate project against which to charge quota.
605
+ # @return [::String]
606
+ #
607
+ class Configuration
608
+ extend ::Gapic::Config
609
+
610
+ config_attr :endpoint, "webrisk.googleapis.com", ::String
611
+ config_attr :credentials, nil do |value|
612
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
613
+ allowed.any? { |klass| klass === value }
614
+ end
615
+ config_attr :scope, nil, ::String, ::Array, nil
616
+ config_attr :lib_name, nil, ::String, nil
617
+ config_attr :lib_version, nil, ::String, nil
618
+ config_attr :timeout, nil, ::Numeric, nil
619
+ config_attr :metadata, nil, ::Hash, nil
620
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
621
+ config_attr :quota_project, nil, ::String, nil
622
+
623
+ # @private
624
+ def initialize parent_config = nil
625
+ @parent_config = parent_config unless parent_config.nil?
626
+
627
+ yield self if block_given?
628
+ end
629
+
630
+ ##
631
+ # Configurations for individual RPCs
632
+ # @return [Rpcs]
633
+ #
634
+ def rpcs
635
+ @rpcs ||= begin
636
+ parent_rpcs = nil
637
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
638
+ Rpcs.new parent_rpcs
639
+ end
640
+ end
641
+
642
+ ##
643
+ # Configuration RPC class for the WebRiskService API.
644
+ #
645
+ # Includes fields providing the configuration for each RPC in this service.
646
+ # Each configuration object is of type `Gapic::Config::Method` and includes
647
+ # the following configuration fields:
648
+ #
649
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
650
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
651
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
652
+ # include the following keys:
653
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
654
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
655
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
656
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
657
+ # trigger a retry.
658
+ #
659
+ class Rpcs
660
+ ##
661
+ # RPC-specific configuration for `compute_threat_list_diff`
662
+ # @return [::Gapic::Config::Method]
663
+ #
664
+ attr_reader :compute_threat_list_diff
665
+ ##
666
+ # RPC-specific configuration for `search_uris`
667
+ # @return [::Gapic::Config::Method]
668
+ #
669
+ attr_reader :search_uris
670
+ ##
671
+ # RPC-specific configuration for `search_hashes`
672
+ # @return [::Gapic::Config::Method]
673
+ #
674
+ attr_reader :search_hashes
675
+ ##
676
+ # RPC-specific configuration for `create_submission`
677
+ # @return [::Gapic::Config::Method]
678
+ #
679
+ attr_reader :create_submission
680
+ ##
681
+ # RPC-specific configuration for `submit_uri`
682
+ # @return [::Gapic::Config::Method]
683
+ #
684
+ attr_reader :submit_uri
685
+
686
+ # @private
687
+ def initialize parent_rpcs = nil
688
+ compute_threat_list_diff_config = parent_rpcs.compute_threat_list_diff if parent_rpcs.respond_to? :compute_threat_list_diff
689
+ @compute_threat_list_diff = ::Gapic::Config::Method.new compute_threat_list_diff_config
690
+ search_uris_config = parent_rpcs.search_uris if parent_rpcs.respond_to? :search_uris
691
+ @search_uris = ::Gapic::Config::Method.new search_uris_config
692
+ search_hashes_config = parent_rpcs.search_hashes if parent_rpcs.respond_to? :search_hashes
693
+ @search_hashes = ::Gapic::Config::Method.new search_hashes_config
694
+ create_submission_config = parent_rpcs.create_submission if parent_rpcs.respond_to? :create_submission
695
+ @create_submission = ::Gapic::Config::Method.new create_submission_config
696
+ submit_uri_config = parent_rpcs.submit_uri if parent_rpcs.respond_to? :submit_uri
697
+ @submit_uri = ::Gapic::Config::Method.new submit_uri_config
698
+
699
+ yield self if block_given?
700
+ end
701
+ end
702
+ end
703
+ end
704
+ end
705
+ end
706
+ end
707
+ end
708
+ end
709
+ end