Google Cloud Config V1 Client - Class ConfigClient (1.0.0)

Reference documentation and code samples for the Google Cloud Config V1 Client class ConfigClient.

Service Description: Infrastructure Manager is a managed service that automates the deployment and management of Google Cloud infrastructure resources.

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

Methods

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

createDeployment

Parameters
Name Description
request Google\Cloud\Config\V1\CreateDeploymentRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\CreateDeploymentRequest;
use Google\Cloud\Config\V1\Deployment;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The parent in whose context the Deployment is created. The parent
 *                                value is in the format: 'projects/{project_id}/locations/{location}'. Please see
 *                                {@see ConfigClient::locationName()} for help formatting this field.
 * @param string $deploymentId    The Deployment ID.
 */
function create_deployment_sample(string $formattedParent, string $deploymentId): void
{
    // Create a client.
    $configClient = new ConfigClient();

    // Prepare the request message.
    $deployment = new Deployment();
    $request = (new CreateDeploymentRequest())
        ->setParent($formattedParent)
        ->setDeploymentId($deploymentId)
        ->setDeployment($deployment);

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

        if ($response->operationSucceeded()) {
            /** @var Deployment $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 = ConfigClient::locationName('[PROJECT]', '[LOCATION]');
    $deploymentId = '[DEPLOYMENT_ID]';

    create_deployment_sample($formattedParent, $deploymentId);
}

createPreview

Parameters
Name Description
request Google\Cloud\Config\V1\CreatePreviewRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\CreatePreviewRequest;
use Google\Cloud\Config\V1\Preview;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The parent in whose context the Preview is created. The parent
 *                                value is in the format: 'projects/{project_id}/locations/{location}'. Please see
 *                                {@see ConfigClient::locationName()} for help formatting this field.
 */
function create_preview_sample(string $formattedParent): void
{
    // Create a client.
    $configClient = new ConfigClient();

    // Prepare the request message.
    $preview = new Preview();
    $request = (new CreatePreviewRequest())
        ->setParent($formattedParent)
        ->setPreview($preview);

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

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

    create_preview_sample($formattedParent);
}

deleteDeployment

Parameters
Name Description
request Google\Cloud\Config\V1\DeleteDeploymentRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\DeleteDeploymentRequest;
use Google\Cloud\Config\V1\Deployment;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the Deployment in the format:
 *                              'projects/{project_id}/locations/{location}/deployments/{deployment}'. Please see
 *                              {@see ConfigClient::deploymentName()} for help formatting this field.
 */
function delete_deployment_sample(string $formattedName): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var Deployment $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 = ConfigClient::deploymentName('[PROJECT]', '[LOCATION]', '[DEPLOYMENT]');

    delete_deployment_sample($formattedName);
}

deletePreview

Parameters
Name Description
request Google\Cloud\Config\V1\DeletePreviewRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\DeletePreviewRequest;
use Google\Cloud\Config\V1\Preview;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the Preview in the format:
 *                              'projects/{project_id}/locations/{location}/previews/{preview}'. Please see
 *                              {@see ConfigClient::previewName()} for help formatting this field.
 */
function delete_preview_sample(string $formattedName): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var Preview $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 = ConfigClient::previewName('[PROJECT]', '[LOCATION]', '[PREVIEW]');

    delete_preview_sample($formattedName);
}

deleteStatefile

Deletes Terraform state file in a given deployment.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::deleteStatefileAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\DeleteStatefileRequest

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.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\DeleteStatefileRequest;

/**
 * @param string $formattedName The name of the deployment in the format:
 *                              'projects/{project_id}/locations/{location}/deployments/{deployment}'. Please see
 *                              {@see ConfigClient::deploymentName()} for help formatting this field.
 * @param int    $lockId        Lock ID of the lock file to verify that the user who is deleting
 *                              the state file previously locked the Deployment.
 */
function delete_statefile_sample(string $formattedName, int $lockId): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        $configClient->deleteStatefile($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 = ConfigClient::deploymentName('[PROJECT]', '[LOCATION]', '[DEPLOYMENT]');
    $lockId = 0;

    delete_statefile_sample($formattedName, $lockId);
}

