Skip to content
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
6 changes: 3 additions & 3 deletions asset/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"google/cloud-bigquery": "^1.16.0",
"google/cloud-storage": "^1.9",
"google/cloud-asset": "^1.4.2"
"google/cloud-bigquery": "^1.28",
"google/cloud-storage": "^1.36",
"google/cloud-asset": "^1.14"
}
}
15 changes: 8 additions & 7 deletions asset/src/batch_get_assets_history.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
namespace Google\Cloud\Samples\Asset;

# [START asset_quickstart_batch_get_assets_history]
use Google\Cloud\Asset\V1\AssetServiceClient;
use Google\Cloud\Asset\V1\BatchGetAssetsHistoryRequest;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\ContentType;
use Google\Cloud\Asset\V1\TimeWindow;
use Google\Protobuf\Timestamp;
Expand All @@ -33,13 +34,13 @@ function batch_get_assets_history(string $projectId, array $assetNames): void
$formattedParent = $client->projectName($projectId);
$contentType = ContentType::RESOURCE;
$readTimeWindow = new TimeWindow(['start_time' => new Timestamp(['seconds' => time()])]);
$request = (new BatchGetAssetsHistoryRequest())
->setParent($formattedParent)
->setContentType($contentType)
->setReadTimeWindow($readTimeWindow)
->setAssetNames($assetNames);

$resp = $client->batchGetAssetsHistory(
$formattedParent,
$contentType,
$readTimeWindow,
['assetNames' => $assetNames]
);
$resp = $client->batchGetAssetsHistory($request);

# Do things with response.
print($resp->serializeToString());
Expand Down
8 changes: 6 additions & 2 deletions asset/src/export_assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
namespace Google\Cloud\Samples\Asset;

# [START asset_quickstart_export_assets]
use Google\Cloud\Asset\V1\AssetServiceClient;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\ExportAssetsRequest;
use Google\Cloud\Asset\V1\GcsDestination;
use Google\Cloud\Asset\V1\OutputConfig;

Expand All @@ -35,8 +36,11 @@ function export_assets(string $projectId, string $dumpFilePath)

$gcsDestination = new GcsDestination(['uri' => $dumpFilePath]);
$outputConfig = new OutputConfig(['gcs_destination' => $gcsDestination]);
$request = (new ExportAssetsRequest())
->setParent("projects/$projectId")
->setOutputConfig($outputConfig);

$resp = $client->exportAssets("projects/$projectId", $outputConfig);
$resp = $client->exportAssets($request);

$resp->pollUntilComplete();

Expand Down
12 changes: 7 additions & 5 deletions asset/src/list_assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
namespace Google\Cloud\Samples\Asset;

// [START asset_quickstart_list_assets]
use Google\Cloud\Asset\V1\AssetServiceClient;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\ListAssetsRequest;

/**
* @param string $projectId Tthe project Id for list assets.
Expand All @@ -34,10 +35,11 @@ function list_assets(
$client = new AssetServiceClient();

// Run request
$response = $client->listAssets("projects/$projectId", [
'assetTypes' => $assetTypes,
'pageSize' => $pageSize,
]);
$request = (new ListAssetsRequest())
->setParent("projects/$projectId")
->setAssetTypes($assetTypes)
->setPageSize($pageSize);
$response = $client->listAssets($request);

// Print the asset names in the result
foreach ($response->getPage() as $asset) {
Expand Down
14 changes: 8 additions & 6 deletions asset/src/search_all_iam_policies.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
namespace Google\Cloud\Samples\Asset;

// [START asset_quickstart_search_all_iam_policies]
use Google\Cloud\Asset\V1\AssetServiceClient;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\SearchAllIamPoliciesRequest;

/**
* @param string $scope Scope of the search
Expand All @@ -36,11 +37,12 @@ function search_all_iam_policies(
$asset = new AssetServiceClient();

// Run request
$response = $asset->searchAllIamPolicies($scope, [
'query' => $query,
'pageSize' => $pageSize,
'pageToken' => $pageToken
]);
$request = (new SearchAllIamPoliciesRequest())
->setScope($scope)
->setQuery($query)
->setPageSize($pageSize)
->setPageToken($pageToken);
$response = $asset->searchAllIamPolicies($request);

// Print the resources that the policies are set on
foreach ($response->getPage() as $policy) {
Expand Down
18 changes: 10 additions & 8 deletions asset/src/search_all_resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
namespace Google\Cloud\Samples\Asset;

// [START asset_quickstart_search_all_resources]
use Google\Cloud\Asset\V1\AssetServiceClient;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\SearchAllResourcesRequest;

/**
* @param string $scope Scope of the search
Expand All @@ -40,13 +41,14 @@ function search_all_resources(
$asset = new AssetServiceClient();

// Run request
$response = $asset->searchAllResources($scope, [
'query' => $query,
'assetTypes' => $assetTypes,
'pageSize' => $pageSize,
'pageToken' => $pageToken,
'orderBy' => $orderBy
]);
$request = (new SearchAllResourcesRequest())
->setScope($scope)
->setQuery($query)
->setAssetTypes($assetTypes)
->setPageSize($pageSize)
->setPageToken($pageToken)
->setOrderBy($orderBy);
$response = $asset->searchAllResources($request);

// Print the resource names in the first page of the result
foreach ($response->getPage() as $resource) {
Expand Down