Skip to content

Commit ec03ed4

Browse files
feat: [StorageControl] add a DeleteFolderRecursive API definition (#8909)
* feat: add a DeleteFolderRecursive API definition PiperOrigin-RevId: 866471251 Source-Link: googleapis/googleapis@af8a8d5 Source-Link: googleapis/googleapis-gen@aab4d11 Copy-Tag: eyJwIjoiU3RvcmFnZUNvbnRyb2wvLk93bEJvdC55YW1sIiwiaCI6ImFhYjRkMTFmNDAzZTk5ZDgzNjRjMzRiY2Q1ZWRhMWY4ZWEwMGM1MDYifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent a37733e commit ec03ed4

9 files changed

Lines changed: 609 additions & 0 deletions

File tree

638 Bytes
Binary file not shown.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/*
3+
* Copyright 2026 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
/*
19+
* GENERATED CODE WARNING
20+
* This file was automatically generated - do not edit!
21+
*/
22+
23+
require_once __DIR__ . '/../../../vendor/autoload.php';
24+
25+
// [START storage_v2_generated_StorageControl_DeleteFolderRecursive_sync]
26+
use Google\ApiCore\ApiException;
27+
use Google\ApiCore\OperationResponse;
28+
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
29+
use Google\Cloud\Storage\Control\V2\DeleteFolderRecursiveRequest;
30+
use Google\Rpc\Status;
31+
32+
/**
33+
* Deletes a folder recursively. This operation is only applicable to a
34+
* hierarchical namespace enabled bucket.
35+
*
36+
* @param string $formattedName Name of the folder being deleted, however all of its contents
37+
* will be deleted too. Format:
38+
* `projects/{project}/buckets/{bucket}/folders/{folder}`
39+
* Please see {@see StorageControlClient::folderName()} for help formatting this field.
40+
*/
41+
function delete_folder_recursive_sample(string $formattedName): void
42+
{
43+
// Create a client.
44+
$storageControlClient = new StorageControlClient();
45+
46+
// Prepare the request message.
47+
$request = (new DeleteFolderRecursiveRequest())
48+
->setName($formattedName);
49+
50+
// Call the API and handle any network failures.
51+
try {
52+
/** @var OperationResponse $response */
53+
$response = $storageControlClient->deleteFolderRecursive($request);
54+
$response->pollUntilComplete();
55+
56+
if ($response->operationSucceeded()) {
57+
printf('Operation completed successfully.' . PHP_EOL);
58+
} else {
59+
/** @var Status $error */
60+
$error = $response->getError();
61+
printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
62+
}
63+
} catch (ApiException $ex) {
64+
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
65+
}
66+
}
67+
68+
/**
69+
* Helper to execute the sample.
70+
*
71+
* This sample has been automatically generated and should be regarded as a code
72+
* template only. It will require modifications to work:
73+
* - It may require correct/in-range values for request initialization.
74+
* - It may require specifying regional endpoints when creating the service client,
75+
* please see the apiEndpoint client configuration option for more details.
76+
*/
77+
function callSample(): void
78+
{
79+
$formattedName = StorageControlClient::folderName('[PROJECT]', '[BUCKET]', '[FOLDER]');
80+
81+
delete_folder_recursive_sample($formattedName);
82+
}
83+
// [END storage_v2_generated_StorageControl_DeleteFolderRecursive_sync]

StorageControl/src/V2/Client/StorageControlClient.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use Google\Cloud\Storage\Control\V2\CreateAnywhereCacheRequest;
4545
use Google\Cloud\Storage\Control\V2\CreateFolderRequest;
4646
use Google\Cloud\Storage\Control\V2\CreateManagedFolderRequest;
47+
use Google\Cloud\Storage\Control\V2\DeleteFolderRecursiveRequest;
4748
use Google\Cloud\Storage\Control\V2\DeleteFolderRequest;
4849
use Google\Cloud\Storage\Control\V2\DeleteManagedFolderRequest;
4950
use Google\Cloud\Storage\Control\V2\DisableAnywhereCacheRequest;
@@ -88,6 +89,7 @@
8889
* @method PromiseInterface<Folder> createFolderAsync(CreateFolderRequest $request, array $optionalArgs = [])
8990
* @method PromiseInterface<ManagedFolder> createManagedFolderAsync(CreateManagedFolderRequest $request, array $optionalArgs = [])
9091
* @method PromiseInterface<void> deleteFolderAsync(DeleteFolderRequest $request, array $optionalArgs = [])
92+
* @method PromiseInterface<OperationResponse> deleteFolderRecursiveAsync(DeleteFolderRecursiveRequest $request, array $optionalArgs = [])
9193
* @method PromiseInterface<void> deleteManagedFolderAsync(DeleteManagedFolderRequest $request, array $optionalArgs = [])
9294
* @method PromiseInterface<AnywhereCache> disableAnywhereCacheAsync(DisableAnywhereCacheRequest $request, array $optionalArgs = [])
9395
* @method PromiseInterface<AnywhereCache> getAnywhereCacheAsync(GetAnywhereCacheRequest $request, array $optionalArgs = [])
@@ -594,6 +596,35 @@ public function deleteFolder(DeleteFolderRequest $request, array $callOptions =
594596
$this->startApiCall('DeleteFolder', $request, $callOptions)->wait();
595597
}
596598

599+
/**
600+
* Deletes a folder recursively. This operation is only applicable to a
601+
* hierarchical namespace enabled bucket.
602+
*
603+
* The async variant is {@see StorageControlClient::deleteFolderRecursiveAsync()} .
604+
*
605+
* @example samples/V2/StorageControlClient/delete_folder_recursive.php
606+
*
607+
* @param DeleteFolderRecursiveRequest $request A request to house fields associated with the call.
608+
* @param array $callOptions {
609+
* Optional.
610+
*
611+
* @type RetrySettings|array $retrySettings
612+
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
613+
* associative array of retry settings parameters. See the documentation on
614+
* {@see RetrySettings} for example usage.
615+
* }
616+
*
617+
* @return OperationResponse<null>
618+
*
619+
* @throws ApiException Thrown if the API call fails.
620+
*/
621+
public function deleteFolderRecursive(
622+
DeleteFolderRecursiveRequest $request,
623+
array $callOptions = []
624+
): OperationResponse {
625+
return $this->startApiCall('DeleteFolderRecursive', $request, $callOptions)->wait();
626+
}
627+
597628
/**
598629
* Permanently deletes an empty managed folder.
599630
*

StorageControl/src/V2/DeleteFolderRecursiveMetadata.php

Lines changed: 112 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)