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

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.

↳ 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\BackupWindow;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Cloud\BackupDR\V1\CreateBackupPlanRequest;
use Google\Cloud\BackupDR\V1\StandardSchedule;
use Google\Cloud\BackupDR\V1\StandardSchedule\RecurrenceType;
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.
 * @param int    $backupPlanBackupRulesStandardScheduleRecurrenceType             Specifies the `RecurrenceType` for the schedule.
 * @param int    $backupPlanBackupRulesStandardScheduleBackupWindowStartHourOfDay The hour of day (0-23) when the window starts for e.g. if value
 *                                                                                of start hour of day is 6 that mean backup window start at 6:00.
 * @param int    $backupPlanBackupRulesStandardScheduleBackupWindowEndHourOfDay   The hour of day (1-24) when the window end for e.g. if value of
 *                                                                                end hour of day is 10 that mean backup window end time is 10:00.
 *
 *                                                                                End hour of day should be greater than start hour of day.
 *                                                                                0 <= start_hour_of_day < end_hour_of_day <= 24
 *
 *                                                                                End hour of day is not include in backup window that mean if
 *                                                                                end_hour_of_day= 10 jobs should start before 10:00.
 * @param string $backupPlanBackupRulesStandardScheduleTimeZone                   The time zone to be used when interpreting the schedule.
 *                                                                                The value of this field must be a time zone name from the IANA tz database.
 *                                                                                See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for the
 *                                                                                list of valid timezone names. For e.g., Europe/Paris.
 * @param string $backupPlanResourceType                                          The resource type to which the `BackupPlan` will be applied.
 *                                                                                Examples include, "compute.googleapis.com/Instance" and
 *                                                                                "storage.googleapis.com/Bucket".
 * @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,
    int $backupPlanBackupRulesStandardScheduleRecurrenceType,
    int $backupPlanBackupRulesStandardScheduleBackupWindowStartHourOfDay,
    int $backupPlanBackupRulesStandardScheduleBackupWindowEndHourOfDay,
    string $backupPlanBackupRulesStandardScheduleTimeZone,
    string $backupPlanResourceType,
    string $formattedBackupPlanBackupVault
): void {
    // Create a client.
    $backupDRClient = new BackupDRClient();

    // Prepare the request message.
    $backupPlanBackupRulesStandardScheduleBackupWindow = (new BackupWindow())
        ->setStartHourOfDay($backupPlanBackupRulesStandardScheduleBackupWindowStartHourOfDay)
        ->setEndHourOfDay($backupPlanBackupRulesStandardScheduleBackupWindowEndHourOfDay);
    $backupPlanBackupRulesStandardSchedule = (new StandardSchedule())
        ->setRecurrenceType($backupPlanBackupRulesStandardScheduleRecurrenceType)
        ->setBackupWindow($backupPlanBackupRulesStandardScheduleBackupWindow)
        ->setTimeZone($backupPlanBackupRulesStandardScheduleTimeZone);
    $backupRule = (new BackupRule())
        ->setRuleId($backupPlanBackupRulesRuleId)
        ->setBackupRetentionDays($backupPlanBackupRulesBackupRetentionDays)
        ->setStandardSchedule($backupPlanBackupRulesStandardSchedule);
    $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;
    $backupPlanBackupRulesStandardScheduleRecurrenceType = RecurrenceType::RECURRENCE_TYPE_UNSPECIFIED;
    $backupPlanBackupRulesStandardScheduleBackupWindowStartHourOfDay = 0;
    $backupPlanBackupRulesStandardScheduleBackupWindowEndHourOfDay = 0;
    $backupPlanBackupRulesStandardScheduleTimeZone = '[TIME_ZONE]';
    $backupPlanResourceType = '[RESOURCE_TYPE]';
    $formattedBackupPlanBackupVault = BackupDRClient::backupVaultName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUPVAULT]'
    );

    create_backup_plan_sample(
        $formattedParent,
        $backupPlanId,
        $backupPlanBackupRulesRuleId,
        $backupPlanBackupRulesBackupRetentionDays,
        $backupPlanBackupRulesStandardScheduleRecurrenceType,
        $backupPlanBackupRulesStandardScheduleBackupWindowStartHourOfDay,
        $backupPlanBackupRulesStandardScheduleBackupWindowEndHourOfDay,
        $backupPlanBackupRulesStandardScheduleTimeZone,
        $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 $backupPlanAssociationResource            Immutable. Resource name of workload on which backupplan is
 *                                                         applied
 * @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 $backupPlanAssociationResource,
    string $formattedBackupPlanAssociationBackupPlan
): void {
    // Create a client.
    $backupDRClient = new BackupDRClient();

    // Prepare the request message.
    $backupPlanAssociation = (new BackupPlanAssociation())
        ->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]';
    $backupPlanAssociationResource = '[RESOURCE]';
    $formattedBackupPlanAssociationBackupPlan = BackupDRClient::backupPlanName(
        '[PROJECT]',
        '[LOCATION]',
        '[BACKUP_PLAN]'
    );

    create_backup_plan_association_sample(
        $formattedParent,
        $backupPlanAssociationId,
        $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\Cloud\BackupDR\V1\NetworkConfig;
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.
    $managementServerNetworks = [new NetworkConfig()];
    $managementServer = (new ManagementServer())
        ->setNetworks($managementServerNetworks);
    $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);
}

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

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

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

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

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/&#42;/locations/&#42;/backupVaults/&#42;/dataSources/&#42;/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());
    }
}

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>

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>

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>

getManagementServerAsync

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

listBackupPlanAssociationsAsync

Parameters
Name Description
request Google\Cloud\BackupDR\V1\ListBackupPlanAssociationsRequest
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>

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::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::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::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}
  • backupVault: projects/{project}/locations/{location}/backupVaults/{backupvault}
  • dataSource: projects/{project}/locations/{location}/backupVaults/{backupvault}/dataSources/{datasource}
  • location: projects/{project}/locations/{location}
  • managementServer: projects/{project}/locations/{location}/managementServers/{managementserver}

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.