Google Cloud Backup Dr V1 Client - Class BackupDRClient (0.7.0)

Reference documentation and code samples for the Google Cloud Backup Dr V1 Client class BackupDRClient.

Service Description: The BackupDR Service

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Cloud \ BackupDR \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

↳ logger false|LoggerInterface

A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag

createBackupPlan

Create a BackupPlan

The async variant is BackupDRClient::createBackupPlanAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\BackupPlan;
use Google\Cloud\BackupDR\V1\BackupRule;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\CreateBackupPlanRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedParent                          The `BackupPlan` project and ___location in the format
 *                                                         `projects/{project}/locations/{___location}`. In Cloud BackupDR locations
 *                                                         map to GCP regions, for example **us-central1**. Please see
 *                                                         {@see BackupDRClient::locationName()} for help formatting this field.
 * @param string $backupPlanId                             The name of the `BackupPlan` to create. The name must be unique
 *                                                         for the specified project and ___location.The name must start with a lowercase
 *                                                         letter followed by up to 62 lowercase letters, numbers, or hyphens.
 *                                                         Pattern, /[a-z][a-z0-9-]{,62}/.
 * @param string $backupPlanBackupRulesRuleId              Immutable. The unique id of this `BackupRule`. The `rule_id` is
 *                                                         unique per `BackupPlan`.The `rule_id` must start with a lowercase letter
 *                                                         followed by up to 62 lowercase letters, numbers, or hyphens. Pattern,
 *                                                         /[a-z][a-z0-9-]{,62}/.
 * @param int    $backupPlanBackupRulesBackupRetentionDays Configures the duration for which backup data will be kept. It is
 *                                                         defined in “days”. The value should be greater than or equal to minimum
 *                                                         enforced retention of the backup vault.
 *
 *                                                         Minimum value is 1 and maximum value is 36159 for custom retention
 *                                                         on-demand backup.
 *                                                         Minimum and maximum values are workload specific for all other rules.
 * @param string $backupPlanResourceType                   The resource type to which the `BackupPlan` will be applied.
 *                                                         Examples include, "compute.googleapis.com/Instance",
 *                                                         "sqladmin.googleapis.com/Instance", "alloydb.googleapis.com/Cluster",
 *                                                         "compute.googleapis.com/Disk".
 * @param string $formattedBackupPlanBackupVault           Resource name of backup vault which will be used as storage
 *                                                         ___location for backups. Format:
 *                                                         projects/{project}/locations/{___location}/backupVaults/{backupvault}
 *                                                         Please see {@see BackupDRClient::backupVaultName()} for help formatting this field.
 */
function create_backup_plan_sample(
    string $formattedParent,
    string $backupPlanId,
    string $backupPlanBackupRulesRuleId,
    int $backupPlanBackupRulesBackupRetentionDays,
    string $backupPlanResourceType,
    string $formattedBackupPlanBackupVault
): void {
    // Create a client.
    $backupDRClient = new BackupDRClient();

    // Prepare the request message.
    $backupRule = (new BackupRule())
        ->setRuleId($backupPlanBackupRulesRuleId)
        ->setBackupRetentionDays($backupPlanBackupRulesBackupRetentionDays);
    $backupPlanBackupRules = [$backupRule,];
    $backupPlan = (new BackupPlan())
        ->setBackupRules($backupPlanBackupRules)
        ->setResourceType($backupPlanResourceType)
        ->setBackupVault($formattedBackupPlanBackupVault);
    $request = (new CreateBackupPlanRequest())
        ->setParent($formattedParent)
        ->setBackupPlanId($backupPlanId)
        ->setBackupPlan($backupPlan);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $backupDRClient->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 = BackupDRClient::locationName('[PROJECT]', '[LOCATION]');
    $backupPlanId = '[BACKUP_PLAN_ID]';
    $backupPlanBackupRulesRuleId = '[RULE_ID]';
    $backupPlanBackupRulesBackupRetentionDays = 0;
    $backupPlanResourceType = '[RESOURCE_TYPE]';
    $formattedBackupPlanBackupVault = BackupDRClient::backupVaultName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUPVAULT]'
    );

    create_backup_plan_sample(
        $formattedParent,
        $backupPlanId,
        $backupPlanBackupRulesRuleId,
        $backupPlanBackupRulesBackupRetentionDays,
        $backupPlanResourceType,
        $formattedBackupPlanBackupVault
    );
}

createBackupPlanAssociation

Create a BackupPlanAssociation

The async variant is BackupDRClient::createBackupPlanAssociationAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\CreateBackupPlanAssociationRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\BackupPlanAssociation;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\CreateBackupPlanAssociationRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedParent                          The backup plan association project and ___location in the format
 *                                                         `projects/{project_id}/locations/{___location}`. In Cloud BackupDR locations
 *                                                         map to GCP regions, for example **us-central1**. Please see
 *                                                         {@see BackupDRClient::locationName()} for help formatting this field.
 * @param string $backupPlanAssociationId                  The name of the backup plan association to create. The name must
 *                                                         be unique for the specified project and ___location.
 * @param string $backupPlanAssociationResourceType        Immutable. Resource type of workload on which backupplan is
 *                                                         applied
 * @param string $backupPlanAssociationResource            Immutable. Resource name of workload on which the backup plan is
 *                                                         applied.
 *
 *                                                         The format can either be the resource name (e.g.,
 *                                                         "projects/my-project/zones/us-central1-a/instances/my-instance") or the
 *                                                         full resource URI (e.g.,
 *                                                         "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances/my-instance").
 * @param string $formattedBackupPlanAssociationBackupPlan Resource name of backup plan which needs to be applied on
 *                                                         workload. Format:
 *                                                         projects/{project}/locations/{___location}/backupPlans/{backupPlanId}
 *                                                         Please see {@see BackupDRClient::backupPlanName()} for help formatting this field.
 */
