google-cloud-web_risk-v1 0.1.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,624 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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
+
22
+ module Google
23
+ module Cloud
24
+ module WebRisk
25
+ module V1
26
+ module WebRiskService
27
+ ##
28
+ # Client for the WebRiskService service.
29
+ #
30
+ # Web Risk API defines an interface to detect malicious URLs on your
31
+ # website and in client applications.
32
+ #
33
+ class Client
34
+ include Paths
35
+
36
+ # @private
37
+ attr_reader :web_risk_service_stub
38
+
39
+ ##
40
+ # Configure the WebRiskService Client class.
41
+ #
42
+ # See {Google::Cloud::WebRisk::V1::WebRiskService::Client::Configuration}
43
+ # for a description of the configuration fields.
44
+ #
45
+ # ## Example
46
+ #
47
+ # To modify the configuration for all WebRiskService clients:
48
+ #
49
+ # Google::Cloud::WebRisk::V1::WebRiskService::Client.configure do |config|
50
+ # config.timeout = 10_000
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", "WebRisk", "V1"]
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.compute_threat_list_diff.timeout = 600.0
70
+ default_config.rpcs.compute_threat_list_diff.retry_policy = {
71
+ initial_delay: 0.1,
72
+ max_delay: 60.0,
73
+ multiplier: 1.3,
74
+ retry_codes: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
75
+ }
76
+
77
+ default_config.rpcs.search_uris.timeout = 600.0
78
+ default_config.rpcs.search_uris.retry_policy = {
79
+ initial_delay: 0.1,
80
+ max_delay: 60.0,
81
+ multiplier: 1.3,
82
+ retry_codes: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
83
+ }
84
+
85
+ default_config.rpcs.search_hashes.timeout = 600.0
86
+ default_config.rpcs.search_hashes.retry_policy = {
87
+ initial_delay: 0.1,
88
+ max_delay: 60.0,
89
+ multiplier: 1.3,
90
+ retry_codes: ["DEADLINE_EXCEEDED", "UNAVAILABLE"]
91
+ }
92
+
93
+ default_config
94
+ end
95
+ yield @configure if block_given?
96
+ @configure
97
+ end
98
+
99
+ ##
100
+ # Configure the WebRiskService Client instance.
101
+ #
102
+ # The configuration is set to the derived mode, meaning that values can be changed,
103
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
104
+ # should be made on {Client.configure}.
105
+ #
106
+ # See {Google::Cloud::WebRisk::V1::WebRiskService::Client::Configuration}
107
+ # for a description of the configuration fields.
108
+ #
109
+ # @yield [config] Configure the Client client.
110
+ # @yieldparam config [Client::Configuration]
111
+ #
112
+ # @return [Client::Configuration]
113
+ #
114
+ def configure
115
+ yield @config if block_given?
116
+ @config
117
+ end
118
+
119
+ ##
120
+ # Create a new WebRiskService client object.
121
+ #
122
+ # ## Examples
123
+ #
124
+ # To create a new WebRiskService client with the default
125
+ # configuration:
126
+ #
127
+ # client = Google::Cloud::WebRisk::V1::WebRiskService::Client.new
128
+ #
129
+ # To create a new WebRiskService client with a custom
130
+ # configuration:
131
+ #
132
+ # client = Google::Cloud::WebRisk::V1::WebRiskService::Client.new do |config|
133
+ # config.timeout = 10_000
134
+ # end
135
+ #
136
+ # @yield [config] Configure the WebRiskService client.
137
+ # @yieldparam config [Client::Configuration]
138
+ #
139
+ def initialize
140
+ # These require statements are intentionally placed here to initialize
141
+ # the gRPC module only when it's required.
142
+ # See https://github.com/googleapis/toolkit/issues/446
143
+ require "gapic/grpc"
144
+ require "google/cloud/webrisk/v1/webrisk_services_pb"
145
+
146
+ # Create the configuration object
147
+ @config = Configuration.new Client.configure
148
+
149
+ # Yield the configuration if needed
150
+ yield @config if block_given?
151
+
152
+ # Create credentials
153
+ credentials = @config.credentials
154
+ credentials ||= Credentials.default scope: @config.scope
155
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
156
+ credentials = Credentials.new credentials, scope: @config.scope
157
+ end
158
+ @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
159
+
160
+ @web_risk_service_stub = Gapic::ServiceStub.new(
161
+ Google::Cloud::WebRisk::V1::WebRiskService::Stub,
162
+ credentials: credentials,
163
+ endpoint: @config.endpoint,
164
+ channel_args: @config.channel_args,
165
+ interceptors: @config.interceptors
166
+ )
167
+ end
168
+
169
+ # Service calls
170
+
171
+ ##
172
+ # Gets the most recent threat list diffs. These diffs should be applied to
173
+ # a local database of hashes to keep it up-to-date. If the local database is
174
+ # empty or excessively out-of-date, a complete snapshot of the database will
175
+ # be returned. This Method only updates a single ThreatList at a time. To
176
+ # update multiple ThreatList databases, this method needs to be called once
177
+ # for each list.
178
+ #
179
+ # @overload compute_threat_list_diff(request, options = nil)
180
+ # Pass arguments to `compute_threat_list_diff` via a request object, either of type
181
+ # {Google::Cloud::WebRisk::V1::ComputeThreatListDiffRequest} or an equivalent Hash.
182
+ #
183
+ # @param request [Google::Cloud::WebRisk::V1::ComputeThreatListDiffRequest, Hash]
184
+ # A request object representing the call parameters. Required. To specify no
185
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
186
+ # @param options [Gapic::CallOptions, Hash]
187
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
188
+ #
189
+ # @overload compute_threat_list_diff(threat_type: nil, version_token: nil, constraints: nil)
190
+ # Pass arguments to `compute_threat_list_diff` via keyword arguments. Note that at
191
+ # least one keyword argument is required. To specify no parameters, or to keep all
192
+ # the default parameter values, pass an empty Hash as a request object (see above).
193
+ #
194
+ # @param threat_type [Google::Cloud::WebRisk::V1::ThreatType]
195
+ # Required. The threat list to update. Only a single ThreatType should be specified.
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
+ #
205
+ # @yield [response, operation] Access the result along with the RPC operation
206
+ # @yieldparam response [Google::Cloud::WebRisk::V1::ComputeThreatListDiffResponse]
207
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
208
+ #
209
+ # @return [Google::Cloud::WebRisk::V1::ComputeThreatListDiffResponse]
210
+ #
211
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
212
+ #
213
+ def compute_threat_list_diff request, options = nil
214
+ raise ArgumentError, "request must be provided" if request.nil?
215
+
216
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::WebRisk::V1::ComputeThreatListDiffRequest
217
+
218
+ # Converts hash and nil to an options object
219
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
220
+
221
+ # Customize the options with defaults
222
+ metadata = @config.rpcs.compute_threat_list_diff.metadata.to_h
223
+
224
+ # Set x-goog-api-client and x-goog-user-project headers
225
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
226
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
227
+ gapic_version: ::Google::Cloud::WebRisk::V1::VERSION
228
+ 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: metadata,
232
+ retry_policy: @config.rpcs.compute_threat_list_diff.retry_policy
233
+ options.apply_defaults metadata: @config.metadata,
234
+ retry_policy: @config.retry_policy
235
+
236
+ @web_risk_service_stub.call_rpc :compute_threat_list_diff, request, options: options do |response, operation|
237
+ yield response, operation if block_given?
238
+ return response
239
+ end
240
+ rescue GRPC::BadStatus => e
241
+ raise Google::Cloud::Error.from_error(e)
242
+ end
243
+
244
+ ##
245
+ # This method is used to check whether a URI is on a given threatList.
246
+ # Multiple threatLists may be searched in a single query.
247
+ # The response will list all requested threatLists the URI was found to
248
+ # match. If the URI is not found on any of the requested ThreatList an
249
+ # empty response will be returned.
250
+ #
251
+ # @overload search_uris(request, options = nil)
252
+ # Pass arguments to `search_uris` via a request object, either of type
253
+ # {Google::Cloud::WebRisk::V1::SearchUrisRequest} or an equivalent Hash.
254
+ #
255
+ # @param request [Google::Cloud::WebRisk::V1::SearchUrisRequest, Hash]
256
+ # A request object representing the call parameters. Required. To specify no
257
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
258
+ # @param options [Gapic::CallOptions, Hash]
259
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
260
+ #
261
+ # @overload search_uris(uri: nil, threat_types: nil)
262
+ # Pass arguments to `search_uris` via keyword arguments. Note that at
263
+ # least one keyword argument is required. To specify no parameters, or to keep all
264
+ # the default parameter values, pass an empty Hash as a request object (see above).
265
+ #
266
+ # @param uri [String]
267
+ # Required. The URI to be checked for matches.
268
+ # @param threat_types [Array<Google::Cloud::WebRisk::V1::ThreatType>]
269
+ # Required. The ThreatLists to search in. Multiple ThreatLists may be specified.
270
+ #
271
+ # @yield [response, operation] Access the result along with the RPC operation
272
+ # @yieldparam response [Google::Cloud::WebRisk::V1::SearchUrisResponse]
273
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
274
+ #
275
+ # @return [Google::Cloud::WebRisk::V1::SearchUrisResponse]
276
+ #
277
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
278
+ #
279
+ def search_uris request, options = nil
280
+ raise ArgumentError, "request must be provided" if request.nil?
281
+
282
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::WebRisk::V1::SearchUrisRequest
283
+
284
+ # Converts hash and nil to an options object
285
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
286
+
287
+ # Customize the options with defaults
288
+ metadata = @config.rpcs.search_uris.metadata.to_h
289
+
290
+ # Set x-goog-api-client and x-goog-user-project headers
291
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
292
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
293
+ gapic_version: ::Google::Cloud::WebRisk::V1::VERSION
294
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
295
+
296
+ options.apply_defaults timeout: @config.rpcs.search_uris.timeout,
297
+ metadata: metadata,
298
+ retry_policy: @config.rpcs.search_uris.retry_policy
299
+ options.apply_defaults metadata: @config.metadata,
300
+ retry_policy: @config.retry_policy
301
+
302
+ @web_risk_service_stub.call_rpc :search_uris, request, options: options do |response, operation|
303
+ yield response, operation if block_given?
304
+ return response
305
+ end
306
+ rescue GRPC::BadStatus => e
307
+ raise Google::Cloud::Error.from_error(e)
308
+ end
309
+
310
+ ##
311
+ # Gets the full hashes that match the requested hash prefix.
312
+ # This is used after a hash prefix is looked up in a threatList
313
+ # and there is a match. The client side threatList only holds partial hashes
314
+ # so the client must query this method to determine if there is a full
315
+ # hash match of a threat.
316
+ #
317
+ # @overload search_hashes(request, options = nil)
318
+ # Pass arguments to `search_hashes` via a request object, either of type
319
+ # {Google::Cloud::WebRisk::V1::SearchHashesRequest} or an equivalent Hash.
320
+ #
321
+ # @param request [Google::Cloud::WebRisk::V1::SearchHashesRequest, Hash]
322
+ # A request object representing the call parameters. Required. To specify no
323
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
324
+ # @param options [Gapic::CallOptions, Hash]
325
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
326
+ #
327
+ # @overload search_hashes(hash_prefix: nil, threat_types: nil)
328
+ # Pass arguments to `search_hashes` via keyword arguments. Note that at
329
+ # least one keyword argument is required. To specify no parameters, or to keep all
330
+ # the default parameter values, pass an empty Hash as a request object (see above).
331
+ #
332
+ # @param hash_prefix [String]
333
+ # A hash prefix, consisting of the most significant 4-32 bytes of a SHA256
334
+ # hash. For JSON requests, this field is base64-encoded.
335
+ # @param threat_types [Array<Google::Cloud::WebRisk::V1::ThreatType>]
336
+ # Required. The ThreatLists to search in. Multiple ThreatLists may be specified.
337
+ #
338
+ # @yield [response, operation] Access the result along with the RPC operation
339
+ # @yieldparam response [Google::Cloud::WebRisk::V1::SearchHashesResponse]
340
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
341
+ #
342
+ # @return [Google::Cloud::WebRisk::V1::SearchHashesResponse]
343
+ #
344
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
345
+ #
346
+ def search_hashes request, options = nil
347
+ raise ArgumentError, "request must be provided" if request.nil?
348
+
349
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::WebRisk::V1::SearchHashesRequest
350
+
351
+ # Converts hash and nil to an options object
352
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
353
+
354
+ # Customize the options with defaults
355
+ metadata = @config.rpcs.search_hashes.metadata.to_h
356
+
357
+ # Set x-goog-api-client and x-goog-user-project headers
358
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
359
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
360
+ gapic_version: ::Google::Cloud::WebRisk::V1::VERSION
361
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
362
+
363
+ options.apply_defaults timeout: @config.rpcs.search_hashes.timeout,
364
+ metadata: metadata,
365
+ retry_policy: @config.rpcs.search_hashes.retry_policy
366
+ options.apply_defaults metadata: @config.metadata,
367
+ retry_policy: @config.retry_policy
368
+
369
+ @web_risk_service_stub.call_rpc :search_hashes, request, options: options do |response, operation|
370
+ yield response, operation if block_given?
371
+ return response
372
+ end
373
+ rescue GRPC::BadStatus => e
374
+ raise Google::Cloud::Error.from_error(e)
375
+ end
376
+
377
+ ##
378
+ # Creates a Submission of a URI suspected of containing phishing content to
379
+ # be reviewed. If the result verifies the existence of malicious phishing
380
+ # content, the site will be added to the [Google's Social Engineering
381
+ # lists](https://support.google.com/webmasters/answer/6350487/) in order to
382
+ # protect users that could get exposed to this threat in the future. Only
383
+ # projects with CREATE_SUBMISSION_USERS visibility can use this method.
384
+ #
385
+ # @overload create_submission(request, options = nil)
386
+ # Pass arguments to `create_submission` via a request object, either of type
387
+ # {Google::Cloud::WebRisk::V1::CreateSubmissionRequest} or an equivalent Hash.
388
+ #
389
+ # @param request [Google::Cloud::WebRisk::V1::CreateSubmissionRequest, Hash]
390
+ # A request object representing the call parameters. Required. To specify no
391
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
392
+ # @param options [Gapic::CallOptions, Hash]
393
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
394
+ #
395
+ # @overload create_submission(parent: nil, submission: nil)
396
+ # Pass arguments to `create_submission` via keyword arguments. Note that at
397
+ # least one keyword argument is required. To specify no parameters, or to keep all
398
+ # the default parameter values, pass an empty Hash as a request object (see above).
399
+ #
400
+ # @param parent [String]
401
+ # Required. The name of the project that is making the submission. This string is in
402
+ # the format "projects/\\{project_number}".
403
+ # @param submission [Google::Cloud::WebRisk::V1::Submission, Hash]
404
+ # Required. The submission that contains the content of the phishing report.
405
+ #
406
+ # @yield [response, operation] Access the result along with the RPC operation
407
+ # @yieldparam response [Google::Cloud::WebRisk::V1::Submission]
408
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
409
+ #
410
+ # @return [Google::Cloud::WebRisk::V1::Submission]
411
+ #
412
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
413
+ #
414
+ def create_submission request, options = nil
415
+ raise ArgumentError, "request must be provided" if request.nil?
416
+
417
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::WebRisk::V1::CreateSubmissionRequest
418
+
419
+ # Converts hash and nil to an options object
420
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
421
+
422
+ # Customize the options with defaults
423
+ metadata = @config.rpcs.create_submission.metadata.to_h
424
+
425
+ # Set x-goog-api-client and x-goog-user-project headers
426
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
427
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
428
+ gapic_version: ::Google::Cloud::WebRisk::V1::VERSION
429
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
430
+
431
+ header_params = {
432
+ "parent" => request.parent
433
+ }
434
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
435
+ metadata[:"x-goog-request-params"] ||= request_params_header
436
+
437
+ options.apply_defaults timeout: @config.rpcs.create_submission.timeout,
438
+ metadata: metadata,
439
+ retry_policy: @config.rpcs.create_submission.retry_policy
440
+ options.apply_defaults metadata: @config.metadata,
441
+ retry_policy: @config.retry_policy
442
+
443
+ @web_risk_service_stub.call_rpc :create_submission, request, options: options do |response, operation|
444
+ yield response, operation if block_given?
445
+ return response
446
+ end
447
+ rescue GRPC::BadStatus => e
448
+ raise Google::Cloud::Error.from_error(e)
449
+ end
450
+
451
+ ##
452
+ # Configuration class for the WebRiskService API.
453
+ #
454
+ # This class represents the configuration for WebRiskService,
455
+ # providing control over timeouts, retry behavior, logging, transport
456
+ # parameters, and other low-level controls. Certain parameters can also be
457
+ # applied individually to specific RPCs. See
458
+ # {Google::Cloud::WebRisk::V1::WebRiskService::Client::Configuration::Rpcs}
459
+ # for a list of RPCs that can be configured independently.
460
+ #
461
+ # Configuration can be applied globally to all clients, or to a single client
462
+ # on construction.
463
+ #
464
+ # # Examples
465
+ #
466
+ # To modify the global config, setting the timeout for compute_threat_list_diff
467
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
468
+ #
469
+ # Google::Cloud::WebRisk::V1::WebRiskService::Client.configure do |config|
470
+ # config.timeout = 10_000
471
+ # config.rpcs.compute_threat_list_diff.timeout = 20_000
472
+ # end
473
+ #
474
+ # To apply the above configuration only to a new client:
475
+ #
476
+ # client = Google::Cloud::WebRisk::V1::WebRiskService::Client.new do |config|
477
+ # config.timeout = 10_000
478
+ # config.rpcs.compute_threat_list_diff.timeout = 20_000
479
+ # end
480
+ #
481
+ # @!attribute [rw] endpoint
482
+ # The hostname or hostname:port of the service endpoint.
483
+ # Defaults to `"webrisk.googleapis.com"`.
484
+ # @return [String]
485
+ # @!attribute [rw] credentials
486
+ # Credentials to send with calls. You may provide any of the following types:
487
+ # * (`String`) The path to a service account key file in JSON format
488
+ # * (`Hash`) A service account key as a Hash
489
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
490
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
491
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
492
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
493
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
494
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
495
+ # * (`nil`) indicating no credentials
496
+ # @return [Object]
497
+ # @!attribute [rw] scope
498
+ # The OAuth scopes
499
+ # @return [Array<String>]
500
+ # @!attribute [rw] lib_name
501
+ # The library name as recorded in instrumentation and logging
502
+ # @return [String]
503
+ # @!attribute [rw] lib_version
504
+ # The library version as recorded in instrumentation and logging
505
+ # @return [String]
506
+ # @!attribute [rw] channel_args
507
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
508
+ # `GRPC::Core::Channel` object is provided as the credential.
509
+ # @return [Hash]
510
+ # @!attribute [rw] interceptors
511
+ # An array of interceptors that are run before calls are executed.
512
+ # @return [Array<GRPC::ClientInterceptor>]
513
+ # @!attribute [rw] timeout
514
+ # The call timeout in milliseconds.
515
+ # @return [Numeric]
516
+ # @!attribute [rw] metadata
517
+ # Additional gRPC headers to be sent with the call.
518
+ # @return [Hash{Symbol=>String}]
519
+ # @!attribute [rw] retry_policy
520
+ # The retry policy. The value is a hash with the following keys:
521
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
522
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
523
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
524
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
525
+ # trigger a retry.
526
+ # @return [Hash]
527
+ #
528
+ class Configuration
529
+ extend Gapic::Config
530
+
531
+ config_attr :endpoint, "webrisk.googleapis.com", String
532
+ config_attr :credentials, nil do |value|
533
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
534
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
535
+ allowed.any? { |klass| klass === value }
536
+ end
537
+ config_attr :scope, nil, String, Array, nil
538
+ config_attr :lib_name, nil, String, nil
539
+ config_attr :lib_version, nil, String, nil
540
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
541
+ config_attr :interceptors, nil, Array, nil
542
+ config_attr :timeout, nil, Numeric, nil
543
+ config_attr :metadata, nil, Hash, nil
544
+ config_attr :retry_policy, nil, Hash, Proc, nil
545
+
546
+ # @private
547
+ def initialize parent_config = nil
548
+ @parent_config = parent_config unless parent_config.nil?
549
+
550
+ yield self if block_given?
551
+ end
552
+
553
+ ##
554
+ # Configurations for individual RPCs
555
+ # @return [Rpcs]
556
+ #
557
+ def rpcs
558
+ @rpcs ||= begin
559
+ parent_rpcs = nil
560
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
561
+ Rpcs.new parent_rpcs
562
+ end
563
+ end
564
+
565
+ ##
566
+ # Configuration RPC class for the WebRiskService API.
567
+ #
568
+ # Includes fields providing the configuration for each RPC in this service.
569
+ # Each configuration object is of type `Gapic::Config::Method` and includes
570
+ # the following configuration fields:
571
+ #
572
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
573
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
574
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
575
+ # include the following keys:
576
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
577
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
578
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
579
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
580
+ # trigger a retry.
581
+ #
582
+ class Rpcs
583
+ ##
584
+ # RPC-specific configuration for `compute_threat_list_diff`
585
+ # @return [Gapic::Config::Method]
586
+ #
587
+ attr_reader :compute_threat_list_diff
588
+ ##
589
+ # RPC-specific configuration for `search_uris`
590
+ # @return [Gapic::Config::Method]
591
+ #
592
+ attr_reader :search_uris
593
+ ##
594
+ # RPC-specific configuration for `search_hashes`
595
+ # @return [Gapic::Config::Method]
596
+ #
597
+ attr_reader :search_hashes
598
+ ##
599
+ # RPC-specific configuration for `create_submission`
600
+ # @return [Gapic::Config::Method]
601
+ #
602
+ attr_reader :create_submission
603
+
604
+ # @private
605
+ def initialize parent_rpcs = nil
606
+ compute_threat_list_diff_config = parent_rpcs&.compute_threat_list_diff if parent_rpcs&.respond_to? :compute_threat_list_diff
607
+ @compute_threat_list_diff = Gapic::Config::Method.new compute_threat_list_diff_config
608
+ search_uris_config = parent_rpcs&.search_uris if parent_rpcs&.respond_to? :search_uris
609
+ @search_uris = Gapic::Config::Method.new search_uris_config
610
+ search_hashes_config = parent_rpcs&.search_hashes if parent_rpcs&.respond_to? :search_hashes
611
+ @search_hashes = Gapic::Config::Method.new search_hashes_config
612
+ create_submission_config = parent_rpcs&.create_submission if parent_rpcs&.respond_to? :create_submission
613
+ @create_submission = Gapic::Config::Method.new create_submission_config
614
+
615
+ yield self if block_given?
616
+ end
617
+ end
618
+ end
619
+ end
620
+ end
621
+ end
622
+ end
623
+ end
624
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 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 "googleauth"
20
+
21
+ module Google
22
+ module Cloud
23
+ module WebRisk
24
+ module V1
25
+ module WebRiskService
26
+ # Credentials for the WebRiskService API.
27
+ class Credentials < Google::Auth::Credentials
28
+ self.scope = [
29
+ "https://www.googleapis.com/auth/cloud-platform"
30
+ ]
31
+ self.env_vars = [
32
+ "WEBRISK_CREDENTIALS",
33
+ "WEBRISK_KEYFILE",
34
+ "GOOGLE_CLOUD_CREDENTIALS",
35
+ "GOOGLE_CLOUD_KEYFILE",
36
+ "GCLOUD_KEYFILE",
37
+ "WEBRISK_CREDENTIALS_JSON",
38
+ "WEBRISK_KEYFILE_JSON",
39
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
40
+ "GOOGLE_CLOUD_KEYFILE_JSON",
41
+ "GCLOUD_KEYFILE_JSON"
42
+ ]
43
+ self.paths = [
44
+ "~/.config/google_cloud/application_default_credentials.json"
45
+ ]
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end