Google Cloud Gke Backup V1 Client - Class BackupForGKEClient (0.7.1)

Reference documentation and code samples for the Google Cloud Gke Backup V1 Client class BackupForGKEClient.

Service Description: BackupForGKE allows Kubernetes administrators to configure, execute, and manage backup and restore operations for their GKE clusters.

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 \ GkeBackup \ 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.

createBackup

Creates a Backup for the given BackupPlan.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::createBackupAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\CreateBackupRequest

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\GkeBackup\V1\Backup;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\CreateBackupRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The BackupPlan within which to create the Backup.
 *                                Format: `projects/*/locations/*/backupPlans/*`
 *                                Please see {@see BackupForGKEClient::backupPlanName()} for help formatting this field.
 */
function create_backup_sample(string $formattedParent): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

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

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

    create_backup_sample($formattedParent);
}

createBackupPlan

Creates a new BackupPlan in a given location.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::createBackupPlanAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\CreateBackupPlanRequest

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\GkeBackup\V1\BackupPlan;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\CreateBackupPlanRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedParent            The location within which to create the BackupPlan.
 *                                           Format: `projects/*/locations/*`
 *                                           Please see {@see BackupForGKEClient::locationName()} for help formatting this field.
 * @param string $formattedBackupPlanCluster Immutable. The source cluster from which Backups will be created
 *                                           via this BackupPlan. Valid formats:
 *
 *                                           - `projects/*/locations/*/clusters/*`
 *                                           - `projects/*/zones/*/clusters/*`
 *                                           Please see {@see BackupForGKEClient::clusterName()} for help formatting this field.
 * @param string $backupPlanId               The client-provided short name for the BackupPlan resource.
 *                                           This name must:
 *
 *                                           - be between 1 and 63 characters long (inclusive)
 *                                           - consist of only lower-case ASCII letters, numbers, and dashes
 *                                           - start with a lower-case letter
 *                                           - end with a lower-case letter or number
 *                                           - be unique within the set of BackupPlans in this location
 */