function create_backup_plan_association_sample(
    string $formattedParent,
    string $backupPlanAssociationId,
    string $backupPlanAssociationResourceType,
    string $backupPlanAssociationResource,
    string $formattedBackupPlanAssociationBackupPlan
): void {
    // Create a client.
    $backupDRClient = new BackupDRClient();

    // Prepare the request message.
    $backupPlanAssociation = (new BackupPlanAssociation())
        ->setResourceType($backupPlanAssociationResourceType)
        ->setResource($backupPlanAssociationResource)
        ->setBackupPlan($formattedBackupPlanAssociationBackupPlan);
    $request = (new CreateBackupPlanAssociationRequest())
        ->setParent($formattedParent)
        ->setBackupPlanAssociationId($backupPlanAssociationId)
        ->setBackupPlanAssociation($backupPlanAssociation);

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

        if ($response->operationSucceeded()) {
            /** @var BackupPlanAssociation $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 = BackupDRClient::locationName('[PROJECT]', '[LOCATION]');
    $backupPlanAssociationId = '[BACKUP_PLAN_ASSOCIATION_ID]';
    $backupPlanAssociationResourceType = '[RESOURCE_TYPE]';
    $backupPlanAssociationResource = '[RESOURCE]';
    $formattedBackupPlanAssociationBackupPlan = BackupDRClient::backupPlanName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]'
    );

    create_backup_plan_association_sample(
        $formattedParent,
        $backupPlanAssociationId,
        $backupPlanAssociationResourceType,
        $backupPlanAssociationResource,
        $formattedBackupPlanAssociationBackupPlan
    );
}

createBackupVault

Creates a new BackupVault in a given project and ___location.

The async variant is BackupDRClient::createBackupVaultAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\CreateBackupVaultRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\BackupVault;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\CreateBackupVaultRequest;
use Google\Protobuf\Duration;
use Google\Rpc\Status;

/**
 * @param string $formattedParent Value for parent. Please see
 *                                {@see BackupDRClient::locationName()} for help formatting this field.
 * @param string $backupVaultId   ID of the requesting object
 *                                If auto-generating ID server-side, remove this field and
 *                                backup_vault_id from the method_signature of Create RPC
 */
function create_backup_vault_sample(string $formattedParent, string $backupVaultId): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

    // Prepare the request message.
    $backupVaultBackupMinimumEnforcedRetentionDuration = new Duration();
    $backupVault = (new BackupVault())
        ->setBackupMinimumEnforcedRetentionDuration($backupVaultBackupMinimumEnforcedRetentionDuration);
    $request = (new CreateBackupVaultRequest())
        ->setParent($formattedParent)
        ->setBackupVaultId($backupVaultId)
        ->setBackupVault($backupVault);

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

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

    create_backup_vault_sample($formattedParent, $backupVaultId);
}

createManagementServer

Creates a new ManagementServer in a given project and ___location.

The async variant is BackupDRClient::createManagementServerAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\CreateManagementServerRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\CreateManagementServerRequest;
use Google\Cloud\BackupDR\V1\ManagementServer;
use Google\Rpc\Status;

/**
 * @param string $formattedParent    The management server project and ___location in the format
 *                                   'projects/{project_id}/locations/{___location}'. In Cloud Backup and DR
 *                                   locations map to Google Cloud regions, for example **us-central1**. Please see
 *                                   {@see BackupDRClient::locationName()} for help formatting this field.
 * @param string $managementServerId The name of the management server to create. The name must be
 *                                   unique for the specified project and ___location.
 */
function create_management_server_sample(
    string $formattedParent,
    string $managementServerId
): void {
    // Create a client.
    $backupDRClient = new BackupDRClient();

    // Prepare the request message.
    $managementServer = new ManagementServer();
    $request = (new CreateManagementServerRequest())
        ->setParent($formattedParent)
        ->setManagementServerId($managementServerId)
        ->setManagementServer($managementServer);

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

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

    create_management_server_sample($formattedParent, $managementServerId);
}

deleteBackup

Deletes a Backup.

The async variant is BackupDRClient::deleteBackupAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\Backup;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\DeleteBackupRequest;
use Google\Rpc\Status;

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

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

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

    delete_backup_sample($formattedName);
}

deleteBackupPlan

Deletes a single BackupPlan.

The async variant is BackupDRClient::deleteBackupPlanAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\DeleteBackupPlanRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The resource name of the `BackupPlan` to delete.
 *
 *                              Format: `projects/{project}/locations/{___location}/backupPlans/{backup_plan}`
 *                              Please see {@see BackupDRClient::backupPlanName()} for help formatting this field.
 */
function delete_backup_plan_sample(string $formattedName): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

    delete_backup_plan_sample($formattedName);
}

deleteBackupPlanAssociation

Deletes a single BackupPlanAssociation.

