Google Cloud Redis Cluster V1 Client - Class CloudRedisClusterClient (0.2.5)

Reference documentation and code samples for the Google Cloud Redis Cluster V1 Client class CloudRedisClusterClient.

Service Description: Configures and manages Cloud Memorystore for Redis clusters

Google Cloud Memorystore for Redis Cluster

The redis.googleapis.com service implements the Google Cloud Memorystore for Redis API and defines the following resource model for managing Redis clusters:

  • 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 Redis clusters, named: /clusters/*
  • As such, Redis clusters are resources of the form: /projects/{project_id}/locations/{location_id}/clusters/{instance_id}

Note that location_id must be a GCP region; for example:

  • projects/redpepper-1290/locations/us-central1/clusters/my-redis

We use API version selector for Flex APIs

  • The versioning strategy is release-based versioning
  • Our backend CLH only deals with the superset version (called v1main)
  • Existing backend for Redis Gen1 and MRR is not touched.
  • More details in go/redis-flex-api-versioning

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 \ Redis \ Cluster \ V1 \ 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. 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.

createCluster

Creates a Redis cluster based on the specified properties.

The creation is executed asynchronously and callers may check the returned operation to track its progress. Once the operation is completed the Redis cluster will be fully functional. The completed longrunning.Operation will contain the new cluster object in the response field.

The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.

The async variant is Google\Cloud\Redis\Cluster\V1\Client\CloudRedisClusterClient::createClusterAsync() .

Parameters
Name Description
request Google\Cloud\Redis\Cluster\V1\CreateClusterRequest

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\Redis\Cluster\V1\Client\CloudRedisClusterClient;
use Google\Cloud\Redis\Cluster\V1\Cluster;
use Google\Cloud\Redis\Cluster\V1\CreateClusterRequest;
use Google\Cloud\Redis\Cluster\V1\PscConfig;
use Google\Rpc\Status;

/**
 * @param string $formattedParent          The resource name of the cluster location using the form:
 *                                         `projects/{project_id}/locations/{location_id}`
 *                                         where `location_id` refers to a GCP region. Please see
 *                                         {@see CloudRedisClusterClient::locationName()} for help formatting this field.
 * @param string $clusterId                The logical name of the Redis cluster in the customer project
 *                                         with the following restrictions:
 *
 *                                         * Must contain only lowercase letters, numbers, and hyphens.
 *                                         * Must start with a letter.
 *                                         * Must be between 1-63 characters.
 *                                         * Must end with a number or a letter.
 *                                         * Must be unique within the customer project / location
 * @param string $clusterName              Unique name of the resource in this scope including project and
 *                                         location using the form:
 *                                         `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`
 * @param int    $clusterShardCount        Number of shards for the Redis cluster.
 * @param string $clusterPscConfigsNetwork The network where the IP address of the discovery endpoint will
 *                                         be reserved, in the form of
 *                                         projects/{network_project}/global/networks/{network_id}.
 */
function create_cluster_sample(
    string $formattedParent,
    string $clusterId,
    string $clusterName,
    int $clusterShardCount,
    string $clusterPscConfigsNetwork
): void {
    // Create a client.
    $cloudRedisClusterClient = new CloudRedisClusterClient();

    // Prepare the request message.
    $pscConfig = (new PscConfig())
        ->setNetwork($clusterPscConfigsNetwork);
    $clusterPscConfigs = [$pscConfig,];
    $cluster = (new Cluster())
        ->setName($clusterName)
        ->setShardCount($clusterShardCount)
        ->setPscConfigs($clusterPscConfigs);
    $request = (new CreateClusterRequest())
        ->setParent($formattedParent)
        ->setClusterId($clusterId)
        ->setCluster($cluster);

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

        if ($response->operationSucceeded()) {
            /** @var Cluster $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
{
    $formattedParent = CloudRedisClusterClient::locationName('[PROJECT]', '[LOCATION]');
    $clusterId = '[CLUSTER_ID]';
    $clusterName = '[NAME]';
    $clusterShardCount = 0;
    $clusterPscConfigsNetwork = '[NETWORK]';

    create_cluster_sample(
        $formattedParent,
        $clusterId,
        $clusterName,
        $clusterShardCount,
        $clusterPscConfigsNetwork
    );
}

deleteCluster

Deletes a specific Redis cluster. Cluster stops serving and data is deleted.

The async variant is Google\Cloud\Redis\Cluster\V1\Client\CloudRedisClusterClient::deleteClusterAsync() .

Parameters
Name Description
request Google\Cloud\Redis\Cluster\V1\DeleteClusterRequest

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\Redis\Cluster\V1\Client\CloudRedisClusterClient;
use Google\Cloud\Redis\Cluster\V1\DeleteClusterRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Redis cluster resource name using the form:
 *                              `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`
 *                              where `location_id` refers to a GCP region. Please see
 *                              {@see CloudRedisClusterClient::clusterName()} for help formatting this field.
 */
function delete_cluster_sample(string $formattedName): void
{
    // Create a client.
    $cloudRedisClusterClient = new CloudRedisClusterClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $cloudRedisClusterClient->deleteCluster($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 = CloudRedisClusterClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');

    delete_cluster_sample($formattedName);
}

getCluster

Gets the details of a specific Redis cluster.

The async variant is Google\Cloud\Redis\Cluster\V1\Client\CloudRedisClusterClient::getClusterAsync() .

Parameters
Name Description
request Google\Cloud\Redis\Cluster\V1\GetClusterRequest

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\Redis\Cluster\V1\Cluster
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Redis\Cluster\V1\Client\CloudRedisClusterClient;
use Google\Cloud\Redis\Cluster\V1\Cluster;
use Google\Cloud\Redis\Cluster\V1\GetClusterRequest;

/**
 * @param string $formattedName Redis cluster resource name using the form:
 *                              `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`
 *                              where `location_id` refers to a GCP region. Please see
 *                              {@see CloudRedisClusterClient::clusterName()} for help formatting this field.
 */
function get_cluster_sample(string $formattedName): void
{
    // Create a client.
    $cloudRedisClusterClient = new CloudRedisClusterClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Cluster $response */
        $response = $cloudRedisClusterClient->getCluster($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 = CloudRedisClusterClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');

    get_cluster_sample($formattedName);
}

listClusters

Lists all Redis clusters owned by a project in either the specified location (region) or all locations.

The location should have the following format:

  • projects/{project_id}/locations/{location_id}

If location_id is specified as - (wildcard), then all regions available to the project are queried, and the results are aggregated.

The async variant is Google\Cloud\Redis\Cluster\V1\Client\CloudRedisClusterClient::listClustersAsync() .

Parameters
Name Description
request Google\Cloud\Redis\Cluster\V1\ListClustersRequest

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\Redis\Cluster\V1\Client\CloudRedisClusterClient;
use Google\Cloud\Redis\Cluster\V1\Cluster;
use Google\Cloud\Redis\Cluster\V1\ListClustersRequest;

/**
 * @param string $formattedParent The resource name of the cluster location using the form:
 *                                `projects/{project_id}/locations/{location_id}`
 *                                where `location_id` refers to a GCP region. Please see
 *                                {@see CloudRedisClusterClient::locationName()} for help formatting this field.
 */
function list_clusters_sample(string $formattedParent): void
{
    // Create a client.
    $cloudRedisClusterClient = new CloudRedisClusterClient();

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

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

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

    list_clusters_sample($formattedParent);
}

updateCluster

Updates the metadata and configuration of a specific Redis cluster.

Completed longrunning.Operation will contain the new cluster object in the response field. The returned operation is automatically deleted after a few hours, so there is no need to call DeleteOperation.

The async variant is Google\Cloud\Redis\Cluster\V1\Client\CloudRedisClusterClient::updateClusterAsync() .

Parameters
Name Description
request Google\Cloud\Redis\Cluster\V1\UpdateClusterRequest

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\Redis\Cluster\V1\Client\CloudRedisClusterClient;
use Google\Cloud\Redis\Cluster\V1\Cluster;
use Google\Cloud\Redis\Cluster\V1\PscConfig;
use Google\Cloud\Redis\Cluster\V1\UpdateClusterRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * @param string $clusterName              Unique name of the resource in this scope including project and
 *                                         location using the form:
 *                                         `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`
 * @param int    $clusterShardCount        Number of shards for the Redis cluster.
 * @param string $clusterPscConfigsNetwork The network where the IP address of the discovery endpoint will
 *                                         be reserved, in the form of
 *                                         projects/{network_project}/global/networks/{network_id}.
 */
function update_cluster_sample(
    string $clusterName,
    int $clusterShardCount,
    string $clusterPscConfigsNetwork
): void {
    // Create a client.
    $cloudRedisClusterClient = new CloudRedisClusterClient();

    // Prepare the request message.
    $updateMask = new FieldMask();
    $pscConfig = (new PscConfig())
        ->setNetwork($clusterPscConfigsNetwork);
    $clusterPscConfigs = [$pscConfig,];
    $cluster = (new Cluster())
        ->setName($clusterName)
        ->setShardCount($clusterShardCount)
        ->setPscConfigs($clusterPscConfigs);
    $request = (new UpdateClusterRequest())
        ->setUpdateMask($updateMask)
        ->setCluster($cluster);

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

        if ($response->operationSucceeded()) {
            /** @var Cluster $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
{
    $clusterName = '[NAME]';
    $clusterShardCount = 0;
    $clusterPscConfigsNetwork = '[NETWORK]';

    update_cluster_sample($clusterName, $clusterShardCount, $clusterPscConfigsNetwork);
}

getLocation

Gets information about a location.

The async variant is Google\Cloud\Redis\Cluster\V1\Client\CloudRedisClusterClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

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\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\Redis\Cluster\V1\Client\CloudRedisClusterClient;

/**
 * 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.
    $cloudRedisClusterClient = new CloudRedisClusterClient();

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

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

listLocations

Lists information about the supported locations for this service.

The async variant is Google\Cloud\Redis\Cluster\V1\Client\CloudRedisClusterClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

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\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\Redis\Cluster\V1\Client\CloudRedisClusterClient;

/**
 * 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.
    $cloudRedisClusterClient = new CloudRedisClusterClient();

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

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

createClusterAsync

Parameters
Name Description
request Google\Cloud\Redis\Cluster\V1\CreateClusterRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteClusterAsync

Parameters
Name Description
request Google\Cloud\Redis\Cluster\V1\DeleteClusterRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getClusterAsync

Parameters
Name Description
request Google\Cloud\Redis\Cluster\V1\GetClusterRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listClustersAsync

Parameters
Name Description
request Google\Cloud\Redis\Cluster\V1\ListClustersRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateClusterAsync

Parameters
Name Description
request Google\Cloud\Redis\Cluster\V1\UpdateClusterRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getOperationsClient

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

Returns
Type Description
Google\LongRunning\Client\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::clusterName

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

Parameters
Name Description
project string
location string
cluster string
Returns
Type Description
string The formatted cluster resource.

static::locationName

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

Parameters
Name Description
project string
location string
Returns
Type Description
string The formatted location 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

  • cluster: projects/{project}/locations/{location}/clusters/{cluster}
  • 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
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.