google-cloud-phishing_protection-v1beta1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
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
+ # This gem does not autoload during Bundler.require. To load this gem,
20
+ # issue explicit require statements for the packages desired, e.g.:
21
+ # require "google/cloud/phishing_protection/v1beta1"
@@ -0,0 +1,35 @@
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/phishing_protection/v1beta1/phishing_protection_service"
20
+ require "google/cloud/phishing_protection/v1beta1/version"
21
+
22
+ module Google
23
+ module Cloud
24
+ module PhishingProtection
25
+ ##
26
+ # To load this package, including all its services, and instantiate a client:
27
+ #
28
+ # require "google/cloud/phishing_protection/v1beta1"
29
+ # client = ::Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionService::Client.new
30
+ #
31
+ module V1beta1
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,49 @@
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 "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/phishing_protection/v1beta1/version"
24
+
25
+ require "google/cloud/phishing_protection/v1beta1/phishing_protection_service/credentials"
26
+ require "google/cloud/phishing_protection/v1beta1/phishing_protection_service/paths"
27
+ require "google/cloud/phishing_protection/v1beta1/phishing_protection_service/client"
28
+
29
+ module Google
30
+ module Cloud
31
+ module PhishingProtection
32
+ module V1beta1
33
+ ##
34
+ # Service to report phishing URIs.
35
+ #
36
+ # To load this service and instantiate a client:
37
+ #
38
+ # require "google/cloud/phishing_protection/v1beta1/phishing_protection_service"
39
+ # client = ::Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionService::Client.new
40
+ #
41
+ module PhishingProtectionService
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ helper_path = ::File.join __dir__, "phishing_protection_service", "helpers.rb"
49
+ require "google/cloud/phishing_protection/v1beta1/phishing_protection_service/helpers" if ::File.file? helper_path
@@ -0,0 +1,380 @@
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/phishingprotection/v1beta1/phishingprotection_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module PhishingProtection
25
+ module V1beta1
26
+ module PhishingProtectionService
27
+ ##
28
+ # Client for the PhishingProtectionService service.
29
+ #
30
+ # Service to report phishing URIs.
31
+ #
32
+ class Client
33
+ include Paths
34
+
35
+ # @private
36
+ attr_reader :phishing_protection_service_stub
37
+
38
+ ##
39
+ # Configure the PhishingProtectionService Client class.
40
+ #
41
+ # See {::Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionService::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # ## Example
45
+ #
46
+ # To modify the configuration for all PhishingProtectionService clients:
47
+ #
48
+ # ::Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionService::Client.configure do |config|
49
+ # config.timeout = 10.0
50
+ # end
51
+ #
52
+ # @yield [config] Configure the Client client.
53
+ # @yieldparam config [Client::Configuration]
54
+ #
55
+ # @return [Client::Configuration]
56
+ #
57
+ def self.configure
58
+ @configure ||= begin
59
+ namespace = ["Google", "Cloud", "PhishingProtection", "V1beta1"]
60
+ parent_config = while namespace.any?
61
+ parent_name = namespace.join "::"
62
+ parent_const = const_get parent_name
63
+ break parent_const.configure if parent_const&.respond_to? :configure
64
+ namespace.pop
65
+ end
66
+ default_config = Client::Configuration.new parent_config
67
+
68
+ default_config.rpcs.report_phishing.timeout = 600.0
69
+
70
+ default_config
71
+ end
72
+ yield @configure if block_given?
73
+ @configure
74
+ end
75
+
76
+ ##
77
+ # Configure the PhishingProtectionService Client instance.
78
+ #
79
+ # The configuration is set to the derived mode, meaning that values can be changed,
80
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
81
+ # should be made on {Client.configure}.
82
+ #
83
+ # See {::Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionService::Client::Configuration}
84
+ # for a description of the configuration fields.
85
+ #
86
+ # @yield [config] Configure the Client client.
87
+ # @yieldparam config [Client::Configuration]
88
+ #
89
+ # @return [Client::Configuration]
90
+ #
91
+ def configure
92
+ yield @config if block_given?
93
+ @config
94
+ end
95
+
96
+ ##
97
+ # Create a new PhishingProtectionService client object.
98
+ #
99
+ # ## Examples
100
+ #
101
+ # To create a new PhishingProtectionService client with the default
102
+ # configuration:
103
+ #
104
+ # client = ::Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionService::Client.new
105
+ #
106
+ # To create a new PhishingProtectionService client with a custom
107
+ # configuration:
108
+ #
109
+ # client = ::Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionService::Client.new do |config|
110
+ # config.timeout = 10.0
111
+ # end
112
+ #
113
+ # @yield [config] Configure the PhishingProtectionService client.
114
+ # @yieldparam config [Client::Configuration]
115
+ #
116
+ def initialize
117
+ # These require statements are intentionally placed here to initialize
118
+ # the gRPC module only when it's required.
119
+ # See https://github.com/googleapis/toolkit/issues/446
120
+ require "gapic/grpc"
121
+ require "google/cloud/phishingprotection/v1beta1/phishingprotection_services_pb"
122
+
123
+ # Create the configuration object
124
+ @config = Configuration.new Client.configure
125
+
126
+ # Yield the configuration if needed
127
+ yield @config if block_given?
128
+
129
+ # Create credentials
130
+ credentials = @config.credentials
131
+ credentials ||= Credentials.default scope: @config.scope
132
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
133
+ credentials = Credentials.new credentials, scope: @config.scope
134
+ end
135
+ @quota_project_id = @config.quota_project
136
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
137
+
138
+ @phishing_protection_service_stub = ::Gapic::ServiceStub.new(
139
+ ::Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionServiceV1Beta1::Stub,
140
+ credentials: credentials,
141
+ endpoint: @config.endpoint,
142
+ channel_args: @config.channel_args,
143
+ interceptors: @config.interceptors
144
+ )
145
+ end
146
+
147
+ # Service calls
148
+
149
+ ##
150
+ # Reports a URI suspected of containing phishing content to be reviewed. Once
151
+ # the report review is complete, its result can be found in the Cloud
152
+ # Security Command Center findings dashboard for Phishing Protection. If the
153
+ # result verifies the existence of malicious phishing content, the site will
154
+ # be added the to [Google's Social Engineering
155
+ # lists](https://support.google.com/webmasters/answer/6350487/) in order to
156
+ # protect users that could get exposed to this threat in the future.
157
+ #
158
+ # @overload report_phishing(request, options = nil)
159
+ # Pass arguments to `report_phishing` via a request object, either of type
160
+ # {::Google::Cloud::PhishingProtection::V1beta1::ReportPhishingRequest} or an equivalent Hash.
161
+ #
162
+ # @param request [::Google::Cloud::PhishingProtection::V1beta1::ReportPhishingRequest, ::Hash]
163
+ # A request object representing the call parameters. Required. To specify no
164
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
165
+ # @param options [::Gapic::CallOptions, ::Hash]
166
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
167
+ #
168
+ # @overload report_phishing(parent: nil, uri: nil)
169
+ # Pass arguments to `report_phishing` via keyword arguments. Note that at
170
+ # least one keyword argument is required. To specify no parameters, or to keep all
171
+ # the default parameter values, pass an empty Hash as a request object (see above).
172
+ #
173
+ # @param parent [::String]
174
+ # Required. The name of the project for which the report will be created,
175
+ # in the format "projects/\\{project_number}".
176
+ # @param uri [::String]
177
+ # Required. The URI that is being reported for phishing content to be analyzed.
178
+ #
179
+ # @yield [response, operation] Access the result along with the RPC operation
180
+ # @yieldparam response [::Google::Cloud::PhishingProtection::V1beta1::ReportPhishingResponse]
181
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
182
+ #
183
+ # @return [::Google::Cloud::PhishingProtection::V1beta1::ReportPhishingResponse]
184
+ #
185
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
186
+ #
187
+ def report_phishing request, options = nil
188
+ raise ::ArgumentError, "request must be provided" if request.nil?
189
+
190
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PhishingProtection::V1beta1::ReportPhishingRequest
191
+
192
+ # Converts hash and nil to an options object
193
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
194
+
195
+ # Customize the options with defaults
196
+ metadata = @config.rpcs.report_phishing.metadata.to_h
197
+
198
+ # Set x-goog-api-client and x-goog-user-project headers
199
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
200
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
201
+ gapic_version: ::Google::Cloud::PhishingProtection::V1beta1::VERSION
202
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
203
+
204
+ header_params = {
205
+ "parent" => request.parent
206
+ }
207
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
208
+ metadata[:"x-goog-request-params"] ||= request_params_header
209
+
210
+ options.apply_defaults timeout: @config.rpcs.report_phishing.timeout,
211
+ metadata: metadata,
212
+ retry_policy: @config.rpcs.report_phishing.retry_policy
213
+ options.apply_defaults metadata: @config.metadata,
214
+ retry_policy: @config.retry_policy
215
+
216
+ @phishing_protection_service_stub.call_rpc :report_phishing, request, options: options do |response, operation|
217
+ yield response, operation if block_given?
218
+ return response
219
+ end
220
+ rescue ::GRPC::BadStatus => e
221
+ raise ::Google::Cloud::Error.from_error(e)
222
+ end
223
+
224
+ ##
225
+ # Configuration class for the PhishingProtectionService API.
226
+ #
227
+ # This class represents the configuration for PhishingProtectionService,
228
+ # providing control over timeouts, retry behavior, logging, transport
229
+ # parameters, and other low-level controls. Certain parameters can also be
230
+ # applied individually to specific RPCs. See
231
+ # {::Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionService::Client::Configuration::Rpcs}
232
+ # for a list of RPCs that can be configured independently.
233
+ #
234
+ # Configuration can be applied globally to all clients, or to a single client
235
+ # on construction.
236
+ #
237
+ # # Examples
238
+ #
239
+ # To modify the global config, setting the timeout for report_phishing
240
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
241
+ #
242
+ # ::Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionService::Client.configure do |config|
243
+ # config.timeout = 10.0
244
+ # config.rpcs.report_phishing.timeout = 20.0
245
+ # end
246
+ #
247
+ # To apply the above configuration only to a new client:
248
+ #
249
+ # client = ::Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionService::Client.new do |config|
250
+ # config.timeout = 10.0
251
+ # config.rpcs.report_phishing.timeout = 20.0
252
+ # end
253
+ #
254
+ # @!attribute [rw] endpoint
255
+ # The hostname or hostname:port of the service endpoint.
256
+ # Defaults to `"phishingprotection.googleapis.com"`.
257
+ # @return [::String]
258
+ # @!attribute [rw] credentials
259
+ # Credentials to send with calls. You may provide any of the following types:
260
+ # * (`String`) The path to a service account key file in JSON format
261
+ # * (`Hash`) A service account key as a Hash
262
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
263
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
264
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
265
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
266
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
267
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
268
+ # * (`nil`) indicating no credentials
269
+ # @return [::Object]
270
+ # @!attribute [rw] scope
271
+ # The OAuth scopes
272
+ # @return [::Array<::String>]
273
+ # @!attribute [rw] lib_name
274
+ # The library name as recorded in instrumentation and logging
275
+ # @return [::String]
276
+ # @!attribute [rw] lib_version
277
+ # The library version as recorded in instrumentation and logging
278
+ # @return [::String]
279
+ # @!attribute [rw] channel_args
280
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
281
+ # `GRPC::Core::Channel` object is provided as the credential.
282
+ # @return [::Hash]
283
+ # @!attribute [rw] interceptors
284
+ # An array of interceptors that are run before calls are executed.
285
+ # @return [::Array<::GRPC::ClientInterceptor>]
286
+ # @!attribute [rw] timeout
287
+ # The call timeout in seconds.
288
+ # @return [::Numeric]
289
+ # @!attribute [rw] metadata
290
+ # Additional gRPC headers to be sent with the call.
291
+ # @return [::Hash{::Symbol=>::String}]
292
+ # @!attribute [rw] retry_policy
293
+ # The retry policy. The value is a hash with the following keys:
294
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
295
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
296
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
297
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
298
+ # trigger a retry.
299
+ # @return [::Hash]
300
+ # @!attribute [rw] quota_project
301
+ # A separate project against which to charge quota.
302
+ # @return [::String]
303
+ #
304
+ class Configuration
305
+ extend ::Gapic::Config
306
+
307
+ config_attr :endpoint, "phishingprotection.googleapis.com", ::String
308
+ config_attr :credentials, nil do |value|
309
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
310
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
311
+ allowed.any? { |klass| klass === value }
312
+ end
313
+ config_attr :scope, nil, ::String, ::Array, nil
314
+ config_attr :lib_name, nil, ::String, nil
315
+ config_attr :lib_version, nil, ::String, nil
316
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
317
+ config_attr :interceptors, nil, ::Array, nil
318
+ config_attr :timeout, nil, ::Numeric, nil
319
+ config_attr :metadata, nil, ::Hash, nil
320
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
321
+ config_attr :quota_project, nil, ::String, nil
322
+
323
+ # @private
324
+ def initialize parent_config = nil
325
+ @parent_config = parent_config unless parent_config.nil?
326
+
327
+ yield self if block_given?
328
+ end
329
+
330
+ ##
331
+ # Configurations for individual RPCs
332
+ # @return [Rpcs]
333
+ #
334
+ def rpcs
335
+ @rpcs ||= begin
336
+ parent_rpcs = nil
337
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
338
+ Rpcs.new parent_rpcs
339
+ end
340
+ end
341
+
342
+ ##
343
+ # Configuration RPC class for the PhishingProtectionService API.
344
+ #
345
+ # Includes fields providing the configuration for each RPC in this service.
346
+ # Each configuration object is of type `Gapic::Config::Method` and includes
347
+ # the following configuration fields:
348
+ #
349
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
350
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
351
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
352
+ # include the following keys:
353
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
354
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
355
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
356
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
357
+ # trigger a retry.
358
+ #
359
+ class Rpcs
360
+ ##
361
+ # RPC-specific configuration for `report_phishing`
362
+ # @return [::Gapic::Config::Method]
363
+ #
364
+ attr_reader :report_phishing
365
+
366
+ # @private
367
+ def initialize parent_rpcs = nil
368
+ report_phishing_config = parent_rpcs&.report_phishing if parent_rpcs&.respond_to? :report_phishing
369
+ @report_phishing = ::Gapic::Config::Method.new report_phishing_config
370
+
371
+ yield self if block_given?
372
+ end
373
+ end
374
+ end
375
+ end
376
+ end
377
+ end
378
+ end
379
+ end
380
+ end