Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] committed Nov 29, 2023
1 parent b17494c commit fa74d6d
Show file tree
Hide file tree
Showing 650 changed files with 172 additions and 96,110 deletions.
Binary file modified SqlAdmin/metadata/V1Beta4/CloudSql.php
Binary file not shown.
Binary file modified SqlAdmin/metadata/V1Beta4/CloudSqlResources.php
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions SqlAdmin/src/V1beta4/Gapic/SqlInstancesServiceGapicClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use Google\Cloud\Sql\V1beta4\DatabaseInstance;
use Google\Cloud\Sql\V1beta4\InstancesCloneRequest;
use Google\Cloud\Sql\V1beta4\InstancesDemoteMasterRequest;
use Google\Cloud\Sql\V1beta4\InstancesDemoteRequest;
use Google\Cloud\Sql\V1beta4\InstancesExportRequest;
use Google\Cloud\Sql\V1beta4\InstancesFailoverRequest;
use Google\Cloud\Sql\V1beta4\InstancesImportRequest;
Expand All @@ -54,6 +55,7 @@
use Google\Cloud\Sql\V1beta4\SqlInstancesCreateEphemeralCertRequest;
use Google\Cloud\Sql\V1beta4\SqlInstancesDeleteRequest;
use Google\Cloud\Sql\V1beta4\SqlInstancesDemoteMasterRequest;
use Google\Cloud\Sql\V1beta4\SqlInstancesDemoteRequest;
use Google\Cloud\Sql\V1beta4\SqlInstancesExportRequest;
use Google\Cloud\Sql\V1beta4\SqlInstancesFailoverRequest;
use Google\Cloud\Sql\V1beta4\SqlInstancesGetDiskShrinkConfigRequest;
Expand Down Expand Up @@ -476,6 +478,67 @@ public function delete(array $optionalArgs = [])
)->wait();
}

/**
* Demotes an existing standalone instance to be a Cloud SQL read replica
* for an external database server.
*
* Sample code:
* ```
* $sqlInstancesServiceClient = new SqlInstancesServiceClient();
* try {
* $instance = 'instance';
* $project = 'project';
* $response = $sqlInstancesServiceClient->demote($instance, $project);
* } finally {
* $sqlInstancesServiceClient->close();
* }
* ```
*
* @param string $instance Required. The name of the Cloud SQL instance.
* @param string $project Required. The project ID of the project that contains the instance.
* @param array $optionalArgs {
* Optional.
*
* @type InstancesDemoteRequest $body
* The request body.
* @type RetrySettings|array $retrySettings
* Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
* associative array of retry settings parameters. See the documentation on
* {@see RetrySettings} for example usage.
* }
*
* @return \Google\Cloud\Sql\V1beta4\Operation
*
* @throws ApiException if the remote call fails
*
* @experimental
*/
public function demote($instance, $project, array $optionalArgs = [])
{
$request = new SqlInstancesDemoteRequest();
$requestParamHeaders = [];
$request->setInstance($instance);
$request->setProject($project);
$requestParamHeaders['instance'] = $instance;
$requestParamHeaders['project'] = $project;
if (isset($optionalArgs['body'])) {
$request->setBody($optionalArgs['body']);
}

$requestParams = new RequestParamsHeaderDescriptor(
$requestParamHeaders
);
$optionalArgs['headers'] = isset($optionalArgs['headers'])
? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
: $requestParams->getHeader();
return $this->startCall(
'Demote',
Operation::class,
$optionalArgs,
$request
)->wait();
}

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions SqlAdmin/src/V1beta4/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@
"delete"
]
},
"Demote": {
"methods": [
"demote"
]
},
"DemoteMaster": {
"methods": [
"demoteMaster"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
"retry_codes_name": "no_retry_1_codes",
"retry_params_name": "no_retry_1_params"
},
"Demote": {
"timeout_millis": 60000,
"retry_codes_name": "no_retry_1_codes",
"retry_params_name": "no_retry_1_params"
},
"DemoteMaster": {
"timeout_millis": 60000,
"retry_codes_name": "no_retry_1_codes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@
],
],
],
'Demote' => [
'method' => 'post',
'uriTemplate' => '/sql/v1beta4/projects/{project}/instances/{instance}/demote',
'body' => 'body',
'placeholders' => [
'instance' => [
'getters' => [
'getInstance',
],
],
'project' => [
'getters' => [
'getProject',
],
],
],
],
'DemoteMaster' => [
'method' => 'post',
'uriTemplate' => '/sql/v1beta4/projects/{project}/instances/{instance}/demoteMaster',
Expand Down
76 changes: 76 additions & 0 deletions SqlAdmin/tests/Unit/V1beta4/SqlInstancesServiceClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,82 @@ public function deleteExceptionTest()
$this->assertTrue($transport->isExhausted());
}

/** @test */
public function demoteTest()
{
$transport = $this->createTransport();
$gapicClient = $this->createClient([
'transport' => $transport,
]);
$this->assertTrue($transport->isExhausted());
// Mock response
$kind = 'kind3292052';
$targetLink = 'targetLink-2084812312';
$user = 'user3599307';
$name = 'name3373707';
$targetId = 'targetId-815576439';
$selfLink = 'selfLink-1691268851';
$targetProject = 'targetProject392184427';
$expectedResponse = new Operation();
$expectedResponse->setKind($kind);
$expectedResponse->setTargetLink($targetLink);
$expectedResponse->setUser($user);
$expectedResponse->setName($name);
$expectedResponse->setTargetId($targetId);
$expectedResponse->setSelfLink($selfLink);
$expectedResponse->setTargetProject($targetProject);
$transport->addResponse($expectedResponse);
// Mock request
$instance = 'instance555127957';
$project = 'project-309310695';
$response = $gapicClient->demote($instance, $project);
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
$actualFuncCall = $actualRequests[0]->getFuncCall();
$actualRequestObject = $actualRequests[0]->getRequestObject();
$this->assertSame('/google.cloud.sql.v1beta4.SqlInstancesService/Demote', $actualFuncCall);
$actualValue = $actualRequestObject->getInstance();
$this->assertProtobufEquals($instance, $actualValue);
$actualValue = $actualRequestObject->getProject();
$this->assertProtobufEquals($project, $actualValue);
$this->assertTrue($transport->isExhausted());
}

/** @test */
public function demoteExceptionTest()
{
$transport = $this->createTransport();
$gapicClient = $this->createClient([
'transport' => $transport,
]);
$this->assertTrue($transport->isExhausted());
$status = new stdClass();
$status->code = Code::DATA_LOSS;
$status->details = 'internal error';
$expectedExceptionMessage = json_encode([
'message' => 'internal error',
'code' => Code::DATA_LOSS,
'status' => 'DATA_LOSS',
'details' => [],
], JSON_PRETTY_PRINT);
$transport->addResponse(null, $status);
// Mock request
$instance = 'instance555127957';
$project = 'project-309310695';
try {
$gapicClient->demote($instance, $project);
// If the $gapicClient method call did not throw, fail the test
$this->fail('Expected an ApiException, but no exception was thrown.');
} catch (ApiException $ex) {
$this->assertEquals($status->code, $ex->getCode());
$this->assertEquals($expectedExceptionMessage, $ex->getMessage());
}
// Call popReceivedCalls to ensure the stub is exhausted
$transport->popReceivedCalls();
$this->assertTrue($transport->isExhausted());
}

/** @test */
public function demoteMasterTest()
{
Expand Down

This file was deleted.

Binary file not shown.

This file was deleted.

Loading

0 comments on commit fa74d6d

Please sign in to comment.