function create_backup_plan_sample(
    string $formattedParent,
    string $formattedBackupPlanCluster,
    string $backupPlanId
): void {
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

    // Prepare the request message.
    $backupPlan = (new BackupPlan())
        ->setCluster($formattedBackupPlanCluster);
    $request = (new CreateBackupPlanRequest())
        ->setParent($formattedParent)
        ->setBackupPlan($backupPlan)
        ->setBackupPlanId($backupPlanId);

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

        if ($response->operationSucceeded()) {
            /** @var BackupPlan $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 = BackupForGKEClient::locationName('[PROJECT]', '[LOCATION]');
    $formattedBackupPlanCluster = BackupForGKEClient::clusterName(
        '[PROJECT]',
        '[LOCATION]',
        '[CLUSTER]'
    );
    $backupPlanId = '[BACKUP_PLAN_ID]';

    create_backup_plan_sample($formattedParent, $formattedBackupPlanCluster, $backupPlanId);
}

createRestore

Creates a new Restore for the given RestorePlan.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::createRestoreAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\CreateRestoreRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\CreateRestoreRequest;
use Google\Cloud\GkeBackup\V1\Restore;
use Google\Rpc\Status;

/**
 * @param string $formattedParent        The RestorePlan within which to create the Restore.
 *                                       Format: `projects/*/locations/*/restorePlans/*`
 *                                       Please see {@see BackupForGKEClient::restorePlanName()} for help formatting this field.
 * @param string $formattedRestoreBackup Immutable. A reference to the
 *                                       [Backup][google.cloud.gkebackup.v1.Backup] used as the source from which
 *                                       this Restore will restore. Note that this Backup must be a sub-resource of
 *                                       the RestorePlan's
 *                                       [backup_plan][google.cloud.gkebackup.v1.RestorePlan.backup_plan]. Format:
 *                                       `projects/*/locations/*/backupPlans/*/backups/*`. Please see
 *                                       {@see BackupForGKEClient::backupName()} for help formatting this field.
 * @param string $restoreId              The client-provided short name for the Restore resource.
 *                                       This name must:
 *
 *                                       - be between 1 and 63 characters long (inclusive)
 *                                       - consist of only lower-case ASCII letters, numbers, and dashes
 *                                       - start with a lower-case letter
 *                                       - end with a lower-case letter or number
 *                                       - be unique within the set of Restores in this RestorePlan.
 */
function create_restore_sample(
    string $formattedParent,
    string $formattedRestoreBackup,
    string $restoreId
): void {
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

    // Prepare the request message.
    $restore = (new Restore())
        ->setBackup($formattedRestoreBackup);
    $request = (new CreateRestoreRequest())
        ->setParent($formattedParent)
        ->setRestore($restore)
        ->setRestoreId($restoreId);

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

        if ($response->operationSucceeded()) {
            /** @var Restore $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 = BackupForGKEClient::restorePlanName('[PROJECT]', '[LOCATION]', '[RESTORE_PLAN]');
    $formattedRestoreBackup = BackupForGKEClient::backupName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]',
        '[BACKUP]'
    );
    $restoreId = '[RESTORE_ID]';

    create_restore_sample($formattedParent, $formattedRestoreBackup, $restoreId);
}

createRestorePlan

Creates a new RestorePlan in a given location.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::createRestorePlanAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\CreateRestorePlanRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\CreateRestorePlanRequest;
use Google\Cloud\GkeBackup\V1\RestoreConfig;
use Google\Cloud\GkeBackup\V1\RestorePlan;
use Google\Rpc\Status;

/**
 * @param string $formattedParent                The location within which to create the RestorePlan.
 *                                               Format: `projects/*/locations/*`
 *                                               Please see {@see BackupForGKEClient::locationName()} for help formatting this field.
 * @param string $formattedRestorePlanBackupPlan Immutable. A reference to the
 *                                               [BackupPlan][google.cloud.gkebackup.v1.BackupPlan] from which Backups may
 *                                               be used as the source for Restores created via this RestorePlan. Format:
 *                                               `projects/*/locations/*/backupPlans/*`. Please see
 *                                               {@see BackupForGKEClient::backupPlanName()} for help formatting this field.
 * @param string $formattedRestorePlanCluster    Immutable. The target cluster into which Restores created via
 *                                               this RestorePlan will restore data. NOTE: the cluster's region must be the
 *                                               same as the RestorePlan. Valid formats:
 *
 *                                               - `projects/*/locations/*/clusters/*`
 *                                               - `projects/*/zones/*/clusters/*`
 *                                               Please see {@see BackupForGKEClient::clusterName()} for help formatting this field.
 * @param string $restorePlanId                  The client-provided short name for the RestorePlan resource.
 *                                               This name must:
 *
 *                                               - be between 1 and 63 characters long (inclusive)
 *                                               - consist of only lower-case ASCII letters, numbers, and dashes
 *                                               - start with a lower-case letter
 *                                               - end with a lower-case letter or number
 *                                               - be unique within the set of RestorePlans in this location
 */
function create_restore_plan_sample(
    string $formattedParent,
    string $formattedRestorePlanBackupPlan,
    string $formattedRestorePlanCluster,
    string $restorePlanId
): void {
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

    // Prepare the request message.
    $restorePlanRestoreConfig = new RestoreConfig();
    $restorePlan = (new RestorePlan())
        ->setBackupPlan($formattedRestorePlanBackupPlan)
        ->setCluster($formattedRestorePlanCluster)
        ->setRestoreConfig($restorePlanRestoreConfig);
    $request = (new CreateRestorePlanRequest())
        ->setParent($formattedParent)
        ->setRestorePlan($restorePlan)
        ->setRestorePlanId($restorePlanId);

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

        if ($response->operationSucceeded()) {
            /** @var RestorePlan $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 = BackupForGKEClient::locationName('[PROJECT]', '[LOCATION]');
    $formattedRestorePlanBackupPlan = BackupForGKEClient::backupPlanName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]'
    );
    $formattedRestorePlanCluster = BackupForGKEClient::clusterName(
        '[PROJECT]',
        '[LOCATION]',
        '[CLUSTER]'
    );
    $restorePlanId = '[RESTORE_PLAN_ID]';

    create_restore_plan_sample(
        $formattedParent,
        $formattedRestorePlanBackupPlan,
        $formattedRestorePlanCluster,
        $restorePlanId
    );
}

deleteBackup

Deletes an existing Backup.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::deleteBackupAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\DeleteBackupRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\DeleteBackupRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Name of the Backup resource.
 *                              Format: `projects/*/locations/*/backupPlans/*/backups/*`
 *                              Please see {@see BackupForGKEClient::backupName()} for help formatting this field.
 */
function delete_backup_sample(string $formattedName): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $backupForGKEClient->deleteBackup($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 = BackupForGKEClient::backupName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]',
        '[BACKUP]'
    );

    delete_backup_sample($formattedName);
}

deleteBackupPlan

Deletes an existing BackupPlan.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::deleteBackupPlanAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\DeleteBackupPlanRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\DeleteBackupPlanRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Fully qualified BackupPlan name.
 *                              Format: `projects/*/locations/*/backupPlans/*`
 *                              Please see {@see BackupForGKEClient::backupPlanName()} for help formatting this field.
 */
function delete_backup_plan_sample(string $formattedName): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $backupForGKEClient->deleteBackupPlan($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 = BackupForGKEClient::backupPlanName('[PROJECT]', '[LOCATION]', '[BACKUP_PLAN]');

    delete_backup_plan_sample($formattedName);
}

deleteRestore

Deletes an existing Restore.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::deleteRestoreAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\DeleteRestoreRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\DeleteRestoreRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Full name of the Restore
 *                              Format: `projects/*/locations/*/restorePlans/*/restores/*`
 *                              Please see {@see BackupForGKEClient::restoreName()} for help formatting this field.
 */
function delete_restore_sample(string $formattedName): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $backupForGKEClient->deleteRestore($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 = BackupForGKEClient::restoreName(
        '[PROJECT]',
        '[LOCATION]',
        '[RESTORE_PLAN]',
        '[RESTORE]'
    );

    delete_restore_sample($formattedName);
}

deleteRestorePlan

Deletes an existing RestorePlan.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::deleteRestorePlanAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\DeleteRestorePlanRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\DeleteRestorePlanRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Fully qualified RestorePlan name.
 *                              Format: `projects/*/locations/*/restorePlans/*`
 *                              Please see {@see BackupForGKEClient::restorePlanName()} for help formatting this field.
 */
function delete_restore_plan_sample(string $formattedName): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $backupForGKEClient->deleteRestorePlan($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 = BackupForGKEClient::restorePlanName('[PROJECT]', '[LOCATION]', '[RESTORE_PLAN]');

    delete_restore_plan_sample($formattedName);
}

getBackup

Retrieve the details of a single Backup.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::getBackupAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\GetBackupRequest

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\GkeBackup\V1\Backup
Example
use Google\ApiCore\ApiException;
use Google\Cloud\GkeBackup\V1\Backup;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\GetBackupRequest;

/**
 * @param string $formattedName Full name of the Backup resource.
 *                              Format: `projects/*/locations/*/backupPlans/*/backups/*`
 *                              Please see {@see BackupForGKEClient::backupName()} for help formatting this field.
 */
function get_backup_sample(string $formattedName): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Backup $response */
        $response = $backupForGKEClient->getBackup($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 = BackupForGKEClient::backupName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]',
        '[BACKUP]'
    );

    get_backup_sample($formattedName);
}

getBackupIndexDownloadUrl

Retrieve the link to the backupIndex.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::getBackupIndexDownloadUrlAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\GetBackupIndexDownloadUrlRequest

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\GkeBackup\V1\GetBackupIndexDownloadUrlResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\GetBackupIndexDownloadUrlRequest;
use Google\Cloud\GkeBackup\V1\GetBackupIndexDownloadUrlResponse;

/**
 * @param string $formattedBackup Full name of Backup resource.
 *                                Format:
 *                                projects/{project}/locations/{location}/backupPlans/{backup_plan}/backups/{backup}
 *                                Please see {@see BackupForGKEClient::backupName()} for help formatting this field.
 */
function get_backup_index_download_url_sample(string $formattedBackup): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

    // Prepare the request message.
    $request = (new GetBackupIndexDownloadUrlRequest())
        ->setBackup($formattedBackup);

    // Call the API and handle any network failures.
    try {
        /** @var GetBackupIndexDownloadUrlResponse $response */
        $response = $backupForGKEClient->getBackupIndexDownloadUrl($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
{
    $formattedBackup = BackupForGKEClient::backupName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]',
        '[BACKUP]'
    );

    get_backup_index_download_url_sample($formattedBackup);
}

getBackupPlan

Retrieve the details of a single BackupPlan.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::getBackupPlanAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\GetBackupPlanRequest

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\GkeBackup\V1\BackupPlan
Example
use Google\ApiCore\ApiException;
use Google\Cloud\GkeBackup\V1\BackupPlan;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\GetBackupPlanRequest;

/**
 * @param string $formattedName Fully qualified BackupPlan name.
 *                              Format: `projects/*/locations/*/backupPlans/*`
 *                              Please see {@see BackupForGKEClient::backupPlanName()} for help formatting this field.
 */
function get_backup_plan_sample(string $formattedName): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var BackupPlan $response */
        $response = $backupForGKEClient->getBackupPlan($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 = BackupForGKEClient::backupPlanName('[PROJECT]', '[LOCATION]', '[BACKUP_PLAN]');

    get_backup_plan_sample($formattedName);
}

getRestore

Retrieves the details of a single Restore.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::getRestoreAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\GetRestoreRequest

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\GkeBackup\V1\Restore
Example
use Google\ApiCore\ApiException;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\GetRestoreRequest;
use Google\Cloud\GkeBackup\V1\Restore;

/**
 * @param string $formattedName Name of the restore resource.
 *                              Format: `projects/*/locations/*/restorePlans/*/restores/*`
 *                              Please see {@see BackupForGKEClient::restoreName()} for help formatting this field.
 */
function get_restore_sample(string $formattedName): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Restore $response */
        $response = $backupForGKEClient->getRestore($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 = BackupForGKEClient::restoreName(
        '[PROJECT]',
        '[LOCATION]',
        '[RESTORE_PLAN]',
        '[RESTORE]'
    );

    get_restore_sample($formattedName);
}

getRestorePlan

Retrieve the details of a single RestorePlan.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::getRestorePlanAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\GetRestorePlanRequest

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\GkeBackup\V1\RestorePlan
Example
use Google\ApiCore\ApiException;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\GetRestorePlanRequest;
use Google\Cloud\GkeBackup\V1\RestorePlan;

/**
 * @param string $formattedName Fully qualified RestorePlan name.
 *                              Format: `projects/*/locations/*/restorePlans/*`
 *                              Please see {@see BackupForGKEClient::restorePlanName()} for help formatting this field.
 */
function get_restore_plan_sample(string $formattedName): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var RestorePlan $response */
        $response = $backupForGKEClient->getRestorePlan($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 = BackupForGKEClient::restorePlanName('[PROJECT]', '[LOCATION]', '[RESTORE_PLAN]');

    get_restore_plan_sample($formattedName);
}

getVolumeBackup

Retrieve the details of a single VolumeBackup.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::getVolumeBackupAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\GetVolumeBackupRequest

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\GkeBackup\V1\VolumeBackup
Example
use Google\ApiCore\ApiException;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\GetVolumeBackupRequest;
use Google\Cloud\GkeBackup\V1\VolumeBackup;

/**
 * @param string $formattedName Full name of the VolumeBackup resource.
 *                              Format: `projects/*/locations/*/backupPlans/*/backups/*/volumeBackups/*`
 *                              Please see {@see BackupForGKEClient::volumeBackupName()} for help formatting this field.
 */
function get_volume_backup_sample(string $formattedName): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var VolumeBackup $response */
        $response = $backupForGKEClient->getVolumeBackup($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 = BackupForGKEClient::volumeBackupName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]',
        '[BACKUP]',
        '[VOLUME_BACKUP]'
    );

    get_volume_backup_sample($formattedName);
}

