Skip to content

Commit

Permalink
feat: Client library for the backupvault api is added (#7704)
Browse files Browse the repository at this point in the history
feat: Add backupplan proto
feat: Add backupplanassociation proto
feat: Add backupvault_ba proto
feat: Add backupvault_gce proto

docs: A comment for field `oauth2_client_id` in message `.google.cloud.backupdr.v1.ManagementServer` is changed
docs: A comment for field `parent` in message `.google.cloud.backupdr.v1.ListManagementServersRequest` is changed
docs: A comment for field `management_servers` in message `.google.cloud.backupdr.v1.ListManagementServersResponse` is changed
docs: A comment for field `name` in message `.google.cloud.backupdr.v1.GetManagementServerRequest` is changed
docs: A comment for field `parent` in message `.google.cloud.backupdr.v1.CreateManagementServerRequest` is changed
docs: A comment for field `requested_cancellation` in message `.google.cloud.backupdr.v1.OperationMetadata` is changed
PiperOrigin-RevId: 678800741
Source-Link: googleapis/googleapis@d36e288
Source-Link: googleapis/googleapis-gen@fba9d22
Copy-Tag: eyJwIjoiQmFja3VwRHIvLk93bEJvdC55YW1sIiwiaCI6ImZiYTlkMjI1YjQzZGNmNzM2MTAwNjQ5MTgxMDQ4NWNkZjFiNTdjZGIifQ==
  • Loading branch information
gcf-owl-bot[bot] authored Sep 27, 2024
1 parent 9ed8a41 commit 1ed4b42
Show file tree
Hide file tree
Showing 169 changed files with 30,693 additions and 387 deletions.
Binary file modified BackupDr/metadata/V1/Backupdr.php
Binary file not shown.
Binary file added BackupDr/metadata/V1/Backupplan.php
Binary file not shown.
Binary file added BackupDr/metadata/V1/Backupplanassociation.php
Binary file not shown.
Binary file added BackupDr/metadata/V1/Backupvault.php
Binary file not shown.
Binary file added BackupDr/metadata/V1/BackupvaultBa.php
Binary file not shown.
Binary file added BackupDr/metadata/V1/BackupvaultGce.php
Binary file not shown.
87 changes: 87 additions & 0 deletions BackupDr/samples/V1/BackupDRClient/abandon_backup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START backupdr_v1_generated_BackupDR_AbandonBackup_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\BackupDR\V1\AbandonBackupRequest;
use Google\Cloud\BackupDR\V1\Client\BackupDRClient;
use Google\Rpc\Status;

/**
* Internal only.
* Abandons a backup.
*
* @param string $formattedDataSource The resource name of the instance, in the format
* 'projects/&#42;/locations/&#42;/backupVaults/&#42;/dataSources/'. Please see
* {@see BackupDRClient::dataSourceName()} for help formatting this field.
*/
function abandon_backup_sample(string $formattedDataSource): void
{
// Create a client.
$backupDRClient = new BackupDRClient();

// Prepare the request message.
$request = (new AbandonBackupRequest())
->setDataSource($formattedDataSource);

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

abandon_backup_sample($formattedDataSource);
}
// [END backupdr_v1_generated_BackupDR_AbandonBackup_sync]
174 changes: 174 additions & 0 deletions BackupDr/samples/V1/BackupDRClient/create_backup_plan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START backupdr_v1_generated_BackupDR_CreateBackupPlan_sync]
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;

/**
* Create a BackupPlan
*
* @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
);
}
// [END backupdr_v1_generated_BackupDR_CreateBackupPlan_sync]
114 changes: 114 additions & 0 deletions BackupDr/samples/V1/BackupDRClient/create_backup_plan_association.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START backupdr_v1_generated_BackupDR_CreateBackupPlanAssociation_sync]
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;

/**
* Create a BackupPlanAssociation
*
* @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
);
}
// [END backupdr_v1_generated_BackupDR_CreateBackupPlanAssociation_sync]
Loading

0 comments on commit 1ed4b42

Please sign in to comment.