exportDeploymentStatefile

Exports Terraform state file from a given deployment.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::exportDeploymentStatefileAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\ExportDeploymentStatefileRequest

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\Config\V1\Statefile
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\ExportDeploymentStatefileRequest;
use Google\Cloud\Config\V1\Statefile;

/**
 * @param string $formattedParent The parent in whose context the statefile is listed. The parent
 *                                value is in the format:
 *                                'projects/{project_id}/locations/{location}/deployments/{deployment}'. Please see
 *                                {@see ConfigClient::deploymentName()} for help formatting this field.
 */
function export_deployment_statefile_sample(string $formattedParent): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Statefile $response */
        $response = $configClient->exportDeploymentStatefile($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 = ConfigClient::deploymentName('[PROJECT]', '[LOCATION]', '[DEPLOYMENT]');

    export_deployment_statefile_sample($formattedParent);
}

exportLockInfo

Exports the lock info on a locked deployment.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::exportLockInfoAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\ExportLockInfoRequest

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\Config\V1\LockInfo
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\ExportLockInfoRequest;
use Google\Cloud\Config\V1\LockInfo;

/**
 * @param string $formattedName The name of the deployment in the format:
 *                              'projects/{project_id}/locations/{location}/deployments/{deployment}'. Please see
 *                              {@see ConfigClient::deploymentName()} for help formatting this field.
 */
function export_lock_info_sample(string $formattedName): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var LockInfo $response */
        $response = $configClient->exportLockInfo($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 = ConfigClient::deploymentName('[PROJECT]', '[LOCATION]', '[DEPLOYMENT]');

    export_lock_info_sample($formattedName);
}

exportPreviewResult

Parameters
Name Description
request Google\Cloud\Config\V1\ExportPreviewResultRequest

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\Config\V1\ExportPreviewResultResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\ExportPreviewResultRequest;
use Google\Cloud\Config\V1\ExportPreviewResultResponse;

/**
 * @param string $formattedParent The preview whose results should be exported. The preview value
 *                                is in the format:
 *                                'projects/{project_id}/locations/{location}/previews/{preview}'. Please see
 *                                {@see ConfigClient::previewName()} for help formatting this field.
 */
function export_preview_result_sample(string $formattedParent): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var ExportPreviewResultResponse $response */
        $response = $configClient->exportPreviewResult($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 = ConfigClient::previewName('[PROJECT]', '[LOCATION]', '[PREVIEW]');

    export_preview_result_sample($formattedParent);
}

exportRevisionStatefile

Exports Terraform state file from a given revision.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::exportRevisionStatefileAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\ExportRevisionStatefileRequest

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\Config\V1\Statefile
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\ExportRevisionStatefileRequest;
use Google\Cloud\Config\V1\Statefile;

/**
 * @param string $formattedParent The parent in whose context the statefile is listed. The parent
 *                                value is in the format:
 *                                'projects/{project_id}/locations/{location}/deployments/{deployment}/revisions/{revision}'. Please see
 *                                {@see ConfigClient::revisionName()} for help formatting this field.
 */
function export_revision_statefile_sample(string $formattedParent): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Statefile $response */
        $response = $configClient->exportRevisionStatefile($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 = ConfigClient::revisionName(
        '[PROJECT]',
        '[LOCATION]',
        '[DEPLOYMENT]',
        '[REVISION]'
    );

    export_revision_statefile_sample($formattedParent);
}

getDeployment

Parameters
Name Description
request Google\Cloud\Config\V1\GetDeploymentRequest

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\Config\V1\Deployment
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\Deployment;
use Google\Cloud\Config\V1\GetDeploymentRequest;

/**
 * @param string $formattedName The name of the deployment. Format:
 *                              'projects/{project_id}/locations/{location}/deployments/{deployment}'. Please see
 *                              {@see ConfigClient::deploymentName()} for help formatting this field.
 */
