Skip to content

Commit

Permalink
Make threat_types a required argument to search_hashes (via synth…
Browse files Browse the repository at this point in the history
…). (#9198)
  • Loading branch information
yoshi-automation authored and tseaver committed Sep 10, 2019
1 parent eb8ef8a commit 2a4ed1a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ def search_uris(

def search_hashes(
self,
threat_types,
hash_prefix=None,
threat_types=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
Expand All @@ -338,15 +338,19 @@ def search_hashes(
Example:
>>> from google.cloud import webrisk_v1beta1
>>> from google.cloud.webrisk_v1beta1 import enums
>>>
>>> client = webrisk_v1beta1.WebRiskServiceV1Beta1Client()
>>>
>>> response = client.search_hashes()
>>> # TODO: Initialize `threat_types`:
>>> threat_types = []
>>>
>>> response = client.search_hashes(threat_types)
Args:
threat_types (list[~google.cloud.webrisk_v1beta1.types.ThreatType]): Required. The ThreatLists to search in.
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[~google.cloud.webrisk_v1beta1.types.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
be retried using a default configuration.
Expand Down Expand Up @@ -378,7 +382,7 @@ def search_hashes(
)

request = webrisk_pb2.SearchHashesRequest(
hash_prefix=hash_prefix, threat_types=threat_types
threat_types=threat_types, hash_prefix=hash_prefix
)
return self._inner_api_calls["search_hashes"](
request, retry=retry, timeout=timeout, metadata=metadata
Expand Down
9 changes: 4 additions & 5 deletions packages/google-cloud-webrisk/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"updateTime": "2019-08-06T12:51:28.182890Z",
"updateTime": "2019-09-10T12:41:37.939470Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.32.1",
"dockerImage": "googleapis/artman@sha256:a684d40ba9a4e15946f5f2ca6b4bd9fe301192f522e9de4fff622118775f309b"
"version": "0.36.2",
"dockerImage": "googleapis/artman@sha256:0e6f3a668cd68afc768ecbe08817cf6e56a0e64fcbdb1c58c3b97492d12418a1"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "e699b0cba64ffddfae39633417180f1f65875896",
"internalRef": "261759677"
"sha": "26e189ad03ba63591fb26eecb6aaade7ad39f57a"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,14 @@ def test_search_hashes(self):
create_channel.return_value = channel
client = webrisk_v1beta1.WebRiskServiceV1Beta1Client()

response = client.search_hashes()
# Setup Request
threat_types = []

response = client.search_hashes(threat_types)
assert expected_response == response

assert len(channel.requests) == 1
expected_request = webrisk_pb2.SearchHashesRequest()
expected_request = webrisk_pb2.SearchHashesRequest(threat_types=threat_types)
actual_request = channel.requests[0][1]
assert expected_request == actual_request

Expand All @@ -174,5 +177,8 @@ def test_search_hashes_exception(self):
create_channel.return_value = channel
client = webrisk_v1beta1.WebRiskServiceV1Beta1Client()

# Setup request
threat_types = []

with pytest.raises(CustomException):
client.search_hashes()
client.search_hashes(threat_types)

0 comments on commit 2a4ed1a

Please sign in to comment.