Class WebRiskServiceClient (0.3.3)

WebRiskServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

Web Risk API defines an interface to detect malicious URLs on your website and in client applications.

Methods

WebRiskServiceClient

WebRiskServiceClient(
    transport=None,
    channel=None,
    credentials=None,
    client_config=None,
    client_info=None,
    client_options=None,
)

Constructor.

Parameters
NameDescription
channel grpc.Channel

DEPRECATED. A Channel instance through which to make calls. This argument is mutually exclusive with credentials; providing both will raise an exception.

credentials google.auth.credentials.Credentials

The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. This argument is mutually exclusive with providing a transport instance to transport; doing so will raise an exception.

client_config dict

DEPRECATED. A dictionary of call options for each method. If not specified, the default configuration is used.

client_info google.api_core.gapic_v1.client_info.ClientInfo

The client info used to send a user-agent string along with API requests. If None, then default info will be used. Generally, you only need to set this if you're developing your own client library.

client_options Union[dict, google.api_core.client_options.ClientOptions]

Client options used to set user options on the client. API Endpoint should be set through client_options.

compute_threat_list_diff

compute_threat_list_diff(threat_type, constraints, version_token=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Gets the most recent threat list diffs. These diffs should be applied to a local database of hashes to keep it up-to-date. If the local database is empty or excessively out-of-date, a complete snapshot of the database will be returned. This Method only updates a single ThreatList at a time. To update multiple ThreatList databases, this method needs to be called once for each list.

.. rubric:: Example

from google.cloud import webrisk_v1 from google.cloud.webrisk_v1 import enums

client = webrisk_v1.WebRiskServiceClient()

TODO: Initialize threat_type:

threat_type = enums.ThreatType.THREAT_TYPE_UNSPECIFIED

TODO: Initialize constraints:

constraints = {}

response = client.compute_threat_list_diff(threat_type, constraints)

Parameters
NameDescription
threat_type ThreatType

Required. The threat list to update. Only a single ThreatType should be specified.

constraints Union[dict, Constraints]

Required. The constraints associated with this request. If a dict is provided, it must be of the same form as the protobuf message Constraints

version_token bytes

The current version token of the client for the requested list (the client version that was received from the last successful diff). If the client does not have a version token (this is the first time calling ComputeThreatListDiff), this may be left empty and a full database snapshot will be returned.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

create_submission

create_submission(parent, submission, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Creates a Submission of a URI suspected of containing phishing content to be reviewed. If the result verifies the existence of malicious phishing content, the site will be added to the Google's Social Engineering lists <https://support.google.com/webmasters/answer/6350487/>__ in order to protect users that could get exposed to this threat in the future. Only projects with CREATE_SUBMISSION_USERS visibility can use this method.

.. rubric:: Example

from google.cloud import webrisk_v1

client = webrisk_v1.WebRiskServiceClient()

parent = client.project_path('[PROJECT]')

TODO: Initialize submission:

submission = {}

response = client.create_submission(parent, submission)

Parameters
NameDescription
parent str

Required. The name of the project that is making the submission. This string is in the format "projects/{project_number}".

submission Union[dict, Submission]

Required. The submission that contains the content of the phishing report. If a dict is provided, it must be of the same form as the protobuf message Submission

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

from_service_account_file

from_service_account_file(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
WebRiskServiceClientThe constructed client.

from_service_account_json

from_service_account_json(filename, *args, **kwargs)

Creates an instance of this client using the provided credentials file.

Parameter
NameDescription
filename str

The path to the service account private key json file.

Returns
TypeDescription
WebRiskServiceClientThe constructed client.

project_path

project_path(project)

Return a fully-qualified project string.

search_hashes

search_hashes(threat_types, hash_prefix=None, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

Gets the full hashes that match the requested hash prefix. This is used after a hash prefix is looked up in a threatList and there is a match. The client side threatList only holds partial hashes so the client must query this method to determine if there is a full hash match of a threat.

.. rubric:: Example

from google.cloud import webrisk_v1 from google.cloud.webrisk_v1 import enums

client = webrisk_v1.WebRiskServiceClient()

TODO: Initialize threat_types:

threat_types = []

response = client.search_hashes(threat_types)

Parameters
NameDescription
threat_types list[ThreatType]

Required. The ThreatLists to search in. Multiple ThreatLists may be specified.

hash_prefix bytes

A hash prefix, consisting of the most significant 4-32 bytes of a SHA256 hash. For JSON requests, this field is base64-encoded.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.

search_uris

search_uris(uri, threat_types, retry=<_MethodDefault._DEFAULT_VALUE: <object object>>, timeout=<_MethodDefault._DEFAULT_VALUE: <object object>>, metadata=None)

This method is used to check whether a URI is on a given threatList. Multiple threatLists may be searched in a single query. The response will list all requested threatLists the URI was found to match. If the URI is not found on any of the requested ThreatList an empty response will be returned.

.. rubric:: Example

from google.cloud import webrisk_v1 from google.cloud.webrisk_v1 import enums

client = webrisk_v1.WebRiskServiceClient()

TODO: Initialize uri:

uri = ''

TODO: Initialize threat_types:

threat_types = []

response = client.search_uris(uri, threat_types)

Parameters
NameDescription
uri str

Required. The URI to be checked for matches.

threat_types list[ThreatType]

Required. The ThreatLists to search in. Multiple ThreatLists may be specified.

retry Optional[google.api_core.retry.Retry]

A retry object used to retry requests. If None is specified, requests will be retried using a default configuration.

timeout Optional[float]

The amount of time, in seconds, to wait for the request to complete. Note that if retry is specified, the timeout applies to each individual attempt.

metadata Optional[Sequence[Tuple[str, str]]]

Additional metadata that is provided to the method.

Exceptions
TypeDescription
google.api_core.exceptions.GoogleAPICallErrorIf the request failed for any reason.
google.api_core.exceptions.RetryErrorIf the request failed due to a retryable error and retry attempts failed.
ValueErrorIf the parameters are invalid.