getVolumeRestore

Retrieve the details of a single VolumeRestore.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::getVolumeRestoreAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\GetVolumeRestoreRequest

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\GkeBackup\V1\VolumeRestore
Example
use Google\ApiCore\ApiException;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\GetVolumeRestoreRequest;
use Google\Cloud\GkeBackup\V1\VolumeRestore;

/**
 * @param string $formattedName Full name of the VolumeRestore resource.
 *                              Format: `projects/*/locations/*/restorePlans/*/restores/*/volumeRestores/*`
 *                              Please see {@see BackupForGKEClient::volumeRestoreName()} for help formatting this field.
 */
function get_volume_restore_sample(string $formattedName): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var VolumeRestore $response */
        $response = $backupForGKEClient->getVolumeRestore($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 = BackupForGKEClient::volumeRestoreName(
        '[PROJECT]',
        '[LOCATION]',
        '[RESTORE_PLAN]',
        '[RESTORE]',
        '[VOLUME_RESTORE]'
    );

    get_volume_restore_sample($formattedName);
}

listBackupPlans

Lists BackupPlans in a given location.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::listBackupPlansAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\ListBackupPlansRequest

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\GkeBackup\V1\BackupPlan;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\ListBackupPlansRequest;

/**
 * @param string $formattedParent The location that contains the BackupPlans to list.
 *                                Format: `projects/*/locations/*`
 *                                Please see {@see BackupForGKEClient::locationName()} for help formatting this field.
 */
