Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added BackupDr/metadata/V1/ProtectionSummary.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/*
* Copyright 2026 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_BackupDrProtectionSummary_GetIamPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\Client\BackupDrProtectionSummaryClient;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;

/**
* Gets the access control policy for a resource. Returns an empty policy
if the resource exists and does not have a policy set.
*
* @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.
$backupDrProtectionSummaryClient = new BackupDrProtectionSummaryClient();

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

// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $backupDrProtectionSummaryClient->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);
}
// [END backupdr_v1_generated_BackupDrProtectionSummary_GetIamPolicy_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/*
* Copyright 2026 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_BackupDrProtectionSummary_GetLocation_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\Client\BackupDrProtectionSummaryClient;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;

/**
* Gets information about a 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.
$backupDrProtectionSummaryClient = new BackupDrProtectionSummaryClient();

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

// Call the API and handle any network failures.
try {
/** @var Location $response */
$response = $backupDrProtectionSummaryClient->getLocation($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
// [END backupdr_v1_generated_BackupDrProtectionSummary_GetLocation_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/*
* Copyright 2026 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_BackupDrProtectionSummary_ListLocations_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDrProtectionSummaryClient;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;

/**
* Lists information about the supported locations for this service.
*
* 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.
$backupDrProtectionSummaryClient = new BackupDrProtectionSummaryClient();

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

// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $backupDrProtectionSummaryClient->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());
}
}
// [END backupdr_v1_generated_BackupDrProtectionSummary_ListLocations_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/*
* Copyright 2026 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_BackupDrProtectionSummary_ListResourceBackupConfigs_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\BackupDR\V1\Client\BackupDrProtectionSummaryClient;
use Google\Cloud\BackupDR\V1\ListResourceBackupConfigsRequest;
use Google\Cloud\BackupDR\V1\ResourceBackupConfig;

/**
* Lists ResourceBackupConfigs.
*
* @param string $formattedParent The project and location for which to retrieve resource backup
* configs. Format: 'projects/{project_id}/locations/{location}'. In Google
* Cloud Backup and DR, locations map to Google Cloud regions, for example
* **us-central1**. Please see
* {@see BackupDrProtectionSummaryClient::locationName()} for help formatting this field.
*/
function list_resource_backup_configs_sample(string $formattedParent): void
{
// Create a client.
$backupDrProtectionSummaryClient = new BackupDrProtectionSummaryClient();

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

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

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

list_resource_backup_configs_sample($formattedParent);
}
// [END backupdr_v1_generated_BackupDrProtectionSummary_ListResourceBackupConfigs_sync]
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2026 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_BackupDrProtectionSummary_SetIamPolicy_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\BackupDR\V1\Client\BackupDrProtectionSummaryClient;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\Iam\V1\SetIamPolicyRequest;

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

Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
errors.
*
* @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.
$backupDrProtectionSummaryClient = new BackupDrProtectionSummaryClient();

// 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 = $backupDrProtectionSummaryClient->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);
}
// [END backupdr_v1_generated_BackupDrProtectionSummary_SetIamPolicy_sync]
Loading
Loading