Skip to content

Commit

Permalink
feat: Add backupplan proto (#7732)
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

PiperOrigin-RevId: 683196317
Source-Link: googleapis/googleapis@c532f35
Source-Link: googleapis/googleapis-gen@fd43f57
Copy-Tag: eyJwIjoiQmFja3VwRHIvLk93bEJvdC55YW1sIiwiaCI6ImZkNDNmNTczM2IwMDIzNThmYTY3OTYyM2Y2MDk5YWFmYjY2NjBjOGUifQ==
  • Loading branch information
gcf-owl-bot[bot] authored Oct 11, 2024
1 parent a93ec74 commit 764bb32
Show file tree
Hide file tree
Showing 153 changed files with 27,238 additions and 186 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.
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]
93 changes: 93 additions & 0 deletions BackupDr/samples/V1/BackupDRClient/create_backup_vault.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?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_CreateBackupVault_sync]
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;

/**
* Creates a new BackupVault in a given project and location.
*
* @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);
}
// [END backupdr_v1_generated_BackupDR_CreateBackupVault_sync]
Loading

0 comments on commit 764bb32

Please sign in to comment.