function get_deployment_sample(string $formattedName): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Deployment $response */
        $response = $configClient->getDeployment($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 = ConfigClient::deploymentName('[PROJECT]', '[LOCATION]', '[DEPLOYMENT]');

    get_deployment_sample($formattedName);
}

getPreview

Gets details about a Preview.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::getPreviewAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\GetPreviewRequest

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\Config\V1\Preview
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\GetPreviewRequest;
use Google\Cloud\Config\V1\Preview;

/**
 * @param string $formattedName The name of the preview. Format:
 *                              'projects/{project_id}/locations/{location}/previews/{preview}'. Please see
 *                              {@see ConfigClient::previewName()} for help formatting this field.
 */
function get_preview_sample(string $formattedName): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Preview $response */
        $response = $configClient->getPreview($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 = ConfigClient::previewName('[PROJECT]', '[LOCATION]', '[PREVIEW]');

    get_preview_sample($formattedName);
}

getResource

Gets details about a Resource deployed by Infra Manager.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::getResourceAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\GetResourceRequest

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
resource
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\GetResourceRequest;
use Google\Cloud\Config\V1\Resource;

/**
 * @param string $formattedName The name of the Resource in the format:
 *                              'projects/{project_id}/locations/{location}/deployments/{deployment}/revisions/{revision}/resource/{resource}'. Please see
 *                              {@see ConfigClient::resourceName()} for help formatting this field.
 */
function get_resource_sample(string $formattedName): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Resource $response */
        $response = $configClient->getResource($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 = ConfigClient::resourceName(
        '[PROJECT]',
        '[LOCATION]',
        '[DEPLOYMENT]',
        '[REVISION]',
        '[RESOURCE]'
    );

    get_resource_sample($formattedName);
}

getRevision

Gets details about a Revision.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::getRevisionAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\GetRevisionRequest

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\Config\V1\Revision
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\GetRevisionRequest;
use Google\Cloud\Config\V1\Revision;

/**
 * @param string $formattedName The name of the Revision in the format:
 *                              'projects/{project_id}/locations/{location}/deployments/{deployment}/revisions/{revision}'. Please see
 *                              {@see ConfigClient::revisionName()} for help formatting this field.
 */
function get_revision_sample(string $formattedName): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Revision $response */
        $response = $configClient->getRevision($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 = ConfigClient::revisionName(
        '[PROJECT]',
        '[LOCATION]',
        '[DEPLOYMENT]',
        '[REVISION]'
    );

    get_revision_sample($formattedName);
}

getTerraformVersion

Parameters
Name Description
request Google\Cloud\Config\V1\GetTerraformVersionRequest

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\Config\V1\TerraformVersion
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\GetTerraformVersionRequest;
use Google\Cloud\Config\V1\TerraformVersion;

/**
 * @param string $formattedName The name of the TerraformVersion. Format:
 *                              'projects/{project_id}/locations/{location}/terraformVersions/{terraform_version}'
 *                              Please see {@see ConfigClient::terraformVersionName()} for help formatting this field.
 */
function get_terraform_version_sample(string $formattedName): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var TerraformVersion $response */
        $response = $configClient->getTerraformVersion($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 = ConfigClient::terraformVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[TERRAFORM_VERSION]'
    );

    get_terraform_version_sample($formattedName);
}

importStatefile

Imports Terraform state file in a given deployment. The state file does not take effect until the Deployment has been unlocked.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::importStatefileAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\ImportStatefileRequest

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\Config\V1\Statefile
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\ImportStatefileRequest;
use Google\Cloud\Config\V1\Statefile;

/**
 * @param string $formattedParent The parent in whose context the statefile is listed. The parent
 *                                value is in the format:
 *                                'projects/{project_id}/locations/{location}/deployments/{deployment}'. Please see
 *                                {@see ConfigClient::deploymentName()} for help formatting this field.
 * @param int    $lockId          Lock ID of the lock file to verify that the user who is importing
 *                                the state file previously locked the Deployment.
 */
