Reference documentation and code samples for the Google Cloud Assured Workloads V1 Client class AssuredWorkloadsServiceClient.
Service Description: Service to manage AssuredWorkloads.
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 \ AssuredWorkloads \ V1 \ ClientMethods
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
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. |
↳ 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 |
↳ 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 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. |
acknowledgeViolation
Acknowledges an existing violation. By acknowledging a violation, users acknowledge the existence of a compliance violation in their workload and decide to ignore it due to a valid business justification. Acknowledgement is a permanent operation and it cannot be reverted.
The async variant is Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient::acknowledgeViolationAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\AcknowledgeViolationRequest
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. |
Returns | |
---|---|
Type | Description |
Google\Cloud\AssuredWorkloads\V1\AcknowledgeViolationResponse |
use Google\ApiCore\ApiException;
use Google\Cloud\AssuredWorkloads\V1\AcknowledgeViolationRequest;
use Google\Cloud\AssuredWorkloads\V1\AcknowledgeViolationResponse;
use Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient;
/**
* @param string $name The resource name of the Violation to acknowledge.
* Format:
* organizations/{organization}/locations/{location}/workloads/{workload}/violations/{violation}
* @param string $comment Business justification explaining the need for violation acknowledgement
*/
function acknowledge_violation_sample(string $name, string $comment): void
{
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();
// Prepare the request message.
$request = (new AcknowledgeViolationRequest())
->setName($name)
->setComment($comment);
// Call the API and handle any network failures.
try {
/** @var AcknowledgeViolationResponse $response */
$response = $assuredWorkloadsServiceClient->acknowledgeViolation($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
{
$name = '[NAME]';
$comment = '[COMMENT]';
acknowledge_violation_sample($name, $comment);
}
createWorkload
Creates Assured Workload.
The async variant is Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient::createWorkloadAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\CreateWorkloadRequest
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. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1\CreateWorkloadRequest;
use Google\Cloud\AssuredWorkloads\V1\Workload;
use Google\Cloud\AssuredWorkloads\V1\Workload\ComplianceRegime;
use Google\Rpc\Status;
/**
* @param string $formattedParent The resource name of the new Workload's parent.
* Must be of the form `organizations/{org_id}/locations/{location_id}`. Please see
* {@see AssuredWorkloadsServiceClient::locationName()} for help formatting this field.
* @param string $workloadDisplayName The user-assigned display name of the Workload.
* When present it must be between 4 to 30 characters.
* Allowed characters are: lowercase and uppercase letters, numbers,
* hyphen, and spaces.
*
* Example: My Workload
* @param int $workloadComplianceRegime Immutable. Compliance Regime associated with this workload.
*/
function create_workload_sample(
string $formattedParent,
string $workloadDisplayName,
int $workloadComplianceRegime
): void {
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();
// Prepare the request message.
$workload = (new Workload())
->setDisplayName($workloadDisplayName)
->setComplianceRegime($workloadComplianceRegime);
$request = (new CreateWorkloadRequest())
->setParent($formattedParent)
->setWorkload($workload);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $assuredWorkloadsServiceClient->createWorkload($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var Workload $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
{
$formattedParent = AssuredWorkloadsServiceClient::locationName('[ORGANIZATION]', '[LOCATION]');
$workloadDisplayName = '[DISPLAY_NAME]';
$workloadComplianceRegime = ComplianceRegime::COMPLIANCE_REGIME_UNSPECIFIED;
create_workload_sample($formattedParent, $workloadDisplayName, $workloadComplianceRegime);
}
deleteWorkload
Deletes the workload. Make sure that workload's direct children are already in a deleted state, otherwise the request will fail with a FAILED_PRECONDITION error.
The async variant is Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient::deleteWorkloadAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\DeleteWorkloadRequest
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\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1\DeleteWorkloadRequest;
/**
* @param string $formattedName The `name` field is used to identify the workload.
* Format:
* organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
* Please see {@see AssuredWorkloadsServiceClient::workloadName()} for help formatting this field.
*/
function delete_workload_sample(string $formattedName): void
{
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();
// Prepare the request message.
$request = (new DeleteWorkloadRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$assuredWorkloadsServiceClient->deleteWorkload($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 = AssuredWorkloadsServiceClient::workloadName(
'[ORGANIZATION]',
'[LOCATION]',
'[WORKLOAD]'
);
delete_workload_sample($formattedName);
}
getViolation
Retrieves Assured Workload Violation based on ID.
The async variant is Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient::getViolationAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\GetViolationRequest
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. |
Returns | |
---|---|
Type | Description |
Google\Cloud\AssuredWorkloads\V1\Violation |
use Google\ApiCore\ApiException;
use Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1\GetViolationRequest;
use Google\Cloud\AssuredWorkloads\V1\Violation;
/**
* @param string $formattedName The resource name of the Violation to fetch (ie. Violation.name).
* Format:
* organizations/{organization}/locations/{location}/workloads/{workload}/violations/{violation}
* Please see {@see AssuredWorkloadsServiceClient::violationName()} for help formatting this field.
*/
function get_violation_sample(string $formattedName): void
{
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();
// Prepare the request message.
$request = (new GetViolationRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Violation $response */
$response = $assuredWorkloadsServiceClient->getViolation($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 = AssuredWorkloadsServiceClient::violationName(
'[ORGANIZATION]',
'[LOCATION]',
'[WORKLOAD]',
'[VIOLATION]'
);
get_violation_sample($formattedName);
}
getWorkload
Gets Assured Workload associated with a CRM Node
The async variant is Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient::getWorkloadAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\GetWorkloadRequest
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. |
Returns | |
---|---|
Type | Description |
Google\Cloud\AssuredWorkloads\V1\Workload |
use Google\ApiCore\ApiException;
use Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1\GetWorkloadRequest;
use Google\Cloud\AssuredWorkloads\V1\Workload;
/**
* @param string $formattedName The resource name of the Workload to fetch. This is the workload's
* relative path in the API, formatted as
* "organizations/{organization_id}/locations/{location_id}/workloads/{workload_id}".
* For example,
* "organizations/123/locations/us-east1/workloads/assured-workload-1". Please see
* {@see AssuredWorkloadsServiceClient::workloadName()} for help formatting this field.
*/
function get_workload_sample(string $formattedName): void
{
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();
// Prepare the request message.
$request = (new GetWorkloadRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Workload $response */
$response = $assuredWorkloadsServiceClient->getWorkload($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 = AssuredWorkloadsServiceClient::workloadName(
'[ORGANIZATION]',
'[LOCATION]',
'[WORKLOAD]'
);
get_workload_sample($formattedName);
}
listViolations
Lists the Violations in the AssuredWorkload Environment.
Callers may also choose to read across multiple Workloads as per
AIP-159 by using '-' (the hyphen or dash
character) as a wildcard character instead of workload-id in the parent.
Format organizations/{org_id}/locations/{location}/workloads/-
The async variant is Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient::listViolationsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\ListViolationsRequest
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. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1\ListViolationsRequest;
use Google\Cloud\AssuredWorkloads\V1\Violation;
/**
* @param string $formattedParent The Workload name.
* Format `organizations/{org_id}/locations/{location}/workloads/{workload}`. Please see
* {@see AssuredWorkloadsServiceClient::workloadName()} for help formatting this field.
*/
function list_violations_sample(string $formattedParent): void
{
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();
// Prepare the request message.
$request = (new ListViolationsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $assuredWorkloadsServiceClient->listViolations($request);
/** @var Violation $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 = AssuredWorkloadsServiceClient::workloadName(
'[ORGANIZATION]',
'[LOCATION]',
'[WORKLOAD]'
);
list_violations_sample($formattedParent);
}
listWorkloads
Lists Assured Workloads under a CRM Node.
The async variant is Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient::listWorkloadsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\ListWorkloadsRequest
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. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1\ListWorkloadsRequest;
use Google\Cloud\AssuredWorkloads\V1\Workload;
/**
* @param string $formattedParent Parent Resource to list workloads from.
* Must be of the form `organizations/{org_id}/locations/{location}`. Please see
* {@see AssuredWorkloadsServiceClient::locationName()} for help formatting this field.
*/
function list_workloads_sample(string $formattedParent): void
{
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();
// Prepare the request message.
$request = (new ListWorkloadsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $assuredWorkloadsServiceClient->listWorkloads($request);
/** @var Workload $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 = AssuredWorkloadsServiceClient::locationName('[ORGANIZATION]', '[LOCATION]');
list_workloads_sample($formattedParent);
}
restrictAllowedResources
Restrict the list of resources allowed in the Workload environment.
The current list of allowed products can be found at https://cloud.google.com/assured-workloads/docs/supported-products In addition to assuredworkloads.workload.update permission, the user should also have orgpolicy.policy.set permission on the folder resource to use this functionality.
The async variant is Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient::restrictAllowedResourcesAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\RestrictAllowedResourcesRequest
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. |
Returns | |
---|---|
Type | Description |
Google\Cloud\AssuredWorkloads\V1\RestrictAllowedResourcesResponse |
use Google\ApiCore\ApiException;
use Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1\RestrictAllowedResourcesRequest;
use Google\Cloud\AssuredWorkloads\V1\RestrictAllowedResourcesRequest\RestrictionType;
use Google\Cloud\AssuredWorkloads\V1\RestrictAllowedResourcesResponse;
/**
* @param string $name The resource name of the Workload. This is the workloads's
* relative path in the API, formatted as
* "organizations/{organization_id}/locations/{location_id}/workloads/{workload_id}".
* For example,
* "organizations/123/locations/us-east1/workloads/assured-workload-1".
* @param int $restrictionType The type of restriction for using gcp products in the Workload environment.
*/
function restrict_allowed_resources_sample(string $name, int $restrictionType): void
{
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();
// Prepare the request message.
$request = (new RestrictAllowedResourcesRequest())
->setName($name)
->setRestrictionType($restrictionType);
// Call the API and handle any network failures.
try {
/** @var RestrictAllowedResourcesResponse $response */
$response = $assuredWorkloadsServiceClient->restrictAllowedResources($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
{
$name = '[NAME]';
$restrictionType = RestrictionType::RESTRICTION_TYPE_UNSPECIFIED;
restrict_allowed_resources_sample($name, $restrictionType);
}
updateWorkload
Updates an existing workload.
Currently allows updating of workload display_name and labels. For force updates don't set etag field in the Workload. Only one update operation per workload can be in progress.
The async variant is Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient::updateWorkloadAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\UpdateWorkloadRequest
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. |
Returns | |
---|---|
Type | Description |
Google\Cloud\AssuredWorkloads\V1\Workload |
use Google\ApiCore\ApiException;
use Google\Cloud\AssuredWorkloads\V1\Client\AssuredWorkloadsServiceClient;
use Google\Cloud\AssuredWorkloads\V1\UpdateWorkloadRequest;
use Google\Cloud\AssuredWorkloads\V1\Workload;
use Google\Cloud\AssuredWorkloads\V1\Workload\ComplianceRegime;
use Google\Protobuf\FieldMask;
/**
* @param string $workloadDisplayName The user-assigned display name of the Workload.
* When present it must be between 4 to 30 characters.
* Allowed characters are: lowercase and uppercase letters, numbers,
* hyphen, and spaces.
*
* Example: My Workload
* @param int $workloadComplianceRegime Immutable. Compliance Regime associated with this workload.
*/
function update_workload_sample(string $workloadDisplayName, int $workloadComplianceRegime): void
{
// Create a client.
$assuredWorkloadsServiceClient = new AssuredWorkloadsServiceClient();
// Prepare the request message.
$workload = (new Workload())
->setDisplayName($workloadDisplayName)
->setComplianceRegime($workloadComplianceRegime);
$updateMask = new FieldMask();
$request = (new UpdateWorkloadRequest())
->setWorkload($workload)
->setUpdateMask($updateMask);
// Call the API and handle any network failures.
try {
/** @var Workload $response */
$response = $assuredWorkloadsServiceClient->updateWorkload($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
{
$workloadDisplayName = '[DISPLAY_NAME]';
$workloadComplianceRegime = ComplianceRegime::COMPLIANCE_REGIME_UNSPECIFIED;
update_workload_sample($workloadDisplayName, $workloadComplianceRegime);
}
acknowledgeViolationAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\AcknowledgeViolationRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
createWorkloadAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\CreateWorkloadRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
deleteWorkloadAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\DeleteWorkloadRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getViolationAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\GetViolationRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getWorkloadAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\GetWorkloadRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
listViolationsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\ListViolationsRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
listWorkloadsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\ListWorkloadsRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
restrictAllowedResourcesAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\RestrictAllowedResourcesRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
updateWorkloadAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AssuredWorkloads\V1\UpdateWorkloadRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getOperationsClient
Return an OperationsClient object with the same endpoint as $this.
Returns | |
---|---|
Type | Description |
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.
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 |
static::locationName
Formats a string containing the fully-qualified path to represent a location resource.
Parameters | |
---|---|
Name | Description |
organization |
string
|
location |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted location resource. |
static::violationName
Formats a string containing the fully-qualified path to represent a violation resource.
Parameters | |
---|---|
Name | Description |
organization |
string
|
location |
string
|
workload |
string
|
violation |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted violation resource. |
static::workloadName
Formats a string containing the fully-qualified path to represent a workload resource.
Parameters | |
---|---|
Name | Description |
organization |
string
|
location |
string
|
workload |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted workload resource. |
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
- location: organizations/{organization}/locations/{location}
- violation: organizations/{organization}/locations/{location}/workloads/{workload}/violations/{violation}
- workload: organizations/{organization}/locations/{location}/workloads/{workload}
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.
Parameters | |
---|---|
Name | Description |
formattedName |
string
The formatted name string |
template |
string
Optional name of template to match |
Returns | |
---|---|
Type | Description |
array |
An associative array from name component IDs to component values. |