# Google Cloud Assured Workloads V1 Client - Class AssuredWorkloadsServiceClient (1.1.3)

1.1.3 (latest) 1.1.2 1.0.5 0.11.5 0.10.2 0.9.1 0.8.3 0.7.3 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 \\ Client

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `options` | `array|https://docs.cloud.google.com/php/docs/reference/gax/latest/Options.ClientOptions.html` 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` | `https://docs.cloud.google.com/php/docs/reference/auth/latest/FetchAuthTokenInterface.html|https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper.html` This option should only be used with a pre-constructed [Google\\Auth\\FetchAuthTokenInterface](https://docs.cloud.google.com/php/docs/reference/auth/latest/FetchAuthTokenInterface.html) or [Google\\ApiCore\\CredentialsWrapper](https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper.html) object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. **Important** : If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is recommended to create the credentials explicitly `use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Cloud\AssuredWorkloads\V1\AssuredWorkloadsServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new AssuredWorkloadsServiceClient(['credentials' => $creds]);` <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()](https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper.html#_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|https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.TransportInterface.html` 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](https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.TransportInterface.html) 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()](https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.GrpcTransport.html#_Google_ApiCore_Transport_GrpcTransport__build__) and [Google\\ApiCore\\Transport\\RestTransport::build()](https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.RestTransport.html#_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|Psr\Log\LoggerInterface` A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag |
| `↳ universeDomain` | `string` The service domain for the client. Defaults to 'googleapis.com'. |

### 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
[AssuredWorkloadsServiceClient::acknowledgeViolationAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Client.AssuredWorkloadsServiceClient#_Google_Cloud_AssuredWorkloads_V1_Client_AssuredWorkloadsServiceClient__acknowledgeViolationAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.AcknowledgeViolationRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.AcknowledgeViolationResponse` |   |

**Example**

    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 [AssuredWorkloadsServiceClient::createWorkloadAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Client.AssuredWorkloadsServiceClient#_Google_Cloud_AssuredWorkloads_V1_Client_AssuredWorkloadsServiceClient__createWorkloadAsync__)
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.CreateWorkloadRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html<https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Workload>` |   |

**Example**

    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 [AssuredWorkloadsServiceClient::deleteWorkloadAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Client.AssuredWorkloadsServiceClient#_Google_Cloud_AssuredWorkloads_V1_Client_AssuredWorkloadsServiceClient__deleteWorkloadAsync__)
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.DeleteWorkloadRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

**Example**

    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 [AssuredWorkloadsServiceClient::getViolationAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Client.AssuredWorkloadsServiceClient#_Google_Cloud_AssuredWorkloads_V1_Client_AssuredWorkloadsServiceClient__getViolationAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.GetViolationRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Violation` |   |

**Example**

    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 [AssuredWorkloadsServiceClient::getWorkloadAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Client.AssuredWorkloadsServiceClient#_Google_Cloud_AssuredWorkloads_V1_Client_AssuredWorkloadsServiceClient__getWorkloadAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.GetWorkloadRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Workload` |   |

**Example**

    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](https://google.aip.dev/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 [AssuredWorkloadsServiceClient::listViolationsAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Client.AssuredWorkloadsServiceClient#_Google_Cloud_AssuredWorkloads_V1_Client_AssuredWorkloadsServiceClient__listViolationsAsync__)
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.ListViolationsRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/PagedListResponse.html` |   |

**Example**

    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 [AssuredWorkloadsServiceClient::listWorkloadsAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Client.AssuredWorkloadsServiceClient#_Google_Cloud_AssuredWorkloads_V1_Client_AssuredWorkloadsServiceClient__listWorkloadsAsync__)
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.ListWorkloadsRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/PagedListResponse.html` |   |

**Example**

    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
[AssuredWorkloadsServiceClient::restrictAllowedResourcesAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Client.AssuredWorkloadsServiceClient#_Google_Cloud_AssuredWorkloads_V1_Client_AssuredWorkloadsServiceClient__restrictAllowedResourcesAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.RestrictAllowedResourcesRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.RestrictAllowedResourcesResponse` |   |

**Example**

    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 [AssuredWorkloadsServiceClient::updateWorkloadAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Client.AssuredWorkloadsServiceClient#_Google_Cloud_AssuredWorkloads_V1_Client_AssuredWorkloadsServiceClient__updateWorkloadAsync__)
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.UpdateWorkloadRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Workload` |   |

**Example**

    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` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.AcknowledgeViolationRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.AcknowledgeViolationResponse>` |   |

### createWorkloadAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.CreateWorkloadRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html>` |   |

### deleteWorkloadAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.DeleteWorkloadRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<void>` |   |

### getViolationAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.GetViolationRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Violation>` |   |

### getWorkloadAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.GetWorkloadRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Workload>` |   |

### listViolationsAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.ListViolationsRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/gax/latest/PagedListResponse.html>` |   |

### listWorkloadsAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.ListWorkloadsRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/gax/latest/PagedListResponse.html>` |   |

### restrictAllowedResourcesAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.RestrictAllowedResourcesRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.RestrictAllowedResourcesResponse>` |   |

### updateWorkloadAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.UpdateWorkloadRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/cloud-assured-workloads/latest/V1.Workload>` |   |

### 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** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html` |   |

### 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. |