Google Cloud Storage Control V2 Client - Class StorageControlClient (0.1.1)

Reference documentation and code samples for the Google Cloud Storage Control V2 Client class StorageControlClient.

Service Description: StorageControl service includes selected control plane operations.

This class provides the ability to make remote calls to the backing service through method calls that map to API methods.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.

Namespace

Google \ Cloud \ Storage \ Control \ V2 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. At the moment, supports only grpc. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() method for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

createFolder

Creates a new folder. This operation is only applicable to a hierarchical namespace enabled bucket.

Hierarchical namespace buckets are in allowlist preview.

The async variant is Google\Cloud\Storage\Control\V2\Client\StorageControlClient::createFolderAsync() .

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\CreateFolderRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Storage\Control\V2\Folder
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
use Google\Cloud\Storage\Control\V2\CreateFolderRequest;
use Google\Cloud\Storage\Control\V2\Folder;

/**
 * @param string $formattedParent Name of the bucket in which the folder will reside. The bucket
 *                                must be a hierarchical namespace enabled bucket. Please see
 *                                {@see StorageControlClient::bucketName()} for help formatting this field.
 * @param string $folderId        The full name of a folder, including all its parent folders.
 *                                Folders use single '/' characters as a delimiter.
 *                                The folder_id must end with a slash.
 *                                For example, the folder_id of "books/biographies/" would create a new
 *                                "biographies/" folder under the "books/" folder.
 */