function list_backup_plans_sample(string $formattedParent): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

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

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

    list_backup_plans_sample($formattedParent);
}

listBackups

Lists the Backups for a given BackupPlan.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::listBackupsAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\ListBackupsRequest

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\GkeBackup\V1\Backup;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\ListBackupsRequest;

/**
 * @param string $formattedParent The BackupPlan that contains the Backups to list.
 *                                Format: `projects/*/locations/*/backupPlans/*`
 *                                Please see {@see BackupForGKEClient::backupPlanName()} for help formatting this field.
 */
function list_backups_sample(string $formattedParent): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

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

        /** @var Backup $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 = BackupForGKEClient::backupPlanName('[PROJECT]', '[LOCATION]', '[BACKUP_PLAN]');

    list_backups_sample($formattedParent);
}

listRestorePlans

Lists RestorePlans in a given location.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::listRestorePlansAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\ListRestorePlansRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\ListRestorePlansRequest;
use Google\Cloud\GkeBackup\V1\RestorePlan;

/**
 * @param string $formattedParent The location that contains the RestorePlans to list.
 *                                Format: `projects/*/locations/*`
 *                                Please see {@see BackupForGKEClient::locationName()} for help formatting this field.
 */
function list_restore_plans_sample(string $formattedParent): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

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

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

    list_restore_plans_sample($formattedParent);
}

