Reference documentation and code samples for the Google Cloud Asset V1 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.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.
Namespace
Google \ Cloud \ Asset \ V1 \ ClientMethods
__construct
Constructor.
options
array
Optional. Options for configuring the service API wrapper.
↳ 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 Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important : If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information https://cloud.google.com/docs/authentication/external/externally-sourced-credentials
↳ credentialsConfig
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .
↳ disableRetries
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to false
.
↳ 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 rest
or grpc
. Defaults to grpc
if gRPC support is detected on the system. Advanced usage
: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface
object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.
↳ 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 Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.
↳ clientCertSource
callable
A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.
↳ logger
false|LoggerInterface
A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag
analyzeIamPolicy
Analyzes IAM policies to answer which identities have what accesses on which resources.
The async variant is AssetServiceClient::analyzeIamPolicyAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\AnalyzeIamPolicyRequest;
use Google\Cloud\Asset\V1\AnalyzeIamPolicyResponse;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\IamPolicyAnalysisQuery;
/**
* @param string $analysisQueryScope The relative name of the root asset. Only resources and IAM
* policies within the scope will be analyzed.
*
* This can only be an organization number (such as "organizations/123"), a
* folder number (such as "folders/123"), a project ID (such as
* "projects/my-project-id"), or a project number (such as "projects/12345").
*
* To know how to get organization ID, visit [here
* ](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
*
* To know how to get folder or project ID, visit [here
* ](https://cloud.google.com/resource-manager/docs/creating-managing-folders#viewing_or_listing_folders_and_projects).
*/
function analyze_iam_policy_sample(string $analysisQueryScope): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$analysisQuery = (new IamPolicyAnalysisQuery())
->setScope($analysisQueryScope);
$request = (new AnalyzeIamPolicyRequest())
->setAnalysisQuery($analysisQuery);
// Call the API and handle any network failures.
try {
/** @var AnalyzeIamPolicyResponse $response */
$response = $assetServiceClient->analyzeIamPolicy($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$analysisQueryScope = '[SCOPE]';
analyze_iam_policy_sample($analysisQueryScope);
}
analyzeIamPolicyLongrunning
Analyzes IAM policies asynchronously to answer which identities have what accesses on which resources, and writes the analysis results to a Google Cloud Storage or a BigQuery destination. For Cloud Storage destination, the output format is the JSON format that represents a AnalyzeIamPolicyResponse .
This method implements the google.longrunning.Operation , which allows you to track the operation status. We recommend intervals of at least 2 seconds with exponential backoff retry to poll the operation result. The metadata contains the metadata for the long-running operation.
The async variant is AssetServiceClient::analyzeIamPolicyLongrunningAsync() .
request
Google\Cloud\Asset\V1\AnalyzeIamPolicyLongrunningRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Asset\V1\AnalyzeIamPolicyLongrunningRequest;
use Google\Cloud\Asset\V1\AnalyzeIamPolicyLongrunningResponse;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\IamPolicyAnalysisOutputConfig;
use Google\Cloud\Asset\V1\IamPolicyAnalysisQuery;
use Google\Rpc\Status;
/**
* @param string $analysisQueryScope The relative name of the root asset. Only resources and IAM
* policies within the scope will be analyzed.
*
* This can only be an organization number (such as "organizations/123"), a
* folder number (such as "folders/123"), a project ID (such as
* "projects/my-project-id"), or a project number (such as "projects/12345").
*
* To know how to get organization ID, visit [here
* ](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
*
* To know how to get folder or project ID, visit [here
* ](https://cloud.google.com/resource-manager/docs/creating-managing-folders#viewing_or_listing_folders_and_projects).
*/
function analyze_iam_policy_longrunning_sample(string $analysisQueryScope): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$analysisQuery = (new IamPolicyAnalysisQuery())
->setScope($analysisQueryScope);
$outputConfig = new IamPolicyAnalysisOutputConfig();
$request = (new AnalyzeIamPolicyLongrunningRequest())
->setAnalysisQuery($analysisQuery)
->setOutputConfig($outputConfig);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $assetServiceClient->analyzeIamPolicyLongrunning($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var AnalyzeIamPolicyLongrunningResponse $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$analysisQueryScope = '[SCOPE]';
analyze_iam_policy_longrunning_sample($analysisQueryScope);
}
analyzeMove
Analyze moving a resource to a specified destination without kicking off the actual move. The analysis is best effort depending on the user's permissions of viewing different hierarchical policies and configurations.
The policies and configuration are subject to change before the actual resource migration takes place.
The async variant is AssetServiceClient::analyzeMoveAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\AnalyzeMoveRequest;
use Google\Cloud\Asset\V1\AnalyzeMoveResponse;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
/**
* @param string $formattedResource Name of the resource to perform the analysis against.
* Only Google Cloud projects are supported as of today. Hence, this can only
* be a project ID (such as "projects/my-project-id") or a project number
* (such as "projects/12345"). Please see
* {@see AssetServiceClient::projectName()} for help formatting this field.
* @param string $destinationParent Name of the Google Cloud folder or organization to reparent the
* target resource. The analysis will be performed against hypothetically
* moving the resource to this specified destination parent. This can only be
* a folder number (such as "folders/123") or an organization number (such as
* "organizations/123").
*/
function analyze_move_sample(string $formattedResource, string $destinationParent): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new AnalyzeMoveRequest())
->setResource($formattedResource)
->setDestinationParent($destinationParent);
// Call the API and handle any network failures.
try {
/** @var AnalyzeMoveResponse $response */
$response = $assetServiceClient->analyzeMove($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedResource = AssetServiceClient::projectName('[PROJECT]');
$destinationParent = '[DESTINATION_PARENT]';
analyze_move_sample($formattedResource, $destinationParent);
}
analyzeOrgPolicies
Analyzes organization policies under a scope.
The async variant is AssetServiceClient::analyzeOrgPoliciesAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Asset\V1\AnalyzeOrgPoliciesRequest;
use Google\Cloud\Asset\V1\AnalyzeOrgPoliciesResponse\OrgPolicyResult;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
/**
* @param string $scope The organization to scope the request. Only organization
* policies within the scope will be analyzed.
*
* * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/123456")
* @param string $constraint The name of the constraint to analyze organization policies for.
* The response only contains analyzed organization policies for the provided
* constraint.
*/
function analyze_org_policies_sample(string $scope, string $constraint): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new AnalyzeOrgPoliciesRequest())
->setScope($scope)
->setConstraint($constraint);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $assetServiceClient->analyzeOrgPolicies($request);
/** @var OrgPolicyResult $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$scope = '[SCOPE]';
$constraint = '[CONSTRAINT]';
analyze_org_policies_sample($scope, $constraint);
}
analyzeOrgPolicyGovernedAssets
Analyzes organization policies governed assets (Google Cloud resources or policies) under a scope. This RPC supports custom constraints and the following canned constraints:
- constraints/ainotebooks.accessMode
- constraints/ainotebooks.disableFileDownloads
- constraints/ainotebooks.disableRootAccess
- constraints/ainotebooks.disableTerminal
- constraints/ainotebooks.environmentOptions
- constraints/ainotebooks.requireAutoUpgradeSchedule
- constraints/ainotebooks.restrictVpcNetworks
- constraints/compute.disableGuestAttributesAccess
- constraints/compute.disableInstanceDataAccessApis
- constraints/compute.disableNestedVirtualization
- constraints/compute.disableSerialPortAccess
- constraints/compute.disableSerialPortLogging
- constraints/compute.disableVpcExternalIpv6
- constraints/compute.requireOsLogin
- constraints/compute.requireShieldedVm
- constraints/compute.restrictLoadBalancerCreationForTypes
- constraints/compute.restrictProtocolForwardingCreationForTypes
- constraints/compute.restrictXpnProjectLienRemoval
- constraints/compute.setNewProjectDefaultToZonalDNSOnly
- constraints/compute.skipDefaultNetworkCreation
- constraints/compute.trustedImageProjects
- constraints/compute.vmCanIpForward
- constraints/compute.vmExternalIpAccess
- constraints/gcp.detailedAuditLoggingMode
- constraints/gcp.resourceLocations
- constraints/iam.allowedPolicyMemberDomains
- constraints/iam.automaticIamGrantsForDefaultServiceAccounts
- constraints/iam.disableServiceAccountCreation
- constraints/iam.disableServiceAccountKeyCreation
- constraints/iam.disableServiceAccountKeyUpload
- constraints/iam.restrictCrossProjectServiceAccountLienRemoval
- constraints/iam.serviceAccountKeyExpiryHours
- constraints/resourcemanager.accessBoundaries
- constraints/resourcemanager.allowedExportDestinations
- constraints/sql.restrictAuthorizedNetworks
- constraints/sql.restrictNoncompliantDiagnosticDataAccess
- constraints/sql.restrictNoncompliantResourceCreation
- constraints/sql.restrictPublicIp
- constraints/storage.publicAccessPrevention
- constraints/storage.restrictAuthTypes
- constraints/storage.uniformBucketLevelAccess
This RPC only returns either resources of types supported by search APIs or IAM policies.
The async variant is AssetServiceClient::analyzeOrgPolicyGovernedAssetsAsync() .
request
Google\Cloud\Asset\V1\AnalyzeOrgPolicyGovernedAssetsRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Asset\V1\AnalyzeOrgPolicyGovernedAssetsRequest;
use Google\Cloud\Asset\V1\AnalyzeOrgPolicyGovernedAssetsResponse\GovernedAsset;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
/**
* @param string $scope The organization to scope the request. Only organization
* policies within the scope will be analyzed. The output assets will
* also be limited to the ones governed by those in-scope organization
* policies.
*
* * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/123456")
* @param string $constraint The name of the constraint to analyze governed assets for. The
* analysis only contains analyzed organization policies for the provided
* constraint.
*/
function analyze_org_policy_governed_assets_sample(string $scope, string $constraint): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new AnalyzeOrgPolicyGovernedAssetsRequest())
->setScope($scope)
->setConstraint($constraint);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $assetServiceClient->analyzeOrgPolicyGovernedAssets($request);
/** @var GovernedAsset $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$scope = '[SCOPE]';
$constraint = '[CONSTRAINT]';
analyze_org_policy_governed_assets_sample($scope, $constraint);
}
analyzeOrgPolicyGovernedContainers
Analyzes organization policies governed containers (projects, folders or organization) under a scope.
The async variant is AssetServiceClient::analyzeOrgPolicyGovernedContainersAsync() .
request
Google\Cloud\Asset\V1\AnalyzeOrgPolicyGovernedContainersRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Asset\V1\AnalyzeOrgPolicyGovernedContainersRequest;
use Google\Cloud\Asset\V1\AnalyzeOrgPolicyGovernedContainersResponse\GovernedContainer;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
/**
* @param string $scope The organization to scope the request. Only organization
* policies within the scope will be analyzed. The output containers will
* also be limited to the ones governed by those in-scope organization
* policies.
*
* * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/123456")
* @param string $constraint The name of the constraint to analyze governed containers for.
* The analysis only contains organization policies for the provided
* constraint.
*/
function analyze_org_policy_governed_containers_sample(string $scope, string $constraint): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new AnalyzeOrgPolicyGovernedContainersRequest())
->setScope($scope)
->setConstraint($constraint);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $assetServiceClient->analyzeOrgPolicyGovernedContainers($request);
/** @var GovernedContainer $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$scope = '[SCOPE]';
$constraint = '[CONSTRAINT]';
analyze_org_policy_governed_containers_sample($scope, $constraint);
}
batchGetAssetsHistory
Batch gets the update history of assets that overlap a time window.
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. Otherwise, this API outputs history with asset in both non-delete or deleted status. If a specified asset does not exist, this API returns an INVALID_ARGUMENT error.
The async variant is AssetServiceClient::batchGetAssetsHistoryAsync() .
request
Google\Cloud\Asset\V1\BatchGetAssetsHistoryRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\BatchGetAssetsHistoryRequest;
use Google\Cloud\Asset\V1\BatchGetAssetsHistoryResponse;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\ContentType;
use Google\Cloud\Asset\V1\TimeWindow;
/**
* @param string $parent 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").
* @param int $contentType Optional. The content type.
*/
function batch_get_assets_history_sample(string $parent, int $contentType): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$readTimeWindow = new TimeWindow();
$request = (new BatchGetAssetsHistoryRequest())
->setParent($parent)
->setContentType($contentType)
->setReadTimeWindow($readTimeWindow);
// Call the API and handle any network failures.
try {
/** @var BatchGetAssetsHistoryResponse $response */
$response = $assetServiceClient->batchGetAssetsHistory($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$parent = '[PARENT]';
$contentType = ContentType::CONTENT_TYPE_UNSPECIFIED;
batch_get_assets_history_sample($parent, $contentType);
}
batchGetEffectiveIamPolicies
Gets effective IAM policies for a batch of resources.
The async variant is AssetServiceClient::batchGetEffectiveIamPoliciesAsync() .
request
Google\Cloud\Asset\V1\BatchGetEffectiveIamPoliciesRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\BatchGetEffectiveIamPoliciesRequest;
use Google\Cloud\Asset\V1\BatchGetEffectiveIamPoliciesResponse;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
/**
* @param string $scope Only IAM policies on or below the scope will be returned.
*
* This can only be an organization number (such as "organizations/123"), a
* folder number (such as "folders/123"), a project ID (such as
* "projects/my-project-id"), or a project number (such as "projects/12345").
*
* To know how to get organization ID, visit [here
* ](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
*
* To know how to get folder or project ID, visit [here
* ](https://cloud.google.com/resource-manager/docs/creating-managing-folders#viewing_or_listing_folders_and_projects).
* @param string $namesElement The names refer to the [full_resource_names]
* (https://cloud.google.com/asset-inventory/docs/resource-name-format)
* of the asset types [supported by search
* APIs](https://cloud.google.com/asset-inventory/docs/supported-asset-types).
* A maximum of 20 resources' effective policies can be retrieved in a batch.
*/
function batch_get_effective_iam_policies_sample(string $scope, string $namesElement): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$names = [$namesElement,];
$request = (new BatchGetEffectiveIamPoliciesRequest())
->setScope($scope)
->setNames($names);
// Call the API and handle any network failures.
try {
/** @var BatchGetEffectiveIamPoliciesResponse $response */
$response = $assetServiceClient->batchGetEffectiveIamPolicies($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$scope = '[SCOPE]';
$namesElement = '[NAMES]';
batch_get_effective_iam_policies_sample($scope, $namesElement);
}
createFeed
Creates a feed in a parent project/folder/organization to listen to its asset updates.
The async variant is AssetServiceClient::createFeedAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\CreateFeedRequest;
use Google\Cloud\Asset\V1\Feed;
use Google\Cloud\Asset\V1\FeedOutputConfig;
/**
* @param string $parent The name of the project/folder/organization where this feed
* should be created in. It can only be an organization number (such as
* "organizations/123"), a folder number (such as "folders/123"), a project ID
* (such as "projects/my-project-id"), or a project number (such as
* "projects/12345").
* @param string $feedId This is the client-assigned asset feed identifier and it needs to
* be unique under a specific parent project/folder/organization.
* @param string $feedName The format will be
* projects/{project_number}/feeds/{client-assigned_feed_identifier} or
* folders/{folder_number}/feeds/{client-assigned_feed_identifier} or
* organizations/{organization_number}/feeds/{client-assigned_feed_identifier}
*
* The client-assigned feed identifier must be unique within the parent
* project/folder/organization.
*/
function create_feed_sample(string $parent, string $feedId, string $feedName): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$feedFeedOutputConfig = new FeedOutputConfig();
$feed = (new Feed())
->setName($feedName)
->setFeedOutputConfig($feedFeedOutputConfig);
$request = (new CreateFeedRequest())
->setParent($parent)
->setFeedId($feedId)
->setFeed($feed);
// Call the API and handle any network failures.
try {
/** @var Feed $response */
$response = $assetServiceClient->createFeed($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$parent = '[PARENT]';
$feedId = '[FEED_ID]';
$feedName = '[NAME]';
create_feed_sample($parent, $feedId, $feedName);
}
createSavedQuery
Creates a saved query in a parent project/folder/organization.
The async variant is AssetServiceClient::createSavedQueryAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\CreateSavedQueryRequest;
use Google\Cloud\Asset\V1\SavedQuery;
/**
* @param string $formattedParent The name of the project/folder/organization where this
* saved_query should be created in. It can only be an organization number
* (such as "organizations/123"), a folder number (such as "folders/123"), a
* project ID (such as "projects/my-project-id"), or a project number (such as
* "projects/12345"). Please see
* {@see AssetServiceClient::projectName()} for help formatting this field.
* @param string $savedQueryId The ID to use for the saved query, which must be unique in the
* specified parent. It will become the final component of the saved query's
* resource name.
*
* This value should be 4-63 characters, and valid characters
* are `[a-z][0-9]-`.
*
* Notice that this field is required in the saved query creation, and the
* `name` field of the `saved_query` will be ignored.
*/
function create_saved_query_sample(string $formattedParent, string $savedQueryId): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$savedQuery = new SavedQuery();
$request = (new CreateSavedQueryRequest())
->setParent($formattedParent)
->setSavedQuery($savedQuery)
->setSavedQueryId($savedQueryId);
// Call the API and handle any network failures.
try {
/** @var SavedQuery $response */
$response = $assetServiceClient->createSavedQuery($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = AssetServiceClient::projectName('[PROJECT]');
$savedQueryId = '[SAVED_QUERY_ID]';
create_saved_query_sample($formattedParent, $savedQueryId);
}
deleteFeed
Deletes an asset feed.
The async variant is AssetServiceClient::deleteFeedAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\DeleteFeedRequest;
/**
* @param string $formattedName The name of the feed and it must be in the format of:
* projects/project_number/feeds/feed_id
* folders/folder_number/feeds/feed_id
* organizations/organization_number/feeds/feed_id
* Please see {@see AssetServiceClient::feedName()} for help formatting this field.
*/
function delete_feed_sample(string $formattedName): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new DeleteFeedRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$assetServiceClient->deleteFeed($request);
printf('Call completed successfully.' . PHP_EOL);
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AssetServiceClient::feedName('[PROJECT]', '[FEED]');
delete_feed_sample($formattedName);
}
deleteSavedQuery
Deletes a saved query.
The async variant is AssetServiceClient::deleteSavedQueryAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\DeleteSavedQueryRequest;
/**
* @param string $formattedName The name of the saved query to delete. It must be in the format
* of:
*
* * projects/project_number/savedQueries/saved_query_id
* * folders/folder_number/savedQueries/saved_query_id
* * organizations/organization_number/savedQueries/saved_query_id
* Please see {@see AssetServiceClient::savedQueryName()} for help formatting this field.
*/
function delete_saved_query_sample(string $formattedName): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new DeleteSavedQueryRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$assetServiceClient->deleteSavedQuery($request);
printf('Call completed successfully.' . PHP_EOL);
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AssetServiceClient::savedQueryName('[PROJECT]', '[SAVED_QUERY]');
delete_saved_query_sample($formattedName);
}
exportAssets
Exports assets with time and resource types to a given Cloud Storage location/BigQuery table. For Cloud Storage location destinations, the output format is newline-delimited JSON. Each line represents a google.cloud.asset.v1.Asset in the JSON format; for BigQuery table destinations, the output table stores the fields in asset Protobuf as columns. This API implements the google.longrunning.Operation API, which allows you to keep track of the export. We recommend intervals of at least 2 seconds with exponential retry to poll the export operation result. For regular-size resource parent, the export operation usually finishes within 5 minutes.
The async variant is AssetServiceClient::exportAssetsAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\ExportAssetsRequest;
use Google\Cloud\Asset\V1\ExportAssetsResponse;
use Google\Cloud\Asset\V1\OutputConfig;
use Google\Rpc\Status;
/**
* @param string $parent 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"), or a project number (such as "projects/12345"),
* or a folder number (such as "folders/123").
*/
function export_assets_sample(string $parent): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$outputConfig = new OutputConfig();
$request = (new ExportAssetsRequest())
->setParent($parent)
->setOutputConfig($outputConfig);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $assetServiceClient->exportAssets($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var ExportAssetsResponse $result */
$result = $response->getResult();
printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
} else {
/** @var Status $error */
$error = $response->getError();
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$parent = '[PARENT]';
export_assets_sample($parent);
}
getFeed
Gets details about an asset feed.
The async variant is AssetServiceClient::getFeedAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\Feed;
use Google\Cloud\Asset\V1\GetFeedRequest;
/**
* @param string $formattedName The name of the Feed and it must be in the format of:
* projects/project_number/feeds/feed_id
* folders/folder_number/feeds/feed_id
* organizations/organization_number/feeds/feed_id
* Please see {@see AssetServiceClient::feedName()} for help formatting this field.
*/
function get_feed_sample(string $formattedName): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new GetFeedRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Feed $response */
$response = $assetServiceClient->getFeed($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AssetServiceClient::feedName('[PROJECT]', '[FEED]');
get_feed_sample($formattedName);
}
getSavedQuery
Gets details about a saved query.
The async variant is AssetServiceClient::getSavedQueryAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\GetSavedQueryRequest;
use Google\Cloud\Asset\V1\SavedQuery;
/**
* @param string $formattedName The name of the saved query and it must be in the format of:
*
* * projects/project_number/savedQueries/saved_query_id
* * folders/folder_number/savedQueries/saved_query_id
* * organizations/organization_number/savedQueries/saved_query_id
* Please see {@see AssetServiceClient::savedQueryName()} for help formatting this field.
*/
function get_saved_query_sample(string $formattedName): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new GetSavedQueryRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var SavedQuery $response */
$response = $assetServiceClient->getSavedQuery($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = AssetServiceClient::savedQueryName('[PROJECT]', '[SAVED_QUERY]');
get_saved_query_sample($formattedName);
}
listAssets
Lists assets with time and resource types and returns paged results in response.
The async variant is AssetServiceClient::listAssetsAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Asset\V1\Asset;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\ListAssetsRequest;
/**
* @param string $parent Name of the organization, folder, or project the assets belong
* to. Format: "organizations/[organization-number]" (such as
* "organizations/123"), "projects/[project-id]" (such as
* "projects/my-project-id"), "projects/[project-number]" (such as
* "projects/12345"), or "folders/[folder-number]" (such as "folders/12345").
*/
function list_assets_sample(string $parent): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new ListAssetsRequest())
->setParent($parent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $assetServiceClient->listAssets($request);
/** @var Asset $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$parent = '[PARENT]';
list_assets_sample($parent);
}
listFeeds
Lists all asset feeds in a parent project/folder/organization.
The async variant is AssetServiceClient::listFeedsAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\ListFeedsRequest;
use Google\Cloud\Asset\V1\ListFeedsResponse;
/**
* @param string $parent The parent project/folder/organization whose feeds are to be
* listed. It can only be using project/folder/organization number (such as
* "folders/12345")", or a project ID (such as "projects/my-project-id").
*/
function list_feeds_sample(string $parent): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new ListFeedsRequest())
->setParent($parent);
// Call the API and handle any network failures.
try {
/** @var ListFeedsResponse $response */
$response = $assetServiceClient->listFeeds($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$parent = '[PARENT]';
list_feeds_sample($parent);
}
listSavedQueries
Lists all saved queries in a parent project/folder/organization.
The async variant is AssetServiceClient::listSavedQueriesAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\ListSavedQueriesRequest;
use Google\Cloud\Asset\V1\SavedQuery;
/**
* @param string $formattedParent The parent project/folder/organization whose savedQueries are to
* be listed. It can only be using project/folder/organization number (such as
* "folders/12345")", or a project ID (such as "projects/my-project-id"). Please see
* {@see AssetServiceClient::projectName()} for help formatting this field.
*/
function list_saved_queries_sample(string $formattedParent): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new ListSavedQueriesRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $assetServiceClient->listSavedQueries($request);
/** @var SavedQuery $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedParent = AssetServiceClient::projectName('[PROJECT]');
list_saved_queries_sample($formattedParent);
}
queryAssets
Issue a job that queries assets using a SQL statement compatible with BigQuery SQL .
If the query execution finishes within timeout and there's no pagination,
the full query results will be returned in the QueryAssetsResponse
.
Otherwise, full query results can be obtained by issuing extra requests
with the job_reference
from the a previous QueryAssets
call.
Note, the query result has approximately 10 GB limitation enforced by BigQuery . Queries return larger results will result in errors.
The async variant is AssetServiceClient::queryAssetsAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\QueryAssetsRequest;
use Google\Cloud\Asset\V1\QueryAssetsResponse;
/**
* @param string $parent 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"), or a project number (such as "projects/12345"),
* or a folder number (such as "folders/123").
*
* Only assets belonging to the `parent` will be returned.
*/
function query_assets_sample(string $parent): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new QueryAssetsRequest())
->setParent($parent);
// Call the API and handle any network failures.
try {
/** @var QueryAssetsResponse $response */
$response = $assetServiceClient->queryAssets($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$parent = '[PARENT]';
query_assets_sample($parent);
}
searchAllIamPolicies
Searches all IAM policies within the specified scope, such as a project,
folder, or organization. The caller must be granted the cloudasset.assets.searchAllIamPolicies
permission on the desired scope,
otherwise the request will be rejected.
The async variant is AssetServiceClient::searchAllIamPoliciesAsync() .
request
Google\Cloud\Asset\V1\SearchAllIamPoliciesRequest
A request to house fields associated with the call.
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\IamPolicySearchResult;
use Google\Cloud\Asset\V1\SearchAllIamPoliciesRequest;
/**
* @param string $scope A scope can be a project, a folder, or an organization. The
* search is limited to the IAM policies within the `scope`. The caller must
* be granted the
* [`cloudasset.assets.searchAllIamPolicies`](https://cloud.google.com/asset-inventory/docs/access-control#required_permissions)
* permission on the desired scope.
*
* The allowed values are:
*
* * projects/{PROJECT_ID} (e.g., "projects/foo-bar")
* * projects/{PROJECT_NUMBER} (e.g., "projects/12345678")
* * folders/{FOLDER_NUMBER} (e.g., "folders/1234567")
* * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/123456")
*/
function search_all_iam_policies_sample(string $scope): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new SearchAllIamPoliciesRequest())
->setScope($scope);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $assetServiceClient->searchAllIamPolicies($request);
/** @var IamPolicySearchResult $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$scope = '[SCOPE]';
search_all_iam_policies_sample($scope);
}
searchAllResources
Searches all Google Cloud resources within the specified scope, such as a
project, folder, or organization. The caller must be granted the cloudasset.assets.searchAllResources
permission on the desired scope,
otherwise the request will be rejected.
The async variant is AssetServiceClient::searchAllResourcesAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\ResourceSearchResult;
use Google\Cloud\Asset\V1\SearchAllResourcesRequest;
/**
* @param string $scope A scope can be a project, a folder, or an organization. The
* search is limited to the resources within the `scope`. The caller must be
* granted the
* [`cloudasset.assets.searchAllResources`](https://cloud.google.com/asset-inventory/docs/access-control#required_permissions)
* permission on the desired scope.
*
* The allowed values are:
*
* * projects/{PROJECT_ID} (e.g., "projects/foo-bar")
* * projects/{PROJECT_NUMBER} (e.g., "projects/12345678")
* * folders/{FOLDER_NUMBER} (e.g., "folders/1234567")
* * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/123456")
*/
function search_all_resources_sample(string $scope): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$request = (new SearchAllResourcesRequest())
->setScope($scope);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $assetServiceClient->searchAllResources($request);
/** @var ResourceSearchResult $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$scope = '[SCOPE]';
search_all_resources_sample($scope);
}
updateFeed
Updates an asset feed configuration.
The async variant is AssetServiceClient::updateFeedAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\Feed;
use Google\Cloud\Asset\V1\FeedOutputConfig;
use Google\Cloud\Asset\V1\UpdateFeedRequest;
use Google\Protobuf\FieldMask;
/**
* @param string $feedName The format will be
* projects/{project_number}/feeds/{client-assigned_feed_identifier} or
* folders/{folder_number}/feeds/{client-assigned_feed_identifier} or
* organizations/{organization_number}/feeds/{client-assigned_feed_identifier}
*
* The client-assigned feed identifier must be unique within the parent
* project/folder/organization.
*/
function update_feed_sample(string $feedName): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$feedFeedOutputConfig = new FeedOutputConfig();
$feed = (new Feed())
->setName($feedName)
->setFeedOutputConfig($feedFeedOutputConfig);
$updateMask = new FieldMask();
$request = (new UpdateFeedRequest())
->setFeed($feed)
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var Feed $response */
$response = $assetServiceClient->updateFeed($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$feedName = '[NAME]';
update_feed_sample($feedName);
}
updateSavedQuery
Updates a saved query.
The async variant is AssetServiceClient::updateSavedQueryAsync() .
request
callOptions
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\SavedQuery;
use Google\Cloud\Asset\V1\UpdateSavedQueryRequest;
use Google\Protobuf\FieldMask;
/**
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function update_saved_query_sample(): void
{
// Create a client.
$assetServiceClient = new AssetServiceClient();
// Prepare the request message.
$savedQuery = new SavedQuery();
$updateMask = new FieldMask();
$request = (new UpdateSavedQueryRequest())
->setSavedQuery($savedQuery)
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var SavedQuery $response */
$response = $assetServiceClient->updateSavedQuery($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
analyzeIamPolicyAsync
optionalArgs
array
analyzeIamPolicyLongrunningAsync
optionalArgs
array
analyzeMoveAsync
analyzeOrgPoliciesAsync
optionalArgs
array
analyzeOrgPolicyGovernedAssetsAsync
optionalArgs
array
analyzeOrgPolicyGovernedContainersAsync
optionalArgs
array
batchGetAssetsHistoryAsync
optionalArgs
array
batchGetEffectiveIamPoliciesAsync
optionalArgs
array
createFeedAsync
createSavedQueryAsync
optionalArgs
array
deleteFeedAsync
deleteSavedQueryAsync
optionalArgs
array
exportAssetsAsync
getFeedAsync
getSavedQueryAsync
listAssetsAsync
listFeedsAsync
listSavedQueriesAsync
optionalArgs
array
queryAssetsAsync
searchAllIamPoliciesAsync
optionalArgs
array
searchAllResourcesAsync
optionalArgs
array
updateFeedAsync
updateSavedQueryAsync
optionalArgs
array
getOperationsClient
Return an OperationsClient object with the same endpoint as $this.
Google\LongRunning\Client\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.
operationName
string
The name of the long running operation
methodName
string
The name of the method used to start the operation
static::feedName
Formats a string containing the fully-qualified path to represent a feed resource.
project
string
feed
string
string
static::folderName
Formats a string containing the fully-qualified path to represent a folder resource.
folder
string
string
static::folderFeedName
Formats a string containing the fully-qualified path to represent a folder_feed resource.
folder
string
feed
string
string
static::folderSavedQueryName
Formats a string containing the fully-qualified path to represent a folder_saved_query resource.
folder
string
savedQuery
string
string
static::organizationName
Formats a string containing the fully-qualified path to represent a organization resource.
organization
string
string
static::organizationFeedName
Formats a string containing the fully-qualified path to represent a organization_feed resource.
organization
string
feed
string
string
static::organizationSavedQueryName
Formats a string containing the fully-qualified path to represent a organization_saved_query resource.
organization
string
savedQuery
string
string
static::projectName
Formats a string containing the fully-qualified path to represent a project resource.
project
string
string
static::projectFeedName
Formats a string containing the fully-qualified path to represent a project_feed resource.
project
string
feed
string
string
static::projectSavedQueryName
Formats a string containing the fully-qualified path to represent a project_saved_query resource.
project
string
savedQuery
string
string
static::savedQueryName
Formats a string containing the fully-qualified path to represent a saved_query resource.
project
string
savedQuery
string
string
static::parseName
Parses a formatted name string and returns an associative array of the components in the name.
The following name formats are supported: Template: Pattern
- feed: projects/{project}/feeds/{feed}
- folder: folders/{folder}
- folderFeed: folders/{folder}/feeds/{feed}
- folderSavedQuery: folders/{folder}/savedQueries/{saved_query}
- organization: organizations/{organization}
- organizationFeed: organizations/{organization}/feeds/{feed}
- organizationSavedQuery: organizations/{organization}/savedQueries/{saved_query}
- project: projects/{project}
- projectFeed: projects/{project}/feeds/{feed}
- projectSavedQuery: projects/{project}/savedQueries/{saved_query}
- savedQuery: projects/{project}/savedQueries/{saved_query}
The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.
formattedName
string
The formatted name string
template
?string
Optional name of template to match
array