Google Cloud Workload Manager V1 Client - Class WorkloadManagerClient (0.1.0)

Reference documentation and code samples for the Google Cloud Workload Manager V1 Client class WorkloadManagerClient.

Service Description: The Workload Manager provides various tools to deploy, validate and observe your workloads running on Google Cloud.

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 \ WorkloadManager \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array|Google\ApiCore\Options\ClientOptions

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 FetchAuthTokenInterface|CredentialsWrapper

This option should only be used with a pre-constructed Google\Auth\FetchAuthTokenInterface or Google\ApiCore\CredentialsWrapper 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\WorkloadManager\V1\WorkloadManagerClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new WorkloadManagerClient(['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() .

↳ 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

↳ universeDomain string

The service domain for the client. Defaults to 'googleapis.com'.

createEvaluation

Creates a new Evaluation in a given project and location.

The async variant is WorkloadManagerClient::createEvaluationAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\CreateEvaluationRequest

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<Google\Cloud\WorkloadManager\V1\Evaluation>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\CreateEvaluationRequest;
use Google\Cloud\WorkloadManager\V1\Evaluation;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The resource prefix of the evaluation location using the form:
 *                                `projects/{project_id}/locations/{location_id}`. Please see
 *                                {@see WorkloadManagerClient::locationName()} for help formatting this field.
 * @param string $evaluationId    Id of the requesting object.
 */
function create_evaluation_sample(string $formattedParent, string $evaluationId): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $evaluation = new Evaluation();
    $request = (new CreateEvaluationRequest())
        ->setParent($formattedParent)
        ->setEvaluationId($evaluationId)
        ->setEvaluation($evaluation);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $workloadManagerClient->createEvaluation($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Evaluation $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 = WorkloadManagerClient::locationName('[PROJECT]', '[LOCATION]');
    $evaluationId = '[EVALUATION_ID]';

    create_evaluation_sample($formattedParent, $evaluationId);
}

deleteEvaluation

Deletes a single Evaluation.

The async variant is WorkloadManagerClient::deleteEvaluationAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\DeleteEvaluationRequest

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<null>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\DeleteEvaluationRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Name of the resource. Please see
 *                              {@see WorkloadManagerClient::evaluationName()} for help formatting this field.
 */
function delete_evaluation_sample(string $formattedName): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $request = (new DeleteEvaluationRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $workloadManagerClient->deleteEvaluation($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } 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
{
    $formattedName = WorkloadManagerClient::evaluationName('[PROJECT]', '[LOCATION]', '[EVALUATION]');

    delete_evaluation_sample($formattedName);
}

deleteExecution

Deletes a single Execution.

The async variant is WorkloadManagerClient::deleteExecutionAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\DeleteExecutionRequest

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<null>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\DeleteExecutionRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Name of the resource. Please see
 *                              {@see WorkloadManagerClient::executionName()} for help formatting this field.
 */
function delete_execution_sample(string $formattedName): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $request = (new DeleteExecutionRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $workloadManagerClient->deleteExecution($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } 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
{
    $formattedName = WorkloadManagerClient::executionName(
        '[PROJECT]',
        '[LOCATION]',
        '[EVALUATION]',
        '[EXECUTION]'
    );

    delete_execution_sample($formattedName);
}

getEvaluation

Gets details of a single Evaluation.

The async variant is WorkloadManagerClient::getEvaluationAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\GetEvaluationRequest

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\WorkloadManager\V1\Evaluation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\Evaluation;
use Google\Cloud\WorkloadManager\V1\GetEvaluationRequest;

/**
 * @param string $formattedName Name of the resource. Please see
 *                              {@see WorkloadManagerClient::evaluationName()} for help formatting this field.
 */
function get_evaluation_sample(string $formattedName): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $request = (new GetEvaluationRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Evaluation $response */
        $response = $workloadManagerClient->getEvaluation($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 = WorkloadManagerClient::evaluationName('[PROJECT]', '[LOCATION]', '[EVALUATION]');

    get_evaluation_sample($formattedName);
}

getExecution

Gets details of a single Execution.

The async variant is WorkloadManagerClient::getExecutionAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\GetExecutionRequest

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\WorkloadManager\V1\Execution
Example
use Google\ApiCore\ApiException;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\Execution;
use Google\Cloud\WorkloadManager\V1\GetExecutionRequest;

/**
 * @param string $formattedName Name of the resource. Please see
 *                              {@see WorkloadManagerClient::executionName()} for help formatting this field.
 */
function get_execution_sample(string $formattedName): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $request = (new GetExecutionRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Execution $response */
        $response = $workloadManagerClient->getExecution($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 = WorkloadManagerClient::executionName(
        '[PROJECT]',
        '[LOCATION]',
        '[EVALUATION]',
        '[EXECUTION]'
    );

    get_execution_sample($formattedName);
}

listEvaluations

Lists Evaluations in a given project and location.

The async variant is WorkloadManagerClient::listEvaluationsAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\ListEvaluationsRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\Evaluation;
use Google\Cloud\WorkloadManager\V1\ListEvaluationsRequest;

/**
 * @param string $formattedParent Parent value for ListEvaluationsRequest. Please see
 *                                {@see WorkloadManagerClient::locationName()} for help formatting this field.
 */
function list_evaluations_sample(string $formattedParent): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $request = (new ListEvaluationsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $workloadManagerClient->listEvaluations($request);

        /** @var Evaluation $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 = WorkloadManagerClient::locationName('[PROJECT]', '[LOCATION]');

    list_evaluations_sample($formattedParent);
}

listExecutionResults

Lists the result of a single evaluation.

The async variant is WorkloadManagerClient::listExecutionResultsAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\ListExecutionResultsRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\ExecutionResult;
use Google\Cloud\WorkloadManager\V1\ListExecutionResultsRequest;

/**
 * @param string $parent The execution results.
 *                       Format: {parent}/evaluations/&#42;/executions/&#42;/results.
 */
function list_execution_results_sample(string $parent): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $request = (new ListExecutionResultsRequest())
        ->setParent($parent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $workloadManagerClient->listExecutionResults($request);

        /** @var ExecutionResult $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_execution_results_sample($parent);
}

listExecutions

Lists Executions in a given project and location.

The async variant is WorkloadManagerClient::listExecutionsAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\ListExecutionsRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\Execution;
use Google\Cloud\WorkloadManager\V1\ListExecutionsRequest;

/**
 * @param string $formattedParent The resource prefix of the Execution using the form:
 *                                `projects/{project}/locations/{location}/evaluations/{evaluation}`. Please see
 *                                {@see WorkloadManagerClient::evaluationName()} for help formatting this field.
 */
function list_executions_sample(string $formattedParent): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $request = (new ListExecutionsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $workloadManagerClient->listExecutions($request);

        /** @var Execution $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 = WorkloadManagerClient::evaluationName('[PROJECT]', '[LOCATION]', '[EVALUATION]');

    list_executions_sample($formattedParent);
}

listRules

Lists rules in a given project.

The async variant is WorkloadManagerClient::listRulesAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\ListRulesRequest

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\WorkloadManager\V1\ListRulesResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\ListRulesRequest;
use Google\Cloud\WorkloadManager\V1\ListRulesResponse;

/**
 * @param string $formattedParent The [project] on which to execute the request. The format is:
 *                                projects/{project_id}/locations/{location}
 *                                Currently, the pre-defined rules are global available to all projects and
 *                                all regions. Please see
 *                                {@see WorkloadManagerClient::locationName()} for help formatting this field.
 */
function list_rules_sample(string $formattedParent): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $request = (new ListRulesRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var ListRulesResponse $response */
        $response = $workloadManagerClient->listRules($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 = WorkloadManagerClient::locationName('[PROJECT]', '[LOCATION]');

    list_rules_sample($formattedParent);
}

listScannedResources

List all scanned resources for a single Execution.

The async variant is WorkloadManagerClient::listScannedResourcesAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\ListScannedResourcesRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\ListScannedResourcesRequest;
use Google\Cloud\WorkloadManager\V1\ScannedResource;

/**
 * @param string $parent Parent for ListScannedResourcesRequest.
 */
function list_scanned_resources_sample(string $parent): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $request = (new ListScannedResourcesRequest())
        ->setParent($parent);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $workloadManagerClient->listScannedResources($request);

        /** @var ScannedResource $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_scanned_resources_sample($parent);
}

runEvaluation

Creates a new Execution in a given project and location.

The async variant is WorkloadManagerClient::runEvaluationAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\RunEvaluationRequest

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<Google\Cloud\WorkloadManager\V1\Execution>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\Execution;
use Google\Cloud\WorkloadManager\V1\RunEvaluationRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The resource name of the Evaluation using the form:
 *                              `projects/{project}/locations/{location}/evaluations/{evaluation}`. Please see
 *                              {@see WorkloadManagerClient::evaluationName()} for help formatting this field.
 * @param string $executionId   ID of the execution which will be created.
 */
function run_evaluation_sample(string $formattedName, string $executionId): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $execution = new Execution();
    $request = (new RunEvaluationRequest())
        ->setName($formattedName)
        ->setExecutionId($executionId)
        ->setExecution($execution);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $workloadManagerClient->runEvaluation($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Execution $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
{
    $formattedName = WorkloadManagerClient::evaluationName('[PROJECT]', '[LOCATION]', '[EVALUATION]');
    $executionId = '[EXECUTION_ID]';

    run_evaluation_sample($formattedName, $executionId);
}

updateEvaluation

Updates the parameters of a single Evaluation.

The async variant is WorkloadManagerClient::updateEvaluationAsync() .

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\UpdateEvaluationRequest

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<Google\Cloud\WorkloadManager\V1\Evaluation>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;
use Google\Cloud\WorkloadManager\V1\Evaluation;
use Google\Cloud\WorkloadManager\V1\UpdateEvaluationRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * 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_evaluation_sample(): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $updateMask = new FieldMask();
    $evaluation = new Evaluation();
    $request = (new UpdateEvaluationRequest())
        ->setUpdateMask($updateMask)
        ->setEvaluation($evaluation);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $workloadManagerClient->updateEvaluation($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Evaluation $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());
    }
}

getLocation

Gets information about a location.

The async variant is WorkloadManagerClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

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\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;

/**
 * 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 get_location_sample(): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $request = new GetLocationRequest();

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $workloadManagerClient->getLocation($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

listLocations

Lists information about the supported locations for this service.

This method can be called in two ways:

List all public locations: Use the path GET /v1/locations. List project-visible locations: Use the path GET /v1/projects/{project_id}/locations. This may include public locations as well as private or other locations specifically visible to the project.

The async variant is WorkloadManagerClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\WorkloadManager\V1\Client\WorkloadManagerClient;

/**
 * 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 list_locations_sample(): void
{
    // Create a client.
    $workloadManagerClient = new WorkloadManagerClient();

    // Prepare the request message.
    $request = new ListLocationsRequest();

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $workloadManagerClient->listLocations($request);

        /** @var Location $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());
    }
}

createEvaluationAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\CreateEvaluationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteEvaluationAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\DeleteEvaluationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteExecutionAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\DeleteExecutionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getEvaluationAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\GetEvaluationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\WorkloadManager\V1\Evaluation>

getExecutionAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\GetExecutionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\WorkloadManager\V1\Execution>

listEvaluationsAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\ListEvaluationsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listExecutionResultsAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\ListExecutionResultsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listExecutionsAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\ListExecutionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listRulesAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\ListRulesRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\WorkloadManager\V1\ListRulesResponse>

listScannedResourcesAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\ListScannedResourcesRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

runEvaluationAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\RunEvaluationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

updateEvaluationAsync

Parameters
Name Description
request Google\Cloud\WorkloadManager\V1\UpdateEvaluationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Location\Location>

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

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::cryptoKeyName

Formats a string containing the fully-qualified path to represent a crypto_key resource.

Parameters
Name Description
project string
location string
keyRing string
cryptoKey string
Returns
Type Description
string The formatted crypto_key resource.

static::evaluationName

Formats a string containing the fully-qualified path to represent a evaluation resource.

Parameters
Name Description
project string
location string
evaluation string
Returns
Type Description
string The formatted evaluation resource.

static::executionName

Formats a string containing the fully-qualified path to represent a execution resource.

Parameters
Name Description
project string
location string
evaluation string
execution string
Returns
Type Description
string The formatted execution resource.

static::locationName

Formats a string containing the fully-qualified path to represent a location resource.

Parameters
Name Description
project string
location string
Returns
Type Description
string The formatted location 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

  • cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}
  • evaluation: projects/{project}/locations/{location}/evaluations/{evaluation}
  • execution: projects/{project}/locations/{location}/evaluations/{evaluation}/executions/{execution}
  • location: projects/{project}/locations/{location}

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.