Reference documentation and code samples for the Google Cloud Asset V1beta1 Client class AssetServiceClient.
Service Description: Asset service definition.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
$assetServiceClient = new AssetServiceClient();
try {
$parent = '';
$outputConfig = new OutputConfig();
$operationResponse = $assetServiceClient->exportAssets($parent, $outputConfig);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $assetServiceClient->exportAssets($parent, $outputConfig);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $assetServiceClient->resumeOperation($operationName, 'exportAssets');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$assetServiceClient->close();
}
Methods
getOperationsClient
Return an OperationsClient object with the same endpoint as $this.
Returns | |
---|---|
Type | Description |
Google\ApiCore\LongRunning\OperationsClient |
resumeOperation
Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.
Parameters | |
---|---|
Name | Description |
operationName |
string
The name of the long running operation |
methodName |
string
The name of the method used to start the operation |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
options |
array
Optional. Options for configuring the service API wrapper. |
↳ serviceAddress |
string
Deprecated. This option will be removed in a future major release. Please utilize the |
↳ apiEndpoint |
string
The address of the API remote host. May optionally include the port, formatted as "
|
↳ credentials |
string|array|FetchAuthTokenInterface|CredentialsWrapper
The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed {@see} object or {@see} object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. |
↳ credentialsConfig |
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see {@see}. |
↳ disableRetries |
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to |
↳ clientConfig |
string|array
Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder. |
↳ transport |
string|TransportInterface
The transport used for executing network requests. May be either the string |
↳ transportConfig |
array
Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...] ]; See the {@see} and {@see} methods for the supported options. |
exportAssets
Exports assets with time and resource types to a given Cloud Storage location. The output format is newline-delimited JSON.
This API implements the google.longrunning.Operation API allowing you to keep track of the export.
Sample code:
$assetServiceClient = new AssetServiceClient();
try {
$parent = '';
$outputConfig = new OutputConfig();
$operationResponse = $assetServiceClient->exportAssets($parent, $outputConfig);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $assetServiceClient->exportAssets($parent, $outputConfig);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $assetServiceClient->resumeOperation($operationName, 'exportAssets');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$assetServiceClient->close();
}
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The relative name of the root asset. This can only be an organization number (such as "organizations/123"), a project ID (such as "projects/my-project-id"), a project number (such as "projects/12345"), or a folder number (such as "folders/123"). |
outputConfig |
Google\Cloud\Asset\V1beta1\OutputConfig
Required. Output configuration indicating where the results will be output to. All results will be in newline delimited JSON format. |
optionalArgs |
array
Optional. |
↳ readTime |
Timestamp
Timestamp to take an asset snapshot. This can only be set to a timestamp between 2018-10-02 UTC (inclusive) and the current time. If not specified, the current time will be used. Due to delays in resource data collection and indexing, there is a volatile window during which running the same query may get different results. |
↳ assetTypes |
string[]
A list of asset types of which to take a snapshot for. For example: "google.compute.Disk". If specified, only matching assets will be returned. See Introduction to Cloud Asset Inventory for all supported asset types. |
↳ contentType |
int
Asset content type. If not specified, no content but the asset name will be returned. For allowed values, use constants defined on {@see} |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
batchGetAssetsHistory
Batch gets the update history of assets that overlap a time window.
For RESOURCE content, this API outputs history with asset in both non-delete or deleted status. For IAM_POLICY content, this API outputs history when the asset and its attached IAM POLICY both exist. This can create gaps in the output history. If a specified asset does not exist, this API returns an INVALID_ARGUMENT error.
Sample code:
$assetServiceClient = new AssetServiceClient();
try {
$parent = '';
$response = $assetServiceClient->batchGetAssetsHistory($parent);
} finally {
$assetServiceClient->close();
}
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The relative name of the root asset. It can only be an organization number (such as "organizations/123"), a project ID (such as "projects/my-project-id")", or a project number (such as "projects/12345"). |
optionalArgs |
array
Optional. |
↳ assetNames |
string[]
A list of the full names of the assets. For example: |
↳ contentType |
int
Optional. The content type. For allowed values, use constants defined on {@see} |
↳ readTimeWindow |
TimeWindow
Optional. The time window for the asset history. Both start_time and end_time are optional and if set, it must be after 2018-10-02 UTC. If end_time is not set, it is default to current timestamp. If start_time is not set, the snapshot of the assets at end_time will be returned. The returned results contain all temporal assets whose time window overlap with read_time_window. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a {@see} object, or an associative array of retry settings parameters. See the documentation on {@see} for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Asset\V1beta1\BatchGetAssetsHistoryResponse |
Constants
SERVICE_NAME
Value: 'google.cloud.asset.v1beta1.AssetService'
The name of the service.
SERVICE_ADDRESS
Value: 'cloudasset.googleapis.com'
The default address of the service.
DEFAULT_SERVICE_PORT
Value: 443
The default port of the service.
CODEGEN_NAME
Value: 'gapic'
The name of the code generator, to be included in the agent header.