google-cloud-phishing_protection 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,140 @@
1
+ # Copyright 2019 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
+ # https://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
+
16
+ require "google/gax"
17
+ require "pathname"
18
+
19
+ module Google
20
+ module Cloud
21
+ # rubocop:disable LineLength
22
+
23
+ ##
24
+ # # Ruby Client for Phishing Protection API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
25
+ #
26
+ # [Phishing Protection API][Product Documentation]:
27
+ #
28
+ # - [Product Documentation][]
29
+ #
30
+ # ## Quick Start
31
+ # In order to use this library, you first need to go through the following
32
+ # steps:
33
+ #
34
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
35
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
36
+ # 3. [Enable the Phishing Protection API.](https://console.cloud.google.com/apis/library/phishingprotection.googleapis.com)
37
+ # 4. [Setup Authentication.](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
38
+ #
39
+ # ### Installation
40
+ # ```
41
+ # $ gem install google-cloud-phishing_protection
42
+ # ```
43
+ #
44
+ # ### Next Steps
45
+ # - Read the [Phishing Protection API Product documentation][Product Documentation]
46
+ # to learn more about the product and see How-to Guides.
47
+ # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
48
+ # to see the full list of Cloud APIs that we cover.
49
+ #
50
+ # [Product Documentation]: https://cloud.google.com/phishingprotection
51
+ #
52
+ # ## Enabling Logging
53
+ #
54
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
55
+ # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
56
+ # or a [`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
57
+ # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
58
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
59
+ #
60
+ # Configuring a Ruby stdlib logger:
61
+ #
62
+ # ```ruby
63
+ # require "logger"
64
+ #
65
+ # module MyLogger
66
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
67
+ # def logger
68
+ # LOGGER
69
+ # end
70
+ # end
71
+ #
72
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
73
+ # module GRPC
74
+ # extend MyLogger
75
+ # end
76
+ # ```
77
+ #
78
+ module PhishingProtection
79
+ # rubocop:enable LineLength
80
+
81
+ FILE_DIR = File.realdirpath(Pathname.new(__FILE__).join("..").join("phishing_protection"))
82
+
83
+ AVAILABLE_VERSIONS = Dir["#{FILE_DIR}/*"]
84
+ .select { |file| File.directory?(file) }
85
+ .select { |dir| Google::Gax::VERSION_MATCHER.match(File.basename(dir)) }
86
+ .select { |dir| File.exist?(dir + ".rb") }
87
+ .map { |dir| File.basename(dir) }
88
+
89
+ ##
90
+ # Service to report phishing URIs.
91
+ #
92
+ # @param version [Symbol, String]
93
+ # The major version of the service to be used. By default :v1beta1
94
+ # is used.
95
+ # @overload new(version:, credentials:, scopes:, client_config:, timeout:)
96
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
97
+ # Provides the means for authenticating requests made by the client. This parameter can
98
+ # be many types.
99
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
100
+ # authenticating requests made by this client.
101
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
102
+ # credentials for this client.
103
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
104
+ # credentials for this client.
105
+ # A `GRPC::Core::Channel` will be used to make calls through.
106
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
107
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
108
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
109
+ # metadata for requests, generally, to give OAuth credentials.
110
+ # @param scopes [Array<String>]
111
+ # The OAuth scopes for this service. This parameter is ignored if
112
+ # an updater_proc is supplied.
113
+ # @param client_config [Hash]
114
+ # A Hash for call options for each method. See
115
+ # Google::Gax#construct_settings for the structure of
116
+ # this data. Falls back to the default config if not specified
117
+ # or the specified config is missing data points.
118
+ # @param timeout [Numeric]
119
+ # The default timeout, in seconds, for calls made through this client.
120
+ # @param metadata [Hash]
121
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
122
+ # @param exception_transformer [Proc]
123
+ # An optional proc that intercepts any exceptions raised during an API call to inject
124
+ # custom error handling.
125
+ def self.new(*args, version: :v1beta1, **kwargs)
126
+ unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
127
+ raise "The version: #{version} is not available. The available versions " \
128
+ "are: [#{AVAILABLE_VERSIONS.join(", ")}]"
129
+ end
130
+
131
+ require "#{FILE_DIR}/#{version.to_s.downcase}"
132
+ version_module = Google::Cloud::PhishingProtection
133
+ .constants
134
+ .select {|sym| sym.to_s.downcase == version.to_s.downcase}
135
+ .first
136
+ Google::Cloud::PhishingProtection.const_get(version_module).new(*args, **kwargs)
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,138 @@
1
+ # Copyright 2019 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
+ # https://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
+
16
+ require "google/cloud/phishing_protection/v1beta1/phishing_protection_client"
17
+ require "google/cloud/phishing_protection/v1beta1/helpers"
18
+
19
+ module Google
20
+ module Cloud
21
+ module PhishingProtection
22
+ # rubocop:disable LineLength
23
+
24
+ ##
25
+ # # Ruby Client for Phishing Protection API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
26
+ #
27
+ # [Phishing Protection API][Product Documentation]:
28
+ #
29
+ # - [Product Documentation][]
30
+ #
31
+ # ## Quick Start
32
+ # In order to use this library, you first need to go through the following
33
+ # steps:
34
+ #
35
+ # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
36
+ # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
37
+ # 3. [Enable the Phishing Protection API.](https://console.cloud.google.com/apis/library/phishingprotection.googleapis.com)
38
+ # 4. [Setup Authentication.](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
39
+ #
40
+ # ### Installation
41
+ # ```
42
+ # $ gem install google-cloud-phishing_protection
43
+ # ```
44
+ #
45
+ # ### Next Steps
46
+ # - Read the [Phishing Protection API Product documentation][Product Documentation]
47
+ # to learn more about the product and see How-to Guides.
48
+ # - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
49
+ # to see the full list of Cloud APIs that we cover.
50
+ #
51
+ # [Product Documentation]: https://cloud.google.com/phishingprotection
52
+ #
53
+ # ## Enabling Logging
54
+ #
55
+ # To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
56
+ # The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
57
+ # or a [`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
58
+ # that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
59
+ # and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
60
+ #
61
+ # Configuring a Ruby stdlib logger:
62
+ #
63
+ # ```ruby
64
+ # require "logger"
65
+ #
66
+ # module MyLogger
67
+ # LOGGER = Logger.new $stderr, level: Logger::WARN
68
+ # def logger
69
+ # LOGGER
70
+ # end
71
+ # end
72
+ #
73
+ # # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
74
+ # module GRPC
75
+ # extend MyLogger
76
+ # end
77
+ # ```
78
+ #
79
+ module V1beta1
80
+ # rubocop:enable LineLength
81
+
82
+ ##
83
+ # Service to report phishing URIs.
84
+ #
85
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
86
+ # Provides the means for authenticating requests made by the client. This parameter can
87
+ # be many types.
88
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
89
+ # authenticating requests made by this client.
90
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
91
+ # credentials for this client.
92
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
93
+ # credentials for this client.
94
+ # A `GRPC::Core::Channel` will be used to make calls through.
95
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
96
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
97
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
98
+ # metadata for requests, generally, to give OAuth credentials.
99
+ # @param scopes [Array<String>]
100
+ # The OAuth scopes for this service. This parameter is ignored if
101
+ # an updater_proc is supplied.
102
+ # @param client_config [Hash]
103
+ # A Hash for call options for each method. See
104
+ # Google::Gax#construct_settings for the structure of
105
+ # this data. Falls back to the default config if not specified
106
+ # or the specified config is missing data points.
107
+ # @param timeout [Numeric]
108
+ # The default timeout, in seconds, for calls made through this client.
109
+ # @param metadata [Hash]
110
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
111
+ # @param exception_transformer [Proc]
112
+ # An optional proc that intercepts any exceptions raised during an API call to inject
113
+ # custom error handling.
114
+ def self.new \
115
+ credentials: nil,
116
+ scopes: nil,
117
+ client_config: nil,
118
+ timeout: nil,
119
+ metadata: nil,
120
+ exception_transformer: nil,
121
+ lib_name: nil,
122
+ lib_version: nil
123
+ kwargs = {
124
+ credentials: credentials,
125
+ scopes: scopes,
126
+ client_config: client_config,
127
+ timeout: timeout,
128
+ metadata: metadata,
129
+ exception_transformer: exception_transformer,
130
+ lib_name: lib_name,
131
+ lib_version: lib_version
132
+ }.select { |_, v| v != nil }
133
+ Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionClient.new(**kwargs)
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,41 @@
1
+ # Copyright 2019 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
+ # https://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
+
16
+ require "googleauth"
17
+
18
+ module Google
19
+ module Cloud
20
+ module PhishingProtection
21
+ module V1beta1
22
+ class Credentials < Google::Auth::Credentials
23
+ SCOPE = [
24
+ "https://www.googleapis.com/auth/cloud-platform"
25
+ ].freeze
26
+ PATH_ENV_VARS = %w(PHISHING_PROTECTION_CREDENTIALS
27
+ PHISHING_PROTECTION_KEYFILE
28
+ GOOGLE_CLOUD_CREDENTIALS
29
+ GOOGLE_CLOUD_KEYFILE
30
+ GCLOUD_KEYFILE)
31
+ JSON_ENV_VARS = %w(PHISHING_PROTECTION_CREDENTIALS_JSON
32
+ PHISHING_PROTECTION_KEYFILE_JSON
33
+ GOOGLE_CLOUD_CREDENTIALS_JSON
34
+ GOOGLE_CLOUD_KEYFILE_JSON
35
+ GCLOUD_KEYFILE_JSON)
36
+ DEFAULT_PATHS = ["~/.config/gcloud/application_default_credentials.json"]
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,35 @@
1
+ # Copyright 2019 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
+ # https://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
+
16
+ module Google
17
+ module Cloud
18
+ module Phishingprotection
19
+ module V1beta1
20
+ # The ReportPhishing request message.
21
+ # @!attribute [rw] parent
22
+ # @return [String]
23
+ # Required. The name of the project for which the report will be created,
24
+ # in the format "projects/\\{project_number}".
25
+ # @!attribute [rw] uri
26
+ # @return [String]
27
+ # The URI that is being reported for phishing content to be analyzed.
28
+ class ReportPhishingRequest; end
29
+
30
+ # The ReportPhishing (empty) response message.
31
+ class ReportPhishingResponse; end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,31 @@
1
+ # Copyright 2018 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
+ # https://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
+ module Google
16
+ module Cloud
17
+ module PhishingProtection
18
+ module V1beta1
19
+ class PhishingProtectionClient
20
+
21
+ # Alias for Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionClient.project_path.
22
+ # @param project [String]
23
+ # @return [String]
24
+ def project_path project
25
+ self.class.project_path project
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,236 @@
1
+ # Copyright 2019 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
+ # https://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
+ # EDITING INSTRUCTIONS
16
+ # This file was generated from the file
17
+ # https://github.com/googleapis/googleapis/blob/master/google/cloud/phishingprotection/v1beta1/phishingprotection.proto,
18
+ # and updates to that file get reflected here through a refresh process.
19
+ # For the short term, the refresh process will only be runnable by Google
20
+ # engineers.
21
+
22
+
23
+ require "json"
24
+ require "pathname"
25
+
26
+ require "google/gax"
27
+
28
+ require "google/cloud/phishingprotection/v1beta1/phishingprotection_pb"
29
+ require "google/cloud/phishing_protection/v1beta1/credentials"
30
+
31
+ module Google
32
+ module Cloud
33
+ module PhishingProtection
34
+ module V1beta1
35
+ # Service to report phishing URIs.
36
+ #
37
+ # @!attribute [r] phishing_protection_stub
38
+ # @return [Google::Cloud::Phishingprotection::V1beta1::PhishingProtection::Stub]
39
+ class PhishingProtectionClient
40
+ # @private
41
+ attr_reader :phishing_protection_stub
42
+
43
+ # The default address of the service.
44
+ SERVICE_ADDRESS = "phishingprotection.googleapis.com".freeze
45
+
46
+ # The default port of the service.
47
+ DEFAULT_SERVICE_PORT = 443
48
+
49
+ # The default set of gRPC interceptors.
50
+ GRPC_INTERCEPTORS = []
51
+
52
+ DEFAULT_TIMEOUT = 30
53
+
54
+ # The scopes needed to make gRPC calls to all of the methods defined in
55
+ # this service.
56
+ ALL_SCOPES = [
57
+ "https://www.googleapis.com/auth/cloud-platform"
58
+ ].freeze
59
+
60
+
61
+ PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
62
+ "projects/{project}"
63
+ )
64
+
65
+ private_constant :PROJECT_PATH_TEMPLATE
66
+
67
+ # Returns a fully-qualified project resource name string.
68
+ # @param project [String]
69
+ # @return [String]
70
+ def self.project_path project
71
+ PROJECT_PATH_TEMPLATE.render(
72
+ :"project" => project
73
+ )
74
+ end
75
+
76
+ # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
77
+ # Provides the means for authenticating requests made by the client. This parameter can
78
+ # be many types.
79
+ # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
80
+ # authenticating requests made by this client.
81
+ # A `String` will be treated as the path to the keyfile to be used for the construction of
82
+ # credentials for this client.
83
+ # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
84
+ # credentials for this client.
85
+ # A `GRPC::Core::Channel` will be used to make calls through.
86
+ # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
87
+ # should already be composed with a `GRPC::Core::CallCredentials` object.
88
+ # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
89
+ # metadata for requests, generally, to give OAuth credentials.
90
+ # @param scopes [Array<String>]
91
+ # The OAuth scopes for this service. This parameter is ignored if
92
+ # an updater_proc is supplied.
93
+ # @param client_config [Hash]
94
+ # A Hash for call options for each method. See
95
+ # Google::Gax#construct_settings for the structure of
96
+ # this data. Falls back to the default config if not specified
97
+ # or the specified config is missing data points.
98
+ # @param timeout [Numeric]
99
+ # The default timeout, in seconds, for calls made through this client.
100
+ # @param metadata [Hash]
101
+ # Default metadata to be sent with each request. This can be overridden on a per call basis.
102
+ # @param exception_transformer [Proc]
103
+ # An optional proc that intercepts any exceptions raised during an API call to inject
104
+ # custom error handling.
105
+ def initialize \
106
+ credentials: nil,
107
+ scopes: ALL_SCOPES,
108
+ client_config: {},
109
+ timeout: DEFAULT_TIMEOUT,
110
+ metadata: nil,
111
+ exception_transformer: nil,
112
+ lib_name: nil,
113
+ lib_version: ""
114
+ # These require statements are intentionally placed here to initialize
115
+ # the gRPC module only when it's required.
116
+ # See https://github.com/googleapis/toolkit/issues/446
117
+ require "google/gax/grpc"
118
+ require "google/cloud/phishingprotection/v1beta1/phishingprotection_services_pb"
119
+
120
+ credentials ||= Google::Cloud::PhishingProtection::V1beta1::Credentials.default
121
+
122
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
123
+ updater_proc = Google::Cloud::PhishingProtection::V1beta1::Credentials.new(credentials).updater_proc
124
+ end
125
+ if credentials.is_a?(GRPC::Core::Channel)
126
+ channel = credentials
127
+ end
128
+ if credentials.is_a?(GRPC::Core::ChannelCredentials)
129
+ chan_creds = credentials
130
+ end
131
+ if credentials.is_a?(Proc)
132
+ updater_proc = credentials
133
+ end
134
+ if credentials.is_a?(Google::Auth::Credentials)
135
+ updater_proc = credentials.updater_proc
136
+ end
137
+
138
+ package_version = Gem.loaded_specs['google-cloud-phishing_protection'].version.version
139
+
140
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
141
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
142
+ google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
143
+ google_api_client << " grpc/#{GRPC::VERSION}"
144
+ google_api_client.freeze
145
+
146
+ headers = { :"x-goog-api-client" => google_api_client }
147
+ headers.merge!(metadata) unless metadata.nil?
148
+ client_config_file = Pathname.new(__dir__).join(
149
+ "phishing_protection_client_config.json"
150
+ )
151
+ defaults = client_config_file.open do |f|
152
+ Google::Gax.construct_settings(
153
+ "google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1",
154
+ JSON.parse(f.read),
155
+ client_config,
156
+ Google::Gax::Grpc::STATUS_CODE_NAMES,
157
+ timeout,
158
+ errors: Google::Gax::Grpc::API_ERRORS,
159
+ metadata: headers
160
+ )
161
+ end
162
+
163
+ # Allow overriding the service path/port in subclasses.
164
+ service_path = self.class::SERVICE_ADDRESS
165
+ port = self.class::DEFAULT_SERVICE_PORT
166
+ interceptors = self.class::GRPC_INTERCEPTORS
167
+ @phishing_protection_stub = Google::Gax::Grpc.create_stub(
168
+ service_path,
169
+ port,
170
+ chan_creds: chan_creds,
171
+ channel: channel,
172
+ updater_proc: updater_proc,
173
+ scopes: scopes,
174
+ interceptors: interceptors,
175
+ &Google::Cloud::Phishingprotection::V1beta1::PhishingProtection::Stub.method(:new)
176
+ )
177
+
178
+ @report_phishing = Google::Gax.create_api_call(
179
+ @phishing_protection_stub.method(:report_phishing),
180
+ defaults["report_phishing"],
181
+ exception_transformer: exception_transformer,
182
+ params_extractor: proc do |request|
183
+ {'parent' => request.parent}
184
+ end
185
+ )
186
+ end
187
+
188
+ # Service calls
189
+
190
+ # Reports a URI suspected of containing phishing content to be reviewed. Once
191
+ # the report review is completed, if its result verifies the existince of
192
+ # malicious phishing content, the site will be added the to [Google's Social
193
+ # Engineering lists](https://support.google.com/webmasters/answer/6350487/)
194
+ # in order to protect users that could get exposed to this threat in
195
+ # the future.
196
+ #
197
+ # @param parent [String]
198
+ # Required. The name of the project for which the report will be created,
199
+ # in the format "projects/\\{project_number}".
200
+ # @param uri [String]
201
+ # The URI that is being reported for phishing content to be analyzed.
202
+ # @param options [Google::Gax::CallOptions]
203
+ # Overrides the default settings for this call, e.g, timeout,
204
+ # retries, etc.
205
+ # @yield [result, operation] Access the result along with the RPC operation
206
+ # @yieldparam result [Google::Cloud::Phishingprotection::V1beta1::ReportPhishingResponse]
207
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
208
+ # @return [Google::Cloud::Phishingprotection::V1beta1::ReportPhishingResponse]
209
+ # @raise [Google::Gax::GaxError] if the RPC is aborted.
210
+ # @example
211
+ # require "google/cloud/phishing_protection"
212
+ #
213
+ # phishing_protection_client = Google::Cloud::PhishingProtection.new(version: :v1beta1)
214
+ # formatted_parent = Google::Cloud::PhishingProtection::V1beta1::PhishingProtectionClient.project_path("[PROJECT]")
215
+ #
216
+ # # TODO: Initialize `uri`:
217
+ # uri = ''
218
+ # response = phishing_protection_client.report_phishing(formatted_parent, uri)
219
+
220
+ def report_phishing \
221
+ parent,
222
+ uri,
223
+ options: nil,
224
+ &block
225
+ req = {
226
+ parent: parent,
227
+ uri: uri
228
+ }.delete_if { |_, v| v.nil? }
229
+ req = Google::Gax::to_proto(req, Google::Cloud::Phishingprotection::V1beta1::ReportPhishingRequest)
230
+ @report_phishing.call(req, options, &block)
231
+ end
232
+ end
233
+ end
234
+ end
235
+ end
236
+ end