listRestores

Lists the Restores for a given RestorePlan.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::listRestoresAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\ListRestoresRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\ListRestoresRequest;
use Google\Cloud\GkeBackup\V1\Restore;

/**
 * @param string $formattedParent The RestorePlan that contains the Restores to list.
 *                                Format: `projects/*/locations/*/restorePlans/*`
 *                                Please see {@see BackupForGKEClient::restorePlanName()} for help formatting this field.
 */
function list_restores_sample(string $formattedParent): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

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

        /** @var Restore $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 = BackupForGKEClient::restorePlanName('[PROJECT]', '[LOCATION]', '[RESTORE_PLAN]');

    list_restores_sample($formattedParent);
}

listVolumeBackups

Lists the VolumeBackups for a given Backup.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::listVolumeBackupsAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\ListVolumeBackupsRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\ListVolumeBackupsRequest;
use Google\Cloud\GkeBackup\V1\VolumeBackup;

/**
 * @param string $formattedParent The Backup that contains the VolumeBackups to list.
 *                                Format: `projects/*/locations/*/backupPlans/*/backups/*`
 *                                Please see {@see BackupForGKEClient::backupName()} for help formatting this field.
 */
function list_volume_backups_sample(string $formattedParent): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

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

        /** @var VolumeBackup $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 = BackupForGKEClient::backupName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]',
        '[BACKUP]'
    );

    list_volume_backups_sample($formattedParent);
}

listVolumeRestores

Lists the VolumeRestores for a given Restore.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::listVolumeRestoresAsync() .

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\ListVolumeRestoresRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\ListVolumeRestoresRequest;
use Google\Cloud\GkeBackup\V1\VolumeRestore;

/**
 * @param string $formattedParent The Restore that contains the VolumeRestores to list.
 *                                Format: `projects/*/locations/*/restorePlans/*/restores/*`
 *                                Please see {@see BackupForGKEClient::restoreName()} for help formatting this field.
 */
