google/cloud-asset

Google Cloud Asset PHP客户端

v2.0.1 2024-09-13 22:45 UTC

README

Google Cloud Asset的惯用PHP客户端。

Latest Stable Version Packagist

注意:此存储库是Google Cloud PHP的一部分。有关支持请求、错误报告或开发贡献,请将该项目指向该项目。

安装

首先,安装PHP首选的依赖关系管理器 Composer

现在安装此组件

$ composer require google/cloud-asset

此组件支持HTTP/1.1上的REST和gRPC。为了利用gRPC(如流方法)提供的优势,请参阅我们的gRPC安装指南

身份验证

有关对客户端进行身份验证的更多信息,请参阅我们的身份验证指南。一旦身份验证,您就可以开始发送请求。

示例

require_once __DIR__ . '/vendor/autoload.php';

use Google\Cloud\Asset\V1\AssetServiceClient;
use Google\Cloud\Asset\V1\GcsDestination;
use Google\Cloud\Asset\V1\OutputConfig;

$objectPath = 'gs://your-bucket/cai-export';
// Now you need to change this with your project number (numeric id)
$project = 'example-project';

$client = new AssetServiceClient();

$gcsDestination = new GcsDestination(['uri' => $objectPath]);
$outputConfig = new OutputConfig(['gcs_destination' => $gcsDestination]);

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

$resp->pollUntilComplete();

if ($resp->operationSucceeded()) {
    echo "The result is dumped to $objectPath successfully." . PHP_EOL;
} else {
    $error = $resp->getError();
    // handleError($error)
}

版本

此组件被认为是GA(通常可用)。因此,它不会在任何次要或补丁版本中引入不兼容的更改。我们将优先解决问题和请求。

下一步

  1. 了解官方文档