Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Risk: Make threat_types a required argument to search_hashes (via synth). #9198

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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)