Google Cloud Filestore V1 Client - Class CloudFilestoreManagerClient (1.0.3)

Reference documentation and code samples for the Google Cloud Filestore V1 Client class CloudFilestoreManagerClient.

Service Description: Configures and manages Cloud Filestore resources.

Cloud Filestore Manager v1.

The file.googleapis.com service implements the Cloud Filestore API and defines the following resource model for managing instances:

  • The service works with a collection of cloud projects, named: /projects/*
  • Each project has a collection of available locations, named: /locations/*
  • Each location has a collection of instances and backups, named: /instances/* and /backups/* respectively.
  • As such, Cloud Filestore instances are resources of the form: /projects/{project_number}/locations/{location_id}/instances/{instance_id} and backups are resources of the form: /projects/{project_number}/locations/{location_id}/backup/{backup_id}

Note that location_id must be a GCP zone for instances and but to a GCP region for backups; for example:

  • projects/12345/locations/us-central1-c/instances/my-filestore
  • projects/12345/locations/us-central1/backups/my-backup

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:

$cloudFilestoreManagerClient = new CloudFilestoreManagerClient();
try {
    $formattedParent = $cloudFilestoreManagerClient->locationName('[PROJECT]', '[LOCATION]');
    $backup = new Backup();
    $backupId = 'backup_id';
    $operationResponse = $cloudFilestoreManagerClient->createBackup($formattedParent, $backup, $backupId);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
    // doSomethingWith($result)
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
    // Alternatively:
    // start the operation, keep the operation name, and resume later
    $operationResponse = $cloudFilestoreManagerClient->createBackup($formattedParent, $backup, $backupId);
    $operationName = $operationResponse->getName();
    // ... do other work
    $newOperationResponse = $cloudFilestoreManagerClient->resumeOperation($operationName, 'createBackup');
    while (!$newOperationResponse->isDone()) {
        // ... do other work
        $newOperationResponse->reload();
    }
    if ($newOperationResponse->operationSucceeded()) {
        $result = $newOperationResponse->getResult();
    // doSomethingWith($result)
    } else {
        $error = $newOperationResponse->getError();
        // handleError($error)
    }
} finally {
    $cloudFilestoreManagerClient->close();
}

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.

Methods

backupName

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

Parameters
NameDescription
project string
location string
backup string
Returns
TypeDescription
stringThe formatted backup resource.

instanceName

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

Parameters
NameDescription
project string
location string
instance string
Returns
TypeDescription
stringThe formatted instance resource.

locationName

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

Parameters
NameDescription
project string
location string
Returns
TypeDescription
stringThe formatted location resource.

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

  • backup: projects/{project}/locations/{location}/backups/{backup}
  • instance: projects/{project}/locations/{location}/instances/{instance}
  • location: projects/{project}/locations/{location}

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
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.

getOperationsClient

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

Returns
TypeDescription
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
NameDescription
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
TypeDescription
Google\ApiCore\OperationResponse

__construct

Constructor.

Parameters
NameDescription
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. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. 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' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods 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.

createBackup

Creates a backup.

Parameters
NameDescription
parent string

Required. The backup's project and location, in the format projects/{project_number}/locations/{location}. In Cloud Filestore, backup locations map to GCP regions, for example us-west1.

backup Google\Cloud\Filestore\V1\Backup

Required. A backup resource

backupId string

Required. The ID to use for the backup. The ID must be unique within the specified project and location.

This value must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens, and cannot end with a hyphen. Values that do not match this pattern will trigger an INVALID_ARGUMENT error.

optionalArgs 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
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Filestore\V1\Backup;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The backup's project and location, in the format
 *                                `projects/{project_number}/locations/{location}`. In Cloud Filestore,
 *                                backup locations map to GCP regions, for example **us-west1**. Please see
 *                                {@see CloudFilestoreManagerClient::locationName()} for help formatting this field.
 * @param string $backupId        The ID to use for the backup.
 *                                The ID must be unique within the specified project and location.
 *
 *                                This value must start with a lowercase letter followed by up to 62
 *                                lowercase letters, numbers, or hyphens, and cannot end with a hyphen.
 *                                Values that do not match this pattern will trigger an INVALID_ARGUMENT
 *                                error.
 */
function create_backup_sample(string $formattedParent, string $backupId): void
{
    // Create a client.
    $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $backup = new Backup();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $cloudFilestoreManagerClient->createBackup($formattedParent, $backup, $backupId);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Backup $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());
    }
}

/**
 * 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 = CloudFilestoreManagerClient::locationName('[PROJECT]', '[LOCATION]');
    $backupId = '[BACKUP_ID]';

    create_backup_sample($formattedParent, $backupId);
}

createInstance

Creates an instance.

When creating from a backup, the capacity of the new instance needs to be equal to or larger than the capacity of the backup (and also equal to or larger than the minimum capacity of the tier).

Parameters
NameDescription
parent string

Required. The instance's project and location, in the format projects/{project_id}/locations/{location}. In Cloud Filestore, locations map to GCP zones, for example us-west1-b.

instanceId string

Required. The name of the instance to create. The name must be unique for the specified project and location.

instance Google\Cloud\Filestore\V1\Instance

Required. An instance resource

optionalArgs 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
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;
use Google\Cloud\Filestore\V1\Instance;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The instance's project and location, in the format
 *                                `projects/{project_id}/locations/{location}`. In Cloud Filestore,
 *                                locations map to GCP zones, for example **us-west1-b**. Please see
 *                                {@see CloudFilestoreManagerClient::locationName()} for help formatting this field.
 * @param string $instanceId      The name of the instance to create.
 *                                The name must be unique for the specified project and location.
 */
function create_instance_sample(string $formattedParent, string $instanceId): void
{
    // Create a client.
    $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $instance = new Instance();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $cloudFilestoreManagerClient->createInstance($formattedParent, $instanceId, $instance);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Instance $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());
    }
}

/**
 * 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 = CloudFilestoreManagerClient::locationName('[PROJECT]', '[LOCATION]');
    $instanceId = '[INSTANCE_ID]';

    create_instance_sample($formattedParent, $instanceId);
}

deleteBackup

Deletes a backup.

Parameters
NameDescription
name string

Required. The backup resource name, in the format projects/{project_number}/locations/{location}/backups/{backup_id}

optionalArgs 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
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;
use Google\Rpc\Status;

/**
 * @param string $formattedName The backup resource name, in the format
 *                              `projects/{project_number}/locations/{location}/backups/{backup_id}`
 *                              Please see {@see CloudFilestoreManagerClient::backupName()} for help formatting this field.
 */
function delete_backup_sample(string $formattedName): void
{
    // Create a client.
    $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $cloudFilestoreManagerClient->deleteBackup($formattedName);
        $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());
    }
}

/**
 * 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 = CloudFilestoreManagerClient::backupName('[PROJECT]', '[LOCATION]', '[BACKUP]');

    delete_backup_sample($formattedName);
}

deleteInstance

Deletes an instance.

Parameters
NameDescription
name string

Required. The instance resource name, in the format projects/{project_id}/locations/{location}/instances/{instance_id}

optionalArgs 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
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;
use Google\Rpc\Status;

/**
 * @param string $formattedName The instance resource name, in the format
 *                              `projects/{project_id}/locations/{location}/instances/{instance_id}`
 *                              Please see {@see CloudFilestoreManagerClient::instanceName()} for help formatting this field.
 */
function delete_instance_sample(string $formattedName): void
{
    // Create a client.
    $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $cloudFilestoreManagerClient->deleteInstance($formattedName);
        $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());
    }
}

/**
 * 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 = CloudFilestoreManagerClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');

    delete_instance_sample($formattedName);
}

getBackup

Gets the details of a specific backup.

Parameters
NameDescription
name string

Required. The backup resource name, in the format projects/{project_number}/locations/{location}/backups/{backup_id}.

optionalArgs 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
TypeDescription
Google\Cloud\Filestore\V1\Backup
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Filestore\V1\Backup;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;

/**
 * @param string $formattedName The backup resource name, in the format
 *                              `projects/{project_number}/locations/{location}/backups/{backup_id}`. Please see
 *                              {@see CloudFilestoreManagerClient::backupName()} for help formatting this field.
 */
function get_backup_sample(string $formattedName): void
{
    // Create a client.
    $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var Backup $response */
        $response = $cloudFilestoreManagerClient->getBackup($formattedName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * 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 = CloudFilestoreManagerClient::backupName('[PROJECT]', '[LOCATION]', '[BACKUP]');

    get_backup_sample($formattedName);
}

getInstance

Gets the details of a specific instance.

Parameters
NameDescription
name string

Required. The instance resource name, in the format projects/{project_id}/locations/{location}/instances/{instance_id}.

optionalArgs 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
TypeDescription
Google\Cloud\Filestore\V1\Instance
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;
use Google\Cloud\Filestore\V1\Instance;

/**
 * @param string $formattedName The instance resource name, in the format
 *                              `projects/{project_id}/locations/{location}/instances/{instance_id}`. Please see
 *                              {@see CloudFilestoreManagerClient::instanceName()} for help formatting this field.
 */
function get_instance_sample(string $formattedName): void
{
    // Create a client.
    $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var Instance $response */
        $response = $cloudFilestoreManagerClient->getInstance($formattedName);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * 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 = CloudFilestoreManagerClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');

    get_instance_sample($formattedName);
}

listBackups

Lists all backups in a project for either a specified location or for all locations.

Parameters
NameDescription
parent string

Required. The project and location for which to retrieve backup information, in the format projects/{project_number}/locations/{location}. In Cloud Filestore, backup locations map to GCP regions, for example us-west1. To retrieve backup information for all locations, use "-" for the {location} value.

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ orderBy string

Sort results. Supported values are "name", "name desc" or "" (unsorted).

↳ filter string

List filter.

↳ 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
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Filestore\V1\Backup;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;

/**
 * @param string $formattedParent The project and location for which to retrieve backup
 *                                information, in the format
 *                                `projects/{project_number}/locations/{location}`. In Cloud Filestore,
 *                                backup locations map to GCP regions, for example **us-west1**. To retrieve
 *                                backup information for all locations, use "-" for the
 *                                `{location}` value. Please see
 *                                {@see CloudFilestoreManagerClient::locationName()} for help formatting this field.
 */
function list_backups_sample(string $formattedParent): void
{
    // Create a client.
    $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

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

        /** @var Backup $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());
    }
}

/**
 * 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 = CloudFilestoreManagerClient::locationName('[PROJECT]', '[LOCATION]');

    list_backups_sample($formattedParent);
}

listInstances

Lists all instances in a project for either a specified location or for all locations.

Parameters
NameDescription
parent string

Required. The project and location for which to retrieve instance information, in the format projects/{project_id}/locations/{location}. In Cloud Filestore, locations map to GCP zones, for example us-west1-b. To retrieve instance information for all locations, use "-" for the {location} value.

optionalArgs array

Optional.

↳ pageSize int

The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.

↳ pageToken string

A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.

↳ orderBy string

Sort results. Supported values are "name", "name desc" or "" (unsorted).

↳ filter string

List filter.

↳ 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
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;
use Google\Cloud\Filestore\V1\Instance;

/**
 * @param string $formattedParent The project and location for which to retrieve instance
 *                                information, in the format `projects/{project_id}/locations/{location}`. In
 *                                Cloud Filestore, locations map to GCP zones, for example **us-west1-b**. To
 *                                retrieve instance information for all locations, use "-" for the
 *                                `{location}` value. Please see
 *                                {@see CloudFilestoreManagerClient::locationName()} for help formatting this field.
 */
function list_instances_sample(string $formattedParent): void
{
    // Create a client.
    $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

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

        /** @var Instance $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());
    }
}

/**
 * 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 = CloudFilestoreManagerClient::locationName('[PROJECT]', '[LOCATION]');

    list_instances_sample($formattedParent);
}

restoreInstance

Restores an existing instance's file share from a backup.

The capacity of the instance needs to be equal to or larger than the capacity of the backup (and also equal to or larger than the minimum capacity of the tier).

Parameters
NameDescription
name string

Required. The resource name of the instance, in the format projects/{project_number}/locations/{location_id}/instances/{instance_id}.

fileShare string

Required. Name of the file share in the Cloud Filestore instance that the backup is being restored to.

optionalArgs array

Optional.

↳ sourceBackup string

The resource name of the backup, in the format projects/{project_number}/locations/{location_id}/backups/{backup_id}.

↳ 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
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;
use Google\Cloud\Filestore\V1\Instance;
use Google\Rpc\Status;

/**
 * @param string $formattedName The resource name of the instance, in the format
 *                              `projects/{project_number}/locations/{location_id}/instances/{instance_id}`. Please see
 *                              {@see CloudFilestoreManagerClient::instanceName()} for help formatting this field.
 * @param string $fileShare     Name of the file share in the Cloud Filestore instance that the
 *                              backup is being restored to.
 */
function restore_instance_sample(string $formattedName, string $fileShare): void
{
    // Create a client.
    $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $cloudFilestoreManagerClient->restoreInstance($formattedName, $fileShare);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Instance $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());
    }
}

/**
 * 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 = CloudFilestoreManagerClient::instanceName('[PROJECT]', '[LOCATION]', '[INSTANCE]');
    $fileShare = '[FILE_SHARE]';

    restore_instance_sample($formattedName, $fileShare);
}

updateBackup

Updates the settings of a specific backup.

Parameters
NameDescription
backup Google\Cloud\Filestore\V1\Backup

Required. A backup resource

updateMask Google\Protobuf\FieldMask

Required. Mask of fields to update. At least one path must be supplied in this field.

optionalArgs 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
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Filestore\V1\Backup;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * 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 update_backup_sample(): void
{
    // Create a client.
    $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

    // Prepare any non-scalar elements to be passed along with the request.
    $backup = new Backup();
    $updateMask = new FieldMask();

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $cloudFilestoreManagerClient->updateBackup($backup, $updateMask);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var Backup $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());
    }
}

updateInstance

Updates the settings of a specific instance.

Parameters
NameDescription
optionalArgs array

Optional.

↳ updateMask FieldMask

Mask of fields to update. At least one path must be supplied in this field. The elements of the repeated paths field may only include these fields: * "description" * "file_shares" * "labels"

↳ instance Instance

Only fields specified in update_mask are updated.

↳ 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
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Filestore\V1\CloudFilestoreManagerClient;
use Google\Cloud\Filestore\V1\Instance;
use Google\Rpc\Status;

/**
 * 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 update_instance_sample(): void
{
    // Create a client.
    $cloudFilestoreManagerClient = new CloudFilestoreManagerClient();

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

        if ($response->operationSucceeded()) {
            /** @var Instance $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());
    }
}

Constants

SERVICE_NAME

Value: 'google.cloud.filestore.v1.CloudFilestoreManager'

The name of the service.

SERVICE_ADDRESS

Value: 'file.googleapis.com'

The default address of the service.

DEFAULT_SERVICE_PORT

Value: 443

The default port of the service.

CODEGEN_NAME

Value: 'gapic'

The name of the code generator, to be included in the agent header.