function import_statefile_sample(string $formattedParent, int $lockId): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Statefile $response */
        $response = $configClient->importStatefile($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 = ConfigClient::deploymentName('[PROJECT]', '[LOCATION]', '[DEPLOYMENT]');
    $lockId = 0;

    import_statefile_sample($formattedParent, $lockId);
}

listDeployments

Lists Deployments in a given project and location.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::listDeploymentsAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\ListDeploymentsRequest

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\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\Deployment;
use Google\Cloud\Config\V1\ListDeploymentsRequest;

/**
 * @param string $formattedParent The parent in whose context the Deployments are listed. The
 *                                parent value is in the format:
 *                                'projects/{project_id}/locations/{location}'. Please see
 *                                {@see ConfigClient::locationName()} for help formatting this field.
 */
function list_deployments_sample(string $formattedParent): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

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

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

    list_deployments_sample($formattedParent);
}

listPreviews

Lists Previews in a given project and location.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::listPreviewsAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\ListPreviewsRequest

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\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\ListPreviewsRequest;
use Google\Cloud\Config\V1\Preview;

/**
 * @param string $formattedParent The parent in whose context the Previews are listed. The parent
 *                                value is in the format: 'projects/{project_id}/locations/{location}'. Please see
 *                                {@see ConfigClient::locationName()} for help formatting this field.
 */
function list_previews_sample(string $formattedParent): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

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

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

    list_previews_sample($formattedParent);
}

listResources

Lists Resources in a given revision.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::listResourcesAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\ListResourcesRequest

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\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\ListResourcesRequest;
use Google\Cloud\Config\V1\Resource;

/**
 * @param string $formattedParent The parent in whose context the Resources are listed. The parent
 *                                value is in the format:
 *                                'projects/{project_id}/locations/{location}/deployments/{deployment}/revisions/{revision}'. Please see
 *                                {@see ConfigClient::revisionName()} for help formatting this field.
 */
function list_resources_sample(string $formattedParent): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

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

        /** @var Resource $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 = ConfigClient::revisionName(
        '[PROJECT]',
        '[LOCATION]',
        '[DEPLOYMENT]',
        '[REVISION]'
    );

    list_resources_sample($formattedParent);
}

listRevisions

Lists Revisions of a deployment.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::listRevisionsAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\ListRevisionsRequest

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\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\ListRevisionsRequest;
use Google\Cloud\Config\V1\Revision;

/**
 * @param string $formattedParent The parent in whose context the Revisions are listed. The parent
 *                                value is in the format:
 *                                'projects/{project_id}/locations/{location}/deployments/{deployment}'. Please see
 *                                {@see ConfigClient::deploymentName()} for help formatting this field.
 */
function list_revisions_sample(string $formattedParent): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

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

        /** @var Revision $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 = ConfigClient::deploymentName('[PROJECT]', '[LOCATION]', '[DEPLOYMENT]');

    list_revisions_sample($formattedParent);
}

listTerraformVersions

Lists TerraformVersions in a given project and location.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::listTerraformVersionsAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\ListTerraformVersionsRequest

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\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\ListTerraformVersionsRequest;
use Google\Cloud\Config\V1\TerraformVersion;

/**
 * @param string $formattedParent The parent in whose context the TerraformVersions are listed. The
 *                                parent value is in the format:
 *                                'projects/{project_id}/locations/{location}'. Please see
 *                                {@see ConfigClient::locationName()} for help formatting this field.
 */
function list_terraform_versions_sample(string $formattedParent): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

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

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

    list_terraform_versions_sample($formattedParent);
}

lockDeployment

Locks a deployment.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::lockDeploymentAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\LockDeploymentRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\Deployment;
use Google\Cloud\Config\V1\LockDeploymentRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the deployment in the format:
 *                              'projects/{project_id}/locations/{location}/deployments/{deployment}'. Please see
 *                              {@see ConfigClient::deploymentName()} for help formatting this field.
 */
function lock_deployment_sample(string $formattedName): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var Deployment $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 = ConfigClient::deploymentName('[PROJECT]', '[LOCATION]', '[DEPLOYMENT]');

    lock_deployment_sample($formattedName);
}