function list_volume_restores_sample(string $formattedParent): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

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

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

        /** @var VolumeRestore $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 = BackupForGKEClient::restoreName(
        '[PROJECT]',
        '[LOCATION]',
        '[RESTORE_PLAN]',
        '[RESTORE]'
    );

    list_volume_restores_sample($formattedParent);
}

updateBackup

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\UpdateBackupRequest

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\GkeBackup\V1\Backup;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\UpdateBackupRequest;
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_backup_sample(): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

    // Prepare the request message.
    $backup = new Backup();
    $request = (new UpdateBackupRequest())
        ->setBackup($backup);

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

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

updateBackupPlan

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\UpdateBackupPlanRequest

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\GkeBackup\V1\BackupPlan;
use Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\UpdateBackupPlanRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedBackupPlanCluster Immutable. The source cluster from which Backups will be created
 *                                           via this BackupPlan. Valid formats:
 *
 *                                           - `projects/*/locations/*/clusters/*`
 *                                           - `projects/*/zones/*/clusters/*`
 *                                           Please see {@see BackupForGKEClient::clusterName()} for help formatting this field.
 */
function update_backup_plan_sample(string $formattedBackupPlanCluster): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

    // Prepare the request message.
    $backupPlan = (new BackupPlan())
        ->setCluster($formattedBackupPlanCluster);
    $request = (new UpdateBackupPlanRequest())
        ->setBackupPlan($backupPlan);

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

        if ($response->operationSucceeded()) {
            /** @var BackupPlan $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
{
    $formattedBackupPlanCluster = BackupForGKEClient::clusterName(
        '[PROJECT]',
        '[LOCATION]',
        '[CLUSTER]'
    );

    update_backup_plan_sample($formattedBackupPlanCluster);
}

updateRestore

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\UpdateRestoreRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\Restore;
use Google\Cloud\GkeBackup\V1\UpdateRestoreRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedRestoreBackup Immutable. A reference to the
 *                                       [Backup][google.cloud.gkebackup.v1.Backup] used as the source from which
 *                                       this Restore will restore. Note that this Backup must be a sub-resource of
 *                                       the RestorePlan's
 *                                       [backup_plan][google.cloud.gkebackup.v1.RestorePlan.backup_plan]. Format:
 *                                       `projects/*/locations/*/backupPlans/*/backups/*`. Please see
 *                                       {@see BackupForGKEClient::backupName()} for help formatting this field.
 */
function update_restore_sample(string $formattedRestoreBackup): void
{
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

    // Prepare the request message.
    $restore = (new Restore())
        ->setBackup($formattedRestoreBackup);
    $request = (new UpdateRestoreRequest())
        ->setRestore($restore);

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

        if ($response->operationSucceeded()) {
            /** @var Restore $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
{
    $formattedRestoreBackup = BackupForGKEClient::backupName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]',
        '[BACKUP]'
    );

    update_restore_sample($formattedRestoreBackup);
}

updateRestorePlan

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\UpdateRestorePlanRequest

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\GkeBackup\V1\Client\BackupForGKEClient;
use Google\Cloud\GkeBackup\V1\RestoreConfig;
use Google\Cloud\GkeBackup\V1\RestorePlan;
use Google\Cloud\GkeBackup\V1\UpdateRestorePlanRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedRestorePlanBackupPlan Immutable. A reference to the
 *                                               [BackupPlan][google.cloud.gkebackup.v1.BackupPlan] from which Backups may
 *                                               be used as the source for Restores created via this RestorePlan. Format:
 *                                               `projects/*/locations/*/backupPlans/*`. Please see
 *                                               {@see BackupForGKEClient::backupPlanName()} for help formatting this field.
 * @param string $formattedRestorePlanCluster    Immutable. The target cluster into which Restores created via
 *                                               this RestorePlan will restore data. NOTE: the cluster's region must be the
 *                                               same as the RestorePlan. Valid formats:
 *
 *                                               - `projects/*/locations/*/clusters/*`
 *                                               - `projects/*/zones/*/clusters/*`
 *                                               Please see {@see BackupForGKEClient::clusterName()} for help formatting this field.
 */
function update_restore_plan_sample(
    string $formattedRestorePlanBackupPlan,
    string $formattedRestorePlanCluster
): void {
    // Create a client.
    $backupForGKEClient = new BackupForGKEClient();

    // Prepare the request message.
    $restorePlanRestoreConfig = new RestoreConfig();
    $restorePlan = (new RestorePlan())
        ->setBackupPlan($formattedRestorePlanBackupPlan)
        ->setCluster($formattedRestorePlanCluster)
        ->setRestoreConfig($restorePlanRestoreConfig);
    $request = (new UpdateRestorePlanRequest())
        ->setRestorePlan($restorePlan);

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

        if ($response->operationSucceeded()) {
            /** @var RestorePlan $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
{
    $formattedRestorePlanBackupPlan = BackupForGKEClient::backupPlanName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]'
    );
    $formattedRestorePlanCluster = BackupForGKEClient::clusterName(
        '[PROJECT]',
        '[LOCATION]',
        '[CLUSTER]'
    );

    update_restore_plan_sample($formattedRestorePlanBackupPlan, $formattedRestorePlanCluster);
}

getLocation

Gets information about a location.

The async variant is Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient::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\GkeBackup\V1\Client\BackupForGKEClient;
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.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $backupForGKEClient->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\GkeBackup\V1\Client\BackupForGKEClient::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\GkeBackup\V1\Client\BackupForGKEClient;
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.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $backupForGKEClient->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\GkeBackup\V1\Client\BackupForGKEClient::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\GkeBackup\V1\Client\BackupForGKEClient;
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.
    $backupForGKEClient = new BackupForGKEClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $backupForGKEClient->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\GkeBackup\V1\Client\BackupForGKEClient::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\GkeBackup\V1\Client\BackupForGKEClient;
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.
    $backupForGKEClient = new BackupForGKEClient();

    // 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 = $backupForGKEClient->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\GkeBackup\V1\Client\BackupForGKEClient::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\GkeBackup\V1\Client\BackupForGKEClient;
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.
    $backupForGKEClient = new BackupForGKEClient();

    // 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 = $backupForGKEClient->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);
}

createBackupAsync

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

createBackupPlanAsync

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

createRestoreAsync

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

createRestorePlanAsync

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

deleteBackupAsync

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

deleteBackupPlanAsync

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

deleteRestoreAsync

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

deleteRestorePlanAsync

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

getBackupAsync

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

getBackupIndexDownloadUrlAsync

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

getBackupPlanAsync

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

getRestoreAsync

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

getRestorePlanAsync

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

getVolumeBackupAsync

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

getVolumeRestoreAsync

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

listBackupPlansAsync

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

listBackupsAsync

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

listRestorePlansAsync

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

listRestoresAsync

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

listVolumeBackupsAsync

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

listVolumeRestoresAsync

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

updateBackupAsync

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

updateBackupPlanAsync

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

updateRestoreAsync

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

updateRestorePlanAsync

Parameters
Name Description
request Google\Cloud\GkeBackup\V1\UpdateRestorePlanRequest
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\ApiCore\LongRunning\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::backupName

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

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

static::backupPlanName

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

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

static::clusterName

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

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

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

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

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

static::restorePlanName

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

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

static::volumeBackupName

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

Parameters
Name Description
project string
location string
backupPlan string
backup string
volumeBackup string
Returns
Type Description
string The formatted volume_backup resource.

static::volumeRestoreName

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

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

  • backup: projects/{project}/locations/{location}/backupPlans/{backup_plan}/backups/{backup}
  • backupPlan: projects/{project}/locations/{location}/backupPlans/{backup_plan}
  • cluster: projects/{project}/locations/{location}/clusters/{cluster}
  • cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}
  • location: projects/{project}/locations/{location}
  • restore: projects/{project}/locations/{location}/restorePlans/{restore_plan}/restores/{restore}
  • restorePlan: projects/{project}/locations/{location}/restorePlans/{restore_plan}
  • volumeBackup: projects/{project}/locations/{location}/backupPlans/{backup_plan}/backups/{backup}/volumeBackups/{volume_backup}
  • volumeRestore: projects/{project}/locations/{location}/restorePlans/{restore_plan}/restores/{restore}/volumeRestores/{volume_restore}

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.