Skip to content

Commit

Permalink
fix!: Add threatTypes to searchHashes request signature. (#2309)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and dwsupplee committed Sep 10, 2019
1 parent 3a87c15 commit 8ed8b72
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
14 changes: 6 additions & 8 deletions WebRisk/src/V1beta1/Gapic/WebRiskServiceV1Beta1GapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,21 +284,21 @@ public function searchUris($uri, $threatTypes, array $optionalArgs = [])
* ```
* $webRiskServiceV1Beta1Client = new Google\Cloud\WebRisk\V1beta1\WebRiskServiceV1Beta1Client();
* try {
* $response = $webRiskServiceV1Beta1Client->searchHashes();
* $threatTypes = [];
* $response = $webRiskServiceV1Beta1Client->searchHashes($threatTypes);
* } finally {
* $webRiskServiceV1Beta1Client->close();
* }
* ```
*
* @param int[] $threatTypes Required. The ThreatLists to search in.
* For allowed values, use constants defined on {@see \Google\Cloud\WebRisk\V1beta1\ThreatType}
* @param array $optionalArgs {
* Optional.
*
* @type string $hashPrefix
* A hash prefix, consisting of the most significant 4-32 bytes of a SHA256
* hash. For JSON requests, this field is base64-encoded.
* @type int[] $threatTypes
* Required. The ThreatLists to search in.
* For allowed values, use constants defined on {@see \Google\Cloud\WebRisk\V1beta1\ThreatType}
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a
* {@see Google\ApiCore\RetrySettings} object, or an associative array
Expand All @@ -311,15 +311,13 @@ public function searchUris($uri, $threatTypes, array $optionalArgs = [])
* @throws ApiException if the remote call fails
* @experimental
*/
public function searchHashes(array $optionalArgs = [])
public function searchHashes($threatTypes, array $optionalArgs = [])
{
$request = new SearchHashesRequest();
$request->setThreatTypes($threatTypes);
if (isset($optionalArgs['hashPrefix'])) {
$request->setHashPrefix($optionalArgs['hashPrefix']);
}
if (isset($optionalArgs['threatTypes'])) {
$request->setThreatTypes($optionalArgs['threatTypes']);
}

return $this->startCall(
'SearchHashes',
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-07T19:10:34.033660Z",
"updateTime": "2019-09-10T10:04:58.767891Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.29.1",
"dockerImage": "googleapis/artman@sha256:b2a73f4dda03ef8fcaa973e3ba26d0cf34091f6c22c70add663af325931aef4d"
"version": "0.36.2",
"dockerImage": "googleapis/artman@sha256:0e6f3a668cd68afc768ecbe08817cf6e56a0e64fcbdb1c58c3b97492d12418a1"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "3a1b46a6668194a527e532a2c355b404c79b0e6a",
"internalRef": "262167956"
"sha": "26e189ad03ba63591fb26eecb6aaade7ad39f57a"
}
}
],
Expand Down
14 changes: 12 additions & 2 deletions WebRisk/tests/Unit/V1beta1/WebRiskServiceV1Beta1ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,21 @@ public function searchHashesTest()
$expectedResponse = new SearchHashesResponse();
$transport->addResponse($expectedResponse);

$response = $client->searchHashes();
// Mock request
$threatTypes = [];

$response = $client->searchHashes($threatTypes);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
$actualFuncCall = $actualRequests[0]->getFuncCall();
$actualRequestObject = $actualRequests[0]->getRequestObject();
$this->assertSame('/google.cloud.webrisk.v1beta1.WebRiskServiceV1Beta1/SearchHashes', $actualFuncCall);

$actualValue = $actualRequestObject->getThreatTypes();

$this->assertProtobufEquals($threatTypes, $actualValue);

$this->assertTrue($transport->isExhausted());
}

Expand All @@ -273,8 +280,11 @@ public function searchHashesExceptionTest()
], JSON_PRETTY_PRINT);
$transport->addResponse(null, $status);

// Mock request
$threatTypes = [];

try {
$client->searchHashes();
$client->searchHashes($threatTypes);
// If the $client method call did not throw, fail the test
$this->fail('Expected an ApiException, but no exception was thrown.');
} catch (ApiException $ex) {
Expand Down

0 comments on commit 8ed8b72

Please sign in to comment.