Google Cloud Gke Backup V1 Client - Class BackupForGKEClient (0.3.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. Sample code to get started:

$backupForGKEClient = new BackupForGKEClient();
try {
    $formattedParent = $backupForGKEClient->backupPlanName('[PROJECT]', '[LOCATION]', '[BACKUP_PLAN]');
    $operationResponse = $backupForGKEClient->createBackup($formattedParent);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
        // doSomethingWith($result)
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
    // Alternatively:
    // start the operation, keep the operation name, and resume later
    $operationResponse = $backupForGKEClient->createBackup($formattedParent);
    $operationName = $operationResponse->getName();
    // ... do other work
    $newOperationResponse = $backupForGKEClient->resumeOperation($operationName, 'createBackup');
    while (!$newOperationResponse->isDone()) {
        // ... do other work
        $newOperationResponse->reload();
    }
    if ($newOperationResponse->operationSucceeded()) {
        $result = $newOperationResponse->getResult();
        // doSomethingWith($result)
    } else {
        $error = $newOperationResponse->getError();
        // handleError($error)
    }
} finally {
    $backupForGKEClient->close();
}

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.

This service has a new (beta) implementation. See Google\Cloud\GkeBackup\V1\Client\BackupForGKEClient to use the new surface.

Namespace

Google \ Cloud \ GkeBackup \ V1

Methods

__construct

Constructor.

Parameters
NameDescription
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.

Parameters
NameDescription
parent string

Required. The BackupPlan within which to create the Backup. Format: projects/*/locations/*/backupPlans/*

optionalArgs array

Optional.

↳ backup Backup

The Backup resource to create.

↳ backupId string

The client-provided short name for the Backup 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 Backups in this BackupPlan

↳ 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
TypeDescription
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.

Parameters
NameDescription
parent string

Required. The location within which to create the BackupPlan. Format: projects/*/locations/*

backupPlan Google\Cloud\GkeBackup\V1\BackupPlan

Required. The BackupPlan resource object to create.

backupPlanId string

Required. 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
optionalArgs 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
TypeDescription
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.

Parameters
NameDescription
parent string

Required. The RestorePlan within which to create the Restore. Format: projects/*/locations/*/restorePlans/*

restore Google\Cloud\GkeBackup\V1\Restore

Required. The restore resource to create.

restoreId string

Required. 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.
optionalArgs 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
TypeDescription
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.

Parameters
NameDescription
parent string

Required. The location within which to create the RestorePlan. Format: projects/*/locations/*

restorePlan Google\Cloud\GkeBackup\V1\RestorePlan

Required. The RestorePlan resource object to create.

restorePlanId string

Required. 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
optionalArgs 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
TypeDescription
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.

Parameters
NameDescription
name string

Required. Name of the Backup resource. Format: projects/*/locations/*/backupPlans/*/backups/*

optionalArgs array

Optional.

↳ etag string

If provided, this value must match the current value of the target Backup's etag field or the request is rejected.

↳ force bool

If set to true, any VolumeBackups below this Backup will also be deleted. Otherwise, the request will only succeed if the Backup has no VolumeBackups.

↳ 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
TypeDescription
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.

Parameters
NameDescription
name string

Required. Fully qualified BackupPlan name. Format: projects/*/locations/*/backupPlans/*

optionalArgs array

Optional.

↳ etag string

If provided, this value must match the current value of the target BackupPlan's etag field or the request is rejected.

↳ 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
TypeDescription
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.

Parameters
NameDescription
name string

Required. Full name of the Restore Format: projects/*/locations/*/restorePlans/*/restores/*

optionalArgs array

Optional.

↳ etag string

If provided, this value must match the current value of the target Restore's etag field or the request is rejected.

↳ force bool

If set to true, any VolumeRestores below this restore will also be deleted. Otherwise, the request will only succeed if the restore has no VolumeRestores.

↳ 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
TypeDescription
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.

Parameters
NameDescription
name string

Required. Fully qualified RestorePlan name. Format: projects/*/locations/*/restorePlans/*

optionalArgs array

Optional.

↳ etag string

If provided, this value must match the current value of the target RestorePlan's etag field or the request is rejected.

↳ force bool

If set to true, any Restores below this RestorePlan will also be deleted. Otherwise, the request will only succeed if the RestorePlan has no Restores.

↳ 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
TypeDescription
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.

Parameters
NameDescription
name string

Required. Full name of the Backup resource. Format: projects/*/locations/*/backupPlans/*/backups/*

optionalArgs 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
TypeDescription
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);
}

getBackupPlan

Retrieve the details of a single BackupPlan.

Parameters
NameDescription
name string

Required. Fully qualified BackupPlan name. Format: projects/*/locations/*/backupPlans/*

optionalArgs 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
TypeDescription
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.

Parameters
NameDescription
name string

Required. Name of the restore resource. Format: projects/*/locations/*/restorePlans/*/restores/*

optionalArgs 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
TypeDescription
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.

Parameters
NameDescription
name string

Required. Fully qualified RestorePlan name. Format: projects/*/locations/*/restorePlans/*

optionalArgs 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
TypeDescription
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.

Parameters
NameDescription
name string

Required. Full name of the VolumeBackup resource. Format: projects/*/locations/*/backupPlans/*/backups/*/volumeBackups/*

optionalArgs 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
TypeDescription
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.

Parameters
NameDescription
name string

Required. Full name of the VolumeRestore resource. Format: projects/*/locations/*/restorePlans/*/restores/*/volumeRestores/*

optionalArgs 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
TypeDescription
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.

Parameters
NameDescription
parent string

Required. The location that contains the BackupPlans to list. Format: projects/*/locations/*

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ filter string

Field match expression used to filter the results.

↳ orderBy string

Field by which to sort the results.

↳ 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
TypeDescription
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.

Parameters
NameDescription
parent string

Required. The BackupPlan that contains the Backups to list. Format: projects/*/locations/*/backupPlans/*

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ filter string

Field match expression used to filter the results.

↳ orderBy string

Field by which to sort the results.

↳ 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
TypeDescription
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.

Parameters
NameDescription
parent string

Required. The location that contains the RestorePlans to list. Format: projects/*/locations/*

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ filter string

Field match expression used to filter the results.

↳ orderBy string

Field by which to sort the results.

↳ 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
TypeDescription
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.

Parameters
NameDescription
parent string

Required. The RestorePlan that contains the Restores to list. Format: projects/*/locations/*/restorePlans/*

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ filter string

Field match expression used to filter the results.

↳ orderBy string

Field by which to sort the results.

↳ 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
TypeDescription
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.

Parameters
NameDescription
parent string

Required. The Backup that contains the VolumeBackups to list. Format: projects/*/locations/*/backupPlans/*/backups/*

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ filter string

Field match expression used to filter the results.

↳ orderBy string

Field by which to sort the results.

↳ 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
TypeDescription
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.

Parameters
NameDescription
parent string

Required. The Restore that contains the VolumeRestores to list. Format: projects/*/locations/*/restorePlans/*/restores/*

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ filter string

Field match expression used to filter the results.

↳ orderBy string

Field by which to sort the results.

↳ 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
TypeDescription
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

Update a Backup.

Parameters
NameDescription
backup Google\Cloud\GkeBackup\V1\Backup

Required. A new version of the Backup resource that contains updated fields. This may be sparsely populated if an update_mask is provided.

optionalArgs array

Optional.

↳ updateMask FieldMask

This is used to specify the fields to be overwritten in the Backup targeted for update. The values for each of these updated fields will be taken from the backup_plan provided with this request. Field names are relative to the root of the resource. If no update_mask is provided, all fields in backup will be written to the target Backup resource. Note that OUTPUT_ONLY and IMMUTABLE fields in backup are ignored and are not used to update the target Backup.

↳ 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
TypeDescription
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

Update a BackupPlan.

Parameters
NameDescription
backupPlan Google\Cloud\GkeBackup\V1\BackupPlan

Required. A new version of the BackupPlan resource that contains updated fields. This may be sparsely populated if an update_mask is provided.

optionalArgs array

Optional.

↳ updateMask FieldMask

This is used to specify the fields to be overwritten in the BackupPlan targeted for update. The values for each of these updated fields will be taken from the backup_plan provided with this request. Field names are relative to the root of the resource (e.g., description, backup_config.include_volume_data, etc.) If no update_mask is provided, all fields in backup_plan will be written to the target BackupPlan resource. Note that OUTPUT_ONLY and IMMUTABLE fields in backup_plan are ignored and are not used to update the target BackupPlan.

↳ 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
TypeDescription
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

Update a Restore.

Parameters
NameDescription
restore Google\Cloud\GkeBackup\V1\Restore

Required. A new version of the Restore resource that contains updated fields. This may be sparsely populated if an update_mask is provided.

optionalArgs array

Optional.

↳ updateMask FieldMask

This is used to specify the fields to be overwritten in the Restore targeted for update. The values for each of these updated fields will be taken from the restore provided with this request. Field names are relative to the root of the resource. If no update_mask is provided, all fields in restore will be written to the target Restore resource. Note that OUTPUT_ONLY and IMMUTABLE fields in restore are ignored and are not used to update the target Restore.

↳ 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
TypeDescription
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

Update a RestorePlan.

Parameters
NameDescription
restorePlan Google\Cloud\GkeBackup\V1\RestorePlan

Required. A new version of the RestorePlan resource that contains updated fields. This may be sparsely populated if an update_mask is provided.

optionalArgs array

Optional.

↳ updateMask FieldMask

This is used to specify the fields to be overwritten in the RestorePlan targeted for update. The values for each of these updated fields will be taken from the restore_plan provided with this request. Field names are relative to the root of the resource. If no update_mask is provided, all fields in restore_plan will be written to the target RestorePlan resource. Note that OUTPUT_ONLY and IMMUTABLE fields in restore_plan are ignored and are not used to update the target RestorePlan.

↳ 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
TypeDescription
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.

Parameters
NameDescription
optionalArgs array

Optional.

↳ name string

Resource name for the location.

↳ 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
TypeDescription
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.

Parameters
NameDescription
optionalArgs array

Optional.

↳ name string

The resource that owns the locations collection, if applicable.

↳ filter string

The standard list filter.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ 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
TypeDescription
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.

Parameters
NameDescription
resource string

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

optionalArgs array

Optional.

↳ options GetPolicyOptions

OPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy.

↳ 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
TypeDescription
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.

Parameters
NameDescription
resource string

REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

policy Google\Cloud\Iam\V1\Policy

REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

optionalArgs array

Optional.

↳ updateMask FieldMask

OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: paths: "bindings, etag"

↳ 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
TypeDescription
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.

Parameters
NameDescription
resource string

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissions string[]

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.

optionalArgs 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
TypeDescription
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);
}

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
TypeDescription
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
NameDescription
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
TypeDescription
Google\ApiCore\OperationResponse

static::backupName

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

Parameters
NameDescription
project string
location string
backupPlan string
backup string
Returns
TypeDescription
stringThe formatted backup resource.

static::backupPlanName

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

Parameters
NameDescription
project string
location string
backupPlan string
Returns
TypeDescription
stringThe formatted backup_plan resource.

static::clusterName

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

Parameters
NameDescription
project string
location string
cluster string
Returns
TypeDescription
stringThe formatted cluster resource.

static::cryptoKeyName

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

Parameters
NameDescription
project string
location string
keyRing string
cryptoKey string
Returns
TypeDescription
stringThe formatted crypto_key resource.

static::locationName

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

Parameters
NameDescription
project string
location string
Returns
TypeDescription
stringThe formatted location resource.

static::restoreName

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

Parameters
NameDescription
project string
location string
restorePlan string
restore string
Returns
TypeDescription
stringThe formatted restore resource.

static::restorePlanName

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

Parameters
NameDescription
project string
location string
restorePlan string
Returns
TypeDescription
stringThe formatted restore_plan resource.

static::volumeBackupName

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

Parameters
NameDescription
project string
location string
backupPlan string
backup string
volumeBackup string
Returns
TypeDescription
stringThe formatted volume_backup resource.

static::volumeRestoreName

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

Parameters
NameDescription
project string
location string
restorePlan string
restore string
volumeRestore string
Returns
TypeDescription
stringThe 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
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.

Constants

SERVICE_NAME

Value: 'google.cloud.gkebackup.v1.BackupForGKE'

The name of the service.

SERVICE_ADDRESS

Value: 'gkebackup.googleapis.com'

The default address of the service.

DEFAULT_SERVICE_PORT

Value: 443

The default port of the service.

CODEGEN_NAME

Value: 'gapic'

The name of the code generator, to be included in the agent header.