unlockDeployment

Unlocks a locked deployment.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::unlockDeploymentAsync() .

Parameters
Name Description
request Google\Cloud\Config\V1\UnlockDeploymentRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\Deployment;
use Google\Cloud\Config\V1\UnlockDeploymentRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the deployment in the format:
 *                              'projects/{project_id}/locations/{location}/deployments/{deployment}'. Please see
 *                              {@see ConfigClient::deploymentName()} for help formatting this field.
 * @param int    $lockId        Lock ID of the lock file to be unlocked.
 */
function unlock_deployment_sample(string $formattedName, int $lockId): void
{
    // Create a client.
    $configClient = new ConfigClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var Deployment $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 = ConfigClient::deploymentName('[PROJECT]', '[LOCATION]', '[DEPLOYMENT]');
    $lockId = 0;

    unlock_deployment_sample($formattedName, $lockId);
}

updateDeployment

Parameters
Name Description
request Google\Cloud\Config\V1\UpdateDeploymentRequest

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
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Config\V1\Deployment;
use Google\Cloud\Config\V1\UpdateDeploymentRequest;
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_deployment_sample(): void
{
    // Create a client.
    $configClient = new ConfigClient();

    // Prepare the request message.
    $deployment = new Deployment();
    $request = (new UpdateDeploymentRequest())
        ->setDeployment($deployment);

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

        if ($response->operationSucceeded()) {
            /** @var Deployment $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 Google\Cloud\Config\V1\Client\ConfigClient::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\Config\V1\Client\ConfigClient;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;

/**
 * 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.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $configClient->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.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::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\Config\V1\Client\ConfigClient;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;

/**
 * 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.
    $configClient = new ConfigClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $configClient->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());
    }
}

getIamPolicy

Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::getIamPolicyAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest

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\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;

/**
 * @param string $resource REQUIRED: The resource for which the policy is being requested.
 *                         See the operation documentation for the appropriate value for this field.
 */
function get_iam_policy_sample(string $resource): void
{
    // Create a client.
    $configClient = new ConfigClient();

    // Prepare the request message.
    $request = (new GetIamPolicyRequest())
        ->setResource($resource);

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $configClient->getIamPolicy($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
{
    $resource = '[RESOURCE]';

    get_iam_policy_sample($resource);
}

setIamPolicy

Sets the access control policy on the specified resource. Replaces any existing policy.

Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED errors.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::setIamPolicyAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest

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\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\Iam\V1\SetIamPolicyRequest;

/**
 * @param string $resource REQUIRED: The resource for which the policy is being specified.
 *                         See the operation documentation for the appropriate value for this field.
 */
function set_iam_policy_sample(string $resource): void
{
    // Create a client.
    $configClient = new ConfigClient();

    // Prepare the request message.
    $policy = new Policy();
    $request = (new SetIamPolicyRequest())
        ->setResource($resource)
        ->setPolicy($policy);

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $configClient->setIamPolicy($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
{
    $resource = '[RESOURCE]';

    set_iam_policy_sample($resource);
}

testIamPermissions

Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.

The async variant is Google\Cloud\Config\V1\Client\ConfigClient::testIamPermissionsAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest

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\Iam\V1\TestIamPermissionsResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Config\V1\Client\ConfigClient;
use Google\Cloud\Iam\V1\TestIamPermissionsRequest;
use Google\Cloud\Iam\V1\TestIamPermissionsResponse;

/**
 * @param string $resource           REQUIRED: The resource for which the policy detail is being requested.
 *                                   See the operation documentation for the appropriate value for this field.
 * @param string $permissionsElement The set of permissions to check for the `resource`. Permissions with
 *                                   wildcards (such as '*' or 'storage.*') are not allowed. For more
 *                                   information see
 *                                   [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
 */
function test_iam_permissions_sample(string $resource, string $permissionsElement): void
{
    // Create a client.
    $configClient = new ConfigClient();

    // Prepare the request message.
    $permissions = [$permissionsElement,];
    $request = (new TestIamPermissionsRequest())
        ->setResource($resource)
        ->setPermissions($permissions);

    // Call the API and handle any network failures.
    try {
        /** @var TestIamPermissionsResponse $response */
        $response = $configClient->testIamPermissions($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
{
    $resource = '[RESOURCE]';
    $permissionsElement = '[PERMISSIONS]';

    test_iam_permissions_sample($resource, $permissionsElement);
}

createDeploymentAsync

Parameters
Name Description
request Google\Cloud\Config\V1\CreateDeploymentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createPreviewAsync

Parameters
Name Description
request Google\Cloud\Config\V1\CreatePreviewRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteDeploymentAsync

Parameters
Name Description
request Google\Cloud\Config\V1\DeleteDeploymentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deletePreviewAsync

Parameters
Name Description
request Google\Cloud\Config\V1\DeletePreviewRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteStatefileAsync

Parameters
Name Description
request Google\Cloud\Config\V1\DeleteStatefileRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

exportDeploymentStatefileAsync

Parameters
Name Description
request Google\Cloud\Config\V1\ExportDeploymentStatefileRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

exportLockInfoAsync

Parameters
Name Description
request Google\Cloud\Config\V1\ExportLockInfoRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

exportPreviewResultAsync

Parameters
Name Description
request Google\Cloud\Config\V1\ExportPreviewResultRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

exportRevisionStatefileAsync

Parameters
Name Description
request Google\Cloud\Config\V1\ExportRevisionStatefileRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getDeploymentAsync

Parameters
Name Description
request Google\Cloud\Config\V1\GetDeploymentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getPreviewAsync

Parameters
Name Description
request Google\Cloud\Config\V1\GetPreviewRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getResourceAsync

Parameters
Name Description
request Google\Cloud\Config\V1\GetResourceRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getRevisionAsync

Parameters
Name Description
request Google\Cloud\Config\V1\GetRevisionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getTerraformVersionAsync

Parameters
Name Description
request Google\Cloud\Config\V1\GetTerraformVersionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

importStatefileAsync

Parameters
Name Description
request Google\Cloud\Config\V1\ImportStatefileRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listDeploymentsAsync

Parameters
Name Description
request Google\Cloud\Config\V1\ListDeploymentsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listPreviewsAsync

Parameters
Name Description
request Google\Cloud\Config\V1\ListPreviewsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listResourcesAsync

Parameters
Name Description
request Google\Cloud\Config\V1\ListResourcesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listRevisionsAsync

Parameters
Name Description
request Google\Cloud\Config\V1\ListRevisionsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listTerraformVersionsAsync

Parameters
Name Description
request Google\Cloud\Config\V1\ListTerraformVersionsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

lockDeploymentAsync

Parameters
Name Description
request Google\Cloud\Config\V1\LockDeploymentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

unlockDeploymentAsync

Parameters
Name Description
request Google\Cloud\Config\V1\UnlockDeploymentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateDeploymentAsync

Parameters
Name Description
request Google\Cloud\Config\V1\UpdateDeploymentRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

setIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

testIamPermissionsAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest
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::deploymentName

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

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

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

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

static::resourceName

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

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

static::revisionName

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

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

static::serviceAccountName

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

Parameters
Name Description
project string
serviceAccount string
Returns
Type Description
string The formatted service_account resource.

static::terraformVersionName

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

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

static::workerPoolName

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

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

  • deployment: projects/{project}/locations/{location}/deployments/{deployment}
  • location: projects/{project}/locations/{location}
  • preview: projects/{project}/locations/{location}/previews/{preview}
  • resource: projects/{project}/locations/{location}/deployments/{deployment}/revisions/{revision}/resources/{resource}
  • revision: projects/{project}/locations/{location}/deployments/{deployment}/revisions/{revision}
  • serviceAccount: projects/{project}/serviceAccounts/{service_account}
  • terraformVersion: projects/{project}/locations/{location}/terraformVersions/{terraform_version}
  • workerPool: projects/{project}/locations/{location}/workerPools/{worker_pool}

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.