Client for Web Risk API#
-
class
google.cloud.webrisk_v1beta1.
WebRiskServiceV1Beta1Client
(transport=None, channel=None, credentials=None, client_config=None, client_info=None, client_options=None)[source]# Web Risk v1beta1 API defines an interface to detect malicious URLs on your website and in client applications.
Constructor.
- Parameters
(Union[WebRiskServiceV1Beta1GrpcTransport, (transport) – Callable[[~.Credentials, type], ~.WebRiskServiceV1Beta1GrpcTransport]): A transport instance, responsible for actually making the API calls. The default transport uses the gRPC protocol. This argument may also be a callable which returns a transport instance. Callables will be sent the credentials as the first argument and the default transport class as the second argument.
channel (grpc.Channel) – DEPRECATED. A
Channel
instance through which to make calls. This argument is mutually exclusive withcredentials
; 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
(threat_type, constraints, version_token=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# Gets the most recent threat list diffs.
Example
>>> from google.cloud import webrisk_v1beta1 >>> from google.cloud.webrisk_v1beta1 import enums >>> >>> client = webrisk_v1beta1.WebRiskServiceV1Beta1Client() >>> >>> # 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
threat_type (ThreatType) – Required. The ThreatList to update.
constraints (Union[dict, Constraints]) –
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).
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will not be retried.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.
- Returns
A
ComputeThreatListDiffResponse
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
enums
= <module 'google.cloud.webrisk_v1beta1.gapic.enums' from '/usr/local/lib/python3.7/site-packages/google/cloud/webrisk_v1beta1/gapic/enums.py'>#
-
classmethod
from_service_account_file
(filename, *args, **kwargs)[source]# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
classmethod
from_service_account_json
(filename, *args, **kwargs)# Creates an instance of this client using the provided credentials file.
- Parameters
filename (str) – The path to the service account private key json file.
args – Additional arguments to pass to the constructor.
kwargs – Additional arguments to pass to the constructor.
- Returns
The constructed client.
- Return type
-
search_hashes
(hash_prefix=None, threat_types=None, retry=<object object>, timeout=<object object>, metadata=None)[source]# 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.
Example
>>> from google.cloud import webrisk_v1beta1 >>> >>> client = webrisk_v1beta1.WebRiskServiceV1Beta1Client() >>> >>> response = client.search_hashes()
- Parameters
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.
threat_types (list[ThreatType]) – Required. The ThreatLists to search in.
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will not be retried.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.
- Returns
A
SearchHashesResponse
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.
-
search_uris
(uri, threat_types, retry=<object object>, timeout=<object object>, metadata=None)[source]# This method is used to check whether a URI is on a given threatList.
Example
>>> from google.cloud import webrisk_v1beta1 >>> from google.cloud.webrisk_v1beta1 import enums >>> >>> client = webrisk_v1beta1.WebRiskServiceV1Beta1Client() >>> >>> # TODO: Initialize `uri`: >>> uri = '' >>> >>> # TODO: Initialize `threat_types`: >>> threat_types = [] >>> >>> response = client.search_uris(uri, threat_types)
- Parameters
uri (str) – The URI to be checked for matches.
threat_types (list[ThreatType]) – Required. The ThreatLists to search in.
retry (Optional[google.api_core.retry.Retry]) – A retry object used to retry requests. If
None
is specified, requests will not be retried.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.
- Returns
A
SearchUrisResponse
instance.- Raises
google.api_core.exceptions.GoogleAPICallError – If the request failed for any reason.
google.api_core.exceptions.RetryError – If the request failed due to a retryable error and retry attempts failed.
ValueError – If the parameters are invalid.