google-apis-safebrowsing_v4 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,288 @@
1
+ # Copyright 2020 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'google/apis/core/base_service'
16
+ require 'google/apis/core/json_representation'
17
+ require 'google/apis/core/hashable'
18
+ require 'google/apis/errors'
19
+
20
+ module Google
21
+ module Apis
22
+ module SafebrowsingV4
23
+ # Safe Browsing API
24
+ #
25
+ # Enables client applications to check web resources (most commonly URLs)
26
+ # against Google-generated lists of unsafe web resources. The Safe Browsing APIs
27
+ # are for non-commercial use only. If you need to use APIs to detect malicious
28
+ # URLs for commercial purposes – meaning “for sale or revenue-generating
29
+ # purposes” – please refer to the Web Risk API.
30
+ #
31
+ # @example
32
+ # require 'google/apis/safebrowsing_v4'
33
+ #
34
+ # Safebrowsing = Google::Apis::SafebrowsingV4 # Alias the module
35
+ # service = Safebrowsing::SafebrowsingService.new
36
+ #
37
+ # @see https://developers.google.com/safe-browsing/
38
+ class SafebrowsingService < Google::Apis::Core::BaseService
39
+ # @return [String]
40
+ # API key. Your API key identifies your project and provides you with API access,
41
+ # quota, and reports. Required unless you provide an OAuth 2.0 token.
42
+ attr_accessor :key
43
+
44
+ # @return [String]
45
+ # Available to use for quota purposes for server-side applications. Can be any
46
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
47
+ attr_accessor :quota_user
48
+
49
+ def initialize
50
+ super('https://safebrowsing.googleapis.com/', '',
51
+ client_name: 'google-apis-safebrowsing_v4',
52
+ client_version: Google::Apis::SafebrowsingV4::GEM_VERSION)
53
+ @batch_path = 'batch'
54
+ end
55
+
56
+ #
57
+ # @param [String] encoded_request
58
+ # A serialized FindFullHashesRequest proto.
59
+ # @param [String] client_id
60
+ # A client ID that (hopefully) uniquely identifies the client implementation of
61
+ # the Safe Browsing API.
62
+ # @param [String] client_version
63
+ # The version of the client implementation.
64
+ # @param [String] fields
65
+ # Selector specifying which fields to include in a partial response.
66
+ # @param [String] quota_user
67
+ # Available to use for quota purposes for server-side applications. Can be any
68
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
69
+ # @param [Google::Apis::RequestOptions] options
70
+ # Request-specific options
71
+ #
72
+ # @yield [result, err] Result & error if block supplied
73
+ # @yieldparam result [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindFullHashesResponse] parsed result object
74
+ # @yieldparam err [StandardError] error object if request failed
75
+ #
76
+ # @return [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindFullHashesResponse]
77
+ #
78
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
79
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
80
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
81
+ def get_encoded_full_hash(encoded_request, client_id: nil, client_version: nil, fields: nil, quota_user: nil, options: nil, &block)
82
+ command = make_simple_command(:get, 'v4/encodedFullHashes/{encodedRequest}', options)
83
+ command.response_representation = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindFullHashesResponse::Representation
84
+ command.response_class = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindFullHashesResponse
85
+ command.params['encodedRequest'] = encoded_request unless encoded_request.nil?
86
+ command.query['clientId'] = client_id unless client_id.nil?
87
+ command.query['clientVersion'] = client_version unless client_version.nil?
88
+ command.query['fields'] = fields unless fields.nil?
89
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
90
+ execute_or_queue_command(command, &block)
91
+ end
92
+
93
+ #
94
+ # @param [String] encoded_request
95
+ # A serialized FetchThreatListUpdatesRequest proto.
96
+ # @param [String] client_id
97
+ # A client ID that uniquely identifies the client implementation of the Safe
98
+ # Browsing API.
99
+ # @param [String] client_version
100
+ # The version of the client implementation.
101
+ # @param [String] fields
102
+ # Selector specifying which fields to include in a partial response.
103
+ # @param [String] quota_user
104
+ # Available to use for quota purposes for server-side applications. Can be any
105
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
106
+ # @param [Google::Apis::RequestOptions] options
107
+ # Request-specific options
108
+ #
109
+ # @yield [result, err] Result & error if block supplied
110
+ # @yieldparam result [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FetchThreatListUpdatesResponse] parsed result object
111
+ # @yieldparam err [StandardError] error object if request failed
112
+ #
113
+ # @return [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FetchThreatListUpdatesResponse]
114
+ #
115
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
116
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
117
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
118
+ def get_encoded_update(encoded_request, client_id: nil, client_version: nil, fields: nil, quota_user: nil, options: nil, &block)
119
+ command = make_simple_command(:get, 'v4/encodedUpdates/{encodedRequest}', options)
120
+ command.response_representation = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FetchThreatListUpdatesResponse::Representation
121
+ command.response_class = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FetchThreatListUpdatesResponse
122
+ command.params['encodedRequest'] = encoded_request unless encoded_request.nil?
123
+ command.query['clientId'] = client_id unless client_id.nil?
124
+ command.query['clientVersion'] = client_version unless client_version.nil?
125
+ command.query['fields'] = fields unless fields.nil?
126
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
127
+ execute_or_queue_command(command, &block)
128
+ end
129
+
130
+ # Finds the full hashes that match the requested hash prefixes.
131
+ # @param [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindFullHashesRequest] google_security_safebrowsing_v4_find_full_hashes_request_object
132
+ # @param [String] fields
133
+ # Selector specifying which fields to include in a partial response.
134
+ # @param [String] quota_user
135
+ # Available to use for quota purposes for server-side applications. Can be any
136
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
137
+ # @param [Google::Apis::RequestOptions] options
138
+ # Request-specific options
139
+ #
140
+ # @yield [result, err] Result & error if block supplied
141
+ # @yieldparam result [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindFullHashesResponse] parsed result object
142
+ # @yieldparam err [StandardError] error object if request failed
143
+ #
144
+ # @return [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindFullHashesResponse]
145
+ #
146
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
147
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
148
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
149
+ def find_full_hashes(google_security_safebrowsing_v4_find_full_hashes_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
150
+ command = make_simple_command(:post, 'v4/fullHashes:find', options)
151
+ command.request_representation = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindFullHashesRequest::Representation
152
+ command.request_object = google_security_safebrowsing_v4_find_full_hashes_request_object
153
+ command.response_representation = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindFullHashesResponse::Representation
154
+ command.response_class = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindFullHashesResponse
155
+ command.query['fields'] = fields unless fields.nil?
156
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
157
+ execute_or_queue_command(command, &block)
158
+ end
159
+
160
+ # Reports a Safe Browsing threat list hit to Google. Only projects with
161
+ # TRUSTED_REPORTER visibility can use this method.
162
+ # @param [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4ThreatHit] google_security_safebrowsing_v4_threat_hit_object
163
+ # @param [String] fields
164
+ # Selector specifying which fields to include in a partial response.
165
+ # @param [String] quota_user
166
+ # Available to use for quota purposes for server-side applications. Can be any
167
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
168
+ # @param [Google::Apis::RequestOptions] options
169
+ # Request-specific options
170
+ #
171
+ # @yield [result, err] Result & error if block supplied
172
+ # @yieldparam result [Google::Apis::SafebrowsingV4::GoogleProtobufEmpty] parsed result object
173
+ # @yieldparam err [StandardError] error object if request failed
174
+ #
175
+ # @return [Google::Apis::SafebrowsingV4::GoogleProtobufEmpty]
176
+ #
177
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
178
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
179
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
180
+ def create_threat_hit(google_security_safebrowsing_v4_threat_hit_object = nil, fields: nil, quota_user: nil, options: nil, &block)
181
+ command = make_simple_command(:post, 'v4/threatHits', options)
182
+ command.request_representation = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4ThreatHit::Representation
183
+ command.request_object = google_security_safebrowsing_v4_threat_hit_object
184
+ command.response_representation = Google::Apis::SafebrowsingV4::GoogleProtobufEmpty::Representation
185
+ command.response_class = Google::Apis::SafebrowsingV4::GoogleProtobufEmpty
186
+ command.query['fields'] = fields unless fields.nil?
187
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
188
+ execute_or_queue_command(command, &block)
189
+ end
190
+
191
+ # Fetches the most recent threat list updates. A client can request updates for
192
+ # multiple lists at once.
193
+ # @param [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FetchThreatListUpdatesRequest] google_security_safebrowsing_v4_fetch_threat_list_updates_request_object
194
+ # @param [String] fields
195
+ # Selector specifying which fields to include in a partial response.
196
+ # @param [String] quota_user
197
+ # Available to use for quota purposes for server-side applications. Can be any
198
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
199
+ # @param [Google::Apis::RequestOptions] options
200
+ # Request-specific options
201
+ #
202
+ # @yield [result, err] Result & error if block supplied
203
+ # @yieldparam result [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FetchThreatListUpdatesResponse] parsed result object
204
+ # @yieldparam err [StandardError] error object if request failed
205
+ #
206
+ # @return [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FetchThreatListUpdatesResponse]
207
+ #
208
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
209
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
210
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
211
+ def fetch_threat_list_updates(google_security_safebrowsing_v4_fetch_threat_list_updates_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
212
+ command = make_simple_command(:post, 'v4/threatListUpdates:fetch', options)
213
+ command.request_representation = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FetchThreatListUpdatesRequest::Representation
214
+ command.request_object = google_security_safebrowsing_v4_fetch_threat_list_updates_request_object
215
+ command.response_representation = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FetchThreatListUpdatesResponse::Representation
216
+ command.response_class = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FetchThreatListUpdatesResponse
217
+ command.query['fields'] = fields unless fields.nil?
218
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
219
+ execute_or_queue_command(command, &block)
220
+ end
221
+
222
+ # Lists the Safe Browsing threat lists available for download.
223
+ # @param [String] fields
224
+ # Selector specifying which fields to include in a partial response.
225
+ # @param [String] quota_user
226
+ # Available to use for quota purposes for server-side applications. Can be any
227
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
228
+ # @param [Google::Apis::RequestOptions] options
229
+ # Request-specific options
230
+ #
231
+ # @yield [result, err] Result & error if block supplied
232
+ # @yieldparam result [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4ListThreatListsResponse] parsed result object
233
+ # @yieldparam err [StandardError] error object if request failed
234
+ #
235
+ # @return [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4ListThreatListsResponse]
236
+ #
237
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
238
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
239
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
240
+ def list_threat_lists(fields: nil, quota_user: nil, options: nil, &block)
241
+ command = make_simple_command(:get, 'v4/threatLists', options)
242
+ command.response_representation = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4ListThreatListsResponse::Representation
243
+ command.response_class = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4ListThreatListsResponse
244
+ command.query['fields'] = fields unless fields.nil?
245
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
246
+ execute_or_queue_command(command, &block)
247
+ end
248
+
249
+ # Finds the threat entries that match the Safe Browsing lists.
250
+ # @param [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindThreatMatchesRequest] google_security_safebrowsing_v4_find_threat_matches_request_object
251
+ # @param [String] fields
252
+ # Selector specifying which fields to include in a partial response.
253
+ # @param [String] quota_user
254
+ # Available to use for quota purposes for server-side applications. Can be any
255
+ # arbitrary string assigned to a user, but should not exceed 40 characters.
256
+ # @param [Google::Apis::RequestOptions] options
257
+ # Request-specific options
258
+ #
259
+ # @yield [result, err] Result & error if block supplied
260
+ # @yieldparam result [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindThreatMatchesResponse] parsed result object
261
+ # @yieldparam err [StandardError] error object if request failed
262
+ #
263
+ # @return [Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindThreatMatchesResponse]
264
+ #
265
+ # @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
266
+ # @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
267
+ # @raise [Google::Apis::AuthorizationError] Authorization is required
268
+ def find_threat_matches(google_security_safebrowsing_v4_find_threat_matches_request_object = nil, fields: nil, quota_user: nil, options: nil, &block)
269
+ command = make_simple_command(:post, 'v4/threatMatches:find', options)
270
+ command.request_representation = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindThreatMatchesRequest::Representation
271
+ command.request_object = google_security_safebrowsing_v4_find_threat_matches_request_object
272
+ command.response_representation = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindThreatMatchesResponse::Representation
273
+ command.response_class = Google::Apis::SafebrowsingV4::GoogleSecuritySafebrowsingV4FindThreatMatchesResponse
274
+ command.query['fields'] = fields unless fields.nil?
275
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
276
+ execute_or_queue_command(command, &block)
277
+ end
278
+
279
+ protected
280
+
281
+ def apply_command_defaults(command)
282
+ command.query['key'] = key unless key.nil?
283
+ command.query['quotaUser'] = quota_user unless quota_user.nil?
284
+ end
285
+ end
286
+ end
287
+ end
288
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: google-apis-safebrowsing_v4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Google LLC
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: google-apis-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
27
+ description: This is the simple REST client for Safe Browsing API V4. Simple REST
28
+ clients are Ruby client libraries that provide access to Google services via their
29
+ HTTP REST API endpoints. These libraries are generated and updated automatically
30
+ based on the discovery documents published by the service, and they handle most
31
+ concerns such as authentication, pagination, retry, timeouts, and logging. You can
32
+ use this client to access the Safe Browsing API, but note that some services may
33
+ provide a separate modern client that is easier to use.
34
+ email: googleapis-packages@google.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - ".yardopts"
40
+ - CHANGELOG.md
41
+ - LICENSE.md
42
+ - OVERVIEW.md
43
+ - lib/google-apis-safebrowsing_v4.rb
44
+ - lib/google/apis/safebrowsing_v4.rb
45
+ - lib/google/apis/safebrowsing_v4/classes.rb
46
+ - lib/google/apis/safebrowsing_v4/gem_version.rb
47
+ - lib/google/apis/safebrowsing_v4/representations.rb
48
+ - lib/google/apis/safebrowsing_v4/service.rb
49
+ homepage: https://github.com/google/google-api-ruby-client
50
+ licenses:
51
+ - Apache-2.0
52
+ metadata:
53
+ bug_tracker_uri: https://github.com/googleapis/google-api-ruby-client/issues
54
+ changelog_uri: https://github.com/googleapis/google-api-ruby-client/tree/master/generated/google-apis-safebrowsing_v4/CHANGELOG.md
55
+ documentation_uri: https://googleapis.dev/ruby/google-apis-safebrowsing_v4/v0.1.0
56
+ source_code_uri: https://github.com/googleapis/google-api-ruby-client/tree/master/generated/google-apis-safebrowsing_v4
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '2.4'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubygems_version: 3.1.4
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Simple REST client for Safe Browsing API V4
76
+ test_files: []