diff --git a/asset/src/list_assets.php b/asset/src/list_assets.php new file mode 100644 index 0000000000..02d2cc06fa --- /dev/null +++ b/asset/src/list_assets.php @@ -0,0 +1,49 @@ +listAssets( + "projects/$projectId", [ + 'assetTypes' => $assetTypes, + 'pageSize' => $pageSize, + ]); + + // Print the asset names in the result + foreach ($response->getPage() as $asset) { + print($asset->getName() . PHP_EOL); + } +} +// [END asset_quickstart_list_assets] + +// The following 2 lines are only needed to run the samples +require_once __DIR__ . '/../../testing/sample_helpers.php'; +\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv); diff --git a/asset/test/assetTest.php b/asset/test/assetTest.php index c5161633f4..18cf4eaad9 100644 --- a/asset/test/assetTest.php +++ b/asset/test/assetTest.php @@ -59,6 +59,20 @@ public function testExportAssets() $assetFile->delete(); } + public function testListAssets() + { + $assetName = '//storage.googleapis.com/' . self::$bucketName; + $this->runEventuallyConsistentTest(function () use ($assetName) { + $output = $this->runFunctionSnippet('list_assets', [ + 'projectId' => self::$projectId, + 'assetTypes' => ['storage.googleapis.com/Bucket'], + 'pageSize' => 1000, + ]); + + $this->assertStringContainsString($assetName, $output); + }, 10, true); + } + public function testBatchGetAssetsHistory() { $assetName = '//storage.googleapis.com/' . self::$bucketName;