Skip to content

Commit 4cc3871

Browse files
committed
CloudAsset: Fix ListAssets sample code
1 parent a7d9675 commit 4cc3871

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

asset/src/list_assets.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,21 @@
2121
use Google\Cloud\Asset\V1\AssetServiceClient;
2222

2323
/**
24-
* @param string $projectId the project Id for list assets.
24+
* @param string $projectId Tthe project Id for list assets.
25+
* @param string|array $assetTypes (Optional) Asset types to list for.
26+
* @param int $pageSize (Optional) Size of one result page.
2527
*/
26-
function list_assets(string $projectId)
28+
function list_assets(string $projectId, array $assetTypes = [], int $pageSize)
2729
{
2830
// Instantiate a client.
2931
$client = new AssetServiceClient();
3032

3133
// Run request
32-
$response = $client->listAssets("projects/$projectId");
34+
$response = $client->listAssets(
35+
"projects/$projectId", [
36+
'assetTypes' => $assetTypes,
37+
'pageSize' => $pageSize,
38+
]);
3339

3440
// Print the asset names in the result
3541
foreach ($response->getPage() as $asset) {

asset/test/assetTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public function testListAssets()
6464
$assetName = '//storage.googleapis.com/' . self::$bucketName;
6565
$this->runEventuallyConsistentTest(function () use ($assetName) {
6666
$output = $this->runFunctionSnippet('list_assets', [
67-
'projectId' => self::$projectId,
67+
'projectId' => self::$projectId,
68+
'assetTypes' => ['storage.buckets'],
69+
'pageSize' => 1000,
6870
]);
6971

7072
$this->assertStringContainsString($assetName, $output);

0 commit comments

Comments
 (0)