google-cloud-web_risk 1.6.1 → 2.0.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.
- checksums.yaml +4 -4
- data/.yardopts +0 -1
- data/README.md +31 -10
- data/lib/google/cloud/web_risk/version.rb +1 -1
- data/lib/google/cloud/web_risk.rb +36 -0
- metadata +8 -38
- data/MIGRATING.md +0 -277
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc31a643d3ef535db094584b8bf3b5956b938cb25116c9b5b3fb62e164068c0c
|
4
|
+
data.tar.gz: 99c5e7881bfaba2616f0a85eeb404073a533bd21a7830684c46b6b34c7645818
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4c45046408acff9ef2ee5755dee68417425824c659b43b4afbc580399b7c01137bdc0f9120857342908faf3df48cc97e4bdfb04fbe18ff57bb6422def351909
|
7
|
+
data.tar.gz: ebe8c1ebae7f9f6defbe8e5f4de215806ae466680faef5e1185adab2a1e50392134e4eb9a3bc64bd8cfe08dfd48733f8572859e60d8cf3047bb5b4fb574804d5
|
data/.yardopts
CHANGED
data/README.md
CHANGED
@@ -16,8 +16,7 @@ for this library, google-cloud-web_risk, to see the convenience methods for
|
|
16
16
|
constructing client objects. Reference documentation for the client objects
|
17
17
|
themselves can be found in the client library documentation for the versioned
|
18
18
|
client gems:
|
19
|
-
[google-cloud-web_risk-v1](https://cloud.google.com/ruby/docs/reference/google-cloud-web_risk-v1/latest)
|
20
|
-
[google-cloud-web_risk-v1beta1](https://cloud.google.com/ruby/docs/reference/google-cloud-web_risk-v1beta1/latest).
|
19
|
+
[google-cloud-web_risk-v1](https://cloud.google.com/ruby/docs/reference/google-cloud-web_risk-v1/latest).
|
21
20
|
|
22
21
|
See also the [Product Documentation](https://cloud.google.com/web-risk)
|
23
22
|
for more usage information.
|
@@ -35,17 +34,39 @@ In order to use this library, you first need to go through the following steps:
|
|
35
34
|
1. [Enable the API.](https://console.cloud.google.com/apis/library/webrisk.googleapis.com)
|
36
35
|
1. {file:AUTHENTICATION.md Set up authentication.}
|
37
36
|
|
38
|
-
##
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
## Debug Logging
|
38
|
+
|
39
|
+
This library comes with opt-in Debug Logging that can help you troubleshoot
|
40
|
+
your application's integration with the API. When logging is activated, key
|
41
|
+
events such as requests and responses, along with data payloads and metadata
|
42
|
+
such as headers and client configuration, are logged to the standard error
|
43
|
+
stream.
|
44
|
+
|
45
|
+
**WARNING:** Client Library Debug Logging includes your data payloads in
|
46
|
+
plaintext, which could include sensitive data such as PII for yourself or your
|
47
|
+
customers, private keys, or other security data that could be compromising if
|
48
|
+
leaked. Always practice good data hygiene with your application logs, and follow
|
49
|
+
the principle of least access. Google also recommends that Client Library Debug
|
50
|
+
Logging be enabled only temporarily during active debugging, and not used
|
51
|
+
permanently in production.
|
52
|
+
|
53
|
+
To enable logging, set the environment variable `GOOGLE_SDK_RUBY_LOGGING_GEMS`
|
54
|
+
to the value `all`. Alternatively, you can set the value to a comma-delimited
|
55
|
+
list of client library gem names. This will select the default logging behavior,
|
56
|
+
which writes logs to the standard error stream. On a local workstation, this may
|
57
|
+
result in logs appearing on the console. When running on a Google Cloud hosting
|
58
|
+
service such as [Google Cloud Run](https://cloud.google.com/run), this generally
|
59
|
+
results in logs appearing alongside your application logs in the
|
60
|
+
[Google Cloud Logging](https://cloud.google.com/logging/) service.
|
61
|
+
|
62
|
+
Debug logging also requires that the versioned clients for this service be
|
63
|
+
sufficiently recent, released after about Dec 10, 2024. If logging is not
|
64
|
+
working, try updating the versioned clients in your bundle or installed gems:
|
65
|
+
[google-cloud-web_risk-v1](https://cloud.google.com/ruby/docs/reference/google-cloud-web_risk-v1/latest).
|
45
66
|
|
46
67
|
## Supported Ruby Versions
|
47
68
|
|
48
|
-
This library is supported on Ruby
|
69
|
+
This library is supported on Ruby 3.0+.
|
49
70
|
|
50
71
|
Google provides official support for Ruby versions that are actively supported
|
51
72
|
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
|
@@ -58,6 +58,11 @@ module Google
|
|
58
58
|
# You can also specify a different transport by passing `:rest` or `:grpc` in
|
59
59
|
# the `transport` parameter.
|
60
60
|
#
|
61
|
+
# Raises an exception if the currently installed versioned client gem for the
|
62
|
+
# given API version does not support the given transport of the WebRiskService service.
|
63
|
+
# You can determine whether the method will succeed by calling
|
64
|
+
# {Google::Cloud::WebRisk.web_risk_service_available?}.
|
65
|
+
#
|
61
66
|
# ## About WebRiskService
|
62
67
|
#
|
63
68
|
# Web Risk API defines an interface to detect malicious URLs on your
|
@@ -80,6 +85,37 @@ module Google
|
|
80
85
|
service_module.const_get(:Client).new(&block)
|
81
86
|
end
|
82
87
|
|
88
|
+
##
|
89
|
+
# Determines whether the WebRiskService service is supported by the current client.
|
90
|
+
# If true, you can retrieve a client object by calling {Google::Cloud::WebRisk.web_risk_service}.
|
91
|
+
# If false, that method will raise an exception. This could happen if the given
|
92
|
+
# API version does not exist or does not support the WebRiskService service,
|
93
|
+
# or if the versioned client gem needs an update to support the WebRiskService service.
|
94
|
+
#
|
95
|
+
# @param version [::String, ::Symbol] The API version to connect to. Optional.
|
96
|
+
# Defaults to `:v1`.
|
97
|
+
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
|
98
|
+
# @return [boolean] Whether the service is available.
|
99
|
+
#
|
100
|
+
def self.web_risk_service_available? version: :v1, transport: :grpc
|
101
|
+
require "google/cloud/web_risk/#{version.to_s.downcase}"
|
102
|
+
package_name = Google::Cloud::WebRisk
|
103
|
+
.constants
|
104
|
+
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
|
105
|
+
.first
|
106
|
+
return false unless package_name
|
107
|
+
service_module = Google::Cloud::WebRisk.const_get package_name
|
108
|
+
return false unless service_module.const_defined? :WebRiskService
|
109
|
+
service_module = service_module.const_get :WebRiskService
|
110
|
+
if transport == :rest
|
111
|
+
return false unless service_module.const_defined? :Rest
|
112
|
+
service_module = service_module.const_get :Rest
|
113
|
+
end
|
114
|
+
service_module.const_defined? :Client
|
115
|
+
rescue ::LoadError
|
116
|
+
false
|
117
|
+
end
|
118
|
+
|
83
119
|
##
|
84
120
|
# Configure the google-cloud-web_risk library.
|
85
121
|
#
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-web_risk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google LLC
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-13 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: google-cloud-core
|
@@ -28,42 +27,16 @@ dependencies:
|
|
28
27
|
name: google-cloud-web_risk-v1
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
30
29
|
requirements:
|
31
|
-
- - "
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.11'
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 2.a
|
37
|
-
type: :runtime
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '0.11'
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 2.a
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: google-cloud-web_risk-v1beta1
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - ">="
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.9'
|
54
|
-
- - "<"
|
30
|
+
- - "~>"
|
55
31
|
- !ruby/object:Gem::Version
|
56
|
-
version: 2
|
32
|
+
version: '1.2'
|
57
33
|
type: :runtime
|
58
34
|
prerelease: false
|
59
35
|
version_requirements: !ruby/object:Gem::Requirement
|
60
36
|
requirements:
|
61
|
-
- - "
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0.9'
|
64
|
-
- - "<"
|
37
|
+
- - "~>"
|
65
38
|
- !ruby/object:Gem::Version
|
66
|
-
version: 2
|
39
|
+
version: '1.2'
|
67
40
|
description: Web Risk is an enterprise security product that lets your client applications
|
68
41
|
check URLs against Google's constantly updated lists of unsafe web resources.
|
69
42
|
email: googleapis-packages@google.com
|
@@ -74,7 +47,6 @@ files:
|
|
74
47
|
- ".yardopts"
|
75
48
|
- AUTHENTICATION.md
|
76
49
|
- LICENSE.md
|
77
|
-
- MIGRATING.md
|
78
50
|
- README.md
|
79
51
|
- lib/google-cloud-web_risk.rb
|
80
52
|
- lib/google/cloud/web_risk.rb
|
@@ -83,7 +55,6 @@ homepage: https://github.com/googleapis/google-cloud-ruby
|
|
83
55
|
licenses:
|
84
56
|
- Apache-2.0
|
85
57
|
metadata: {}
|
86
|
-
post_install_message:
|
87
58
|
rdoc_options: []
|
88
59
|
require_paths:
|
89
60
|
- lib
|
@@ -91,15 +62,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
62
|
requirements:
|
92
63
|
- - ">="
|
93
64
|
- !ruby/object:Gem::Version
|
94
|
-
version: '
|
65
|
+
version: '3.0'
|
95
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
67
|
requirements:
|
97
68
|
- - ">="
|
98
69
|
- !ruby/object:Gem::Version
|
99
70
|
version: '0'
|
100
71
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
102
|
-
signing_key:
|
72
|
+
rubygems_version: 3.6.3
|
103
73
|
specification_version: 4
|
104
74
|
summary: API Client library for the Web Risk API
|
105
75
|
test_files: []
|
data/MIGRATING.md
DELETED
@@ -1,277 +0,0 @@
|
|
1
|
-
## Migrating to google-cloud-web_risk 1.0
|
2
|
-
|
3
|
-
The `google-cloud-web_risk` gem is a significant upgrade over the older and now
|
4
|
-
deprecated `google-cloud-webrisk` gem. It is based on a
|
5
|
-
[next-gen code generator](https://github.com/googleapis/gapic-generator-ruby),
|
6
|
-
and includes substantial interface changes. Existing code written for the older
|
7
|
-
gem will likely require updates to use this version. This document describes
|
8
|
-
the changes that have been made, and what you need to do to update your usage.
|
9
|
-
|
10
|
-
To summarize:
|
11
|
-
|
12
|
-
* The new gem supports versions V1 and V1beta1 of the Web Risk service. The
|
13
|
-
older gem supported only V1beta1.
|
14
|
-
* The client has been broken out into multiple libraries. The new gems
|
15
|
-
`google-cloud-web_risk-v1` and `google-cloud-web_risk-v1beta1` contain the
|
16
|
-
actual client classes for versions V1 and V1beta1 of the Web Risk service,
|
17
|
-
and the gem `google-cloud-web_risk` provides a convenience wrapper.
|
18
|
-
See [Library Structure](#library-structure) for more info.
|
19
|
-
* Some classes have moved into different namespaces. In particular, the
|
20
|
-
`Google::Cloud::Webrisk` module has been renamed to `Google::Cloud::WebRisk`.
|
21
|
-
See [Class Namespaces](#class-namespaces) for more info.
|
22
|
-
* The library uses a new configuration mechanism giving you closer control
|
23
|
-
over endpoint address, network timeouts, and retry. See
|
24
|
-
[Client Configuration](#client-configuration) for more info. Furthermore,
|
25
|
-
when creating a client object, you can customize its configuration in a
|
26
|
-
block rather than passing arguments to the constructor. See
|
27
|
-
[Creating Clients](#creating-clients) for more info.
|
28
|
-
* Previously, positional arguments were used to indicate required arguments.
|
29
|
-
Now, all method arguments are keyword arguments, with documentation that
|
30
|
-
specifies whether they are required or optional. Additionally, you can pass
|
31
|
-
a proto request object instead of separate arguments. See
|
32
|
-
[Passing Arguments](#passing-arguments) for more info.
|
33
|
-
* Previously, clients reported RPC errors by raising instances of
|
34
|
-
`Google::Gax::GaxError` and its subclasses. Now, RPC exceptions are of type
|
35
|
-
`Google::Cloud::Error` and its subclasses. See
|
36
|
-
[Handling Errors](#handling-errors) for more info.
|
37
|
-
|
38
|
-
### Library Structure
|
39
|
-
|
40
|
-
The older `google-cloud-webrisk` gem was an all-in-one gem
|
41
|
-
that included potentially multiple clients for multiple versions of the
|
42
|
-
Web Risk service. The `Google::Cloud::Webrisk.new` factory method would
|
43
|
-
return you an instance of a `Google::Cloud::Webrisk::V1beta1::WebRiskServiceV1Beta1Client`
|
44
|
-
object for the V1beta1 version of the service. (Version V1 of the service was
|
45
|
-
not supported by the older gem.)
|
46
|
-
|
47
|
-
The new `google-cloud-web_risk` gem still provides factory
|
48
|
-
methods for obtaining clients. (The method signatures will have changed. See
|
49
|
-
[Creating Clients](#creating-clients) for details.) However, the actual client
|
50
|
-
classes have been moved into separate gems, one per service version. The
|
51
|
-
`Google::Cloud::WebRisk::V1::WebRiskService::Client` class, along with its
|
52
|
-
helpers and data types, is now part of the `google-cloud-web_risk-v1` gem.
|
53
|
-
Similarly, the `Google::Cloud::WebRisk::V1beta1::WebRiskService::Client`
|
54
|
-
class is part of the `google-cloud-web_risk-v1beta1` gem.
|
55
|
-
|
56
|
-
For normal usage, you can install the `google-cloud-web_risk` gem
|
57
|
-
(which will bring in the versioned client gems as dependencies) and continue to
|
58
|
-
use factory methods to create clients. However, you may alternatively choose to
|
59
|
-
install only one of the versioned gems. For example, if you know you will only
|
60
|
-
use `V1` of the service, you can install `google-cloud-web_risk-v1` by
|
61
|
-
itself, and construct instances of the
|
62
|
-
`Google::Cloud::WebRisk::V1::WebRiskService::Client` client class directly.
|
63
|
-
|
64
|
-
### Class Namespaces
|
65
|
-
|
66
|
-
As part of the gem being renamed from `google-cloud-webrisk` to
|
67
|
-
`google-cloud-web_risk`, the main namespace module has also been renamed
|
68
|
-
accordingly, from `Google::Cloud::Webrisk` to `Google::Cloud::WebRisk`. (Note
|
69
|
-
the "R" in "WebRisk" is now capitalized.) This affects the entire library,
|
70
|
-
including clients, data types, and all other modules and classes.
|
71
|
-
|
72
|
-
Additionally, some of the underlying classes have also been renamed.
|
73
|
-
In the older gem, the client object was of classes with names like:
|
74
|
-
`Google::Cloud::Webrisk::V1beta1::WebRiskServiceV1Beta1Client`.
|
75
|
-
In the new gem, the corresponding client object is of a different class:
|
76
|
-
`Google::Cloud::WebRisk::V1beta1::WebRiskService::Client`.
|
77
|
-
Note that most users will use the factory methods such as
|
78
|
-
`Google::Cloud::WebRisk.web_risk_service` to create instances of the client object,
|
79
|
-
so you may not need to reference the actual class directly.
|
80
|
-
See [Creating Clients](#creating-clients).
|
81
|
-
|
82
|
-
In older releases, the credentials object was of class
|
83
|
-
`Google::Cloud::Webrisk::V1beta1::Credentials`.
|
84
|
-
In the 1.0 release, each service has its own credentials class, e.g.
|
85
|
-
`Google::Cloud::WebRisk::V1beta1::WebRiskService::Credentials`.
|
86
|
-
Again, most users will not need to reference this class directly.
|
87
|
-
See [Client Configuration](#client-configuration).
|
88
|
-
|
89
|
-
### Client Configuration
|
90
|
-
|
91
|
-
In the older gem, if you wanted to customize performance parameters or
|
92
|
-
low-level behavior of the client (such as credentials, timeouts, or
|
93
|
-
instrumentation), you would pass a variety of keyword arguments to the client
|
94
|
-
constructor. It was also extremely difficult to customize the default settings.
|
95
|
-
|
96
|
-
In the new gem, a configuration interface provides control over these
|
97
|
-
parameters, including defaults for all instances of a client, and settings for
|
98
|
-
each specific client instance. For example, to set default credentials and
|
99
|
-
timeout for all Web Risk V1 clients:
|
100
|
-
|
101
|
-
```
|
102
|
-
Google::Cloud::WebRisk::V1::WebRiskService::Client.configure do |config|
|
103
|
-
config.credentials = "/path/to/credentials.json"
|
104
|
-
config.timeout = 10.0
|
105
|
-
end
|
106
|
-
```
|
107
|
-
|
108
|
-
Individual RPCs can also be configured independently. For example, to set the
|
109
|
-
timeout for the `search_uris` call:
|
110
|
-
|
111
|
-
```
|
112
|
-
Google::Cloud::WebRisk::V1::WebRiskService::Client.configure do |config|
|
113
|
-
config.rpcs.search_uris.timeout = 20.0
|
114
|
-
end
|
115
|
-
```
|
116
|
-
|
117
|
-
Defaults for certain configurations can be set for all Web Risk versions and
|
118
|
-
services globally:
|
119
|
-
|
120
|
-
```
|
121
|
-
Google::Cloud::WebRisk.configure do |config|
|
122
|
-
config.credentials = "/path/to/credentials.json"
|
123
|
-
config.timeout = 10.0
|
124
|
-
end
|
125
|
-
```
|
126
|
-
|
127
|
-
Finally, you can override the configuration for each client instance. See the
|
128
|
-
next section on [Creating Clients](#creating-clients) for details.
|
129
|
-
|
130
|
-
### Creating Clients
|
131
|
-
|
132
|
-
In the older gem, to create a client object, you would use the
|
133
|
-
`Google::Cloud::Webrisk.new` class method. Keyword arguments were available to
|
134
|
-
select a service version and to configure parameters such as credentials and
|
135
|
-
timeouts.
|
136
|
-
|
137
|
-
In the new gem, use the `Google::Cloud::WebRisk.web_risk_service` class
|
138
|
-
method to create a client object. You may select a service version using the
|
139
|
-
`:version` keyword argument. However, other configuration parameters should be
|
140
|
-
set in a configuration block when you create the client.
|
141
|
-
|
142
|
-
Old:
|
143
|
-
```
|
144
|
-
client = Google::Cloud::Webrisk.new credentials: "/path/to/credentials.json"
|
145
|
-
```
|
146
|
-
|
147
|
-
New:
|
148
|
-
```
|
149
|
-
client = Google::Cloud::WebRisk.web_risk_service do |config|
|
150
|
-
config.credentials = "/path/to/credentials.json"
|
151
|
-
end
|
152
|
-
```
|
153
|
-
|
154
|
-
The configuration block is optional. If you do not provide it, or you do not
|
155
|
-
set some configuration parameters, then the default configuration is used. See
|
156
|
-
[Client Configuration](#client-configuration).
|
157
|
-
|
158
|
-
### Passing Arguments
|
159
|
-
|
160
|
-
In the older gem, required arguments would be passed as positional method
|
161
|
-
arguments, while most optional arguments would be passed as keyword arguments.
|
162
|
-
|
163
|
-
In the new gem, all RPC arguments are passed as keyword arguments,
|
164
|
-
regardless of whether they are required or optional. For example:
|
165
|
-
|
166
|
-
Old:
|
167
|
-
```
|
168
|
-
client = Google::Cloud::Webrisk.new
|
169
|
-
|
170
|
-
uri = "http://example.com"
|
171
|
-
threat_types = [Google::Cloud::Webrisk::V1beta1::ThreatType::MALWARE]
|
172
|
-
|
173
|
-
# Both uri and threat_types are positional arguments.
|
174
|
-
response = client.search_uris uri, threat_types
|
175
|
-
```
|
176
|
-
|
177
|
-
New:
|
178
|
-
```
|
179
|
-
client = Google::Cloud::WebRisk.web_risk_service
|
180
|
-
|
181
|
-
uri = "http://example.com"
|
182
|
-
threat_types = [Google::Cloud::WebRisk::V1::ThreatType::MALWARE]
|
183
|
-
|
184
|
-
# Both uri and threat_types are keyword arguments.
|
185
|
-
response = client.search_uris uri: uri, threat_types: threat_types
|
186
|
-
```
|
187
|
-
|
188
|
-
In the new gem, it is also possible to pass a request object, either
|
189
|
-
as a hash or as a protocol buffer.
|
190
|
-
|
191
|
-
New:
|
192
|
-
```
|
193
|
-
client = Google::Cloud::WebRisk.web_risk_service
|
194
|
-
|
195
|
-
request = Google::Cloud::WebRisk::V1::SearchUrisRequest.new(
|
196
|
-
uri: "http://example.com",
|
197
|
-
threat_types: [Google::Cloud::WebRisk::V1::ThreatType::MALWARE]
|
198
|
-
)
|
199
|
-
|
200
|
-
# Pass a request object as a positional argument:
|
201
|
-
response = client.search_uris request
|
202
|
-
```
|
203
|
-
|
204
|
-
Finally, in older releases, to provide call options, you would pass a
|
205
|
-
`Google::Gax::CallOptions` object with the `:options` keyword argument. In the
|
206
|
-
1.0 release, pass call options using a _second set_ of keyword arguments.
|
207
|
-
|
208
|
-
Old:
|
209
|
-
```
|
210
|
-
client = Google::Cloud::Webrisk.new
|
211
|
-
|
212
|
-
uri = "http://example.com"
|
213
|
-
threat_types = [Google::Cloud::Webrisk::V1beta1::ThreatType::MALWARE]
|
214
|
-
|
215
|
-
options = Google::Gax::CallOptions.new timeout: 10.0
|
216
|
-
|
217
|
-
response = client.search_uris uri, threat_types, options: options
|
218
|
-
```
|
219
|
-
|
220
|
-
New:
|
221
|
-
```
|
222
|
-
client = Google::Cloud::WebRisk.web_risk_service
|
223
|
-
|
224
|
-
uri = "http://example.com"
|
225
|
-
threat_types = [Google::Cloud::WebRisk::V1::ThreatType::MALWARE]
|
226
|
-
|
227
|
-
# Use a hash to wrap the normal call arguments (or pass a request object), and
|
228
|
-
# then add further keyword arguments for the call options.
|
229
|
-
response = client.search_uris(
|
230
|
-
{ uri: uri, threat_types: threat_types },
|
231
|
-
timeout: 10.0
|
232
|
-
)
|
233
|
-
```
|
234
|
-
|
235
|
-
### Handling Errors
|
236
|
-
|
237
|
-
The client reports standard
|
238
|
-
[gRPC error codes](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md)
|
239
|
-
by raising exceptions. In the older gem, these exceptions were located in the
|
240
|
-
`Google::Gax` namespace and were subclasses of the `Google::Gax::GaxError` base
|
241
|
-
exception class, defined in the `google-gax` gem. However, these classes were
|
242
|
-
different from the standard exceptions (subclasses of `Google::Cloud::Error`)
|
243
|
-
thrown by other client libraries such as `google-cloud-storage`.
|
244
|
-
|
245
|
-
The new client library now uses the `Google::Cloud::Error` exception hierarchy,
|
246
|
-
for consistency across all the Google Cloud client libraries. In general, these
|
247
|
-
exceptions have the same name as their counterparts from older releases, but
|
248
|
-
are located in the `Google::Cloud` namespace rather than the `Google::Gax`
|
249
|
-
namespace.
|
250
|
-
|
251
|
-
Old:
|
252
|
-
```
|
253
|
-
client = Google::Cloud::Webrisk.new
|
254
|
-
|
255
|
-
uri = "http://example.com"
|
256
|
-
threat_types = [Google::Cloud::Webrisk::V1beta1::ThreatType::MALWARE]
|
257
|
-
|
258
|
-
begin
|
259
|
-
response = client.search_uris uri, threat_types
|
260
|
-
rescue Google::Gax::Error => e
|
261
|
-
# Handle exceptions that subclass Google::Gax::Error
|
262
|
-
end
|
263
|
-
```
|
264
|
-
|
265
|
-
New:
|
266
|
-
```
|
267
|
-
client = Google::Cloud::WebRisk.web_risk_service
|
268
|
-
|
269
|
-
uri = "http://example.com"
|
270
|
-
threat_types = [Google::Cloud::WebRisk::V1::ThreatType::MALWARE]
|
271
|
-
|
272
|
-
begin
|
273
|
-
response = client.search_uris uri: uri, threat_types: threat_types
|
274
|
-
rescue Google::Cloud::Error => e
|
275
|
-
# Handle exceptions that subclass Google::Cloud::Error
|
276
|
-
end
|
277
|
-
```
|