Reference documentation and code samples for the Google Cloud AlloyDB for PostgreSQL V1 Client class AlloyDBAdminClient.
Service Description: Service describing handlers for resources
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 \ AlloyDb \ V1 \ ClientMethods
__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 |
↳ 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 |
↳ 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. |
batchCreateInstances
Creates new instances under the given project, location and cluster.
There can be only one primary instance in a cluster. If the primary instance exists in the cluster as well as this request, then API will throw an error. The primary instance should exist before any read pool instance is created. If the primary instance is a part of the request payload, then the API will take care of creating instances in the correct order. This method is here to support Google-internal use cases, and is not meant for external customers to consume. Please do not start relying on it; its behavior is subject to change without notice.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::batchCreateInstancesAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\BatchCreateInstancesRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\BatchCreateInstancesRequest;
use Google\Cloud\AlloyDb\V1\BatchCreateInstancesResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\CreateInstanceRequest;
use Google\Cloud\AlloyDb\V1\CreateInstanceRequests;
use Google\Cloud\AlloyDb\V1\Instance;
use Google\Cloud\AlloyDb\V1\Instance\InstanceType;
use Google\Rpc\Status;
/**
* @param string $formattedParent The name of the parent resource. Please see
* {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
* @param string $formattedRequestsCreateInstanceRequestsParent The name of the parent resource. For the required format, see the
* comment on the Instance.name field. Please see
* {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
* @param string $requestsCreateInstanceRequestsInstanceId ID of the requesting object.
* @param int $requestsCreateInstanceRequestsInstanceInstanceType The type of the instance. Specified at creation time.
*/
function batch_create_instances_sample(
string $formattedParent,
string $formattedRequestsCreateInstanceRequestsParent,
string $requestsCreateInstanceRequestsInstanceId,
int $requestsCreateInstanceRequestsInstanceInstanceType
): void {
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$requestsCreateInstanceRequestsInstance = (new Instance())
->setInstanceType($requestsCreateInstanceRequestsInstanceInstanceType);
$createInstanceRequest = (new CreateInstanceRequest())
->setParent($formattedRequestsCreateInstanceRequestsParent)
->setInstanceId($requestsCreateInstanceRequestsInstanceId)
->setInstance($requestsCreateInstanceRequestsInstance);
$requestsCreateInstanceRequests = [$createInstanceRequest,];
$requests = (new CreateInstanceRequests())
->setCreateInstanceRequests($requestsCreateInstanceRequests);
$request = (new BatchCreateInstancesRequest())
->setParent($formattedParent)
->setRequests($requests);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->batchCreateInstances($request);
$response->pollUntilComplete();
if ($response->operationSucceeded()) {
/** @var BatchCreateInstancesResponse $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 = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');
$formattedRequestsCreateInstanceRequestsParent = AlloyDBAdminClient::clusterName(
'[PROJECT]',
'[LOCATION]',
'[CLUSTER]'
);
$requestsCreateInstanceRequestsInstanceId = '[INSTANCE_ID]';
$requestsCreateInstanceRequestsInstanceInstanceType = InstanceType::INSTANCE_TYPE_UNSPECIFIED;
batch_create_instances_sample(
$formattedParent,
$formattedRequestsCreateInstanceRequestsParent,
$requestsCreateInstanceRequestsInstanceId,
$requestsCreateInstanceRequestsInstanceInstanceType
);
}
createBackup
Creates a new Backup in a given project and location.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::createBackupAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\CreateBackupRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Backup;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\CreateBackupRequest;
use Google\Rpc\Status;
/**
* @param string $formattedParent Value for parent. Please see
* {@see AlloyDBAdminClient::locationName()} for help formatting this field.
* @param string $backupId ID of the requesting object.
* @param string $formattedBackupClusterName The full resource name of the backup source cluster
* (e.g., projects/{project}/locations/{region}/clusters/{cluster_id}). Please see
* {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
*/
function create_backup_sample(
string $formattedParent,
string $backupId,
string $formattedBackupClusterName
): void {
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$backup = (new Backup())
->setClusterName($formattedBackupClusterName);
$request = (new CreateBackupRequest())
->setParent($formattedParent)
->setBackupId($backupId)
->setBackup($backup);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->createBackup($request);
$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());
}
}
/**
* 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 = AlloyDBAdminClient::locationName('[PROJECT]', '[LOCATION]');
$backupId = '[BACKUP_ID]';
$formattedBackupClusterName = AlloyDBAdminClient::clusterName(
'[PROJECT]',
'[LOCATION]',
'[CLUSTER]'
);
create_backup_sample($formattedParent, $backupId, $formattedBackupClusterName);
}
createCluster
Creates a new Cluster in a given project and location.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::createClusterAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\Cluster;
use Google\Cloud\AlloyDb\V1\CreateClusterRequest;
use Google\Rpc\Status;
/**
* @param string $formattedParent The location of the new cluster. For the required format, see the
* comment on the Cluster.name field. Please see
* {@see AlloyDBAdminClient::locationName()} for help formatting this field.
* @param string $clusterId ID of the requesting object.
* @param string $formattedClusterNetwork The resource link for the VPC network in which cluster resources
* are created and from which they are accessible via Private IP. The network
* must belong to the same project as the cluster. It is specified in the
* form: "projects/{project}/global/networks/{network_id}". This is required
* to create a cluster. Deprecated, use network_config.network instead. Please see
* {@see AlloyDBAdminClient::networkName()} for help formatting this field.
*/
function create_cluster_sample(
string $formattedParent,
string $clusterId,
string $formattedClusterNetwork
): void {
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$cluster = (new Cluster())
->setNetwork($formattedClusterNetwork);
$request = (new CreateClusterRequest())
->setParent($formattedParent)
->setClusterId($clusterId)
->setCluster($cluster);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->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 = AlloyDBAdminClient::locationName('[PROJECT]', '[LOCATION]');
$clusterId = '[CLUSTER_ID]';
$formattedClusterNetwork = AlloyDBAdminClient::networkName('[PROJECT]', '[NETWORK]');
create_cluster_sample($formattedParent, $clusterId, $formattedClusterNetwork);
}
createInstance
Creates a new Instance in a given project and location.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::createInstanceAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\CreateInstanceRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\CreateInstanceRequest;
use Google\Cloud\AlloyDb\V1\Instance;
use Google\Cloud\AlloyDb\V1\Instance\InstanceType;
use Google\Rpc\Status;
/**
* @param string $formattedParent The name of the parent resource. For the required format, see the
* comment on the Instance.name field. Please see
* {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
* @param string $instanceId ID of the requesting object.
* @param int $instanceInstanceType The type of the instance. Specified at creation time.
*/
function create_instance_sample(
string $formattedParent,
string $instanceId,
int $instanceInstanceType
): void {
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$instance = (new Instance())
->setInstanceType($instanceInstanceType);
$request = (new CreateInstanceRequest())
->setParent($formattedParent)
->setInstanceId($instanceId)
->setInstance($instance);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->createInstance($request);
$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());
}
}
/**
* 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 = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');
$instanceId = '[INSTANCE_ID]';
$instanceInstanceType = InstanceType::INSTANCE_TYPE_UNSPECIFIED;
create_instance_sample($formattedParent, $instanceId, $instanceInstanceType);
}
createSecondaryCluster
Creates a cluster of type SECONDARY in the given location using the primary cluster as the source.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::createSecondaryClusterAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\CreateSecondaryClusterRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\Cluster;
use Google\Cloud\AlloyDb\V1\CreateSecondaryClusterRequest;
use Google\Rpc\Status;
/**
* @param string $formattedParent The location of the new cluster. For the required
* format, see the comment on the Cluster.name field. Please see
* {@see AlloyDBAdminClient::locationName()} for help formatting this field.
* @param string $clusterId ID of the requesting object (the secondary cluster).
* @param string $formattedClusterNetwork The resource link for the VPC network in which cluster resources
* are created and from which they are accessible via Private IP. The network
* must belong to the same project as the cluster. It is specified in the
* form: "projects/{project}/global/networks/{network_id}". This is required
* to create a cluster. Deprecated, use network_config.network instead. Please see
* {@see AlloyDBAdminClient::networkName()} for help formatting this field.
*/
function create_secondary_cluster_sample(
string $formattedParent,
string $clusterId,
string $formattedClusterNetwork
): void {
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$cluster = (new Cluster())
->setNetwork($formattedClusterNetwork);
$request = (new CreateSecondaryClusterRequest())
->setParent($formattedParent)
->setClusterId($clusterId)
->setCluster($cluster);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->createSecondaryCluster($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 = AlloyDBAdminClient::locationName('[PROJECT]', '[LOCATION]');
$clusterId = '[CLUSTER_ID]';
$formattedClusterNetwork = AlloyDBAdminClient::networkName('[PROJECT]', '[NETWORK]');
create_secondary_cluster_sample($formattedParent, $clusterId, $formattedClusterNetwork);
}
createSecondaryInstance
Creates a new SECONDARY Instance in a given project and location.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::createSecondaryInstanceAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\CreateSecondaryInstanceRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\CreateSecondaryInstanceRequest;
use Google\Cloud\AlloyDb\V1\Instance;
use Google\Cloud\AlloyDb\V1\Instance\InstanceType;
use Google\Rpc\Status;
/**
* @param string $formattedParent The name of the parent resource. For the required format, see the
* comment on the Instance.name field. Please see
* {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
* @param string $instanceId ID of the requesting object.
* @param int $instanceInstanceType The type of the instance. Specified at creation time.
*/
function create_secondary_instance_sample(
string $formattedParent,
string $instanceId,
int $instanceInstanceType
): void {
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$instance = (new Instance())
->setInstanceType($instanceInstanceType);
$request = (new CreateSecondaryInstanceRequest())
->setParent($formattedParent)
->setInstanceId($instanceId)
->setInstance($instance);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->createSecondaryInstance($request);
$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());
}
}
/**
* 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 = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');
$instanceId = '[INSTANCE_ID]';
$instanceInstanceType = InstanceType::INSTANCE_TYPE_UNSPECIFIED;
create_secondary_instance_sample($formattedParent, $instanceId, $instanceInstanceType);
}
createUser
Creates a new User in a given project, location, and cluster.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::createUserAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\CreateUserRequest
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\AlloyDb\V1\User |
use Google\ApiCore\ApiException;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\CreateUserRequest;
use Google\Cloud\AlloyDb\V1\User;
/**
* @param string $formattedParent Value for parent. Please see
* {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
* @param string $userId ID of the requesting object.
*/
function create_user_sample(string $formattedParent, string $userId): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$user = new User();
$request = (new CreateUserRequest())
->setParent($formattedParent)
->setUserId($userId)
->setUser($user);
// Call the API and handle any network failures.
try {
/** @var User $response */
$response = $alloyDBAdminClient->createUser($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 = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');
$userId = '[USER_ID]';
create_user_sample($formattedParent, $userId);
}
deleteBackup
Deletes a single Backup.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::deleteBackupAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\DeleteBackupRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\DeleteBackupRequest;
use Google\Rpc\Status;
/**
* @param string $formattedName Name of the resource. For the required format, see the comment on
* the Backup.name field. Please see
* {@see AlloyDBAdminClient::backupName()} for help formatting this field.
*/
function delete_backup_sample(string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new DeleteBackupRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->deleteBackup($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 = AlloyDBAdminClient::backupName('[PROJECT]', '[LOCATION]', '[BACKUP]');
delete_backup_sample($formattedName);
}
deleteCluster
Deletes a single Cluster.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::deleteClusterAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\DeleteClusterRequest;
use Google\Rpc\Status;
/**
* @param string $formattedName The name of the resource. For the required format, see the
* comment on the Cluster.name field. Please see
* {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
*/
function delete_cluster_sample(string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new DeleteClusterRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->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 = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');
delete_cluster_sample($formattedName);
}
deleteInstance
Deletes a single Instance.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::deleteInstanceAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\DeleteInstanceRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\DeleteInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $formattedName The name of the resource. For the required format, see the
* comment on the Instance.name field. Please see
* {@see AlloyDBAdminClient::instanceName()} for help formatting this field.
*/
function delete_instance_sample(string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new DeleteInstanceRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->deleteInstance($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 = AlloyDBAdminClient::instanceName(
'[PROJECT]',
'[LOCATION]',
'[CLUSTER]',
'[INSTANCE]'
);
delete_instance_sample($formattedName);
}
deleteUser
Deletes a single User.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::deleteUserAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\DeleteUserRequest
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. |
use Google\ApiCore\ApiException;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\DeleteUserRequest;
/**
* @param string $formattedName The name of the resource. For the required format, see the
* comment on the User.name field. Please see
* {@see AlloyDBAdminClient::userName()} for help formatting this field.
*/
function delete_user_sample(string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new DeleteUserRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$alloyDBAdminClient->deleteUser($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 = AlloyDBAdminClient::userName('[PROJECT]', '[LOCATION]', '[CLUSTER]', '[USER]');
delete_user_sample($formattedName);
}
failoverInstance
Forces a Failover for a highly available instance.
Failover promotes the HA standby instance as the new primary. Imperative only.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::failoverInstanceAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\FailoverInstanceRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\FailoverInstanceRequest;
use Google\Cloud\AlloyDb\V1\Instance;
use Google\Rpc\Status;
/**
* @param string $formattedName The name of the resource. For the required format, see the
* comment on the Instance.name field. Please see
* {@see AlloyDBAdminClient::instanceName()} for help formatting this field.
*/
function failover_instance_sample(string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new FailoverInstanceRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->failoverInstance($request);
$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());
}
}
/**
* 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 = AlloyDBAdminClient::instanceName(
'[PROJECT]',
'[LOCATION]',
'[CLUSTER]',
'[INSTANCE]'
);
failover_instance_sample($formattedName);
}
generateClientCertificate
Generate a client certificate signed by a Cluster CA.
The sole purpose of this endpoint is to support AlloyDB connectors and the Auth Proxy client. The endpoint's behavior is subject to change without notice, so do not rely on its behavior remaining constant. Future changes will not break AlloyDB connectors or the Auth Proxy client.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::generateClientCertificateAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\GenerateClientCertificateRequest
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\AlloyDb\V1\GenerateClientCertificateResponse |
use Google\ApiCore\ApiException;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\GenerateClientCertificateRequest;
use Google\Cloud\AlloyDb\V1\GenerateClientCertificateResponse;
/**
* @param string $formattedParent The name of the parent resource. The required format is:
* * projects/{project}/locations/{location}/clusters/{cluster}
* Please see {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
*/
function generate_client_certificate_sample(string $formattedParent): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new GenerateClientCertificateRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var GenerateClientCertificateResponse $response */
$response = $alloyDBAdminClient->generateClientCertificate($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 = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');
generate_client_certificate_sample($formattedParent);
}
getBackup
Gets details of a single Backup.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::getBackupAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\GetBackupRequest
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\AlloyDb\V1\Backup |
use Google\ApiCore\ApiException;
use Google\Cloud\AlloyDb\V1\Backup;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\GetBackupRequest;
/**
* @param string $formattedName Name of the resource
* Please see {@see AlloyDBAdminClient::backupName()} for help formatting this field.
*/
function get_backup_sample(string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new GetBackupRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Backup $response */
$response = $alloyDBAdminClient->getBackup($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 = AlloyDBAdminClient::backupName('[PROJECT]', '[LOCATION]', '[BACKUP]');
get_backup_sample($formattedName);
}
getCluster
Gets details of a single Cluster.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::getClusterAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\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\AlloyDb\V1\Cluster |
use Google\ApiCore\ApiException;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\Cluster;
use Google\Cloud\AlloyDb\V1\GetClusterRequest;
/**
* @param string $formattedName The name of the resource. For the required format, see the
* comment on the Cluster.name field. Please see
* {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
*/
function get_cluster_sample(string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new GetClusterRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Cluster $response */
$response = $alloyDBAdminClient->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 = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');
get_cluster_sample($formattedName);
}
getConnectionInfo
Get instance metadata used for a connection.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::getConnectionInfoAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\GetConnectionInfoRequest
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\AlloyDb\V1\ConnectionInfo |
use Google\ApiCore\ApiException;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\ConnectionInfo;
use Google\Cloud\AlloyDb\V1\GetConnectionInfoRequest;
/**
* @param string $formattedParent The name of the parent resource. The required format is:
* projects/{project}/locations/{location}/clusters/{cluster}/instances/{instance}
* Please see {@see AlloyDBAdminClient::instanceName()} for help formatting this field.
*/
function get_connection_info_sample(string $formattedParent): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new GetConnectionInfoRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var ConnectionInfo $response */
$response = $alloyDBAdminClient->getConnectionInfo($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 = AlloyDBAdminClient::instanceName(
'[PROJECT]',
'[LOCATION]',
'[CLUSTER]',
'[INSTANCE]'
);
get_connection_info_sample($formattedParent);
}
getInstance
Gets details of a single Instance.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::getInstanceAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\GetInstanceRequest
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\AlloyDb\V1\Instance |
use Google\ApiCore\ApiException;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\GetInstanceRequest;
use Google\Cloud\AlloyDb\V1\Instance;
/**
* @param string $formattedName The name of the resource. For the required format, see the
* comment on the Instance.name field. Please see
* {@see AlloyDBAdminClient::instanceName()} for help formatting this field.
*/
function get_instance_sample(string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new GetInstanceRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var Instance $response */
$response = $alloyDBAdminClient->getInstance($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 = AlloyDBAdminClient::instanceName(
'[PROJECT]',
'[LOCATION]',
'[CLUSTER]',
'[INSTANCE]'
);
get_instance_sample($formattedName);
}
getUser
Gets details of a single User.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::getUserAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\GetUserRequest
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\AlloyDb\V1\User |
use Google\ApiCore\ApiException;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\GetUserRequest;
use Google\Cloud\AlloyDb\V1\User;
/**
* @param string $formattedName The name of the resource. For the required format, see the
* comment on the User.name field. Please see
* {@see AlloyDBAdminClient::userName()} for help formatting this field.
*/
function get_user_sample(string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new GetUserRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var User $response */
$response = $alloyDBAdminClient->getUser($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 = AlloyDBAdminClient::userName('[PROJECT]', '[LOCATION]', '[CLUSTER]', '[USER]');
get_user_sample($formattedName);
}
injectFault
Injects fault in an instance.
Imperative only.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::injectFaultAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\InjectFaultRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\InjectFaultRequest;
use Google\Cloud\AlloyDb\V1\InjectFaultRequest\FaultType;
use Google\Cloud\AlloyDb\V1\Instance;
use Google\Rpc\Status;
/**
* @param int $faultType The type of fault to be injected in an instance.
* @param string $formattedName The name of the resource. For the required format, see the
* comment on the Instance.name field. Please see
* {@see AlloyDBAdminClient::instanceName()} for help formatting this field.
*/
function inject_fault_sample(int $faultType, string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new InjectFaultRequest())
->setFaultType($faultType)
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->injectFault($request);
$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());
}
}
/**
* 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
{
$faultType = FaultType::FAULT_TYPE_UNSPECIFIED;
$formattedName = AlloyDBAdminClient::instanceName(
'[PROJECT]',
'[LOCATION]',
'[CLUSTER]',
'[INSTANCE]'
);
inject_fault_sample($faultType, $formattedName);
}
listBackups
Lists Backups in a given project and location.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::listBackupsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\ListBackupsRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AlloyDb\V1\Backup;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\ListBackupsRequest;
/**
* @param string $formattedParent Parent value for ListBackupsRequest
* Please see {@see AlloyDBAdminClient::locationName()} for help formatting this field.
*/
function list_backups_sample(string $formattedParent): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new ListBackupsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $alloyDBAdminClient->listBackups($request);
/** @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());
}
}
/**
* 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 = AlloyDBAdminClient::locationName('[PROJECT]', '[LOCATION]');
list_backups_sample($formattedParent);
}
listClusters
Lists Clusters in a given project and location.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::listClustersAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\Cluster;
use Google\Cloud\AlloyDb\V1\ListClustersRequest;
/**
* @param string $formattedParent The name of the parent resource. For the required format, see the
* comment on the Cluster.name field. Additionally, you can perform an
* aggregated list operation by specifying a value with the following format:
* * projects/{project}/locations/-
* Please see {@see AlloyDBAdminClient::locationName()} for help formatting this field.
*/
function list_clusters_sample(string $formattedParent): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new ListClustersRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $alloyDBAdminClient->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 = AlloyDBAdminClient::locationName('[PROJECT]', '[LOCATION]');
list_clusters_sample($formattedParent);
}
listInstances
Lists Instances in a given project and location.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::listInstancesAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\ListInstancesRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\Instance;
use Google\Cloud\AlloyDb\V1\ListInstancesRequest;
/**
* @param string $formattedParent The name of the parent resource. For the required format, see the
* comment on the Instance.name field. Additionally, you can perform an
* aggregated list operation by specifying a value with one of the following
* formats:
* * projects/{project}/locations/-/clusters/-
* * projects/{project}/locations/{region}/clusters/-
* Please see {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
*/
function list_instances_sample(string $formattedParent): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new ListInstancesRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $alloyDBAdminClient->listInstances($request);
/** @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());
}
}
/**
* 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 = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');
list_instances_sample($formattedParent);
}
listSupportedDatabaseFlags
Lists SupportedDatabaseFlags for a given project and location.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::listSupportedDatabaseFlagsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\ListSupportedDatabaseFlagsRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\ListSupportedDatabaseFlagsRequest;
use Google\Cloud\AlloyDb\V1\SupportedDatabaseFlag;
/**
* @param string $formattedParent The name of the parent resource. The required format is:
* * projects/{project}/locations/{location}
*
* Regardless of the parent specified here, as long it is contains a valid
* project and location, the service will return a static list of supported
* flags resources. Note that we do not yet support region-specific
* flags. Please see
* {@see AlloyDBAdminClient::locationName()} for help formatting this field.
*/
function list_supported_database_flags_sample(string $formattedParent): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new ListSupportedDatabaseFlagsRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $alloyDBAdminClient->listSupportedDatabaseFlags($request);
/** @var SupportedDatabaseFlag $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 = AlloyDBAdminClient::locationName('[PROJECT]', '[LOCATION]');
list_supported_database_flags_sample($formattedParent);
}
listUsers
Lists Users in a given project and location.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::listUsersAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\ListUsersRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\ListUsersRequest;
use Google\Cloud\AlloyDb\V1\User;
/**
* @param string $formattedParent Parent value for ListUsersRequest
* Please see {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
*/
function list_users_sample(string $formattedParent): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new ListUsersRequest())
->setParent($formattedParent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $alloyDBAdminClient->listUsers($request);
/** @var User $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 = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');
list_users_sample($formattedParent);
}
promoteCluster
Promotes a SECONDARY cluster. This turns down replication from the PRIMARY cluster and promotes a secondary cluster into its own standalone cluster.
Imperative only.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::promoteClusterAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\PromoteClusterRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\Cluster;
use Google\Cloud\AlloyDb\V1\PromoteClusterRequest;
use Google\Rpc\Status;
/**
* @param string $formattedName The name of the resource. For the required format, see the
* comment on the Cluster.name field
* Please see {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
*/
function promote_cluster_sample(string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new PromoteClusterRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->promoteCluster($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
{
$formattedName = AlloyDBAdminClient::clusterName('[PROJECT]', '[LOCATION]', '[CLUSTER]');
promote_cluster_sample($formattedName);
}
restartInstance
Restart an Instance in a cluster.
Imperative only.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::restartInstanceAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\RestartInstanceRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\Instance;
use Google\Cloud\AlloyDb\V1\RestartInstanceRequest;
use Google\Rpc\Status;
/**
* @param string $formattedName The name of the resource. For the required format, see the
* comment on the Instance.name field. Please see
* {@see AlloyDBAdminClient::instanceName()} for help formatting this field.
*/
function restart_instance_sample(string $formattedName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = (new RestartInstanceRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->restartInstance($request);
$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());
}
}
/**
* 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 = AlloyDBAdminClient::instanceName(
'[PROJECT]',
'[LOCATION]',
'[CLUSTER]',
'[INSTANCE]'
);
restart_instance_sample($formattedName);
}
restoreCluster
Creates a new Cluster in a given project and location, with a volume restored from the provided source, either a backup ID or a point-in-time and a source cluster.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::restoreClusterAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\RestoreClusterRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\Cluster;
use Google\Cloud\AlloyDb\V1\RestoreClusterRequest;
use Google\Rpc\Status;
/**
* @param string $formattedParent The name of the parent resource. For the required format, see the
* comment on the Cluster.name field. Please see
* {@see AlloyDBAdminClient::locationName()} for help formatting this field.
* @param string $clusterId ID of the requesting object.
* @param string $formattedClusterNetwork The resource link for the VPC network in which cluster resources
* are created and from which they are accessible via Private IP. The network
* must belong to the same project as the cluster. It is specified in the
* form: "projects/{project}/global/networks/{network_id}". This is required
* to create a cluster. Deprecated, use network_config.network instead. Please see
* {@see AlloyDBAdminClient::networkName()} for help formatting this field.
*/
function restore_cluster_sample(
string $formattedParent,
string $clusterId,
string $formattedClusterNetwork
): void {
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$cluster = (new Cluster())
->setNetwork($formattedClusterNetwork);
$request = (new RestoreClusterRequest())
->setParent($formattedParent)
->setClusterId($clusterId)
->setCluster($cluster);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->restoreCluster($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 = AlloyDBAdminClient::locationName('[PROJECT]', '[LOCATION]');
$clusterId = '[CLUSTER_ID]';
$formattedClusterNetwork = AlloyDBAdminClient::networkName('[PROJECT]', '[NETWORK]');
restore_cluster_sample($formattedParent, $clusterId, $formattedClusterNetwork);
}
updateBackup
Updates the parameters of a single Backup.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::updateBackupAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\UpdateBackupRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Backup;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\UpdateBackupRequest;
use Google\Rpc\Status;
/**
* @param string $formattedBackupClusterName The full resource name of the backup source cluster
* (e.g., projects/{project}/locations/{region}/clusters/{cluster_id}). Please see
* {@see AlloyDBAdminClient::clusterName()} for help formatting this field.
*/
function update_backup_sample(string $formattedBackupClusterName): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$backup = (new Backup())
->setClusterName($formattedBackupClusterName);
$request = (new UpdateBackupRequest())
->setBackup($backup);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->updateBackup($request);
$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());
}
}
/**
* 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
{
$formattedBackupClusterName = AlloyDBAdminClient::clusterName(
'[PROJECT]',
'[LOCATION]',
'[CLUSTER]'
);
update_backup_sample($formattedBackupClusterName);
}
updateCluster
Updates the parameters of a single Cluster.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::updateClusterAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\Cluster;
use Google\Cloud\AlloyDb\V1\UpdateClusterRequest;
use Google\Rpc\Status;
/**
* @param string $formattedClusterNetwork The resource link for the VPC network in which cluster resources
* are created and from which they are accessible via Private IP. The network
* must belong to the same project as the cluster. It is specified in the
* form: "projects/{project}/global/networks/{network_id}". This is required
* to create a cluster. Deprecated, use network_config.network instead. Please see
* {@see AlloyDBAdminClient::networkName()} for help formatting this field.
*/
function update_cluster_sample(string $formattedClusterNetwork): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$cluster = (new Cluster())
->setNetwork($formattedClusterNetwork);
$request = (new UpdateClusterRequest())
->setCluster($cluster);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->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
{
$formattedClusterNetwork = AlloyDBAdminClient::networkName('[PROJECT]', '[NETWORK]');
update_cluster_sample($formattedClusterNetwork);
}
updateInstance
Updates the parameters of a single Instance.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::updateInstanceAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\UpdateInstanceRequest
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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\Instance;
use Google\Cloud\AlloyDb\V1\Instance\InstanceType;
use Google\Cloud\AlloyDb\V1\UpdateInstanceRequest;
use Google\Rpc\Status;
/**
* @param int $instanceInstanceType The type of the instance. Specified at creation time.
*/
function update_instance_sample(int $instanceInstanceType): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$instance = (new Instance())
->setInstanceType($instanceInstanceType);
$request = (new UpdateInstanceRequest())
->setInstance($instance);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $alloyDBAdminClient->updateInstance($request);
$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());
}
}
/**
* 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
{
$instanceInstanceType = InstanceType::INSTANCE_TYPE_UNSPECIFIED;
update_instance_sample($instanceInstanceType);
}
updateUser
Updates the parameters of a single User.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::updateUserAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\UpdateUserRequest
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\AlloyDb\V1\User |
use Google\ApiCore\ApiException;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\AlloyDb\V1\UpdateUserRequest;
use Google\Cloud\AlloyDb\V1\User;
/**
* 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_user_sample(): void
{
// Create a client.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$user = new User();
$request = (new UpdateUserRequest())
->setUser($user);
// Call the API and handle any network failures.
try {
/** @var User $response */
$response = $alloyDBAdminClient->updateUser($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
getLocation
Gets information about a location.
The async variant is Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient::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 |
use Google\ApiCore\ApiException;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;
/**
* 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.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = new GetLocationRequest();
// Call the API and handle any network failures.
try {
/** @var Location $response */
$response = $alloyDBAdminClient->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\AlloyDb\V1\Client\AlloyDBAdminClient::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 |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\AlloyDb\V1\Client\AlloyDBAdminClient;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;
/**
* 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.
$alloyDBAdminClient = new AlloyDBAdminClient();
// Prepare the request message.
$request = new ListLocationsRequest();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $alloyDBAdminClient->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());
}
}
batchCreateInstancesAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\BatchCreateInstancesRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
createBackupAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\CreateBackupRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
createClusterAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\CreateClusterRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
createInstanceAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\CreateInstanceRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
createSecondaryClusterAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\CreateSecondaryClusterRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
createSecondaryInstanceAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\CreateSecondaryInstanceRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
createUserAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\CreateUserRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
deleteBackupAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\DeleteBackupRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
deleteClusterAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\DeleteClusterRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
deleteInstanceAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\DeleteInstanceRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
deleteUserAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\DeleteUserRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
failoverInstanceAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\FailoverInstanceRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
generateClientCertificateAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\GenerateClientCertificateRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getBackupAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\GetBackupRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getClusterAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\GetClusterRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getConnectionInfoAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\GetConnectionInfoRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getInstanceAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\GetInstanceRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getUserAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\GetUserRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
injectFaultAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\InjectFaultRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
listBackupsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\ListBackupsRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
listClustersAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\ListClustersRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
listInstancesAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\ListInstancesRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
listSupportedDatabaseFlagsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\ListSupportedDatabaseFlagsRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
listUsersAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\ListUsersRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
promoteClusterAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\PromoteClusterRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
restartInstanceAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\RestartInstanceRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
restoreClusterAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\RestoreClusterRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
updateBackupAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\UpdateBackupRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
updateClusterAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\UpdateClusterRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
updateInstanceAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\UpdateInstanceRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
updateUserAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\AlloyDb\V1\UpdateUserRequest
|
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::backupName
Formats a string containing the fully-qualified path to represent a backup resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
backup |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted backup resource. |
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::cryptoKeyVersionName
Formats a string containing the fully-qualified path to represent a crypto_key_version resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
keyRing |
string
|
cryptoKey |
string
|
cryptoKeyVersion |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted crypto_key_version resource. |
static::instanceName
Formats a string containing the fully-qualified path to represent a instance resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
cluster |
string
|
instance |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted instance 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::networkName
Formats a string containing the fully-qualified path to represent a network resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
network |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted network resource. |
static::userName
Formats a string containing the fully-qualified path to represent a user resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
cluster |
string
|
user |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted user 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
- backup: projects/{project}/locations/{location}/backups/{backup}
- cluster: projects/{project}/locations/{location}/clusters/{cluster}
- cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}
- instance: projects/{project}/locations/{location}/clusters/{cluster}/instances/{instance}
- location: projects/{project}/locations/{location}
- network: projects/{project}/global/networks/{network}
- user: projects/{project}/locations/{location}/clusters/{cluster}/users/{user}
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. |