The async variant is BackupDRClient::deleteBackupPlanAssociationAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\DeleteBackupPlanAssociationRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\DeleteBackupPlanAssociationRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Name of the backup plan association resource, in the format
 *                              `projects/{project}/locations/{___location}/backupPlanAssociations/{backupPlanAssociationId}`
 *                              Please see {@see BackupDRClient::backupPlanAssociationName()} for help formatting this field.
 */
function delete_backup_plan_association_sample(string $formattedName): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $backupDRClient->deleteBackupPlanAssociation($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 = BackupDRClient::backupPlanAssociationName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN_ASSOCIATION]'
    );

    delete_backup_plan_association_sample($formattedName);
}

deleteBackupVault

Deletes a BackupVault.

The async variant is BackupDRClient::deleteBackupVaultAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\DeleteBackupVaultRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\DeleteBackupVaultRequest;
use Google\Rpc\Status;

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

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $backupDRClient->deleteBackupVault($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 = BackupDRClient::backupVaultName('[PROJECT]', '[LOCATION]', '[BACKUPVAULT]');

    delete_backup_vault_sample($formattedName);
}

deleteManagementServer

Deletes a single ManagementServer.

The async variant is BackupDRClient::deleteManagementServerAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\DeleteManagementServerRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\DeleteManagementServerRequest;
use Google\Rpc\Status;

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

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $backupDRClient->deleteManagementServer($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 = BackupDRClient::managementServerName(
        '[PROJECT]',
        '[LOCATION]',
        '[MANAGEMENTSERVER]'
    );

    delete_management_server_sample($formattedName);
}

fetchBackupPlanAssociationsForResourceType

List BackupPlanAssociations for a given resource type.

The async variant is BackupDRClient::fetchBackupPlanAssociationsForResourceTypeAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\FetchBackupPlanAssociationsForResourceTypeRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\BackupPlanAssociation;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\FetchBackupPlanAssociationsForResourceTypeRequest;

/**
 * @param string $formattedParent The parent resource name.
 *                                Format: projects/{project}/locations/{___location}
 *                                Please see {@see BackupDRClient::locationName()} for help formatting this field.
 * @param string $resourceType    The type of the GCP resource.
 *                                Ex: sql.googleapis.com/Instance
 */
function fetch_backup_plan_associations_for_resource_type_sample(
    string $formattedParent,
    string $resourceType
): void {
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

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

    fetch_backup_plan_associations_for_resource_type_sample($formattedParent, $resourceType);
}

fetchDataSourceReferencesForResourceType

Fetch DataSourceReferences for a given project, ___location and resource type.

The async variant is BackupDRClient::fetchDataSourceReferencesForResourceTypeAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\FetchDataSourceReferencesForResourceTypeRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\DataSourceReference;
use Google\Cloud\BackupDR\V1\FetchDataSourceReferencesForResourceTypeRequest;

/**
 * @param string $formattedParent The parent resource name.
 *                                Format: projects/{project}/locations/{___location}
 *                                Please see {@see BackupDRClient::locationName()} for help formatting this field.
 * @param string $resourceType    The type of the GCP resource.
 *                                Ex: sql.googleapis.com/Instance
 */
function fetch_data_source_references_for_resource_type_sample(
    string $formattedParent,
    string $resourceType
): void {
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

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

    fetch_data_source_references_for_resource_type_sample($formattedParent, $resourceType);
}

fetchUsableBackupVaults

FetchUsableBackupVaults lists usable BackupVaults in a given project and ___location. Usable BackupVault are the ones that user has backupdr.backupVaults.get permission.

The async variant is BackupDRClient::fetchUsableBackupVaultsAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\FetchUsableBackupVaultsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\BackupVault;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\FetchUsableBackupVaultsRequest;

/**
 * @param string $formattedParent The project and ___location for which to retrieve backupvault stores
 *                                information, in the format 'projects/{project_id}/locations/{___location}'. In
 *                                Cloud Backup and DR, locations map to Google Cloud regions, for example
 *                                **us-central1**.
 *                                To retrieve backupvault stores for all locations, use "-" for the
 *                                '{___location}' value. Please see
 *                                {@see BackupDRClient::locationName()} for help formatting this field.
 */
function fetch_usable_backup_vaults_sample(string $formattedParent): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

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

    fetch_usable_backup_vaults_sample($formattedParent);
}

getBackup

Gets details of a Backup.

The async variant is BackupDRClient::getBackupAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\BackupDR\V1\Backup
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\Backup;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\GetBackupRequest;

/**
 * @param string $formattedName Name of the data source resource name, in the format
 *                              'projects/{project_id}/locations/{___location}/backupVaults/{backupVault}/dataSources/{datasource}/backups/{backup}'
 *                              Please see {@see BackupDRClient::backupName()} for help formatting this field.
 */
function get_backup_sample(string $formattedName): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

    get_backup_sample($formattedName);
}

getBackupPlan

Gets details of a single BackupPlan.

The async variant is BackupDRClient::getBackupPlanAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\BackupDR\V1\BackupPlan
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\BackupPlan;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\GetBackupPlanRequest;

/**
 * @param string $formattedName The resource name of the `BackupPlan` to retrieve.
 *
 *                              Format: `projects/{project}/locations/{___location}/backupPlans/{backup_plan}`
 *                              Please see {@see BackupDRClient::backupPlanName()} for help formatting this field.
 */
function get_backup_plan_sample(string $formattedName): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

    get_backup_plan_sample($formattedName);
}

getBackupPlanAssociation

Gets details of a single BackupPlanAssociation.

The async variant is BackupDRClient::getBackupPlanAssociationAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetBackupPlanAssociationRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\BackupDR\V1\BackupPlanAssociation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\BackupPlanAssociation;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\GetBackupPlanAssociationRequest;

/**
 * @param string $formattedName Name of the backup plan association resource, in the format
 *                              `projects/{project}/locations/{___location}/backupPlanAssociations/{backupPlanAssociationId}`
 *                              Please see {@see BackupDRClient::backupPlanAssociationName()} for help formatting this field.
 */
function get_backup_plan_association_sample(string $formattedName): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var BackupPlanAssociation $response */
        $response = $backupDRClient->getBackupPlanAssociation($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 = BackupDRClient::backupPlanAssociationName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN_ASSOCIATION]'
    );

    get_backup_plan_association_sample($formattedName);
}

getBackupPlanRevision

Gets details of a single BackupPlanRevision.

The async variant is BackupDRClient::getBackupPlanRevisionAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetBackupPlanRevisionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\BackupDR\V1\BackupPlanRevision
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\BackupPlanRevision;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\GetBackupPlanRevisionRequest;

/**
 * @param string $formattedName The resource name of the `BackupPlanRevision` to retrieve.
 *
 *                              Format:
 *                              `projects/{project}/locations/{___location}/backupPlans/{backup_plan}/revisions/{revision}`
 *                              Please see {@see BackupDRClient::backupPlanRevisionName()} for help formatting this field.
 */
function get_backup_plan_revision_sample(string $formattedName): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var BackupPlanRevision $response */
        $response = $backupDRClient->getBackupPlanRevision($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 = BackupDRClient::backupPlanRevisionName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]',
        '[REVISION]'
    );

    get_backup_plan_revision_sample($formattedName);
}

getBackupVault

Gets details of a BackupVault.

The async variant is BackupDRClient::getBackupVaultAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetBackupVaultRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\BackupDR\V1\BackupVault
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\BackupVault;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\GetBackupVaultRequest;

/**
 * @param string $formattedName Name of the backupvault store resource name, in the format
 *                              'projects/{project_id}/locations/{___location}/backupVaults/{resource_name}'
 *                              Please see {@see BackupDRClient::backupVaultName()} for help formatting this field.
 */
function get_backup_vault_sample(string $formattedName): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var BackupVault $response */
        $response = $backupDRClient->getBackupVault($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 = BackupDRClient::backupVaultName('[PROJECT]', '[LOCATION]', '[BACKUPVAULT]');

    get_backup_vault_sample($formattedName);
}

getDataSource

Gets details of a DataSource.

The async variant is BackupDRClient::getDataSourceAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetDataSourceRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\BackupDR\V1\DataSource
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\DataSource;
use Google\Cloud\BackupDR\V1\GetDataSourceRequest;

/**
 * @param string $formattedName Name of the data source resource name, in the format
 *                              'projects/{project_id}/locations/{___location}/backupVaults/{resource_name}/dataSource/{resource_name}'
 *                              Please see {@see BackupDRClient::dataSourceName()} for help formatting this field.
 */
function get_data_source_sample(string $formattedName): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var DataSource $response */
        $response = $backupDRClient->getDataSource($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 = BackupDRClient::dataSourceName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUPVAULT]',
        '[DATASOURCE]'
    );

    get_data_source_sample($formattedName);
}

getDataSourceReference

Gets details of a single DataSourceReference.

The async variant is BackupDRClient::getDataSourceReferenceAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetDataSourceReferenceRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\BackupDR\V1\DataSourceReference
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\DataSourceReference;
use Google\Cloud\BackupDR\V1\GetDataSourceReferenceRequest;

/**
 * @param string $formattedName The name of the DataSourceReference to retrieve.
 *                              Format:
 *                              projects/{project}/locations/{___location}/dataSourceReferences/{data_source_reference}
 *                              Please see {@see BackupDRClient::dataSourceReferenceName()} for help formatting this field.
 */
function get_data_source_reference_sample(string $formattedName): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var DataSourceReference $response */
        $response = $backupDRClient->getDataSourceReference($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 = BackupDRClient::dataSourceReferenceName(
        '[PROJECT]',
        '[LOCATION]',
        '[DATA_SOURCE_REFERENCE]'
    );

    get_data_source_reference_sample($formattedName);
}

getManagementServer

Gets details of a single ManagementServer.

The async variant is BackupDRClient::getManagementServerAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetManagementServerRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\BackupDR\V1\ManagementServer
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\GetManagementServerRequest;
use Google\Cloud\BackupDR\V1\ManagementServer;

/**
 * @param string $formattedName Name of the management server resource name, in the format
 *                              'projects/{project_id}/locations/{___location}/managementServers/{resource_name}'
 *                              Please see {@see BackupDRClient::managementServerName()} for help formatting this field.
 */
function get_management_server_sample(string $formattedName): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var ManagementServer $response */
        $response = $backupDRClient->getManagementServer($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 = BackupDRClient::managementServerName(
        '[PROJECT]',
        '[LOCATION]',
        '[MANAGEMENTSERVER]'
    );

    get_management_server_sample($formattedName);
}

initializeService

Initializes the service related config for a project.

The async variant is BackupDRClient::initializeServiceAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\InitializeServiceRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\InitializeServiceRequest;
use Google\Cloud\BackupDR\V1\InitializeServiceResponse;
use Google\Rpc\Status;

/**
 * @param string $name         The resource name of the serviceConfig used to initialize the
 *                             service. Format:
 *                             `projects/{project_id}/locations/{___location}/serviceConfig`.
 * @param string $resourceType The resource type to which the default service config will be
 *                             applied. Examples include, "compute.googleapis.com/Instance" and
 *                             "storage.googleapis.com/Bucket".
 */
function initialize_service_sample(string $name, string $resourceType): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

    // Prepare the request message.
    $request = (new InitializeServiceRequest())
        ->setName($name)
        ->setResourceType($resourceType);

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

        if ($response->operationSucceeded()) {
            /** @var InitializeServiceResponse $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
{
    $name = '[NAME]';
    $resourceType = '[RESOURCE_TYPE]';

    initialize_service_sample($name, $resourceType);
}

listBackupPlanAssociations

Lists BackupPlanAssociations in a given project and ___location.

The async variant is BackupDRClient::listBackupPlanAssociationsAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\ListBackupPlanAssociationsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\BackupPlanAssociation;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\ListBackupPlanAssociationsRequest;

/**
 * @param string $formattedParent The project and ___location for which to retrieve backup Plan
 *                                Associations information, in the format
 *                                `projects/{project_id}/locations/{___location}`. In Cloud BackupDR, locations
 *                                map to GCP regions, for example **us-central1**. To retrieve backup plan
 *                                associations for all locations, use "-" for the
 *                                `{___location}` value. Please see
 *                                {@see BackupDRClient::locationName()} for help formatting this field.
 */
function list_backup_plan_associations_sample(string $formattedParent): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

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

    list_backup_plan_associations_sample($formattedParent);
}

listBackupPlanRevisions

Lists BackupPlanRevisions in a given project and ___location.

The async variant is BackupDRClient::listBackupPlanRevisionsAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\ListBackupPlanRevisionsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\BackupPlanRevision;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\ListBackupPlanRevisionsRequest;

/**
 * @param string $formattedParent The project and ___location for which to retrieve
 *                                `BackupPlanRevisions` information. Format:
 *                                `projects/{project}/locations/{___location}/backupPlans/{backup_plan}`. In
 *                                Cloud BackupDR, locations map to GCP regions, for e.g. **us-central1**. Please see
 *                                {@see BackupDRClient::backupPlanName()} for help formatting this field.
 */
function list_backup_plan_revisions_sample(string $formattedParent): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

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

    list_backup_plan_revisions_sample($formattedParent);
}

listBackupPlans

Lists BackupPlans in a given project and ___location.

The async variant is BackupDRClient::listBackupPlansAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\BackupPlan;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\ListBackupPlansRequest;

/**
 * @param string $formattedParent The project and ___location for which to retrieve `BackupPlans`
 *                                information. Format: `projects/{project}/locations/{___location}`. In Cloud
 *                                BackupDR, locations map to GCP regions, for e.g. **us-central1**. To
 *                                retrieve backup plans for all locations, use "-" for the
 *                                `{___location}` value. Please see
 *                                {@see BackupDRClient::locationName()} for help formatting this field.
 */
function list_backup_plans_sample(string $formattedParent): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

    list_backup_plans_sample($formattedParent);
}

listBackupVaults

Lists BackupVaults in a given project and ___location.

The async variant is BackupDRClient::listBackupVaultsAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\ListBackupVaultsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\BackupVault;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\ListBackupVaultsRequest;

/**
 * @param string $formattedParent The project and ___location for which to retrieve backupvault stores
 *                                information, in the format 'projects/{project_id}/locations/{___location}'. In
 *                                Cloud Backup and DR, locations map to Google Cloud regions, for example
 *                                **us-central1**.
 *                                To retrieve backupvault stores for all locations, use "-" for the
 *                                '{___location}' value. Please see
 *                                {@see BackupDRClient::locationName()} for help formatting this field.
 */
function list_backup_vaults_sample(string $formattedParent): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

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

    list_backup_vaults_sample($formattedParent);
}

listBackups

Lists Backups in a given project and ___location.

The async variant is BackupDRClient::listBackupsAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\Backup;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\ListBackupsRequest;

/**
 * @param string $formattedParent The project and ___location for which to retrieve backup
 *                                information, in the format
 *                                'projects/{project_id}/locations/{___location}'. In Cloud Backup and DR,
 *                                locations map to Google Cloud regions, for example **us-central1**.
 *                                To retrieve data sources for all locations, use "-" for the
 *                                '{___location}' value. Please see
 *                                {@see BackupDRClient::dataSourceName()} for help formatting this field.
 */
function list_backups_sample(string $formattedParent): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $backupDRClient->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 = BackupDRClient::dataSourceName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUPVAULT]',
        '[DATASOURCE]'
    );

    list_backups_sample($formattedParent);
}

listDataSources

Lists DataSources in a given project and ___location.

The async variant is BackupDRClient::listDataSourcesAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\ListDataSourcesRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\DataSource;
use Google\Cloud\BackupDR\V1\ListDataSourcesRequest;

/**
 * @param string $formattedParent The project and ___location for which to retrieve data
 *                                sources information, in the format
 *                                'projects/{project_id}/locations/{___location}'. In Cloud Backup and DR,
 *                                locations map to Google Cloud regions, for example **us-central1**.
 *                                To retrieve data sources for all locations, use "-" for the
 *                                '{___location}' value. Please see
 *                                {@see BackupDRClient::backupVaultName()} for help formatting this field.
 */
function list_data_sources_sample(string $formattedParent): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

        /** @var DataSource $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 = BackupDRClient::backupVaultName('[PROJECT]', '[LOCATION]', '[BACKUPVAULT]');

    list_data_sources_sample($formattedParent);
}

listManagementServers

Lists ManagementServers in a given project and ___location.

The async variant is BackupDRClient::listManagementServersAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\ListManagementServersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\ListManagementServersRequest;
use Google\Cloud\BackupDR\V1\ManagementServer;

/**
 * @param string $formattedParent The project and ___location for which to retrieve management servers
 *                                information, in the format 'projects/{project_id}/locations/{___location}'. In
 *                                Cloud BackupDR, locations map to Google Cloud regions, for example
 *                                **us-central1**. To retrieve management servers for all locations, use "-"
 *                                for the
 *                                '{___location}' value. Please see
 *                                {@see BackupDRClient::locationName()} for help formatting this field.
 */
function list_management_servers_sample(string $formattedParent): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

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

    list_management_servers_sample($formattedParent);
}

restoreBackup

Restore from a Backup

The async variant is BackupDRClient::restoreBackupAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\RestoreBackupRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\RestoreBackupRequest;
use Google\Cloud\BackupDR\V1\RestoreBackupResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedName The resource name of the Backup instance, in the format
 *                              'projects/*/locations/*/backupVaults/*/dataSources/*/backups/'. Please see
 *                              {@see BackupDRClient::backupName()} for help formatting this field.
 */
function restore_backup_sample(string $formattedName): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var RestoreBackupResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = BackupDRClient::backupName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUPVAULT]',
        '[DATASOURCE]',
        '[BACKUP]'
    );

    restore_backup_sample($formattedName);
}

triggerBackup

Triggers a new Backup.

The async variant is BackupDRClient::triggerBackupAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\TriggerBackupRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\BackupPlanAssociation;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\TriggerBackupRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Name of the backup plan association resource, in the format
 *                              `projects/{project}/locations/{___location}/backupPlanAssociations/{backupPlanAssociationId}`
 *                              Please see {@see BackupDRClient::backupPlanAssociationName()} for help formatting this field.
 * @param string $ruleId        backup rule_id for which a backup needs to be triggered.
 */
function trigger_backup_sample(string $formattedName, string $ruleId): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var BackupPlanAssociation $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = BackupDRClient::backupPlanAssociationName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN_ASSOCIATION]'
    );
    $ruleId = '[RULE_ID]';

    trigger_backup_sample($formattedName, $ruleId);
}

updateBackup

Updates the settings of a Backup.

The async variant is BackupDRClient::updateBackupAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\Backup;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\UpdateBackupRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_backup_sample(): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

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

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

The async variant is BackupDRClient::updateBackupPlanAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\BackupPlan;
use Google\Cloud\BackupDR\V1\BackupRule;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\UpdateBackupPlanRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * @param string $backupPlanBackupRulesRuleId              Immutable. The unique id of this `BackupRule`. The `rule_id` is
 *                                                         unique per `BackupPlan`.The `rule_id` must start with a lowercase letter
 *                                                         followed by up to 62 lowercase letters, numbers, or hyphens. Pattern,
 *                                                         /[a-z][a-z0-9-]{,62}/.
 * @param int    $backupPlanBackupRulesBackupRetentionDays Configures the duration for which backup data will be kept. It is
 *                                                         defined in “days”. The value should be greater than or equal to minimum
 *                                                         enforced retention of the backup vault.
 *
 *                                                         Minimum value is 1 and maximum value is 36159 for custom retention
 *                                                         on-demand backup.
 *                                                         Minimum and maximum values are workload specific for all other rules.
 * @param string $backupPlanResourceType                   The resource type to which the `BackupPlan` will be applied.
 *                                                         Examples include, "compute.googleapis.com/Instance",
 *                                                         "sqladmin.googleapis.com/Instance", "alloydb.googleapis.com/Cluster",
 *                                                         "compute.googleapis.com/Disk".
 * @param string $formattedBackupPlanBackupVault           Resource name of backup vault which will be used as storage
 *                                                         ___location for backups. Format:
 *                                                         projects/{project}/locations/{___location}/backupVaults/{backupvault}
 *                                                         Please see {@see BackupDRClient::backupVaultName()} for help formatting this field.
 */
function update_backup_plan_sample(
    string $backupPlanBackupRulesRuleId,
    int $backupPlanBackupRulesBackupRetentionDays,
    string $backupPlanResourceType,
    string $formattedBackupPlanBackupVault
): void {
    // Create a client.
    $backupDRClient = new BackupDRClient();

    // Prepare the request message.
    $backupRule = (new BackupRule())
        ->setRuleId($backupPlanBackupRulesRuleId)
        ->setBackupRetentionDays($backupPlanBackupRulesBackupRetentionDays);
    $backupPlanBackupRules = [$backupRule,];
    $backupPlan = (new BackupPlan())
        ->setBackupRules($backupPlanBackupRules)
        ->setResourceType($backupPlanResourceType)
        ->setBackupVault($formattedBackupPlanBackupVault);
    $updateMask = new FieldMask();
    $request = (new UpdateBackupPlanRequest())
        ->setBackupPlan($backupPlan)
        ->setUpdateMask($updateMask);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $backupDRClient->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
{
    $backupPlanBackupRulesRuleId = '[RULE_ID]';
    $backupPlanBackupRulesBackupRetentionDays = 0;
    $backupPlanResourceType = '[RESOURCE_TYPE]';
    $formattedBackupPlanBackupVault = BackupDRClient::backupVaultName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUPVAULT]'
    );

    update_backup_plan_sample(
        $backupPlanBackupRulesRuleId,
        $backupPlanBackupRulesBackupRetentionDays,
        $backupPlanResourceType,
        $formattedBackupPlanBackupVault
    );
}

updateBackupPlanAssociation

Update a BackupPlanAssociation.

The async variant is BackupDRClient::updateBackupPlanAssociationAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\UpdateBackupPlanAssociationRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\BackupPlanAssociation;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\UpdateBackupPlanAssociationRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * @param string $backupPlanAssociationResourceType        Immutable. Resource type of workload on which backupplan is
 *                                                         applied
 * @param string $backupPlanAssociationResource            Immutable. Resource name of workload on which the backup plan is
 *                                                         applied.
 *
 *                                                         The format can either be the resource name (e.g.,
 *                                                         "projects/my-project/zones/us-central1-a/instances/my-instance") or the
 *                                                         full resource URI (e.g.,
 *                                                         "https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-a/instances/my-instance").
 * @param string $formattedBackupPlanAssociationBackupPlan Resource name of backup plan which needs to be applied on
 *                                                         workload. Format:
 *                                                         projects/{project}/locations/{___location}/backupPlans/{backupPlanId}
 *                                                         Please see {@see BackupDRClient::backupPlanName()} for help formatting this field.
 */
function update_backup_plan_association_sample(
    string $backupPlanAssociationResourceType,
    string $backupPlanAssociationResource,
    string $formattedBackupPlanAssociationBackupPlan
): void {
    // Create a client.
    $backupDRClient = new BackupDRClient();

    // Prepare the request message.
    $backupPlanAssociation = (new BackupPlanAssociation())
        ->setResourceType($backupPlanAssociationResourceType)
        ->setResource($backupPlanAssociationResource)
        ->setBackupPlan($formattedBackupPlanAssociationBackupPlan);
    $updateMask = new FieldMask();
    $request = (new UpdateBackupPlanAssociationRequest())
        ->setBackupPlanAssociation($backupPlanAssociation)
        ->setUpdateMask($updateMask);

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

        if ($response->operationSucceeded()) {
            /** @var BackupPlanAssociation $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
{
    $backupPlanAssociationResourceType = '[RESOURCE_TYPE]';
    $backupPlanAssociationResource = '[RESOURCE]';
    $formattedBackupPlanAssociationBackupPlan = BackupDRClient::backupPlanName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]'
    );

    update_backup_plan_association_sample(
        $backupPlanAssociationResourceType,
        $backupPlanAssociationResource,
        $formattedBackupPlanAssociationBackupPlan
    );
}

updateBackupVault

Updates the settings of a BackupVault.

The async variant is BackupDRClient::updateBackupVaultAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\UpdateBackupVaultRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\BackupVault;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\UpdateBackupVaultRequest;
use Google\Protobuf\Duration;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_backup_vault_sample(): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

    // Prepare the request message.
    $updateMask = new FieldMask();
    $backupVaultBackupMinimumEnforcedRetentionDuration = new Duration();
    $backupVault = (new BackupVault())
        ->setBackupMinimumEnforcedRetentionDuration($backupVaultBackupMinimumEnforcedRetentionDuration);
    $request = (new UpdateBackupVaultRequest())
        ->setUpdateMask($updateMask)
        ->setBackupVault($backupVault);

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

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

updateDataSource

Updates the settings of a DataSource.

The async variant is BackupDRClient::updateDataSourceAsync() .

Parameters
Name Description
request Google\Cloud\BackupDR\V1\UpdateDataSourceRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\DataSource;
use Google\Cloud\BackupDR\V1\UpdateDataSourceRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function update_data_source_sample(): void
{
    // Create a client.
    $backupDRClient = new BackupDRClient();

    // Prepare the request message.
    $updateMask = new FieldMask();
    $dataSource = new DataSource();
    $request = (new UpdateDataSourceRequest())
        ->setUpdateMask($updateMask)
        ->setDataSource($dataSource);

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

        if ($response->operationSucceeded()) {
            /** @var DataSource $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

getLocation

Gets information about a ___location.

The async variant is BackupDRClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
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.
    $backupDRClient = new BackupDRClient();

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

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

listLocations

Lists information about the supported locations for this service.

The async variant is BackupDRClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
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.
    $backupDRClient = new BackupDRClient();

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

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

        /** @var Location $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

getIamPolicy

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

The async variant is BackupDRClient::getIamPolicyAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
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.
    $backupDRClient = new BackupDRClient();

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

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

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $resource = '[RESOURCE]';

    get_iam_policy_sample($resource);
}

setIamPolicy

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

Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED errors.

The async variant is BackupDRClient::setIamPolicyAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
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.
    $backupDRClient = new BackupDRClient();

    // 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 = $backupDRClient->setIamPolicy($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $resource = '[RESOURCE]';

    set_iam_policy_sample($resource);
}

testIamPermissions

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

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

The async variant is BackupDRClient::testIamPermissionsAsync() .

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

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Iam\V1\TestIamPermissionsResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
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.
    $backupDRClient = new BackupDRClient();

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

createBackupPlanAsync

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

createBackupPlanAssociationAsync

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

createBackupVaultAsync

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

createManagementServerAsync

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

deleteBackupAsync

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

deleteBackupPlanAsync

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

deleteBackupPlanAssociationAsync

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

deleteBackupVaultAsync

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

deleteManagementServerAsync

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

fetchBackupPlanAssociationsForResourceTypeAsync

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

fetchDataSourceReferencesForResourceTypeAsync

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

fetchUsableBackupVaultsAsync

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

getBackupAsync

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetBackupRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\BackupDR\V1\Backup>

getBackupPlanAsync

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetBackupPlanRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\BackupDR\V1\BackupPlan>

getBackupPlanAssociationAsync

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetBackupPlanAssociationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\BackupDR\V1\BackupPlanAssociation>

getBackupPlanRevisionAsync

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetBackupPlanRevisionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\BackupDR\V1\BackupPlanRevision>

getBackupVaultAsync

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetBackupVaultRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\BackupDR\V1\BackupVault>

getDataSourceAsync

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetDataSourceRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\BackupDR\V1\DataSource>

getDataSourceReferenceAsync

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetDataSourceReferenceRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\BackupDR\V1\DataSourceReference>

getManagementServerAsync

Parameters
Name Description
request Google\Cloud\BackupDR\V1\GetManagementServerRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\BackupDR\V1\ManagementServer>

initializeServiceAsync

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

listBackupPlanAssociationsAsync

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

listBackupPlanRevisionsAsync

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

listBackupPlansAsync

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

listBackupVaultsAsync

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

listBackupsAsync

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

listDataSourcesAsync

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

listManagementServersAsync

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

restoreBackupAsync

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

triggerBackupAsync

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

updateBackupAsync

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

updateBackupPlanAsync

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

updateBackupPlanAssociationAsync

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

updateBackupVaultAsync

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

updateDataSourceAsync

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

getLocationAsync

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

listLocationsAsync

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

getIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\Policy>

setIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\Policy>

testIamPermissionsAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\TestIamPermissionsResponse>

getOperationsClient

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

Returns
Type Description
Google\LongRunning\Client\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::backupName

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

Parameters
Name Description
project string
___location string
backupvault string
datasource string
backup string
Returns
Type Description
string The formatted backup resource.

static::backupPlanName

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

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

static::backupPlanAssociationName

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

Parameters
Name Description
project string
___location string
backupPlanAssociation string
Returns
Type Description
string The formatted backup_plan_association resource.

static::backupPlanRevisionName

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

Parameters
Name Description
project string
___location string
backupPlan string
revision string
Returns
Type Description
string The formatted backup_plan_revision resource.

static::backupVaultName

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

Parameters
Name Description
project string
___location string
backupvault string
Returns
Type Description
string The formatted backup_vault resource.

static::dataSourceName

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

Parameters
Name Description
project string
___location string
backupvault string
datasource string
Returns
Type Description
string The formatted data_source resource.

static::dataSourceReferenceName

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

Parameters
Name Description
project string
___location string
dataSourceReference string
Returns
Type Description
string The formatted data_source_reference resource.

static::instanceName

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

Parameters
Name Description
project string
instance string
Returns
Type Description
string The formatted instance resource.

static::locationName

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

Parameters
Name Description
project string
___location string
Returns
Type Description
string The formatted ___location resource.

static::managementServerName

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

Parameters
Name Description
project string
___location string
managementserver string
Returns
Type Description
string The formatted management_server resource.

static::storagePoolName

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

Parameters
Name Description
project string
zone string
storagePool string
Returns
Type Description
string The formatted storage_pool resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • backup: projects/{project}/locations/{___location}/backupVaults/{backupvault}/dataSources/{datasource}/backups/{backup}
  • backupPlan: projects/{project}/locations/{___location}/backupPlans/{backup_plan}
  • backupPlanAssociation: projects/{project}/locations/{___location}/backupPlanAssociations/{backup_plan_association}
  • backupPlanRevision: projects/{project}/locations/{___location}/backupPlans/{backup_plan}/revisions/{revision}
  • backupVault: projects/{project}/locations/{___location}/backupVaults/{backupvault}
  • dataSource: projects/{project}/locations/{___location}/backupVaults/{backupvault}/dataSources/{datasource}
  • dataSourceReference: projects/{project}/locations/{___location}/dataSourceReferences/{data_source_reference}
  • instance: projects/{project}/instances/{instance}
  • ___location: projects/{project}/locations/{___location}
  • managementServer: projects/{project}/locations/{___location}/managementServers/{managementserver}
  • storagePool: projects/{project}/zones/{zone}/storagePools/{storage_pool}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
Name Description
formattedName string

The formatted name string

template ?string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.