function create_folder_sample(string $formattedParent, string $folderId): void
{
    // Create a client.
    $storageControlClient = new StorageControlClient();

    // Prepare the request message.
    $folder = new Folder();
    $request = (new CreateFolderRequest())
        ->setParent($formattedParent)
        ->setFolder($folder)
        ->setFolderId($folderId);

    // Call the API and handle any network failures.
    try {
        /** @var Folder $response */
        $response = $storageControlClient->createFolder($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
{
    $formattedParent = StorageControlClient::bucketName('[PROJECT]', '[BUCKET]');
    $folderId = '[FOLDER_ID]';

    create_folder_sample($formattedParent, $folderId);
}

createManagedFolder

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\CreateManagedFolderRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Storage\Control\V2\ManagedFolder
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
use Google\Cloud\Storage\Control\V2\CreateManagedFolderRequest;
use Google\Cloud\Storage\Control\V2\ManagedFolder;

/**
 * @param string $formattedParent Name of the bucket this managed folder belongs to. Please see
 *                                {@see StorageControlClient::bucketName()} for help formatting this field.
 * @param string $managedFolderId The name of the managed folder. It uses a single `/` as delimiter
 *                                and leading and trailing `/` are allowed.
 */
function create_managed_folder_sample(string $formattedParent, string $managedFolderId): void
{
    // Create a client.
    $storageControlClient = new StorageControlClient();

    // Prepare the request message.
    $managedFolder = new ManagedFolder();
    $request = (new CreateManagedFolderRequest())
        ->setParent($formattedParent)
        ->setManagedFolder($managedFolder)
        ->setManagedFolderId($managedFolderId);

    // Call the API and handle any network failures.
    try {
        /** @var ManagedFolder $response */
        $response = $storageControlClient->createManagedFolder($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
{
    $formattedParent = StorageControlClient::bucketName('[PROJECT]', '[BUCKET]');
    $managedFolderId = '[MANAGED_FOLDER_ID]';

    create_managed_folder_sample($formattedParent, $managedFolderId);
}

deleteFolder

Permanently deletes an empty folder. This operation is only applicable to a hierarchical namespace enabled bucket.

Hierarchical namespace buckets are in allowlist preview.

The async variant is Google\Cloud\Storage\Control\V2\Client\StorageControlClient::deleteFolderAsync() .

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\DeleteFolderRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
use Google\Cloud\Storage\Control\V2\DeleteFolderRequest;

/**
 * @param string $formattedName Name of the folder.
 *                              Format: `projects/{project}/buckets/{bucket}/folders/{folder}`
 *                              Please see {@see StorageControlClient::folderName()} for help formatting this field.
 */
function delete_folder_sample(string $formattedName): void
{
    // Create a client.
    $storageControlClient = new StorageControlClient();

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

    // Call the API and handle any network failures.
    try {
        $storageControlClient->deleteFolder($request);
        printf('Call completed successfully.' . PHP_EOL);
    } 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_sample($formattedName);
}

deleteManagedFolder

Permanently deletes an empty managed folder.

The async variant is Google\Cloud\Storage\Control\V2\Client\StorageControlClient::deleteManagedFolderAsync() .

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\DeleteManagedFolderRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
use Google\Cloud\Storage\Control\V2\DeleteManagedFolderRequest;

/**
 * @param string $formattedName Name of the managed folder.
 *                              Format:
 *                              `projects/{project}/buckets/{bucket}/managedFolders/{managedFolder}`
 *                              Please see {@see StorageControlClient::managedFolderName()} for help formatting this field.
 */
function delete_managed_folder_sample(string $formattedName): void
{
    // Create a client.
    $storageControlClient = new StorageControlClient();

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

    // Call the API and handle any network failures.
    try {
        $storageControlClient->deleteManagedFolder($request);
        printf('Call completed successfully.' . PHP_EOL);
    } 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::managedFolderName(
        '[PROJECT]',
        '[BUCKET]',
        '[MANAGEDFOLDER]'
    );

    delete_managed_folder_sample($formattedName);
}

getFolder

Returns metadata for the specified folder. This operation is only applicable to a hierarchical namespace enabled bucket.

Hierarchical namespace buckets are in allowlist preview.

The async variant is Google\Cloud\Storage\Control\V2\Client\StorageControlClient::getFolderAsync() .

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\GetFolderRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Storage\Control\V2\Folder
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
use Google\Cloud\Storage\Control\V2\Folder;
use Google\Cloud\Storage\Control\V2\GetFolderRequest;

/**
 * @param string $formattedName Name of the folder.
 *                              Format: `projects/{project}/buckets/{bucket}/folders/{folder}`
 *                              Please see {@see StorageControlClient::folderName()} for help formatting this field.
 */
function get_folder_sample(string $formattedName): void
{
    // Create a client.
    $storageControlClient = new StorageControlClient();

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

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

    get_folder_sample($formattedName);
}

getManagedFolder

Returns metadata for the specified managed folder.

The async variant is Google\Cloud\Storage\Control\V2\Client\StorageControlClient::getManagedFolderAsync() .

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\GetManagedFolderRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Storage\Control\V2\ManagedFolder
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
use Google\Cloud\Storage\Control\V2\GetManagedFolderRequest;
use Google\Cloud\Storage\Control\V2\ManagedFolder;

/**
 * @param string $formattedName Name of the managed folder.
 *                              Format:
 *                              `projects/{project}/buckets/{bucket}/managedFolders/{managedFolder}`
 *                              Please see {@see StorageControlClient::managedFolderName()} for help formatting this field.
 */
function get_managed_folder_sample(string $formattedName): void
{
    // Create a client.
    $storageControlClient = new StorageControlClient();

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

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

    get_managed_folder_sample($formattedName);
}

getStorageLayout

Returns the storage layout configuration for a given bucket.

The async variant is Google\Cloud\Storage\Control\V2\Client\StorageControlClient::getStorageLayoutAsync() .

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\GetStorageLayoutRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Storage\Control\V2\StorageLayout
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
use Google\Cloud\Storage\Control\V2\GetStorageLayoutRequest;
use Google\Cloud\Storage\Control\V2\StorageLayout;

/**
 * @param string $formattedName The name of the StorageLayout resource.
 *                              Format: `projects/{project}/buckets/{bucket}/storageLayout`
 *                              Please see {@see StorageControlClient::storageLayoutName()} for help formatting this field.
 */
function get_storage_layout_sample(string $formattedName): void
{
    // Create a client.
    $storageControlClient = new StorageControlClient();

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

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

    get_storage_layout_sample($formattedName);
}

listFolders

Retrieves a list of folders. This operation is only applicable to a hierarchical namespace enabled bucket.

Hierarchical namespace buckets are in allowlist preview.

The async variant is Google\Cloud\Storage\Control\V2\Client\StorageControlClient::listFoldersAsync() .

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\ListFoldersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
use Google\Cloud\Storage\Control\V2\Folder;
use Google\Cloud\Storage\Control\V2\ListFoldersRequest;

/**
 * @param string $formattedParent Name of the bucket in which to look for folders. The bucket must
 *                                be a hierarchical namespace enabled bucket. Please see
 *                                {@see StorageControlClient::bucketName()} for help formatting this field.
 */
function list_folders_sample(string $formattedParent): void
{
    // Create a client.
    $storageControlClient = new StorageControlClient();

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

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

        /** @var Folder $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 = StorageControlClient::bucketName('[PROJECT]', '[BUCKET]');

    list_folders_sample($formattedParent);
}

listManagedFolders

Retrieves a list of managed folders for a given bucket.

The async variant is Google\Cloud\Storage\Control\V2\Client\StorageControlClient::listManagedFoldersAsync() .

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\ListManagedFoldersRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
use Google\Cloud\Storage\Control\V2\ListManagedFoldersRequest;
use Google\Cloud\Storage\Control\V2\ManagedFolder;

/**
 * @param string $formattedParent Name of the bucket this managed folder belongs to. Please see
 *                                {@see StorageControlClient::bucketName()} for help formatting this field.
 */
function list_managed_folders_sample(string $formattedParent): void
{
    // Create a client.
    $storageControlClient = new StorageControlClient();

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

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

        /** @var ManagedFolder $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 = StorageControlClient::bucketName('[PROJECT]', '[BUCKET]');

    list_managed_folders_sample($formattedParent);
}

renameFolder

Renames a source folder to a destination folder. This operation is only applicable to a hierarchical namespace enabled bucket. During a rename, the source and destination folders are locked until the long running operation completes.

Hierarchical namespace buckets are in allowlist preview.

The async variant is Google\Cloud\Storage\Control\V2\Client\StorageControlClient::renameFolderAsync() .

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\RenameFolderRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Storage\Control\V2\Client\StorageControlClient;
use Google\Cloud\Storage\Control\V2\Folder;
use Google\Cloud\Storage\Control\V2\RenameFolderRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName       Name of the source folder being renamed.
 *                                    Format: `projects/{project}/buckets/{bucket}/folders/{folder}`
 *                                    Please see {@see StorageControlClient::folderName()} for help formatting this field.
 * @param string $destinationFolderId The destination folder ID, e.g. `foo/bar/`.
 */
function rename_folder_sample(string $formattedName, string $destinationFolderId): void
{
    // Create a client.
    $storageControlClient = new StorageControlClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $storageControlClient->renameFolder($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Folder $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
{
    $formattedName = StorageControlClient::folderName('[PROJECT]', '[BUCKET]', '[FOLDER]');
    $destinationFolderId = '[DESTINATION_FOLDER_ID]';

    rename_folder_sample($formattedName, $destinationFolderId);
}

createFolderAsync

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\CreateFolderRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createManagedFolderAsync

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\CreateManagedFolderRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteFolderAsync

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\DeleteFolderRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteManagedFolderAsync

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\DeleteManagedFolderRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getFolderAsync

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\GetFolderRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getManagedFolderAsync

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\GetManagedFolderRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getStorageLayoutAsync

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\GetStorageLayoutRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listFoldersAsync

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\ListFoldersRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listManagedFoldersAsync

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\ListManagedFoldersRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

renameFolderAsync

Parameters
Name Description
request Google\Cloud\Storage\Control\V2\RenameFolderRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
Type Description
Google\ApiCore\LongRunning\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::bucketName

Formats a string containing the fully-qualified path to represent a bucket resource.

Parameters
Name Description
project string
bucket string
Returns
Type Description
string The formatted bucket resource.

static::folderName

Formats a string containing the fully-qualified path to represent a folder resource.

Parameters
Name Description
project string
bucket string
folder string
Returns
Type Description
string The formatted folder resource.

static::managedFolderName

Formats a string containing the fully-qualified path to represent a managed_folder resource.

Parameters
Name Description
project string
bucket string
managedFolder string
Returns
Type Description
string The formatted managed_folder resource.

static::storageLayoutName

Formats a string containing the fully-qualified path to represent a storage_layout resource.

Parameters
Name Description
project string
bucket string
Returns
Type Description
string The formatted storage_layout resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • bucket: projects/{project}/buckets/{bucket}
  • folder: projects/{project}/buckets/{bucket}/folders/{folder=**}
  • managedFolder: projects/{project}/buckets/{bucket}/managedFolders/{managedFolder=**}
  • storageLayout: projects/{project}/buckets/{bucket}/storageLayout

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
Name Description
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.