Skip to content
Open
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 modified StorageControl/metadata/V2/StorageControl.php
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?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 storage_v2_generated_StorageControl_DeleteFolderRecursive_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
use Google\Cloud\Storage\Control\V2\DeleteFolderRecursiveRequest;
use Google\Rpc\Status;

/**
* Deletes a folder recursively. This operation is only applicable to a
* hierarchical namespace enabled bucket.
*
* @param string $formattedName Name of the folder being deleted, however all of its contents
* will be deleted too. Format:
* `projects/{project}/buckets/{bucket}/folders/{folder}`
* Please see {@see StorageControlClient::folderName()} for help formatting this field.
*/
function delete_folder_recursive_sample(string $formattedName): void
{
// Create a client.
$storageControlClient = new StorageControlClient();

// Prepare the request message.
$request = (new DeleteFolderRecursiveRequest())
->setName($formattedName);

// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $storageControlClient->deleteFolderRecursive($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 = StorageControlClient::folderName('[PROJECT]', '[BUCKET]', '[FOLDER]');

delete_folder_recursive_sample($formattedName);
}
// [END storage_v2_generated_StorageControl_DeleteFolderRecursive_sync]
31 changes: 31 additions & 0 deletions StorageControl/src/V2/Client/StorageControlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use Google\Cloud\Storage\Control\V2\CreateAnywhereCacheRequest;
use Google\Cloud\Storage\Control\V2\CreateFolderRequest;
use Google\Cloud\Storage\Control\V2\CreateManagedFolderRequest;
use Google\Cloud\Storage\Control\V2\DeleteFolderRecursiveRequest;
use Google\Cloud\Storage\Control\V2\DeleteFolderRequest;
use Google\Cloud\Storage\Control\V2\DeleteManagedFolderRequest;
use Google\Cloud\Storage\Control\V2\DisableAnywhereCacheRequest;
Expand Down Expand Up @@ -88,6 +89,7 @@
* @method PromiseInterface<Folder> createFolderAsync(CreateFolderRequest $request, array $optionalArgs = [])
* @method PromiseInterface<ManagedFolder> createManagedFolderAsync(CreateManagedFolderRequest $request, array $optionalArgs = [])
* @method PromiseInterface<void> deleteFolderAsync(DeleteFolderRequest $request, array $optionalArgs = [])
* @method PromiseInterface<OperationResponse> deleteFolderRecursiveAsync(DeleteFolderRecursiveRequest $request, array $optionalArgs = [])
* @method PromiseInterface<void> deleteManagedFolderAsync(DeleteManagedFolderRequest $request, array $optionalArgs = [])
* @method PromiseInterface<AnywhereCache> disableAnywhereCacheAsync(DisableAnywhereCacheRequest $request, array $optionalArgs = [])
* @method PromiseInterface<AnywhereCache> getAnywhereCacheAsync(GetAnywhereCacheRequest $request, array $optionalArgs = [])
Expand Down Expand Up @@ -594,6 +596,35 @@ public function deleteFolder(DeleteFolderRequest $request, array $callOptions =
$this->startApiCall('DeleteFolder', $request, $callOptions)->wait();
}

/**
* Deletes a folder recursively. This operation is only applicable to a
* hierarchical namespace enabled bucket.
*
* The async variant is {@see StorageControlClient::deleteFolderRecursiveAsync()} .
*
* @example samples/V2/StorageControlClient/delete_folder_recursive.php
*
* @param DeleteFolderRecursiveRequest $request A request to house fields associated with the call.
* @param array $callOptions {
* Optional.
*
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return OperationResponse<null>
*
* @throws ApiException Thrown if the API call fails.
*/
public function deleteFolderRecursive(
DeleteFolderRecursiveRequest $request,
array $callOptions = []
): OperationResponse {
return $this->startApiCall('DeleteFolderRecursive', $request, $callOptions)->wait();
}

/**
* Permanently deletes an empty managed folder.
*
Expand Down
112 changes: 112 additions & 0 deletions StorageControl/src/V2/DeleteFolderRecursiveMetadata.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading