Google Cloud Sql Admin V1 Client - Class SqlInstancesServiceClient (0.10.0)

Reference documentation and code samples for the Google Cloud Sql Admin V1 Client class SqlInstancesServiceClient.

Service Description: Service to manage Cloud SQL instances.

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

This class is currently experimental and may be subject to changes.

Namespace

Google \ Cloud \ Sql \ V1 \ Client

Methods

__construct

Constructor.

Parameters
NameDescription
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

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

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

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

↳ credentialsConfig array

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

↳ disableRetries bool

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

↳ clientConfig string|array

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

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

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

↳ clientCertSource callable

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

addServerCa

Adds a new trusted Certificate Authority (CA) version for the specified instance. Required to prepare for a certificate rotation. If a CA version was previously added but never used in a certificate rotation, this operation replaces that version. There cannot be more than one CA version waiting to be rotated in.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::addServerCaAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesAddServerCaRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesAddServerCaRequest;

/**
 * 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 add_server_ca_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

clone

Creates a Cloud SQL instance as a clone of the source instance. Using this operation might cause your instance to restart.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::cloneAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesCloneRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesCloneRequest;

/**
 * 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 clone_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

createEphemeral

Generates a short-lived X509 certificate containing the provided public key and signed by a private key specific to the target instance. Users may use the certificate to authenticate as themselves when connecting to the database.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::createEphemeralAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesCreateEphemeralCertRequest

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
TypeDescription
Google\Cloud\Sql\V1\SslCert
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\SqlInstancesCreateEphemeralCertRequest;
use Google\Cloud\Sql\V1\SslCert;

/**
 * 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 create_ephemeral_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

delete

Deletes a Cloud SQL instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::deleteAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesDeleteRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesDeleteRequest;

/**
 * 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 delete_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

demote

Demotes an existing standalone instance to be a Cloud SQL read replica for an external database server.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::demoteAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesDemoteRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\DemoteContext;
use Google\Cloud\Sql\V1\InstancesDemoteRequest;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesDemoteRequest;

/**
 * @param string $instance                                          Cloud SQL instance name.
 * @param string $project                                           ID of the project that contains the instance.
 * @param string $bodyDemoteContextSourceRepresentativeInstanceName The name of the instance which acts as the on-premises primary
 *                                                                  instance in the replication setup.
 */
function demote_sample(
    string $instance,
    string $project,
    string $bodyDemoteContextSourceRepresentativeInstanceName
): void {
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

    // Prepare the request message.
    $bodyDemoteContext = (new DemoteContext())
        ->setSourceRepresentativeInstanceName($bodyDemoteContextSourceRepresentativeInstanceName);
    $body = (new InstancesDemoteRequest())
        ->setDemoteContext($bodyDemoteContext);
    $request = (new SqlInstancesDemoteRequest())
        ->setInstance($instance)
        ->setProject($project)
        ->setBody($body);

    // Call the API and handle any network failures.
    try {
        /** @var Operation $response */
        $response = $sqlInstancesServiceClient->demote($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
{
    $instance = '[INSTANCE]';
    $project = '[PROJECT]';
    $bodyDemoteContextSourceRepresentativeInstanceName = '[SOURCE_REPRESENTATIVE_INSTANCE_NAME]';

    demote_sample($instance, $project, $bodyDemoteContextSourceRepresentativeInstanceName);
}

demoteMaster

Demotes the stand-alone instance to be a Cloud SQL read replica for an external database server.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::demoteMasterAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesDemoteMasterRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesDemoteMasterRequest;

/**
 * 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 demote_master_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

export

Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL dump or CSV file.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::exportAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesExportRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesExportRequest;

/**
 * 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 export_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

failover

Initiates a manual failover of a high availability (HA) primary instance to a standby instance, which becomes the primary instance. Users are then rerouted to the new primary. For more information, see the Overview of high availability page in the Cloud SQL documentation.

If using Legacy HA (MySQL only), this causes the instance to failover to its failover replica instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::failoverAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesFailoverRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesFailoverRequest;

/**
 * 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 failover_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

get

Retrieves a resource containing information about a Cloud SQL instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::getAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesGetRequest

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
TypeDescription
Google\Cloud\Sql\V1\DatabaseInstance
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\DatabaseInstance;
use Google\Cloud\Sql\V1\SqlInstancesGetRequest;

/**
 * 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_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

getDiskShrinkConfig

Get Disk Shrink Config for a given instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::getDiskShrinkConfigAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesGetDiskShrinkConfigRequest

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
TypeDescription
Google\Cloud\Sql\V1\SqlInstancesGetDiskShrinkConfigResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\SqlInstancesGetDiskShrinkConfigRequest;
use Google\Cloud\Sql\V1\SqlInstancesGetDiskShrinkConfigResponse;

/**
 * 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_disk_shrink_config_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

getLatestRecoveryTime

Get Latest Recovery Time for a given instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::getLatestRecoveryTimeAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesGetLatestRecoveryTimeRequest

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
TypeDescription
Google\Cloud\Sql\V1\SqlInstancesGetLatestRecoveryTimeResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\SqlInstancesGetLatestRecoveryTimeRequest;
use Google\Cloud\Sql\V1\SqlInstancesGetLatestRecoveryTimeResponse;

/**
 * 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_latest_recovery_time_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

import

Imports data into a Cloud SQL instance from a SQL dump or CSV file in Cloud Storage.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::importAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesImportRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesImportRequest;

/**
 * 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 import_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

insert

Creates a new Cloud SQL instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::insertAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesInsertRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesInsertRequest;

/**
 * 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 insert_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

list

Lists instances under a given project.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::listAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesListRequest

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
TypeDescription
Google\Cloud\Sql\V1\InstancesListResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\InstancesListResponse;
use Google\Cloud\Sql\V1\SqlInstancesListRequest;

/**
 * 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_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

listServerCas

Lists all of the trusted Certificate Authorities (CAs) for the specified instance. There can be up to three CAs listed: the CA that was used to sign the certificate that is currently in use, a CA that has been added but not yet used to sign a certificate, and a CA used to sign a certificate that has previously rotated out.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::listServerCasAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesListServerCasRequest

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
TypeDescription
Google\Cloud\Sql\V1\InstancesListServerCasResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\InstancesListServerCasResponse;
use Google\Cloud\Sql\V1\SqlInstancesListServerCasRequest;

/**
 * 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_server_cas_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

patch

Partially updates settings of a Cloud SQL instance by merging the request with the current configuration. This method supports patch semantics.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::patchAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesPatchRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesPatchRequest;

/**
 * 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 patch_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

performDiskShrink

Perform Disk Shrink on primary instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::performDiskShrinkAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesPerformDiskShrinkRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesPerformDiskShrinkRequest;

/**
 * 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 perform_disk_shrink_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

promoteReplica

Promotes the read replica instance to be a stand-alone Cloud SQL instance.

Using this operation might cause your instance to restart.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::promoteReplicaAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesPromoteReplicaRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesPromoteReplicaRequest;

/**
 * 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 promote_replica_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

reencrypt

Reencrypt CMEK instance with latest key version.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::reencryptAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesReencryptRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesReencryptRequest;

/**
 * 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 reencrypt_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

rescheduleMaintenance

Reschedules the maintenance on the given instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::rescheduleMaintenanceAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesRescheduleMaintenanceRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesRescheduleMaintenanceRequest;

/**
 * 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 reschedule_maintenance_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

resetReplicaSize

Reset Replica Size to primary instance disk size.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::resetReplicaSizeAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesResetReplicaSizeRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesResetReplicaSizeRequest;

/**
 * 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 reset_replica_size_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

resetSslConfig

Deletes all client certificates and generates a new server SSL certificate for the instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::resetSslConfigAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesResetSslConfigRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesResetSslConfigRequest;

/**
 * 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 reset_ssl_config_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

restart

Restarts a Cloud SQL instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::restartAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesRestartRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesRestartRequest;

/**
 * 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 restart_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

restoreBackup

Restores a backup of a Cloud SQL instance. Using this operation might cause your instance to restart.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::restoreBackupAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesRestoreBackupRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesRestoreBackupRequest;

/**
 * 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 restore_backup_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

rotateServerCa

Rotates the server certificate to one signed by the Certificate Authority (CA) version previously added with the addServerCA method.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::rotateServerCaAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesRotateServerCaRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesRotateServerCaRequest;

/**
 * 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 rotate_server_ca_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

startExternalSync

Start External primary instance migration.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::startExternalSyncAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesStartExternalSyncRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesStartExternalSyncRequest;

/**
 * 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 start_external_sync_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

startReplica

Starts the replication in the read replica instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::startReplicaAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesStartReplicaRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesStartReplicaRequest;

/**
 * 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 start_replica_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

stopReplica

Stops the replication in the read replica instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::stopReplicaAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesStopReplicaRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesStopReplicaRequest;

/**
 * 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 stop_replica_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

switchover

Switches over from the primary instance to the replica instance.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::switchoverAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesSwitchoverRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesSwitchoverRequest;

/**
 * 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 switchover_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

truncateLog

Truncate MySQL general and slow query log tables MySQL only.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::truncateLogAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesTruncateLogRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesTruncateLogRequest;

/**
 * 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 truncate_log_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

update

Updates settings of a Cloud SQL instance. Using this operation might cause your instance to restart.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::updateAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesUpdateRequest

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
TypeDescription
Google\Cloud\Sql\V1\Operation
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\Operation;
use Google\Cloud\Sql\V1\SqlInstancesUpdateRequest;

/**
 * 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_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

verifyExternalSyncSettings

Verify External primary instance external sync settings.

The async variant is Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient::verifyExternalSyncSettingsAsync() .

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesVerifyExternalSyncSettingsRequest

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
TypeDescription
Google\Cloud\Sql\V1\SqlInstancesVerifyExternalSyncSettingsResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Sql\V1\Client\SqlInstancesServiceClient;
use Google\Cloud\Sql\V1\SqlInstancesVerifyExternalSyncSettingsRequest;
use Google\Cloud\Sql\V1\SqlInstancesVerifyExternalSyncSettingsResponse;

/**
 * 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 verify_external_sync_settings_sample(): void
{
    // Create a client.
    $sqlInstancesServiceClient = new SqlInstancesServiceClient();

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

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

addServerCaAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesAddServerCaRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

cloneAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesCloneRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

createEphemeralAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesCreateEphemeralCertRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

deleteAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesDeleteRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

demoteAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesDemoteRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

demoteMasterAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesDemoteMasterRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

exportAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesExportRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

failoverAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesFailoverRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesGetRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getDiskShrinkConfigAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesGetDiskShrinkConfigRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getLatestRecoveryTimeAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesGetLatestRecoveryTimeRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

importAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesImportRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

insertAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesInsertRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

listAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesListRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

listServerCasAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesListServerCasRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

patchAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesPatchRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

performDiskShrinkAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesPerformDiskShrinkRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

promoteReplicaAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesPromoteReplicaRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

reencryptAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesReencryptRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

rescheduleMaintenanceAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesRescheduleMaintenanceRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

resetReplicaSizeAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesResetReplicaSizeRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

resetSslConfigAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesResetSslConfigRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

restartAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesRestartRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

restoreBackupAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesRestoreBackupRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

rotateServerCaAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesRotateServerCaRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

startExternalSyncAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesStartExternalSyncRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

startReplicaAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesStartReplicaRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

stopReplicaAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesStopReplicaRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

switchoverAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesSwitchoverRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

truncateLogAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesTruncateLogRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

updateAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesUpdateRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

verifyExternalSyncSettingsAsync

Parameters
NameDescription
request Google\Cloud\Sql\V1\SqlInstancesVerifyExternalSyncSettingsRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface