From b32fb1956c69b36ebd6337d22f431327512fd73b Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Thu, 9 May 2024 12:03:01 +0530 Subject: [PATCH 01/36] Added changes to BigtableClient --- Bigtable/src/BigtableClient.php | 68 +++++++++++++++++---------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/Bigtable/src/BigtableClient.php b/Bigtable/src/BigtableClient.php index 2ca952e47c8..3ff071a4dde 100644 --- a/Bigtable/src/BigtableClient.php +++ b/Bigtable/src/BigtableClient.php @@ -21,8 +21,12 @@ use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; -use Google\Cloud\Bigtable\V2\BigtableClient as GapicClient; -use Google\Cloud\Core\ArrayTrait; +use Google\ApiCore\ArrayTrait; +use Google\ApiCore\ClientOptionsTrait; +use Google\ApiCore\Serializer; +use Google\Cloud\Bigtable\V2\Client\BigtableClient as BigtableGapicClient; +use Google\Cloud\Core\DetectProjectIdTrait; +use Google\Cloud\Core\RequestHandler; /** * Google Cloud Bigtable is Google's NoSQL Big Data database service. @@ -39,13 +43,23 @@ class BigtableClient { use ArrayTrait; + use DetectProjectIdTrait; + use ClientOptionsTrait; const VERSION = '1.31.1'; /** - * @var GapicClient + * @var RequestHandler + * @internal + * The request handler that is responsible for sending a request and + * serializing responses into relevant classes. */ - private $gapicClient; + private $requestHandler; + + /** + * @var Serializer + */ + private Serializer $serializer; /** * @var string @@ -122,9 +136,21 @@ public function __construct(array $config = []) 'grpc.keepalive_timeout_ms' => 10000 ]; - $this->projectId = $this->pluck('projectId', $config, false) - ?: $this->detectProjectId(); - $this->gapicClient = new GapicClient($config); + // Configure GAPIC client options + $config = $this->buildClientOptions($config); + $config['credentials'] = $this->createCredentialsWrapper( + $config['credentials'], + $config['credentialsConfig'], + $config['universeDomain'] + ); + + $this->projectId = $this->detectProjectId($config); + $this->serializer = new Serializer(); + $this->requestHandler = new RequestHandler( + $this->serializer, + [BigtableGapicClient::class], + $config + ); } /** @@ -150,32 +176,10 @@ public function __construct(array $config = []) public function table($instanceId, $tableId, array $options = []) { return new Table( - $this->gapicClient, - GapicClient::tableName($this->projectId, $instanceId, $tableId), + $this->requestHandler, + $this->serializer, + BigtableGapicClient::tableName($this->projectId, $instanceId, $tableId), $options ); } - - /** - * Attempts to detect the project ID. - * - * @todo Add better support for detecting the project ID (check keyFile/GCE metadata server). - * @return string - * @throws ValidationException If a project ID cannot be detected. - */ - private function detectProjectId() - { - if (getenv('GOOGLE_CLOUD_PROJECT')) { - return getenv('GOOGLE_CLOUD_PROJECT'); - } - - if (getenv('GCLOUD_PROJECT')) { - return getenv('GCLOUD_PROJECT'); - } - - throw new ValidationException( - 'No project ID was provided, ' . - 'and we were unable to detect a default project ID.' - ); - } } From 152702b29db4cca0f37c2b9efa95f2d8546d45a1 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Mon, 13 May 2024 16:55:51 +0530 Subject: [PATCH 02/36] feat(Bigtable): Replaced V1 GAPIC client surface with the V2 GAPIC surface. --- Bigtable/src/BigtableClient.php | 19 ++--- Bigtable/src/ResumableStream.php | 66 ++++++++++------ Bigtable/src/Table.php | 117 ++++++++++++++++++++--------- Bigtable/src/V2/BigtableClient.php | 4 +- 4 files changed, 136 insertions(+), 70 deletions(-) diff --git a/Bigtable/src/BigtableClient.php b/Bigtable/src/BigtableClient.php index 3ff071a4dde..2b2c4f653ca 100644 --- a/Bigtable/src/BigtableClient.php +++ b/Bigtable/src/BigtableClient.php @@ -24,7 +24,7 @@ use Google\ApiCore\ArrayTrait; use Google\ApiCore\ClientOptionsTrait; use Google\ApiCore\Serializer; -use Google\Cloud\Bigtable\V2\Client\BigtableClient as BigtableGapicClient; +use Google\Cloud\Bigtable\V2\Client\BigtableClient as GapicClient; use Google\Cloud\Core\DetectProjectIdTrait; use Google\Cloud\Core\RequestHandler; @@ -49,12 +49,9 @@ class BigtableClient const VERSION = '1.31.1'; /** - * @var RequestHandler - * @internal - * The request handler that is responsible for sending a request and - * serializing responses into relevant classes. + * @var GapicClient */ - private $requestHandler; + private $gapicClient; /** * @var Serializer @@ -146,11 +143,7 @@ public function __construct(array $config = []) $this->projectId = $this->detectProjectId($config); $this->serializer = new Serializer(); - $this->requestHandler = new RequestHandler( - $this->serializer, - [BigtableGapicClient::class], - $config - ); + $this->gapicClient = new GapicClient($config); } /** @@ -176,9 +169,9 @@ public function __construct(array $config = []) public function table($instanceId, $tableId, array $options = []) { return new Table( - $this->requestHandler, + $this->gapicClient, $this->serializer, - BigtableGapicClient::tableName($this->projectId, $instanceId, $tableId), + GapicClient::tableName($this->projectId, $instanceId, $tableId), $options ); } diff --git a/Bigtable/src/ResumableStream.php b/Bigtable/src/ResumableStream.php index 8b169ce3ec3..067bbe49111 100644 --- a/Bigtable/src/ResumableStream.php +++ b/Bigtable/src/ResumableStream.php @@ -18,15 +18,20 @@ namespace Google\Cloud\Bigtable; use Google\ApiCore\ApiException; -use Google\Cloud\Core\ExponentialBackoff; +use Google\ApiCore\ArrayTrait; +use Google\Cloud\Bigtable\V2\Client\BigtableClient as GapicClient; +use Google\Protobuf\Internal\Message; use Google\Rpc\Code; /** * User stream which handles failure from upstream, retries if necessary and * provides single retrying user stream. + * @internal */ class ResumableStream implements \IteratorAggregate { + use ArrayTrait; + const DEFAULT_MAX_RETRIES = 3; /** @@ -44,9 +49,19 @@ class ResumableStream implements \IteratorAggregate private $retries; /** - * @var callable + * @var GapicClient + */ + private $gapicClient; + + /** + * @var Message */ - private $apiFunction; + private $request; + + /** + * @var string + */ + private $method; /** * @var callable @@ -58,26 +73,38 @@ class ResumableStream implements \IteratorAggregate */ private $retryFunction; + /** + * array $optionalArgs + */ + private $optionalArgs; + /** * Constructs a resumable stream. * - * @param callable $apiFunction Function to execute to get server stream. Function signature - * should match: `function (...) : Google\ApiCore\ServerStream`. + * @param GapicClient $gapicClient The GAPIC client to use in order to send requests. + * @param string $method The method to call on the GAPIC client. + * @param Message $request The request to pass on to the GAPIC client method. * @param callable $argumentFunction Function which returns the argument to be used while * calling `$apiFunction`. * @param callable $retryFunction Function which determines whether to retry or not. * @param int $retries [optional] Number of times to retry. **Defaults to** `3`. */ public function __construct( - callable $apiFunction, + GapicClient $gapicClient, + string $method, + Message $request, callable $argumentFunction, callable $retryFunction, - $retries = self::DEFAULT_MAX_RETRIES + $retries = self::DEFAULT_MAX_RETRIES, + array $optionalArgs = [] ) { + $this->gapicClient = $gapicClient; + $this->method = $method; + $this->request = $request; $this->retries = $retries ?: self::DEFAULT_MAX_RETRIES; - $this->apiFunction = $apiFunction; $this->argumentFunction = $argumentFunction; $this->retryFunction = $retryFunction; + $this->optionalArgs = $optionalArgs; } /** @@ -93,9 +120,16 @@ public function readAll() $retryFunction = $this->retryFunction; do { $ex = null; - $args = $argumentFunction(); - if (!isset($args[1]['requestCompleted']) || $args[1]['requestCompleted'] !== true) { - $stream = $this->createExponentialBackoff()->execute($this->apiFunction, $args); + list($this->request, $this->optionalArgs) = $argumentFunction($this->request, $this->optionalArgs); + + $completed = $this->pluck('requestCompleted', $this->optionalArgs, false); + + if ($completed !== true) { + $stream = call_user_func_array( + [$this->gapicClient, $this->method], + [$this->request, $this->optionalArgs] + ); + try { foreach ($stream->readAll() as $item) { yield $item; @@ -131,14 +165,4 @@ public static function isRetryable($code) { return isset(self::$retryableStatusCodes[$code]); } - - private function createExponentialBackoff() - { - return new ExponentialBackoff( - $this->retries, - function ($ex) { - return self::isRetryable($ex->getCode()); - } - ); - } } diff --git a/Bigtable/src/Table.php b/Bigtable/src/Table.php index fe157fb9bc9..ffffa676b00 100644 --- a/Bigtable/src/Table.php +++ b/Bigtable/src/Table.php @@ -23,12 +23,19 @@ use Google\Cloud\Bigtable\Filter\FilterInterface; use Google\Cloud\Bigtable\Mutations; use Google\Cloud\Bigtable\ReadModifyWriteRowRules; -use Google\Cloud\Bigtable\V2\BigtableClient as GapicClient; use Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry; use Google\Cloud\Bigtable\V2\Row; use Google\Cloud\Bigtable\V2\RowRange; use Google\Cloud\Bigtable\V2\RowSet; -use Google\Cloud\Core\ArrayTrait; +use Google\ApiCore\ArrayTrait; +use Google\Cloud\Bigtable\V2\CheckAndMutateRowRequest; +use Google\Cloud\Bigtable\V2\Client\BigtableClient as GapicClient; +use Google\Cloud\Bigtable\V2\MutateRowRequest; +use Google\Cloud\Bigtable\V2\MutateRowsRequest; +use Google\Cloud\Bigtable\V2\ReadModifyWriteRowRequest; +use Google\Cloud\Bigtable\V2\ReadRowsRequest; +use Google\Cloud\Bigtable\V2\SampleRowKeysRequest; +use Google\Cloud\Core\ApiHelperTrait; use Google\Rpc\Code; /** @@ -46,6 +53,7 @@ class Table { use ArrayTrait; + use ApiHelperTrait; /** * @var GapicClient @@ -70,7 +78,8 @@ class Table /** * Create a table instance. * - * @param GapicClient $gapicClient The GAPIC client used to make requests. + * @param GapicClient $gapicClient The GAPIC client to use in order to send requests. + * @param Serializer $serializer The serializer instance to encode/decode messages. * @param string $tableName The full table name. Must match the following * pattern: projects/{project}/instances/{instance}/tables/{table}. * @param array $options [optional] { @@ -86,14 +95,15 @@ class Table * } */ public function __construct( - GapicClient $gapicClient, - $tableName, + $gapicClient, + Serializer $serializer, + string $tableName, array $options = [] ) { $this->gapicClient = $gapicClient; + $this->serializer = $serializer; $this->tableName = $tableName; $this->options = $options; - $this->serializer = new Serializer(); } /** @@ -157,12 +167,17 @@ public function mutateRows(array $rowMutations, array $options = []) */ public function mutateRow($rowKey, Mutations $mutations, array $options = []) { - $this->gapicClient->mutateRow( - $this->tableName, - $rowKey, - $mutations->toProto(), - $options + $this->options + list($data, $optionalArgs) = $this->splitOptionalArgs($options); + $data['table_name'] = $this->tableName; + $data['row_key'] = $rowKey; + $data['mutations'] = $mutations->toProto(); + $request = $this->serializer->decodeMessage( + new MutateRowRequest(), + $data ); + $optionalArgs += $this->options; + + $this->gapicClient->mutateRow($request, $optionalArgs); } /** @@ -265,7 +280,9 @@ public function readRows(array $options = []) $rowKeys = $this->pluck('rowKeys', $options, false) ?: []; $ranges = $this->pluck('rowRanges', $options, false) ?: []; $filter = $this->pluck('filter', $options, false) ?: null; + list($data, $optionalArgs) = $this->splitOptionalArgs($options); + // TODO: check if we can use the mergeFromJsonString function here. array_walk($ranges, function (&$range) { $range = $this->serializer->decodeMessage( new RowRange(), @@ -280,8 +297,10 @@ public function readRows(array $options = []) ) ); } + + // TODO: check if we can use the mergeFromJsonString function here. if ($ranges || $rowKeys) { - $options['rows'] = $this->serializer->decodeMessage( + $data['rows'] = $this->serializer->decodeMessage( new RowSet, [ 'rowKeys' => $rowKeys, @@ -299,12 +318,16 @@ public function readRows(array $options = []) ) ); } - $options['filter'] = $filter->toProto(); + $data['filter'] = $filter->toProto(); } + + $data += ['table_name' => $this->tableName]; + $request = new ReadRowsRequest($data); + return new ChunkFormatter( - [$this->gapicClient, 'readRows'], - $this->tableName, - $options + $this->options + $this->gapicClient, + $request, + $optionalArgs + $this->options ); } @@ -375,12 +398,17 @@ public function readRow($rowKey, array $options = []) */ public function readModifyWriteRow($rowKey, ReadModifyWriteRowRules $rules, array $options = []) { + list($data, $optionalArgs) = $this->splitOptionalArgs($options); + $data['table_name'] = $this->tableName; + $data['row_key'] = $rowKey; + $data['rules'] = $rules->toProto(); + + $request = new ReadModifyWriteRowRequest($data); $readModifyWriteRowResponse = $this->gapicClient->readModifyWriteRow( - $this->tableName, - $rowKey, - $rules->toProto(), - $options + $this->options + $request, + $optionalArgs + $this->options ); + return $this->convertToArray($readModifyWriteRowResponse->getRow()); } @@ -404,9 +432,13 @@ public function readModifyWriteRow($rowKey, ReadModifyWriteRowRules $rules, arra */ public function sampleRowKeys(array $options = []) { + list($data, $optionalArgs) = $this->splitOptionalArgs($options); + $data['table_name'] = $this->tableName; + + $request = new SampleRowKeysRequest($data); $stream = $this->gapicClient->sampleRowKeys( - $this->tableName, - $options + $this->options + $request, + $optionalArgs + $this->options ); foreach ($stream->readAll() as $response) { @@ -485,26 +517,33 @@ public function checkAndMutateRow($rowKey, array $options = []) throw new \InvalidArgumentException('checkAndMutateRow must have either trueMutations or falseMutations.'); } - return $this->gapicClient - ->checkAndMutateRow( - $this->tableName, - $rowKey, - $options + $this->options - ) - ->getPredicateMatched(); + list($data, $optionalArgs) = $this->splitOptionalArgs($options); + $data['table_name'] = $this->tableName; + $data['row_key'] = $rowKey; + $request = $this->serializer->decodeMessage(new CheckAndMutateRowRequest, $data); + + return $this->gapicClient->checkAndMutateRow( + $request, + $optionalArgs + $this->options + )->getPredicateMatched(); } private function mutateRowsWithEntries(array $entries, array $options = []) { $rowMutationsFailedResponse = []; $options = $options + $this->options; - $argumentFunction = function () use (&$entries, &$rowMutationsFailedResponse, $options) { + // This function is responsible to modify the $entries before every retry. + // TODO: Test failing $entries and see the effect. + $argumentFunction = function ($request, $options) use (&$entries, &$rowMutationsFailedResponse) { if (count($rowMutationsFailedResponse) > 0) { $entries = array_values($entries); $rowMutationsFailedResponse = []; } - return [$this->tableName, $entries, $options]; + + $request->setEntries($entries); + return [$request, $options]; }; + $statusCode = Code::OK; $lastProcessedIndex = -1; $retryFunction = function ($ex) use (&$statusCode, &$lastProcessedIndex) { @@ -515,11 +554,20 @@ private function mutateRowsWithEntries(array $entries, array $options = []) } return false; }; + + list($data, $optionalArgs) = $this->splitOptionalArgs($options); + + $request = new MutateRowsRequest($data); + $request->setTableName($this->tableName); + $retryingStream = new ResumableStream( - [$this->gapicClient, 'mutateRows'], + $this->gapicClient, + 'mutateRows', + $request, $argumentFunction, $retryFunction, - $this->pluck('retries', $options, false) + $this->pluck('retries', $options, false), + $optionalArgs ); $message = 'partial failure'; try { @@ -585,7 +633,8 @@ private function appendPendingEntryToFailedMutations( end($entries); foreach (range($lastProcessedIndex + 1, key($entries)) as $index) { $rowMutationsFailedResponse[] = [ - 'rowKey' => $entries[$index]->getRowKey(), + // TODO: check this + // 'rowKey' => $entries[$index]->getRowKey(), 'statusCode' => $statusCode, 'message' => $message ]; diff --git a/Bigtable/src/V2/BigtableClient.php b/Bigtable/src/V2/BigtableClient.php index ac3ab8f2607..79ef10006b6 100644 --- a/Bigtable/src/V2/BigtableClient.php +++ b/Bigtable/src/V2/BigtableClient.php @@ -31,7 +31,7 @@ namespace Google\Cloud\Bigtable\V2; use Google\Cloud\Bigtable\EmulatorSupportTrait; -use Google\Cloud\Bigtable\V2\Gapic\BigtableGapicClient; +use Google\Cloud\Bigtable\V2\Client\BigtableClient as BigtableGapicClient; /** * {@inheritdoc} @@ -41,5 +41,5 @@ class BigtableClient extends BigtableGapicClient use EmulatorSupportTrait; // This class is intentionally empty, and is intended to hold manual - // additions to the generated {@see BigtableGapicClient} class. + // additions to the generated {@see Google\Cloud\Bigtable\V2\Client\BigtableClient} class. } From deb138d624424cd49b8d885eb30ae6362cf61123 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Wed, 15 May 2024 18:54:49 +0530 Subject: [PATCH 03/36] Modified tests for ChunkFormatter --- Bigtable/tests/Unit/ChunkFormatterTest.php | 267 ++++++++++++--------- 1 file changed, 160 insertions(+), 107 deletions(-) diff --git a/Bigtable/tests/Unit/ChunkFormatterTest.php b/Bigtable/tests/Unit/ChunkFormatterTest.php index f5d8c6f6cae..a4d1e105e78 100644 --- a/Bigtable/tests/Unit/ChunkFormatterTest.php +++ b/Bigtable/tests/Unit/ChunkFormatterTest.php @@ -17,9 +17,12 @@ namespace Google\Cloud\Bigtable\Tests\Unit; -use Google\ApiCore\ServerStream; +use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\Testing\MockTransport; use Google\Cloud\Bigtable\ChunkFormatter; use Google\Cloud\Bigtable\Exception\BigtableDataOperationException; +use Google\Cloud\Bigtable\V2\Client\BigtableClient; +use Google\Cloud\Bigtable\V2\ReadRowsRequest; use Google\Cloud\Bigtable\V2\ReadRowsResponse; use Google\Cloud\Bigtable\V2\ReadRowsResponse\CellChunk as ReadRowsResponse_CellChunk; use Google\Protobuf\StringValue; @@ -36,17 +39,21 @@ class ChunkFormatterTest extends TestCase use ProphecyTrait; const TABLE_NAME = 'test-table'; - private $serverStream; private $chunkFormatter; + private $gapicClient; + private $readRowsRequest; + private $transport; public function setUp(): void { - $this->serverStream = $this->prophesize(ServerStream::class); + $this->transport = $this->createTransport(); + $this->gapicClient = $this->createClient([ + 'transport' => $this->transport, + ]); + $this->readRowsRequest = new ReadRowsRequest(['table_name' => self::TABLE_NAME]); $this->chunkFormatter = new ChunkFormatter( - function () { - return $this->serverStream->reveal(); - }, - self::TABLE_NAME, + $this->gapicClient, + $this->readRowsRequest, [] ); } @@ -56,12 +63,13 @@ public function testNewRowShouldThrowWhenNoRowKey() $this->expectException(BigtableDataOperationException::class); $this->expectExceptionMessage('A row key must be set.'); + // Add a mock response to our transport $readRowsResponse = new ReadRowsResponse; $chunk = new ReadRowsResponse_CellChunk(); $readRowsResponse->setChunks([$chunk]); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -80,9 +88,11 @@ public function testNewRowShouldGenerateWhenRowKeyIsZero() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + + // Execute the test $rows = iterator_to_array($this->chunkFormatter->readAll()); $expectedRows = [ '0' => [ @@ -108,9 +118,10 @@ public function testNewRowShouldThrowWhenResetIsTrue() $chunk->setRowKey('rk1'); $chunk->setResetRow(true); $readRowsResponse->setChunks([$chunk]); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -123,9 +134,10 @@ public function testNewRowShouldThrowWhenNoFamilyName() $chunk = new ReadRowsResponse_CellChunk(); $chunk->setRowKey('rk1'); $readRowsResponse->setChunks([$chunk]); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -141,9 +153,10 @@ public function testNewRowShouldThrowWhenNoQualifier() $stringValue->setValue('cf1'); $chunk->setFamilyName($stringValue); $readRowsResponse->setChunks([$chunk]); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -164,9 +177,10 @@ public function testNewRowShouldThrowWhenValueSizeAndCommitRow() $chunk->setValueSize(10); $chunk->setCommitRow(true); $readRowsResponse->setChunks([$chunk]); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -198,9 +212,10 @@ public function testNewRowShouldThrowWhenSameRowKeyFollows() $chunk->setQualifier($bytesValue); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -220,9 +235,10 @@ public function testNewRowShouldGenerateNewRow() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $expectedRows = [ 'rk1' => [ @@ -255,9 +271,10 @@ public function testNewRowShouldGenerateNewRowWithBinaryData() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $expectedRows = [ 'rk1' => [ @@ -290,9 +307,10 @@ public function testNewRowShouldGenerateNewRowWithBinaryRowKey() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $expectedRows = [ $data => [ @@ -325,9 +343,10 @@ public function testNewRowShouldGenerateNewRowWithTimeStamp() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $expectedRows = [ 'rk1' => [ @@ -361,9 +380,10 @@ public function testNewRowShouldGenerateNewRowWithLabels() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $expectedRows = [ 'rk1' => [ @@ -397,9 +417,10 @@ public function testNewRowShouldThrowWhenPendingRow() $chunk->setValue('Value1'); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -425,9 +446,10 @@ public function testValidateResetWithRowKey() $chunk->setResetRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -453,9 +475,10 @@ public function testValidateResetWithQualifier() $chunk->setResetRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -481,9 +504,10 @@ public function testValidateResetWithValue() $chunk->setResetRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -509,9 +533,10 @@ public function testValidateResetWithTimestampMicro() $chunk->setResetRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -536,9 +561,10 @@ public function testRowInProgressDifferentRowKey() $chunk->setRowKey('rk2'); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -566,9 +592,10 @@ public function testRowInProgressFamilyNameWithouQualifier() $chunk->setFamilyName($stringValue); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -601,9 +628,10 @@ public function testRowInProgressValueSizeAndCommit() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -625,9 +653,10 @@ public function testRowInProgressResetShouldNotGenerateRow() $chunk->setResetRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $this->assertEquals([], $rows); } @@ -657,9 +686,10 @@ public function testRowInProgressTwoFamily() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $expectedRows = [ 'rk1' => [ @@ -704,9 +734,10 @@ public function testRowInProgressOneFamilyTwoQualifier() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $expectedRows = [ 'rk1' => [ @@ -750,9 +781,10 @@ public function testRowInProgressWithTimestamp() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $expectedRows = [ 'rk1' => [ @@ -796,9 +828,10 @@ public function testRowInProgressWithLabels() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $expectedRows = [ 'rk1' => [ @@ -842,9 +875,10 @@ public function testCellInProgressValueSizeAndCommit() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -871,9 +905,10 @@ public function testCellInProgressValidateResetWithRowKey() $chunk->setResetRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -902,9 +937,10 @@ public function testCellInProgressValidateResetWithQualifier() $chunk->setResetRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -931,9 +967,10 @@ public function testCellInProgressValidateResetWithValue() $chunk->setResetRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -960,9 +997,10 @@ public function testCellInProgressValidateResetWithTimestampMicro() $chunk->setResetRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + iterator_to_array($this->chunkFormatter->readAll()); } @@ -985,9 +1023,10 @@ public function testCellInProgressResetShouldNotGenerateRow() $chunk->setResetRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $this->assertEquals([], $rows); } @@ -1012,9 +1051,10 @@ public function testCellInProgressOneFamilyTwoQualifier() $chunk->setCommitRow(true); $chunks[] = $chunk; $readRowsResponse->setChunks($chunks); - $this->serverStream->readAll()->shouldBeCalled()->willReturn( - $this->arrayAsGenerator([$readRowsResponse]) - ); + + // Add a mock response to our transport + $this->transport->addResponse($readRowsResponse); + $rows = iterator_to_array($this->chunkFormatter->readAll()); $expectedRows = [ 'rk1' => [ @@ -1030,10 +1070,23 @@ public function testCellInProgressOneFamilyTwoQualifier() $this->assertEquals($expectedRows, $rows); } - private function arrayAsGenerator(array $array) + private function createTransport($deserialize = null) { - foreach ($array as $item) { - yield $item; - } + return new MockTransport($deserialize); + } + + /** @return CredentialsWrapper */ + private function createCredentials() + { + return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); + } + + /** @return BigtableClient */ + private function createClient(array $options = []) + { + $options += [ + 'credentials' => $this->createCredentials(), + ]; + return new BigtableClient($options); } } From 6aabbf472f27aa3d1899e7fd005d53252eedcddc Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Wed, 15 May 2024 19:15:57 +0530 Subject: [PATCH 04/36] Modified BigtableClientTest --- Bigtable/tests/Unit/V2/BigtableClientTest.php | 117 ++++++++++++++---- 1 file changed, 96 insertions(+), 21 deletions(-) diff --git a/Bigtable/tests/Unit/V2/BigtableClientTest.php b/Bigtable/tests/Unit/V2/BigtableClientTest.php index 98e28eb6097..8f80cbdd27b 100644 --- a/Bigtable/tests/Unit/V2/BigtableClientTest.php +++ b/Bigtable/tests/Unit/V2/BigtableClientTest.php @@ -27,15 +27,24 @@ use Google\ApiCore\ServerStream; use Google\ApiCore\Testing\GeneratedTest; use Google\ApiCore\Testing\MockTransport; -use Google\Cloud\Bigtable\V2\BigtableClient; +use Google\Cloud\Bigtable\V2\CheckAndMutateRowRequest; use Google\Cloud\Bigtable\V2\CheckAndMutateRowResponse; +use Google\Cloud\Bigtable\V2\Client\BigtableClient as BigtableGapicClient; +use Google\Cloud\Bigtable\V2\GenerateInitialChangeStreamPartitionsRequest; use Google\Cloud\Bigtable\V2\GenerateInitialChangeStreamPartitionsResponse; +use Google\Cloud\Bigtable\V2\MutateRowRequest; use Google\Cloud\Bigtable\V2\MutateRowResponse; +use Google\Cloud\Bigtable\V2\MutateRowsRequest; use Google\Cloud\Bigtable\V2\MutateRowsResponse; +use Google\Cloud\Bigtable\V2\PingAndWarmRequest; use Google\Cloud\Bigtable\V2\PingAndWarmResponse; +use Google\Cloud\Bigtable\V2\ReadChangeStreamRequest; use Google\Cloud\Bigtable\V2\ReadChangeStreamResponse; +use Google\Cloud\Bigtable\V2\ReadModifyWriteRowRequest; use Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse; +use Google\Cloud\Bigtable\V2\ReadRowsRequest; use Google\Cloud\Bigtable\V2\ReadRowsResponse; +use Google\Cloud\Bigtable\V2\SampleRowKeysRequest; use Google\Cloud\Bigtable\V2\SampleRowKeysResponse; use Google\Rpc\Code; use stdClass; @@ -59,13 +68,13 @@ private function createCredentials() return $this->getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); } - /** @return BigtableClient */ + /** @return BigtableGapicClient */ private function createClient(array $options = []) { $options += [ 'credentials' => $this->createCredentials(), ]; - return new BigtableClient($options); + return new BigtableGapicClient($options); } /** @test */ @@ -84,7 +93,11 @@ public function checkAndMutateRowTest() // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); $rowKey = '122'; - $response = $gapicClient->checkAndMutateRow($formattedTableName, $rowKey); + $request = new CheckAndMutateRowRequest([ + 'table_name' => $formattedTableName, + 'row_key' => $rowKey + ]); + $response = $gapicClient->checkAndMutateRow($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -119,8 +132,12 @@ public function checkAndMutateRowExceptionTest() // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); $rowKey = '122'; + $request = new CheckAndMutateRowRequest([ + 'table_name' => $formattedTableName, + 'row_key' => $rowKey + ]); try { - $gapicClient->checkAndMutateRow($formattedTableName, $rowKey); + $gapicClient->checkAndMutateRow($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -149,7 +166,10 @@ public function generateInitialChangeStreamPartitionsTest() $transport->addResponse($expectedResponse3); // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $serverStream = $gapicClient->generateInitialChangeStreamPartitions($formattedTableName); + $request = new GenerateInitialChangeStreamPartitionsRequest([ + 'table_name' => $formattedTableName + ]); + $serverStream = $gapicClient->generateInitialChangeStreamPartitions($request); $this->assertInstanceOf(ServerStream::class, $serverStream); $responses = iterator_to_array($serverStream->readAll()); $expectedResponses = []; @@ -187,7 +207,10 @@ public function generateInitialChangeStreamPartitionsExceptionTest() $this->assertTrue($transport->isExhausted()); // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $serverStream = $gapicClient->generateInitialChangeStreamPartitions($formattedTableName); + $request = new GenerateInitialChangeStreamPartitionsRequest([ + 'table_name' => $formattedTableName + ]); + $serverStream = $gapicClient->generateInitialChangeStreamPartitions($request); $results = $serverStream->readAll(); try { iterator_to_array($results); @@ -217,7 +240,12 @@ public function mutateRowTest() $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); $rowKey = '122'; $mutations = []; - $response = $gapicClient->mutateRow($formattedTableName, $rowKey, $mutations); + $request = new MutateRowRequest([ + 'row_key' => $rowKey, + 'mutations' => $mutations, + 'table_name' => $formattedTableName + ]); + $response = $gapicClient->mutateRow($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -255,8 +283,13 @@ public function mutateRowExceptionTest() $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); $rowKey = '122'; $mutations = []; + $request = new MutateRowRequest([ + 'row_key' => $rowKey, + 'mutations' => $mutations, + 'table_name' => $formattedTableName + ]); try { - $gapicClient->mutateRow($formattedTableName, $rowKey, $mutations); + $gapicClient->mutateRow($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -286,7 +319,11 @@ public function mutateRowsTest() // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); $entries = []; - $serverStream = $gapicClient->mutateRows($formattedTableName, $entries); + $request = new MutateRowsRequest([ + 'entries' => $entries, + 'table_name' => $formattedTableName + ]); + $serverStream = $gapicClient->mutateRows($request); $this->assertInstanceOf(ServerStream::class, $serverStream); $responses = iterator_to_array($serverStream->readAll()); $expectedResponses = []; @@ -327,7 +364,11 @@ public function mutateRowsExceptionTest() // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); $entries = []; - $serverStream = $gapicClient->mutateRows($formattedTableName, $entries); + $request = new MutateRowsRequest([ + 'entries' => $entries, + 'table_name' => $formattedTableName + ]); + $serverStream = $gapicClient->mutateRows($request); $results = $serverStream->readAll(); try { iterator_to_array($results); @@ -355,7 +396,10 @@ public function pingAndWarmTest() $transport->addResponse($expectedResponse); // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $response = $gapicClient->pingAndWarm($formattedName); + $request = new PingAndWarmRequest([ + 'name' => $formattedName + ]); + $response = $gapicClient->pingAndWarm($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -388,7 +432,10 @@ public function pingAndWarmExceptionTest() // Mock request $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); try { - $gapicClient->pingAndWarm($formattedName); + $request = new PingAndWarmRequest([ + 'name' => $formattedName + ]); + $gapicClient->pingAndWarm($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -417,7 +464,10 @@ public function readChangeStreamTest() $transport->addResponse($expectedResponse3); // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $serverStream = $gapicClient->readChangeStream($formattedTableName); + $request = new ReadChangeStreamRequest([ + 'table_name' => $formattedTableName + ]); + $serverStream = $gapicClient->readChangeStream($request); $this->assertInstanceOf(ServerStream::class, $serverStream); $responses = iterator_to_array($serverStream->readAll()); $expectedResponses = []; @@ -455,7 +505,10 @@ public function readChangeStreamExceptionTest() $this->assertTrue($transport->isExhausted()); // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $serverStream = $gapicClient->readChangeStream($formattedTableName); + $request = new ReadChangeStreamRequest([ + 'table_name' => $formattedTableName + ]); + $serverStream = $gapicClient->readChangeStream($request); $results = $serverStream->readAll(); try { iterator_to_array($results); @@ -485,7 +538,12 @@ public function readModifyWriteRowTest() $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); $rowKey = '122'; $rules = []; - $response = $gapicClient->readModifyWriteRow($formattedTableName, $rowKey, $rules); + $request = new ReadModifyWriteRowRequest([ + 'table_name' => $formattedTableName, + 'row_key' => $rowKey, + 'rules' => $rules + ]); + $response = $gapicClient->readModifyWriteRow($request); $this->assertEquals($expectedResponse, $response); $actualRequests = $transport->popReceivedCalls(); $this->assertSame(1, count($actualRequests)); @@ -524,7 +582,12 @@ public function readModifyWriteRowExceptionTest() $rowKey = '122'; $rules = []; try { - $gapicClient->readModifyWriteRow($formattedTableName, $rowKey, $rules); + $request = new ReadModifyWriteRowRequest([ + 'table_name' => $formattedTableName, + 'row_key' => $rowKey, + 'rules' => $rules + ]); + $gapicClient->readModifyWriteRow($request); // If the $gapicClient method call did not throw, fail the test $this->fail('Expected an ApiException, but no exception was thrown.'); } catch (ApiException $ex) { @@ -559,7 +622,10 @@ public function readRowsTest() $transport->addResponse($expectedResponse3); // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $serverStream = $gapicClient->readRows($formattedTableName); + $request = new ReadRowsRequest([ + 'table_name' => $formattedTableName + ]); + $serverStream = $gapicClient->readRows($request); $this->assertInstanceOf(ServerStream::class, $serverStream); $responses = iterator_to_array($serverStream->readAll()); $expectedResponses = []; @@ -597,7 +663,10 @@ public function readRowsExceptionTest() $this->assertTrue($transport->isExhausted()); // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $serverStream = $gapicClient->readRows($formattedTableName); + $request = new ReadRowsRequest([ + 'table_name' => $formattedTableName + ]); + $serverStream = $gapicClient->readRows($request); $results = $serverStream->readAll(); try { iterator_to_array($results); @@ -641,7 +710,10 @@ public function sampleRowKeysTest() $transport->addResponse($expectedResponse3); // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $serverStream = $gapicClient->sampleRowKeys($formattedTableName); + $request = new SampleRowKeysRequest([ + 'table_name' => $formattedTableName + ]); + $serverStream = $gapicClient->sampleRowKeys($request); $this->assertInstanceOf(ServerStream::class, $serverStream); $responses = iterator_to_array($serverStream->readAll()); $expectedResponses = []; @@ -679,7 +751,10 @@ public function sampleRowKeysExceptionTest() $this->assertTrue($transport->isExhausted()); // Mock request $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $serverStream = $gapicClient->sampleRowKeys($formattedTableName); + $request = new SampleRowKeysRequest([ + 'table_name' => $formattedTableName + ]); + $serverStream = $gapicClient->sampleRowKeys($request); $results = $serverStream->readAll(); try { iterator_to_array($results); From 9d2616239ccead4387d4571fa3daf4cff1d0f214 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Thu, 16 May 2024 15:45:03 +0530 Subject: [PATCH 05/36] Modified TableTest --- Bigtable/tests/Unit/TableTest.php | 353 +++++++++++++++++------------- 1 file changed, 196 insertions(+), 157 deletions(-) diff --git a/Bigtable/tests/Unit/TableTest.php b/Bigtable/tests/Unit/TableTest.php index 600b9af015a..02728456170 100644 --- a/Bigtable/tests/Unit/TableTest.php +++ b/Bigtable/tests/Unit/TableTest.php @@ -18,6 +18,7 @@ namespace Google\Cloud\Bigtable\Tests\Unit; use Google\ApiCore\ApiException; +use Google\ApiCore\Serializer; use Google\ApiCore\ServerStream; use Google\Cloud\Bigtable\ChunkFormatter; use Google\Cloud\Bigtable\Exception\BigtableDataOperationException; @@ -27,17 +28,23 @@ use Google\Cloud\Bigtable\Table; use Google\Cloud\Bigtable\V2\BigtableClient as TableClient; use Google\Cloud\Bigtable\V2\Cell; +use Google\Cloud\Bigtable\V2\CheckAndMutateRowRequest; use Google\Cloud\Bigtable\V2\CheckAndMutateRowResponse; use Google\Cloud\Bigtable\V2\Column; use Google\Cloud\Bigtable\V2\Family; +use Google\Cloud\Bigtable\V2\MutateRowRequest; use Google\Cloud\Bigtable\V2\MutateRowResponse; +use Google\Cloud\Bigtable\V2\MutateRowsRequest; use Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry as RequestEntry; use Google\Cloud\Bigtable\V2\MutateRowsResponse; use Google\Cloud\Bigtable\V2\MutateRowsResponse\Entry as ResponseEntry; +use Google\Cloud\Bigtable\V2\ReadModifyWriteRowRequest; use Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse; +use Google\Cloud\Bigtable\V2\ReadRowsRequest; use Google\Cloud\Bigtable\V2\Row; use Google\Cloud\Bigtable\V2\RowRange; use Google\Cloud\Bigtable\V2\RowSet; +use Google\Cloud\Bigtable\V2\SampleRowKeysRequest; use Google\Cloud\Bigtable\V2\SampleRowKeysResponse; use Google\Rpc\Code; use InvalidArgumentException; @@ -77,6 +84,7 @@ public function setUp(): void ]; $this->table = new Table( $this->bigtableClient->reveal(), + new Serializer(), self::TABLE_NAME, $this->options ); @@ -117,11 +125,13 @@ public function testMutateRows() ->willReturn( $this->arrayAsGenerator($mutateRowsResponses) ); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $this->entries, $this->options) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $this->table->mutateRows($this->rowMutations); } @@ -133,13 +143,18 @@ public function testMutateRowsOptionalConfiguration() $this->arrayAsGenerator([]) ); $options = [ - 'key1' => 'value1' + 'transportOptions' => [ + 'key1' => 'value1' + ] ]; - $this->bigtableClient->mutateRows(self::TABLE_NAME, $this->entries, $this->options + $options) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); + $this->table->mutateRows($this->rowMutations, $options); } @@ -160,11 +175,14 @@ public function testMutateRowsFailure() ->willReturn( $this->arrayAsGenerator($mutateRowsResponses) ); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $this->entries, $this->options) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + ) + ->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); try { $this->table->mutateRows($this->rowMutations); $this->fail('Expected exception is not thrown'); @@ -191,11 +209,14 @@ public function testMutateRowsApiExceptionInMutateRows() $this->expectExceptionMessage('unauthenticated'); $apiException = new ApiException('unauthenticated', Code::UNAUTHENTICATED, 'unauthenticated'); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $this->entries, $this->options) - ->shouldBeCalled() - ->willThrow( - $apiException - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + ) + ->shouldBeCalled() + ->willThrow( + $apiException + ); $this->table->mutateRows($this->rowMutations); } @@ -220,9 +241,11 @@ public function testMutateRowsApiExceptionThrowsErrorInfo() ], ] ); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $this->entries, $this->options) - ->shouldBeCalled() - ->willThrow($apiException); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willThrow($apiException); try { $this->table->mutateRows($this->rowMutations); $this->fail('Expected an Exception, but no exception was thrown.'); @@ -252,11 +275,13 @@ public function testMutateRowsApiExceptionInReadAll() ->willThrow( $apiException ); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $this->entries, $this->options) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $this->table->mutateRows($this->rowMutations); } @@ -274,11 +299,13 @@ public function testUpsert() ->willReturn( $this->arrayAsGenerator($mutateRowsResponses) ); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $this->entries, $this->options) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $rows = [ 'rk1' => [ 'cf1' => [ @@ -308,13 +335,17 @@ public function testUpsertOptionalConfiguration() $this->arrayAsGenerator([]) ); $options = [ - 'key1' => 'value1' + 'transportOptions' => [ + 'key1' => 'value1' + ] ]; - $this->bigtableClient->mutateRows(self::TABLE_NAME, $this->entries, $this->options + $options) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $rows = [ 'rk1' => [ 'cf1' => [ @@ -340,11 +371,13 @@ public function testMutateRow() { $mutations = (new Mutations) ->upsert('cf1', 'cq1', 'value1'); - $this->bigtableClient->mutateRow(self::TABLE_NAME, 'r1', $mutations->toProto(), $this->options) - ->shouldBeCalled() - ->willReturn( - new MutateRowResponse - ); + $this->bigtableClient->mutateRow( + Argument::type(MutateRowRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + new MutateRowResponse + ); $this->table->mutateRow('r1', $mutations); } @@ -356,11 +389,13 @@ public function testReadRowsNoArg() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, $expectedArgs) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = []; $iterator = $this->table->readRows($args); $this->assertInstanceOf(ChunkFormatter::class, $iterator); @@ -379,13 +414,13 @@ public function testReadRow() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($expectedArgs) { - return $argument['rows']->serializeToJsonString() === $expectedArgs['rows']->serializeToJsonString(); - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $row = $this->table->readRow('rk1'); $this->assertNull($row); } @@ -404,14 +439,13 @@ public function testReadRowWithFilter() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($expectedArgs) { - return $argument['rows']->serializeToJsonString() === $expectedArgs['rows']->serializeToJsonString() - && $argument['filter']->serializeToJsonString() === $expectedArgs['filter']->serializeToJsonString(); - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = [ 'filter' => $rowFilter ]; @@ -431,13 +465,13 @@ public function testReadRowsWithMultipleRowKeys() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($expectedArgs) { - return $argument['rows']->serializeToJsonString() === $expectedArgs['rows']->serializeToJsonString(); - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = [ 'rowKeys' => ['rk1', 'rk2'] ]; @@ -459,14 +493,13 @@ public function testReadRowsWithRowLimit() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($expectedArgs) { - return $argument['rows']->serializeToJsonString() === $expectedArgs['rows']->serializeToJsonString() - && $argument['rowsLimit'] === $expectedArgs['rowsLimit']; - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = [ 'rowKeys' => ['rk1', 'rk2'], 'rowsLimit' => 10 @@ -491,13 +524,13 @@ public function testReadRowsWithRowRangeKeysOpen() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($expectedArgs) { - return $argument['rows']->serializeToJsonString() === $expectedArgs['rows']->serializeToJsonString(); - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = [ 'rowRanges' =>[ [ @@ -526,13 +559,13 @@ public function testReadRowsWithRowRangeKeysClosed() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($expectedArgs) { - return $argument['rows']->serializeToJsonString() === $expectedArgs['rows']->serializeToJsonString(); - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = [ 'rowRanges' =>[ [ @@ -561,13 +594,13 @@ public function testReadRowsWithRowRangeKeysOpenClosed() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($expectedArgs) { - return $argument['rows']->serializeToJsonString() === $expectedArgs['rows']->serializeToJsonString(); - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = [ 'rowRanges' =>[ [ @@ -596,13 +629,13 @@ public function testReadRowsWithRowRangeKeysClosedOpen() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($expectedArgs) { - return $argument['rows']->serializeToJsonString() === $expectedArgs['rows']->serializeToJsonString(); - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = [ 'rowRanges' =>[ [ @@ -636,13 +669,13 @@ public function testReadRowsWithRowRangeKeysMultipleRowRanges() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($expectedArgs) { - return $argument['rows']->serializeToJsonString() === $expectedArgs['rows']->serializeToJsonString(); - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = [ 'rowRanges' =>[ [ @@ -676,11 +709,13 @@ public function testReadRowsWithKeyAndRanges() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, $expectedArgs) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = [ 'rowKeys' => ['rk1'], 'rowRanges' => [ @@ -706,11 +741,13 @@ public function testReadRowsWithFilter() ->willReturn( $this->arrayAsGenerator([]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, $expectedArgs) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = [ 'filter' => $rowFilter ]; @@ -742,12 +779,9 @@ public function testReadModifyWriteRowAppend() ->append('cf1', 'cq1', 'v1'); $this->bigtableClient ->readModifyWriteRow( - self::TABLE_NAME, - 'rk1', - $readModifyWriteRowRules->toProto(), - $this->options - ) - ->shouldBeCalled() + Argument::type(ReadModifyWriteRowRequest::class), + Argument::type('array') + )->shouldBeCalled() ->willReturn( $readModifyWriteRowResponse ); @@ -790,12 +824,9 @@ public function testReadModifyWriteRowIncrement() ->increment('cf1', 'cq1', 5); $this->bigtableClient ->readModifyWriteRow( - self::TABLE_NAME, - 'rk1', - $readModifyWriteRowRules->toProto(), - $this->options - ) - ->shouldBeCalled() + Argument::type(ReadModifyWriteRowRequest::class), + Argument::type('array') + )->shouldBeCalled() ->willReturn( $readModifyWriteRowResponse ); @@ -826,11 +857,13 @@ public function testSampleRowKeys() ->willReturn( $this->arrayAsGenerator($sampleRowKeyResponses) ); - $this->bigtableClient->sampleRowKeys(self::TABLE_NAME, $this->options) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->sampleRowKeys( + Argument::type(SampleRowKeysRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $rowKeyStream = $this->table->sampleRowKeys(); $rowKeys = iterator_to_array($rowKeyStream); $expectedRowKeys = [ @@ -885,11 +918,13 @@ public function testCheckAndMutateRowWithTrueMutations() 'trueMutations' => $mutations->toProto() ]; $rowKey = 'rk1'; - $this->bigtableClient->checkAndMutateRow(self::TABLE_NAME, $rowKey, $expectedArgs) - ->shouldBeCalled() - ->willReturn( - (new CheckAndMutateRowResponse)->setPredicateMatched(true) - ); + $this->bigtableClient->checkAndMutateRow( + Argument::type(CheckAndMutateRowRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + (new CheckAndMutateRowResponse)->setPredicateMatched(true) + ); $result = $this->table->checkAndMutateRow($rowKey, ['trueMutations' => $mutations]); $this->assertTrue($result); } @@ -901,11 +936,13 @@ public function testCheckAndMutateRowWithFalseMutations() 'falseMutations' => $mutations->toProto() ]; $rowKey = 'rk1'; - $this->bigtableClient->checkAndMutateRow(self::TABLE_NAME, $rowKey, $expectedArgs) - ->shouldBeCalled() - ->willReturn( - (new CheckAndMutateRowResponse)->setPredicateMatched(false) - ); + $this->bigtableClient->checkAndMutateRow( + Argument::type(CheckAndMutateRowRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + (new CheckAndMutateRowResponse)->setPredicateMatched(false) + ); $result = $this->table->checkAndMutateRow($rowKey, ['falseMutations' => $mutations]); $this->assertFalse($result); } @@ -919,11 +956,13 @@ public function testCheckAndMutateRowWithPredicateFilter() 'trueMutations' => $mutations->toProto() ]; $rowKey = 'rk1'; - $this->bigtableClient->checkAndMutateRow(self::TABLE_NAME, $rowKey, $expectedArgs) - ->shouldBeCalled() - ->willReturn( - (new CheckAndMutateRowResponse)->setPredicateMatched(false) - ); + $this->bigtableClient->checkAndMutateRow( + Argument::type(CheckAndMutateRowRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + (new CheckAndMutateRowResponse)->setPredicateMatched(false) + ); $result = $this->table->checkAndMutateRow( $rowKey, [ From 590d1a6fff9243e8bc6d2c3a873692ec409ae2b5 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Thu, 16 May 2024 18:05:54 +0530 Subject: [PATCH 06/36] Modified SmartRetriesTest --- Bigtable/tests/Unit/SmartRetriesTest.php | 404 +++++++++++++---------- 1 file changed, 237 insertions(+), 167 deletions(-) diff --git a/Bigtable/tests/Unit/SmartRetriesTest.php b/Bigtable/tests/Unit/SmartRetriesTest.php index 34e0c61cf67..9d4f2924f21 100644 --- a/Bigtable/tests/Unit/SmartRetriesTest.php +++ b/Bigtable/tests/Unit/SmartRetriesTest.php @@ -18,14 +18,17 @@ namespace Google\Cloud\Bigtable\Tests\Unit; use Google\ApiCore\ApiException; +use Google\ApiCore\Serializer; use Google\ApiCore\ServerStream; use Google\Cloud\Bigtable\Exception\BigtableDataOperationException; use Google\Cloud\Bigtable\Mutations; use Google\Cloud\Bigtable\Table; use Google\Cloud\Bigtable\V2\BigtableClient as TableClient; +use Google\Cloud\Bigtable\V2\MutateRowsRequest; use Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry as RequestEntry; use Google\Cloud\Bigtable\V2\MutateRowsResponse; use Google\Cloud\Bigtable\V2\MutateRowsResponse\Entry as ResponseEntry; +use Google\Cloud\Bigtable\V2\ReadRowsRequest; use Google\Cloud\Bigtable\V2\RowRange; use Google\Cloud\Bigtable\V2\RowSet; use Google\Cloud\Bigtable\V2\ReadRowsResponse; @@ -80,6 +83,7 @@ public function setUp(): void ]; $this->table = new Table( $this->bigtableClient->reveal(), + new Serializer(), self::TABLE_NAME, $this->options ); @@ -96,11 +100,13 @@ public function testReadRowsShouldRetryDefaultTimes() ->willThrow( $this->retryingApiException ); - $this->bigtableClient->readRows(self::TABLE_NAME, $expectedArgs) - ->shouldBeCalledTimes(4) - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalledTimes(4) + ->willReturn( + $this->serverStream->reveal() + ); $args = []; $iterator = $this->table->readRows($args); $iterator->getIterator()->current(); @@ -117,8 +123,10 @@ public function testReadRowsShouldRetryForProvidedAttempts() ->willThrow( $this->retryingApiException ); - $this->bigtableClient->readRows(self::TABLE_NAME, $expectedArgs) - ->shouldBeCalledTimes(6) + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalledTimes(6) ->willReturn( $this->serverStream->reveal() ); @@ -142,19 +150,12 @@ public function testReadRowsPartialSuccess() $this->nonRetryingApiException ) ); - $this->bigtableClient->readRows(self::TABLE_NAME, $expectedArgs) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); - $secondCallArgument = [ - 'rows' => (new RowSet)->setRowRanges([(new RowRange)->setStartKeyOpen('rk2')]) - ] + $expectedArgs; - $this->bigtableClient->readRows(self::TABLE_NAME, $secondCallArgument) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->willReturn( + $this->serverStream->reveal() + ); $args = []; $iterator = $this->table->readRows($args); $rows = []; @@ -184,20 +185,26 @@ public function testReadRowsWithRowsLimit() $this->generateRowsResponse(3, 4) ) ); - $this->bigtableClient->readRows(self::TABLE_NAME, $expectedArgs) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); - $secondCallArgument = [ - 'rows' => (new RowSet)->setRowRanges([(new RowRange)->setStartKeyOpen('rk2')]), - 'rowsLimit' => 3 - ] + $expectedArgs; - $this->bigtableClient->readRows(self::TABLE_NAME, $secondCallArgument) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); + + $allowedRowsLimit = ['5' => 1, '3' => 1]; + $this->bigtableClient->readRows( + Argument::that(function($request) use(&$allowedRowsLimit) { + $rowsLimit = $request->getRowsLimit(); + if (!isset($allowedRowsLimit[$rowsLimit]) || $allowedRowsLimit[$rowsLimit] == 0) { + return false; + } + + // This means that once we have encountered a `rowsLimit` in a request. + // We decrease the number of times the request is allowed with the particular rowsLimit. + $allowedRowsLimit[$rowsLimit] -= 1; + return true; + }), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); + $iterator = $this->table->readRows($args); $rows = []; foreach ($iterator as $rowKey => $row) { @@ -221,20 +228,26 @@ public function testReadRowsWithRowKeys() $this->generateRowsResponse(3, 4) ) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) { - return iterator_to_array($argument['rows']->getRowKeys()) === ['rk1', 'rk2', 'rk3', 'rk4']; - })) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) { - return iterator_to_array($argument['rows']->getRowKeys()) === ['rk3', 'rk4']; - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + + $this->bigtableClient->readRows( + Argument::that(function($request) { + return iterator_to_array($request->getRows()->getRowKeys()) === ['rk1', 'rk2', 'rk3', 'rk4']; + }), + Argument::type('array') + )->shouldBeCalledTimes(1) + ->willReturn( + $this->serverStream->reveal() + ); + + $this->bigtableClient->readRows( + Argument::that(function($request) { + return iterator_to_array($request->getRows()->getRowKeys()) === ['rk3', 'rk4']; + }), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $iterator = $this->table->readRows($args); $rows = []; foreach ($iterator as $rowKey => $row) { @@ -257,17 +270,23 @@ public function testReadRowsRangeStartKeyOpen() $this->generateRowsResponse(8, 9) ) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) { - return $argument['rows']->getRowRanges()[0]->getStartKeyOpen() === 'rk5'; - })) - ->shouldBeCalledTimes(1) + + $this->bigtableClient->readRows( + Argument::that(function($request) { + return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === 'rk5'; + }), + Argument::type('array') + )->shouldBeCalledTimes(1) ->willReturn( $this->serverStream->reveal() ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) { - return $argument['rows']->getRowRanges()[0]->getStartKeyOpen() === 'rk7'; - })) - ->shouldBeCalled() + + $this->bigtableClient->readRows( + Argument::that(function($request) { + return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === 'rk7'; + }), + Argument::type('array') + )->shouldBeCalled() ->willReturn( $this->serverStream->reveal() ); @@ -296,20 +315,26 @@ public function testReadRowsRangeStartKeyClosed() $this->generateRowsResponse(7, 9) ) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) { - return $argument['rows']->getRowRanges()[0]->getStartKeyClosed() === 'rk5'; - })) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) { - return $argument['rows']->getRowRanges()[0]->getStartKeyOpen() === 'rk6'; - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + + $this->bigtableClient->readRows( + Argument::that(function($request) { + return $request->getRows()->getRowRanges()[0]->getStartKeyClosed() === 'rk5'; + }), + Argument::type('array') + )->shouldBeCalledTimes(1) + ->willReturn( + $this->serverStream->reveal() + ); + + $this->bigtableClient->readRows( + Argument::that(function($request) { + return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === 'rk6'; + }), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $args = ['rowRanges' => [ ['startKeyClosed' => 'rk5'] ]]; @@ -335,22 +360,29 @@ public function testReadRowsRangeEndKeyOpen() $this->generateRowsResponse(4, 6) ) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) { - return $argument['rows']->getRowRanges()[0]->getStartKeyOpen() === '' - && $argument['rows']->getRowRanges()[0]->getEndKeyOpen() === 'rk7'; - })) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) { - return $argument['rows']->getRowRanges()[0]->getStartKeyOpen() === 'rk3' - && $argument['rows']->getRowRanges()[0]->getEndKeyOpen() === 'rk7'; - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + + $this->bigtableClient->readRows( + Argument::that(function($request) { + return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === '' && + $request->getRows()->getRowRanges()[0]->getEndKeyOpen() === 'rk7'; + }), + Argument::type('array') + )->shouldBeCalledTimes(1) + ->willReturn( + $this->serverStream->reveal() + ); + + $this->bigtableClient->readRows( + Argument::that(function($request) { + return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === 'rk3' && + $request->getRows()->getRowRanges()[0]->getEndKeyOpen() === 'rk7'; + }), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); + $args = ['rowRanges' => [ ['endKeyOpen' => 'rk7'] ]]; @@ -376,22 +408,29 @@ public function testReadRowsRangeEndKeyClosed() $this->generateRowsResponse(4, 7) ) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) { - return $argument['rows']->getRowRanges()[0]->getStartKeyOpen() === '' - && $argument['rows']->getRowRanges()[0]->getEndKeyClosed() === 'rk7'; - })) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) { - return $argument['rows']->getRowRanges()[0]->getStartKeyOpen() === 'rk3' - && $argument['rows']->getRowRanges()[0]->getEndKeyClosed() === 'rk7'; - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + + $this->bigtableClient->readRows( + Argument::that(function($request) { + return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === '' && + $request->getRows()->getRowRanges()[0]->getEndKeyClosed() === 'rk7'; + }), + Argument::type('array') + )->shouldBeCalledTimes(1) + ->willReturn( + $this->serverStream->reveal() + ); + + $this->bigtableClient->readRows( + Argument::that(function($request) { + return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === 'rk3' && + $request->getRows()->getRowRanges()[0]->getEndKeyClosed() === 'rk7'; + }), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); + $args = ['rowRanges' => [ ['endKeyClosed' => 'rk7'] ]]; @@ -422,24 +461,32 @@ public function testReadRowsRangeWithSomeCompletedRange() $this->generateRowsResponse(7, 9) ) ); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($expectedRows) { - return $argument['rows']->serializeToJsonString() === $expectedRows->serializeToJsonString(); - })) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); + + $this->bigtableClient->readRows( + Argument::that(function($request) use($expectedRows) { + return $request->getRows()->serializeToJsonString() === $expectedRows->serializeToJsonString(); + }), + Argument::type('array') + )->shouldBeCalledTimes(1) + ->willReturn( + $this->serverStream->reveal() + ); + $expectedRows2 = (new RowSet)->setRowRanges([ (new RowRange)->setStartKeyOpen('rk6')->setEndKeyClosed('rk7'), (new RowRange)->setStartKeyClosed('rk8')->setEndKeyClosed('rk9') ]); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($expectedRows2) { - return $argument['rows']->serializeToJsonString() === $expectedRows2->serializeToJsonString(); - })) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + + $this->bigtableClient->readRows( + Argument::that(function($request) use($expectedRows2) { + return $request->getRows()->serializeToJsonString() === $expectedRows2->serializeToJsonString(); + }), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); + $args = ['rowRanges' => [ ['startKeyOpen' => 'rk1', 'endKeyClosed' => 'rk3'], ['startKeyClosed' => 'rk5', 'endKeyClosed' => 'rk7'], @@ -467,17 +514,18 @@ public function testReadRowsWithRetryableErrorAfterAllDataReceived() // First Call // Check if the request has expected row range $this->bigtableClient->readRows( - self::TABLE_NAME, - Argument::that(function ($argument) { - $rowRanges = $argument['rows']->getRowRanges(); + Argument::that(function($request) { + $rowRanges = $request->getRows()->getRowRanges(); if (count($rowRanges) === 0) { return false; } $rowRange = $rowRanges[0]; return $rowRange->getStartKeyClosed() === 'rk1' && $rowRange->getEndKeyClosed() === 'rk3'; - }) - )->shouldBeCalledOnce()->willReturn( + }), + Argument::type('array') + )->shouldBeCalledTimes(1) + ->willReturn( $this->serverStream->reveal() ); @@ -485,17 +533,15 @@ public function testReadRowsWithRetryableErrorAfterAllDataReceived() // Check if the request has empty row range and fail the test // as this will result in full table scan $this->bigtableClient->readRows( - self::TABLE_NAME, - Argument::that(function ($argument) { - $rowRanges = $argument['rows']->getRowRanges(); - if (count($rowRanges)) { - return false; - } - return true; - }) - )->will(function ($args) { - self::fail('Full table scan attempted'); - }); + Argument::that(function($request) { + $rowRanges = $request->getRows()->getRowRanges(); + return !count($rowRanges); + }), + Argument::type('array') + )->shouldBeCalledTimes(1) + ->willReturn( + $this->serverStream->reveal() + ); $args = [ 'rowRanges' => [[ @@ -519,11 +565,13 @@ public function testMutateRowsShouldRetryDefaultNumberOfTimes() ); $mutations = $this->generateMutations(1, 5); $entries = $this->generateEntries(1, 5); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $entries, $this->options) - ->shouldBeCalledTimes(4) - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + )->shouldBeCalledTimes(4) + ->willReturn( + $this->serverStream->reveal() + ); $this->table->mutateRows($mutations); } @@ -539,11 +587,13 @@ public function testMutateRowsRespectRetriesAttempt() ); $mutations = $this->generateMutations(1, 5); $entries = $this->generateEntries(1, 5); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $entries, ['retries' => 5] + $this->options) - ->shouldBeCalledTimes(6) - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::withEntry('retries', 5) + )->shouldBeCalledTimes(6) + ->willReturn( + $this->serverStream->reveal() + ); $this->table->mutateRows($mutations, ['retries' => 5]); } @@ -560,17 +610,25 @@ public function testMutateRowsOnlyRetriesFailedEntries() ) ); $entries = $this->generateEntries(0, 5); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $entries, $this->options) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::that(function($request) use($entries) { + return iterator_to_array($request->getEntries()) == $entries; + }), + Argument::type('array') + )->shouldBeCalledTimes(1) + ->willReturn( + $this->serverStream->reveal() + ); $entries = $this->generateEntries(2, 3); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $entries, $this->options) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::that(function($request) use($entries) { + return iterator_to_array($request->getEntries()) == $entries; + }), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $mutations = $this->generateMutations(0, 5); $this->table->mutateRows($mutations); } @@ -589,17 +647,25 @@ public function testMutateRowsExceptionShouldAddEntryToPendingMutations() ) ); $entries = $this->generateEntries(0, 5); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $entries, $this->options) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::that(function($request) use($entries) { + return iterator_to_array($request->getEntries()) == $entries; + }), + Argument::type('array') + )->shouldBeCalledTimes(1) + ->willReturn( + $this->serverStream->reveal() + ); $entries = array_merge($this->generateEntries(1, 2), $this->generateEntries(4, 5)); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $entries, $this->options) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::that(function($request) use($entries) { + return iterator_to_array($request->getEntries()) == $entries; + }), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); try { $mutations = $this->generateMutations(0, 5); $this->table->mutateRows($mutations); @@ -630,11 +696,15 @@ public function testMutateRowsShouldNotRetryIfAnyMutationIsNotRetryable() ) ); $entries = $this->generateEntries(0, 7); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $entries, $this->options) - ->shouldBeCalledTimes(1) - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::that(function($request) use($entries) { + return iterator_to_array($request->getEntries()) == $entries; + }), + Argument::type('array') + )->shouldBeCalledTimes(1) + ->willReturn( + $this->serverStream->reveal() + ); try { $mutations = $this->generateMutations(0, 7); $this->table->mutateRows($mutations); From 20093150e30c8239d5b45120e28b815e87c1cfa0 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Thu, 16 May 2024 18:16:29 +0530 Subject: [PATCH 07/36] Modified Table resource class --- Bigtable/src/Table.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Bigtable/src/Table.php b/Bigtable/src/Table.php index ffffa676b00..d76376aabc6 100644 --- a/Bigtable/src/Table.php +++ b/Bigtable/src/Table.php @@ -280,7 +280,7 @@ public function readRows(array $options = []) $rowKeys = $this->pluck('rowKeys', $options, false) ?: []; $ranges = $this->pluck('rowRanges', $options, false) ?: []; $filter = $this->pluck('filter', $options, false) ?: null; - list($data, $optionalArgs) = $this->splitOptionalArgs($options); + list($data, $optionalArgs) = $this->splitOptionalArgs($options, ['retries']); // TODO: check if we can use the mergeFromJsonString function here. array_walk($ranges, function (&$range) { @@ -321,8 +321,8 @@ public function readRows(array $options = []) $data['filter'] = $filter->toProto(); } - $data += ['table_name' => $this->tableName]; - $request = new ReadRowsRequest($data); + $data['table_name'] = $this->tableName; + $request = $this->serializer->decodeMessage(new ReadRowsRequest(), $data); return new ChunkFormatter( $this->gapicClient, @@ -403,7 +403,7 @@ public function readModifyWriteRow($rowKey, ReadModifyWriteRowRules $rules, arra $data['row_key'] = $rowKey; $data['rules'] = $rules->toProto(); - $request = new ReadModifyWriteRowRequest($data); + $request = $this->serializer->decodeMessage(new ReadModifyWriteRowRequest(), $data); $readModifyWriteRowResponse = $this->gapicClient->readModifyWriteRow( $request, $optionalArgs + $this->options @@ -435,7 +435,7 @@ public function sampleRowKeys(array $options = []) list($data, $optionalArgs) = $this->splitOptionalArgs($options); $data['table_name'] = $this->tableName; - $request = new SampleRowKeysRequest($data); + $request = $this->serializer->decodeMessage(new SampleRowKeysRequest(), $data); $stream = $this->gapicClient->sampleRowKeys( $request, $optionalArgs + $this->options @@ -555,9 +555,9 @@ private function mutateRowsWithEntries(array $entries, array $options = []) return false; }; - list($data, $optionalArgs) = $this->splitOptionalArgs($options); + list($data, $optionalArgs) = $this->splitOptionalArgs($options, ['retries']); - $request = new MutateRowsRequest($data); + $request = $this->serializer->decodeMessage(new MutateRowsRequest(), $data); $request->setTableName($this->tableName); $retryingStream = new ResumableStream( @@ -633,8 +633,7 @@ private function appendPendingEntryToFailedMutations( end($entries); foreach (range($lastProcessedIndex + 1, key($entries)) as $index) { $rowMutationsFailedResponse[] = [ - // TODO: check this - // 'rowKey' => $entries[$index]->getRowKey(), + 'rowKey' => $entries[$index]->getRowKey(), 'statusCode' => $statusCode, 'message' => $message ]; From 82254eeb4b008ee24a8e0f731c222925000e2dd8 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Thu, 16 May 2024 18:18:04 +0530 Subject: [PATCH 08/36] Disable GAX retries in ResumableStream --- Bigtable/src/ResumableStream.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Bigtable/src/ResumableStream.php b/Bigtable/src/ResumableStream.php index 067bbe49111..10ab81dfd3e 100644 --- a/Bigtable/src/ResumableStream.php +++ b/Bigtable/src/ResumableStream.php @@ -104,7 +104,14 @@ public function __construct( $this->retries = $retries ?: self::DEFAULT_MAX_RETRIES; $this->argumentFunction = $argumentFunction; $this->retryFunction = $retryFunction; - $this->optionalArgs = $optionalArgs; + // Disable GAX retries because we want to handle the retries here. + // Once GAX has the provision to modify request/args in between retries, + // we can re enable GAX's retries and use them completely. + $this->optionalArgs = $optionalArgs + [ + 'retrySettings' => [ + 'retriesEnabled' => false + ] + ]; } /** From a91e89526a7e30e108ee76f54d7dc06d211d803b Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Thu, 16 May 2024 18:19:55 +0530 Subject: [PATCH 09/36] Modified ChunkFormatter --- Bigtable/src/ChunkFormatter.php | 95 +++++++++++++++++++++++---------- 1 file changed, 66 insertions(+), 29 deletions(-) diff --git a/Bigtable/src/ChunkFormatter.php b/Bigtable/src/ChunkFormatter.php index 9a9fb1372f9..84251bdb2fc 100644 --- a/Bigtable/src/ChunkFormatter.php +++ b/Bigtable/src/ChunkFormatter.php @@ -17,11 +17,14 @@ namespace Google\Cloud\Bigtable; +use Google\ApiCore\ArrayTrait; use Google\Cloud\Bigtable\Exception\BigtableDataOperationException; +use Google\Cloud\Bigtable\V2\ReadRowsRequest; use Google\Cloud\Bigtable\V2\ReadRowsResponse\CellChunk; use Google\Cloud\Bigtable\V2\RowRange; use Google\Cloud\Bigtable\V2\RowSet; -use Google\Cloud\Core\ArrayTrait; +use Google\Protobuf\Internal\Message; +use Google\Cloud\Bigtable\V2\Client\BigtableClient as GapicClient; /** * Converts cell chunks into an easily digestable format. Please note this class @@ -50,6 +53,20 @@ class ChunkFormatter implements \IteratorAggregate 'CELL_IN_PROGRESS' => 3, ]; + // When we use ChunkFormatter, we know that we always + // need to readRows. + private const GAPIC_CLIENT_METHOD = 'readRows'; + + /** + * @var GapicClient + */ + private $gapicClient; + + /** + * @var Message + */ + private $request; + /** * @var string */ @@ -113,34 +130,48 @@ class ChunkFormatter implements \IteratorAggregate /** * Constructs the ChunkFormatter. * - * @param callable $readRowsCall A callable which executes a read rows call and returns a stream. - * @param string $tableName The table name used for the read rows call. + * @param GapicClient $gapicClient The GAPIC client to use in order to send requests. + * @param ReadRowsRequest $request The proto request to be passed to the Gapic client. * @param array $options [optional] Configuration options for read rows call. */ - public function __construct(callable $readRowsCall, $tableName, array $options = []) + public function __construct( + GapicClient $gapicClient, + ReadRowsRequest $request, + array $options = [] + ) { - $this->tableName = $tableName; + $this->gapicClient = $gapicClient; + $this->request = $request; $this->options = $options; - if (isset($options['rowsLimit'])) { - $this->originalRowsLimit = $options['rowsLimit']; + + if ($request->getRowsLimit()) { + $this->originalRowsLimit = $request->getRowsLimit(); } + + $argumentFunction = function ($request, $options) { + $prevRowKey = $this->prevRowKey; + $this->reset(); + if ($prevRowKey) { + list($request, $options) = $this->updateReadRowsRequest($request, $options, $prevRowKey); + } + return [$request, $options]; + }; + + $retryFunction = function ($ex) { + if ($ex && ResumableStream::isRetryable($ex->getCode())) { + return true; + } + return false; + }; + $this->stream = new ResumableStream( - $readRowsCall, - function () { - $prevRowKey = $this->prevRowKey; - $this->reset(); - if ($prevRowKey) { - $this->updateOptions($prevRowKey); - } - return [$this->tableName, $this->options]; - }, - function ($ex) { - if ($ex && ResumableStream::isRetryable($ex->getCode())) { - return true; - } - return false; - }, - $this->pluck('retries', $this->options, false) + $this->gapicClient, + self::GAPIC_CLIENT_METHOD, + $request, + $argumentFunction, + $retryFunction, + $this->pluck('retries', $options, false), + $options ); } @@ -192,13 +223,17 @@ public function readAll() $this->onStreamEnd(); } - private function updateOptions($prevRowKey) + /** + * Helper to modify the request and the options in b/w retries. + */ + private function updateReadRowsRequest($request, $options, $prevRowKey) { if ($this->originalRowsLimit) { - $this->options['rowsLimit'] = $this->originalRowsLimit - $this->numberOfRowsRead; + $request->setRowsLimit($this->originalRowsLimit - $this->numberOfRowsRead); } - if (isset($this->options['rows'])) { - $rowSet = $this->options['rows']; + + if ($request->hasRows()) { + $rowSet = $request->getRows(); if (count($rowSet->getRowKeys()) > 0) { $rowKeys = []; foreach ($rowSet->getRowKeys() as $rowKey) { @@ -229,12 +264,14 @@ private function updateOptions($prevRowKey) // after all data is received causing empty rows to be sent in next retry // request resulting in a full table scan. if (empty($rowKeys) && empty($ranges)) { - $this->options['requestCompleted'] = true; + $options['requestCompleted'] = true; } } else { $range = (new RowRange)->setStartKeyOpen($prevRowKey); - $this->options['rows'] = (new RowSet)->setRowRanges([$range]); + $options['rows'] = (new RowSet)->setRowRanges([$range]); } + + return [$request, $options]; } /** From bde2f7f90d65dbf860c339b25dc2e13a04bd6e23 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Thu, 16 May 2024 18:28:34 +0530 Subject: [PATCH 10/36] Removed Todos --- Bigtable/src/Table.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/Bigtable/src/Table.php b/Bigtable/src/Table.php index d76376aabc6..e609f9f0cb5 100644 --- a/Bigtable/src/Table.php +++ b/Bigtable/src/Table.php @@ -282,7 +282,6 @@ public function readRows(array $options = []) $filter = $this->pluck('filter', $options, false) ?: null; list($data, $optionalArgs) = $this->splitOptionalArgs($options, ['retries']); - // TODO: check if we can use the mergeFromJsonString function here. array_walk($ranges, function (&$range) { $range = $this->serializer->decodeMessage( new RowRange(), @@ -298,7 +297,6 @@ public function readRows(array $options = []) ); } - // TODO: check if we can use the mergeFromJsonString function here. if ($ranges || $rowKeys) { $data['rows'] = $this->serializer->decodeMessage( new RowSet, @@ -533,7 +531,6 @@ private function mutateRowsWithEntries(array $entries, array $options = []) $rowMutationsFailedResponse = []; $options = $options + $this->options; // This function is responsible to modify the $entries before every retry. - // TODO: Test failing $entries and see the effect. $argumentFunction = function ($request, $options) use (&$entries, &$rowMutationsFailedResponse) { if (count($rowMutationsFailedResponse) > 0) { $entries = array_values($entries); From 6eacc2581fe3dd59edd51dc860180216df6c69ba Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Fri, 17 May 2024 12:42:26 +0530 Subject: [PATCH 11/36] Bypassed 'final' keyword for final classes in unit tests --- Bigtable/composer.json | 3 ++- Bigtable/phpunit.xml.dist | 2 +- Bigtable/tests/Unit/SmartRetriesTest.php | 4 ++-- Bigtable/tests/Unit/TableTest.php | 4 ++-- Bigtable/tests/Unit/bootstrap.php | 10 ++++++++++ 5 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 Bigtable/tests/Unit/bootstrap.php diff --git a/Bigtable/composer.json b/Bigtable/composer.json index 4103987dc74..10f357195ef 100644 --- a/Bigtable/composer.json +++ b/Bigtable/composer.json @@ -13,7 +13,8 @@ "erusev/parsedown": "^1.6", "phpdocumentor/reflection": "^5.3.3", "phpdocumentor/reflection-docblock": "^5.3", - "phpspec/prophecy-phpunit": "^2.0" + "phpspec/prophecy-phpunit": "^2.0", + "dg/bypass-finals": "^1.7" }, "suggest": { "ext-protobuf": "Provides a significant increase in throughput over the pure PHP protobuf implementation. See https://cloud.google.com/php/grpc for installation instructions." diff --git a/Bigtable/phpunit.xml.dist b/Bigtable/phpunit.xml.dist index 06944c9f297..3df735a1096 100644 --- a/Bigtable/phpunit.xml.dist +++ b/Bigtable/phpunit.xml.dist @@ -1,5 +1,5 @@ - + src diff --git a/Bigtable/tests/Unit/SmartRetriesTest.php b/Bigtable/tests/Unit/SmartRetriesTest.php index 9d4f2924f21..87565b91a79 100644 --- a/Bigtable/tests/Unit/SmartRetriesTest.php +++ b/Bigtable/tests/Unit/SmartRetriesTest.php @@ -23,7 +23,7 @@ use Google\Cloud\Bigtable\Exception\BigtableDataOperationException; use Google\Cloud\Bigtable\Mutations; use Google\Cloud\Bigtable\Table; -use Google\Cloud\Bigtable\V2\BigtableClient as TableClient; +use Google\Cloud\Bigtable\V2\Client\BigtableClient; use Google\Cloud\Bigtable\V2\MutateRowsRequest; use Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry as RequestEntry; use Google\Cloud\Bigtable\V2\MutateRowsResponse; @@ -75,7 +75,7 @@ public function setUp(): void Code::UNAUTHENTICATED, 'UNAUTHENTICATED' ); - $this->bigtableClient = $this->prophesize(TableClient::class); + $this->bigtableClient = $this->prophesize(BigtableClient::class); $this->serverStream = $this->prophesize(ServerStream::class); $this->options = [ 'appProfileId' => self::APP_PROFILE, diff --git a/Bigtable/tests/Unit/TableTest.php b/Bigtable/tests/Unit/TableTest.php index 02728456170..a3417036585 100644 --- a/Bigtable/tests/Unit/TableTest.php +++ b/Bigtable/tests/Unit/TableTest.php @@ -26,7 +26,7 @@ use Google\Cloud\Bigtable\Mutations; use Google\Cloud\Bigtable\ReadModifyWriteRowRules; use Google\Cloud\Bigtable\Table; -use Google\Cloud\Bigtable\V2\BigtableClient as TableClient; +use Google\Cloud\Bigtable\V2\Client\BigtableClient; use Google\Cloud\Bigtable\V2\Cell; use Google\Cloud\Bigtable\V2\CheckAndMutateRowRequest; use Google\Cloud\Bigtable\V2\CheckAndMutateRowResponse; @@ -76,7 +76,7 @@ class TableTest extends TestCase public function setUp(): void { - $this->bigtableClient = $this->prophesize(TableClient::class); + $this->bigtableClient = $this->prophesize(BigtableClient::class); $this->serverStream = $this->prophesize(ServerStream::class); $this->options = [ 'appProfileId' => self::APP_PROFILE, diff --git a/Bigtable/tests/Unit/bootstrap.php b/Bigtable/tests/Unit/bootstrap.php new file mode 100644 index 00000000000..7f6d31fa9c7 --- /dev/null +++ b/Bigtable/tests/Unit/bootstrap.php @@ -0,0 +1,10 @@ + Date: Tue, 21 May 2024 13:01:32 +0530 Subject: [PATCH 12/36] Fix snippet tests --- Bigtable/phpunit-snippets.xml.dist | 2 +- Bigtable/tests/Snippet/ChunkFormatterTest.php | 18 ++- Bigtable/tests/Snippet/TableTest.php | 134 ++++++++++-------- Bigtable/tests/Snippet/bootstrap.php | 12 ++ 4 files changed, 102 insertions(+), 64 deletions(-) create mode 100644 Bigtable/tests/Snippet/bootstrap.php diff --git a/Bigtable/phpunit-snippets.xml.dist b/Bigtable/phpunit-snippets.xml.dist index 319673b50fe..85b08c90f19 100644 --- a/Bigtable/phpunit-snippets.xml.dist +++ b/Bigtable/phpunit-snippets.xml.dist @@ -1,5 +1,5 @@ - + src diff --git a/Bigtable/tests/Snippet/ChunkFormatterTest.php b/Bigtable/tests/Snippet/ChunkFormatterTest.php index 0d4ac6a163d..1b44d20b5e2 100644 --- a/Bigtable/tests/Snippet/ChunkFormatterTest.php +++ b/Bigtable/tests/Snippet/ChunkFormatterTest.php @@ -17,12 +17,15 @@ namespace Google\Cloud\Bigtable\Tests\Snippet; +use Google\ApiCore\Serializer; use \Google\ApiCore\ServerStream; use Google\Cloud\Bigtable\ChunkFormatter; use Google\Cloud\Bigtable\Table; -use Google\Cloud\Bigtable\V2\BigtableClient as TableClient; +use Google\Cloud\Bigtable\V2\Client\BigtableClient as TableClient; +use Google\Cloud\Bigtable\V2\ReadRowsRequest; use Google\Cloud\Core\Testing\Snippet\SnippetTestCase; use Google\Cloud\Core\Testing\TestHelpers; +use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; /** @@ -47,6 +50,7 @@ public function setUp(): void Table::class, [ $this->bigtableClient->reveal(), + new Serializer(), self::TABLE_NAME ] ); @@ -63,11 +67,13 @@ public function testClass() $this->serverStream->readAll() ->shouldBeCalled() ->willReturn([]); - $this->bigtableClient->readRows(self::TABLE_NAME, []) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $snippet->addLocal('table', $this->table); $res = $snippet->invoke('formatter'); $this->assertInstanceOf(ChunkFormatter::class, $res->returnVal()); diff --git a/Bigtable/tests/Snippet/TableTest.php b/Bigtable/tests/Snippet/TableTest.php index 49adb17bd0a..80ea1a1add3 100644 --- a/Bigtable/tests/Snippet/TableTest.php +++ b/Bigtable/tests/Snippet/TableTest.php @@ -17,28 +17,35 @@ namespace Google\Cloud\Bigtable\Tests\Snippet; +use Google\ApiCore\Serializer; use Google\ApiCore\ServerStream; use Google\Cloud\Bigtable\DataUtil; use Google\Cloud\Bigtable\Mutations; use Google\Cloud\Bigtable\ReadModifyWriteRowRules; use Google\Cloud\Bigtable\Table; -use Google\Cloud\Bigtable\V2\BigtableClient as TableClient; +use Google\Cloud\Bigtable\V2\Client\BigtableClient as TableClient; use Google\Cloud\Bigtable\V2\Cell; +use Google\Cloud\Bigtable\V2\CheckAndMutateRowRequest; use Google\Cloud\Bigtable\V2\CheckAndMutateRowResponse; use Google\Cloud\Bigtable\V2\Column; use Google\Cloud\Bigtable\V2\Family; +use Google\Cloud\Bigtable\V2\MutateRowRequest; use Google\Cloud\Bigtable\V2\MutateRowResponse; +use Google\Cloud\Bigtable\V2\MutateRowsRequest; use Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry as MutateRowsRequest_Entry; use Google\Cloud\Bigtable\V2\MutateRowsResponse; use Google\Cloud\Bigtable\V2\MutateRowsResponse\Entry as MutateRowsResponse_Entry; use Google\Cloud\Bigtable\V2\Mutation; use Google\Cloud\Bigtable\V2\Mutation\SetCell; +use Google\Cloud\Bigtable\V2\ReadModifyWriteRowRequest; use Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse; +use Google\Cloud\Bigtable\V2\ReadRowsRequest; use Google\Cloud\Bigtable\V2\ReadRowsResponse; use Google\Cloud\Bigtable\V2\ReadRowsResponse_CellChunk as ReadRowsResponse_CellChunk; use Google\Cloud\Bigtable\V2\Row; use Google\Cloud\Bigtable\V2\RowRange; use Google\Cloud\Bigtable\V2\RowSet; +use Google\Cloud\Bigtable\V2\SampleRowKeysRequest; use Google\Cloud\Bigtable\V2\SampleRowKeysResponse; use Google\Cloud\Core\Testing\Snippet\SnippetTestCase; use Google\Cloud\Core\Testing\TestHelpers; @@ -93,6 +100,7 @@ public function setUp(): void Table::class, [ $this->bigtableClient->reveal(), + new Serializer(), self::TABLE_NAME ] ); @@ -117,11 +125,13 @@ public function testMutateRows() ->willReturn( $this->arrayAsGenerator($this->mutateRowsResponses) ); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $this->entries, []) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $snippet = $this->snippetFromMethod(Table::class, 'mutateRows'); $snippet->addLocal('table', $this->table); $snippet->invoke(); @@ -131,11 +141,13 @@ public function testMutateRow() { $mutations = (new Mutations) ->upsert('cf1', 'cq1', 'value1', 1534183334215000); - $this->bigtableClient->mutateRow(self::TABLE_NAME, 'r1', $mutations->toProto(), []) - ->shouldBeCalled() - ->willReturn( - new MutateRowResponse - ); + $this->bigtableClient->mutateRow( + Argument::type(MutateRowRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + new MutateRowResponse + ); $snippet = $this->snippetFromMethod(Table::class, 'mutateRow'); $snippet->addLocal('table', $this->table); $snippet->invoke(); @@ -148,11 +160,13 @@ public function testUpsert() ->willReturn( $this->arrayAsGenerator($this->mutateRowsResponses) ); - $this->bigtableClient->mutateRows(self::TABLE_NAME, $this->entries, []) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $snippet = $this->snippetFromMethod(Table::class, 'upsert'); $snippet->addLocal('table', $this->table); $snippet->invoke(); @@ -165,11 +179,13 @@ public function testReadRows() ->willReturn( $this->arrayAsGenerator([$this->setUpReadRowsResponse()]) ); - $this->bigtableClient->readRows(self::TABLE_NAME, []) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $snippet = $this->snippetFromMethod(Table::class, 'readRows'); $snippet->addLocal('table', $this->table); $res = $snippet->invoke('rows'); @@ -200,11 +216,13 @@ public function testReadRowsWithRowRanges() ->setEndKeyOpen('lincoln'); $rowSet = (new RowSet()) ->setRowRanges([$rowRange]); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($rowSet) { - return $argument['rows']->serializeToJsonString() === $rowSet->serializeToJsonString(); - })) - ->shouldBeCalled() - ->willReturn($this->serverStream->reveal()); + $this->bigtableClient->readRows( + Argument::that(function($request) use($rowSet) { + return $request->getRows()->serializeToJsonString() === $rowSet->serializeToJsonString(); + }), + Argument::type('array') + )->shouldBeCalled() + ->willReturn($this->serverStream->reveal()); $snippet = $this->snippetFromMethod(Table::class, 'readRows', 1); $snippet->addLocal('table', $this->table); @@ -233,11 +251,13 @@ public function testReadRow() ); $rowSet = (new RowSet()) ->setRowKeys(['jefferson']); - $this->bigtableClient->readRows(self::TABLE_NAME, Argument::that(function ($argument) use ($rowSet) { - return $argument['rows']->serializeToJsonString() === $rowSet->serializeToJsonString(); - })) - ->shouldBeCalled() - ->willReturn($this->serverStream->reveal()); + $this->bigtableClient->readRows( + Argument::that(function($request) use($rowSet) { + return $request->getRows()->serializeToJsonString() === $rowSet->serializeToJsonString(); + }), + Argument::type('array') + )->shouldBeCalled() + ->willReturn($this->serverStream->reveal()); $snippet = $this->snippetFromMethod(Table::class, 'readRow'); $snippet->addLocal('table', $this->table); $res = $snippet->invoke('row'); @@ -279,10 +299,8 @@ public function testReadModifyWriteRowAppend() ->append('cf1', 'cq1', 'value12'); $this->bigtableClient ->readModifyWriteRow( - self::TABLE_NAME, - 'rk1', - $readModifyWriteRowRules->toProto(), - [] + Argument::type(ReadModifyWriteRowRequest::class), + Argument::type('array') ) ->shouldBeCalled() ->willReturn( @@ -320,11 +338,13 @@ public function testReadModifyWriteRowIncrement() ->willReturn( $this->arrayAsGenerator($this->mutateRowsResponses) ); - $this->bigtableClient->mutateRows(self::TABLE_NAME, Argument::any(), []) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->mutateRows( + Argument::type(MutateRowsRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $readModifyWriteRowResponse = (new ReadModifyWriteRowResponse) ->setRow( (new Row) @@ -346,12 +366,9 @@ public function testReadModifyWriteRowIncrement() ->increment('cf1', 'cq1', 3); $this->bigtableClient ->readModifyWriteRow( - self::TABLE_NAME, - 'rk1', - $readModifyWriteRowRules->toProto(), - [] - ) - ->shouldBeCalled() + Argument::type(ReadModifyWriteRowRequest::class), + Argument::type('array') + )->shouldBeCalled() ->willReturn( $readModifyWriteRowResponse ); @@ -383,11 +400,13 @@ public function testSampleRowKeys() ->willReturn( $this->arrayAsGenerator($sampleRowKeyResponses) ); - $this->bigtableClient->sampleRowKeys(self::TABLE_NAME, []) - ->shouldBeCalled() - ->willReturn( - $this->serverStream->reveal() - ); + $this->bigtableClient->sampleRowKeys( + Argument::type(SampleRowKeysRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn( + $this->serverStream->reveal() + ); $snippet = $this->snippetFromMethod(Table::class, 'sampleRowKeys'); $snippet->addLocal('table', $this->table); $res = $snippet->invoke('rowKeyStream'); @@ -403,9 +422,11 @@ public function testSampleRowKeys() public function testCheckAndMutateRow() { - $this->bigtableClient->checkAndMutateRow(self::TABLE_NAME, 'rk1', Argument::any()) - ->shouldBeCalled() - ->willReturn((new CheckAndMutateRowResponse)->setPredicateMatched(true)); + $this->bigtableClient->checkAndMutateRow( + Argument::type(CheckAndMutateRowRequest::class), + Argument::type('array') + )->shouldBeCalled() + ->willReturn((new CheckAndMutateRowResponse)->setPredicateMatched(true)); $snippet = $this->snippetFromMethod(Table::class, 'checkAndMutateRow'); $snippet->addLocal('table', $this->table); $res = $snippet->invoke('result'); @@ -416,9 +437,8 @@ public function testCheckAndMutateRowWithFilter() { $this->bigtableClient ->checkAndMutateRow( - self::TABLE_NAME, - 'rk1', - Argument::any() + Argument::type(CheckAndMutateRowRequest::class), + Argument::type('array') ) ->shouldBeCalled() ->willReturn((new CheckAndMutateRowResponse)->setPredicateMatched(true)); diff --git a/Bigtable/tests/Snippet/bootstrap.php b/Bigtable/tests/Snippet/bootstrap.php new file mode 100644 index 00000000000..c2b7a4db9e2 --- /dev/null +++ b/Bigtable/tests/Snippet/bootstrap.php @@ -0,0 +1,12 @@ + Date: Tue, 21 May 2024 16:38:44 +0530 Subject: [PATCH 13/36] Changed the system tests to use the V2 GAPIC surface --- Bigtable/tests/System/BackupTests.php | 116 +++++++++++------- .../BigtableInstanceAdminClientTest.php | 9 +- Bigtable/tests/System/BigtableTestCase.php | 42 ++++--- 3 files changed, 104 insertions(+), 63 deletions(-) diff --git a/Bigtable/tests/System/BackupTests.php b/Bigtable/tests/System/BackupTests.php index 305814638b4..854718d0ff5 100644 --- a/Bigtable/tests/System/BackupTests.php +++ b/Bigtable/tests/System/BackupTests.php @@ -20,9 +20,17 @@ use Exception; use Google\ApiCore\ApiException; use Google\Cloud\Bigtable\Admin\V2\Backup; -use Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient; -use Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient; +use Google\Cloud\Bigtable\Admin\V2\Client\BigtableInstanceAdminClient; +use Google\Cloud\Bigtable\Admin\V2\Client\BigtableTableAdminClient; use Google\Cloud\Bigtable\Admin\V2\Cluster; +use Google\Cloud\Bigtable\Admin\V2\CopyBackupRequest; +use Google\Cloud\Bigtable\Admin\V2\CreateBackupRequest; +use Google\Cloud\Bigtable\Admin\V2\CreateClusterRequest; +use Google\Cloud\Bigtable\Admin\V2\CreateInstanceRequest; +use Google\Cloud\Bigtable\Admin\V2\DeleteBackupRequest; +use Google\Cloud\Bigtable\Admin\V2\DeleteInstanceRequest; +use Google\Cloud\Bigtable\Admin\V2\GetBackupRequest; +use Google\Cloud\Bigtable\Admin\V2\GetInstanceRequest; use Google\Cloud\Bigtable\Admin\V2\Instance; use Google\Cloud\Bigtable\Admin\V2\StorageType; use Google\Protobuf\Timestamp; @@ -106,11 +114,12 @@ public function testCreateBackup(): void self::$instanceId, self::$clusterId ); - $operationResponse = self::$tableAdminClient->createBackup( - $parentName, - self::$backupId, - $backup - ); + $request = new CreateBackupRequest([ + 'parent' => $parentName, + 'backup_id' => self::$backupId, + 'backup' => $backup + ]); + $operationResponse = self::$tableAdminClient->createBackup($request); $operationResponse->pollUntilComplete(); $result = $operationResponse->getResult(); $this->assertStringContainsString(self::$backupName, $result->getName()); @@ -131,13 +140,15 @@ public function testCopyBackupSameProjectDifferentCluster(): void $ex = null; try { - $operationResponse = self::$tableAdminClient->copyBackup( - $clusterName, - self::$copyBackupId, - self::$backupName, - // Setting 10 days expiration time - new Timestamp(['seconds' => time() + self::SECONDS_IN_A_DAY * 10]) - ); + // Setting 10 days expiration time + $expireTime = new Timestamp(['seconds' => time() + self::SECONDS_IN_A_DAY * 10]); + $request = new CopyBackupRequest([ + 'parent' => $clusterName, + 'backup_id' => self::$copyBackupId, + 'source_backup' => self::$backupName, + 'expire_time' => $expireTime + ]); + $operationResponse = self::$tableAdminClient->copyBackup($request); $operationResponse->pollUntilComplete(); $copyBackup = $operationResponse->getResult(); @@ -193,23 +204,26 @@ public function testCopyBackupInDifferentProject(): void $ex = null; try { - $operationResponse = $instanceClient->createInstance( - $projectName, - $instanceId, - $instance, - $clusters - ); + $request = new CreateInstanceRequest([ + 'parent' => $projectName, + 'instance_id' => $instanceId, + 'instance' => $instance, + 'clusters' => $clusters + ]); + $operationResponse = $instanceClient->createInstance($request); $operationResponse->pollUntilComplete(); if (!$operationResponse->operationSucceeded()) { $this->fail("Secondary project's instance creation failed"); } - $operationResponse = $tableClient->copyBackup( - $clusterName, - $copyBackupId, - self::$backupName, - new Timestamp(['seconds' => time() + self::SECONDS_IN_A_DAY * 10]) - ); + $expireTime = new Timestamp(['seconds' => time() + self::SECONDS_IN_A_DAY * 10]); + $copyBackupRequest = new CopyBackupRequest([ + 'parent' => $clusterName, + 'backup_id' => $copyBackupId, + 'source_backup' => self::$backupName, + 'expire_time' => $expireTime + ]); + $operationResponse = $tableClient->copyBackup($copyBackupRequest); $operationResponse->pollUntilComplete(); $result = $operationResponse->getResult(); @@ -224,8 +238,10 @@ public function testCopyBackupInDifferentProject(): void if (!self::isEmulatorUsed()) { try { $instanceName = $instanceClient->instanceName($projectId, $instanceId); - $instanceClient->getInstance($instanceName); - $instanceClient->deleteInstance($instanceName); + $getInstanceRequest = new GetInstanceRequest(['name' => $instanceName]); + $instanceClient->getInstance($getInstanceRequest); + $deleteInstanceRequest = new DeleteInstanceRequest(['name' => $instanceName]); + $instanceClient->deleteInstance($deleteInstanceRequest); } catch (Exception $th) { printf($th->getMessage() . PHP_EOL); } @@ -250,16 +266,20 @@ public function testCopyBackupShouldThrowForCopiedBackup(): void self::$copyBackupClusterId, self::$copyBackupId ); - $operationResponse = self::$tableAdminClient->copyBackup( - self::$instanceAdminClient->clusterName( - self::$projectId, - self::$instanceId, - self::$clusterId - ), - self::$copyBackupId, - $copyBackupName, - new Timestamp(['seconds' => time() + self::SECONDS_IN_A_DAY * 10]) + + $clusterName = self::$instanceAdminClient->clusterName( + self::$projectId, + self::$instanceId, + self::$clusterId ); + $expireTime = new Timestamp(['seconds' => time() + self::SECONDS_IN_A_DAY * 10]); + $request = new CopyBackupRequest([ + 'parent' => $clusterName, + 'backup_id' => self::$copyBackupId, + 'source_backup' => $copyBackupName, + 'expire_time' => $expireTime + ]); + $operationResponse = self::$tableAdminClient->copyBackup($request); $operationResponse->pollUntilComplete(); } @@ -292,11 +312,12 @@ private function createCustomCluster( $location ) ); - $operationResponse = self::$instanceAdminClient->createCluster( - $instanceName, - $clusterId, - $cluster - ); + $request = new CreateClusterRequest([ + 'parent' => $instanceName, + 'cluster_id' => $clusterId, + 'cluster' => $cluster + ]); + $operationResponse = self::$instanceAdminClient->createCluster($request); $operationResponse->pollUntilComplete(); if (!$operationResponse->operationSucceeded()) { $this->fail('Cluster creation failed'); @@ -309,8 +330,15 @@ private static function deleteBackupIfExists( string $backupName ): void { try { - $client->getBackup($backupName); - $client->deleteBackup($backupName); + $getBackupRequest = new GetBackupRequest([ + 'name' => $backupName + ]); + $client->getBackup($getBackupRequest); + + $deleteBackupRequest = new DeleteBackupRequest([ + 'name' => $backupName + ]); + $client->deleteBackup($deleteBackupRequest); } catch (ApiException $th) { printf($th->getMessage() . PHP_EOL); } diff --git a/Bigtable/tests/System/BigtableInstanceAdminClientTest.php b/Bigtable/tests/System/BigtableInstanceAdminClientTest.php index 4544d80ca50..eda7f68a49c 100644 --- a/Bigtable/tests/System/BigtableInstanceAdminClientTest.php +++ b/Bigtable/tests/System/BigtableInstanceAdminClientTest.php @@ -17,7 +17,8 @@ namespace Google\Cloud\Bigtable\Tests\System; -use Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient; +use Google\Cloud\Bigtable\Admin\V2\Client\BigtableInstanceAdminClient; +use Google\Cloud\Bigtable\Admin\V2\ListInstancesRequest; use Google\Cloud\Bigtable\Admin\V2\ListInstancesResponse; use PHPUnit\Framework\TestCase; @@ -67,9 +68,9 @@ public static function setUpBeforeClass(): void */ public function testListInstances(BigtableInstanceAdminClient $client) { - $response = $client->listInstances( - $client->projectName(self::$projectId) - ); + $project = $client::projectName(self::$projectId); + $request = new ListInstancesRequest(['parent' => $project]); + $response = $client->listInstances($request); $this->assertInstanceOf(ListInstancesResponse::class, $response); } diff --git a/Bigtable/tests/System/BigtableTestCase.php b/Bigtable/tests/System/BigtableTestCase.php index 72f14b9ef3b..fd5167a11fc 100644 --- a/Bigtable/tests/System/BigtableTestCase.php +++ b/Bigtable/tests/System/BigtableTestCase.php @@ -17,8 +17,8 @@ namespace Google\Cloud\Bigtable\Tests\System; -use Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient as InstanceAdminClient; -use Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient as TableAdminClient; +use Google\Cloud\Bigtable\Admin\V2\Client\BigtableInstanceAdminClient as InstanceAdminClient; +use Google\Cloud\Bigtable\Admin\V2\Client\BigtableTableAdminClient as TableAdminClient; use Google\Cloud\Bigtable\Admin\V2\Cluster; use Google\Cloud\Bigtable\Admin\V2\ColumnFamily; use Google\Cloud\Bigtable\Admin\V2\Instance; @@ -26,6 +26,10 @@ use Google\Cloud\Bigtable\BigtableClient; use Google\Cloud\Core\Testing\System\SystemTestCase; use Exception; +use Google\Cloud\Bigtable\Admin\V2\CreateInstanceRequest; +use Google\Cloud\Bigtable\Admin\V2\CreateTableRequest; +use Google\Cloud\Bigtable\Admin\V2\DeleteInstanceRequest; +use Google\Cloud\Bigtable\Admin\V2\DeleteTableRequest; /** * @group bigtable @@ -93,12 +97,13 @@ private static function createInstance() $clusters = [ self::$clusterId => $cluster ]; - $operationResponse = self::$instanceAdminClient->createInstance( - $formattedParent, - self::$instanceId, - $instance, - $clusters - ); + $request = new CreateInstanceRequest([ + 'parent' => $formattedParent, + 'instance_id' => self::$instanceId, + 'instance' => $instance, + 'clusters' => $clusters + ]); + $operationResponse = self::$instanceAdminClient->createInstance($request); $operationResponse->pollUntilComplete(); if (!$operationResponse->operationSucceeded()) { throw new Exception('error creating instance', -1); @@ -111,7 +116,10 @@ private static function deleteInstance() self::$projectId, self::$instanceId ); - self::$instanceAdminClient->deleteInstance($formattedName); + $request = new DeleteInstanceRequest([ + 'name' => $formattedName + ]); + self::$instanceAdminClient->deleteInstance($request); } private static function createTable() @@ -134,11 +142,12 @@ private static function createTable() 'cf8' => $columnFamily, 'cf9' => $columnFamily ]); - self::$tableAdminClient->createTable( - $formattedParent, - self::TABLE_ID, - $table - ); + $request = new CreateTableRequest([ + 'parent' => $formattedParent, + 'table_id' => self::TABLE_ID, + 'table' => $table + ]); + self::$tableAdminClient->createTable($request); } private static function deleteTable() @@ -148,6 +157,9 @@ private static function deleteTable() self::$instanceId, self::TABLE_ID ); - self::$tableAdminClient->deleteTable($formattedName); + $request = new DeleteTableRequest([ + 'name' => $formattedName + ]); + self::$tableAdminClient->deleteTable($request); } } From c5278758566881c716457f07e95b34d6790f6c4e Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Tue, 21 May 2024 18:10:31 +0530 Subject: [PATCH 14/36] Removed deprecated classes --- Bigtable/src/V2/MutateRowsRequest_Entry.php | 16 ---------------- Bigtable/src/V2/MutateRowsResponse_Entry.php | 16 ---------------- Bigtable/src/V2/Mutation_DeleteFromColumn.php | 16 ---------------- Bigtable/src/V2/Mutation_DeleteFromFamily.php | 16 ---------------- Bigtable/src/V2/Mutation_DeleteFromRow.php | 16 ---------------- Bigtable/src/V2/Mutation_SetCell.php | 16 ---------------- .../V2/ReadChangeStreamResponse_CloseStream.php | 16 ---------------- .../V2/ReadChangeStreamResponse_DataChange.php | 16 ---------------- .../ReadChangeStreamResponse_DataChange_Type.php | 16 ---------------- .../V2/ReadChangeStreamResponse_Heartbeat.php | 16 ---------------- .../ReadChangeStreamResponse_MutationChunk.php | 16 ---------------- ...ngeStreamResponse_MutationChunk_ChunkInfo.php | 16 ---------------- .../src/V2/ReadRowsRequest_RequestStatsView.php | 16 ---------------- Bigtable/src/V2/ReadRowsResponse_CellChunk.php | 16 ---------------- Bigtable/src/V2/RowFilter_Chain.php | 16 ---------------- Bigtable/src/V2/RowFilter_Condition.php | 16 ---------------- Bigtable/src/V2/RowFilter_Interleave.php | 16 ---------------- 17 files changed, 272 deletions(-) delete mode 100644 Bigtable/src/V2/MutateRowsRequest_Entry.php delete mode 100644 Bigtable/src/V2/MutateRowsResponse_Entry.php delete mode 100644 Bigtable/src/V2/Mutation_DeleteFromColumn.php delete mode 100644 Bigtable/src/V2/Mutation_DeleteFromFamily.php delete mode 100644 Bigtable/src/V2/Mutation_DeleteFromRow.php delete mode 100644 Bigtable/src/V2/Mutation_SetCell.php delete mode 100644 Bigtable/src/V2/ReadChangeStreamResponse_CloseStream.php delete mode 100644 Bigtable/src/V2/ReadChangeStreamResponse_DataChange.php delete mode 100644 Bigtable/src/V2/ReadChangeStreamResponse_DataChange_Type.php delete mode 100644 Bigtable/src/V2/ReadChangeStreamResponse_Heartbeat.php delete mode 100644 Bigtable/src/V2/ReadChangeStreamResponse_MutationChunk.php delete mode 100644 Bigtable/src/V2/ReadChangeStreamResponse_MutationChunk_ChunkInfo.php delete mode 100644 Bigtable/src/V2/ReadRowsRequest_RequestStatsView.php delete mode 100644 Bigtable/src/V2/ReadRowsResponse_CellChunk.php delete mode 100644 Bigtable/src/V2/RowFilter_Chain.php delete mode 100644 Bigtable/src/V2/RowFilter_Condition.php delete mode 100644 Bigtable/src/V2/RowFilter_Interleave.php diff --git a/Bigtable/src/V2/MutateRowsRequest_Entry.php b/Bigtable/src/V2/MutateRowsRequest_Entry.php deleted file mode 100644 index a25e607142d..00000000000 --- a/Bigtable/src/V2/MutateRowsRequest_Entry.php +++ /dev/null @@ -1,16 +0,0 @@ - Date: Wed, 22 May 2024 12:03:18 +0530 Subject: [PATCH 15/36] Modified retries param to retrySettings.maxRetries --- Bigtable/src/ChunkFormatter.php | 1 - Bigtable/src/ResumableStream.php | 29 ++++++++++++++++++-- Bigtable/src/Table.php | 26 ++++++++++++------ Bigtable/tests/Unit/SmartRetriesTest.php | 35 ++++++++++++++++++++++-- 4 files changed, 75 insertions(+), 16 deletions(-) diff --git a/Bigtable/src/ChunkFormatter.php b/Bigtable/src/ChunkFormatter.php index 84251bdb2fc..674079d339e 100644 --- a/Bigtable/src/ChunkFormatter.php +++ b/Bigtable/src/ChunkFormatter.php @@ -170,7 +170,6 @@ public function __construct( $request, $argumentFunction, $retryFunction, - $this->pluck('retries', $options, false), $options ); } diff --git a/Bigtable/src/ResumableStream.php b/Bigtable/src/ResumableStream.php index 10ab81dfd3e..649fd988f5c 100644 --- a/Bigtable/src/ResumableStream.php +++ b/Bigtable/src/ResumableStream.php @@ -19,6 +19,7 @@ use Google\ApiCore\ApiException; use Google\ApiCore\ArrayTrait; +use Google\ApiCore\RetrySettings; use Google\Cloud\Bigtable\V2\Client\BigtableClient as GapicClient; use Google\Protobuf\Internal\Message; use Google\Rpc\Code; @@ -87,7 +88,11 @@ class ResumableStream implements \IteratorAggregate * @param callable $argumentFunction Function which returns the argument to be used while * calling `$apiFunction`. * @param callable $retryFunction Function which determines whether to retry or not. - * @param int $retries [optional] Number of times to retry. **Defaults to** `3`. + * @param int $retries [optional] + * @param RetrySettings|array $retrySettings { + * @option int $maxRetries Number of times to retry. **Defaults to** `3`. + * Only maxRetries works for RetrySettings in this API. + * } */ public function __construct( GapicClient $gapicClient, @@ -95,13 +100,12 @@ public function __construct( Message $request, callable $argumentFunction, callable $retryFunction, - $retries = self::DEFAULT_MAX_RETRIES, array $optionalArgs = [] ) { $this->gapicClient = $gapicClient; $this->method = $method; $this->request = $request; - $this->retries = $retries ?: self::DEFAULT_MAX_RETRIES; + $this->retries = $this->getMaxRetries($optionalArgs); $this->argumentFunction = $argumentFunction; $this->retryFunction = $retryFunction; // Disable GAX retries because we want to handle the retries here. @@ -172,4 +176,23 @@ public static function isRetryable($code) { return isset(self::$retryableStatusCodes[$code]); } + + private function getMaxRetries(array &$options) : int + { + $options += [ + 'retrySettings' => [ + 'maxRetries' => ResumableStream::DEFAULT_MAX_RETRIES + ] + ]; + + // We remove the retrySettings from the options array because + // we don't need to forward it to GAX anyway. + $retrySettings = $this->pluck('retrySettings', $options, false); + + if ($retrySettings instanceof RetrySettings) { + return $retrySettings->getMaxRetries(); + } + + return $retrySettings['maxRetries']; + } } diff --git a/Bigtable/src/Table.php b/Bigtable/src/Table.php index e609f9f0cb5..56580a098bd 100644 --- a/Bigtable/src/Table.php +++ b/Bigtable/src/Table.php @@ -88,7 +88,7 @@ class Table * @type string $appProfileId This value specifies routing for * replication. **Defaults to** the "default" application profile. * @type array $headers Headers to be passed with each request. - * @type int $retries Number of times to retry. **Defaults to** `3`. + * @type int $retrySettings.maxRetries Number of times to retry. **Defaults to** `3`. * This settings only applies to {@see \Google\Cloud\Bigtable\Table::mutateRows()}, * {@see \Google\Cloud\Bigtable\Table::upsert()} and * {@see \Google\Cloud\Bigtable\Table::readRows()}. @@ -138,7 +138,7 @@ public function mutateRows(array $rowMutations, array $options = []) foreach ($rowMutations as $rowKey => $mutations) { $entries[] = $this->toEntry($rowKey, $mutations); } - $this->mutateRowsWithEntries($entries, $options); + $this->mutateRowsWithEntries($entries, $options + $this->options); } /** @@ -160,7 +160,10 @@ public function mutateRows(array $rowMutations, array $options = []) * @param array $options [optional] { * Configuration options. * - * @type int $retries Number of times to retry. **Defaults to** `3`. + * @param RetrySettings|array $retrySettings { + * @option int $maxRetries Number of times to retry. **Defaults to** `3`. + * Only maxRetries works for RetrySettings in this API. + * } * } * @return void * @throws ApiException If the remote call fails. @@ -201,7 +204,10 @@ public function mutateRow($rowKey, Mutations $mutations, array $options = []) * @param array $options [optional] { * Configuration options. * - * @type int $retries Number of times to retry. **Defaults to** `3`. + * @param RetrySettings|array $retrySettings { + * @option int $maxRetries Number of times to retry. **Defaults to** `3`. + * Only maxRetries works for RetrySettings in this API. + * } * } * @return void * @throws ApiException|BigtableDataOperationException If the remote call fails or operation fails @@ -227,7 +233,7 @@ public function upsert(array $rows, array $options = []) } $entries[] = $this->toEntry($rowKey, $mutations); } - $this->mutateRowsWithEntries($entries, $options); + $this->mutateRowsWithEntries($entries, $options + $this->options); } /** @@ -271,7 +277,10 @@ public function upsert(array $rows, array $options = []) * To learn more please see {@see \Google\Cloud\Bigtable\Filter} which * provides static factory methods for the various filter types. * @type int $rowsLimit The number of rows to scan. - * @type int $retries Number of times to retry. **Defaults to** `3`. + * @param RetrySettings|array $retrySettings { + * @option int $maxRetries Number of times to retry. **Defaults to** `3`. + * Only maxRetries works for RetrySettings in this API. + * } * } * @return ChunkFormatter */ @@ -280,7 +289,7 @@ public function readRows(array $options = []) $rowKeys = $this->pluck('rowKeys', $options, false) ?: []; $ranges = $this->pluck('rowRanges', $options, false) ?: []; $filter = $this->pluck('filter', $options, false) ?: null; - list($data, $optionalArgs) = $this->splitOptionalArgs($options, ['retries']); + list($data, $optionalArgs) = $this->splitOptionalArgs($options, ['retrySettings']); array_walk($ranges, function (&$range) { $range = $this->serializer->decodeMessage( @@ -552,7 +561,7 @@ private function mutateRowsWithEntries(array $entries, array $options = []) return false; }; - list($data, $optionalArgs) = $this->splitOptionalArgs($options, ['retries']); + list($data, $optionalArgs) = $this->splitOptionalArgs($options, ['retrySettings']); $request = $this->serializer->decodeMessage(new MutateRowsRequest(), $data); $request->setTableName($this->tableName); @@ -563,7 +572,6 @@ private function mutateRowsWithEntries(array $entries, array $options = []) $request, $argumentFunction, $retryFunction, - $this->pluck('retries', $options, false), $optionalArgs ); $message = 'partial failure'; diff --git a/Bigtable/tests/Unit/SmartRetriesTest.php b/Bigtable/tests/Unit/SmartRetriesTest.php index 87565b91a79..f4fb0c91b60 100644 --- a/Bigtable/tests/Unit/SmartRetriesTest.php +++ b/Bigtable/tests/Unit/SmartRetriesTest.php @@ -18,6 +18,7 @@ namespace Google\Cloud\Bigtable\Tests\Unit; use Google\ApiCore\ApiException; +use Google\ApiCore\RetrySettings; use Google\ApiCore\Serializer; use Google\ApiCore\ServerStream; use Google\Cloud\Bigtable\Exception\BigtableDataOperationException; @@ -130,7 +131,7 @@ public function testReadRowsShouldRetryForProvidedAttempts() ->willReturn( $this->serverStream->reveal() ); - $args = ['retries' => 5]; + $args = ['retrySettings' => ['maxRetries' => 5]]; $iterator = $this->table->readRows($args); $iterator->getIterator()->current(); } @@ -589,12 +590,12 @@ public function testMutateRowsRespectRetriesAttempt() $entries = $this->generateEntries(1, 5); $this->bigtableClient->mutateRows( Argument::type(MutateRowsRequest::class), - Argument::withEntry('retries', 5) + Argument::type('array') )->shouldBeCalledTimes(6) ->willReturn( $this->serverStream->reveal() ); - $this->table->mutateRows($mutations, ['retries' => 5]); + $this->table->mutateRows($mutations, ['retrySettings' => ['maxRetries' => 5]]); } public function testMutateRowsOnlyRetriesFailedEntries() @@ -737,6 +738,34 @@ public function testMutateRowsShouldNotRetryIfAnyMutationIsNotRetryable() } } + public function testRetrySettingsObject() + { + $this->expectException(ApiException::class); + $this->expectExceptionMessage('DEADLINE_EXCEEDED'); + + $this->serverStream->readAll() + ->shouldBeCalledTimes(5) + ->willThrow( + $this->retryingApiException + ); + $this->bigtableClient->readRows( + Argument::type(ReadRowsRequest::class), + Argument::type('array') + )->shouldBeCalledTimes(5) + ->willReturn( + $this->serverStream->reveal() + ); + + $retrySettings = RetrySettings::constructDefault(); + $retrySettings = $retrySettings->with(['maxRetries' => 4]); + + $iterator = $this->table->readRows([ + 'retrySettings' => $retrySettings + ]); + + $iterator->getIterator()->current(); + } + private function generateRowsResponse($from, $to) { $rows = []; From 913c2474382b09841918b5a17eabe4693c794d67 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Wed, 22 May 2024 13:12:37 +0530 Subject: [PATCH 16/36] Fix snippet tests --- Bigtable/tests/Snippet/TableTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Bigtable/tests/Snippet/TableTest.php b/Bigtable/tests/Snippet/TableTest.php index 80ea1a1add3..8c201756e28 100644 --- a/Bigtable/tests/Snippet/TableTest.php +++ b/Bigtable/tests/Snippet/TableTest.php @@ -41,7 +41,7 @@ use Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse; use Google\Cloud\Bigtable\V2\ReadRowsRequest; use Google\Cloud\Bigtable\V2\ReadRowsResponse; -use Google\Cloud\Bigtable\V2\ReadRowsResponse_CellChunk as ReadRowsResponse_CellChunk; +use Google\Cloud\Bigtable\V2\ReadRowsResponse\CellChunk; use Google\Cloud\Bigtable\V2\Row; use Google\Cloud\Bigtable\V2\RowRange; use Google\Cloud\Bigtable\V2\RowSet; @@ -452,7 +452,7 @@ private function setUpReadRowsResponse() { $readRowsResponse = new ReadRowsResponse; $chunks = []; - $chunk = new ReadRowsResponse_CellChunk(); + $chunk = new CellChunk(); $chunk->setRowKey('rk1'); $stringValue = new StringValue(); $stringValue->setValue('cf1'); From f2e83c0a60eb2fe8145b44fa0be1d30f314a7093 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Wed, 22 May 2024 13:18:39 +0530 Subject: [PATCH 17/36] Added a migrating guide --- Bigtable/MIGRATING.md | 66 +++++++++++++++++++++++++++++++++++++++++++ Bigtable/README.md | 2 ++ 2 files changed, 68 insertions(+) create mode 100644 Bigtable/MIGRATING.md diff --git a/Bigtable/MIGRATING.md b/Bigtable/MIGRATING.md new file mode 100644 index 00000000000..72572f534a8 --- /dev/null +++ b/Bigtable/MIGRATING.md @@ -0,0 +1,66 @@ +# Migrating Google Cloud Bigtable from V1 to V2 + +## How to upgrade + +Update your `google/cloud-bigtable` dependency to `^2.0`: + +``` +{ + "require": { + "google/cloud-bigtable": "^2.0" + } +} +``` + +## Changes + +### Retry Options changes + +The `retries` parameter in the following RPC calls is changed to `retrySettings.maxRetries`: +- Google\Cloud\Bigtable\Table::mutateRows +- Google\Cloud\Bigtable\Table::upsert +- Google\Cloud\Bigtable\Table::readRows + +For example: +```php +$table->readRows([ + 'retrySettings' => [ + 'maxRetries' => 3 + ] +]); +``` + +OR + +```php +$retrySettings = RetrySettings::constructDefault(); +$retrySettings = $retrySettings->with(['maxRetries' => 3]) +$table->readRows([ + 'retrySettings' => $retrySettings +]); +``` + +This is done in order to be consistent across other RPC calls which use GAX's retrySettings and to be consistent across other products which mostly use the [RetrySettings](https://github.com/googleapis/gax-php/blob/main/src/RetrySettings.php) from GAX already. + +Only the maxRetries parameter is supported for now and not the other options in the `RetrySettings`. + +### Removed deprecated classes + +The following deprecated classes are now removed completely. Use the specified alternatives. +- `Google\Cloud\Bigtable\V2\MutateRowsRequest_Entry`, use `Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry` instead. +- `Google\Cloud\Bigtable\V2\MutateRowsResponse_Entry`, use `Google\Cloud\Bigtable\V2\MutateRowsResponse\Entry` instead. +- `Google\Cloud\Bigtable\V2\Mutation_DeleteFromFamily`, use `Google\Cloud\Bigtable\V2\Mutation\DeleteFromFamily` instead. +- `Google\Cloud\Bigtable\V2\Mutation_DeleteFromColumn`, use `Google\Cloud\Bigtable\V2\Mutation\DeleteFromColumn` instead. +- `Google\Cloud\Bigtable\V2\Mutation_DeleteFromRow`, use `Google\Cloud\Bigtable\V2\Mutation\DeleteFromRow` instead. +- `Google\Cloud\Bigtable\V2\Mutation_SetCell`, use `Google\Cloud\Bigtable\V2\Mutation\SetCell` instead. +- `Google\Cloud\Bigtable\V2\ReadChangeStreamResponse_CloseStream`, use Google\Cloud\Bigtable\V2\ReadChangeStreamResponse\CloseStream`` instead. +- `Google\Cloud\Bigtable\V2\ReadChangeStreamResponse_DataChange_Type`, use `Google\Cloud\Bigtable\V2\ReadChangeStreamResponse\DataChange\Type` instead. +- `Google\Cloud\Bigtable\V2\ReadChangeStreamResponse_DataChange`, use `Google\Cloud\Bigtable\V2\ReadChangeStreamResponse\DataChange` instead. +- `Google\Cloud\Bigtable\V2\ReadChangeStreamResponse_Heartbeat`, use `Google\Cloud\Bigtable\V2\ReadChangeStreamResponse\Heartbeat` instead. +- `Google\Cloud\Bigtable\V2\ReadChangeStreamResponse_MutationChunk_ChunkInfo`, use `Google\Cloud\Bigtable\V2\ReadChangeStreamResponse\MutationChunk\ChunkInfo` instead. +- `Google\Cloud\Bigtable\V2\ReadChangeStreamResponse_MutationChunk`, use `Google\Cloud\Bigtable\V2\ReadChangeStreamResponse\MutationChunk` instead. +- `Google\Cloud\Bigtable\V2\ReadRowsRequest_RequestStatsView`, use `Google\Cloud\Bigtable\V2\ReadRowsRequest\RequestStatsView` instead. +- `Google\Cloud\Bigtable\V2\RowFilter_Chain`, use `Google\Cloud\Bigtable\V2\RowFilter\Chain` instead. +- `Google\Cloud\Bigtable\V2\RowFilter_Condition`, use `Google\Cloud\Bigtable\V2\RowFilter\Condition` instead. +- `Google\Cloud\Bigtable\V2\RowFilter_Interleave`, use `Google\Cloud\Bigtable\V2\RowFilter\Interleave` instead. +- `Google\Cloud\Bigtable\V2\ReadRowsResponse_CellChunk`, use `Google\Cloud\Bigtable\V2\ReadRowsResponse\CellChunk` instead. diff --git a/Bigtable/README.md b/Bigtable/README.md index 3408b4f6aec..c8b4acaccb4 100644 --- a/Bigtable/README.md +++ b/Bigtable/README.md @@ -66,6 +66,8 @@ foreach ($rows as $row) { This component is considered GA (generally available). As such, it will not introduce backwards-incompatible changes in any minor or patch releases. We will address issues and requests with the highest priority. +Please see the [migration guide](./MIGRATING.md) to upgrade from **V1** of the library to **V2**. + ### Next Steps Take a look at and understand the [official documentation](https://cloud.google.com/bigtable/docs). From ad0a412783585bde17ca3b682a34d70e94b7c2f0 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Wed, 22 May 2024 13:29:33 +0530 Subject: [PATCH 18/36] Undo changes in V2/BigtableClient and mark it deprecated --- Bigtable/src/V2/BigtableClient.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Bigtable/src/V2/BigtableClient.php b/Bigtable/src/V2/BigtableClient.php index 79ef10006b6..ee3d93664ac 100644 --- a/Bigtable/src/V2/BigtableClient.php +++ b/Bigtable/src/V2/BigtableClient.php @@ -31,15 +31,16 @@ namespace Google\Cloud\Bigtable\V2; use Google\Cloud\Bigtable\EmulatorSupportTrait; -use Google\Cloud\Bigtable\V2\Client\BigtableClient as BigtableGapicClient; +use Google\Cloud\Bigtable\V2\Gapic\BigtableGapicClient; /** * {@inheritdoc} + * @deprecated Please use the new service client {@see \Google\Cloud\Bigtable\V2\Client\BigtableClient}. */ class BigtableClient extends BigtableGapicClient { use EmulatorSupportTrait; // This class is intentionally empty, and is intended to hold manual - // additions to the generated {@see Google\Cloud\Bigtable\V2\Client\BigtableClient} class. + // additions to the generated {@see BigtableGapicClient} class. } From 15714aca998660ae92e6a99caeee96f124be4d1f Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Wed, 22 May 2024 13:40:01 +0530 Subject: [PATCH 19/36] Lint fixes --- Bigtable/src/ChunkFormatter.php | 3 +- Bigtable/src/ResumableStream.php | 15 ++++----- Bigtable/src/Table.php | 6 ++-- Bigtable/tests/Snippet/TableTest.php | 4 +-- Bigtable/tests/Snippet/bootstrap.php | 2 +- Bigtable/tests/Unit/SmartRetriesTest.php | 40 ++++++++++++------------ Bigtable/tests/Unit/bootstrap.php | 2 +- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Bigtable/src/ChunkFormatter.php b/Bigtable/src/ChunkFormatter.php index 674079d339e..af7ffc44129 100644 --- a/Bigtable/src/ChunkFormatter.php +++ b/Bigtable/src/ChunkFormatter.php @@ -138,8 +138,7 @@ public function __construct( GapicClient $gapicClient, ReadRowsRequest $request, array $options = [] - ) - { + ) { $this->gapicClient = $gapicClient; $this->request = $request; $this->options = $options; diff --git a/Bigtable/src/ResumableStream.php b/Bigtable/src/ResumableStream.php index 649fd988f5c..84800eb714d 100644 --- a/Bigtable/src/ResumableStream.php +++ b/Bigtable/src/ResumableStream.php @@ -88,11 +88,12 @@ class ResumableStream implements \IteratorAggregate * @param callable $argumentFunction Function which returns the argument to be used while * calling `$apiFunction`. * @param callable $retryFunction Function which determines whether to retry or not. - * @param int $retries [optional] - * @param RetrySettings|array $retrySettings { - * @option int $maxRetries Number of times to retry. **Defaults to** `3`. + * @param array $optionalArgs { + * @option RetrySettings|array $retrySettings { + * @option int $maxRetries Number of times to retry. **Defaults to** `3`. * Only maxRetries works for RetrySettings in this API. - * } + * } + * } */ public function __construct( GapicClient $gapicClient, @@ -137,9 +138,9 @@ public function readAll() if ($completed !== true) { $stream = call_user_func_array( - [$this->gapicClient, $this->method], - [$this->request, $this->optionalArgs] - ); + [$this->gapicClient, $this->method], + [$this->request, $this->optionalArgs] + ); try { foreach ($stream->readAll() as $item) { diff --git a/Bigtable/src/Table.php b/Bigtable/src/Table.php index 56580a098bd..2fbf2ab8b57 100644 --- a/Bigtable/src/Table.php +++ b/Bigtable/src/Table.php @@ -530,9 +530,9 @@ public function checkAndMutateRow($rowKey, array $options = []) $request = $this->serializer->decodeMessage(new CheckAndMutateRowRequest, $data); return $this->gapicClient->checkAndMutateRow( - $request, - $optionalArgs + $this->options - )->getPredicateMatched(); + $request, + $optionalArgs + $this->options + )->getPredicateMatched(); } private function mutateRowsWithEntries(array $entries, array $options = []) diff --git a/Bigtable/tests/Snippet/TableTest.php b/Bigtable/tests/Snippet/TableTest.php index 8c201756e28..cc477087ceb 100644 --- a/Bigtable/tests/Snippet/TableTest.php +++ b/Bigtable/tests/Snippet/TableTest.php @@ -217,7 +217,7 @@ public function testReadRowsWithRowRanges() $rowSet = (new RowSet()) ->setRowRanges([$rowRange]); $this->bigtableClient->readRows( - Argument::that(function($request) use($rowSet) { + Argument::that(function ($request) use ($rowSet) { return $request->getRows()->serializeToJsonString() === $rowSet->serializeToJsonString(); }), Argument::type('array') @@ -252,7 +252,7 @@ public function testReadRow() $rowSet = (new RowSet()) ->setRowKeys(['jefferson']); $this->bigtableClient->readRows( - Argument::that(function($request) use($rowSet) { + Argument::that(function ($request) use ($rowSet) { return $request->getRows()->serializeToJsonString() === $rowSet->serializeToJsonString(); }), Argument::type('array') diff --git a/Bigtable/tests/Snippet/bootstrap.php b/Bigtable/tests/Snippet/bootstrap.php index c2b7a4db9e2..6e92c03c697 100644 --- a/Bigtable/tests/Snippet/bootstrap.php +++ b/Bigtable/tests/Snippet/bootstrap.php @@ -9,4 +9,4 @@ BypassFinals::enable(); -include_once(__DIR__ . '/../../vendor/google/cloud-core/snippet-bootstrap.php'); \ No newline at end of file +include_once(__DIR__ . '/../../vendor/google/cloud-core/snippet-bootstrap.php'); diff --git a/Bigtable/tests/Unit/SmartRetriesTest.php b/Bigtable/tests/Unit/SmartRetriesTest.php index f4fb0c91b60..f6c52136da1 100644 --- a/Bigtable/tests/Unit/SmartRetriesTest.php +++ b/Bigtable/tests/Unit/SmartRetriesTest.php @@ -189,7 +189,7 @@ public function testReadRowsWithRowsLimit() $allowedRowsLimit = ['5' => 1, '3' => 1]; $this->bigtableClient->readRows( - Argument::that(function($request) use(&$allowedRowsLimit) { + Argument::that(function ($request) use (&$allowedRowsLimit) { $rowsLimit = $request->getRowsLimit(); if (!isset($allowedRowsLimit[$rowsLimit]) || $allowedRowsLimit[$rowsLimit] == 0) { return false; @@ -231,7 +231,7 @@ public function testReadRowsWithRowKeys() ); $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { return iterator_to_array($request->getRows()->getRowKeys()) === ['rk1', 'rk2', 'rk3', 'rk4']; }), Argument::type('array') @@ -241,7 +241,7 @@ public function testReadRowsWithRowKeys() ); $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { return iterator_to_array($request->getRows()->getRowKeys()) === ['rk3', 'rk4']; }), Argument::type('array') @@ -273,7 +273,7 @@ public function testReadRowsRangeStartKeyOpen() ); $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === 'rk5'; }), Argument::type('array') @@ -283,7 +283,7 @@ public function testReadRowsRangeStartKeyOpen() ); $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === 'rk7'; }), Argument::type('array') @@ -318,7 +318,7 @@ public function testReadRowsRangeStartKeyClosed() ); $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { return $request->getRows()->getRowRanges()[0]->getStartKeyClosed() === 'rk5'; }), Argument::type('array') @@ -328,7 +328,7 @@ public function testReadRowsRangeStartKeyClosed() ); $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === 'rk6'; }), Argument::type('array') @@ -363,7 +363,7 @@ public function testReadRowsRangeEndKeyOpen() ); $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === '' && $request->getRows()->getRowRanges()[0]->getEndKeyOpen() === 'rk7'; }), @@ -374,7 +374,7 @@ public function testReadRowsRangeEndKeyOpen() ); $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === 'rk3' && $request->getRows()->getRowRanges()[0]->getEndKeyOpen() === 'rk7'; }), @@ -411,7 +411,7 @@ public function testReadRowsRangeEndKeyClosed() ); $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === '' && $request->getRows()->getRowRanges()[0]->getEndKeyClosed() === 'rk7'; }), @@ -422,7 +422,7 @@ public function testReadRowsRangeEndKeyClosed() ); $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { return $request->getRows()->getRowRanges()[0]->getStartKeyOpen() === 'rk3' && $request->getRows()->getRowRanges()[0]->getEndKeyClosed() === 'rk7'; }), @@ -464,7 +464,7 @@ public function testReadRowsRangeWithSomeCompletedRange() ); $this->bigtableClient->readRows( - Argument::that(function($request) use($expectedRows) { + Argument::that(function ($request) use ($expectedRows) { return $request->getRows()->serializeToJsonString() === $expectedRows->serializeToJsonString(); }), Argument::type('array') @@ -479,7 +479,7 @@ public function testReadRowsRangeWithSomeCompletedRange() ]); $this->bigtableClient->readRows( - Argument::that(function($request) use($expectedRows2) { + Argument::that(function ($request) use ($expectedRows2) { return $request->getRows()->serializeToJsonString() === $expectedRows2->serializeToJsonString(); }), Argument::type('array') @@ -515,7 +515,7 @@ public function testReadRowsWithRetryableErrorAfterAllDataReceived() // First Call // Check if the request has expected row range $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { $rowRanges = $request->getRows()->getRowRanges(); if (count($rowRanges) === 0) { return false; @@ -534,7 +534,7 @@ public function testReadRowsWithRetryableErrorAfterAllDataReceived() // Check if the request has empty row range and fail the test // as this will result in full table scan $this->bigtableClient->readRows( - Argument::that(function($request) { + Argument::that(function ($request) { $rowRanges = $request->getRows()->getRowRanges(); return !count($rowRanges); }), @@ -612,7 +612,7 @@ public function testMutateRowsOnlyRetriesFailedEntries() ); $entries = $this->generateEntries(0, 5); $this->bigtableClient->mutateRows( - Argument::that(function($request) use($entries) { + Argument::that(function ($request) use ($entries) { return iterator_to_array($request->getEntries()) == $entries; }), Argument::type('array') @@ -622,7 +622,7 @@ public function testMutateRowsOnlyRetriesFailedEntries() ); $entries = $this->generateEntries(2, 3); $this->bigtableClient->mutateRows( - Argument::that(function($request) use($entries) { + Argument::that(function ($request) use ($entries) { return iterator_to_array($request->getEntries()) == $entries; }), Argument::type('array') @@ -649,7 +649,7 @@ public function testMutateRowsExceptionShouldAddEntryToPendingMutations() ); $entries = $this->generateEntries(0, 5); $this->bigtableClient->mutateRows( - Argument::that(function($request) use($entries) { + Argument::that(function ($request) use ($entries) { return iterator_to_array($request->getEntries()) == $entries; }), Argument::type('array') @@ -659,7 +659,7 @@ public function testMutateRowsExceptionShouldAddEntryToPendingMutations() ); $entries = array_merge($this->generateEntries(1, 2), $this->generateEntries(4, 5)); $this->bigtableClient->mutateRows( - Argument::that(function($request) use($entries) { + Argument::that(function ($request) use ($entries) { return iterator_to_array($request->getEntries()) == $entries; }), Argument::type('array') @@ -698,7 +698,7 @@ public function testMutateRowsShouldNotRetryIfAnyMutationIsNotRetryable() ); $entries = $this->generateEntries(0, 7); $this->bigtableClient->mutateRows( - Argument::that(function($request) use($entries) { + Argument::that(function ($request) use ($entries) { return iterator_to_array($request->getEntries()) == $entries; }), Argument::type('array') diff --git a/Bigtable/tests/Unit/bootstrap.php b/Bigtable/tests/Unit/bootstrap.php index 7f6d31fa9c7..743a917983d 100644 --- a/Bigtable/tests/Unit/bootstrap.php +++ b/Bigtable/tests/Unit/bootstrap.php @@ -7,4 +7,4 @@ '*/src/V2/Client/*', ]); -BypassFinals::enable(); \ No newline at end of file +BypassFinals::enable(); From 4d09967e8c6f82d8f6592046911b4698f74101e3 Mon Sep 17 00:00:00 2001 From: Saransh Dhingra Date: Thu, 23 May 2024 07:09:27 +0000 Subject: [PATCH 20/36] Added 'final' class bypassing in Core's bootstrap file --- Core/unit-bootstrap.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/unit-bootstrap.php b/Core/unit-bootstrap.php index 4fc30215b3d..222f62288f7 100644 --- a/Core/unit-bootstrap.php +++ b/Core/unit-bootstrap.php @@ -3,8 +3,12 @@ use Google\ApiCore\Testing\MessageAwareArrayComparator; use Google\ApiCore\Testing\ProtobufMessageComparator; use Google\ApiCore\Testing\ProtobufGPBEmptyComparator; +use DG\BypassFinals; date_default_timezone_set('UTC'); \SebastianBergmann\Comparator\Factory::getInstance()->register(new MessageAwareArrayComparator()); \SebastianBergmann\Comparator\Factory::getInstance()->register(new ProtobufMessageComparator()); \SebastianBergmann\Comparator\Factory::getInstance()->register(new ProtobufGPBEmptyComparator()); + +// Make sure that while testing we bypass the `final` keyword for the GAPIC client. +BypassFinals::enable(); From d643732b165c261774521ac127c326718770739e Mon Sep 17 00:00:00 2001 From: Saransh Dhingra Date: Thu, 23 May 2024 07:11:20 +0000 Subject: [PATCH 21/36] Added the bypass-finals package in root composer.json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a1945c92a16..87c0ca4eee2 100644 --- a/composer.json +++ b/composer.json @@ -64,7 +64,8 @@ "flix-tech/avro-php": "^5.0.0", "phpspec/prophecy-phpunit": "^2.1", "kreait/firebase-php": "^6.9", - "psr/log": "^2.0||^3.0" + "psr/log": "^2.0||^3.0", + "dg/bypass-finals": "^1.7" }, "conflict": { "psr/log": ">=3" From 6198f82628e2f6f1d8976cabb42358b4fe6d8e00 Mon Sep 17 00:00:00 2001 From: Saransh Dhingra Date: Thu, 23 May 2024 07:37:11 +0000 Subject: [PATCH 22/36] Added 'final' class bypassing in Core's snippet-bootstrap file --- Core/snippet-bootstrap.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/snippet-bootstrap.php b/Core/snippet-bootstrap.php index b53df247d3c..dcbba262e33 100644 --- a/Core/snippet-bootstrap.php +++ b/Core/snippet-bootstrap.php @@ -1,7 +1,11 @@ Date: Thu, 23 May 2024 08:23:45 +0000 Subject: [PATCH 23/36] Fix for the package tests --- Core/snippet-bootstrap.php | 5 ++++- Core/unit-bootstrap.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Core/snippet-bootstrap.php b/Core/snippet-bootstrap.php index dcbba262e33..156f1a32222 100644 --- a/Core/snippet-bootstrap.php +++ b/Core/snippet-bootstrap.php @@ -8,4 +8,7 @@ date_default_timezone_set('UTC'); // Make sure that while testing we bypass the `final` keyword for the GAPIC client. -BypassFinals::enable(); +// Only run this if the individual component has the helper package installed +if (class_exists(BypassFinals::class)) { + BypassFinals::enable(); +} diff --git a/Core/unit-bootstrap.php b/Core/unit-bootstrap.php index 222f62288f7..864cd943679 100644 --- a/Core/unit-bootstrap.php +++ b/Core/unit-bootstrap.php @@ -11,4 +11,7 @@ \SebastianBergmann\Comparator\Factory::getInstance()->register(new ProtobufGPBEmptyComparator()); // Make sure that while testing we bypass the `final` keyword for the GAPIC client. -BypassFinals::enable(); +// Only run this if the individual component has the helper package installed +if (class_exists(BypassFinals::class)) { + BypassFinals::enable(); +} From 476b811b017947e1b167ae23d22e01ab6f303c00 Mon Sep 17 00:00:00 2001 From: Saransh Dhingra Date: Thu, 23 May 2024 09:18:06 +0000 Subject: [PATCH 24/36] Bump cloud-core version in composer.json --- Bigtable/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bigtable/composer.json b/Bigtable/composer.json index 10f357195ef..9f27be00352 100644 --- a/Bigtable/composer.json +++ b/Bigtable/composer.json @@ -6,7 +6,7 @@ "require": { "php": "^8.0", "google/gax": "^1.30", - "google/cloud-core": "^1.52.7" + "google/cloud-core": "^1.55" }, "require-dev": { "phpunit/phpunit": "^9.0", From 24765e6071f075738d13360b8fbdfa666be612e3 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Fri, 24 May 2024 15:05:58 +0530 Subject: [PATCH 25/36] Change bootstrap file for snippet tests --- Bigtable/phpunit-snippets.xml.dist | 2 +- Bigtable/tests/Snippet/bootstrap.php | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 Bigtable/tests/Snippet/bootstrap.php diff --git a/Bigtable/phpunit-snippets.xml.dist b/Bigtable/phpunit-snippets.xml.dist index 85b08c90f19..e8f38489b71 100644 --- a/Bigtable/phpunit-snippets.xml.dist +++ b/Bigtable/phpunit-snippets.xml.dist @@ -1,5 +1,5 @@ - + src diff --git a/Bigtable/tests/Snippet/bootstrap.php b/Bigtable/tests/Snippet/bootstrap.php deleted file mode 100644 index 6e92c03c697..00000000000 --- a/Bigtable/tests/Snippet/bootstrap.php +++ /dev/null @@ -1,12 +0,0 @@ - Date: Fri, 24 May 2024 15:06:38 +0530 Subject: [PATCH 26/36] Removed V1 GAPIC surface clients --- .../Admin/V2/BigtableInstanceAdminClient.php | 45 - .../V2/BigtableInstanceAdminGrpcClient.php | 385 --- .../src/Admin/V2/BigtableTableAdminClient.php | 45 - .../Admin/V2/BigtableTableAdminGrpcClient.php | 461 --- .../BigtableInstanceAdminGapicClient.php | 1768 ------------ .../Gapic/BigtableTableAdminGapicClient.php | 2512 ----------------- Bigtable/src/V2/BigtableClient.php | 46 - Bigtable/src/V2/BigtableGrpcClient.php | 191 -- Bigtable/src/V2/Gapic/BigtableGapicClient.php | 1090 ------- 9 files changed, 6543 deletions(-) delete mode 100644 Bigtable/src/Admin/V2/BigtableInstanceAdminClient.php delete mode 100644 Bigtable/src/Admin/V2/BigtableInstanceAdminGrpcClient.php delete mode 100644 Bigtable/src/Admin/V2/BigtableTableAdminClient.php delete mode 100644 Bigtable/src/Admin/V2/BigtableTableAdminGrpcClient.php delete mode 100644 Bigtable/src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php delete mode 100644 Bigtable/src/Admin/V2/Gapic/BigtableTableAdminGapicClient.php delete mode 100644 Bigtable/src/V2/BigtableClient.php delete mode 100644 Bigtable/src/V2/BigtableGrpcClient.php delete mode 100644 Bigtable/src/V2/Gapic/BigtableGapicClient.php diff --git a/Bigtable/src/Admin/V2/BigtableInstanceAdminClient.php b/Bigtable/src/Admin/V2/BigtableInstanceAdminClient.php deleted file mode 100644 index d1e24181ade..00000000000 --- a/Bigtable/src/Admin/V2/BigtableInstanceAdminClient.php +++ /dev/null @@ -1,45 +0,0 @@ -_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/CreateInstance', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Gets information about an instance. - * @param \Google\Cloud\Bigtable\Admin\V2\GetInstanceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetInstance(\Google\Cloud\Bigtable\Admin\V2\GetInstanceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/GetInstance', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\Instance', 'decode'], - $metadata, $options); - } - - /** - * Lists information about instances in a project. - * @param \Google\Cloud\Bigtable\Admin\V2\ListInstancesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListInstances(\Google\Cloud\Bigtable\Admin\V2\ListInstancesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/ListInstances', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\ListInstancesResponse', 'decode'], - $metadata, $options); - } - - /** - * Updates an instance within a project. This method updates only the display - * name and type for an Instance. To update other Instance properties, such as - * labels, use PartialUpdateInstance. - * @param \Google\Cloud\Bigtable\Admin\V2\Instance $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateInstance(\Google\Cloud\Bigtable\Admin\V2\Instance $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/UpdateInstance', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\Instance', 'decode'], - $metadata, $options); - } - - /** - * Partially updates an instance within a project. This method can modify all - * fields of an Instance and is the preferred way to update an Instance. - * @param \Google\Cloud\Bigtable\Admin\V2\PartialUpdateInstanceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function PartialUpdateInstance(\Google\Cloud\Bigtable\Admin\V2\PartialUpdateInstanceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/PartialUpdateInstance', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Delete an instance from a project. - * @param \Google\Cloud\Bigtable\Admin\V2\DeleteInstanceRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteInstance(\Google\Cloud\Bigtable\Admin\V2\DeleteInstanceRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/DeleteInstance', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Creates a cluster within an instance. - * - * Note that exactly one of Cluster.serve_nodes and - * Cluster.cluster_config.cluster_autoscaling_config can be set. If - * serve_nodes is set to non-zero, then the cluster is manually scaled. If - * cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is - * enabled. - * @param \Google\Cloud\Bigtable\Admin\V2\CreateClusterRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateCluster(\Google\Cloud\Bigtable\Admin\V2\CreateClusterRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/CreateCluster', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Gets information about a cluster. - * @param \Google\Cloud\Bigtable\Admin\V2\GetClusterRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetCluster(\Google\Cloud\Bigtable\Admin\V2\GetClusterRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/GetCluster', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\Cluster', 'decode'], - $metadata, $options); - } - - /** - * Lists information about clusters in an instance. - * @param \Google\Cloud\Bigtable\Admin\V2\ListClustersRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListClusters(\Google\Cloud\Bigtable\Admin\V2\ListClustersRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/ListClusters', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\ListClustersResponse', 'decode'], - $metadata, $options); - } - - /** - * Updates a cluster within an instance. - * - * Note that UpdateCluster does not support updating - * cluster_config.cluster_autoscaling_config. In order to update it, you - * must use PartialUpdateCluster. - * @param \Google\Cloud\Bigtable\Admin\V2\Cluster $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateCluster(\Google\Cloud\Bigtable\Admin\V2\Cluster $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/UpdateCluster', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Partially updates a cluster within a project. This method is the preferred - * way to update a Cluster. - * - * To enable and update autoscaling, set - * cluster_config.cluster_autoscaling_config. When autoscaling is enabled, - * serve_nodes is treated as an OUTPUT_ONLY field, meaning that updates to it - * are ignored. Note that an update cannot simultaneously set serve_nodes to - * non-zero and cluster_config.cluster_autoscaling_config to non-empty, and - * also specify both in the update_mask. - * - * To disable autoscaling, clear cluster_config.cluster_autoscaling_config, - * and explicitly set a serve_node count via the update_mask. - * @param \Google\Cloud\Bigtable\Admin\V2\PartialUpdateClusterRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function PartialUpdateCluster(\Google\Cloud\Bigtable\Admin\V2\PartialUpdateClusterRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/PartialUpdateCluster', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Deletes a cluster from an instance. - * @param \Google\Cloud\Bigtable\Admin\V2\DeleteClusterRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteCluster(\Google\Cloud\Bigtable\Admin\V2\DeleteClusterRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/DeleteCluster', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Creates an app profile within an instance. - * @param \Google\Cloud\Bigtable\Admin\V2\CreateAppProfileRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateAppProfile(\Google\Cloud\Bigtable\Admin\V2\CreateAppProfileRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/CreateAppProfile', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\AppProfile', 'decode'], - $metadata, $options); - } - - /** - * Gets information about an app profile. - * @param \Google\Cloud\Bigtable\Admin\V2\GetAppProfileRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetAppProfile(\Google\Cloud\Bigtable\Admin\V2\GetAppProfileRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/GetAppProfile', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\AppProfile', 'decode'], - $metadata, $options); - } - - /** - * Lists information about app profiles in an instance. - * @param \Google\Cloud\Bigtable\Admin\V2\ListAppProfilesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListAppProfiles(\Google\Cloud\Bigtable\Admin\V2\ListAppProfilesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/ListAppProfiles', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\ListAppProfilesResponse', 'decode'], - $metadata, $options); - } - - /** - * Updates an app profile within an instance. - * @param \Google\Cloud\Bigtable\Admin\V2\UpdateAppProfileRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateAppProfile(\Google\Cloud\Bigtable\Admin\V2\UpdateAppProfileRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/UpdateAppProfile', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Deletes an app profile from an instance. - * @param \Google\Cloud\Bigtable\Admin\V2\DeleteAppProfileRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteAppProfile(\Google\Cloud\Bigtable\Admin\V2\DeleteAppProfileRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/DeleteAppProfile', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Gets the access control policy for an instance resource. Returns an empty - * policy if an instance exists but does not have a policy set. - * @param \Google\Cloud\Iam\V1\GetIamPolicyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetIamPolicy(\Google\Cloud\Iam\V1\GetIamPolicyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/GetIamPolicy', - $argument, - ['\Google\Cloud\Iam\V1\Policy', 'decode'], - $metadata, $options); - } - - /** - * Sets the access control policy on an instance resource. Replaces any - * existing policy. - * @param \Google\Cloud\Iam\V1\SetIamPolicyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function SetIamPolicy(\Google\Cloud\Iam\V1\SetIamPolicyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/SetIamPolicy', - $argument, - ['\Google\Cloud\Iam\V1\Policy', 'decode'], - $metadata, $options); - } - - /** - * Returns permissions that the caller has on the specified instance resource. - * @param \Google\Cloud\Iam\V1\TestIamPermissionsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function TestIamPermissions(\Google\Cloud\Iam\V1\TestIamPermissionsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/TestIamPermissions', - $argument, - ['\Google\Cloud\Iam\V1\TestIamPermissionsResponse', 'decode'], - $metadata, $options); - } - - /** - * Lists hot tablets in a cluster, within the time range provided. Hot - * tablets are ordered based on CPU usage. - * @param \Google\Cloud\Bigtable\Admin\V2\ListHotTabletsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListHotTablets(\Google\Cloud\Bigtable\Admin\V2\ListHotTabletsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableInstanceAdmin/ListHotTablets', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\ListHotTabletsResponse', 'decode'], - $metadata, $options); - } - -} diff --git a/Bigtable/src/Admin/V2/BigtableTableAdminClient.php b/Bigtable/src/Admin/V2/BigtableTableAdminClient.php deleted file mode 100644 index 0b35aa6938f..00000000000 --- a/Bigtable/src/Admin/V2/BigtableTableAdminClient.php +++ /dev/null @@ -1,45 +0,0 @@ -_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/CreateTable', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\Table', 'decode'], - $metadata, $options); - } - - /** - * Creates a new table from the specified snapshot. The target table must - * not exist. The snapshot and the table must be in the same instance. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * @param \Google\Cloud\Bigtable\Admin\V2\CreateTableFromSnapshotRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateTableFromSnapshot(\Google\Cloud\Bigtable\Admin\V2\CreateTableFromSnapshotRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/CreateTableFromSnapshot', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Lists all tables served from a specified instance. - * @param \Google\Cloud\Bigtable\Admin\V2\ListTablesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListTables(\Google\Cloud\Bigtable\Admin\V2\ListTablesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/ListTables', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\ListTablesResponse', 'decode'], - $metadata, $options); - } - - /** - * Gets metadata information about the specified table. - * @param \Google\Cloud\Bigtable\Admin\V2\GetTableRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetTable(\Google\Cloud\Bigtable\Admin\V2\GetTableRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/GetTable', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\Table', 'decode'], - $metadata, $options); - } - - /** - * Updates a specified table. - * @param \Google\Cloud\Bigtable\Admin\V2\UpdateTableRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateTable(\Google\Cloud\Bigtable\Admin\V2\UpdateTableRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/UpdateTable', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Permanently deletes a specified table and all of its data. - * @param \Google\Cloud\Bigtable\Admin\V2\DeleteTableRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteTable(\Google\Cloud\Bigtable\Admin\V2\DeleteTableRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/DeleteTable', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Restores a specified table which was accidentally deleted. - * @param \Google\Cloud\Bigtable\Admin\V2\UndeleteTableRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UndeleteTable(\Google\Cloud\Bigtable\Admin\V2\UndeleteTableRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/UndeleteTable', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Performs a series of column family modifications on the specified table. - * Either all or none of the modifications will occur before this method - * returns, but data requests received prior to that point may see a table - * where only some modifications have taken effect. - * @param \Google\Cloud\Bigtable\Admin\V2\ModifyColumnFamiliesRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ModifyColumnFamilies(\Google\Cloud\Bigtable\Admin\V2\ModifyColumnFamiliesRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/ModifyColumnFamilies', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\Table', 'decode'], - $metadata, $options); - } - - /** - * Permanently drop/delete a row range from a specified table. The request can - * specify whether to delete all rows in a table, or only those that match a - * particular prefix. - * @param \Google\Cloud\Bigtable\Admin\V2\DropRowRangeRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DropRowRange(\Google\Cloud\Bigtable\Admin\V2\DropRowRangeRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/DropRowRange', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Generates a consistency token for a Table, which can be used in - * CheckConsistency to check whether mutations to the table that finished - * before this call started have been replicated. The tokens will be available - * for 90 days. - * @param \Google\Cloud\Bigtable\Admin\V2\GenerateConsistencyTokenRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GenerateConsistencyToken(\Google\Cloud\Bigtable\Admin\V2\GenerateConsistencyTokenRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/GenerateConsistencyToken', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\GenerateConsistencyTokenResponse', 'decode'], - $metadata, $options); - } - - /** - * Checks replication consistency based on a consistency token, that is, if - * replication has caught up based on the conditions specified in the token - * and the check request. - * @param \Google\Cloud\Bigtable\Admin\V2\CheckConsistencyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CheckConsistency(\Google\Cloud\Bigtable\Admin\V2\CheckConsistencyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/CheckConsistency', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\CheckConsistencyResponse', 'decode'], - $metadata, $options); - } - - /** - * Creates a new snapshot in the specified cluster from the specified - * source table. The cluster and the table must be in the same instance. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * @param \Google\Cloud\Bigtable\Admin\V2\SnapshotTableRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function SnapshotTable(\Google\Cloud\Bigtable\Admin\V2\SnapshotTableRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/SnapshotTable', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Gets metadata information about the specified snapshot. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * @param \Google\Cloud\Bigtable\Admin\V2\GetSnapshotRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetSnapshot(\Google\Cloud\Bigtable\Admin\V2\GetSnapshotRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/GetSnapshot', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\Snapshot', 'decode'], - $metadata, $options); - } - - /** - * Lists all snapshots associated with the specified cluster. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * @param \Google\Cloud\Bigtable\Admin\V2\ListSnapshotsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListSnapshots(\Google\Cloud\Bigtable\Admin\V2\ListSnapshotsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/ListSnapshots', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\ListSnapshotsResponse', 'decode'], - $metadata, $options); - } - - /** - * Permanently deletes the specified snapshot. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * @param \Google\Cloud\Bigtable\Admin\V2\DeleteSnapshotRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteSnapshot(\Google\Cloud\Bigtable\Admin\V2\DeleteSnapshotRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/DeleteSnapshot', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Starts creating a new Cloud Bigtable Backup. The returned backup - * [long-running operation][google.longrunning.Operation] can be used to - * track creation of the backup. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [CreateBackupMetadata][google.bigtable.admin.v2.CreateBackupMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Backup][google.bigtable.admin.v2.Backup], if successful. Cancelling the returned operation will stop the - * creation and delete the backup. - * @param \Google\Cloud\Bigtable\Admin\V2\CreateBackupRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CreateBackup(\Google\Cloud\Bigtable\Admin\V2\CreateBackupRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/CreateBackup', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Gets metadata on a pending or completed Cloud Bigtable Backup. - * @param \Google\Cloud\Bigtable\Admin\V2\GetBackupRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetBackup(\Google\Cloud\Bigtable\Admin\V2\GetBackupRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/GetBackup', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\Backup', 'decode'], - $metadata, $options); - } - - /** - * Updates a pending or completed Cloud Bigtable Backup. - * @param \Google\Cloud\Bigtable\Admin\V2\UpdateBackupRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function UpdateBackup(\Google\Cloud\Bigtable\Admin\V2\UpdateBackupRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/UpdateBackup', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\Backup', 'decode'], - $metadata, $options); - } - - /** - * Deletes a pending or completed Cloud Bigtable backup. - * @param \Google\Cloud\Bigtable\Admin\V2\DeleteBackupRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function DeleteBackup(\Google\Cloud\Bigtable\Admin\V2\DeleteBackupRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/DeleteBackup', - $argument, - ['\Google\Protobuf\GPBEmpty', 'decode'], - $metadata, $options); - } - - /** - * Lists Cloud Bigtable backups. Returns both completed and pending - * backups. - * @param \Google\Cloud\Bigtable\Admin\V2\ListBackupsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ListBackups(\Google\Cloud\Bigtable\Admin\V2\ListBackupsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/ListBackups', - $argument, - ['\Google\Cloud\Bigtable\Admin\V2\ListBackupsResponse', 'decode'], - $metadata, $options); - } - - /** - * Create a new table by restoring from a completed backup. The new table - * must be in the same project as the instance containing the backup. The - * returned table [long-running operation][google.longrunning.Operation] can - * be used to track the progress of the operation, and to cancel it. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [RestoreTableMetadata][google.bigtable.admin.RestoreTableMetadata]. The - * [response][google.longrunning.Operation.response] type is - * [Table][google.bigtable.admin.v2.Table], if successful. - * @param \Google\Cloud\Bigtable\Admin\V2\RestoreTableRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function RestoreTable(\Google\Cloud\Bigtable\Admin\V2\RestoreTableRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/RestoreTable', - $argument, - ['\Google\LongRunning\Operation', 'decode'], - $metadata, $options); - } - - /** - * Gets the access control policy for a Table or Backup resource. - * Returns an empty policy if the resource exists but does not have a policy - * set. - * @param \Google\Cloud\Iam\V1\GetIamPolicyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function GetIamPolicy(\Google\Cloud\Iam\V1\GetIamPolicyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/GetIamPolicy', - $argument, - ['\Google\Cloud\Iam\V1\Policy', 'decode'], - $metadata, $options); - } - - /** - * Sets the access control policy on a Table or Backup resource. - * Replaces any existing policy. - * @param \Google\Cloud\Iam\V1\SetIamPolicyRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function SetIamPolicy(\Google\Cloud\Iam\V1\SetIamPolicyRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/SetIamPolicy', - $argument, - ['\Google\Cloud\Iam\V1\Policy', 'decode'], - $metadata, $options); - } - - /** - * Returns permissions that the caller has on the specified Table or Backup resource. - * @param \Google\Cloud\Iam\V1\TestIamPermissionsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function TestIamPermissions(\Google\Cloud\Iam\V1\TestIamPermissionsRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.admin.v2.BigtableTableAdmin/TestIamPermissions', - $argument, - ['\Google\Cloud\Iam\V1\TestIamPermissionsResponse', 'decode'], - $metadata, $options); - } - -} diff --git a/Bigtable/src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php b/Bigtable/src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php deleted file mode 100644 index 432d9accaff..00000000000 --- a/Bigtable/src/Admin/V2/Gapic/BigtableInstanceAdminGapicClient.php +++ /dev/null @@ -1,1768 +0,0 @@ -instanceName('[PROJECT]', '[INSTANCE]'); - * $appProfileId = 'app_profile_id'; - * $appProfile = new Google\Cloud\Bigtable\Admin\V2\AppProfile(); - * $response = $bigtableInstanceAdminClient->createAppProfile($formattedParent, $appProfileId, $appProfile); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * Many parameters require resource names to be formatted in a particular way. To - * assist with these names, this class includes a format method for each type of - * name, and additionally a parseName method to extract the individual identifiers - * contained within formatted names that are returned by the API. - * - * @deprecated Please use the new service client {@see \Google\Cloud\Bigtable\Admin\V2\Client\BigtableInstanceAdminClient}. - */ -class BigtableInstanceAdminGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.bigtable.admin.v2.BigtableInstanceAdmin'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'bigtableadmin.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'bigtableadmin.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/bigtable.admin', - 'https://www.googleapis.com/auth/bigtable.admin.cluster', - 'https://www.googleapis.com/auth/bigtable.admin.instance', - 'https://www.googleapis.com/auth/cloud-bigtable.admin', - 'https://www.googleapis.com/auth/cloud-bigtable.admin.cluster', - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - ]; - - private static $appProfileNameTemplate; - - private static $clusterNameTemplate; - - private static $cryptoKeyNameTemplate; - - private static $instanceNameTemplate; - - private static $locationNameTemplate; - - private static $projectNameTemplate; - - private static $pathTemplateMap; - - private $operationsClient; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/bigtable_instance_admin_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/bigtable_instance_admin_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/bigtable_instance_admin_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/bigtable_instance_admin_rest_client_config.php', - ], - ], - ]; - } - - private static function getAppProfileNameTemplate() - { - if (self::$appProfileNameTemplate == null) { - self::$appProfileNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/appProfiles/{app_profile}'); - } - - return self::$appProfileNameTemplate; - } - - private static function getClusterNameTemplate() - { - if (self::$clusterNameTemplate == null) { - self::$clusterNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/clusters/{cluster}'); - } - - return self::$clusterNameTemplate; - } - - private static function getCryptoKeyNameTemplate() - { - if (self::$cryptoKeyNameTemplate == null) { - self::$cryptoKeyNameTemplate = new PathTemplate('projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}'); - } - - return self::$cryptoKeyNameTemplate; - } - - private static function getInstanceNameTemplate() - { - if (self::$instanceNameTemplate == null) { - self::$instanceNameTemplate = new PathTemplate('projects/{project}/instances/{instance}'); - } - - return self::$instanceNameTemplate; - } - - private static function getLocationNameTemplate() - { - if (self::$locationNameTemplate == null) { - self::$locationNameTemplate = new PathTemplate('projects/{project}/locations/{location}'); - } - - return self::$locationNameTemplate; - } - - private static function getProjectNameTemplate() - { - if (self::$projectNameTemplate == null) { - self::$projectNameTemplate = new PathTemplate('projects/{project}'); - } - - return self::$projectNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'appProfile' => self::getAppProfileNameTemplate(), - 'cluster' => self::getClusterNameTemplate(), - 'cryptoKey' => self::getCryptoKeyNameTemplate(), - 'instance' => self::getInstanceNameTemplate(), - 'location' => self::getLocationNameTemplate(), - 'project' => self::getProjectNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a app_profile - * resource. - * - * @param string $project - * @param string $instance - * @param string $appProfile - * - * @return string The formatted app_profile resource. - */ - public static function appProfileName($project, $instance, $appProfile) - { - return self::getAppProfileNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - 'app_profile' => $appProfile, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a cluster - * resource. - * - * @param string $project - * @param string $instance - * @param string $cluster - * - * @return string The formatted cluster resource. - */ - public static function clusterName($project, $instance, $cluster) - { - return self::getClusterNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a crypto_key - * resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * - * @return string The formatted crypto_key resource. - */ - public static function cryptoKeyName($project, $location, $keyRing, $cryptoKey) - { - return self::getCryptoKeyNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName($project, $instance) - { - return self::getInstanceNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a location - * resource. - * - * @param string $project - * @param string $location - * - * @return string The formatted location resource. - */ - public static function locationName($project, $location) - { - return self::getLocationNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a project - * resource. - * - * @param string $project - * - * @return string The formatted project resource. - */ - public static function projectName($project) - { - return self::getProjectNameTemplate()->render([ - 'project' => $project, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - appProfile: projects/{project}/instances/{instance}/appProfiles/{app_profile} - * - cluster: projects/{project}/instances/{instance}/clusters/{cluster} - * - cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key} - * - instance: projects/{project}/instances/{instance} - * - location: projects/{project}/locations/{location} - * - project: projects/{project} - * - * 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. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * 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. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'bigtableadmin.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * 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 - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * 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. - * @type string|TransportInterface $transport - * 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 {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * 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 {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * 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. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Creates an app profile within an instance. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedParent = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); - * $appProfileId = 'app_profile_id'; - * $appProfile = new Google\Cloud\Bigtable\Admin\V2\AppProfile(); - * $response = $bigtableInstanceAdminClient->createAppProfile($formattedParent, $appProfileId, $appProfile); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique name of the instance in which to create the new app - * profile. Values are of the form `projects/{project}/instances/{instance}`. - * @param string $appProfileId Required. The ID to be used when referring to the new app profile within - * its instance, e.g., just `myprofile` rather than - * `projects/myproject/instances/myinstance/appProfiles/myprofile`. - * @param AppProfile $appProfile Required. The app profile to be created. - * Fields marked `OutputOnly` will be ignored. - * @param array $optionalArgs { - * Optional. - * - * @type bool $ignoreWarnings - * If true, ignore safety checks when creating the app profile. - * @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\Bigtable\Admin\V2\AppProfile - * - * @throws ApiException if the remote call fails - */ - public function createAppProfile($parent, $appProfileId, $appProfile, array $optionalArgs = []) - { - $request = new CreateAppProfileRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setAppProfileId($appProfileId); - $request->setAppProfile($appProfile); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['ignoreWarnings'])) { - $request->setIgnoreWarnings($optionalArgs['ignoreWarnings']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateAppProfile', AppProfile::class, $optionalArgs, $request)->wait(); - } - - /** - * Creates a cluster within an instance. - * - * Note that exactly one of Cluster.serve_nodes and - * Cluster.cluster_config.cluster_autoscaling_config can be set. If - * serve_nodes is set to non-zero, then the cluster is manually scaled. If - * cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is - * enabled. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedParent = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); - * $clusterId = 'cluster_id'; - * $cluster = new Google\Cloud\Bigtable\Admin\V2\Cluster(); - * $operationResponse = $bigtableInstanceAdminClient->createCluster($formattedParent, $clusterId, $cluster); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableInstanceAdminClient->createCluster($formattedParent, $clusterId, $cluster); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableInstanceAdminClient->resumeOperation($operationName, 'createCluster'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique name of the instance in which to create the new - * cluster. Values are of the form `projects/{project}/instances/{instance}`. - * @param string $clusterId Required. The ID to be used when referring to the new cluster within its - * instance, e.g., just `mycluster` rather than - * `projects/myproject/instances/myinstance/clusters/mycluster`. - * @param Cluster $cluster Required. The cluster to be created. - * Fields marked `OutputOnly` must be left blank. - * @param array $optionalArgs { - * Optional. - * - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function createCluster($parent, $clusterId, $cluster, array $optionalArgs = []) - { - $request = new CreateClusterRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setClusterId($clusterId); - $request->setCluster($cluster); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateCluster', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Create an instance within a project. - * - * Note that exactly one of Cluster.serve_nodes and - * Cluster.cluster_config.cluster_autoscaling_config can be set. If - * serve_nodes is set to non-zero, then the cluster is manually scaled. If - * cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is - * enabled. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedParent = $bigtableInstanceAdminClient->projectName('[PROJECT]'); - * $instanceId = 'instance_id'; - * $instance = new Google\Cloud\Bigtable\Admin\V2\Instance(); - * $clusters = []; - * $operationResponse = $bigtableInstanceAdminClient->createInstance($formattedParent, $instanceId, $instance, $clusters); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableInstanceAdminClient->createInstance($formattedParent, $instanceId, $instance, $clusters); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableInstanceAdminClient->resumeOperation($operationName, 'createInstance'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique name of the project in which to create the new - * instance. Values are of the form `projects/{project}`. - * @param string $instanceId Required. The ID to be used when referring to the new instance within its - * project, e.g., just `myinstance` rather than - * `projects/myproject/instances/myinstance`. - * @param Instance $instance Required. The instance to create. - * Fields marked `OutputOnly` must be left blank. - * @param array $clusters Required. The clusters to be created within the instance, mapped by desired - * cluster ID, e.g., just `mycluster` rather than - * `projects/myproject/instances/myinstance/clusters/mycluster`. - * Fields marked `OutputOnly` must be left blank. - * Currently, at most four clusters can be specified. - * @param array $optionalArgs { - * Optional. - * - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function createInstance($parent, $instanceId, $instance, $clusters, array $optionalArgs = []) - { - $request = new CreateInstanceRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setInstanceId($instanceId); - $request->setInstance($instance); - $request->setClusters($clusters); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateInstance', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Deletes an app profile from an instance. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedName = $bigtableInstanceAdminClient->appProfileName('[PROJECT]', '[INSTANCE]', '[APP_PROFILE]'); - * $ignoreWarnings = false; - * $bigtableInstanceAdminClient->deleteAppProfile($formattedName, $ignoreWarnings); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the app profile to be deleted. Values are of - * the form - * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. - * @param bool $ignoreWarnings Required. If true, ignore safety checks when deleting the app profile. - * @param array $optionalArgs { - * Optional. - * - * @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. - * } - * - * @throws ApiException if the remote call fails - */ - public function deleteAppProfile($name, $ignoreWarnings, array $optionalArgs = []) - { - $request = new DeleteAppProfileRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setIgnoreWarnings($ignoreWarnings); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteAppProfile', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes a cluster from an instance. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedName = $bigtableInstanceAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - * $bigtableInstanceAdminClient->deleteCluster($formattedName); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the cluster to be deleted. Values are of the - * form `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param array $optionalArgs { - * Optional. - * - * @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. - * } - * - * @throws ApiException if the remote call fails - */ - public function deleteCluster($name, array $optionalArgs = []) - { - $request = new DeleteClusterRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteCluster', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Delete an instance from a project. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedName = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); - * $bigtableInstanceAdminClient->deleteInstance($formattedName); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the instance to be deleted. - * Values are of the form `projects/{project}/instances/{instance}`. - * @param array $optionalArgs { - * Optional. - * - * @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. - * } - * - * @throws ApiException if the remote call fails - */ - public function deleteInstance($name, array $optionalArgs = []) - { - $request = new DeleteInstanceRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteInstance', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about an app profile. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedName = $bigtableInstanceAdminClient->appProfileName('[PROJECT]', '[INSTANCE]', '[APP_PROFILE]'); - * $response = $bigtableInstanceAdminClient->getAppProfile($formattedName); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the requested app profile. Values are of the - * form `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. - * @param array $optionalArgs { - * Optional. - * - * @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\Bigtable\Admin\V2\AppProfile - * - * @throws ApiException if the remote call fails - */ - public function getAppProfile($name, array $optionalArgs = []) - { - $request = new GetAppProfileRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetAppProfile', AppProfile::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about a cluster. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedName = $bigtableInstanceAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - * $response = $bigtableInstanceAdminClient->getCluster($formattedName); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the requested cluster. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param array $optionalArgs { - * Optional. - * - * @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\Bigtable\Admin\V2\Cluster - * - * @throws ApiException if the remote call fails - */ - public function getCluster($name, array $optionalArgs = []) - { - $request = new GetClusterRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetCluster', Cluster::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets the access control policy for an instance resource. Returns an empty - * policy if an instance exists but does not have a policy set. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $resource = 'resource'; - * $response = $bigtableInstanceAdminClient->getIamPolicy($resource); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information about an instance. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedName = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); - * $response = $bigtableInstanceAdminClient->getInstance($formattedName); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the requested instance. Values are of the form - * `projects/{project}/instances/{instance}`. - * @param array $optionalArgs { - * Optional. - * - * @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\Bigtable\Admin\V2\Instance - * - * @throws ApiException if the remote call fails - */ - public function getInstance($name, array $optionalArgs = []) - { - $request = new GetInstanceRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetInstance', Instance::class, $optionalArgs, $request)->wait(); - } - - /** - * Lists information about app profiles in an instance. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedParent = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); - * // Iterate over pages of elements - * $pagedResponse = $bigtableInstanceAdminClient->listAppProfiles($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bigtableInstanceAdminClient->listAppProfiles($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique name of the instance for which a list of app profiles - * is requested. Values are of the form - * `projects/{project}/instances/{instance}`. - * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, - * e.g., `projects/myproject/instances/-`. - * @param array $optionalArgs { - * Optional. - * - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @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\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listAppProfiles($parent, array $optionalArgs = []) - { - $request = new ListAppProfilesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListAppProfiles', $optionalArgs, ListAppProfilesResponse::class, $request); - } - - /** - * Lists information about clusters in an instance. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedParent = $bigtableInstanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); - * $response = $bigtableInstanceAdminClient->listClusters($formattedParent); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique name of the instance for which a list of clusters is - * requested. Values are of the form - * `projects/{project}/instances/{instance}`. Use `{instance} = '-'` to list - * Clusters for all Instances in a project, e.g., - * `projects/myproject/instances/-`. - * @param array $optionalArgs { - * Optional. - * - * @type string $pageToken - * DEPRECATED: This field is unused and ignored. - * @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\Bigtable\Admin\V2\ListClustersResponse - * - * @throws ApiException if the remote call fails - */ - public function listClusters($parent, array $optionalArgs = []) - { - $request = new ListClustersRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ListClusters', ListClustersResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Lists hot tablets in a cluster, within the time range provided. Hot - * tablets are ordered based on CPU usage. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedParent = $bigtableInstanceAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - * // Iterate over pages of elements - * $pagedResponse = $bigtableInstanceAdminClient->listHotTablets($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bigtableInstanceAdminClient->listHotTablets($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The cluster name to list hot tablets. - * Value is in the following form: - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param array $optionalArgs { - * Optional. - * - * @type Timestamp $startTime - * The start time to list hot tablets. The hot tablets in the response will - * have start times between the requested start time and end time. Start time - * defaults to Now if it is unset, and end time defaults to Now - 24 hours if - * it is unset. The start time should be less than the end time, and the - * maximum allowed time range between start time and end time is 48 hours. - * Start time and end time should have values between Now and Now - 14 days. - * @type Timestamp $endTime - * The end time to list hot tablets. - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @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\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listHotTablets($parent, array $optionalArgs = []) - { - $request = new ListHotTabletsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['startTime'])) { - $request->setStartTime($optionalArgs['startTime']); - } - - if (isset($optionalArgs['endTime'])) { - $request->setEndTime($optionalArgs['endTime']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListHotTablets', $optionalArgs, ListHotTabletsResponse::class, $request); - } - - /** - * Lists information about instances in a project. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $formattedParent = $bigtableInstanceAdminClient->projectName('[PROJECT]'); - * $response = $bigtableInstanceAdminClient->listInstances($formattedParent); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique name of the project for which a list of instances is - * requested. Values are of the form `projects/{project}`. - * @param array $optionalArgs { - * Optional. - * - * @type string $pageToken - * DEPRECATED: This field is unused and ignored. - * @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\Bigtable\Admin\V2\ListInstancesResponse - * - * @throws ApiException if the remote call fails - */ - public function listInstances($parent, array $optionalArgs = []) - { - $request = new ListInstancesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ListInstances', ListInstancesResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Partially updates a cluster within a project. This method is the preferred - * way to update a Cluster. - * - * To enable and update autoscaling, set - * cluster_config.cluster_autoscaling_config. When autoscaling is enabled, - * serve_nodes is treated as an OUTPUT_ONLY field, meaning that updates to it - * are ignored. Note that an update cannot simultaneously set serve_nodes to - * non-zero and cluster_config.cluster_autoscaling_config to non-empty, and - * also specify both in the update_mask. - * - * To disable autoscaling, clear cluster_config.cluster_autoscaling_config, - * and explicitly set a serve_node count via the update_mask. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $cluster = new Google\Cloud\Bigtable\Admin\V2\Cluster(); - * $updateMask = new Google\Protobuf\FieldMask(); - * $operationResponse = $bigtableInstanceAdminClient->partialUpdateCluster($cluster, $updateMask); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableInstanceAdminClient->partialUpdateCluster($cluster, $updateMask); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableInstanceAdminClient->resumeOperation($operationName, 'partialUpdateCluster'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param Cluster $cluster Required. The Cluster which contains the partial updates to be applied, - * subject to the update_mask. - * @param FieldMask $updateMask Required. The subset of Cluster fields which should be replaced. - * @param array $optionalArgs { - * Optional. - * - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function partialUpdateCluster($cluster, $updateMask, array $optionalArgs = []) - { - $request = new PartialUpdateClusterRequest(); - $requestParamHeaders = []; - $request->setCluster($cluster); - $request->setUpdateMask($updateMask); - $requestParamHeaders['cluster.name'] = $cluster->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('PartialUpdateCluster', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Partially updates an instance within a project. This method can modify all - * fields of an Instance and is the preferred way to update an Instance. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $instance = new Google\Cloud\Bigtable\Admin\V2\Instance(); - * $updateMask = new Google\Protobuf\FieldMask(); - * $operationResponse = $bigtableInstanceAdminClient->partialUpdateInstance($instance, $updateMask); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableInstanceAdminClient->partialUpdateInstance($instance, $updateMask); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableInstanceAdminClient->resumeOperation($operationName, 'partialUpdateInstance'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param Instance $instance Required. The Instance which will (partially) replace the current value. - * @param FieldMask $updateMask Required. The subset of Instance fields which should be replaced. - * Must be explicitly set. - * @param array $optionalArgs { - * Optional. - * - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function partialUpdateInstance($instance, $updateMask, array $optionalArgs = []) - { - $request = new PartialUpdateInstanceRequest(); - $requestParamHeaders = []; - $request->setInstance($instance); - $request->setUpdateMask($updateMask); - $requestParamHeaders['instance.name'] = $instance->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('PartialUpdateInstance', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Sets the access control policy on an instance resource. Replaces any - * existing policy. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $resource = 'resource'; - * $policy = new Google\Cloud\Iam\V1\Policy(); - * $response = $bigtableInstanceAdminClient->setIamPolicy($resource, $policy); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('SetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); - } - - /** - * Returns permissions that the caller has on the specified instance resource. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $bigtableInstanceAdminClient->testIamPermissions($resource, $permissions); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param array $optionalArgs { - * Optional. - * - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions($resource, $permissions, array $optionalArgs = []) - { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('TestIamPermissions', TestIamPermissionsResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Updates an app profile within an instance. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $appProfile = new Google\Cloud\Bigtable\Admin\V2\AppProfile(); - * $updateMask = new Google\Protobuf\FieldMask(); - * $operationResponse = $bigtableInstanceAdminClient->updateAppProfile($appProfile, $updateMask); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableInstanceAdminClient->updateAppProfile($appProfile, $updateMask); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableInstanceAdminClient->resumeOperation($operationName, 'updateAppProfile'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param AppProfile $appProfile Required. The app profile which will (partially) replace the current value. - * @param FieldMask $updateMask Required. The subset of app profile fields which should be replaced. - * If unset, all fields will be replaced. - * @param array $optionalArgs { - * Optional. - * - * @type bool $ignoreWarnings - * If true, ignore safety checks when updating the app profile. - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function updateAppProfile($appProfile, $updateMask, array $optionalArgs = []) - { - $request = new UpdateAppProfileRequest(); - $requestParamHeaders = []; - $request->setAppProfile($appProfile); - $request->setUpdateMask($updateMask); - $requestParamHeaders['app_profile.name'] = $appProfile->getName(); - if (isset($optionalArgs['ignoreWarnings'])) { - $request->setIgnoreWarnings($optionalArgs['ignoreWarnings']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('UpdateAppProfile', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Updates a cluster within an instance. - * - * Note that UpdateCluster does not support updating - * cluster_config.cluster_autoscaling_config. In order to update it, you - * must use PartialUpdateCluster. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $name = 'name'; - * $serveNodes = 0; - * $operationResponse = $bigtableInstanceAdminClient->updateCluster($name, $serveNodes); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableInstanceAdminClient->updateCluster($name, $serveNodes); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableInstanceAdminClient->resumeOperation($operationName, 'updateCluster'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $name The unique name of the cluster. Values are of the form - * `projects/{project}/instances/{instance}/clusters/[a-z][-a-z0-9]*`. - * @param int $serveNodes The number of nodes allocated to this cluster. More nodes enable higher - * throughput and more consistent performance. - * @param array $optionalArgs { - * Optional. - * - * @type string $location - * Immutable. The location where this cluster's nodes and storage reside. For - * best performance, clients should be located as close as possible to this - * cluster. Currently only zones are supported, so values should be of the - * form `projects/{project}/locations/{zone}`. - * @type int $state - * Output only. The current state of the cluster. - * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\Cluster\State} - * @type ClusterConfig $clusterConfig - * Configuration for this cluster. - * @type int $defaultStorageType - * Immutable. The type of storage used by this cluster to serve its - * parent instance's tables, unless explicitly overridden. - * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\StorageType} - * @type EncryptionConfig $encryptionConfig - * Immutable. The encryption configuration for CMEK-protected clusters. - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function updateCluster($name, $serveNodes, array $optionalArgs = []) - { - $request = new Cluster(); - $requestParamHeaders = []; - $request->setName($name); - $request->setServeNodes($serveNodes); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['location'])) { - $request->setLocation($optionalArgs['location']); - } - - if (isset($optionalArgs['state'])) { - $request->setState($optionalArgs['state']); - } - - if (isset($optionalArgs['clusterConfig'])) { - $request->setClusterConfig($optionalArgs['clusterConfig']); - } - - if (isset($optionalArgs['defaultStorageType'])) { - $request->setDefaultStorageType($optionalArgs['defaultStorageType']); - } - - if (isset($optionalArgs['encryptionConfig'])) { - $request->setEncryptionConfig($optionalArgs['encryptionConfig']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('UpdateCluster', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Updates an instance within a project. This method updates only the display - * name and type for an Instance. To update other Instance properties, such as - * labels, use PartialUpdateInstance. - * - * Sample code: - * ``` - * $bigtableInstanceAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableInstanceAdminClient(); - * try { - * $name = 'name'; - * $displayName = 'display_name'; - * $type = Google\Cloud\Bigtable\Admin\V2\Instance\Type::TYPE_UNSPECIFIED; - * $labels = []; - * $response = $bigtableInstanceAdminClient->updateInstance($name, $displayName, $type, $labels); - * } finally { - * $bigtableInstanceAdminClient->close(); - * } - * ``` - * - * @param string $name The unique name of the instance. Values are of the form - * `projects/{project}/instances/[a-z][a-z0-9\\-]+[a-z0-9]`. - * @param string $displayName Required. The descriptive name for this instance as it appears in UIs. - * Can be changed at any time, but should be kept globally unique - * to avoid confusion. - * @param int $type The type of the instance. Defaults to `PRODUCTION`. - * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\Instance\Type} - * @param array $labels Labels are a flexible and lightweight mechanism for organizing cloud - * resources into groups that reflect a customer's organizational needs and - * deployment strategies. They can be used to filter resources and aggregate - * metrics. - * - * * Label keys must be between 1 and 63 characters long and must conform to - * the regular expression: `[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}`. - * * Label values must be between 0 and 63 characters long and must conform to - * the regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}`. - * * No more than 64 labels can be associated with a given resource. - * * Keys and values must both be under 128 bytes. - * @param array $optionalArgs { - * Optional. - * - * @type int $state - * (`OutputOnly`) - * The current state of the instance. - * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\Instance\State} - * @type Timestamp $createTime - * Output only. A server-assigned timestamp representing when this Instance - * was created. For instances created before this field was added (August - * 2021), this value is `seconds: 0, nanos: 1`. - * @type bool $satisfiesPzs - * Output only. Reserved for future use. - * @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\Bigtable\Admin\V2\Instance - * - * @throws ApiException if the remote call fails - */ - public function updateInstance($name, $displayName, $type, $labels, array $optionalArgs = []) - { - $request = new Instance(); - $requestParamHeaders = []; - $request->setName($name); - $request->setDisplayName($displayName); - $request->setType($type); - $request->setLabels($labels); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['state'])) { - $request->setState($optionalArgs['state']); - } - - if (isset($optionalArgs['createTime'])) { - $request->setCreateTime($optionalArgs['createTime']); - } - - if (isset($optionalArgs['satisfiesPzs'])) { - $request->setSatisfiesPzs($optionalArgs['satisfiesPzs']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('UpdateInstance', Instance::class, $optionalArgs, $request)->wait(); - } -} diff --git a/Bigtable/src/Admin/V2/Gapic/BigtableTableAdminGapicClient.php b/Bigtable/src/Admin/V2/Gapic/BigtableTableAdminGapicClient.php deleted file mode 100644 index f109aeeae09..00000000000 --- a/Bigtable/src/Admin/V2/Gapic/BigtableTableAdminGapicClient.php +++ /dev/null @@ -1,2512 +0,0 @@ -tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $consistencyToken = 'consistency_token'; - * $response = $bigtableTableAdminClient->checkConsistency($formattedName, $consistencyToken); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * Many parameters require resource names to be formatted in a particular way. To - * assist with these names, this class includes a format method for each type of - * name, and additionally a parseName method to extract the individual identifiers - * contained within formatted names that are returned by the API. - * - * @deprecated Please use the new service client {@see \Google\Cloud\Bigtable\Admin\V2\Client\BigtableTableAdminClient}. - */ -class BigtableTableAdminGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.bigtable.admin.v2.BigtableTableAdmin'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'bigtableadmin.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'bigtableadmin.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/bigtable.admin', - 'https://www.googleapis.com/auth/bigtable.admin.table', - 'https://www.googleapis.com/auth/cloud-bigtable.admin', - 'https://www.googleapis.com/auth/cloud-bigtable.admin.table', - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - ]; - - private static $authorizedViewNameTemplate; - - private static $backupNameTemplate; - - private static $clusterNameTemplate; - - private static $cryptoKeyVersionNameTemplate; - - private static $instanceNameTemplate; - - private static $snapshotNameTemplate; - - private static $tableNameTemplate; - - private static $pathTemplateMap; - - private $operationsClient; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/bigtable_table_admin_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/bigtable_table_admin_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/bigtable_table_admin_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/bigtable_table_admin_rest_client_config.php', - ], - ], - ]; - } - - private static function getAuthorizedViewNameTemplate() - { - if (self::$authorizedViewNameTemplate == null) { - self::$authorizedViewNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/tables/{table}/authorizedViews/{authorized_view}'); - } - - return self::$authorizedViewNameTemplate; - } - - private static function getBackupNameTemplate() - { - if (self::$backupNameTemplate == null) { - self::$backupNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup}'); - } - - return self::$backupNameTemplate; - } - - private static function getClusterNameTemplate() - { - if (self::$clusterNameTemplate == null) { - self::$clusterNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/clusters/{cluster}'); - } - - return self::$clusterNameTemplate; - } - - private static function getCryptoKeyVersionNameTemplate() - { - if (self::$cryptoKeyVersionNameTemplate == null) { - self::$cryptoKeyVersionNameTemplate = new PathTemplate('projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}'); - } - - return self::$cryptoKeyVersionNameTemplate; - } - - private static function getInstanceNameTemplate() - { - if (self::$instanceNameTemplate == null) { - self::$instanceNameTemplate = new PathTemplate('projects/{project}/instances/{instance}'); - } - - return self::$instanceNameTemplate; - } - - private static function getSnapshotNameTemplate() - { - if (self::$snapshotNameTemplate == null) { - self::$snapshotNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}'); - } - - return self::$snapshotNameTemplate; - } - - private static function getTableNameTemplate() - { - if (self::$tableNameTemplate == null) { - self::$tableNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/tables/{table}'); - } - - return self::$tableNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'authorizedView' => self::getAuthorizedViewNameTemplate(), - 'backup' => self::getBackupNameTemplate(), - 'cluster' => self::getClusterNameTemplate(), - 'cryptoKeyVersion' => self::getCryptoKeyVersionNameTemplate(), - 'instance' => self::getInstanceNameTemplate(), - 'snapshot' => self::getSnapshotNameTemplate(), - 'table' => self::getTableNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * authorized_view resource. - * - * @param string $project - * @param string $instance - * @param string $table - * @param string $authorizedView - * - * @return string The formatted authorized_view resource. - */ - public static function authorizedViewName($project, $instance, $table, $authorizedView) - { - return self::getAuthorizedViewNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - 'table' => $table, - 'authorized_view' => $authorizedView, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a backup - * resource. - * - * @param string $project - * @param string $instance - * @param string $cluster - * @param string $backup - * - * @return string The formatted backup resource. - */ - public static function backupName($project, $instance, $cluster, $backup) - { - return self::getBackupNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - 'cluster' => $cluster, - 'backup' => $backup, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a cluster - * resource. - * - * @param string $project - * @param string $instance - * @param string $cluster - * - * @return string The formatted cluster resource. - */ - public static function clusterName($project, $instance, $cluster) - { - return self::getClusterNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - 'cluster' => $cluster, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a - * crypto_key_version resource. - * - * @param string $project - * @param string $location - * @param string $keyRing - * @param string $cryptoKey - * @param string $cryptoKeyVersion - * - * @return string The formatted crypto_key_version resource. - */ - public static function cryptoKeyVersionName($project, $location, $keyRing, $cryptoKey, $cryptoKeyVersion) - { - return self::getCryptoKeyVersionNameTemplate()->render([ - 'project' => $project, - 'location' => $location, - 'key_ring' => $keyRing, - 'crypto_key' => $cryptoKey, - 'crypto_key_version' => $cryptoKeyVersion, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName($project, $instance) - { - return self::getInstanceNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a snapshot - * resource. - * - * @param string $project - * @param string $instance - * @param string $cluster - * @param string $snapshot - * - * @return string The formatted snapshot resource. - */ - public static function snapshotName($project, $instance, $cluster, $snapshot) - { - return self::getSnapshotNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - 'cluster' => $cluster, - 'snapshot' => $snapshot, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a table - * resource. - * - * @param string $project - * @param string $instance - * @param string $table - * - * @return string The formatted table resource. - */ - public static function tableName($project, $instance, $table) - { - return self::getTableNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - 'table' => $table, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - authorizedView: projects/{project}/instances/{instance}/tables/{table}/authorizedViews/{authorized_view} - * - backup: projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup} - * - cluster: projects/{project}/instances/{instance}/clusters/{cluster} - * - cryptoKeyVersion: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version} - * - instance: projects/{project}/instances/{instance} - * - snapshot: projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot} - * - table: projects/{project}/instances/{instance}/tables/{table} - * - * 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. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Return an OperationsClient object with the same endpoint as $this. - * - * @return OperationsClient - */ - public function getOperationsClient() - { - return $this->operationsClient; - } - - /** - * 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. - * - * @param string $operationName The name of the long running operation - * @param string $methodName The name of the method used to start the operation - * - * @return OperationResponse - */ - public function resumeOperation($operationName, $methodName = null) - { - $options = isset($this->descriptors[$methodName]['longRunning']) ? $this->descriptors[$methodName]['longRunning'] : []; - $operation = new OperationResponse($operationName, $this->getOperationsClient(), $options); - $operation->reload(); - return $operation; - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'bigtableadmin.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * 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 - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * 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. - * @type string|TransportInterface $transport - * 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 {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * 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 {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * 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. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - $this->operationsClient = $this->createOperationsClient($clientOptions); - } - - /** - * Checks replication consistency based on a consistency token, that is, if - * replication has caught up based on the conditions specified in the token - * and the check request. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $consistencyToken = 'consistency_token'; - * $response = $bigtableTableAdminClient->checkConsistency($formattedName, $consistencyToken); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the Table for which to check replication - * consistency. Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param string $consistencyToken Required. The token created using GenerateConsistencyToken for the Table. - * @param array $optionalArgs { - * Optional. - * - * @type StandardReadRemoteWrites $standardReadRemoteWrites - * Checks that reads using an app profile with `StandardIsolation` can - * see all writes committed before the token was created, even if the - * read and write target different clusters. - * @type DataBoostReadLocalWrites $dataBoostReadLocalWrites - * Checks that reads using an app profile with `DataBoostIsolationReadOnly` - * can see all writes committed before the token was created, but only if - * the read and write target the same cluster. - * @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\Bigtable\Admin\V2\CheckConsistencyResponse - * - * @throws ApiException if the remote call fails - */ - public function checkConsistency($name, $consistencyToken, array $optionalArgs = []) - { - $request = new CheckConsistencyRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setConsistencyToken($consistencyToken); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['standardReadRemoteWrites'])) { - $request->setStandardReadRemoteWrites($optionalArgs['standardReadRemoteWrites']); - } - - if (isset($optionalArgs['dataBoostReadLocalWrites'])) { - $request->setDataBoostReadLocalWrites($optionalArgs['dataBoostReadLocalWrites']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CheckConsistency', CheckConsistencyResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Copy a Cloud Bigtable backup to a new backup in the destination cluster - * located in the destination instance and project. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedParent = $bigtableTableAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - * $backupId = 'backup_id'; - * $formattedSourceBackup = $bigtableTableAdminClient->backupName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[BACKUP]'); - * $expireTime = new Timestamp(); - * $operationResponse = $bigtableTableAdminClient->copyBackup($formattedParent, $backupId, $formattedSourceBackup, $expireTime); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableTableAdminClient->copyBackup($formattedParent, $backupId, $formattedSourceBackup, $expireTime); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableTableAdminClient->resumeOperation($operationName, 'copyBackup'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the destination cluster that will contain the backup - * copy. The cluster must already exists. Values are of the form: - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param string $backupId Required. The id of the new backup. The `backup_id` along with `parent` - * are combined as {parent}/backups/{backup_id} to create the full backup - * name, of the form: - * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup_id}`. - * This string must be between 1 and 50 characters in length and match the - * regex [_a-zA-Z0-9][-_.a-zA-Z0-9]*. - * @param string $sourceBackup Required. The source backup to be copied from. - * The source backup needs to be in READY state for it to be copied. - * Copying a copied backup is not allowed. - * Once CopyBackup is in progress, the source backup cannot be deleted or - * cleaned up on expiration until CopyBackup is finished. - * Values are of the form: - * `projects//instances//clusters//backups/`. - * @param Timestamp $expireTime Required. Required. The expiration time of the copied backup with - * microsecond granularity that must be at least 6 hours and at most 30 days - * from the time the request is received. Once the `expire_time` has - * passed, Cloud Bigtable will delete the backup and free the resources used - * by the backup. - * @param array $optionalArgs { - * Optional. - * - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function copyBackup($parent, $backupId, $sourceBackup, $expireTime, array $optionalArgs = []) - { - $request = new CopyBackupRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setBackupId($backupId); - $request->setSourceBackup($sourceBackup); - $request->setExpireTime($expireTime); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CopyBackup', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Creates a new AuthorizedView in a table. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedParent = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $authorizedViewId = 'authorized_view_id'; - * $authorizedView = new AuthorizedView(); - * $operationResponse = $bigtableTableAdminClient->createAuthorizedView($formattedParent, $authorizedViewId, $authorizedView); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableTableAdminClient->createAuthorizedView($formattedParent, $authorizedViewId, $authorizedView); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableTableAdminClient->resumeOperation($operationName, 'createAuthorizedView'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. This is the name of the table the AuthorizedView belongs to. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param string $authorizedViewId Required. The id of the AuthorizedView to create. This AuthorizedView must - * not already exist. The `authorized_view_id` appended to `parent` forms the - * full AuthorizedView name of the form - * `projects/{project}/instances/{instance}/tables/{table}/authorizedView/{authorized_view}`. - * @param AuthorizedView $authorizedView Required. The AuthorizedView to create. - * @param array $optionalArgs { - * Optional. - * - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function createAuthorizedView($parent, $authorizedViewId, $authorizedView, array $optionalArgs = []) - { - $request = new CreateAuthorizedViewRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setAuthorizedViewId($authorizedViewId); - $request->setAuthorizedView($authorizedView); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateAuthorizedView', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Starts creating a new Cloud Bigtable Backup. The returned backup - * [long-running operation][google.longrunning.Operation] can be used to - * track creation of the backup. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [CreateBackupMetadata][google.bigtable.admin.v2.CreateBackupMetadata]. The - * [response][google.longrunning.Operation.response] field type is - * [Backup][google.bigtable.admin.v2.Backup], if successful. Cancelling the - * returned operation will stop the creation and delete the backup. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedParent = $bigtableTableAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - * $backupId = 'backup_id'; - * $backup = new Backup(); - * $operationResponse = $bigtableTableAdminClient->createBackup($formattedParent, $backupId, $backup); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableTableAdminClient->createBackup($formattedParent, $backupId, $backup); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableTableAdminClient->resumeOperation($operationName, 'createBackup'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. This must be one of the clusters in the instance in which this - * table is located. The backup will be stored in this cluster. Values are - * of the form `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param string $backupId Required. The id of the backup to be created. The `backup_id` along with - * the parent `parent` are combined as {parent}/backups/{backup_id} to create - * the full backup name, of the form: - * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup_id}`. - * This string must be between 1 and 50 characters in length and match the - * regex [_a-zA-Z0-9][-_.a-zA-Z0-9]*. - * @param Backup $backup Required. The backup to create. - * @param array $optionalArgs { - * Optional. - * - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function createBackup($parent, $backupId, $backup, array $optionalArgs = []) - { - $request = new CreateBackupRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setBackupId($backupId); - $request->setBackup($backup); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateBackup', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Creates a new table in the specified instance. - * The table can be created with a full set of initial column families, - * specified in the request. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedParent = $bigtableTableAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); - * $tableId = 'table_id'; - * $table = new Google\Cloud\Bigtable\Admin\V2\Table(); - * $response = $bigtableTableAdminClient->createTable($formattedParent, $tableId, $table); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique name of the instance in which to create the table. - * Values are of the form `projects/{project}/instances/{instance}`. - * @param string $tableId Required. The name by which the new table should be referred to within the - * parent instance, e.g., `foobar` rather than `{parent}/tables/foobar`. - * Maximum 50 characters. - * @param Table $table Required. The Table to create. - * @param array $optionalArgs { - * Optional. - * - * @type Split[] $initialSplits - * The optional list of row keys that will be used to initially split the - * table into several tablets (tablets are similar to HBase regions). - * Given two split keys, `s1` and `s2`, three tablets will be created, - * spanning the key ranges: `[, s1), [s1, s2), [s2, )`. - * - * Example: - * - * * Row keys := `["a", "apple", "custom", "customer_1", "customer_2",` - * `"other", "zz"]` - * * initial_split_keys := `["apple", "customer_1", "customer_2", "other"]` - * * Key assignment: - * - Tablet 1 `[, apple) => {"a"}.` - * - Tablet 2 `[apple, customer_1) => {"apple", "custom"}.` - * - Tablet 3 `[customer_1, customer_2) => {"customer_1"}.` - * - Tablet 4 `[customer_2, other) => {"customer_2"}.` - * - Tablet 5 `[other, ) => {"other", "zz"}.` - * @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\Bigtable\Admin\V2\Table - * - * @throws ApiException if the remote call fails - */ - public function createTable($parent, $tableId, $table, array $optionalArgs = []) - { - $request = new CreateTableRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTableId($tableId); - $request->setTable($table); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['initialSplits'])) { - $request->setInitialSplits($optionalArgs['initialSplits']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CreateTable', Table::class, $optionalArgs, $request)->wait(); - } - - /** - * Creates a new table from the specified snapshot. The target table must - * not exist. The snapshot and the table must be in the same instance. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedParent = $bigtableTableAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); - * $tableId = 'table_id'; - * $formattedSourceSnapshot = $bigtableTableAdminClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); - * $operationResponse = $bigtableTableAdminClient->createTableFromSnapshot($formattedParent, $tableId, $formattedSourceSnapshot); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableTableAdminClient->createTableFromSnapshot($formattedParent, $tableId, $formattedSourceSnapshot); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableTableAdminClient->resumeOperation($operationName, 'createTableFromSnapshot'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique name of the instance in which to create the table. - * Values are of the form `projects/{project}/instances/{instance}`. - * @param string $tableId Required. The name by which the new table should be referred to within the - * parent instance, e.g., `foobar` rather than `{parent}/tables/foobar`. - * @param string $sourceSnapshot Required. The unique name of the snapshot from which to restore the table. - * The snapshot and the table must be in the same instance. Values are of the - * form - * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}`. - * @param array $optionalArgs { - * Optional. - * - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function createTableFromSnapshot($parent, $tableId, $sourceSnapshot, array $optionalArgs = []) - { - $request = new CreateTableFromSnapshotRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTableId($tableId); - $request->setSourceSnapshot($sourceSnapshot); - $requestParamHeaders['parent'] = $parent; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('CreateTableFromSnapshot', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Permanently deletes a specified AuthorizedView. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->authorizedViewName('[PROJECT]', '[INSTANCE]', '[TABLE]', '[AUTHORIZED_VIEW]'); - * $bigtableTableAdminClient->deleteAuthorizedView($formattedName); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the AuthorizedView to be deleted. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}/authorizedViews/{authorized_view}`. - * @param array $optionalArgs { - * Optional. - * - * @type string $etag - * Optional. The current etag of the AuthorizedView. - * If an etag is provided and does not match the current etag of the - * AuthorizedView, deletion will be blocked and an ABORTED error will be - * returned. - * @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. - * } - * - * @throws ApiException if the remote call fails - */ - public function deleteAuthorizedView($name, array $optionalArgs = []) - { - $request = new DeleteAuthorizedViewRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['etag'])) { - $request->setEtag($optionalArgs['etag']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteAuthorizedView', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Deletes a pending or completed Cloud Bigtable backup. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->backupName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[BACKUP]'); - * $bigtableTableAdminClient->deleteBackup($formattedName); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the backup to delete. - * Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup}`. - * @param array $optionalArgs { - * Optional. - * - * @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. - * } - * - * @throws ApiException if the remote call fails - */ - public function deleteBackup($name, array $optionalArgs = []) - { - $request = new DeleteBackupRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteBackup', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Permanently deletes the specified snapshot. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); - * $bigtableTableAdminClient->deleteSnapshot($formattedName); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the snapshot to be deleted. - * Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}`. - * @param array $optionalArgs { - * Optional. - * - * @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. - * } - * - * @throws ApiException if the remote call fails - */ - public function deleteSnapshot($name, array $optionalArgs = []) - { - $request = new DeleteSnapshotRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteSnapshot', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Permanently deletes a specified table and all of its data. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $bigtableTableAdminClient->deleteTable($formattedName); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the table to be deleted. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param array $optionalArgs { - * Optional. - * - * @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. - * } - * - * @throws ApiException if the remote call fails - */ - public function deleteTable($name, array $optionalArgs = []) - { - $request = new DeleteTableRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DeleteTable', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Permanently drop/delete a row range from a specified table. The request can - * specify whether to delete all rows in a table, or only those that match a - * particular prefix. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $bigtableTableAdminClient->dropRowRange($formattedName); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the table on which to drop a range of rows. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param array $optionalArgs { - * Optional. - * - * @type string $rowKeyPrefix - * Delete all rows that start with this row key prefix. Prefix cannot be - * zero length. - * @type bool $deleteAllDataFromTable - * Delete all rows in the table. Setting this to false is a no-op. - * @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. - * } - * - * @throws ApiException if the remote call fails - */ - public function dropRowRange($name, array $optionalArgs = []) - { - $request = new DropRowRangeRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['rowKeyPrefix'])) { - $request->setRowKeyPrefix($optionalArgs['rowKeyPrefix']); - } - - if (isset($optionalArgs['deleteAllDataFromTable'])) { - $request->setDeleteAllDataFromTable($optionalArgs['deleteAllDataFromTable']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('DropRowRange', GPBEmpty::class, $optionalArgs, $request)->wait(); - } - - /** - * Generates a consistency token for a Table, which can be used in - * CheckConsistency to check whether mutations to the table that finished - * before this call started have been replicated. The tokens will be available - * for 90 days. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $response = $bigtableTableAdminClient->generateConsistencyToken($formattedName); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the Table for which to create a consistency - * token. Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param array $optionalArgs { - * Optional. - * - * @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\Bigtable\Admin\V2\GenerateConsistencyTokenResponse - * - * @throws ApiException if the remote call fails - */ - public function generateConsistencyToken($name, array $optionalArgs = []) - { - $request = new GenerateConsistencyTokenRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GenerateConsistencyToken', GenerateConsistencyTokenResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets information from a specified AuthorizedView. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->authorizedViewName('[PROJECT]', '[INSTANCE]', '[TABLE]', '[AUTHORIZED_VIEW]'); - * $response = $bigtableTableAdminClient->getAuthorizedView($formattedName); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the requested AuthorizedView. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}/authorizedViews/{authorized_view}`. - * @param array $optionalArgs { - * Optional. - * - * @type int $view - * Optional. The resource_view to be applied to the returned AuthorizedView's - * fields. Default to BASIC. - * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\AuthorizedView\ResponseView} - * @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\Bigtable\Admin\V2\AuthorizedView - * - * @throws ApiException if the remote call fails - */ - public function getAuthorizedView($name, array $optionalArgs = []) - { - $request = new GetAuthorizedViewRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetAuthorizedView', AuthorizedView::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets metadata on a pending or completed Cloud Bigtable Backup. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->backupName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[BACKUP]'); - * $response = $bigtableTableAdminClient->getBackup($formattedName); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. Name of the backup. - * Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup}`. - * @param array $optionalArgs { - * Optional. - * - * @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\Bigtable\Admin\V2\Backup - * - * @throws ApiException if the remote call fails - */ - public function getBackup($name, array $optionalArgs = []) - { - $request = new GetBackupRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetBackup', Backup::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets the access control policy for a Table or Backup resource. - * Returns an empty policy if the resource exists but does not have a policy - * set. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $resource = 'resource'; - * $response = $bigtableTableAdminClient->getIamPolicy($resource); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param array $optionalArgs { - * Optional. - * - * @type GetPolicyOptions $options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function getIamPolicy($resource, array $optionalArgs = []) - { - $request = new GetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['options'])) { - $request->setOptions($optionalArgs['options']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets metadata information about the specified snapshot. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); - * $response = $bigtableTableAdminClient->getSnapshot($formattedName); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the requested snapshot. - * Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}`. - * @param array $optionalArgs { - * Optional. - * - * @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\Bigtable\Admin\V2\Snapshot - * - * @throws ApiException if the remote call fails - */ - public function getSnapshot($name, array $optionalArgs = []) - { - $request = new GetSnapshotRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetSnapshot', Snapshot::class, $optionalArgs, $request)->wait(); - } - - /** - * Gets metadata information about the specified table. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $response = $bigtableTableAdminClient->getTable($formattedName); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the requested table. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param array $optionalArgs { - * Optional. - * - * @type int $view - * The view to be applied to the returned table's fields. - * Defaults to `SCHEMA_VIEW` if unspecified. - * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\Table\View} - * @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\Bigtable\Admin\V2\Table - * - * @throws ApiException if the remote call fails - */ - public function getTable($name, array $optionalArgs = []) - { - $request = new GetTableRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GetTable', Table::class, $optionalArgs, $request)->wait(); - } - - /** - * Lists all AuthorizedViews from a specific table. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedParent = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * // Iterate over pages of elements - * $pagedResponse = $bigtableTableAdminClient->listAuthorizedViews($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bigtableTableAdminClient->listAuthorizedViews($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique name of the table for which AuthorizedViews should be - * listed. Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param array $optionalArgs { - * Optional. - * - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @type int $view - * Optional. The resource_view to be applied to the returned views' fields. - * Default to NAME_ONLY. - * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\AuthorizedView\ResponseView} - * @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\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listAuthorizedViews($parent, array $optionalArgs = []) - { - $request = new ListAuthorizedViewsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListAuthorizedViews', $optionalArgs, ListAuthorizedViewsResponse::class, $request); - } - - /** - * Lists Cloud Bigtable backups. Returns both completed and pending - * backups. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedParent = $bigtableTableAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - * // Iterate over pages of elements - * $pagedResponse = $bigtableTableAdminClient->listBackups($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bigtableTableAdminClient->listBackups($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The cluster to list backups from. Values are of the - * form `projects/{project}/instances/{instance}/clusters/{cluster}`. - * Use `{cluster} = '-'` to list backups for all clusters in an instance, - * e.g., `projects/{project}/instances/{instance}/clusters/-`. - * @param array $optionalArgs { - * Optional. - * - * @type string $filter - * A filter expression that filters backups listed in the response. - * The expression must specify the field name, a comparison operator, - * and the value that you want to use for filtering. The value must be a - * string, a number, or a boolean. The comparison operator must be - * <, >, <=, >=, !=, =, or :. Colon ':' represents a HAS operator which is - * roughly synonymous with equality. Filter rules are case insensitive. - * - * The fields eligible for filtering are: - * - * * `name` - * * `source_table` - * * `state` - * * `start_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `end_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `size_bytes` - * - * To filter on multiple expressions, provide each separate expression within - * parentheses. By default, each expression is an AND expression. However, - * you can include AND, OR, and NOT expressions explicitly. - * - * Some examples of using filters are: - * - * * `name:"exact"` --> The backup's name is the string "exact". - * * `name:howl` --> The backup's name contains the string "howl". - * * `source_table:prod` - * --> The source_table's name contains the string "prod". - * * `state:CREATING` --> The backup is pending creation. - * * `state:READY` --> The backup is fully created and ready for use. - * * `(name:howl) AND (start_time < \"2018-03-28T14:50:00Z\")` - * --> The backup name contains the string "howl" and start_time - * of the backup is before 2018-03-28T14:50:00Z. - * * `size_bytes > 10000000000` --> The backup's size is greater than 10GB - * @type string $orderBy - * An expression for specifying the sort order of the results of the request. - * The string value should specify one or more fields in - * [Backup][google.bigtable.admin.v2.Backup]. The full syntax is described at - * https://aip.dev/132#ordering. - * - * Fields supported are: - * - * * name - * * source_table - * * expire_time - * * start_time - * * end_time - * * size_bytes - * * state - * - * For example, "start_time". The default sorting order is ascending. - * To specify descending order for the field, a suffix " desc" should - * be appended to the field name. For example, "start_time desc". - * Redundant space characters in the syntax are insigificant. - * - * If order_by is empty, results will be sorted by `start_time` in descending - * order starting from the most recently created backup. - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @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\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listBackups($parent, array $optionalArgs = []) - { - $request = new ListBackupsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['orderBy'])) { - $request->setOrderBy($optionalArgs['orderBy']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListBackups', $optionalArgs, ListBackupsResponse::class, $request); - } - - /** - * Lists all snapshots associated with the specified cluster. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedParent = $bigtableTableAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - * // Iterate over pages of elements - * $pagedResponse = $bigtableTableAdminClient->listSnapshots($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bigtableTableAdminClient->listSnapshots($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique name of the cluster for which snapshots should be - * listed. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * Use `{cluster} = '-'` to list snapshots for all clusters in an instance, - * e.g., `projects/{project}/instances/{instance}/clusters/-`. - * @param array $optionalArgs { - * Optional. - * - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @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\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listSnapshots($parent, array $optionalArgs = []) - { - $request = new ListSnapshotsRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListSnapshots', $optionalArgs, ListSnapshotsResponse::class, $request); - } - - /** - * Lists all tables served from a specified instance. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedParent = $bigtableTableAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); - * // Iterate over pages of elements - * $pagedResponse = $bigtableTableAdminClient->listTables($formattedParent); - * foreach ($pagedResponse->iteratePages() as $page) { - * foreach ($page as $element) { - * // doSomethingWith($element); - * } - * } - * // Alternatively: - * // Iterate through all elements - * $pagedResponse = $bigtableTableAdminClient->listTables($formattedParent); - * foreach ($pagedResponse->iterateAllElements() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The unique name of the instance for which tables should be - * listed. Values are of the form `projects/{project}/instances/{instance}`. - * @param array $optionalArgs { - * Optional. - * - * @type int $view - * The view to be applied to the returned tables' fields. - * NAME_ONLY view (default) and REPLICATION_VIEW are supported. - * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\Admin\V2\Table\View} - * @type int $pageSize - * The maximum number of resources contained in the underlying API - * response. The API may return fewer values in a page, even if - * there are additional values to be retrieved. - * @type string $pageToken - * A page token is used to specify a page of values to be returned. - * If no page token is specified (the default), the first page - * of values will be returned. Any page token used here must have - * been generated by a previous call to the API. - * @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\ApiCore\PagedListResponse - * - * @throws ApiException if the remote call fails - */ - public function listTables($parent, array $optionalArgs = []) - { - $request = new ListTablesRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['view'])) { - $request->setView($optionalArgs['view']); - } - - if (isset($optionalArgs['pageSize'])) { - $request->setPageSize($optionalArgs['pageSize']); - } - - if (isset($optionalArgs['pageToken'])) { - $request->setPageToken($optionalArgs['pageToken']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->getPagedListResponse('ListTables', $optionalArgs, ListTablesResponse::class, $request); - } - - /** - * Performs a series of column family modifications on the specified table. - * Either all or none of the modifications will occur before this method - * returns, but data requests received prior to that point may see a table - * where only some modifications have taken effect. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $modifications = []; - * $response = $bigtableTableAdminClient->modifyColumnFamilies($formattedName, $modifications); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the table whose families should be modified. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param Modification[] $modifications Required. Modifications to be atomically applied to the specified table's - * families. Entries are applied in order, meaning that earlier modifications - * can be masked by later ones (in the case of repeated updates to the same - * family, for example). - * @param array $optionalArgs { - * Optional. - * - * @type bool $ignoreWarnings - * Optional. If true, ignore safety checks when modifying the column families. - * @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\Bigtable\Admin\V2\Table - * - * @throws ApiException if the remote call fails - */ - public function modifyColumnFamilies($name, $modifications, array $optionalArgs = []) - { - $request = new ModifyColumnFamiliesRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setModifications($modifications); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['ignoreWarnings'])) { - $request->setIgnoreWarnings($optionalArgs['ignoreWarnings']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ModifyColumnFamilies', Table::class, $optionalArgs, $request)->wait(); - } - - /** - * Create a new table by restoring from a completed backup. The - * returned table [long-running operation][google.longrunning.Operation] can - * be used to track the progress of the operation, and to cancel it. The - * [metadata][google.longrunning.Operation.metadata] field type is - * [RestoreTableMetadata][google.bigtable.admin.RestoreTableMetadata]. The - * [response][google.longrunning.Operation.response] type is - * [Table][google.bigtable.admin.v2.Table], if successful. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedParent = $bigtableTableAdminClient->instanceName('[PROJECT]', '[INSTANCE]'); - * $tableId = 'table_id'; - * $operationResponse = $bigtableTableAdminClient->restoreTable($formattedParent, $tableId); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableTableAdminClient->restoreTable($formattedParent, $tableId); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableTableAdminClient->resumeOperation($operationName, 'restoreTable'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $parent Required. The name of the instance in which to create the restored - * table. Values are of the form `projects//instances/`. - * @param string $tableId Required. The id of the table to create and restore to. This - * table must not already exist. The `table_id` appended to - * `parent` forms the full table name of the form - * `projects//instances//tables/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $backup - * Name of the backup from which to restore. Values are of the form - * `projects//instances//clusters//backups/`. - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function restoreTable($parent, $tableId, array $optionalArgs = []) - { - $request = new RestoreTableRequest(); - $requestParamHeaders = []; - $request->setParent($parent); - $request->setTableId($tableId); - $requestParamHeaders['parent'] = $parent; - if (isset($optionalArgs['backup'])) { - $request->setBackup($optionalArgs['backup']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('RestoreTable', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Sets the access control policy on a Table or Backup resource. - * Replaces any existing policy. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $resource = 'resource'; - * $policy = new Google\Cloud\Iam\V1\Policy(); - * $response = $bigtableTableAdminClient->setIamPolicy($resource, $policy); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param Policy $policy REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @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\Iam\V1\Policy - * - * @throws ApiException if the remote call fails - */ - public function setIamPolicy($resource, $policy, array $optionalArgs = []) - { - $request = new SetIamPolicyRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPolicy($policy); - $requestParamHeaders['resource'] = $resource; - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('SetIamPolicy', Policy::class, $optionalArgs, $request)->wait(); - } - - /** - * Creates a new snapshot in the specified cluster from the specified - * source table. The cluster and the table must be in the same instance. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $formattedCluster = $bigtableTableAdminClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - * $snapshotId = 'snapshot_id'; - * $operationResponse = $bigtableTableAdminClient->snapshotTable($formattedName, $formattedCluster, $snapshotId); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableTableAdminClient->snapshotTable($formattedName, $formattedCluster, $snapshotId); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableTableAdminClient->resumeOperation($operationName, 'snapshotTable'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the table to have the snapshot taken. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param string $cluster Required. The name of the cluster where the snapshot will be created in. - * Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param string $snapshotId Required. The ID by which the new snapshot should be referred to within the - * parent cluster, e.g., `mysnapshot` of the form: - * `[_a-zA-Z0-9][-_.a-zA-Z0-9]*` rather than - * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/mysnapshot`. - * @param array $optionalArgs { - * Optional. - * - * @type Duration $ttl - * The amount of time that the new snapshot can stay active after it is - * created. Once 'ttl' expires, the snapshot will get deleted. The maximum - * amount of time a snapshot can stay active is 7 days. If 'ttl' is not - * specified, the default value of 24 hours will be used. - * @type string $description - * Description of the snapshot. - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function snapshotTable($name, $cluster, $snapshotId, array $optionalArgs = []) - { - $request = new SnapshotTableRequest(); - $requestParamHeaders = []; - $request->setName($name); - $request->setCluster($cluster); - $request->setSnapshotId($snapshotId); - $requestParamHeaders['name'] = $name; - if (isset($optionalArgs['ttl'])) { - $request->setTtl($optionalArgs['ttl']); - } - - if (isset($optionalArgs['description'])) { - $request->setDescription($optionalArgs['description']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('SnapshotTable', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Returns permissions that the caller has on the specified Table or Backup - * resource. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $resource = 'resource'; - * $permissions = []; - * $response = $bigtableTableAdminClient->testIamPermissions($resource, $permissions); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $resource REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param string[] $permissions The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param array $optionalArgs { - * Optional. - * - * @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\Iam\V1\TestIamPermissionsResponse - * - * @throws ApiException if the remote call fails - */ - public function testIamPermissions($resource, $permissions, array $optionalArgs = []) - { - $request = new TestIamPermissionsRequest(); - $requestParamHeaders = []; - $request->setResource($resource); - $request->setPermissions($permissions); - $requestParamHeaders['resource'] = $resource; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('TestIamPermissions', TestIamPermissionsResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Restores a specified table which was accidentally deleted. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $formattedName = $bigtableTableAdminClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $operationResponse = $bigtableTableAdminClient->undeleteTable($formattedName); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableTableAdminClient->undeleteTable($formattedName); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableTableAdminClient->resumeOperation($operationName, 'undeleteTable'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the table to be restored. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param array $optionalArgs { - * Optional. - * - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function undeleteTable($name, array $optionalArgs = []) - { - $request = new UndeleteTableRequest(); - $requestParamHeaders = []; - $request->setName($name); - $requestParamHeaders['name'] = $name; - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('UndeleteTable', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Updates an AuthorizedView in a table. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $authorizedView = new AuthorizedView(); - * $operationResponse = $bigtableTableAdminClient->updateAuthorizedView($authorizedView); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableTableAdminClient->updateAuthorizedView($authorizedView); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableTableAdminClient->resumeOperation($operationName, 'updateAuthorizedView'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param AuthorizedView $authorizedView Required. The AuthorizedView to update. The `name` in `authorized_view` is - * used to identify the AuthorizedView. AuthorizedView name must in this - * format - * projects//instances//tables//authorizedViews/ - * @param array $optionalArgs { - * Optional. - * - * @type FieldMask $updateMask - * Optional. The list of fields to update. - * A mask specifying which fields in the AuthorizedView resource should be - * updated. This mask is relative to the AuthorizedView resource, not to the - * request message. A field will be overwritten if it is in the mask. If - * empty, all fields set in the request will be overwritten. A special value - * `*` means to overwrite all fields (including fields not set in the - * request). - * @type bool $ignoreWarnings - * Optional. If true, ignore the safety checks when updating the - * AuthorizedView. - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function updateAuthorizedView($authorizedView, array $optionalArgs = []) - { - $request = new UpdateAuthorizedViewRequest(); - $requestParamHeaders = []; - $request->setAuthorizedView($authorizedView); - $requestParamHeaders['authorized_view.name'] = $authorizedView->getName(); - if (isset($optionalArgs['updateMask'])) { - $request->setUpdateMask($optionalArgs['updateMask']); - } - - if (isset($optionalArgs['ignoreWarnings'])) { - $request->setIgnoreWarnings($optionalArgs['ignoreWarnings']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('UpdateAuthorizedView', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } - - /** - * Updates a pending or completed Cloud Bigtable Backup. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $backup = new Backup(); - * $updateMask = new Google\Protobuf\FieldMask(); - * $response = $bigtableTableAdminClient->updateBackup($backup, $updateMask); - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param Backup $backup Required. The backup to update. `backup.name`, and the fields to be updated - * as specified by `update_mask` are required. Other fields are ignored. - * Update is only supported for the following fields: - * - * * `backup.expire_time`. - * @param FieldMask $updateMask Required. A mask specifying which fields (e.g. `expire_time`) in the - * Backup resource should be updated. This mask is relative to the Backup - * resource, not to the request message. The field mask must always be - * specified; this prevents any future fields from being erased accidentally - * by clients that do not know about them. - * @param array $optionalArgs { - * Optional. - * - * @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\Bigtable\Admin\V2\Backup - * - * @throws ApiException if the remote call fails - */ - public function updateBackup($backup, $updateMask, array $optionalArgs = []) - { - $request = new UpdateBackupRequest(); - $requestParamHeaders = []; - $request->setBackup($backup); - $request->setUpdateMask($updateMask); - $requestParamHeaders['backup.name'] = $backup->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('UpdateBackup', Backup::class, $optionalArgs, $request)->wait(); - } - - /** - * Updates a specified table. - * - * Sample code: - * ``` - * $bigtableTableAdminClient = new Google\Cloud\Bigtable\Admin\V2\BigtableTableAdminClient(); - * try { - * $table = new Google\Cloud\Bigtable\Admin\V2\Table(); - * $updateMask = new Google\Protobuf\FieldMask(); - * $operationResponse = $bigtableTableAdminClient->updateTable($table, $updateMask); - * $operationResponse->pollUntilComplete(); - * if ($operationResponse->operationSucceeded()) { - * $result = $operationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $operationResponse->getError(); - * // handleError($error) - * } - * // Alternatively: - * // start the operation, keep the operation name, and resume later - * $operationResponse = $bigtableTableAdminClient->updateTable($table, $updateMask); - * $operationName = $operationResponse->getName(); - * // ... do other work - * $newOperationResponse = $bigtableTableAdminClient->resumeOperation($operationName, 'updateTable'); - * while (!$newOperationResponse->isDone()) { - * // ... do other work - * $newOperationResponse->reload(); - * } - * if ($newOperationResponse->operationSucceeded()) { - * $result = $newOperationResponse->getResult(); - * // doSomethingWith($result) - * } else { - * $error = $newOperationResponse->getError(); - * // handleError($error) - * } - * } finally { - * $bigtableTableAdminClient->close(); - * } - * ``` - * - * @param Table $table Required. The table to update. - * The table's `name` field is used to identify the table to update. - * @param FieldMask $updateMask Required. The list of fields to update. - * A mask specifying which fields (e.g. `change_stream_config`) in the `table` - * field should be updated. This mask is relative to the `table` field, not to - * the request message. The wildcard (*) path is currently not supported. - * Currently UpdateTable is only supported for the following fields: - * - * * `change_stream_config` - * * `change_stream_config.retention_period` - * * `deletion_protection` - * - * If `column_families` is set in `update_mask`, it will return an - * UNIMPLEMENTED error. - * @param array $optionalArgs { - * Optional. - * - * @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\ApiCore\OperationResponse - * - * @throws ApiException if the remote call fails - */ - public function updateTable($table, $updateMask, array $optionalArgs = []) - { - $request = new UpdateTableRequest(); - $requestParamHeaders = []; - $request->setTable($table); - $request->setUpdateMask($updateMask); - $requestParamHeaders['table.name'] = $table->getName(); - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startOperationsCall('UpdateTable', $optionalArgs, $request, $this->getOperationsClient())->wait(); - } -} diff --git a/Bigtable/src/V2/BigtableClient.php b/Bigtable/src/V2/BigtableClient.php deleted file mode 100644 index ee3d93664ac..00000000000 --- a/Bigtable/src/V2/BigtableClient.php +++ /dev/null @@ -1,46 +0,0 @@ -_serverStreamRequest('/google.bigtable.v2.Bigtable/ReadRows', - $argument, - ['\Google\Cloud\Bigtable\V2\ReadRowsResponse', 'decode'], - $metadata, $options); - } - - /** - * Returns a sample of row keys in the table. The returned row keys will - * delimit contiguous sections of the table of approximately equal size, - * which can be used to break up the data for distributed tasks like - * mapreduces. - * @param \Google\Cloud\Bigtable\V2\SampleRowKeysRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\ServerStreamingCall - */ - public function SampleRowKeys(\Google\Cloud\Bigtable\V2\SampleRowKeysRequest $argument, - $metadata = [], $options = []) { - return $this->_serverStreamRequest('/google.bigtable.v2.Bigtable/SampleRowKeys', - $argument, - ['\Google\Cloud\Bigtable\V2\SampleRowKeysResponse', 'decode'], - $metadata, $options); - } - - /** - * Mutates a row atomically. Cells already present in the row are left - * unchanged unless explicitly changed by `mutation`. - * @param \Google\Cloud\Bigtable\V2\MutateRowRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function MutateRow(\Google\Cloud\Bigtable\V2\MutateRowRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.v2.Bigtable/MutateRow', - $argument, - ['\Google\Cloud\Bigtable\V2\MutateRowResponse', 'decode'], - $metadata, $options); - } - - /** - * Mutates multiple rows in a batch. Each individual row is mutated - * atomically as in MutateRow, but the entire batch is not executed - * atomically. - * @param \Google\Cloud\Bigtable\V2\MutateRowsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\ServerStreamingCall - */ - public function MutateRows(\Google\Cloud\Bigtable\V2\MutateRowsRequest $argument, - $metadata = [], $options = []) { - return $this->_serverStreamRequest('/google.bigtable.v2.Bigtable/MutateRows', - $argument, - ['\Google\Cloud\Bigtable\V2\MutateRowsResponse', 'decode'], - $metadata, $options); - } - - /** - * Mutates a row atomically based on the output of a predicate Reader filter. - * @param \Google\Cloud\Bigtable\V2\CheckAndMutateRowRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function CheckAndMutateRow(\Google\Cloud\Bigtable\V2\CheckAndMutateRowRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.v2.Bigtable/CheckAndMutateRow', - $argument, - ['\Google\Cloud\Bigtable\V2\CheckAndMutateRowResponse', 'decode'], - $metadata, $options); - } - - /** - * Warm up associated instance metadata for this connection. - * This call is not required but may be useful for connection keep-alive. - * @param \Google\Cloud\Bigtable\V2\PingAndWarmRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function PingAndWarm(\Google\Cloud\Bigtable\V2\PingAndWarmRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.v2.Bigtable/PingAndWarm', - $argument, - ['\Google\Cloud\Bigtable\V2\PingAndWarmResponse', 'decode'], - $metadata, $options); - } - - /** - * Modifies a row atomically on the server. The method reads the latest - * existing timestamp and value from the specified columns and writes a new - * entry based on pre-defined read/modify/write rules. The new value for the - * timestamp is the greater of the existing timestamp or the current server - * time. The method returns the new contents of all modified cells. - * @param \Google\Cloud\Bigtable\V2\ReadModifyWriteRowRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\UnaryCall - */ - public function ReadModifyWriteRow(\Google\Cloud\Bigtable\V2\ReadModifyWriteRowRequest $argument, - $metadata = [], $options = []) { - return $this->_simpleRequest('/google.bigtable.v2.Bigtable/ReadModifyWriteRow', - $argument, - ['\Google\Cloud\Bigtable\V2\ReadModifyWriteRowResponse', 'decode'], - $metadata, $options); - } - - /** - * NOTE: This API is intended to be used by Apache Beam BigtableIO. - * Returns the current list of partitions that make up the table's - * change stream. The union of partitions will cover the entire keyspace. - * Partitions can be read with `ReadChangeStream`. - * @param \Google\Cloud\Bigtable\V2\GenerateInitialChangeStreamPartitionsRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\ServerStreamingCall - */ - public function GenerateInitialChangeStreamPartitions(\Google\Cloud\Bigtable\V2\GenerateInitialChangeStreamPartitionsRequest $argument, - $metadata = [], $options = []) { - return $this->_serverStreamRequest('/google.bigtable.v2.Bigtable/GenerateInitialChangeStreamPartitions', - $argument, - ['\Google\Cloud\Bigtable\V2\GenerateInitialChangeStreamPartitionsResponse', 'decode'], - $metadata, $options); - } - - /** - * NOTE: This API is intended to be used by Apache Beam BigtableIO. - * Reads changes from a table's change stream. Changes will - * reflect both user-initiated mutations and mutations that are caused by - * garbage collection. - * @param \Google\Cloud\Bigtable\V2\ReadChangeStreamRequest $argument input argument - * @param array $metadata metadata - * @param array $options call options - * @return \Grpc\ServerStreamingCall - */ - public function ReadChangeStream(\Google\Cloud\Bigtable\V2\ReadChangeStreamRequest $argument, - $metadata = [], $options = []) { - return $this->_serverStreamRequest('/google.bigtable.v2.Bigtable/ReadChangeStream', - $argument, - ['\Google\Cloud\Bigtable\V2\ReadChangeStreamResponse', 'decode'], - $metadata, $options); - } - -} diff --git a/Bigtable/src/V2/Gapic/BigtableGapicClient.php b/Bigtable/src/V2/Gapic/BigtableGapicClient.php deleted file mode 100644 index 99c5625a5b2..00000000000 --- a/Bigtable/src/V2/Gapic/BigtableGapicClient.php +++ /dev/null @@ -1,1090 +0,0 @@ -tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $rowKey = '...'; - * $response = $bigtableClient->checkAndMutateRow($formattedTableName, $rowKey); - * } finally { - * $bigtableClient->close(); - * } - * ``` - * - * Many parameters require resource names to be formatted in a particular way. To - * assist with these names, this class includes a format method for each type of - * name, and additionally a parseName method to extract the individual identifiers - * contained within formatted names that are returned by the API. - * - * @deprecated Please use the new service client {@see \Google\Cloud\Bigtable\V2\Client\BigtableClient}. - */ -class BigtableGapicClient -{ - use GapicClientTrait; - - /** The name of the service. */ - const SERVICE_NAME = 'google.bigtable.v2.Bigtable'; - - /** - * The default address of the service. - * - * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead. - */ - const SERVICE_ADDRESS = 'bigtable.googleapis.com'; - - /** The address template of the service. */ - private const SERVICE_ADDRESS_TEMPLATE = 'bigtable.UNIVERSE_DOMAIN'; - - /** The default port of the service. */ - const DEFAULT_SERVICE_PORT = 443; - - /** The name of the code generator, to be included in the agent header. */ - const CODEGEN_NAME = 'gapic'; - - /** The default scopes required by the service. */ - public static $serviceScopes = [ - 'https://www.googleapis.com/auth/bigtable.data', - 'https://www.googleapis.com/auth/bigtable.data.readonly', - 'https://www.googleapis.com/auth/cloud-bigtable.data', - 'https://www.googleapis.com/auth/cloud-bigtable.data.readonly', - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only', - ]; - - private static $authorizedViewNameTemplate; - - private static $instanceNameTemplate; - - private static $tableNameTemplate; - - private static $pathTemplateMap; - - private static function getClientDefaults() - { - return [ - 'serviceName' => self::SERVICE_NAME, - 'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT, - 'clientConfig' => __DIR__ . '/../resources/bigtable_client_config.json', - 'descriptorsConfigPath' => __DIR__ . '/../resources/bigtable_descriptor_config.php', - 'gcpApiConfigPath' => __DIR__ . '/../resources/bigtable_grpc_config.json', - 'credentialsConfig' => [ - 'defaultScopes' => self::$serviceScopes, - ], - 'transportConfig' => [ - 'rest' => [ - 'restClientConfigPath' => __DIR__ . '/../resources/bigtable_rest_client_config.php', - ], - ], - ]; - } - - private static function getAuthorizedViewNameTemplate() - { - if (self::$authorizedViewNameTemplate == null) { - self::$authorizedViewNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/tables/{table}/authorizedViews/{authorized_view}'); - } - - return self::$authorizedViewNameTemplate; - } - - private static function getInstanceNameTemplate() - { - if (self::$instanceNameTemplate == null) { - self::$instanceNameTemplate = new PathTemplate('projects/{project}/instances/{instance}'); - } - - return self::$instanceNameTemplate; - } - - private static function getTableNameTemplate() - { - if (self::$tableNameTemplate == null) { - self::$tableNameTemplate = new PathTemplate('projects/{project}/instances/{instance}/tables/{table}'); - } - - return self::$tableNameTemplate; - } - - private static function getPathTemplateMap() - { - if (self::$pathTemplateMap == null) { - self::$pathTemplateMap = [ - 'authorizedView' => self::getAuthorizedViewNameTemplate(), - 'instance' => self::getInstanceNameTemplate(), - 'table' => self::getTableNameTemplate(), - ]; - } - - return self::$pathTemplateMap; - } - - /** - * Formats a string containing the fully-qualified path to represent a - * authorized_view resource. - * - * @param string $project - * @param string $instance - * @param string $table - * @param string $authorizedView - * - * @return string The formatted authorized_view resource. - */ - public static function authorizedViewName($project, $instance, $table, $authorizedView) - { - return self::getAuthorizedViewNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - 'table' => $table, - 'authorized_view' => $authorizedView, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a instance - * resource. - * - * @param string $project - * @param string $instance - * - * @return string The formatted instance resource. - */ - public static function instanceName($project, $instance) - { - return self::getInstanceNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - ]); - } - - /** - * Formats a string containing the fully-qualified path to represent a table - * resource. - * - * @param string $project - * @param string $instance - * @param string $table - * - * @return string The formatted table resource. - */ - public static function tableName($project, $instance, $table) - { - return self::getTableNameTemplate()->render([ - 'project' => $project, - 'instance' => $instance, - 'table' => $table, - ]); - } - - /** - * Parses a formatted name string and returns an associative array of the components in the name. - * The following name formats are supported: - * Template: Pattern - * - authorizedView: projects/{project}/instances/{instance}/tables/{table}/authorizedViews/{authorized_view} - * - instance: projects/{project}/instances/{instance} - * - table: projects/{project}/instances/{instance}/tables/{table} - * - * 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. - * - * @param string $formattedName The formatted name string - * @param string $template Optional name of template to match - * - * @return array An associative array from name component IDs to component values. - * - * @throws ValidationException If $formattedName could not be matched. - */ - public static function parseName($formattedName, $template = null) - { - $templateMap = self::getPathTemplateMap(); - if ($template) { - if (!isset($templateMap[$template])) { - throw new ValidationException("Template name $template does not exist"); - } - - return $templateMap[$template]->match($formattedName); - } - - foreach ($templateMap as $templateName => $pathTemplate) { - try { - return $pathTemplate->match($formattedName); - } catch (ValidationException $ex) { - // Swallow the exception to continue trying other path templates - } - } - - throw new ValidationException("Input did not match any known format. Input: $formattedName"); - } - - /** - * Constructor. - * - * @param array $options { - * Optional. Options for configuring the service API wrapper. - * - * @type string $apiEndpoint - * The address of the API remote host. May optionally include the port, formatted - * as ":". Default 'bigtable.googleapis.com:443'. - * @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials - * 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 - * {@see \Google\Auth\FetchAuthTokenInterface} object or - * {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these - * objects are provided, any settings in $credentialsConfig will be ignored. - * @type array $credentialsConfig - * Options used to configure credentials, including auth token caching, for the - * client. For a full list of supporting configuration options, see - * {@see \Google\ApiCore\CredentialsWrapper::build()} . - * @type bool $disableRetries - * Determines whether or not retries defined by the client configuration should be - * disabled. Defaults to `false`. - * @type string|array $clientConfig - * 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. - * @type string|TransportInterface $transport - * 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 {@see \Google\ApiCore\Transport\TransportInterface} object. Note - * that when this object is provided, any settings in $transportConfig, and any - * $apiEndpoint setting, will be ignored. - * @type array $transportConfig - * 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 {@see \Google\ApiCore\Transport\GrpcTransport::build()} and - * {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the - * supported options. - * @type callable $clientCertSource - * 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. - * } - * - * @throws ValidationException - */ - public function __construct(array $options = []) - { - $clientOptions = $this->buildClientOptions($options); - $this->setClientOptions($clientOptions); - } - - /** - * Mutates a row atomically based on the output of a predicate Reader filter. - * - * Sample code: - * ``` - * $bigtableClient = new Google\Cloud\Bigtable\V2\BigtableClient(); - * try { - * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $rowKey = '...'; - * $response = $bigtableClient->checkAndMutateRow($formattedTableName, $rowKey); - * } finally { - * $bigtableClient->close(); - * } - * ``` - * - * @param string $tableName Optional. The unique name of the table to which the conditional mutation - * should be applied. - * - * Values are of the form - * `projects//instances//tables/
`. - * @param string $rowKey Required. The key of the row to which the conditional mutation should be - * applied. - * @param array $optionalArgs { - * Optional. - * - * @type string $authorizedViewName - * Optional. The unique name of the AuthorizedView to which the conditional - * mutation should be applied. - * - * Values are of the form - * `projects//instances//tables/
/authorizedViews/`. - * @type string $appProfileId - * This value specifies routing for replication. If not specified, the - * "default" application profile will be used. - * @type RowFilter $predicateFilter - * The filter to be applied to the contents of the specified row. Depending - * on whether or not any results are yielded, either `true_mutations` or - * `false_mutations` will be executed. If unset, checks that the row contains - * any values at all. - * @type Mutation[] $trueMutations - * Changes to be atomically applied to the specified row if `predicate_filter` - * yields at least one cell when applied to `row_key`. Entries are applied in - * order, meaning that earlier mutations can be masked by later ones. - * Must contain at least one entry if `false_mutations` is empty, and at most - * 100000. - * @type Mutation[] $falseMutations - * Changes to be atomically applied to the specified row if `predicate_filter` - * does not yield any cells when applied to `row_key`. Entries are applied in - * order, meaning that earlier mutations can be masked by later ones. - * Must contain at least one entry if `true_mutations` is empty, and at most - * 100000. - * @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\Bigtable\V2\CheckAndMutateRowResponse - * - * @throws ApiException if the remote call fails - */ - public function checkAndMutateRow($tableName, $rowKey, array $optionalArgs = []) - { - $request = new CheckAndMutateRowRequest(); - $requestParamHeaders = []; - $request->setTableName($tableName); - $request->setRowKey($rowKey); - $tableNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+)$/', $tableName, $tableNameMatches)) { - $requestParamHeaders['table_name'] = $tableNameMatches['table_name']; - } - - if (isset($optionalArgs['authorizedViewName'])) { - $request->setAuthorizedViewName($optionalArgs['authorizedViewName']); - $authorizedViewNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+\/authorizedViews\/[^\/]+)$/', $optionalArgs['authorizedViewName'], $authorizedViewNameMatches)) { - $requestParamHeaders['authorized_view_name'] = $authorizedViewNameMatches['authorized_view_name']; - } - } - - if (isset($optionalArgs['appProfileId'])) { - $request->setAppProfileId($optionalArgs['appProfileId']); - $requestParamHeaders['app_profile_id'] = $optionalArgs['appProfileId']; - } - - if (isset($optionalArgs['predicateFilter'])) { - $request->setPredicateFilter($optionalArgs['predicateFilter']); - } - - if (isset($optionalArgs['trueMutations'])) { - $request->setTrueMutations($optionalArgs['trueMutations']); - } - - if (isset($optionalArgs['falseMutations'])) { - $request->setFalseMutations($optionalArgs['falseMutations']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('CheckAndMutateRow', CheckAndMutateRowResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * NOTE: This API is intended to be used by Apache Beam BigtableIO. - * Returns the current list of partitions that make up the table's - * change stream. The union of partitions will cover the entire keyspace. - * Partitions can be read with `ReadChangeStream`. - * - * Sample code: - * ``` - * $bigtableClient = new Google\Cloud\Bigtable\V2\BigtableClient(); - * try { - * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * // Read all responses until the stream is complete - * $stream = $bigtableClient->generateInitialChangeStreamPartitions($formattedTableName); - * foreach ($stream->readAll() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bigtableClient->close(); - * } - * ``` - * - * @param string $tableName Required. The unique name of the table from which to get change stream - * partitions. Values are of the form - * `projects//instances//tables/
`. - * Change streaming must be enabled on the table. - * @param array $optionalArgs { - * Optional. - * - * @type string $appProfileId - * This value specifies routing for replication. If not specified, the - * "default" application profile will be used. - * Single cluster routing must be configured on the profile. - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return \Google\ApiCore\ServerStream - * - * @throws ApiException if the remote call fails - */ - public function generateInitialChangeStreamPartitions($tableName, array $optionalArgs = []) - { - $request = new GenerateInitialChangeStreamPartitionsRequest(); - $requestParamHeaders = []; - $request->setTableName($tableName); - $requestParamHeaders['table_name'] = $tableName; - if (isset($optionalArgs['appProfileId'])) { - $request->setAppProfileId($optionalArgs['appProfileId']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('GenerateInitialChangeStreamPartitions', GenerateInitialChangeStreamPartitionsResponse::class, $optionalArgs, $request, Call::SERVER_STREAMING_CALL); - } - - /** - * Mutates a row atomically. Cells already present in the row are left - * unchanged unless explicitly changed by `mutation`. - * - * Sample code: - * ``` - * $bigtableClient = new Google\Cloud\Bigtable\V2\BigtableClient(); - * try { - * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $rowKey = '...'; - * $mutations = []; - * $response = $bigtableClient->mutateRow($formattedTableName, $rowKey, $mutations); - * } finally { - * $bigtableClient->close(); - * } - * ``` - * - * @param string $tableName Optional. The unique name of the table to which the mutation should be - * applied. - * - * Values are of the form - * `projects//instances//tables/
`. - * @param string $rowKey Required. The key of the row to which the mutation should be applied. - * @param Mutation[] $mutations Required. Changes to be atomically applied to the specified row. Entries - * are applied in order, meaning that earlier mutations can be masked by later - * ones. Must contain at least one entry and at most 100000. - * @param array $optionalArgs { - * Optional. - * - * @type string $authorizedViewName - * Optional. The unique name of the AuthorizedView to which the mutation - * should be applied. - * - * Values are of the form - * `projects//instances//tables/
/authorizedViews/`. - * @type string $appProfileId - * This value specifies routing for replication. If not specified, the - * "default" application profile will be used. - * @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\Bigtable\V2\MutateRowResponse - * - * @throws ApiException if the remote call fails - */ - public function mutateRow($tableName, $rowKey, $mutations, array $optionalArgs = []) - { - $request = new MutateRowRequest(); - $requestParamHeaders = []; - $request->setTableName($tableName); - $request->setRowKey($rowKey); - $request->setMutations($mutations); - $tableNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+)$/', $tableName, $tableNameMatches)) { - $requestParamHeaders['table_name'] = $tableNameMatches['table_name']; - } - - if (isset($optionalArgs['authorizedViewName'])) { - $request->setAuthorizedViewName($optionalArgs['authorizedViewName']); - $authorizedViewNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+\/authorizedViews\/[^\/]+)$/', $optionalArgs['authorizedViewName'], $authorizedViewNameMatches)) { - $requestParamHeaders['authorized_view_name'] = $authorizedViewNameMatches['authorized_view_name']; - } - } - - if (isset($optionalArgs['appProfileId'])) { - $request->setAppProfileId($optionalArgs['appProfileId']); - $requestParamHeaders['app_profile_id'] = $optionalArgs['appProfileId']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('MutateRow', MutateRowResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Mutates multiple rows in a batch. Each individual row is mutated - * atomically as in MutateRow, but the entire batch is not executed - * atomically. - * - * Sample code: - * ``` - * $bigtableClient = new Google\Cloud\Bigtable\V2\BigtableClient(); - * try { - * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $entries = []; - * // Read all responses until the stream is complete - * $stream = $bigtableClient->mutateRows($formattedTableName, $entries); - * foreach ($stream->readAll() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bigtableClient->close(); - * } - * ``` - * - * @param string $tableName Optional. The unique name of the table to which the mutations should be - * applied. - * - * Values are of the form - * `projects//instances//tables/
`. - * @param Entry[] $entries Required. The row keys and corresponding mutations to be applied in bulk. - * Each entry is applied as an atomic mutation, but the entries may be - * applied in arbitrary order (even between entries for the same row). - * At least one entry must be specified, and in total the entries can - * contain at most 100000 mutations. - * @param array $optionalArgs { - * Optional. - * - * @type string $authorizedViewName - * Optional. The unique name of the AuthorizedView to which the mutations - * should be applied. - * - * Values are of the form - * `projects//instances//tables/
/authorizedViews/`. - * @type string $appProfileId - * This value specifies routing for replication. If not specified, the - * "default" application profile will be used. - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return \Google\ApiCore\ServerStream - * - * @throws ApiException if the remote call fails - */ - public function mutateRows($tableName, $entries, array $optionalArgs = []) - { - $request = new MutateRowsRequest(); - $requestParamHeaders = []; - $request->setTableName($tableName); - $request->setEntries($entries); - $tableNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+)$/', $tableName, $tableNameMatches)) { - $requestParamHeaders['table_name'] = $tableNameMatches['table_name']; - } - - if (isset($optionalArgs['authorizedViewName'])) { - $request->setAuthorizedViewName($optionalArgs['authorizedViewName']); - $authorizedViewNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+\/authorizedViews\/[^\/]+)$/', $optionalArgs['authorizedViewName'], $authorizedViewNameMatches)) { - $requestParamHeaders['authorized_view_name'] = $authorizedViewNameMatches['authorized_view_name']; - } - } - - if (isset($optionalArgs['appProfileId'])) { - $request->setAppProfileId($optionalArgs['appProfileId']); - $requestParamHeaders['app_profile_id'] = $optionalArgs['appProfileId']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('MutateRows', MutateRowsResponse::class, $optionalArgs, $request, Call::SERVER_STREAMING_CALL); - } - - /** - * Warm up associated instance metadata for this connection. - * This call is not required but may be useful for connection keep-alive. - * - * Sample code: - * ``` - * $bigtableClient = new Google\Cloud\Bigtable\V2\BigtableClient(); - * try { - * $formattedName = $bigtableClient->instanceName('[PROJECT]', '[INSTANCE]'); - * $response = $bigtableClient->pingAndWarm($formattedName); - * } finally { - * $bigtableClient->close(); - * } - * ``` - * - * @param string $name Required. The unique name of the instance to check permissions for as well - * as respond. Values are of the form - * `projects//instances/`. - * @param array $optionalArgs { - * Optional. - * - * @type string $appProfileId - * This value specifies routing for replication. If not specified, the - * "default" application profile will be used. - * @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\Bigtable\V2\PingAndWarmResponse - * - * @throws ApiException if the remote call fails - */ - public function pingAndWarm($name, array $optionalArgs = []) - { - $request = new PingAndWarmRequest(); - $requestParamHeaders = []; - $request->setName($name); - $nameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+)$/', $name, $nameMatches)) { - $requestParamHeaders['name'] = $nameMatches['name']; - } - - if (isset($optionalArgs['appProfileId'])) { - $request->setAppProfileId($optionalArgs['appProfileId']); - $requestParamHeaders['app_profile_id'] = $optionalArgs['appProfileId']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('PingAndWarm', PingAndWarmResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * NOTE: This API is intended to be used by Apache Beam BigtableIO. - * Reads changes from a table's change stream. Changes will - * reflect both user-initiated mutations and mutations that are caused by - * garbage collection. - * - * Sample code: - * ``` - * $bigtableClient = new Google\Cloud\Bigtable\V2\BigtableClient(); - * try { - * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * // Read all responses until the stream is complete - * $stream = $bigtableClient->readChangeStream($formattedTableName); - * foreach ($stream->readAll() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bigtableClient->close(); - * } - * ``` - * - * @param string $tableName Required. The unique name of the table from which to read a change stream. - * Values are of the form - * `projects//instances//tables/
`. - * Change streaming must be enabled on the table. - * @param array $optionalArgs { - * Optional. - * - * @type string $appProfileId - * This value specifies routing for replication. If not specified, the - * "default" application profile will be used. - * Single cluster routing must be configured on the profile. - * @type StreamPartition $partition - * The partition to read changes from. - * @type Timestamp $startTime - * Start reading the stream at the specified timestamp. This timestamp must - * be within the change stream retention period, less than or equal to the - * current time, and after change stream creation, whichever is greater. - * This value is inclusive and will be truncated to microsecond granularity. - * @type StreamContinuationTokens $continuationTokens - * Tokens that describe how to resume reading a stream where reading - * previously left off. If specified, changes will be read starting at the - * the position. Tokens are delivered on the stream as part of `Heartbeat` - * and `CloseStream` messages. - * - * If a single token is provided, the token’s partition must exactly match - * the request’s partition. If multiple tokens are provided, as in the case - * of a partition merge, the union of the token partitions must exactly - * cover the request’s partition. Otherwise, INVALID_ARGUMENT will be - * returned. - * @type Timestamp $endTime - * If specified, OK will be returned when the stream advances beyond - * this time. Otherwise, changes will be continuously delivered on the stream. - * This value is inclusive and will be truncated to microsecond granularity. - * @type Duration $heartbeatDuration - * If specified, the duration between `Heartbeat` messages on the stream. - * Otherwise, defaults to 5 seconds. - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return \Google\ApiCore\ServerStream - * - * @throws ApiException if the remote call fails - */ - public function readChangeStream($tableName, array $optionalArgs = []) - { - $request = new ReadChangeStreamRequest(); - $requestParamHeaders = []; - $request->setTableName($tableName); - $requestParamHeaders['table_name'] = $tableName; - if (isset($optionalArgs['appProfileId'])) { - $request->setAppProfileId($optionalArgs['appProfileId']); - } - - if (isset($optionalArgs['partition'])) { - $request->setPartition($optionalArgs['partition']); - } - - if (isset($optionalArgs['startTime'])) { - $request->setStartTime($optionalArgs['startTime']); - } - - if (isset($optionalArgs['continuationTokens'])) { - $request->setContinuationTokens($optionalArgs['continuationTokens']); - } - - if (isset($optionalArgs['endTime'])) { - $request->setEndTime($optionalArgs['endTime']); - } - - if (isset($optionalArgs['heartbeatDuration'])) { - $request->setHeartbeatDuration($optionalArgs['heartbeatDuration']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ReadChangeStream', ReadChangeStreamResponse::class, $optionalArgs, $request, Call::SERVER_STREAMING_CALL); - } - - /** - * Modifies a row atomically on the server. The method reads the latest - * existing timestamp and value from the specified columns and writes a new - * entry based on pre-defined read/modify/write rules. The new value for the - * timestamp is the greater of the existing timestamp or the current server - * time. The method returns the new contents of all modified cells. - * - * Sample code: - * ``` - * $bigtableClient = new Google\Cloud\Bigtable\V2\BigtableClient(); - * try { - * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * $rowKey = '...'; - * $rules = []; - * $response = $bigtableClient->readModifyWriteRow($formattedTableName, $rowKey, $rules); - * } finally { - * $bigtableClient->close(); - * } - * ``` - * - * @param string $tableName Optional. The unique name of the table to which the read/modify/write rules - * should be applied. - * - * Values are of the form - * `projects//instances//tables/
`. - * @param string $rowKey Required. The key of the row to which the read/modify/write rules should be - * applied. - * @param ReadModifyWriteRule[] $rules Required. Rules specifying how the specified row's contents are to be - * transformed into writes. Entries are applied in order, meaning that earlier - * rules will affect the results of later ones. - * @param array $optionalArgs { - * Optional. - * - * @type string $authorizedViewName - * Optional. The unique name of the AuthorizedView to which the - * read/modify/write rules should be applied. - * - * Values are of the form - * `projects//instances//tables/
/authorizedViews/`. - * @type string $appProfileId - * This value specifies routing for replication. If not specified, the - * "default" application profile will be used. - * @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\Bigtable\V2\ReadModifyWriteRowResponse - * - * @throws ApiException if the remote call fails - */ - public function readModifyWriteRow($tableName, $rowKey, $rules, array $optionalArgs = []) - { - $request = new ReadModifyWriteRowRequest(); - $requestParamHeaders = []; - $request->setTableName($tableName); - $request->setRowKey($rowKey); - $request->setRules($rules); - $tableNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+)$/', $tableName, $tableNameMatches)) { - $requestParamHeaders['table_name'] = $tableNameMatches['table_name']; - } - - if (isset($optionalArgs['authorizedViewName'])) { - $request->setAuthorizedViewName($optionalArgs['authorizedViewName']); - $authorizedViewNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+\/authorizedViews\/[^\/]+)$/', $optionalArgs['authorizedViewName'], $authorizedViewNameMatches)) { - $requestParamHeaders['authorized_view_name'] = $authorizedViewNameMatches['authorized_view_name']; - } - } - - if (isset($optionalArgs['appProfileId'])) { - $request->setAppProfileId($optionalArgs['appProfileId']); - $requestParamHeaders['app_profile_id'] = $optionalArgs['appProfileId']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ReadModifyWriteRow', ReadModifyWriteRowResponse::class, $optionalArgs, $request)->wait(); - } - - /** - * Streams back the contents of all requested rows in key order, optionally - * applying the same Reader filter to each. Depending on their size, - * rows and cells may be broken up across multiple responses, but - * atomicity of each row will still be preserved. See the - * ReadRowsResponse documentation for details. - * - * Sample code: - * ``` - * $bigtableClient = new Google\Cloud\Bigtable\V2\BigtableClient(); - * try { - * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * // Read all responses until the stream is complete - * $stream = $bigtableClient->readRows($formattedTableName); - * foreach ($stream->readAll() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bigtableClient->close(); - * } - * ``` - * - * @param string $tableName Optional. The unique name of the table from which to read. - * - * Values are of the form - * `projects//instances//tables/
`. - * @param array $optionalArgs { - * Optional. - * - * @type string $authorizedViewName - * Optional. The unique name of the AuthorizedView from which to read. - * - * Values are of the form - * `projects//instances//tables/
/authorizedViews/`. - * @type string $appProfileId - * This value specifies routing for replication. If not specified, the - * "default" application profile will be used. - * @type RowSet $rows - * The row keys and/or ranges to read sequentially. If not specified, reads - * from all rows. - * @type RowFilter $filter - * The filter to apply to the contents of the specified row(s). If unset, - * reads the entirety of each row. - * @type int $rowsLimit - * The read will stop after committing to N rows' worth of results. The - * default (zero) is to return all results. - * @type int $requestStatsView - * The view into RequestStats, as described above. - * For allowed values, use constants defined on {@see \Google\Cloud\Bigtable\V2\ReadRowsRequest\RequestStatsView} - * @type bool $reversed - * Experimental API - Please note that this API is currently experimental - * and can change in the future. - * - * Return rows in lexiographical descending order of the row keys. The row - * contents will not be affected by this flag. - * - * Example result set: - * - * [ - * {key: "k2", "f:col1": "v1", "f:col2": "v1"}, - * {key: "k1", "f:col1": "v2", "f:col2": "v2"} - * ] - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return \Google\ApiCore\ServerStream - * - * @throws ApiException if the remote call fails - */ - public function readRows($tableName, array $optionalArgs = []) - { - $request = new ReadRowsRequest(); - $requestParamHeaders = []; - $request->setTableName($tableName); - $tableNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+)$/', $tableName, $tableNameMatches)) { - $requestParamHeaders['table_name'] = $tableNameMatches['table_name']; - } - - if (isset($optionalArgs['authorizedViewName'])) { - $request->setAuthorizedViewName($optionalArgs['authorizedViewName']); - $authorizedViewNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+\/authorizedViews\/[^\/]+)$/', $optionalArgs['authorizedViewName'], $authorizedViewNameMatches)) { - $requestParamHeaders['authorized_view_name'] = $authorizedViewNameMatches['authorized_view_name']; - } - } - - if (isset($optionalArgs['appProfileId'])) { - $request->setAppProfileId($optionalArgs['appProfileId']); - $requestParamHeaders['app_profile_id'] = $optionalArgs['appProfileId']; - } - - if (isset($optionalArgs['rows'])) { - $request->setRows($optionalArgs['rows']); - } - - if (isset($optionalArgs['filter'])) { - $request->setFilter($optionalArgs['filter']); - } - - if (isset($optionalArgs['rowsLimit'])) { - $request->setRowsLimit($optionalArgs['rowsLimit']); - } - - if (isset($optionalArgs['requestStatsView'])) { - $request->setRequestStatsView($optionalArgs['requestStatsView']); - } - - if (isset($optionalArgs['reversed'])) { - $request->setReversed($optionalArgs['reversed']); - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('ReadRows', ReadRowsResponse::class, $optionalArgs, $request, Call::SERVER_STREAMING_CALL); - } - - /** - * Returns a sample of row keys in the table. The returned row keys will - * delimit contiguous sections of the table of approximately equal size, - * which can be used to break up the data for distributed tasks like - * mapreduces. - * - * Sample code: - * ``` - * $bigtableClient = new Google\Cloud\Bigtable\V2\BigtableClient(); - * try { - * $formattedTableName = $bigtableClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - * // Read all responses until the stream is complete - * $stream = $bigtableClient->sampleRowKeys($formattedTableName); - * foreach ($stream->readAll() as $element) { - * // doSomethingWith($element); - * } - * } finally { - * $bigtableClient->close(); - * } - * ``` - * - * @param string $tableName Optional. The unique name of the table from which to sample row keys. - * - * Values are of the form - * `projects//instances//tables/
`. - * @param array $optionalArgs { - * Optional. - * - * @type string $authorizedViewName - * Optional. The unique name of the AuthorizedView from which to sample row - * keys. - * - * Values are of the form - * `projects//instances//tables/
/authorizedViews/`. - * @type string $appProfileId - * This value specifies routing for replication. If not specified, the - * "default" application profile will be used. - * @type int $timeoutMillis - * Timeout to use for this call. - * } - * - * @return \Google\ApiCore\ServerStream - * - * @throws ApiException if the remote call fails - */ - public function sampleRowKeys($tableName, array $optionalArgs = []) - { - $request = new SampleRowKeysRequest(); - $requestParamHeaders = []; - $request->setTableName($tableName); - $tableNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+)$/', $tableName, $tableNameMatches)) { - $requestParamHeaders['table_name'] = $tableNameMatches['table_name']; - } - - if (isset($optionalArgs['authorizedViewName'])) { - $request->setAuthorizedViewName($optionalArgs['authorizedViewName']); - $authorizedViewNameMatches = []; - if (preg_match('/^(?projects\/[^\/]+\/instances\/[^\/]+\/tables\/[^\/]+\/authorizedViews\/[^\/]+)$/', $optionalArgs['authorizedViewName'], $authorizedViewNameMatches)) { - $requestParamHeaders['authorized_view_name'] = $authorizedViewNameMatches['authorized_view_name']; - } - } - - if (isset($optionalArgs['appProfileId'])) { - $request->setAppProfileId($optionalArgs['appProfileId']); - $requestParamHeaders['app_profile_id'] = $optionalArgs['appProfileId']; - } - - $requestParams = new RequestParamsHeaderDescriptor($requestParamHeaders); - $optionalArgs['headers'] = isset($optionalArgs['headers']) ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) : $requestParams->getHeader(); - return $this->startCall('SampleRowKeys', SampleRowKeysResponse::class, $optionalArgs, $request, Call::SERVER_STREAMING_CALL); - } -} From e4f33bd0b75bf2ef42d3a6c1b9bc834a8844c12d Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Fri, 24 May 2024 15:26:01 +0530 Subject: [PATCH 27/36] Removed deprecated classes from the Admin namespace --- .../V2/AppProfile_MultiClusterRoutingUseAny.php | 16 ---------------- .../Admin/V2/AppProfile_SingleClusterRouting.php | 16 ---------------- Bigtable/src/Admin/V2/Backup_State.php | 16 ---------------- .../V2/Cluster_ClusterAutoscalingConfig.php | 16 ---------------- .../src/Admin/V2/Cluster_EncryptionConfig.php | 16 ---------------- Bigtable/src/Admin/V2/Cluster_State.php | 16 ---------------- .../V2/CreateClusterMetadata_TableProgress.php | 16 ---------------- ...CreateClusterMetadata_TableProgress_State.php | 16 ---------------- .../src/Admin/V2/CreateTableRequest_Split.php | 16 ---------------- .../Admin/V2/EncryptionInfo_EncryptionType.php | 16 ---------------- Bigtable/src/Admin/V2/GcRule_Intersection.php | 16 ---------------- Bigtable/src/Admin/V2/GcRule_Union.php | 16 ---------------- Bigtable/src/Admin/V2/Instance_State.php | 16 ---------------- Bigtable/src/Admin/V2/Instance_Type.php | 16 ---------------- .../ModifyColumnFamiliesRequest_Modification.php | 16 ---------------- Bigtable/src/Admin/V2/Snapshot_State.php | 16 ---------------- Bigtable/src/Admin/V2/Table_ClusterState.php | 16 ---------------- .../V2/Table_ClusterState_ReplicationState.php | 16 ---------------- .../src/Admin/V2/Table_TimestampGranularity.php | 16 ---------------- Bigtable/src/Admin/V2/Table_View.php | 16 ---------------- 20 files changed, 320 deletions(-) delete mode 100644 Bigtable/src/Admin/V2/AppProfile_MultiClusterRoutingUseAny.php delete mode 100644 Bigtable/src/Admin/V2/AppProfile_SingleClusterRouting.php delete mode 100644 Bigtable/src/Admin/V2/Backup_State.php delete mode 100644 Bigtable/src/Admin/V2/Cluster_ClusterAutoscalingConfig.php delete mode 100644 Bigtable/src/Admin/V2/Cluster_EncryptionConfig.php delete mode 100644 Bigtable/src/Admin/V2/Cluster_State.php delete mode 100644 Bigtable/src/Admin/V2/CreateClusterMetadata_TableProgress.php delete mode 100644 Bigtable/src/Admin/V2/CreateClusterMetadata_TableProgress_State.php delete mode 100644 Bigtable/src/Admin/V2/CreateTableRequest_Split.php delete mode 100644 Bigtable/src/Admin/V2/EncryptionInfo_EncryptionType.php delete mode 100644 Bigtable/src/Admin/V2/GcRule_Intersection.php delete mode 100644 Bigtable/src/Admin/V2/GcRule_Union.php delete mode 100644 Bigtable/src/Admin/V2/Instance_State.php delete mode 100644 Bigtable/src/Admin/V2/Instance_Type.php delete mode 100644 Bigtable/src/Admin/V2/ModifyColumnFamiliesRequest_Modification.php delete mode 100644 Bigtable/src/Admin/V2/Snapshot_State.php delete mode 100644 Bigtable/src/Admin/V2/Table_ClusterState.php delete mode 100644 Bigtable/src/Admin/V2/Table_ClusterState_ReplicationState.php delete mode 100644 Bigtable/src/Admin/V2/Table_TimestampGranularity.php delete mode 100644 Bigtable/src/Admin/V2/Table_View.php diff --git a/Bigtable/src/Admin/V2/AppProfile_MultiClusterRoutingUseAny.php b/Bigtable/src/Admin/V2/AppProfile_MultiClusterRoutingUseAny.php deleted file mode 100644 index b37ee5d7f97..00000000000 --- a/Bigtable/src/Admin/V2/AppProfile_MultiClusterRoutingUseAny.php +++ /dev/null @@ -1,16 +0,0 @@ - Date: Fri, 24 May 2024 15:35:07 +0530 Subject: [PATCH 28/36] Removed V1 GAPIC tests --- .../V2/BigtableInstanceAdminClientTest.php | 1893 ------------ .../Admin/V2/BigtableTableAdminClientTest.php | 2584 ----------------- 2 files changed, 4477 deletions(-) delete mode 100644 Bigtable/tests/Unit/Admin/V2/BigtableInstanceAdminClientTest.php delete mode 100644 Bigtable/tests/Unit/Admin/V2/BigtableTableAdminClientTest.php diff --git a/Bigtable/tests/Unit/Admin/V2/BigtableInstanceAdminClientTest.php b/Bigtable/tests/Unit/Admin/V2/BigtableInstanceAdminClientTest.php deleted file mode 100644 index 3301cbdc268..00000000000 --- a/Bigtable/tests/Unit/Admin/V2/BigtableInstanceAdminClientTest.php +++ /dev/null @@ -1,1893 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return BigtableInstanceAdminClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new BigtableInstanceAdminClient($options); - } - - /** @test */ - public function createAppProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $etag = 'etag3123477'; - $description = 'description-1724546052'; - $expectedResponse = new AppProfile(); - $expectedResponse->setName($name); - $expectedResponse->setEtag($etag); - $expectedResponse->setDescription($description); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $appProfileId = 'appProfileId1262094415'; - $appProfile = new AppProfile(); - $response = $gapicClient->createAppProfile($formattedParent, $appProfileId, $appProfile); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/CreateAppProfile', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getAppProfileId(); - $this->assertProtobufEquals($appProfileId, $actualValue); - $actualValue = $actualRequestObject->getAppProfile(); - $this->assertProtobufEquals($appProfile, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createAppProfileExceptionTest() - { - $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 - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $appProfileId = 'appProfileId1262094415'; - $appProfile = new AppProfile(); - try { - $gapicClient->createAppProfile($formattedParent, $appProfileId, $appProfile); - // 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 createClusterTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/createClusterTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $location = 'location1901043637'; - $serveNodes = 1288838783; - $expectedResponse = new Cluster(); - $expectedResponse->setName($name); - $expectedResponse->setLocation($location); - $expectedResponse->setServeNodes($serveNodes); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createClusterTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $clusterId = 'clusterId240280960'; - $cluster = new Cluster(); - $clusterName = 'clusterName-1141738587'; - $cluster->setName($clusterName); - $clusterServeNodes = 1434304124; - $cluster->setServeNodes($clusterServeNodes); - $response = $gapicClient->createCluster($formattedParent, $clusterId, $cluster); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/CreateCluster', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getClusterId(); - $this->assertProtobufEquals($clusterId, $actualValue); - $actualValue = $actualApiRequestObject->getCluster(); - $this->assertProtobufEquals($cluster, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createClusterTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function createClusterExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/createClusterTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $clusterId = 'clusterId240280960'; - $cluster = new Cluster(); - $clusterName = 'clusterName-1141738587'; - $cluster->setName($clusterName); - $clusterServeNodes = 1434304124; - $cluster->setServeNodes($clusterServeNodes); - $response = $gapicClient->createCluster($formattedParent, $clusterId, $cluster); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createClusterTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function createInstanceTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/createInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $satisfiesPzs = false; - $expectedResponse = new Instance(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setSatisfiesPzs($satisfiesPzs); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createInstanceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->projectName('[PROJECT]'); - $instanceId = 'instanceId-2101995259'; - $instance = new Instance(); - $instanceName = 'instanceName-737857344'; - $instance->setName($instanceName); - $instanceDisplayName = 'instanceDisplayName1824500376'; - $instance->setDisplayName($instanceDisplayName); - $instanceType = Type::TYPE_UNSPECIFIED; - $instance->setType($instanceType); - $labelsValue = 'labelsValue950036658'; - $instanceLabels = [ - 'labelsKey' => $labelsValue, - ]; - $instance->setLabels($instanceLabels); - $clustersValue = new Cluster(); - $valueName = 'valueName-765894756'; - $clustersValue->setName($valueName); - $valueServeNodes = 370436813; - $clustersValue->setServeNodes($valueServeNodes); - $clusters = [ - 'clustersKey' => $clustersValue, - ]; - $response = $gapicClient->createInstance($formattedParent, $instanceId, $instance, $clusters); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/CreateInstance', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getInstanceId(); - $this->assertProtobufEquals($instanceId, $actualValue); - $actualValue = $actualApiRequestObject->getInstance(); - $this->assertProtobufEquals($instance, $actualValue); - $actualValue = $actualApiRequestObject->getClusters(); - $this->assertProtobufEquals($clusters, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createInstanceTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function createInstanceExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/createInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $formattedParent = $gapicClient->projectName('[PROJECT]'); - $instanceId = 'instanceId-2101995259'; - $instance = new Instance(); - $instanceName = 'instanceName-737857344'; - $instance->setName($instanceName); - $instanceDisplayName = 'instanceDisplayName1824500376'; - $instance->setDisplayName($instanceDisplayName); - $instanceType = Type::TYPE_UNSPECIFIED; - $instance->setType($instanceType); - $labelsValue = 'labelsValue950036658'; - $instanceLabels = [ - 'labelsKey' => $labelsValue, - ]; - $instance->setLabels($instanceLabels); - $clustersValue = new Cluster(); - $valueName = 'valueName-765894756'; - $clustersValue->setName($valueName); - $valueServeNodes = 370436813; - $clustersValue->setServeNodes($valueServeNodes); - $clusters = [ - 'clustersKey' => $clustersValue, - ]; - $response = $gapicClient->createInstance($formattedParent, $instanceId, $instance, $clusters); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createInstanceTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function deleteAppProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->appProfileName('[PROJECT]', '[INSTANCE]', '[APP_PROFILE]'); - $ignoreWarnings = true; - $gapicClient->deleteAppProfile($formattedName, $ignoreWarnings); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/DeleteAppProfile', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getIgnoreWarnings(); - $this->assertProtobufEquals($ignoreWarnings, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteAppProfileExceptionTest() - { - $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 - $formattedName = $gapicClient->appProfileName('[PROJECT]', '[INSTANCE]', '[APP_PROFILE]'); - $ignoreWarnings = true; - try { - $gapicClient->deleteAppProfile($formattedName, $ignoreWarnings); - // 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 deleteClusterTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - $gapicClient->deleteCluster($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/DeleteCluster', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteClusterExceptionTest() - { - $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 - $formattedName = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - try { - $gapicClient->deleteCluster($formattedName); - // 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 deleteInstanceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $gapicClient->deleteInstance($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/DeleteInstance', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteInstanceExceptionTest() - { - $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 - $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - try { - $gapicClient->deleteInstance($formattedName); - // 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 getAppProfileTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $etag = 'etag3123477'; - $description = 'description-1724546052'; - $expectedResponse = new AppProfile(); - $expectedResponse->setName($name2); - $expectedResponse->setEtag($etag); - $expectedResponse->setDescription($description); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->appProfileName('[PROJECT]', '[INSTANCE]', '[APP_PROFILE]'); - $response = $gapicClient->getAppProfile($formattedName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/GetAppProfile', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getAppProfileExceptionTest() - { - $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 - $formattedName = $gapicClient->appProfileName('[PROJECT]', '[INSTANCE]', '[APP_PROFILE]'); - try { - $gapicClient->getAppProfile($formattedName); - // 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 getClusterTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $location = 'location1901043637'; - $serveNodes = 1288838783; - $expectedResponse = new Cluster(); - $expectedResponse->setName($name2); - $expectedResponse->setLocation($location); - $expectedResponse->setServeNodes($serveNodes); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - $response = $gapicClient->getCluster($formattedName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/GetCluster', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getClusterExceptionTest() - { - $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 - $formattedName = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - try { - $gapicClient->getCluster($formattedName); - // 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 getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 getInstanceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName = 'displayName1615086568'; - $satisfiesPzs = false; - $expectedResponse = new Instance(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setSatisfiesPzs($satisfiesPzs); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $response = $gapicClient->getInstance($formattedName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/GetInstance', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getInstanceExceptionTest() - { - $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 - $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - try { - $gapicClient->getInstance($formattedName); - // 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 listAppProfilesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $appProfilesElement = new AppProfile(); - $appProfiles = [ - $appProfilesElement, - ]; - $expectedResponse = new ListAppProfilesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setAppProfiles($appProfiles); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $response = $gapicClient->listAppProfiles($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getAppProfiles()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/ListAppProfiles', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listAppProfilesExceptionTest() - { - $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 - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - try { - $gapicClient->listAppProfiles($formattedParent); - // 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 listClustersTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = 'nextPageToken-1530815211'; - $expectedResponse = new ListClustersResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $response = $gapicClient->listClusters($formattedParent); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/ListClusters', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listClustersExceptionTest() - { - $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 - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - try { - $gapicClient->listClusters($formattedParent); - // 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 listHotTabletsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $hotTabletsElement = new HotTablet(); - $hotTablets = [ - $hotTabletsElement, - ]; - $expectedResponse = new ListHotTabletsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setHotTablets($hotTablets); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - $response = $gapicClient->listHotTablets($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getHotTablets()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/ListHotTablets', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listHotTabletsExceptionTest() - { - $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 - $formattedParent = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - try { - $gapicClient->listHotTablets($formattedParent); - // 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 listInstancesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = 'nextPageToken-1530815211'; - $expectedResponse = new ListInstancesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->projectName('[PROJECT]'); - $response = $gapicClient->listInstances($formattedParent); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/ListInstances', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listInstancesExceptionTest() - { - $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 - $formattedParent = $gapicClient->projectName('[PROJECT]'); - try { - $gapicClient->listInstances($formattedParent); - // 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 partialUpdateClusterTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/partialUpdateClusterTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $location = 'location1901043637'; - $serveNodes = 1288838783; - $expectedResponse = new Cluster(); - $expectedResponse->setName($name); - $expectedResponse->setLocation($location); - $expectedResponse->setServeNodes($serveNodes); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/partialUpdateClusterTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $cluster = new Cluster(); - $clusterName = 'clusterName-1141738587'; - $cluster->setName($clusterName); - $clusterServeNodes = 1434304124; - $cluster->setServeNodes($clusterServeNodes); - $updateMask = new FieldMask(); - $response = $gapicClient->partialUpdateCluster($cluster, $updateMask); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/PartialUpdateCluster', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getCluster(); - $this->assertProtobufEquals($cluster, $actualValue); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/partialUpdateClusterTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function partialUpdateClusterExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/partialUpdateClusterTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $cluster = new Cluster(); - $clusterName = 'clusterName-1141738587'; - $cluster->setName($clusterName); - $clusterServeNodes = 1434304124; - $cluster->setServeNodes($clusterServeNodes); - $updateMask = new FieldMask(); - $response = $gapicClient->partialUpdateCluster($cluster, $updateMask); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/partialUpdateClusterTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function partialUpdateInstanceTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/partialUpdateInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $satisfiesPzs = false; - $expectedResponse = new Instance(); - $expectedResponse->setName($name); - $expectedResponse->setDisplayName($displayName); - $expectedResponse->setSatisfiesPzs($satisfiesPzs); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/partialUpdateInstanceTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $instance = new Instance(); - $instanceName = 'instanceName-737857344'; - $instance->setName($instanceName); - $instanceDisplayName = 'instanceDisplayName1824500376'; - $instance->setDisplayName($instanceDisplayName); - $instanceType = Type::TYPE_UNSPECIFIED; - $instance->setType($instanceType); - $labelsValue = 'labelsValue950036658'; - $instanceLabels = [ - 'labelsKey' => $labelsValue, - ]; - $instance->setLabels($instanceLabels); - $updateMask = new FieldMask(); - $response = $gapicClient->partialUpdateInstance($instance, $updateMask); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/PartialUpdateInstance', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getInstance(); - $this->assertProtobufEquals($instance, $actualValue); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/partialUpdateInstanceTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function partialUpdateInstanceExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/partialUpdateInstanceTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $instance = new Instance(); - $instanceName = 'instanceName-737857344'; - $instance->setName($instanceName); - $instanceDisplayName = 'instanceDisplayName1824500376'; - $instance->setDisplayName($instanceDisplayName); - $instanceType = Type::TYPE_UNSPECIFIED; - $instance->setType($instanceType); - $labelsValue = 'labelsValue950036658'; - $instanceLabels = [ - 'labelsKey' => $labelsValue, - ]; - $instance->setLabels($instanceLabels); - $updateMask = new FieldMask(); - $response = $gapicClient->partialUpdateInstance($instance, $updateMask); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/partialUpdateInstanceTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // 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 updateAppProfileTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/updateAppProfileTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $etag = 'etag3123477'; - $description = 'description-1724546052'; - $expectedResponse = new AppProfile(); - $expectedResponse->setName($name); - $expectedResponse->setEtag($etag); - $expectedResponse->setDescription($description); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateAppProfileTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $appProfile = new AppProfile(); - $updateMask = new FieldMask(); - $response = $gapicClient->updateAppProfile($appProfile, $updateMask); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/UpdateAppProfile', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getAppProfile(); - $this->assertProtobufEquals($appProfile, $actualValue); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateAppProfileTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function updateAppProfileExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/updateAppProfileTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $appProfile = new AppProfile(); - $updateMask = new FieldMask(); - $response = $gapicClient->updateAppProfile($appProfile, $updateMask); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateAppProfileTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function updateClusterTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/updateClusterTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $location2 = 'location21541837352'; - $serveNodes2 = 1623486220; - $expectedResponse = new Cluster(); - $expectedResponse->setName($name2); - $expectedResponse->setLocation($location2); - $expectedResponse->setServeNodes($serveNodes2); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateClusterTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $name = 'name3373707'; - $serveNodes = 1288838783; - $response = $gapicClient->updateCluster($name, $serveNodes); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/UpdateCluster', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $actualValue = $actualApiRequestObject->getServeNodes(); - $this->assertProtobufEquals($serveNodes, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateClusterTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function updateClusterExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/updateClusterTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $name = 'name3373707'; - $serveNodes = 1288838783; - $response = $gapicClient->updateCluster($name, $serveNodes); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateClusterTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function updateInstanceTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $displayName2 = 'displayName21615000987'; - $satisfiesPzs2 = true; - $expectedResponse = new Instance(); - $expectedResponse->setName($name2); - $expectedResponse->setDisplayName($displayName2); - $expectedResponse->setSatisfiesPzs($satisfiesPzs2); - $transport->addResponse($expectedResponse); - // Mock request - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $type = Type::TYPE_UNSPECIFIED; - $labelsValue = 'labelsValue950036658'; - $labels = [ - 'labelsKey' => $labelsValue, - ]; - $response = $gapicClient->updateInstance($name, $displayName, $type, $labels); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableInstanceAdmin/UpdateInstance', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($name, $actualValue); - $actualValue = $actualRequestObject->getDisplayName(); - $this->assertProtobufEquals($displayName, $actualValue); - $actualValue = $actualRequestObject->getType(); - $this->assertProtobufEquals($type, $actualValue); - $actualValue = $actualRequestObject->getLabels(); - $this->assertProtobufEquals($labels, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateInstanceExceptionTest() - { - $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 - $name = 'name3373707'; - $displayName = 'displayName1615086568'; - $type = Type::TYPE_UNSPECIFIED; - $labelsValue = 'labelsValue950036658'; - $labels = [ - 'labelsKey' => $labelsValue, - ]; - try { - $gapicClient->updateInstance($name, $displayName, $type, $labels); - // 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()); - } -} diff --git a/Bigtable/tests/Unit/Admin/V2/BigtableTableAdminClientTest.php b/Bigtable/tests/Unit/Admin/V2/BigtableTableAdminClientTest.php deleted file mode 100644 index cc1e86b5c6f..00000000000 --- a/Bigtable/tests/Unit/Admin/V2/BigtableTableAdminClientTest.php +++ /dev/null @@ -1,2584 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return BigtableTableAdminClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new BigtableTableAdminClient($options); - } - - /** @test */ - public function checkConsistencyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $consistent = true; - $expectedResponse = new CheckConsistencyResponse(); - $expectedResponse->setConsistent($consistent); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $consistencyToken = 'consistencyToken-1090516718'; - $response = $gapicClient->checkConsistency($formattedName, $consistencyToken); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/CheckConsistency', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getConsistencyToken(); - $this->assertProtobufEquals($consistencyToken, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function checkConsistencyExceptionTest() - { - $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 - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $consistencyToken = 'consistencyToken-1090516718'; - try { - $gapicClient->checkConsistency($formattedName, $consistencyToken); - // 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 copyBackupTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/copyBackupTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $sourceTable = 'sourceTable1670858410'; - $sourceBackup2 = 'sourceBackup2889376921'; - $sizeBytes = 1796325715; - $expectedResponse = new Backup(); - $expectedResponse->setName($name); - $expectedResponse->setSourceTable($sourceTable); - $expectedResponse->setSourceBackup($sourceBackup2); - $expectedResponse->setSizeBytes($sizeBytes); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/copyBackupTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - $backupId = 'backupId1355353272'; - $formattedSourceBackup = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[BACKUP]'); - $expireTime = new Timestamp(); - $response = $gapicClient->copyBackup($formattedParent, $backupId, $formattedSourceBackup, $expireTime); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/CopyBackup', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getBackupId(); - $this->assertProtobufEquals($backupId, $actualValue); - $actualValue = $actualApiRequestObject->getSourceBackup(); - $this->assertProtobufEquals($formattedSourceBackup, $actualValue); - $actualValue = $actualApiRequestObject->getExpireTime(); - $this->assertProtobufEquals($expireTime, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/copyBackupTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function copyBackupExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/copyBackupTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $formattedParent = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - $backupId = 'backupId1355353272'; - $formattedSourceBackup = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[BACKUP]'); - $expireTime = new Timestamp(); - $response = $gapicClient->copyBackup($formattedParent, $backupId, $formattedSourceBackup, $expireTime); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/copyBackupTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function createAuthorizedViewTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/createAuthorizedViewTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $etag = 'etag3123477'; - $deletionProtection = true; - $expectedResponse = new AuthorizedView(); - $expectedResponse->setName($name); - $expectedResponse->setEtag($etag); - $expectedResponse->setDeletionProtection($deletionProtection); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createAuthorizedViewTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $authorizedViewId = 'authorizedViewId1171901009'; - $authorizedView = new AuthorizedView(); - $response = $gapicClient->createAuthorizedView($formattedParent, $authorizedViewId, $authorizedView); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/CreateAuthorizedView', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getAuthorizedViewId(); - $this->assertProtobufEquals($authorizedViewId, $actualValue); - $actualValue = $actualApiRequestObject->getAuthorizedView(); - $this->assertProtobufEquals($authorizedView, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createAuthorizedViewTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function createAuthorizedViewExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/createAuthorizedViewTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $formattedParent = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $authorizedViewId = 'authorizedViewId1171901009'; - $authorizedView = new AuthorizedView(); - $response = $gapicClient->createAuthorizedView($formattedParent, $authorizedViewId, $authorizedView); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createAuthorizedViewTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function createBackupTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/createBackupTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $sourceTable = 'sourceTable1670858410'; - $sourceBackup = 'sourceBackup-258292122'; - $sizeBytes = 1796325715; - $expectedResponse = new Backup(); - $expectedResponse->setName($name); - $expectedResponse->setSourceTable($sourceTable); - $expectedResponse->setSourceBackup($sourceBackup); - $expectedResponse->setSizeBytes($sizeBytes); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createBackupTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - $backupId = 'backupId1355353272'; - $backup = new Backup(); - $backupSourceTable = 'backupSourceTable1043210577'; - $backup->setSourceTable($backupSourceTable); - $backupExpireTime = new Timestamp(); - $backup->setExpireTime($backupExpireTime); - $response = $gapicClient->createBackup($formattedParent, $backupId, $backup); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/CreateBackup', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getBackupId(); - $this->assertProtobufEquals($backupId, $actualValue); - $actualValue = $actualApiRequestObject->getBackup(); - $this->assertProtobufEquals($backup, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createBackupTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function createBackupExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/createBackupTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $formattedParent = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - $backupId = 'backupId1355353272'; - $backup = new Backup(); - $backupSourceTable = 'backupSourceTable1043210577'; - $backup->setSourceTable($backupSourceTable); - $backupExpireTime = new Timestamp(); - $backup->setExpireTime($backupExpireTime); - $response = $gapicClient->createBackup($formattedParent, $backupId, $backup); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createBackupTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function createTableTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $deletionProtection = true; - $expectedResponse = new Table(); - $expectedResponse->setName($name); - $expectedResponse->setDeletionProtection($deletionProtection); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $tableId = 'tableId-895419604'; - $table = new Table(); - $response = $gapicClient->createTable($formattedParent, $tableId, $table); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/CreateTable', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualRequestObject->getTableId(); - $this->assertProtobufEquals($tableId, $actualValue); - $actualValue = $actualRequestObject->getTable(); - $this->assertProtobufEquals($table, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function createTableExceptionTest() - { - $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 - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $tableId = 'tableId-895419604'; - $table = new Table(); - try { - $gapicClient->createTable($formattedParent, $tableId, $table); - // 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 createTableFromSnapshotTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/createTableFromSnapshotTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $deletionProtection = true; - $expectedResponse = new Table(); - $expectedResponse->setName($name); - $expectedResponse->setDeletionProtection($deletionProtection); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/createTableFromSnapshotTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $tableId = 'tableId-895419604'; - $formattedSourceSnapshot = $gapicClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); - $response = $gapicClient->createTableFromSnapshot($formattedParent, $tableId, $formattedSourceSnapshot); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/CreateTableFromSnapshot', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getTableId(); - $this->assertProtobufEquals($tableId, $actualValue); - $actualValue = $actualApiRequestObject->getSourceSnapshot(); - $this->assertProtobufEquals($formattedSourceSnapshot, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createTableFromSnapshotTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function createTableFromSnapshotExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/createTableFromSnapshotTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $tableId = 'tableId-895419604'; - $formattedSourceSnapshot = $gapicClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); - $response = $gapicClient->createTableFromSnapshot($formattedParent, $tableId, $formattedSourceSnapshot); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/createTableFromSnapshotTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function deleteAuthorizedViewTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->authorizedViewName('[PROJECT]', '[INSTANCE]', '[TABLE]', '[AUTHORIZED_VIEW]'); - $gapicClient->deleteAuthorizedView($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/DeleteAuthorizedView', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteAuthorizedViewExceptionTest() - { - $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 - $formattedName = $gapicClient->authorizedViewName('[PROJECT]', '[INSTANCE]', '[TABLE]', '[AUTHORIZED_VIEW]'); - try { - $gapicClient->deleteAuthorizedView($formattedName); - // 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 deleteBackupTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[BACKUP]'); - $gapicClient->deleteBackup($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/DeleteBackup', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteBackupExceptionTest() - { - $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 - $formattedName = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[BACKUP]'); - try { - $gapicClient->deleteBackup($formattedName); - // 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 deleteSnapshotTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); - $gapicClient->deleteSnapshot($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/DeleteSnapshot', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteSnapshotExceptionTest() - { - $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 - $formattedName = $gapicClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); - try { - $gapicClient->deleteSnapshot($formattedName); - // 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 deleteTableTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $gapicClient->deleteTable($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/DeleteTable', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function deleteTableExceptionTest() - { - $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 - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - try { - $gapicClient->deleteTable($formattedName); - // 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 dropRowRangeTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GPBEmpty(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $gapicClient->dropRowRange($formattedName); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/DropRowRange', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function dropRowRangeExceptionTest() - { - $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 - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - try { - $gapicClient->dropRowRange($formattedName); - // 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 generateConsistencyTokenTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $consistencyToken = 'consistencyToken-1090516718'; - $expectedResponse = new GenerateConsistencyTokenResponse(); - $expectedResponse->setConsistencyToken($consistencyToken); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $response = $gapicClient->generateConsistencyToken($formattedName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/GenerateConsistencyToken', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function generateConsistencyTokenExceptionTest() - { - $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 - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - try { - $gapicClient->generateConsistencyToken($formattedName); - // 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 getAuthorizedViewTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $etag = 'etag3123477'; - $deletionProtection = true; - $expectedResponse = new AuthorizedView(); - $expectedResponse->setName($name2); - $expectedResponse->setEtag($etag); - $expectedResponse->setDeletionProtection($deletionProtection); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->authorizedViewName('[PROJECT]', '[INSTANCE]', '[TABLE]', '[AUTHORIZED_VIEW]'); - $response = $gapicClient->getAuthorizedView($formattedName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/GetAuthorizedView', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getAuthorizedViewExceptionTest() - { - $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 - $formattedName = $gapicClient->authorizedViewName('[PROJECT]', '[INSTANCE]', '[TABLE]', '[AUTHORIZED_VIEW]'); - try { - $gapicClient->getAuthorizedView($formattedName); - // 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 getBackupTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $sourceTable = 'sourceTable1670858410'; - $sourceBackup = 'sourceBackup-258292122'; - $sizeBytes = 1796325715; - $expectedResponse = new Backup(); - $expectedResponse->setName($name2); - $expectedResponse->setSourceTable($sourceTable); - $expectedResponse->setSourceBackup($sourceBackup); - $expectedResponse->setSizeBytes($sizeBytes); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[BACKUP]'); - $response = $gapicClient->getBackup($formattedName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/GetBackup', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getBackupExceptionTest() - { - $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 - $formattedName = $gapicClient->backupName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[BACKUP]'); - try { - $gapicClient->getBackup($formattedName); - // 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 getIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $response = $gapicClient->getIamPolicy($resource); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/GetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - try { - $gapicClient->getIamPolicy($resource); - // 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 getSnapshotTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $dataSizeBytes = 2110122398; - $description = 'description-1724546052'; - $expectedResponse = new Snapshot(); - $expectedResponse->setName($name2); - $expectedResponse->setDataSizeBytes($dataSizeBytes); - $expectedResponse->setDescription($description); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); - $response = $gapicClient->getSnapshot($formattedName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/GetSnapshot', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getSnapshotExceptionTest() - { - $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 - $formattedName = $gapicClient->snapshotName('[PROJECT]', '[INSTANCE]', '[CLUSTER]', '[SNAPSHOT]'); - try { - $gapicClient->getSnapshot($formattedName); - // 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 getTableTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $deletionProtection = true; - $expectedResponse = new Table(); - $expectedResponse->setName($name2); - $expectedResponse->setDeletionProtection($deletionProtection); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $response = $gapicClient->getTable($formattedName); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/GetTable', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function getTableExceptionTest() - { - $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 - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - try { - $gapicClient->getTable($formattedName); - // 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 listAuthorizedViewsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $authorizedViewsElement = new AuthorizedView(); - $authorizedViews = [ - $authorizedViewsElement, - ]; - $expectedResponse = new ListAuthorizedViewsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setAuthorizedViews($authorizedViews); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $response = $gapicClient->listAuthorizedViews($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getAuthorizedViews()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/ListAuthorizedViews', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listAuthorizedViewsExceptionTest() - { - $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 - $formattedParent = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - try { - $gapicClient->listAuthorizedViews($formattedParent); - // 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 listBackupsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $backupsElement = new Backup(); - $backups = [ - $backupsElement, - ]; - $expectedResponse = new ListBackupsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setBackups($backups); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - $response = $gapicClient->listBackups($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getBackups()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/ListBackups', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listBackupsExceptionTest() - { - $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 - $formattedParent = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - try { - $gapicClient->listBackups($formattedParent); - // 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 listSnapshotsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $snapshotsElement = new Snapshot(); - $snapshots = [ - $snapshotsElement, - ]; - $expectedResponse = new ListSnapshotsResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setSnapshots($snapshots); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - $response = $gapicClient->listSnapshots($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getSnapshots()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/ListSnapshots', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listSnapshotsExceptionTest() - { - $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 - $formattedParent = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - try { - $gapicClient->listSnapshots($formattedParent); - // 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 listTablesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $nextPageToken = ''; - $tablesElement = new Table(); - $tables = [ - $tablesElement, - ]; - $expectedResponse = new ListTablesResponse(); - $expectedResponse->setNextPageToken($nextPageToken); - $expectedResponse->setTables($tables); - $transport->addResponse($expectedResponse); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $response = $gapicClient->listTables($formattedParent); - $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); - $resources = iterator_to_array($response->iterateAllElements()); - $this->assertSame(1, count($resources)); - $this->assertEquals($expectedResponse->getTables()[0], $resources[0]); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/ListTables', $actualFuncCall); - $actualValue = $actualRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function listTablesExceptionTest() - { - $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 - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - try { - $gapicClient->listTables($formattedParent); - // 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 modifyColumnFamiliesTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name2 = 'name2-1052831874'; - $deletionProtection = true; - $expectedResponse = new Table(); - $expectedResponse->setName($name2); - $expectedResponse->setDeletionProtection($deletionProtection); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $modifications = []; - $response = $gapicClient->modifyColumnFamilies($formattedName, $modifications); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/ModifyColumnFamilies', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualRequestObject->getModifications(); - $this->assertProtobufEquals($modifications, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function modifyColumnFamiliesExceptionTest() - { - $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 - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $modifications = []; - try { - $gapicClient->modifyColumnFamilies($formattedName, $modifications); - // 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 restoreTableTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/restoreTableTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $deletionProtection = true; - $expectedResponse = new Table(); - $expectedResponse->setName($name); - $expectedResponse->setDeletionProtection($deletionProtection); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/restoreTableTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $tableId = 'tableId-895419604'; - $response = $gapicClient->restoreTable($formattedParent, $tableId); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/RestoreTable', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getParent(); - $this->assertProtobufEquals($formattedParent, $actualValue); - $actualValue = $actualApiRequestObject->getTableId(); - $this->assertProtobufEquals($tableId, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/restoreTableTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function restoreTableExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/restoreTableTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $formattedParent = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $tableId = 'tableId-895419604'; - $response = $gapicClient->restoreTable($formattedParent, $tableId); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/restoreTableTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function setIamPolicyTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $version = 351608024; - $etag = '21'; - $expectedResponse = new Policy(); - $expectedResponse->setVersion($version); - $expectedResponse->setEtag($etag); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $policy = new Policy(); - $response = $gapicClient->setIamPolicy($resource, $policy); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/SetIamPolicy', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPolicy(); - $this->assertProtobufEquals($policy, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function setIamPolicyExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $policy = new Policy(); - try { - $gapicClient->setIamPolicy($resource, $policy); - // 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 snapshotTableTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/snapshotTableTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $dataSizeBytes = 2110122398; - $description2 = 'description2568623279'; - $expectedResponse = new Snapshot(); - $expectedResponse->setName($name2); - $expectedResponse->setDataSizeBytes($dataSizeBytes); - $expectedResponse->setDescription($description2); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/snapshotTableTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $formattedCluster = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - $snapshotId = 'snapshotId-168585866'; - $response = $gapicClient->snapshotTable($formattedName, $formattedCluster, $snapshotId); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/SnapshotTable', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $actualValue = $actualApiRequestObject->getCluster(); - $this->assertProtobufEquals($formattedCluster, $actualValue); - $actualValue = $actualApiRequestObject->getSnapshotId(); - $this->assertProtobufEquals($snapshotId, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/snapshotTableTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function snapshotTableExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/snapshotTableTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $formattedCluster = $gapicClient->clusterName('[PROJECT]', '[INSTANCE]', '[CLUSTER]'); - $snapshotId = 'snapshotId-168585866'; - $response = $gapicClient->snapshotTable($formattedName, $formattedCluster, $snapshotId); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/snapshotTableTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new TestIamPermissionsResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $resource = 'resource-341064690'; - $permissions = []; - $response = $gapicClient->testIamPermissions($resource, $permissions); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/TestIamPermissions', $actualFuncCall); - $actualValue = $actualRequestObject->getResource(); - $this->assertProtobufEquals($resource, $actualValue); - $actualValue = $actualRequestObject->getPermissions(); - $this->assertProtobufEquals($permissions, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function testIamPermissionsExceptionTest() - { - $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 - $resource = 'resource-341064690'; - $permissions = []; - try { - $gapicClient->testIamPermissions($resource, $permissions); - // 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 undeleteTableTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/undeleteTableTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name2 = 'name2-1052831874'; - $deletionProtection = true; - $expectedResponse = new Table(); - $expectedResponse->setName($name2); - $expectedResponse->setDeletionProtection($deletionProtection); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/undeleteTableTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $response = $gapicClient->undeleteTable($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/UndeleteTable', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/undeleteTableTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function undeleteTableExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/undeleteTableTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $formattedName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $response = $gapicClient->undeleteTable($formattedName); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/undeleteTableTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function updateAuthorizedViewTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/updateAuthorizedViewTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $etag = 'etag3123477'; - $deletionProtection = true; - $expectedResponse = new AuthorizedView(); - $expectedResponse->setName($name); - $expectedResponse->setEtag($etag); - $expectedResponse->setDeletionProtection($deletionProtection); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateAuthorizedViewTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $authorizedView = new AuthorizedView(); - $response = $gapicClient->updateAuthorizedView($authorizedView); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/UpdateAuthorizedView', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getAuthorizedView(); - $this->assertProtobufEquals($authorizedView, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateAuthorizedViewTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function updateAuthorizedViewExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/updateAuthorizedViewTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $authorizedView = new AuthorizedView(); - $response = $gapicClient->updateAuthorizedView($authorizedView); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateAuthorizedViewTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function updateBackupTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $name = 'name3373707'; - $sourceTable = 'sourceTable1670858410'; - $sourceBackup = 'sourceBackup-258292122'; - $sizeBytes = 1796325715; - $expectedResponse = new Backup(); - $expectedResponse->setName($name); - $expectedResponse->setSourceTable($sourceTable); - $expectedResponse->setSourceBackup($sourceBackup); - $expectedResponse->setSizeBytes($sizeBytes); - $transport->addResponse($expectedResponse); - // Mock request - $backup = new Backup(); - $backupSourceTable = 'backupSourceTable1043210577'; - $backup->setSourceTable($backupSourceTable); - $backupExpireTime = new Timestamp(); - $backup->setExpireTime($backupExpireTime); - $updateMask = new FieldMask(); - $response = $gapicClient->updateBackup($backup, $updateMask); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/UpdateBackup', $actualFuncCall); - $actualValue = $actualRequestObject->getBackup(); - $this->assertProtobufEquals($backup, $actualValue); - $actualValue = $actualRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function updateBackupExceptionTest() - { - $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 - $backup = new Backup(); - $backupSourceTable = 'backupSourceTable1043210577'; - $backup->setSourceTable($backupSourceTable); - $backupExpireTime = new Timestamp(); - $backup->setExpireTime($backupExpireTime); - $updateMask = new FieldMask(); - try { - $gapicClient->updateBackup($backup, $updateMask); - // 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 updateTableTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/updateTableTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $name = 'name3373707'; - $deletionProtection = true; - $expectedResponse = new Table(); - $expectedResponse->setName($name); - $expectedResponse->setDeletionProtection($deletionProtection); - $anyResponse = new Any(); - $anyResponse->setValue($expectedResponse->serializeToString()); - $completeOperation = new Operation(); - $completeOperation->setName('operations/updateTableTest'); - $completeOperation->setDone(true); - $completeOperation->setResponse($anyResponse); - $operationsTransport->addResponse($completeOperation); - // Mock request - $table = new Table(); - $updateMask = new FieldMask(); - $response = $gapicClient->updateTable($table, $updateMask); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $apiRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($apiRequests)); - $operationsRequestsEmpty = $operationsTransport->popReceivedCalls(); - $this->assertSame(0, count($operationsRequestsEmpty)); - $actualApiFuncCall = $apiRequests[0]->getFuncCall(); - $actualApiRequestObject = $apiRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.admin.v2.BigtableTableAdmin/UpdateTable', $actualApiFuncCall); - $actualValue = $actualApiRequestObject->getTable(); - $this->assertProtobufEquals($table, $actualValue); - $actualValue = $actualApiRequestObject->getUpdateMask(); - $this->assertProtobufEquals($updateMask, $actualValue); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateTableTest'); - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - $this->assertTrue($response->isDone()); - $this->assertEquals($expectedResponse, $response->getResult()); - $apiRequestsEmpty = $transport->popReceivedCalls(); - $this->assertSame(0, count($apiRequestsEmpty)); - $operationsRequests = $operationsTransport->popReceivedCalls(); - $this->assertSame(1, count($operationsRequests)); - $actualOperationsFuncCall = $operationsRequests[0]->getFuncCall(); - $actualOperationsRequestObject = $operationsRequests[0]->getRequestObject(); - $this->assertSame('/google.longrunning.Operations/GetOperation', $actualOperationsFuncCall); - $this->assertEquals($expectedOperationsRequestObject, $actualOperationsRequestObject); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } - - /** @test */ - public function updateTableExceptionTest() - { - $operationsTransport = $this->createTransport(); - $operationsClient = new OperationsClient([ - 'apiEndpoint' => '', - 'transport' => $operationsTransport, - 'credentials' => $this->createCredentials(), - ]); - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - 'operationsClient' => $operationsClient, - ]); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - // Mock response - $incompleteOperation = new Operation(); - $incompleteOperation->setName('operations/updateTableTest'); - $incompleteOperation->setDone(false); - $transport->addResponse($incompleteOperation); - $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); - $operationsTransport->addResponse(null, $status); - // Mock request - $table = new Table(); - $updateMask = new FieldMask(); - $response = $gapicClient->updateTable($table, $updateMask); - $this->assertFalse($response->isDone()); - $this->assertNull($response->getResult()); - $expectedOperationsRequestObject = new GetOperationRequest(); - $expectedOperationsRequestObject->setName('operations/updateTableTest'); - try { - $response->pollUntilComplete([ - 'initialPollDelayMillis' => 1, - ]); - // If the pollUntilComplete() 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 stubs are exhausted - $transport->popReceivedCalls(); - $operationsTransport->popReceivedCalls(); - $this->assertTrue($transport->isExhausted()); - $this->assertTrue($operationsTransport->isExhausted()); - } -} From 837dfc600ac29f4c31eca030833ab7669492607a Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Fri, 24 May 2024 15:35:25 +0530 Subject: [PATCH 29/36] Addressed PR comments --- Bigtable/src/ResumableStream.php | 37 ++++++++++++-------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/Bigtable/src/ResumableStream.php b/Bigtable/src/ResumableStream.php index 84800eb714d..597a8fa391a 100644 --- a/Bigtable/src/ResumableStream.php +++ b/Bigtable/src/ResumableStream.php @@ -75,9 +75,9 @@ class ResumableStream implements \IteratorAggregate private $retryFunction; /** - * array $optionalArgs + * @var array */ - private $optionalArgs; + private $callOptions; /** * Constructs a resumable stream. @@ -88,7 +88,7 @@ class ResumableStream implements \IteratorAggregate * @param callable $argumentFunction Function which returns the argument to be used while * calling `$apiFunction`. * @param callable $retryFunction Function which determines whether to retry or not. - * @param array $optionalArgs { + * @param array $callOptions { * @option RetrySettings|array $retrySettings { * @option int $maxRetries Number of times to retry. **Defaults to** `3`. * Only maxRetries works for RetrySettings in this API. @@ -101,21 +101,20 @@ public function __construct( Message $request, callable $argumentFunction, callable $retryFunction, - array $optionalArgs = [] + array $callOptions = [] ) { $this->gapicClient = $gapicClient; $this->method = $method; $this->request = $request; - $this->retries = $this->getMaxRetries($optionalArgs); + $this->retries = $this->getMaxRetries($callOptions); $this->argumentFunction = $argumentFunction; $this->retryFunction = $retryFunction; + $this->callOptions = $callOptions; // Disable GAX retries because we want to handle the retries here. // Once GAX has the provision to modify request/args in between retries, // we can re enable GAX's retries and use them completely. - $this->optionalArgs = $optionalArgs + [ - 'retrySettings' => [ - 'retriesEnabled' => false - ] + $this->callOptions['retrySettings'] = [ + 'retriesEnabled' => false ]; } @@ -132,14 +131,14 @@ public function readAll() $retryFunction = $this->retryFunction; do { $ex = null; - list($this->request, $this->optionalArgs) = $argumentFunction($this->request, $this->optionalArgs); + list($this->request, $this->callOptions) = $argumentFunction($this->request, $this->callOptions); - $completed = $this->pluck('requestCompleted', $this->optionalArgs, false); + $completed = $this->pluck('requestCompleted', $this->callOptions, false); if ($completed !== true) { $stream = call_user_func_array( [$this->gapicClient, $this->method], - [$this->request, $this->optionalArgs] + [$this->request, $this->callOptions] ); try { @@ -178,22 +177,14 @@ public static function isRetryable($code) return isset(self::$retryableStatusCodes[$code]); } - private function getMaxRetries(array &$options) : int + private function getMaxRetries(array $options) : int { - $options += [ - 'retrySettings' => [ - 'maxRetries' => ResumableStream::DEFAULT_MAX_RETRIES - ] - ]; - - // We remove the retrySettings from the options array because - // we don't need to forward it to GAX anyway. - $retrySettings = $this->pluck('retrySettings', $options, false); + $retrySettings = $options['retrySettings'] ?? []; if ($retrySettings instanceof RetrySettings) { return $retrySettings->getMaxRetries(); } - return $retrySettings['maxRetries']; + return $retrySettings['maxRetries'] ?? ResumableStream::DEFAULT_MAX_RETRIES; } } From e8e97154125f735aaa850f8b9d1283a68bf22930 Mon Sep 17 00:00:00 2001 From: saranshdhingra Date: Fri, 24 May 2024 15:42:09 +0530 Subject: [PATCH 30/36] Updated migrating guide --- Bigtable/MIGRATING.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Bigtable/MIGRATING.md b/Bigtable/MIGRATING.md index 72572f534a8..8f936575542 100644 --- a/Bigtable/MIGRATING.md +++ b/Bigtable/MIGRATING.md @@ -47,6 +47,10 @@ Only the maxRetries parameter is supported for now and not the other options in ### Removed deprecated classes The following deprecated classes are now removed completely. Use the specified alternatives. +- `Google\Cloud\Bigtable\V2\Gapic\BigtableGapicClient`, use `Google\Cloud\Bigtable\V2\Client\BigtableClient` instead. +- `Google\Cloud\Bigtable\V2\BigtableClient`, use `Google\Cloud\Bigtable\V2\Client\BigtableClient` instead. +- `Google\Cloud\Bigtable\Admin\V2\Gapic\BigtableInstanceAdminGapicClient`, use `Google\Cloud\Bigtable\Admin\V2\Client\BigtableInstanceAdminClient` instead. +- `Google\Cloud\Bigtable\Admin\V2\Gapic\BigtableTableAdminGapicClient`, use `Google\Cloud\Bigtable\Admin\V2\Client\BigtableTableAdminClient` instead. - `Google\Cloud\Bigtable\V2\MutateRowsRequest_Entry`, use `Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry` instead. - `Google\Cloud\Bigtable\V2\MutateRowsResponse_Entry`, use `Google\Cloud\Bigtable\V2\MutateRowsResponse\Entry` instead. - `Google\Cloud\Bigtable\V2\Mutation_DeleteFromFamily`, use `Google\Cloud\Bigtable\V2\Mutation\DeleteFromFamily` instead. @@ -64,3 +68,24 @@ The following deprecated classes are now removed completely. Use the specified a - `Google\Cloud\Bigtable\V2\RowFilter_Condition`, use `Google\Cloud\Bigtable\V2\RowFilter\Condition` instead. - `Google\Cloud\Bigtable\V2\RowFilter_Interleave`, use `Google\Cloud\Bigtable\V2\RowFilter\Interleave` instead. - `Google\Cloud\Bigtable\V2\ReadRowsResponse_CellChunk`, use `Google\Cloud\Bigtable\V2\ReadRowsResponse\CellChunk` instead. +- `Google\Cloud\Bigtable\Admin\V2\AppProfile_MultiClusterRoutingUseAny`, use `Google\Cloud\Bigtable\Admin\V2\AppProfile\MultiClusterRoutingUseAny` instead. +- `Google\Cloud\Bigtable\Admin\V2\AppProfile_SingleClusterRouting`, use `Google\Cloud\Bigtable\Admin\V2\AppProfile\SingleClusterRouting` instead. +- `Google\Cloud\Bigtable\Admin\V2\Backup_State`, use `Google\Cloud\Bigtable\Admin\V2\Backup\State` instead. +- `Google\Cloud\Bigtable\Admin\V2\Cluster_ClusterAutoscalingConfig`, use `Google\Cloud\Bigtable\Admin\V2\Cluster\ClusterAutoscalingConfig` instead. +- `Google\Cloud\Bigtable\Admin\V2\Cluster_ClusterConfig`, use `Google\Cloud\Bigtable\Admin\V2\Cluster\ClusterConfig` instead. +- `Google\Cloud\Bigtable\Admin\V2\Cluster_EncryptionConfig`, use `Google\Cloud\Bigtable\Admin\V2\Cluster\EncryptionConfig` instead. +- `Google\Cloud\Bigtable\Admin\V2\Cluster_State`, use `Google\Cloud\Bigtable\Admin\V2\Cluster\State` instead. +- `Google\Cloud\Bigtable\Admin\V2\CreateClusterMetadata_TableProgress`, use `Google\Cloud\Bigtable\Admin\V2\CreateClusterMetadata\TableProgress` instead. +- `Google\Cloud\Bigtable\Admin\V2\CreateClusterMetadata_TableProgress_State`, use `Google\Cloud\Bigtable\Admin\V2\CreateClusterMetadata\TableProgress\State` instead. +- `Google\Cloud\Bigtable\Admin\V2\CreateTableRequest_Split`, use `Google\Cloud\Bigtable\Admin\V2\CreateTableRequest\Split` instead. +- `Google\Cloud\Bigtable\Admin\V2\EncryptionInfo_EncryptionType`, use `Google\Cloud\Bigtable\Admin\V2\EncryptionInfo\EncryptionType` instead. +- `Google\Cloud\Bigtable\Admin\V2\GcRule_Intersection`, use `Google\Cloud\Bigtable\Admin\V2\GcRule\Intersection` instead. +- `Google\Cloud\Bigtable\Admin\V2\GcRule_Union`, use `Google\Cloud\Bigtable\Admin\V2\GcRule\Union` instead. +- `Google\Cloud\Bigtable\Admin\V2\Instance_State`, use `Google\Cloud\Bigtable\Admin\V2\Instance\State` instead. +- `Google\Cloud\Bigtable\Admin\V2\Instance_Type`, use `Google\Cloud\Bigtable\Admin\V2\Instance\Type` instead. +- `Google\Cloud\Bigtable\Admin\V2\ModifyColumnFamiliesRequest_Modification`, use `Google\Cloud\Bigtable\Admin\V2\ModifyColumnFamiliesRequest\Modification` instead. +- `Google\Cloud\Bigtable\Admin\V2\Snapshot_State`, use `Google\Cloud\Bigtable\Admin\V2\Snapshot\State` instead. +- `Google\Cloud\Bigtable\Admin\V2\Table_ClusterState`, use `Google\Cloud\Bigtable\Admin\V2\Table\ClusterState` instead. +- `Google\Cloud\Bigtable\Admin\V2\Table_ClusterState_ReplicationState`, use `Google\Cloud\Bigtable\Admin\V2\Table\ClusterState\ReplicationState` instead. +- `Google\Cloud\Bigtable\Admin\V2\Table_TimestampGranularity`, use `Google\Cloud\Bigtable\Admin\V2\Table\TimestampGranularity` instead. +- `Google\Cloud\Bigtable\Admin\V2\Table_View`, use `Google\Cloud\Bigtable\Admin\V2\Table\View` instead. From 2b1a0caca2c126c768b6cb4161c20a528c0cbdb7 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Fri, 31 May 2024 14:52:36 -0700 Subject: [PATCH 31/36] chore(Bigtable): generator changes from owlbot for V2 (#7352) --- Bigtable/metadata/Admin/V2/Types.php | Bin 1736 -> 1986 bytes Bigtable/owlbot.py | 80 +- Bigtable/src/Admin/V2/AppProfile.php | 6 +- .../AppProfile/DataBoostIsolationReadOnly.php | 2 +- .../V2/AppProfile/SingleClusterRouting.php | 4 +- .../Admin/V2/AppProfile/StandardIsolation.php | 2 +- Bigtable/src/Admin/V2/AuthorizedView.php | 6 +- Bigtable/src/Admin/V2/AutoscalingLimits.php | 4 +- Bigtable/src/Admin/V2/AutoscalingTargets.php | 4 +- Bigtable/src/Admin/V2/Backup.php | 18 +- Bigtable/src/Admin/V2/BackupInfo.php | 10 +- Bigtable/src/Admin/V2/ChangeStreamConfig.php | 2 +- .../src/Admin/V2/CheckConsistencyRequest.php | 4 +- .../src/Admin/V2/CheckConsistencyResponse.php | 2 +- .../V2/Client/BigtableInstanceAdminClient.php | 24 +- .../V2/Client/BigtableTableAdminClient.php | 24 +- Bigtable/src/Admin/V2/Cluster.php | 12 +- .../V2/Cluster/ClusterAutoscalingConfig.php | 4 +- .../src/Admin/V2/Cluster/ClusterConfig.php | 2 +- .../src/Admin/V2/Cluster/EncryptionConfig.php | 2 +- .../src/Admin/V2/Cluster_ClusterConfig.php | 16 - Bigtable/src/Admin/V2/ColumnFamily.php | 4 +- Bigtable/src/Admin/V2/CopyBackupMetadata.php | 6 +- Bigtable/src/Admin/V2/CopyBackupRequest.php | 8 +- .../src/Admin/V2/CreateAppProfileRequest.php | 8 +- .../Admin/V2/CreateAuthorizedViewMetadata.php | 6 +- .../Admin/V2/CreateAuthorizedViewRequest.php | 6 +- .../src/Admin/V2/CreateBackupMetadata.php | 8 +- Bigtable/src/Admin/V2/CreateBackupRequest.php | 6 +- .../src/Admin/V2/CreateClusterMetadata.php | 6 +- .../CreateClusterMetadata/TableProgress.php | 6 +- .../src/Admin/V2/CreateClusterRequest.php | 6 +- .../src/Admin/V2/CreateInstanceMetadata.php | 6 +- .../src/Admin/V2/CreateInstanceRequest.php | 6 +- .../V2/CreateTableFromSnapshotMetadata.php | 6 +- .../V2/CreateTableFromSnapshotRequest.php | 6 +- Bigtable/src/Admin/V2/CreateTableRequest.php | 6 +- .../src/Admin/V2/CreateTableRequest/Split.php | 2 +- .../src/Admin/V2/DeleteAppProfileRequest.php | 4 +- .../Admin/V2/DeleteAuthorizedViewRequest.php | 4 +- Bigtable/src/Admin/V2/DeleteBackupRequest.php | 2 +- .../src/Admin/V2/DeleteClusterRequest.php | 2 +- .../src/Admin/V2/DeleteInstanceRequest.php | 2 +- .../src/Admin/V2/DeleteSnapshotRequest.php | 2 +- Bigtable/src/Admin/V2/DeleteTableRequest.php | 2 +- Bigtable/src/Admin/V2/DropRowRangeRequest.php | 2 +- Bigtable/src/Admin/V2/EncryptionInfo.php | 6 +- .../V2/GenerateConsistencyTokenRequest.php | 2 +- .../V2/GenerateConsistencyTokenResponse.php | 2 +- .../src/Admin/V2/GetAppProfileRequest.php | 2 +- .../src/Admin/V2/GetAuthorizedViewRequest.php | 4 +- Bigtable/src/Admin/V2/GetBackupRequest.php | 2 +- Bigtable/src/Admin/V2/GetClusterRequest.php | 2 +- Bigtable/src/Admin/V2/GetInstanceRequest.php | 2 +- Bigtable/src/Admin/V2/GetSnapshotRequest.php | 2 +- Bigtable/src/Admin/V2/GetTableRequest.php | 4 +- Bigtable/src/Admin/V2/HotTablet.php | 14 +- Bigtable/src/Admin/V2/Instance.php | 12 +- .../src/Admin/V2/ListAppProfilesRequest.php | 6 +- .../src/Admin/V2/ListAppProfilesResponse.php | 2 +- .../Admin/V2/ListAuthorizedViewsRequest.php | 8 +- .../Admin/V2/ListAuthorizedViewsResponse.php | 2 +- Bigtable/src/Admin/V2/ListBackupsRequest.php | 10 +- Bigtable/src/Admin/V2/ListBackupsResponse.php | 2 +- Bigtable/src/Admin/V2/ListClustersRequest.php | 4 +- .../src/Admin/V2/ListClustersResponse.php | 2 +- .../src/Admin/V2/ListHotTabletsRequest.php | 10 +- .../src/Admin/V2/ListHotTabletsResponse.php | 2 +- .../src/Admin/V2/ListInstancesRequest.php | 4 +- .../src/Admin/V2/ListInstancesResponse.php | 2 +- .../src/Admin/V2/ListSnapshotsRequest.php | 6 +- .../src/Admin/V2/ListSnapshotsResponse.php | 2 +- Bigtable/src/Admin/V2/ListTablesRequest.php | 8 +- Bigtable/src/Admin/V2/ListTablesResponse.php | 2 +- .../Admin/V2/ModifyColumnFamiliesRequest.php | 4 +- .../Modification.php | 4 +- Bigtable/src/Admin/V2/OperationProgress.php | 6 +- .../V2/OptimizeRestoredTableMetadata.php | 4 +- .../Admin/V2/PartialUpdateClusterMetadata.php | 6 +- .../Admin/V2/PartialUpdateClusterRequest.php | 4 +- .../Admin/V2/PartialUpdateInstanceRequest.php | 4 +- Bigtable/src/Admin/V2/RestoreInfo.php | 2 +- .../src/Admin/V2/RestoreTableMetadata.php | 8 +- Bigtable/src/Admin/V2/RestoreTableRequest.php | 4 +- Bigtable/src/Admin/V2/Snapshot.php | 14 +- .../src/Admin/V2/SnapshotTableMetadata.php | 6 +- .../src/Admin/V2/SnapshotTableRequest.php | 10 +- Bigtable/src/Admin/V2/Table.php | 10 +- .../Admin/V2/Table/AutomatedBackupPolicy.php | 4 +- Bigtable/src/Admin/V2/Table/ClusterState.php | 2 +- Bigtable/src/Admin/V2/Type.php | 39 +- Bigtable/src/Admin/V2/Type/Aggregate.php | 4 +- Bigtable/src/Admin/V2/Type/Bytes.php | 2 +- Bigtable/src/Admin/V2/Type/Int64.php | 2 +- .../V2/Type/Int64/Encoding/BigEndianBytes.php | 2 +- Bigtable/src/Admin/V2/Type/PBString.php | 81 ++ .../src/Admin/V2/Type/PBString/Encoding.php | 78 ++ .../V2/Type/PBString/Encoding/Utf8Raw.php | 42 + .../src/Admin/V2/UndeleteTableMetadata.php | 6 +- .../src/Admin/V2/UndeleteTableRequest.php | 2 +- .../src/Admin/V2/UpdateAppProfileRequest.php | 6 +- .../Admin/V2/UpdateAuthorizedViewMetadata.php | 6 +- .../Admin/V2/UpdateAuthorizedViewRequest.php | 6 +- Bigtable/src/Admin/V2/UpdateBackupRequest.php | 4 +- .../src/Admin/V2/UpdateClusterMetadata.php | 6 +- .../src/Admin/V2/UpdateInstanceMetadata.php | 6 +- Bigtable/src/Admin/V2/UpdateTableMetadata.php | 6 +- Bigtable/src/Admin/V2/UpdateTableRequest.php | 4 +- Bigtable/src/Admin/V2/gapic_metadata.json | 282 +++++++ Bigtable/src/BigtableClient.php | 17 +- Bigtable/src/V2/AllReadStats.php | 137 ---- Bigtable/src/V2/Cell.php | 4 +- Bigtable/src/V2/CheckAndMutateRowRequest.php | 10 +- Bigtable/src/V2/CheckAndMutateRowResponse.php | 2 +- Bigtable/src/V2/Client/BigtableClient.php | 24 +- Bigtable/src/V2/Column.php | 2 +- Bigtable/src/V2/ColumnRange.php | 2 +- Bigtable/src/V2/Family.php | 2 +- Bigtable/src/V2/FeatureFlags.php | 14 +- Bigtable/src/V2/FullReadStatsView.php | 4 +- ...teInitialChangeStreamPartitionsRequest.php | 4 +- ...eInitialChangeStreamPartitionsResponse.php | 2 +- Bigtable/src/V2/MutateRowRequest.php | 8 +- Bigtable/src/V2/MutateRowsRequest.php | 6 +- Bigtable/src/V2/MutateRowsRequest/Entry.php | 2 +- Bigtable/src/V2/MutateRowsResponse.php | 2 +- Bigtable/src/V2/MutateRowsResponse/Entry.php | 4 +- Bigtable/src/V2/Mutation/AddToCell.php | 8 +- Bigtable/src/V2/Mutation/DeleteFromColumn.php | 6 +- Bigtable/src/V2/Mutation/DeleteFromFamily.php | 2 +- Bigtable/src/V2/Mutation/SetCell.php | 8 +- Bigtable/src/V2/PingAndWarmRequest.php | 4 +- Bigtable/src/V2/RateLimitInfo.php | 4 +- Bigtable/src/V2/ReadChangeStreamRequest.php | 10 +- .../ReadChangeStreamResponse/CloseStream.php | 2 +- .../ReadChangeStreamResponse/DataChange.php | 16 +- .../V2/ReadChangeStreamResponse/Heartbeat.php | 4 +- .../MutationChunk.php | 4 +- .../MutationChunk/ChunkInfo.php | 6 +- Bigtable/src/V2/ReadEfficiencyStats.php | 137 ---- Bigtable/src/V2/ReadIterationStats.php | 8 +- Bigtable/src/V2/ReadIteratorStats.php | 213 ----- Bigtable/src/V2/ReadModifyWriteRowRequest.php | 8 +- .../src/V2/ReadModifyWriteRowResponse.php | 2 +- Bigtable/src/V2/ReadModifyWriteRule.php | 4 +- Bigtable/src/V2/ReadRowsRequest.php | 16 +- Bigtable/src/V2/ReadRowsResponse.php | 4 +- .../src/V2/ReadRowsResponse/CellChunk.php | 20 +- Bigtable/src/V2/RequestLatencyStats.php | 2 +- Bigtable/src/V2/ResponseParams.php | 4 +- Bigtable/src/V2/Row.php | 2 +- Bigtable/src/V2/RowFilter/Condition.php | 6 +- Bigtable/src/V2/SampleRowKeysRequest.php | 6 +- Bigtable/src/V2/SampleRowKeysResponse.php | 4 +- Bigtable/src/V2/StreamContinuationToken.php | 4 +- Bigtable/src/V2/StreamPartition.php | 2 +- Bigtable/src/V2/TimestampRange.php | 4 +- Bigtable/tests/System/BigtableTestCase.php | 7 +- .../BigtableInstanceAdminClientTest.php | 3 +- .../Client/BigtableTableAdminClientTest.php | 3 +- Bigtable/tests/Unit/V2/BigtableClientTest.php | 771 ------------------ 161 files changed, 967 insertions(+), 1735 deletions(-) delete mode 100644 Bigtable/src/Admin/V2/Cluster_ClusterConfig.php create mode 100644 Bigtable/src/Admin/V2/Type/PBString.php create mode 100644 Bigtable/src/Admin/V2/Type/PBString/Encoding.php create mode 100644 Bigtable/src/Admin/V2/Type/PBString/Encoding/Utf8Raw.php create mode 100644 Bigtable/src/Admin/V2/gapic_metadata.json delete mode 100644 Bigtable/src/V2/AllReadStats.php delete mode 100644 Bigtable/src/V2/ReadEfficiencyStats.php delete mode 100644 Bigtable/src/V2/ReadIteratorStats.php delete mode 100644 Bigtable/tests/Unit/V2/BigtableClientTest.php diff --git a/Bigtable/metadata/Admin/V2/Types.php b/Bigtable/metadata/Admin/V2/Types.php index bee616b20e2a6164f9d554b74367dc2500212da2..4dedcc0cac878a14afce4a49ff34d23bfdc45ff6 100644 GIT binary patch delta 191 zcmX@Xdx(F7029k|E-sac-YSzVn53DGb4(6pau&1U;w~;J%FIiTFR3g@m0(g})ZjK! zom|Ky&lU_8-#nE`pHXfnBNvn}|029kw4lb36-YSzVn53D`vP}+Ua^8H6Nr!RsJ{A^c0M3RAt^fc4 diff --git a/Bigtable/owlbot.py b/Bigtable/owlbot.py index 56fef857879..a770b3d174e 100644 --- a/Bigtable/owlbot.py +++ b/Bigtable/owlbot.py @@ -38,88 +38,18 @@ src=src, dest=dest, copy_excludes=[ - src / "*/src/V2/BigtableClient.php" + src / "**/[A-Z]*_*.php", ] ) # First copy the Bigtable Admin admin_library = Path(f"../{php.STAGING_DIR}/Bigtable/v2/Admin").resolve() -# copy all src except handwritten partial veneers -s.move(admin_library / f'src/V2/Gapic', 'src/Admin/V2/Gapic', merge=preserve_copyright_year) -s.move(admin_library / f'src/V2/Client', 'src/Admin/V2/Client', merge=preserve_copyright_year) -s.move(admin_library / f'src/V2/resources', f'src/Admin/V2/resources', merge=preserve_copyright_year) - -# copy proto files to src also -s.move(admin_library / f'proto/src/Google/Cloud/Bigtable', f'src/', merge=preserve_copyright_year) +# copy gapic src and tests +s.move(admin_library / f'src', 'src/Admin', merge=preserve_copyright_year) s.move(admin_library / f'tests/Unit', 'tests/Unit/Admin', merge=preserve_copyright_year) -# copy GPBMetadata file to metadata +# copy proto and metadata files +s.move(admin_library / f'proto/src/Google/Cloud/Bigtable', f'src/', merge=preserve_copyright_year) s.move(admin_library / f'proto/src/GPBMetadata/Google/Bigtable', f'metadata/', merge=preserve_copyright_year) - -# fix unit test namespace -s.replace( - 'tests/Unit/Admin/*/*.php', - r'namespace Google\\Cloud\\Bigtable\\Admin\\Tests\\Unit', - r'namespace Google\\Cloud\\Bigtable\\Tests\\Unit\\Admin') - -# fix test group -s.replace( - 'tests/**/Admin/**/*Test.php', - '@group admin', - '@group bigtable' + '\n' + ' * bigtable-admin') - -# Fix class references in gapic samples -for version in ['V2']: - pathExpr = [ - 'src/' + version + '/Gapic/BigtableGapicClient.php', - 'src/Admin/' + version + '/Gapic/*GapicClient.php' - ] - - types = { - 'new BigtableClient': r'new Google\\Cloud\\Bigtable\\' + version + r'\\BigtableClient', - 'new BigtableInstanceAdminClient': r'new Google\\Cloud\\Bigtable\\Admin\\' + version + r'\\BigtableInstanceAdminClient', - r'\$instance = new Instance': r'$instance = new Google\\Cloud\\Bigtable\\Admin\\' + version + r'\\Instance', - '= Type::': r'= Google\\Cloud\\Bigtable\\Admin\\' + version + r'\\Instance\\Type::', - 'new FieldMask': r'new Google\\Protobuf\\FieldMask', - r'\$cluster = new Cluster': r'$cluster = new Google\\Cloud\\Bigtable\\Admin\\' + version + r'\\Cluster', - 'new AppProfile': r'new Google\\Cloud\\Bigtable\\Admin\\' + version + r'\\AppProfile', - 'new Policy': r'new Google\\Cloud\\Iam\\V1\\Policy', - 'new BigtableTableAdminClient': r'new Google\\Cloud\\Bigtable\\Admin\\' + version + r'\\BigtableTableAdminClient', - 'new Table': r'new Google\\Cloud\\Bigtable\\Admin\\' + version + r'\\Table', - } - - for search, replace in types.items(): - s.replace( - pathExpr, - search, - replace -) - -### [START] protoc backwards compatibility fixes - -# roll back to private properties. -s.replace( - "src/**/V*/**/*.php", - r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$", - r"""Generated from protobuf field \1 - */ - private $""") - -# Replace "Unwrapped" with "Value" for method names. -s.replace( - "src/**/V*/**/*.php", - r"public function ([s|g]\w{3,})Unwrapped", - r"public function \1Value" -) - -### [END] protoc backwards compatibility fixes - -# fix relative cloud.google.com links -s.replace( - "src/**/V*/**/*.php", - r"(.{0,})\]\((/.{0,})\)", - r"\1](https://cloud.google.com\2)" -) - diff --git a/Bigtable/src/Admin/V2/AppProfile.php b/Bigtable/src/Admin/V2/AppProfile.php index 7dca81d1a90..4eb3ef034a7 100644 --- a/Bigtable/src/Admin/V2/AppProfile.php +++ b/Bigtable/src/Admin/V2/AppProfile.php @@ -22,7 +22,7 @@ class AppProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Strongly validated etag for optimistic concurrency control. Preserve the * value returned from `GetAppProfile` when calling `UpdateAppProfile` to @@ -35,13 +35,13 @@ class AppProfile extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string etag = 2; */ - private $etag = ''; + protected $etag = ''; /** * Long form description of the use case for this AppProfile. * * Generated from protobuf field string description = 3; */ - private $description = ''; + protected $description = ''; protected $routing_policy; protected $isolation; diff --git a/Bigtable/src/Admin/V2/AppProfile/DataBoostIsolationReadOnly.php b/Bigtable/src/Admin/V2/AppProfile/DataBoostIsolationReadOnly.php index 98124477661..7a8e71fd801 100644 --- a/Bigtable/src/Admin/V2/AppProfile/DataBoostIsolationReadOnly.php +++ b/Bigtable/src/Admin/V2/AppProfile/DataBoostIsolationReadOnly.php @@ -30,7 +30,7 @@ class DataBoostIsolationReadOnly extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional .google.bigtable.admin.v2.AppProfile.DataBoostIsolationReadOnly.ComputeBillingOwner compute_billing_owner = 1; */ - private $compute_billing_owner = null; + protected $compute_billing_owner = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/AppProfile/SingleClusterRouting.php b/Bigtable/src/Admin/V2/AppProfile/SingleClusterRouting.php index 4bdf45e1f03..5bd27b02ed0 100644 --- a/Bigtable/src/Admin/V2/AppProfile/SingleClusterRouting.php +++ b/Bigtable/src/Admin/V2/AppProfile/SingleClusterRouting.php @@ -22,7 +22,7 @@ class SingleClusterRouting extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cluster_id = 1; */ - private $cluster_id = ''; + protected $cluster_id = ''; /** * Whether or not `CheckAndMutateRow` and `ReadModifyWriteRow` requests are * allowed by this app profile. It is unsafe to send these requests to @@ -30,7 +30,7 @@ class SingleClusterRouting extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool allow_transactional_writes = 2; */ - private $allow_transactional_writes = false; + protected $allow_transactional_writes = false; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/AppProfile/StandardIsolation.php b/Bigtable/src/Admin/V2/AppProfile/StandardIsolation.php index 42e7b0d4dbb..3638ebc7521 100644 --- a/Bigtable/src/Admin/V2/AppProfile/StandardIsolation.php +++ b/Bigtable/src/Admin/V2/AppProfile/StandardIsolation.php @@ -21,7 +21,7 @@ class StandardIsolation extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.AppProfile.Priority priority = 1; */ - private $priority = 0; + protected $priority = 0; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/AuthorizedView.php b/Bigtable/src/Admin/V2/AuthorizedView.php index f891a683d9f..a5533981fbc 100644 --- a/Bigtable/src/Admin/V2/AuthorizedView.php +++ b/Bigtable/src/Admin/V2/AuthorizedView.php @@ -24,7 +24,7 @@ class AuthorizedView extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; */ - private $name = ''; + protected $name = ''; /** * The etag for this AuthorizedView. * If this is provided on update, it must match the server's etag. The server @@ -32,7 +32,7 @@ class AuthorizedView extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string etag = 3; */ - private $etag = ''; + protected $etag = ''; /** * Set to true to make the AuthorizedView protected against deletion. * The parent Table and containing Instance cannot be deleted if an @@ -40,7 +40,7 @@ class AuthorizedView extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool deletion_protection = 4; */ - private $deletion_protection = false; + protected $deletion_protection = false; protected $authorized_view; /** diff --git a/Bigtable/src/Admin/V2/AutoscalingLimits.php b/Bigtable/src/Admin/V2/AutoscalingLimits.php index da98a23a0c7..87c9350253d 100644 --- a/Bigtable/src/Admin/V2/AutoscalingLimits.php +++ b/Bigtable/src/Admin/V2/AutoscalingLimits.php @@ -20,13 +20,13 @@ class AutoscalingLimits extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 min_serve_nodes = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $min_serve_nodes = 0; + protected $min_serve_nodes = 0; /** * Required. Maximum number of nodes to scale up to. * * Generated from protobuf field int32 max_serve_nodes = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $max_serve_nodes = 0; + protected $max_serve_nodes = 0; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/AutoscalingTargets.php b/Bigtable/src/Admin/V2/AutoscalingTargets.php index 7faa6668dd6..4825251531f 100644 --- a/Bigtable/src/Admin/V2/AutoscalingTargets.php +++ b/Bigtable/src/Admin/V2/AutoscalingTargets.php @@ -23,7 +23,7 @@ class AutoscalingTargets extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 cpu_utilization_percent = 2; */ - private $cpu_utilization_percent = 0; + protected $cpu_utilization_percent = 0; /** * The storage utilization that the Autoscaler should be trying to achieve. * This number is limited between 2560 (2.5TiB) and 5120 (5TiB) for a SSD @@ -34,7 +34,7 @@ class AutoscalingTargets extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 storage_utilization_gib_per_node = 3; */ - private $storage_utilization_gib_per_node = 0; + protected $storage_utilization_gib_per_node = 0; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/Backup.php b/Bigtable/src/Admin/V2/Backup.php index 45cdcd433d9..6dbc78c186c 100644 --- a/Bigtable/src/Admin/V2/Backup.php +++ b/Bigtable/src/Admin/V2/Backup.php @@ -28,7 +28,7 @@ class Backup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Required. Immutable. Name of the table from which this backup was created. * This needs to be in the same instance as the backup. Values are of the form @@ -36,7 +36,7 @@ class Backup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_table = 2 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = REQUIRED]; */ - private $source_table = ''; + protected $source_table = ''; /** * Output only. Name of the backup from which this backup was copied. If a * backup is not created by copying a backup, this field will be empty. Values @@ -44,7 +44,7 @@ class Backup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_backup = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $source_backup = ''; + protected $source_backup = ''; /** * Required. The expiration time of the backup, with microseconds * granularity that must be at least 6 hours and at most 90 days @@ -54,7 +54,7 @@ class Backup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp expire_time = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $expire_time = null; + protected $expire_time = null; /** * Output only. `start_time` is the time that the backup was started * (i.e. approximately the time the @@ -64,32 +64,32 @@ class Backup extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp start_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $start_time = null; + protected $start_time = null; /** * Output only. `end_time` is the time that the backup was finished. The row * data in the backup will be no newer than this timestamp. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * Output only. Size of the backup in bytes. * * Generated from protobuf field int64 size_bytes = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $size_bytes = 0; + protected $size_bytes = 0; /** * Output only. The current state of the backup. * * Generated from protobuf field .google.bigtable.admin.v2.Backup.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Output only. The encryption information for the backup. * * Generated from protobuf field .google.bigtable.admin.v2.EncryptionInfo encryption_info = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $encryption_info = null; + protected $encryption_info = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/BackupInfo.php b/Bigtable/src/Admin/V2/BackupInfo.php index 6b7445be61b..97b8b310985 100644 --- a/Bigtable/src/Admin/V2/BackupInfo.php +++ b/Bigtable/src/Admin/V2/BackupInfo.php @@ -20,27 +20,27 @@ class BackupInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string backup = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $backup = ''; + protected $backup = ''; /** * Output only. The time that the backup was started. Row data in the backup * will be no older than this timestamp. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $start_time = null; + protected $start_time = null; /** * Output only. This time that the backup was finished. Row data in the * backup will be no newer than this timestamp. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * Output only. Name of the table the backup was created from. * * Generated from protobuf field string source_table = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $source_table = ''; + protected $source_table = ''; /** * Output only. Name of the backup from which this backup was copied. If a * backup is not created by copying a backup, this field will be empty. Values @@ -48,7 +48,7 @@ class BackupInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_backup = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $source_backup = ''; + protected $source_backup = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/ChangeStreamConfig.php b/Bigtable/src/Admin/V2/ChangeStreamConfig.php index 592d8a711cd..49dbf3a3665 100644 --- a/Bigtable/src/Admin/V2/ChangeStreamConfig.php +++ b/Bigtable/src/Admin/V2/ChangeStreamConfig.php @@ -24,7 +24,7 @@ class ChangeStreamConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration retention_period = 1; */ - private $retention_period = null; + protected $retention_period = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/CheckConsistencyRequest.php b/Bigtable/src/Admin/V2/CheckConsistencyRequest.php index 1a96e4a2a4a..543b4f86156 100644 --- a/Bigtable/src/Admin/V2/CheckConsistencyRequest.php +++ b/Bigtable/src/Admin/V2/CheckConsistencyRequest.php @@ -23,13 +23,13 @@ class CheckConsistencyRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The token created using GenerateConsistencyToken for the Table. * * Generated from protobuf field string consistency_token = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $consistency_token = ''; + protected $consistency_token = ''; protected $mode; /** diff --git a/Bigtable/src/Admin/V2/CheckConsistencyResponse.php b/Bigtable/src/Admin/V2/CheckConsistencyResponse.php index b4f54edcb24..86e78943268 100644 --- a/Bigtable/src/Admin/V2/CheckConsistencyResponse.php +++ b/Bigtable/src/Admin/V2/CheckConsistencyResponse.php @@ -22,7 +22,7 @@ class CheckConsistencyResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool consistent = 1; */ - private $consistent = false; + protected $consistent = false; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/Client/BigtableInstanceAdminClient.php b/Bigtable/src/Admin/V2/Client/BigtableInstanceAdminClient.php index db440391631..cb02d2714e8 100644 --- a/Bigtable/src/Admin/V2/Client/BigtableInstanceAdminClient.php +++ b/Bigtable/src/Admin/V2/Client/BigtableInstanceAdminClient.php @@ -1,6 +1,6 @@ setDefaultEmulatorConfig($options); $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); $this->operationsClient = $this->createOperationsClient($clientOptions); @@ -972,4 +975,23 @@ public function updateInstance(Instance $request, array $callOptions = []): Inst { return $this->startApiCall('UpdateInstance', $request, $callOptions)->wait(); } + + /** Configure the gapic configuration to use a service emulator. */ + private function setDefaultEmulatorConfig(array $options): array + { + $emulatorHost = getenv('BIGTABLE_EMULATOR_HOST'); + if (empty($emulatorHost)) { + return $options; + } + + if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) { + $search = $scheme . '://'; + $emulatorHost = str_replace($search, '', $emulatorHost); + } + + $options['apiEndpoint'] ??= $emulatorHost; + $options['transportConfig']['grpc']['stubOpts']['credentials'] ??= ChannelCredentials::createInsecure(); + $options['credentials'] ??= new InsecureCredentialsWrapper(); + return $options; + } } diff --git a/Bigtable/src/Admin/V2/Client/BigtableTableAdminClient.php b/Bigtable/src/Admin/V2/Client/BigtableTableAdminClient.php index 2bad059c593..c5afa40d8dd 100644 --- a/Bigtable/src/Admin/V2/Client/BigtableTableAdminClient.php +++ b/Bigtable/src/Admin/V2/Client/BigtableTableAdminClient.php @@ -1,6 +1,6 @@ setDefaultEmulatorConfig($options); $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); $this->operationsClient = $this->createOperationsClient($clientOptions); @@ -1291,4 +1294,23 @@ public function updateTable(UpdateTableRequest $request, array $callOptions = [] { return $this->startApiCall('UpdateTable', $request, $callOptions)->wait(); } + + /** Configure the gapic configuration to use a service emulator. */ + private function setDefaultEmulatorConfig(array $options): array + { + $emulatorHost = getenv('BIGTABLE_EMULATOR_HOST'); + if (empty($emulatorHost)) { + return $options; + } + + if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) { + $search = $scheme . '://'; + $emulatorHost = str_replace($search, '', $emulatorHost); + } + + $options['apiEndpoint'] ??= $emulatorHost; + $options['transportConfig']['grpc']['stubOpts']['credentials'] ??= ChannelCredentials::createInsecure(); + $options['credentials'] ??= new InsecureCredentialsWrapper(); + return $options; + } } diff --git a/Bigtable/src/Admin/V2/Cluster.php b/Bigtable/src/Admin/V2/Cluster.php index 21ebc80ddbd..4039b9ce2cb 100644 --- a/Bigtable/src/Admin/V2/Cluster.php +++ b/Bigtable/src/Admin/V2/Cluster.php @@ -23,7 +23,7 @@ class Cluster extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Immutable. The location where this cluster's nodes and storage reside. For * best performance, clients should be located as close as possible to this @@ -32,33 +32,33 @@ class Cluster extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string location = 2 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.resource_reference) = { */ - private $location = ''; + protected $location = ''; /** * Output only. The current state of the cluster. * * Generated from protobuf field .google.bigtable.admin.v2.Cluster.State state = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * The number of nodes allocated to this cluster. More nodes enable higher * throughput and more consistent performance. * * Generated from protobuf field int32 serve_nodes = 4; */ - private $serve_nodes = 0; + protected $serve_nodes = 0; /** * Immutable. The type of storage used by this cluster to serve its * parent instance's tables, unless explicitly overridden. * * Generated from protobuf field .google.bigtable.admin.v2.StorageType default_storage_type = 5 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $default_storage_type = 0; + protected $default_storage_type = 0; /** * Immutable. The encryption configuration for CMEK-protected clusters. * * Generated from protobuf field .google.bigtable.admin.v2.Cluster.EncryptionConfig encryption_config = 6 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $encryption_config = null; + protected $encryption_config = null; protected $config; /** diff --git a/Bigtable/src/Admin/V2/Cluster/ClusterAutoscalingConfig.php b/Bigtable/src/Admin/V2/Cluster/ClusterAutoscalingConfig.php index b66b8c8de5f..997961367dd 100644 --- a/Bigtable/src/Admin/V2/Cluster/ClusterAutoscalingConfig.php +++ b/Bigtable/src/Admin/V2/Cluster/ClusterAutoscalingConfig.php @@ -20,13 +20,13 @@ class ClusterAutoscalingConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.AutoscalingLimits autoscaling_limits = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $autoscaling_limits = null; + protected $autoscaling_limits = null; /** * Required. Autoscaling targets for this cluster. * * Generated from protobuf field .google.bigtable.admin.v2.AutoscalingTargets autoscaling_targets = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $autoscaling_targets = null; + protected $autoscaling_targets = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/Cluster/ClusterConfig.php b/Bigtable/src/Admin/V2/Cluster/ClusterConfig.php index e8d1f29fc4a..b8856b291e6 100644 --- a/Bigtable/src/Admin/V2/Cluster/ClusterConfig.php +++ b/Bigtable/src/Admin/V2/Cluster/ClusterConfig.php @@ -20,7 +20,7 @@ class ClusterConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Cluster.ClusterAutoscalingConfig cluster_autoscaling_config = 1; */ - private $cluster_autoscaling_config = null; + protected $cluster_autoscaling_config = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/Cluster/EncryptionConfig.php b/Bigtable/src/Admin/V2/Cluster/EncryptionConfig.php index 711feebc663..3294a44ba56 100644 --- a/Bigtable/src/Admin/V2/Cluster/EncryptionConfig.php +++ b/Bigtable/src/Admin/V2/Cluster/EncryptionConfig.php @@ -30,7 +30,7 @@ class EncryptionConfig extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string kms_key_name = 1 [(.google.api.resource_reference) = { */ - private $kms_key_name = ''; + protected $kms_key_name = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/Cluster_ClusterConfig.php b/Bigtable/src/Admin/V2/Cluster_ClusterConfig.php deleted file mode 100644 index c9ebe8b4beb..00000000000 --- a/Bigtable/src/Admin/V2/Cluster_ClusterConfig.php +++ /dev/null @@ -1,16 +0,0 @@ -.google.bigtable.admin.v2.GcRule gc_rule = 1; */ - private $gc_rule = null; + protected $gc_rule = null; /** * The type of data stored in each of this family's cell values, including its * full encoding. If omitted, the family only serves raw untyped bytes. @@ -35,7 +35,7 @@ class ColumnFamily extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Type value_type = 3; */ - private $value_type = null; + protected $value_type = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/CopyBackupMetadata.php b/Bigtable/src/Admin/V2/CopyBackupMetadata.php index 98165e430e0..0efc355bd7d 100644 --- a/Bigtable/src/Admin/V2/CopyBackupMetadata.php +++ b/Bigtable/src/Admin/V2/CopyBackupMetadata.php @@ -23,13 +23,13 @@ class CopyBackupMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Information about the source backup that is being copied from. * * Generated from protobuf field .google.bigtable.admin.v2.BackupInfo source_backup_info = 2; */ - private $source_backup_info = null; + protected $source_backup_info = null; /** * The progress of the * [CopyBackup][google.bigtable.admin.v2.BigtableTableAdmin.CopyBackup] @@ -37,7 +37,7 @@ class CopyBackupMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.OperationProgress progress = 3; */ - private $progress = null; + protected $progress = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/CopyBackupRequest.php b/Bigtable/src/Admin/V2/CopyBackupRequest.php index 877e9e5c602..2212688f3c0 100644 --- a/Bigtable/src/Admin/V2/CopyBackupRequest.php +++ b/Bigtable/src/Admin/V2/CopyBackupRequest.php @@ -23,7 +23,7 @@ class CopyBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The id of the new backup. The `backup_id` along with `parent` * are combined as {parent}/backups/{backup_id} to create the full backup @@ -34,7 +34,7 @@ class CopyBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $backup_id = ''; + protected $backup_id = ''; /** * Required. The source backup to be copied from. * The source backup needs to be in READY state for it to be copied. @@ -46,7 +46,7 @@ class CopyBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $source_backup = ''; + protected $source_backup = ''; /** * Required. Required. The expiration time of the copied backup with * microsecond granularity that must be at least 6 hours and at most 30 days @@ -56,7 +56,7 @@ class CopyBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = REQUIRED]; */ - private $expire_time = null; + protected $expire_time = null; /** * @param string $parent Required. The name of the destination cluster that will contain the backup diff --git a/Bigtable/src/Admin/V2/CreateAppProfileRequest.php b/Bigtable/src/Admin/V2/CreateAppProfileRequest.php index 3495b4a6bce..12b67e4093a 100644 --- a/Bigtable/src/Admin/V2/CreateAppProfileRequest.php +++ b/Bigtable/src/Admin/V2/CreateAppProfileRequest.php @@ -21,7 +21,7 @@ class CreateAppProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID to be used when referring to the new app profile within * its instance, e.g., just `myprofile` rather than @@ -29,20 +29,20 @@ class CreateAppProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string app_profile_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $app_profile_id = ''; + protected $app_profile_id = ''; /** * Required. The app profile to be created. * Fields marked `OutputOnly` will be ignored. * * Generated from protobuf field .google.bigtable.admin.v2.AppProfile app_profile = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $app_profile = null; + protected $app_profile = null; /** * If true, ignore safety checks when creating the app profile. * * Generated from protobuf field bool ignore_warnings = 4; */ - private $ignore_warnings = false; + protected $ignore_warnings = false; /** * @param string $parent Required. The unique name of the instance in which to create the new app diff --git a/Bigtable/src/Admin/V2/CreateAuthorizedViewMetadata.php b/Bigtable/src/Admin/V2/CreateAuthorizedViewMetadata.php index d2a0d15a408..e2172d832ac 100644 --- a/Bigtable/src/Admin/V2/CreateAuthorizedViewMetadata.php +++ b/Bigtable/src/Admin/V2/CreateAuthorizedViewMetadata.php @@ -20,19 +20,19 @@ class CreateAuthorizedViewMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.CreateAuthorizedViewRequest original_request = 1; */ - private $original_request = null; + protected $original_request = null; /** * The time at which the original request was received. * * Generated from protobuf field .google.protobuf.Timestamp request_time = 2; */ - private $request_time = null; + protected $request_time = null; /** * The time at which the operation failed or was completed successfully. * * Generated from protobuf field .google.protobuf.Timestamp finish_time = 3; */ - private $finish_time = null; + protected $finish_time = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/CreateAuthorizedViewRequest.php b/Bigtable/src/Admin/V2/CreateAuthorizedViewRequest.php index e3971ef2ea3..0329adcb6e0 100644 --- a/Bigtable/src/Admin/V2/CreateAuthorizedViewRequest.php +++ b/Bigtable/src/Admin/V2/CreateAuthorizedViewRequest.php @@ -23,7 +23,7 @@ class CreateAuthorizedViewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The id of the AuthorizedView to create. This AuthorizedView must * not already exist. The `authorized_view_id` appended to `parent` forms the @@ -32,13 +32,13 @@ class CreateAuthorizedViewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string authorized_view_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $authorized_view_id = ''; + protected $authorized_view_id = ''; /** * Required. The AuthorizedView to create. * * Generated from protobuf field .google.bigtable.admin.v2.AuthorizedView authorized_view = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $authorized_view = null; + protected $authorized_view = null; /** * @param string $parent Required. This is the name of the table the AuthorizedView belongs to. diff --git a/Bigtable/src/Admin/V2/CreateBackupMetadata.php b/Bigtable/src/Admin/V2/CreateBackupMetadata.php index dddaf94be6d..557de786e6d 100644 --- a/Bigtable/src/Admin/V2/CreateBackupMetadata.php +++ b/Bigtable/src/Admin/V2/CreateBackupMetadata.php @@ -21,25 +21,25 @@ class CreateBackupMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The name of the table the backup is created from. * * Generated from protobuf field string source_table = 2; */ - private $source_table = ''; + protected $source_table = ''; /** * The time at which this operation started. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 3; */ - private $start_time = null; + protected $start_time = null; /** * If set, the time at which this operation finished or was cancelled. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 4; */ - private $end_time = null; + protected $end_time = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/CreateBackupRequest.php b/Bigtable/src/Admin/V2/CreateBackupRequest.php index f0510f3ded1..8022a0ae61e 100644 --- a/Bigtable/src/Admin/V2/CreateBackupRequest.php +++ b/Bigtable/src/Admin/V2/CreateBackupRequest.php @@ -23,7 +23,7 @@ class CreateBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The id of the backup to be created. The `backup_id` along with * the parent `parent` are combined as {parent}/backups/{backup_id} to create @@ -34,13 +34,13 @@ class CreateBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string backup_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $backup_id = ''; + protected $backup_id = ''; /** * Required. The backup to create. * * Generated from protobuf field .google.bigtable.admin.v2.Backup backup = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $backup = null; + protected $backup = null; /** * @param string $parent Required. This must be one of the clusters in the instance in which this diff --git a/Bigtable/src/Admin/V2/CreateClusterMetadata.php b/Bigtable/src/Admin/V2/CreateClusterMetadata.php index a846611ca3c..c752a40618c 100644 --- a/Bigtable/src/Admin/V2/CreateClusterMetadata.php +++ b/Bigtable/src/Admin/V2/CreateClusterMetadata.php @@ -20,19 +20,19 @@ class CreateClusterMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.CreateClusterRequest original_request = 1; */ - private $original_request = null; + protected $original_request = null; /** * The time at which the original request was received. * * Generated from protobuf field .google.protobuf.Timestamp request_time = 2; */ - private $request_time = null; + protected $request_time = null; /** * The time at which the operation failed or was completed successfully. * * Generated from protobuf field .google.protobuf.Timestamp finish_time = 3; */ - private $finish_time = null; + protected $finish_time = null; /** * Keys: the full `name` of each table that existed in the instance when * CreateCluster was first called, i.e. diff --git a/Bigtable/src/Admin/V2/CreateClusterMetadata/TableProgress.php b/Bigtable/src/Admin/V2/CreateClusterMetadata/TableProgress.php index da30502037b..6fbf11f7cc3 100644 --- a/Bigtable/src/Admin/V2/CreateClusterMetadata/TableProgress.php +++ b/Bigtable/src/Admin/V2/CreateClusterMetadata/TableProgress.php @@ -20,7 +20,7 @@ class TableProgress extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 estimated_size_bytes = 2; */ - private $estimated_size_bytes = 0; + protected $estimated_size_bytes = 0; /** * Estimate of the number of bytes copied so far for this table. * This will eventually reach 'estimated_size_bytes' unless the table copy @@ -28,11 +28,11 @@ class TableProgress extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 estimated_copied_bytes = 3; */ - private $estimated_copied_bytes = 0; + protected $estimated_copied_bytes = 0; /** * Generated from protobuf field .google.bigtable.admin.v2.CreateClusterMetadata.TableProgress.State state = 4; */ - private $state = 0; + protected $state = 0; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/CreateClusterRequest.php b/Bigtable/src/Admin/V2/CreateClusterRequest.php index 7f851c492e4..8a849b57932 100644 --- a/Bigtable/src/Admin/V2/CreateClusterRequest.php +++ b/Bigtable/src/Admin/V2/CreateClusterRequest.php @@ -21,7 +21,7 @@ class CreateClusterRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID to be used when referring to the new cluster within its * instance, e.g., just `mycluster` rather than @@ -29,14 +29,14 @@ class CreateClusterRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cluster_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $cluster_id = ''; + protected $cluster_id = ''; /** * Required. The cluster to be created. * Fields marked `OutputOnly` must be left blank. * * Generated from protobuf field .google.bigtable.admin.v2.Cluster cluster = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $cluster = null; + protected $cluster = null; /** * @param string $parent Required. The unique name of the instance in which to create the new diff --git a/Bigtable/src/Admin/V2/CreateInstanceMetadata.php b/Bigtable/src/Admin/V2/CreateInstanceMetadata.php index 515bf09d252..dd7f505c077 100644 --- a/Bigtable/src/Admin/V2/CreateInstanceMetadata.php +++ b/Bigtable/src/Admin/V2/CreateInstanceMetadata.php @@ -20,19 +20,19 @@ class CreateInstanceMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.CreateInstanceRequest original_request = 1; */ - private $original_request = null; + protected $original_request = null; /** * The time at which the original request was received. * * Generated from protobuf field .google.protobuf.Timestamp request_time = 2; */ - private $request_time = null; + protected $request_time = null; /** * The time at which the operation failed or was completed successfully. * * Generated from protobuf field .google.protobuf.Timestamp finish_time = 3; */ - private $finish_time = null; + protected $finish_time = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/CreateInstanceRequest.php b/Bigtable/src/Admin/V2/CreateInstanceRequest.php index 5649c4eed16..7af92a99c77 100644 --- a/Bigtable/src/Admin/V2/CreateInstanceRequest.php +++ b/Bigtable/src/Admin/V2/CreateInstanceRequest.php @@ -21,7 +21,7 @@ class CreateInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The ID to be used when referring to the new instance within its * project, e.g., just `myinstance` rather than @@ -29,14 +29,14 @@ class CreateInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string instance_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $instance_id = ''; + protected $instance_id = ''; /** * Required. The instance to create. * Fields marked `OutputOnly` must be left blank. * * Generated from protobuf field .google.bigtable.admin.v2.Instance instance = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $instance = null; + protected $instance = null; /** * Required. The clusters to be created within the instance, mapped by desired * cluster ID, e.g., just `mycluster` rather than diff --git a/Bigtable/src/Admin/V2/CreateTableFromSnapshotMetadata.php b/Bigtable/src/Admin/V2/CreateTableFromSnapshotMetadata.php index f5b508a121d..ad6178e78b9 100644 --- a/Bigtable/src/Admin/V2/CreateTableFromSnapshotMetadata.php +++ b/Bigtable/src/Admin/V2/CreateTableFromSnapshotMetadata.php @@ -25,19 +25,19 @@ class CreateTableFromSnapshotMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.CreateTableFromSnapshotRequest original_request = 1; */ - private $original_request = null; + protected $original_request = null; /** * The time at which the original request was received. * * Generated from protobuf field .google.protobuf.Timestamp request_time = 2; */ - private $request_time = null; + protected $request_time = null; /** * The time at which the operation failed or was completed successfully. * * Generated from protobuf field .google.protobuf.Timestamp finish_time = 3; */ - private $finish_time = null; + protected $finish_time = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/CreateTableFromSnapshotRequest.php b/Bigtable/src/Admin/V2/CreateTableFromSnapshotRequest.php index 1254d92e893..2dfa7bc9490 100644 --- a/Bigtable/src/Admin/V2/CreateTableFromSnapshotRequest.php +++ b/Bigtable/src/Admin/V2/CreateTableFromSnapshotRequest.php @@ -26,14 +26,14 @@ class CreateTableFromSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The name by which the new table should be referred to within the * parent instance, e.g., `foobar` rather than `{parent}/tables/foobar`. * * Generated from protobuf field string table_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $table_id = ''; + protected $table_id = ''; /** * Required. The unique name of the snapshot from which to restore the table. * The snapshot and the table must be in the same instance. Values are of the @@ -42,7 +42,7 @@ class CreateTableFromSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string source_snapshot = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $source_snapshot = ''; + protected $source_snapshot = ''; /** * @param string $parent Required. The unique name of the instance in which to create the table. diff --git a/Bigtable/src/Admin/V2/CreateTableRequest.php b/Bigtable/src/Admin/V2/CreateTableRequest.php index 697f98579ee..06608297cf4 100644 --- a/Bigtable/src/Admin/V2/CreateTableRequest.php +++ b/Bigtable/src/Admin/V2/CreateTableRequest.php @@ -22,7 +22,7 @@ class CreateTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The name by which the new table should be referred to within the * parent instance, e.g., `foobar` rather than `{parent}/tables/foobar`. @@ -30,13 +30,13 @@ class CreateTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $table_id = ''; + protected $table_id = ''; /** * Required. The Table to create. * * Generated from protobuf field .google.bigtable.admin.v2.Table table = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $table = null; + protected $table = null; /** * The optional list of row keys that will be used to initially split the * table into several tablets (tablets are similar to HBase regions). diff --git a/Bigtable/src/Admin/V2/CreateTableRequest/Split.php b/Bigtable/src/Admin/V2/CreateTableRequest/Split.php index 42f28883717..af1990b8531 100644 --- a/Bigtable/src/Admin/V2/CreateTableRequest/Split.php +++ b/Bigtable/src/Admin/V2/CreateTableRequest/Split.php @@ -20,7 +20,7 @@ class Split extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes key = 1; */ - private $key = ''; + protected $key = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/DeleteAppProfileRequest.php b/Bigtable/src/Admin/V2/DeleteAppProfileRequest.php index 4122b01fc89..d5e04caa49f 100644 --- a/Bigtable/src/Admin/V2/DeleteAppProfileRequest.php +++ b/Bigtable/src/Admin/V2/DeleteAppProfileRequest.php @@ -22,13 +22,13 @@ class DeleteAppProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. If true, ignore safety checks when deleting the app profile. * * Generated from protobuf field bool ignore_warnings = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $ignore_warnings = false; + protected $ignore_warnings = false; /** * @param string $name Required. The unique name of the app profile to be deleted. Values are of diff --git a/Bigtable/src/Admin/V2/DeleteAuthorizedViewRequest.php b/Bigtable/src/Admin/V2/DeleteAuthorizedViewRequest.php index 38e240c2b03..e623fe8ebb9 100644 --- a/Bigtable/src/Admin/V2/DeleteAuthorizedViewRequest.php +++ b/Bigtable/src/Admin/V2/DeleteAuthorizedViewRequest.php @@ -23,7 +23,7 @@ class DeleteAuthorizedViewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. The current etag of the AuthorizedView. * If an etag is provided and does not match the current etag of the @@ -32,7 +32,7 @@ class DeleteAuthorizedViewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string etag = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $etag = ''; + protected $etag = ''; /** * @param string $name Required. The unique name of the AuthorizedView to be deleted. diff --git a/Bigtable/src/Admin/V2/DeleteBackupRequest.php b/Bigtable/src/Admin/V2/DeleteBackupRequest.php index 2e6ba3f8f59..6bd500313c9 100644 --- a/Bigtable/src/Admin/V2/DeleteBackupRequest.php +++ b/Bigtable/src/Admin/V2/DeleteBackupRequest.php @@ -23,7 +23,7 @@ class DeleteBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the backup to delete. diff --git a/Bigtable/src/Admin/V2/DeleteClusterRequest.php b/Bigtable/src/Admin/V2/DeleteClusterRequest.php index 7f83bd0b9c6..690cdb21a15 100644 --- a/Bigtable/src/Admin/V2/DeleteClusterRequest.php +++ b/Bigtable/src/Admin/V2/DeleteClusterRequest.php @@ -21,7 +21,7 @@ class DeleteClusterRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The unique name of the cluster to be deleted. Values are of the diff --git a/Bigtable/src/Admin/V2/DeleteInstanceRequest.php b/Bigtable/src/Admin/V2/DeleteInstanceRequest.php index 3dda4c4c00f..bcbc1c1a1e5 100644 --- a/Bigtable/src/Admin/V2/DeleteInstanceRequest.php +++ b/Bigtable/src/Admin/V2/DeleteInstanceRequest.php @@ -21,7 +21,7 @@ class DeleteInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The unique name of the instance to be deleted. diff --git a/Bigtable/src/Admin/V2/DeleteSnapshotRequest.php b/Bigtable/src/Admin/V2/DeleteSnapshotRequest.php index 90c5e10db83..b83ec8b2043 100644 --- a/Bigtable/src/Admin/V2/DeleteSnapshotRequest.php +++ b/Bigtable/src/Admin/V2/DeleteSnapshotRequest.php @@ -27,7 +27,7 @@ class DeleteSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The unique name of the snapshot to be deleted. diff --git a/Bigtable/src/Admin/V2/DeleteTableRequest.php b/Bigtable/src/Admin/V2/DeleteTableRequest.php index aec8bd70a69..3bd4eac51dc 100644 --- a/Bigtable/src/Admin/V2/DeleteTableRequest.php +++ b/Bigtable/src/Admin/V2/DeleteTableRequest.php @@ -23,7 +23,7 @@ class DeleteTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The unique name of the table to be deleted. diff --git a/Bigtable/src/Admin/V2/DropRowRangeRequest.php b/Bigtable/src/Admin/V2/DropRowRangeRequest.php index 9ed18eed7ca..a005c44024c 100644 --- a/Bigtable/src/Admin/V2/DropRowRangeRequest.php +++ b/Bigtable/src/Admin/V2/DropRowRangeRequest.php @@ -23,7 +23,7 @@ class DropRowRangeRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; protected $target; /** diff --git a/Bigtable/src/Admin/V2/EncryptionInfo.php b/Bigtable/src/Admin/V2/EncryptionInfo.php index 86527572f71..d13861cd38e 100644 --- a/Bigtable/src/Admin/V2/EncryptionInfo.php +++ b/Bigtable/src/Admin/V2/EncryptionInfo.php @@ -23,7 +23,7 @@ class EncryptionInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.EncryptionInfo.EncryptionType encryption_type = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $encryption_type = 0; + protected $encryption_type = 0; /** * Output only. The status of encrypt/decrypt calls on underlying data for * this resource. Regardless of status, the existing data is always encrypted @@ -31,14 +31,14 @@ class EncryptionInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.rpc.Status encryption_status = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $encryption_status = null; + protected $encryption_status = null; /** * Output only. The version of the Cloud KMS key specified in the parent * cluster that is in use for the data underlying this table. * * Generated from protobuf field string kms_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { */ - private $kms_key_version = ''; + protected $kms_key_version = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/GenerateConsistencyTokenRequest.php b/Bigtable/src/Admin/V2/GenerateConsistencyTokenRequest.php index 2842ebe14e2..de27631825e 100644 --- a/Bigtable/src/Admin/V2/GenerateConsistencyTokenRequest.php +++ b/Bigtable/src/Admin/V2/GenerateConsistencyTokenRequest.php @@ -23,7 +23,7 @@ class GenerateConsistencyTokenRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The unique name of the Table for which to create a consistency diff --git a/Bigtable/src/Admin/V2/GenerateConsistencyTokenResponse.php b/Bigtable/src/Admin/V2/GenerateConsistencyTokenResponse.php index 54c768b2ce6..6b02098b9ff 100644 --- a/Bigtable/src/Admin/V2/GenerateConsistencyTokenResponse.php +++ b/Bigtable/src/Admin/V2/GenerateConsistencyTokenResponse.php @@ -21,7 +21,7 @@ class GenerateConsistencyTokenResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string consistency_token = 1; */ - private $consistency_token = ''; + protected $consistency_token = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/GetAppProfileRequest.php b/Bigtable/src/Admin/V2/GetAppProfileRequest.php index de9af9eb1ac..017793bbb5f 100644 --- a/Bigtable/src/Admin/V2/GetAppProfileRequest.php +++ b/Bigtable/src/Admin/V2/GetAppProfileRequest.php @@ -21,7 +21,7 @@ class GetAppProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The unique name of the requested app profile. Values are of the diff --git a/Bigtable/src/Admin/V2/GetAuthorizedViewRequest.php b/Bigtable/src/Admin/V2/GetAuthorizedViewRequest.php index 7e0db42b32b..385c1c34c26 100644 --- a/Bigtable/src/Admin/V2/GetAuthorizedViewRequest.php +++ b/Bigtable/src/Admin/V2/GetAuthorizedViewRequest.php @@ -23,14 +23,14 @@ class GetAuthorizedViewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Optional. The resource_view to be applied to the returned AuthorizedView's * fields. Default to BASIC. * * Generated from protobuf field .google.bigtable.admin.v2.AuthorizedView.ResponseView view = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $view = 0; + protected $view = 0; /** * @param string $name Required. The unique name of the requested AuthorizedView. diff --git a/Bigtable/src/Admin/V2/GetBackupRequest.php b/Bigtable/src/Admin/V2/GetBackupRequest.php index 99fdcb4b370..5f73e6f2900 100644 --- a/Bigtable/src/Admin/V2/GetBackupRequest.php +++ b/Bigtable/src/Admin/V2/GetBackupRequest.php @@ -23,7 +23,7 @@ class GetBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. Name of the backup. diff --git a/Bigtable/src/Admin/V2/GetClusterRequest.php b/Bigtable/src/Admin/V2/GetClusterRequest.php index fffa489e799..037844cc19a 100644 --- a/Bigtable/src/Admin/V2/GetClusterRequest.php +++ b/Bigtable/src/Admin/V2/GetClusterRequest.php @@ -21,7 +21,7 @@ class GetClusterRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The unique name of the requested cluster. Values are of the form diff --git a/Bigtable/src/Admin/V2/GetInstanceRequest.php b/Bigtable/src/Admin/V2/GetInstanceRequest.php index 850496e920c..28ca52c590c 100644 --- a/Bigtable/src/Admin/V2/GetInstanceRequest.php +++ b/Bigtable/src/Admin/V2/GetInstanceRequest.php @@ -21,7 +21,7 @@ class GetInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The unique name of the requested instance. Values are of the form diff --git a/Bigtable/src/Admin/V2/GetSnapshotRequest.php b/Bigtable/src/Admin/V2/GetSnapshotRequest.php index ab9de859048..5b3547a68e7 100644 --- a/Bigtable/src/Admin/V2/GetSnapshotRequest.php +++ b/Bigtable/src/Admin/V2/GetSnapshotRequest.php @@ -27,7 +27,7 @@ class GetSnapshotRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The unique name of the requested snapshot. diff --git a/Bigtable/src/Admin/V2/GetTableRequest.php b/Bigtable/src/Admin/V2/GetTableRequest.php index 296403090a6..34142b7797a 100644 --- a/Bigtable/src/Admin/V2/GetTableRequest.php +++ b/Bigtable/src/Admin/V2/GetTableRequest.php @@ -23,14 +23,14 @@ class GetTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * The view to be applied to the returned table's fields. * Defaults to `SCHEMA_VIEW` if unspecified. * * Generated from protobuf field .google.bigtable.admin.v2.Table.View view = 2; */ - private $view = 0; + protected $view = 0; /** * @param string $name Required. The unique name of the requested table. diff --git a/Bigtable/src/Admin/V2/HotTablet.php b/Bigtable/src/Admin/V2/HotTablet.php index fed0f7cc296..4d75a90e66e 100644 --- a/Bigtable/src/Admin/V2/HotTablet.php +++ b/Bigtable/src/Admin/V2/HotTablet.php @@ -25,38 +25,38 @@ class HotTablet extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Name of the table that contains the tablet. Values are of the form * `projects/{project}/instances/{instance}/tables/[_a-zA-Z0-9][-_.a-zA-Z0-9]*`. * * Generated from protobuf field string table_name = 2 [(.google.api.resource_reference) = { */ - private $table_name = ''; + protected $table_name = ''; /** * Output only. The start time of the hot tablet. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $start_time = null; + protected $start_time = null; /** * Output only. The end time of the hot tablet. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $end_time = null; + protected $end_time = null; /** * Tablet Start Key (inclusive). * * Generated from protobuf field string start_key = 5; */ - private $start_key = ''; + protected $start_key = ''; /** * Tablet End Key (inclusive). * * Generated from protobuf field string end_key = 6; */ - private $end_key = ''; + protected $end_key = ''; /** * Output only. The average CPU usage spent by a node on this tablet over the * start_time to end_time time range. The percentage is the amount of CPU used @@ -65,7 +65,7 @@ class HotTablet extends \Google\Protobuf\Internal\Message * * Generated from protobuf field float node_cpu_usage_percent = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $node_cpu_usage_percent = 0.0; + protected $node_cpu_usage_percent = 0.0; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/Instance.php b/Bigtable/src/Admin/V2/Instance.php index ba69bf7c6cf..69fc8d87d69 100644 --- a/Bigtable/src/Admin/V2/Instance.php +++ b/Bigtable/src/Admin/V2/Instance.php @@ -24,7 +24,7 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Required. The descriptive name for this instance as it appears in UIs. * Can be changed at any time, but should be kept globally unique @@ -32,20 +32,20 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string display_name = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $display_name = ''; + protected $display_name = ''; /** * (`OutputOnly`) * The current state of the instance. * * Generated from protobuf field .google.bigtable.admin.v2.Instance.State state = 3; */ - private $state = 0; + protected $state = 0; /** * The type of the instance. Defaults to `PRODUCTION`. * * Generated from protobuf field .google.bigtable.admin.v2.Instance.Type type = 4; */ - private $type = 0; + protected $type = 0; /** * Labels are a flexible and lightweight mechanism for organizing cloud * resources into groups that reflect a customer's organizational needs and @@ -68,13 +68,13 @@ class Instance extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp create_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * Output only. Reserved for future use. * * Generated from protobuf field optional bool satisfies_pzs = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $satisfies_pzs = null; + protected $satisfies_pzs = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/ListAppProfilesRequest.php b/Bigtable/src/Admin/V2/ListAppProfilesRequest.php index 24de37843fb..42d6c478cd5 100644 --- a/Bigtable/src/Admin/V2/ListAppProfilesRequest.php +++ b/Bigtable/src/Admin/V2/ListAppProfilesRequest.php @@ -24,7 +24,7 @@ class ListAppProfilesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Maximum number of results per page. * A page_size of zero lets the server choose the number of items to return. @@ -36,13 +36,13 @@ class ListAppProfilesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 3; */ - private $page_size = 0; + protected $page_size = 0; /** * The value of `next_page_token` returned by a previous call. * * Generated from protobuf field string page_token = 2; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The unique name of the instance for which a list of app profiles diff --git a/Bigtable/src/Admin/V2/ListAppProfilesResponse.php b/Bigtable/src/Admin/V2/ListAppProfilesResponse.php index e3580387207..c49770b40a0 100644 --- a/Bigtable/src/Admin/V2/ListAppProfilesResponse.php +++ b/Bigtable/src/Admin/V2/ListAppProfilesResponse.php @@ -28,7 +28,7 @@ class ListAppProfilesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Locations from which AppProfile information could not be retrieved, * due to an outage or some other transient condition. diff --git a/Bigtable/src/Admin/V2/ListAuthorizedViewsRequest.php b/Bigtable/src/Admin/V2/ListAuthorizedViewsRequest.php index 02e566a938e..4a02cb12c2c 100644 --- a/Bigtable/src/Admin/V2/ListAuthorizedViewsRequest.php +++ b/Bigtable/src/Admin/V2/ListAuthorizedViewsRequest.php @@ -23,7 +23,7 @@ class ListAuthorizedViewsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Optional. Maximum number of results per page. * A page_size of zero lets the server choose the number of items to return. @@ -35,20 +35,20 @@ class ListAuthorizedViewsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_size = 0; + protected $page_size = 0; /** * Optional. The value of `next_page_token` returned by a previous call. * * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $page_token = ''; + protected $page_token = ''; /** * Optional. The resource_view to be applied to the returned views' fields. * Default to NAME_ONLY. * * Generated from protobuf field .google.bigtable.admin.v2.AuthorizedView.ResponseView view = 4 [(.google.api.field_behavior) = OPTIONAL]; */ - private $view = 0; + protected $view = 0; /** * @param string $parent Required. The unique name of the table for which AuthorizedViews should be diff --git a/Bigtable/src/Admin/V2/ListAuthorizedViewsResponse.php b/Bigtable/src/Admin/V2/ListAuthorizedViewsResponse.php index e143146f234..83d26b84396 100644 --- a/Bigtable/src/Admin/V2/ListAuthorizedViewsResponse.php +++ b/Bigtable/src/Admin/V2/ListAuthorizedViewsResponse.php @@ -29,7 +29,7 @@ class ListAuthorizedViewsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/ListBackupsRequest.php b/Bigtable/src/Admin/V2/ListBackupsRequest.php index 6db24178e80..6f5666e3bdb 100644 --- a/Bigtable/src/Admin/V2/ListBackupsRequest.php +++ b/Bigtable/src/Admin/V2/ListBackupsRequest.php @@ -24,7 +24,7 @@ class ListBackupsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * A filter expression that filters backups listed in the response. * The expression must specify the field name, a comparison operator, @@ -57,7 +57,7 @@ class ListBackupsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string filter = 2; */ - private $filter = ''; + protected $filter = ''; /** * An expression for specifying the sort order of the results of the request. * The string value should specify one or more fields in @@ -80,14 +80,14 @@ class ListBackupsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string order_by = 3; */ - private $order_by = ''; + protected $order_by = ''; /** * Number of backups to be returned in the response. If 0 or * less, defaults to the server's maximum allowed page size. * * Generated from protobuf field int32 page_size = 4; */ - private $page_size = 0; + protected $page_size = 0; /** * If non-empty, `page_token` should contain a * [next_page_token][google.bigtable.admin.v2.ListBackupsResponse.next_page_token] @@ -97,7 +97,7 @@ class ListBackupsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string page_token = 5; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The cluster to list backups from. Values are of the diff --git a/Bigtable/src/Admin/V2/ListBackupsResponse.php b/Bigtable/src/Admin/V2/ListBackupsResponse.php index 023795edd04..c9792bd915b 100644 --- a/Bigtable/src/Admin/V2/ListBackupsResponse.php +++ b/Bigtable/src/Admin/V2/ListBackupsResponse.php @@ -29,7 +29,7 @@ class ListBackupsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/ListClustersRequest.php b/Bigtable/src/Admin/V2/ListClustersRequest.php index 8376ed2de6b..00a12138e51 100644 --- a/Bigtable/src/Admin/V2/ListClustersRequest.php +++ b/Bigtable/src/Admin/V2/ListClustersRequest.php @@ -24,13 +24,13 @@ class ListClustersRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * DEPRECATED: This field is unused and ignored. * * Generated from protobuf field string page_token = 2; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The unique name of the instance for which a list of clusters is diff --git a/Bigtable/src/Admin/V2/ListClustersResponse.php b/Bigtable/src/Admin/V2/ListClustersResponse.php index 55159e1a95c..84ccf514aa7 100644 --- a/Bigtable/src/Admin/V2/ListClustersResponse.php +++ b/Bigtable/src/Admin/V2/ListClustersResponse.php @@ -36,7 +36,7 @@ class ListClustersResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 3; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/ListHotTabletsRequest.php b/Bigtable/src/Admin/V2/ListHotTabletsRequest.php index 7a6eebbbdfe..2fcefef12c2 100644 --- a/Bigtable/src/Admin/V2/ListHotTabletsRequest.php +++ b/Bigtable/src/Admin/V2/ListHotTabletsRequest.php @@ -22,7 +22,7 @@ class ListHotTabletsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The start time to list hot tablets. The hot tablets in the response will * have start times between the requested start time and end time. Start time @@ -33,13 +33,13 @@ class ListHotTabletsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; */ - private $start_time = null; + protected $start_time = null; /** * The end time to list hot tablets. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 3; */ - private $end_time = null; + protected $end_time = null; /** * Maximum number of results per page. * A page_size that is empty or zero lets the server choose the number of @@ -51,13 +51,13 @@ class ListHotTabletsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 4; */ - private $page_size = 0; + protected $page_size = 0; /** * The value of `next_page_token` returned by a previous call. * * Generated from protobuf field string page_token = 5; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The cluster name to list hot tablets. diff --git a/Bigtable/src/Admin/V2/ListHotTabletsResponse.php b/Bigtable/src/Admin/V2/ListHotTabletsResponse.php index 92391aae5db..39b6a733dad 100644 --- a/Bigtable/src/Admin/V2/ListHotTabletsResponse.php +++ b/Bigtable/src/Admin/V2/ListHotTabletsResponse.php @@ -32,7 +32,7 @@ class ListHotTabletsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/ListInstancesRequest.php b/Bigtable/src/Admin/V2/ListInstancesRequest.php index e87c9af9c13..e0d88b2803f 100644 --- a/Bigtable/src/Admin/V2/ListInstancesRequest.php +++ b/Bigtable/src/Admin/V2/ListInstancesRequest.php @@ -21,13 +21,13 @@ class ListInstancesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * DEPRECATED: This field is unused and ignored. * * Generated from protobuf field string page_token = 2; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The unique name of the project for which a list of instances is diff --git a/Bigtable/src/Admin/V2/ListInstancesResponse.php b/Bigtable/src/Admin/V2/ListInstancesResponse.php index c9d8c6c2d26..6e08425dbe3 100644 --- a/Bigtable/src/Admin/V2/ListInstancesResponse.php +++ b/Bigtable/src/Admin/V2/ListInstancesResponse.php @@ -37,7 +37,7 @@ class ListInstancesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 3; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/ListSnapshotsRequest.php b/Bigtable/src/Admin/V2/ListSnapshotsRequest.php index 49e1998d96e..5ee84a20781 100644 --- a/Bigtable/src/Admin/V2/ListSnapshotsRequest.php +++ b/Bigtable/src/Admin/V2/ListSnapshotsRequest.php @@ -29,20 +29,20 @@ class ListSnapshotsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The maximum number of snapshots to return per page. * CURRENTLY UNIMPLEMENTED AND IGNORED. * * Generated from protobuf field int32 page_size = 2; */ - private $page_size = 0; + protected $page_size = 0; /** * The value of `next_page_token` returned by a previous call. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The unique name of the cluster for which snapshots should be diff --git a/Bigtable/src/Admin/V2/ListSnapshotsResponse.php b/Bigtable/src/Admin/V2/ListSnapshotsResponse.php index 82136fba133..c3d9df13f7e 100644 --- a/Bigtable/src/Admin/V2/ListSnapshotsResponse.php +++ b/Bigtable/src/Admin/V2/ListSnapshotsResponse.php @@ -33,7 +33,7 @@ class ListSnapshotsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/ListTablesRequest.php b/Bigtable/src/Admin/V2/ListTablesRequest.php index 201df542391..d10580296a6 100644 --- a/Bigtable/src/Admin/V2/ListTablesRequest.php +++ b/Bigtable/src/Admin/V2/ListTablesRequest.php @@ -22,14 +22,14 @@ class ListTablesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * The view to be applied to the returned tables' fields. * NAME_ONLY view (default) and REPLICATION_VIEW are supported. * * Generated from protobuf field .google.bigtable.admin.v2.Table.View view = 2; */ - private $view = 0; + protected $view = 0; /** * Maximum number of results per page. * A page_size of zero lets the server choose the number of items to return. @@ -41,13 +41,13 @@ class ListTablesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 page_size = 4; */ - private $page_size = 0; + protected $page_size = 0; /** * The value of `next_page_token` returned by a previous call. * * Generated from protobuf field string page_token = 3; */ - private $page_token = ''; + protected $page_token = ''; /** * @param string $parent Required. The unique name of the instance for which tables should be diff --git a/Bigtable/src/Admin/V2/ListTablesResponse.php b/Bigtable/src/Admin/V2/ListTablesResponse.php index efdcb1c3e89..1dac80ef82f 100644 --- a/Bigtable/src/Admin/V2/ListTablesResponse.php +++ b/Bigtable/src/Admin/V2/ListTablesResponse.php @@ -29,7 +29,7 @@ class ListTablesResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string next_page_token = 2; */ - private $next_page_token = ''; + protected $next_page_token = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/ModifyColumnFamiliesRequest.php b/Bigtable/src/Admin/V2/ModifyColumnFamiliesRequest.php index e7d4d8ff7bd..8960e4680f7 100644 --- a/Bigtable/src/Admin/V2/ModifyColumnFamiliesRequest.php +++ b/Bigtable/src/Admin/V2/ModifyColumnFamiliesRequest.php @@ -23,7 +23,7 @@ class ModifyColumnFamiliesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. Modifications to be atomically applied to the specified table's * families. Entries are applied in order, meaning that earlier modifications @@ -38,7 +38,7 @@ class ModifyColumnFamiliesRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool ignore_warnings = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $ignore_warnings = false; + protected $ignore_warnings = false; /** * @param string $name Required. The unique name of the table whose families should be modified. diff --git a/Bigtable/src/Admin/V2/ModifyColumnFamiliesRequest/Modification.php b/Bigtable/src/Admin/V2/ModifyColumnFamiliesRequest/Modification.php index 0886bfccdd8..0675f7d2203 100644 --- a/Bigtable/src/Admin/V2/ModifyColumnFamiliesRequest/Modification.php +++ b/Bigtable/src/Admin/V2/ModifyColumnFamiliesRequest/Modification.php @@ -20,7 +20,7 @@ class Modification extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string id = 1; */ - private $id = ''; + protected $id = ''; /** * Optional. A mask specifying which fields (e.g. `gc_rule`) in the `update` * mod should be updated, ignored for other modification types. If unset or @@ -28,7 +28,7 @@ class Modification extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 6 [(.google.api.field_behavior) = OPTIONAL]; */ - private $update_mask = null; + protected $update_mask = null; protected $mod; /** diff --git a/Bigtable/src/Admin/V2/OperationProgress.php b/Bigtable/src/Admin/V2/OperationProgress.php index 83c1f737e2c..31e8504969e 100644 --- a/Bigtable/src/Admin/V2/OperationProgress.php +++ b/Bigtable/src/Admin/V2/OperationProgress.php @@ -22,20 +22,20 @@ class OperationProgress extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 progress_percent = 1; */ - private $progress_percent = 0; + protected $progress_percent = 0; /** * Time the request was received. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; */ - private $start_time = null; + protected $start_time = null; /** * If set, the time at which this operation failed or was completed * successfully. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 3; */ - private $end_time = null; + protected $end_time = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/OptimizeRestoredTableMetadata.php b/Bigtable/src/Admin/V2/OptimizeRestoredTableMetadata.php index 7c17e6ceff3..6a51fb65bbe 100644 --- a/Bigtable/src/Admin/V2/OptimizeRestoredTableMetadata.php +++ b/Bigtable/src/Admin/V2/OptimizeRestoredTableMetadata.php @@ -23,13 +23,13 @@ class OptimizeRestoredTableMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The progress of the post-restore optimizations. * * Generated from protobuf field .google.bigtable.admin.v2.OperationProgress progress = 2; */ - private $progress = null; + protected $progress = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/PartialUpdateClusterMetadata.php b/Bigtable/src/Admin/V2/PartialUpdateClusterMetadata.php index 613219b35f7..60d2f7c47f6 100644 --- a/Bigtable/src/Admin/V2/PartialUpdateClusterMetadata.php +++ b/Bigtable/src/Admin/V2/PartialUpdateClusterMetadata.php @@ -20,19 +20,19 @@ class PartialUpdateClusterMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp request_time = 1; */ - private $request_time = null; + protected $request_time = null; /** * The time at which the operation failed or was completed successfully. * * Generated from protobuf field .google.protobuf.Timestamp finish_time = 2; */ - private $finish_time = null; + protected $finish_time = null; /** * The original request for PartialUpdateCluster. * * Generated from protobuf field .google.bigtable.admin.v2.PartialUpdateClusterRequest original_request = 3; */ - private $original_request = null; + protected $original_request = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/PartialUpdateClusterRequest.php b/Bigtable/src/Admin/V2/PartialUpdateClusterRequest.php index d9d6c1483e9..c5cb2b443ee 100644 --- a/Bigtable/src/Admin/V2/PartialUpdateClusterRequest.php +++ b/Bigtable/src/Admin/V2/PartialUpdateClusterRequest.php @@ -21,13 +21,13 @@ class PartialUpdateClusterRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Cluster cluster = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $cluster = null; + protected $cluster = null; /** * Required. The subset of Cluster fields which should be replaced. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\Bigtable\Admin\V2\Cluster $cluster Required. The Cluster which contains the partial updates to be applied, diff --git a/Bigtable/src/Admin/V2/PartialUpdateInstanceRequest.php b/Bigtable/src/Admin/V2/PartialUpdateInstanceRequest.php index 8324d4d0dae..91e4ac7d79e 100644 --- a/Bigtable/src/Admin/V2/PartialUpdateInstanceRequest.php +++ b/Bigtable/src/Admin/V2/PartialUpdateInstanceRequest.php @@ -20,14 +20,14 @@ class PartialUpdateInstanceRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Instance instance = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $instance = null; + protected $instance = null; /** * Required. The subset of Instance fields which should be replaced. * Must be explicitly set. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\Bigtable\Admin\V2\Instance $instance Required. The Instance which will (partially) replace the current value. diff --git a/Bigtable/src/Admin/V2/RestoreInfo.php b/Bigtable/src/Admin/V2/RestoreInfo.php index f4727ceb528..d470c27dc7b 100644 --- a/Bigtable/src/Admin/V2/RestoreInfo.php +++ b/Bigtable/src/Admin/V2/RestoreInfo.php @@ -20,7 +20,7 @@ class RestoreInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.RestoreSourceType source_type = 1; */ - private $source_type = 0; + protected $source_type = 0; protected $source_info; /** diff --git a/Bigtable/src/Admin/V2/RestoreTableMetadata.php b/Bigtable/src/Admin/V2/RestoreTableMetadata.php index f5957fb7951..c487dd2c61b 100644 --- a/Bigtable/src/Admin/V2/RestoreTableMetadata.php +++ b/Bigtable/src/Admin/V2/RestoreTableMetadata.php @@ -21,13 +21,13 @@ class RestoreTableMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The type of the restore source. * * Generated from protobuf field .google.bigtable.admin.v2.RestoreSourceType source_type = 2; */ - private $source_type = 0; + protected $source_type = 0; /** * If exists, the name of the long-running operation that will be used to * track the post-restore optimization process to optimize the performance of @@ -41,7 +41,7 @@ class RestoreTableMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string optimize_table_operation_name = 4; */ - private $optimize_table_operation_name = ''; + protected $optimize_table_operation_name = ''; /** * The progress of the * [RestoreTable][google.bigtable.admin.v2.BigtableTableAdmin.RestoreTable] @@ -49,7 +49,7 @@ class RestoreTableMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.OperationProgress progress = 5; */ - private $progress = null; + protected $progress = null; protected $source_info; /** diff --git a/Bigtable/src/Admin/V2/RestoreTableRequest.php b/Bigtable/src/Admin/V2/RestoreTableRequest.php index 00a80fdfaf6..abdc023aa9c 100644 --- a/Bigtable/src/Admin/V2/RestoreTableRequest.php +++ b/Bigtable/src/Admin/V2/RestoreTableRequest.php @@ -22,7 +22,7 @@ class RestoreTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $parent = ''; + protected $parent = ''; /** * Required. The id of the table to create and restore to. This * table must not already exist. The `table_id` appended to @@ -31,7 +31,7 @@ class RestoreTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table_id = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $table_id = ''; + protected $table_id = ''; protected $source; /** diff --git a/Bigtable/src/Admin/V2/Snapshot.php b/Bigtable/src/Admin/V2/Snapshot.php index 07ca6e32aa5..ed150a235f5 100644 --- a/Bigtable/src/Admin/V2/Snapshot.php +++ b/Bigtable/src/Admin/V2/Snapshot.php @@ -27,13 +27,13 @@ class Snapshot extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Output only. The source table at the time the snapshot was taken. * * Generated from protobuf field .google.bigtable.admin.v2.Table source_table = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $source_table = null; + protected $source_table = null; /** * Output only. The size of the data in the source table at the time the * snapshot was taken. In some cases, this value may be computed @@ -42,13 +42,13 @@ class Snapshot extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 data_size_bytes = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $data_size_bytes = 0; + protected $data_size_bytes = 0; /** * Output only. The time when the snapshot is created. * * Generated from protobuf field .google.protobuf.Timestamp create_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $create_time = null; + protected $create_time = null; /** * The time when the snapshot will be deleted. The maximum amount of time a * snapshot can stay active is 365 days. If 'ttl' is not specified, @@ -56,19 +56,19 @@ class Snapshot extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp delete_time = 5; */ - private $delete_time = null; + protected $delete_time = null; /** * Output only. The current state of the snapshot. * * Generated from protobuf field .google.bigtable.admin.v2.Snapshot.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state = 0; + protected $state = 0; /** * Description of the snapshot. * * Generated from protobuf field string description = 7; */ - private $description = ''; + protected $description = ''; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/SnapshotTableMetadata.php b/Bigtable/src/Admin/V2/SnapshotTableMetadata.php index dc35add98b9..62d29e1d1bf 100644 --- a/Bigtable/src/Admin/V2/SnapshotTableMetadata.php +++ b/Bigtable/src/Admin/V2/SnapshotTableMetadata.php @@ -24,19 +24,19 @@ class SnapshotTableMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.SnapshotTableRequest original_request = 1; */ - private $original_request = null; + protected $original_request = null; /** * The time at which the original request was received. * * Generated from protobuf field .google.protobuf.Timestamp request_time = 2; */ - private $request_time = null; + protected $request_time = null; /** * The time at which the operation failed or was completed successfully. * * Generated from protobuf field .google.protobuf.Timestamp finish_time = 3; */ - private $finish_time = null; + protected $finish_time = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/SnapshotTableRequest.php b/Bigtable/src/Admin/V2/SnapshotTableRequest.php index 4d11a8f8390..007e4b8c67a 100644 --- a/Bigtable/src/Admin/V2/SnapshotTableRequest.php +++ b/Bigtable/src/Admin/V2/SnapshotTableRequest.php @@ -27,7 +27,7 @@ class SnapshotTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * Required. The name of the cluster where the snapshot will be created in. * Values are of the form @@ -35,7 +35,7 @@ class SnapshotTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string cluster = 2 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $cluster = ''; + protected $cluster = ''; /** * Required. The ID by which the new snapshot should be referred to within the * parent cluster, e.g., `mysnapshot` of the form: @@ -44,7 +44,7 @@ class SnapshotTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string snapshot_id = 3 [(.google.api.field_behavior) = REQUIRED]; */ - private $snapshot_id = ''; + protected $snapshot_id = ''; /** * The amount of time that the new snapshot can stay active after it is * created. Once 'ttl' expires, the snapshot will get deleted. The maximum @@ -53,13 +53,13 @@ class SnapshotTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration ttl = 4; */ - private $ttl = null; + protected $ttl = null; /** * Description of the snapshot. * * Generated from protobuf field string description = 5; */ - private $description = ''; + protected $description = ''; /** * @param string $name Required. The unique name of the table to have the snapshot taken. diff --git a/Bigtable/src/Admin/V2/Table.php b/Bigtable/src/Admin/V2/Table.php index d1c8ac9abf6..046130e31c1 100644 --- a/Bigtable/src/Admin/V2/Table.php +++ b/Bigtable/src/Admin/V2/Table.php @@ -23,7 +23,7 @@ class Table extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Output only. Map from cluster ID to per-cluster table state. * If it could not be determined whether or not the table has data in a @@ -49,14 +49,14 @@ class Table extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Table.TimestampGranularity granularity = 4 [(.google.api.field_behavior) = IMMUTABLE]; */ - private $granularity = 0; + protected $granularity = 0; /** * Output only. If this table was restored from another data source (e.g. a * backup), this field will be populated with information about the restore. * * Generated from protobuf field .google.bigtable.admin.v2.RestoreInfo restore_info = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $restore_info = null; + protected $restore_info = null; /** * If specified, enable the change stream on this table. * Otherwise, the change stream is disabled and the change stream is not @@ -64,7 +64,7 @@ class Table extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.ChangeStreamConfig change_stream_config = 8; */ - private $change_stream_config = null; + protected $change_stream_config = null; /** * Set to true to make the table protected against data loss. i.e. deleting * the following resources through Admin APIs are prohibited: @@ -75,7 +75,7 @@ class Table extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool deletion_protection = 9; */ - private $deletion_protection = false; + protected $deletion_protection = false; protected $automated_backup_config; /** diff --git a/Bigtable/src/Admin/V2/Table/AutomatedBackupPolicy.php b/Bigtable/src/Admin/V2/Table/AutomatedBackupPolicy.php index 77c2510af29..4befbef5a7d 100644 --- a/Bigtable/src/Admin/V2/Table/AutomatedBackupPolicy.php +++ b/Bigtable/src/Admin/V2/Table/AutomatedBackupPolicy.php @@ -21,14 +21,14 @@ class AutomatedBackupPolicy extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration retention_period = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $retention_period = null; + protected $retention_period = null; /** * Required. How frequently automated backups should occur. The only * supported value at this time is 24 hours. * * Generated from protobuf field .google.protobuf.Duration frequency = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $frequency = null; + protected $frequency = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/Table/ClusterState.php b/Bigtable/src/Admin/V2/Table/ClusterState.php index 73db21ce54c..73802c4ea58 100644 --- a/Bigtable/src/Admin/V2/Table/ClusterState.php +++ b/Bigtable/src/Admin/V2/Table/ClusterState.php @@ -20,7 +20,7 @@ class ClusterState extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Table.ClusterState.ReplicationState replication_state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $replication_state = 0; + protected $replication_state = 0; /** * Output only. The encryption information for the table in this cluster. * If the encryption key protecting this resource is customer managed, then diff --git a/Bigtable/src/Admin/V2/Type.php b/Bigtable/src/Admin/V2/Type.php index 8f116ff2aba..671bfa8fadf 100644 --- a/Bigtable/src/Admin/V2/Type.php +++ b/Bigtable/src/Admin/V2/Type.php @@ -22,18 +22,18 @@ * * Natural sort: Does the encoded value sort consistently with the original * typed value? Note that Bigtable will always sort data based on the raw * encoded value, *not* the decoded type. - * - Example: STRING values sort in the same order as their UTF-8 encodings. + * - Example: BYTES values sort in the same order as their raw encodings. * - Counterexample: Encoding INT64 to a fixed-width STRING does *not* * preserve sort order when dealing with negative numbers. * INT64(1) > INT64(-1), but STRING("-00001") > STRING("00001). - * - The overall encoding chain sorts naturally if *every* link does. + * - The overall encoding chain has this property if *every* link does. * * Self-delimiting: If we concatenate two encoded values, can we always tell * where the first one ends and the second one begins? * - Example: If we encode INT64s to fixed-width STRINGs, the first value * will always contain exactly N digits, possibly preceded by a sign. * - Counterexample: If we concatenate two UTF-8 encoded STRINGs, we have * no way to tell where the first one ends. - * - The overall encoding chain is self-delimiting if *any* link is. + * - The overall encoding chain has this property if *any* link does. * * Compatibility: Which other systems have matching encoding schemes? For * example, does this encoding have a GoogleSQL equivalent? HBase? Java? * @@ -51,6 +51,8 @@ class Type extends \Google\Protobuf\Internal\Message * * @type \Google\Cloud\Bigtable\Admin\V2\Type\Bytes $bytes_type * Bytes + * @type \Google\Cloud\Bigtable\Admin\V2\Type\PBString $string_type + * String * @type \Google\Cloud\Bigtable\Admin\V2\Type\Int64 $int64_type * Int64 * @type \Google\Cloud\Bigtable\Admin\V2\Type\Aggregate $aggregate_type @@ -93,6 +95,37 @@ public function setBytesType($var) return $this; } + /** + * String + * + * Generated from protobuf field .google.bigtable.admin.v2.Type.String string_type = 2; + * @return \Google\Cloud\Bigtable\Admin\V2\Type\PBString|null + */ + public function getStringType() + { + return $this->readOneof(2); + } + + public function hasStringType() + { + return $this->hasOneof(2); + } + + /** + * String + * + * Generated from protobuf field .google.bigtable.admin.v2.Type.String string_type = 2; + * @param \Google\Cloud\Bigtable\Admin\V2\Type\PBString $var + * @return $this + */ + public function setStringType($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\Type\PBString::class); + $this->writeOneof(2, $var); + + return $this; + } + /** * Int64 * diff --git a/Bigtable/src/Admin/V2/Type/Aggregate.php b/Bigtable/src/Admin/V2/Type/Aggregate.php index b8d2747badb..bfa2b8e7434 100644 --- a/Bigtable/src/Admin/V2/Type/Aggregate.php +++ b/Bigtable/src/Admin/V2/Type/Aggregate.php @@ -25,7 +25,7 @@ class Aggregate extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Type input_type = 1; */ - private $input_type = null; + protected $input_type = null; /** * Output only. Type that holds the internal accumulator state for the * `Aggregate`. This is a function of the `input_type` and `aggregator` @@ -33,7 +33,7 @@ class Aggregate extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Type state_type = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; */ - private $state_type = null; + protected $state_type = null; protected $aggregator; /** diff --git a/Bigtable/src/Admin/V2/Type/Bytes.php b/Bigtable/src/Admin/V2/Type/Bytes.php index 02a0e445451..8bd21135aff 100644 --- a/Bigtable/src/Admin/V2/Type/Bytes.php +++ b/Bigtable/src/Admin/V2/Type/Bytes.php @@ -21,7 +21,7 @@ class Bytes extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Type.Bytes.Encoding encoding = 1; */ - private $encoding = null; + protected $encoding = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/Type/Int64.php b/Bigtable/src/Admin/V2/Type/Int64.php index cdc02b87042..90641966f56 100644 --- a/Bigtable/src/Admin/V2/Type/Int64.php +++ b/Bigtable/src/Admin/V2/Type/Int64.php @@ -21,7 +21,7 @@ class Int64 extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Type.Int64.Encoding encoding = 1; */ - private $encoding = null; + protected $encoding = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/Type/Int64/Encoding/BigEndianBytes.php b/Bigtable/src/Admin/V2/Type/Int64/Encoding/BigEndianBytes.php index 4d45c8bd7cd..a758e28bb91 100644 --- a/Bigtable/src/Admin/V2/Type/Int64/Encoding/BigEndianBytes.php +++ b/Bigtable/src/Admin/V2/Type/Int64/Encoding/BigEndianBytes.php @@ -27,7 +27,7 @@ class BigEndianBytes extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Type.Bytes bytes_type = 1; */ - private $bytes_type = null; + protected $bytes_type = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/Type/PBString.php b/Bigtable/src/Admin/V2/Type/PBString.php new file mode 100644 index 00000000000..dec7bacd818 --- /dev/null +++ b/Bigtable/src/Admin/V2/Type/PBString.php @@ -0,0 +1,81 @@ +google.bigtable.admin.v2.Type.String + */ +class PBString extends \Google\Protobuf\Internal\Message +{ + /** + * The encoding to use when converting to/from lower level types. + * + * Generated from protobuf field .google.bigtable.admin.v2.Type.String.Encoding encoding = 1; + */ + protected $encoding = null; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Bigtable\Admin\V2\Type\PBString\Encoding $encoding + * The encoding to use when converting to/from lower level types. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Bigtable\Admin\V2\Types::initOnce(); + parent::__construct($data); + } + + /** + * The encoding to use when converting to/from lower level types. + * + * Generated from protobuf field .google.bigtable.admin.v2.Type.String.Encoding encoding = 1; + * @return \Google\Cloud\Bigtable\Admin\V2\Type\PBString\Encoding|null + */ + public function getEncoding() + { + return $this->encoding; + } + + public function hasEncoding() + { + return isset($this->encoding); + } + + public function clearEncoding() + { + unset($this->encoding); + } + + /** + * The encoding to use when converting to/from lower level types. + * + * Generated from protobuf field .google.bigtable.admin.v2.Type.String.Encoding encoding = 1; + * @param \Google\Cloud\Bigtable\Admin\V2\Type\PBString\Encoding $var + * @return $this + */ + public function setEncoding($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\Type\PBString\Encoding::class); + $this->encoding = $var; + + return $this; + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(PBString::class, \Google\Cloud\Bigtable\Admin\V2\Type_String::class); + diff --git a/Bigtable/src/Admin/V2/Type/PBString/Encoding.php b/Bigtable/src/Admin/V2/Type/PBString/Encoding.php new file mode 100644 index 00000000000..fd1365320bf --- /dev/null +++ b/Bigtable/src/Admin/V2/Type/PBString/Encoding.php @@ -0,0 +1,78 @@ +google.bigtable.admin.v2.Type.String.Encoding + */ +class Encoding extends \Google\Protobuf\Internal\Message +{ + protected $encoding; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type \Google\Cloud\Bigtable\Admin\V2\Type\PBString\Encoding\Utf8Raw $utf8_raw + * Use `Utf8Raw` encoding. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Bigtable\Admin\V2\Types::initOnce(); + parent::__construct($data); + } + + /** + * Use `Utf8Raw` encoding. + * + * Generated from protobuf field .google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw utf8_raw = 1; + * @return \Google\Cloud\Bigtable\Admin\V2\Type\PBString\Encoding\Utf8Raw|null + */ + public function getUtf8Raw() + { + return $this->readOneof(1); + } + + public function hasUtf8Raw() + { + return $this->hasOneof(1); + } + + /** + * Use `Utf8Raw` encoding. + * + * Generated from protobuf field .google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw utf8_raw = 1; + * @param \Google\Cloud\Bigtable\Admin\V2\Type\PBString\Encoding\Utf8Raw $var + * @return $this + */ + public function setUtf8Raw($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\Admin\V2\Type\PBString\Encoding\Utf8Raw::class); + $this->writeOneof(1, $var); + + return $this; + } + + /** + * @return string + */ + public function getEncoding() + { + return $this->whichOneof("encoding"); + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Encoding::class, \Google\Cloud\Bigtable\Admin\V2\Type_String_Encoding::class); + diff --git a/Bigtable/src/Admin/V2/Type/PBString/Encoding/Utf8Raw.php b/Bigtable/src/Admin/V2/Type/PBString/Encoding/Utf8Raw.php new file mode 100644 index 00000000000..a474b3f01b7 --- /dev/null +++ b/Bigtable/src/Admin/V2/Type/PBString/Encoding/Utf8Raw.php @@ -0,0 +1,42 @@ +google.bigtable.admin.v2.Type.String.Encoding.Utf8Raw + */ +class Utf8Raw extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Bigtable\Admin\V2\Types::initOnce(); + parent::__construct($data); + } + +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(Utf8Raw::class, \Google\Cloud\Bigtable\Admin\V2\Type_String_Encoding_Utf8Raw::class); + diff --git a/Bigtable/src/Admin/V2/UndeleteTableMetadata.php b/Bigtable/src/Admin/V2/UndeleteTableMetadata.php index a92d928bc94..b847a234a94 100644 --- a/Bigtable/src/Admin/V2/UndeleteTableMetadata.php +++ b/Bigtable/src/Admin/V2/UndeleteTableMetadata.php @@ -21,19 +21,19 @@ class UndeleteTableMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The time at which this operation started. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; */ - private $start_time = null; + protected $start_time = null; /** * If set, the time at which this operation finished or was cancelled. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 3; */ - private $end_time = null; + protected $end_time = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/UndeleteTableRequest.php b/Bigtable/src/Admin/V2/UndeleteTableRequest.php index 81af8d6ec50..d3ead7ced6a 100644 --- a/Bigtable/src/Admin/V2/UndeleteTableRequest.php +++ b/Bigtable/src/Admin/V2/UndeleteTableRequest.php @@ -23,7 +23,7 @@ class UndeleteTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * @param string $name Required. The unique name of the table to be restored. diff --git a/Bigtable/src/Admin/V2/UpdateAppProfileRequest.php b/Bigtable/src/Admin/V2/UpdateAppProfileRequest.php index 88e6a951b68..5933bed32b5 100644 --- a/Bigtable/src/Admin/V2/UpdateAppProfileRequest.php +++ b/Bigtable/src/Admin/V2/UpdateAppProfileRequest.php @@ -20,20 +20,20 @@ class UpdateAppProfileRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.AppProfile app_profile = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $app_profile = null; + protected $app_profile = null; /** * Required. The subset of app profile fields which should be replaced. * If unset, all fields will be replaced. * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * If true, ignore safety checks when updating the app profile. * * Generated from protobuf field bool ignore_warnings = 3; */ - private $ignore_warnings = false; + protected $ignore_warnings = false; /** * @param \Google\Cloud\Bigtable\Admin\V2\AppProfile $appProfile Required. The app profile which will (partially) replace the current value. diff --git a/Bigtable/src/Admin/V2/UpdateAuthorizedViewMetadata.php b/Bigtable/src/Admin/V2/UpdateAuthorizedViewMetadata.php index 3133122f229..1457fd96929 100644 --- a/Bigtable/src/Admin/V2/UpdateAuthorizedViewMetadata.php +++ b/Bigtable/src/Admin/V2/UpdateAuthorizedViewMetadata.php @@ -22,19 +22,19 @@ class UpdateAuthorizedViewMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.UpdateAuthorizedViewRequest original_request = 1; */ - private $original_request = null; + protected $original_request = null; /** * The time at which the original request was received. * * Generated from protobuf field .google.protobuf.Timestamp request_time = 2; */ - private $request_time = null; + protected $request_time = null; /** * The time at which the operation failed or was completed successfully. * * Generated from protobuf field .google.protobuf.Timestamp finish_time = 3; */ - private $finish_time = null; + protected $finish_time = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/UpdateAuthorizedViewRequest.php b/Bigtable/src/Admin/V2/UpdateAuthorizedViewRequest.php index 9616019d26d..c5ba84b2314 100644 --- a/Bigtable/src/Admin/V2/UpdateAuthorizedViewRequest.php +++ b/Bigtable/src/Admin/V2/UpdateAuthorizedViewRequest.php @@ -24,7 +24,7 @@ class UpdateAuthorizedViewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.AuthorizedView authorized_view = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $authorized_view = null; + protected $authorized_view = null; /** * Optional. The list of fields to update. * A mask specifying which fields in the AuthorizedView resource should be @@ -36,14 +36,14 @@ class UpdateAuthorizedViewRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = OPTIONAL]; */ - private $update_mask = null; + protected $update_mask = null; /** * Optional. If true, ignore the safety checks when updating the * AuthorizedView. * * Generated from protobuf field bool ignore_warnings = 3 [(.google.api.field_behavior) = OPTIONAL]; */ - private $ignore_warnings = false; + protected $ignore_warnings = false; /** * @param \Google\Cloud\Bigtable\Admin\V2\AuthorizedView $authorizedView Required. The AuthorizedView to update. The `name` in `authorized_view` is diff --git a/Bigtable/src/Admin/V2/UpdateBackupRequest.php b/Bigtable/src/Admin/V2/UpdateBackupRequest.php index f4660b9f49d..b450460b852 100644 --- a/Bigtable/src/Admin/V2/UpdateBackupRequest.php +++ b/Bigtable/src/Admin/V2/UpdateBackupRequest.php @@ -24,7 +24,7 @@ class UpdateBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Backup backup = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $backup = null; + protected $backup = null; /** * Required. A mask specifying which fields (e.g. `expire_time`) in the * Backup resource should be updated. This mask is relative to the Backup @@ -34,7 +34,7 @@ class UpdateBackupRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\Bigtable\Admin\V2\Backup $backup Required. The backup to update. `backup.name`, and the fields to be updated diff --git a/Bigtable/src/Admin/V2/UpdateClusterMetadata.php b/Bigtable/src/Admin/V2/UpdateClusterMetadata.php index 4b684eb5295..09fcde08400 100644 --- a/Bigtable/src/Admin/V2/UpdateClusterMetadata.php +++ b/Bigtable/src/Admin/V2/UpdateClusterMetadata.php @@ -20,19 +20,19 @@ class UpdateClusterMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Cluster original_request = 1; */ - private $original_request = null; + protected $original_request = null; /** * The time at which the original request was received. * * Generated from protobuf field .google.protobuf.Timestamp request_time = 2; */ - private $request_time = null; + protected $request_time = null; /** * The time at which the operation failed or was completed successfully. * * Generated from protobuf field .google.protobuf.Timestamp finish_time = 3; */ - private $finish_time = null; + protected $finish_time = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/UpdateInstanceMetadata.php b/Bigtable/src/Admin/V2/UpdateInstanceMetadata.php index 1dd8a95843c..5caa3d20f2a 100644 --- a/Bigtable/src/Admin/V2/UpdateInstanceMetadata.php +++ b/Bigtable/src/Admin/V2/UpdateInstanceMetadata.php @@ -20,19 +20,19 @@ class UpdateInstanceMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.PartialUpdateInstanceRequest original_request = 1; */ - private $original_request = null; + protected $original_request = null; /** * The time at which the original request was received. * * Generated from protobuf field .google.protobuf.Timestamp request_time = 2; */ - private $request_time = null; + protected $request_time = null; /** * The time at which the operation failed or was completed successfully. * * Generated from protobuf field .google.protobuf.Timestamp finish_time = 3; */ - private $finish_time = null; + protected $finish_time = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/UpdateTableMetadata.php b/Bigtable/src/Admin/V2/UpdateTableMetadata.php index 363254ade50..ab407c9bfd1 100644 --- a/Bigtable/src/Admin/V2/UpdateTableMetadata.php +++ b/Bigtable/src/Admin/V2/UpdateTableMetadata.php @@ -21,19 +21,19 @@ class UpdateTableMetadata extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * The time at which this operation started. * * Generated from protobuf field .google.protobuf.Timestamp start_time = 2; */ - private $start_time = null; + protected $start_time = null; /** * If set, the time at which this operation finished or was canceled. * * Generated from protobuf field .google.protobuf.Timestamp end_time = 3; */ - private $end_time = null; + protected $end_time = null; /** * Constructor. diff --git a/Bigtable/src/Admin/V2/UpdateTableRequest.php b/Bigtable/src/Admin/V2/UpdateTableRequest.php index 2cd4ad6f4f1..17d6cb5e06e 100644 --- a/Bigtable/src/Admin/V2/UpdateTableRequest.php +++ b/Bigtable/src/Admin/V2/UpdateTableRequest.php @@ -22,7 +22,7 @@ class UpdateTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.admin.v2.Table table = 1 [(.google.api.field_behavior) = REQUIRED]; */ - private $table = null; + protected $table = null; /** * Required. The list of fields to update. * A mask specifying which fields (e.g. `change_stream_config`) in the `table` @@ -37,7 +37,7 @@ class UpdateTableRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $update_mask = null; + protected $update_mask = null; /** * @param \Google\Cloud\Bigtable\Admin\V2\Table $table Required. The table to update. diff --git a/Bigtable/src/Admin/V2/gapic_metadata.json b/Bigtable/src/Admin/V2/gapic_metadata.json new file mode 100644 index 00000000000..fecd9cc3d7e --- /dev/null +++ b/Bigtable/src/Admin/V2/gapic_metadata.json @@ -0,0 +1,282 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services\/RPCs to the corresponding library clients\/methods", + "language": "php", + "protoPackage": "google.bigtable.admin.v2", + "libraryPackage": "Google\\Cloud\\Bigtable\\Admin\\V2", + "services": { + "BigtableInstanceAdmin": { + "clients": { + "grpc": { + "libraryClient": "BigtableInstanceAdminGapicClient", + "rpcs": { + "CreateAppProfile": { + "methods": [ + "createAppProfile" + ] + }, + "CreateCluster": { + "methods": [ + "createCluster" + ] + }, + "CreateInstance": { + "methods": [ + "createInstance" + ] + }, + "DeleteAppProfile": { + "methods": [ + "deleteAppProfile" + ] + }, + "DeleteCluster": { + "methods": [ + "deleteCluster" + ] + }, + "DeleteInstance": { + "methods": [ + "deleteInstance" + ] + }, + "GetAppProfile": { + "methods": [ + "getAppProfile" + ] + }, + "GetCluster": { + "methods": [ + "getCluster" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "GetInstance": { + "methods": [ + "getInstance" + ] + }, + "ListAppProfiles": { + "methods": [ + "listAppProfiles" + ] + }, + "ListClusters": { + "methods": [ + "listClusters" + ] + }, + "ListHotTablets": { + "methods": [ + "listHotTablets" + ] + }, + "ListInstances": { + "methods": [ + "listInstances" + ] + }, + "PartialUpdateCluster": { + "methods": [ + "partialUpdateCluster" + ] + }, + "PartialUpdateInstance": { + "methods": [ + "partialUpdateInstance" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "UpdateAppProfile": { + "methods": [ + "updateAppProfile" + ] + }, + "UpdateCluster": { + "methods": [ + "updateCluster" + ] + }, + "UpdateInstance": { + "methods": [ + "updateInstance" + ] + } + } + } + } + }, + "BigtableTableAdmin": { + "clients": { + "grpc": { + "libraryClient": "BigtableTableAdminGapicClient", + "rpcs": { + "CheckConsistency": { + "methods": [ + "checkConsistency" + ] + }, + "CopyBackup": { + "methods": [ + "copyBackup" + ] + }, + "CreateAuthorizedView": { + "methods": [ + "createAuthorizedView" + ] + }, + "CreateBackup": { + "methods": [ + "createBackup" + ] + }, + "CreateTable": { + "methods": [ + "createTable" + ] + }, + "CreateTableFromSnapshot": { + "methods": [ + "createTableFromSnapshot" + ] + }, + "DeleteAuthorizedView": { + "methods": [ + "deleteAuthorizedView" + ] + }, + "DeleteBackup": { + "methods": [ + "deleteBackup" + ] + }, + "DeleteSnapshot": { + "methods": [ + "deleteSnapshot" + ] + }, + "DeleteTable": { + "methods": [ + "deleteTable" + ] + }, + "DropRowRange": { + "methods": [ + "dropRowRange" + ] + }, + "GenerateConsistencyToken": { + "methods": [ + "generateConsistencyToken" + ] + }, + "GetAuthorizedView": { + "methods": [ + "getAuthorizedView" + ] + }, + "GetBackup": { + "methods": [ + "getBackup" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "GetSnapshot": { + "methods": [ + "getSnapshot" + ] + }, + "GetTable": { + "methods": [ + "getTable" + ] + }, + "ListAuthorizedViews": { + "methods": [ + "listAuthorizedViews" + ] + }, + "ListBackups": { + "methods": [ + "listBackups" + ] + }, + "ListSnapshots": { + "methods": [ + "listSnapshots" + ] + }, + "ListTables": { + "methods": [ + "listTables" + ] + }, + "ModifyColumnFamilies": { + "methods": [ + "modifyColumnFamilies" + ] + }, + "RestoreTable": { + "methods": [ + "restoreTable" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "SnapshotTable": { + "methods": [ + "snapshotTable" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "UndeleteTable": { + "methods": [ + "undeleteTable" + ] + }, + "UpdateAuthorizedView": { + "methods": [ + "updateAuthorizedView" + ] + }, + "UpdateBackup": { + "methods": [ + "updateBackup" + ] + }, + "UpdateTable": { + "methods": [ + "updateTable" + ] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/Bigtable/src/BigtableClient.php b/Bigtable/src/BigtableClient.php index 2b2c4f653ca..8cf2db87565 100644 --- a/Bigtable/src/BigtableClient.php +++ b/Bigtable/src/BigtableClient.php @@ -58,11 +58,6 @@ class BigtableClient */ private Serializer $serializer; - /** - * @var string - */ - private $projectId; - /** * Create a Bigtable client. * @@ -134,14 +129,14 @@ public function __construct(array $config = []) ]; // Configure GAPIC client options - $config = $this->buildClientOptions($config); - $config['credentials'] = $this->createCredentialsWrapper( - $config['credentials'], - $config['credentialsConfig'], - $config['universeDomain'] + $detectProjectIdConfig = $this->buildClientOptions($config); + $detectProjectIdConfig['credentials'] = $this->createCredentialsWrapper( + $detectProjectIdConfig['credentials'], + $detectProjectIdConfig['credentialsConfig'], + $detectProjectIdConfig['universeDomain'] ); - $this->projectId = $this->detectProjectId($config); + $this->projectId = $this->detectProjectId($detectProjectIdConfig); $this->serializer = new Serializer(); $this->gapicClient = new GapicClient($config); } diff --git a/Bigtable/src/V2/AllReadStats.php b/Bigtable/src/V2/AllReadStats.php deleted file mode 100644 index cc4f14f1b51..00000000000 --- a/Bigtable/src/V2/AllReadStats.php +++ /dev/null @@ -1,137 +0,0 @@ -google.bigtable.v2.AllReadStats - */ -class AllReadStats extends \Google\Protobuf\Internal\Message -{ - /** - * Iteration stats describe how efficient the read is, e.g. comparing - * rows seen vs. rows returned or cells seen vs cells returned can provide an - * indication of read efficiency (the higher the ratio of seen to retuned the - * better). - * - * Generated from protobuf field .google.bigtable.v2.ReadIteratorStats read_iterator_stats = 1; - */ - private $read_iterator_stats = null; - /** - * Request latency stats describe the time taken to complete a request, from - * the server side. - * - * Generated from protobuf field .google.bigtable.v2.RequestLatencyStats request_latency_stats = 2; - */ - private $request_latency_stats = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Bigtable\V2\ReadIteratorStats $read_iterator_stats - * Iteration stats describe how efficient the read is, e.g. comparing - * rows seen vs. rows returned or cells seen vs cells returned can provide an - * indication of read efficiency (the higher the ratio of seen to retuned the - * better). - * @type \Google\Cloud\Bigtable\V2\RequestLatencyStats $request_latency_stats - * Request latency stats describe the time taken to complete a request, from - * the server side. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Bigtable\V2\RequestStats::initOnce(); - parent::__construct($data); - } - - /** - * Iteration stats describe how efficient the read is, e.g. comparing - * rows seen vs. rows returned or cells seen vs cells returned can provide an - * indication of read efficiency (the higher the ratio of seen to retuned the - * better). - * - * Generated from protobuf field .google.bigtable.v2.ReadIteratorStats read_iterator_stats = 1; - * @return \Google\Cloud\Bigtable\V2\ReadIteratorStats|null - */ - public function getReadIteratorStats() - { - return $this->read_iterator_stats; - } - - public function hasReadIteratorStats() - { - return isset($this->read_iterator_stats); - } - - public function clearReadIteratorStats() - { - unset($this->read_iterator_stats); - } - - /** - * Iteration stats describe how efficient the read is, e.g. comparing - * rows seen vs. rows returned or cells seen vs cells returned can provide an - * indication of read efficiency (the higher the ratio of seen to retuned the - * better). - * - * Generated from protobuf field .google.bigtable.v2.ReadIteratorStats read_iterator_stats = 1; - * @param \Google\Cloud\Bigtable\V2\ReadIteratorStats $var - * @return $this - */ - public function setReadIteratorStats($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\ReadIteratorStats::class); - $this->read_iterator_stats = $var; - - return $this; - } - - /** - * Request latency stats describe the time taken to complete a request, from - * the server side. - * - * Generated from protobuf field .google.bigtable.v2.RequestLatencyStats request_latency_stats = 2; - * @return \Google\Cloud\Bigtable\V2\RequestLatencyStats|null - */ - public function getRequestLatencyStats() - { - return $this->request_latency_stats; - } - - public function hasRequestLatencyStats() - { - return isset($this->request_latency_stats); - } - - public function clearRequestLatencyStats() - { - unset($this->request_latency_stats); - } - - /** - * Request latency stats describe the time taken to complete a request, from - * the server side. - * - * Generated from protobuf field .google.bigtable.v2.RequestLatencyStats request_latency_stats = 2; - * @param \Google\Cloud\Bigtable\V2\RequestLatencyStats $var - * @return $this - */ - public function setRequestLatencyStats($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\RequestLatencyStats::class); - $this->request_latency_stats = $var; - - return $this; - } - -} - diff --git a/Bigtable/src/V2/Cell.php b/Bigtable/src/V2/Cell.php index 71a3c01f626..ae97f1e167a 100644 --- a/Bigtable/src/V2/Cell.php +++ b/Bigtable/src/V2/Cell.php @@ -25,7 +25,7 @@ class Cell extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 timestamp_micros = 1; */ - private $timestamp_micros = 0; + protected $timestamp_micros = 0; /** * The value stored in the cell. * May contain any byte string, including the empty string, up to 100MiB in @@ -33,7 +33,7 @@ class Cell extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes value = 2; */ - private $value = ''; + protected $value = ''; /** * Labels applied to the cell by a [RowFilter][google.bigtable.v2.RowFilter]. * diff --git a/Bigtable/src/V2/CheckAndMutateRowRequest.php b/Bigtable/src/V2/CheckAndMutateRowRequest.php index c87631158d0..71dc9e6065d 100644 --- a/Bigtable/src/V2/CheckAndMutateRowRequest.php +++ b/Bigtable/src/V2/CheckAndMutateRowRequest.php @@ -23,7 +23,7 @@ class CheckAndMutateRowRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table_name = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $table_name = ''; + protected $table_name = ''; /** * Optional. The unique name of the AuthorizedView to which the conditional * mutation should be applied. @@ -32,21 +32,21 @@ class CheckAndMutateRowRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string authorized_view_name = 9 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $authorized_view_name = ''; + protected $authorized_view_name = ''; /** * This value specifies routing for replication. If not specified, the * "default" application profile will be used. * * Generated from protobuf field string app_profile_id = 7; */ - private $app_profile_id = ''; + protected $app_profile_id = ''; /** * Required. The key of the row to which the conditional mutation should be * applied. * * Generated from protobuf field bytes row_key = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $row_key = ''; + protected $row_key = ''; /** * The filter to be applied to the contents of the specified row. Depending * on whether or not any results are yielded, either `true_mutations` or @@ -55,7 +55,7 @@ class CheckAndMutateRowRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.RowFilter predicate_filter = 6; */ - private $predicate_filter = null; + protected $predicate_filter = null; /** * Changes to be atomically applied to the specified row if `predicate_filter` * yields at least one cell when applied to `row_key`. Entries are applied in diff --git a/Bigtable/src/V2/CheckAndMutateRowResponse.php b/Bigtable/src/V2/CheckAndMutateRowResponse.php index 2e970bd41dd..ea562f574e7 100644 --- a/Bigtable/src/V2/CheckAndMutateRowResponse.php +++ b/Bigtable/src/V2/CheckAndMutateRowResponse.php @@ -21,7 +21,7 @@ class CheckAndMutateRowResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool predicate_matched = 1; */ - private $predicate_matched = false; + protected $predicate_matched = false; /** * Constructor. diff --git a/Bigtable/src/V2/Client/BigtableClient.php b/Bigtable/src/V2/Client/BigtableClient.php index 01f9efeb284..770c2d544d1 100644 --- a/Bigtable/src/V2/Client/BigtableClient.php +++ b/Bigtable/src/V2/Client/BigtableClient.php @@ -1,6 +1,6 @@ setDefaultEmulatorConfig($options); $clientOptions = $this->buildClientOptions($options); $this->setClientOptions($clientOptions); } @@ -507,4 +510,23 @@ public function sampleRowKeys(SampleRowKeysRequest $request, array $callOptions { return $this->startApiCall('SampleRowKeys', $request, $callOptions); } + + /** Configure the gapic configuration to use a service emulator. */ + private function setDefaultEmulatorConfig(array $options): array + { + $emulatorHost = getenv('BIGTABLE_EMULATOR_HOST'); + if (empty($emulatorHost)) { + return $options; + } + + if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) { + $search = $scheme . '://'; + $emulatorHost = str_replace($search, '', $emulatorHost); + } + + $options['apiEndpoint'] ??= $emulatorHost; + $options['transportConfig']['grpc']['stubOpts']['credentials'] ??= ChannelCredentials::createInsecure(); + $options['credentials'] ??= new InsecureCredentialsWrapper(); + return $options; + } } diff --git a/Bigtable/src/V2/Column.php b/Bigtable/src/V2/Column.php index 99b5e8dee8a..b2f46bdf290 100644 --- a/Bigtable/src/V2/Column.php +++ b/Bigtable/src/V2/Column.php @@ -25,7 +25,7 @@ class Column extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes qualifier = 1; */ - private $qualifier = ''; + protected $qualifier = ''; /** * Must not be empty. Sorted in order of decreasing "timestamp_micros". * diff --git a/Bigtable/src/V2/ColumnRange.php b/Bigtable/src/V2/ColumnRange.php index f094744c2b5..d5ff522b00d 100644 --- a/Bigtable/src/V2/ColumnRange.php +++ b/Bigtable/src/V2/ColumnRange.php @@ -23,7 +23,7 @@ class ColumnRange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string family_name = 1; */ - private $family_name = ''; + protected $family_name = ''; protected $start_qualifier; protected $end_qualifier; diff --git a/Bigtable/src/V2/Family.php b/Bigtable/src/V2/Family.php index 6a428080d24..429023c4587 100644 --- a/Bigtable/src/V2/Family.php +++ b/Bigtable/src/V2/Family.php @@ -26,7 +26,7 @@ class Family extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1; */ - private $name = ''; + protected $name = ''; /** * Must not be empty. Sorted in order of increasing "qualifier". * diff --git a/Bigtable/src/V2/FeatureFlags.php b/Bigtable/src/V2/FeatureFlags.php index f9d2d8bcace..06504aadd20 100644 --- a/Bigtable/src/V2/FeatureFlags.php +++ b/Bigtable/src/V2/FeatureFlags.php @@ -28,7 +28,7 @@ class FeatureFlags extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool reverse_scans = 1; */ - private $reverse_scans = false; + protected $reverse_scans = false; /** * Notify the server that the client enables batch write flow control by * requesting RateLimitInfo from MutateRowsResponse. Due to technical reasons, @@ -36,7 +36,7 @@ class FeatureFlags extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool mutate_rows_rate_limit = 3; */ - private $mutate_rows_rate_limit = false; + protected $mutate_rows_rate_limit = false; /** * Notify the server that the client enables batch write flow control by * requesting RateLimitInfo from MutateRowsResponse. With partial retries @@ -44,34 +44,34 @@ class FeatureFlags extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool mutate_rows_rate_limit2 = 5; */ - private $mutate_rows_rate_limit2 = false; + protected $mutate_rows_rate_limit2 = false; /** * Notify the server that the client supports the last_scanned_row field * in ReadRowsResponse for long-running scans. * * Generated from protobuf field bool last_scanned_row_responses = 4; */ - private $last_scanned_row_responses = false; + protected $last_scanned_row_responses = false; /** * Notify the server that the client supports using encoded routing cookie * strings to retry requests with. * * Generated from protobuf field bool routing_cookie = 6; */ - private $routing_cookie = false; + protected $routing_cookie = false; /** * Notify the server that the client supports using retry info back off * durations to retry requests with. * * Generated from protobuf field bool retry_info = 7; */ - private $retry_info = false; + protected $retry_info = false; /** * Notify the server that the client has client side metrics enabled. * * Generated from protobuf field bool client_side_metrics_enabled = 8; */ - private $client_side_metrics_enabled = false; + protected $client_side_metrics_enabled = false; /** * Constructor. diff --git a/Bigtable/src/V2/FullReadStatsView.php b/Bigtable/src/V2/FullReadStatsView.php index 7e407f5aca7..3376ecb5017 100644 --- a/Bigtable/src/V2/FullReadStatsView.php +++ b/Bigtable/src/V2/FullReadStatsView.php @@ -23,14 +23,14 @@ class FullReadStatsView extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.ReadIterationStats read_iteration_stats = 1; */ - private $read_iteration_stats = null; + protected $read_iteration_stats = null; /** * Request latency stats describe the time taken to complete a request, from * the server side. * * Generated from protobuf field .google.bigtable.v2.RequestLatencyStats request_latency_stats = 2; */ - private $request_latency_stats = null; + protected $request_latency_stats = null; /** * Constructor. diff --git a/Bigtable/src/V2/GenerateInitialChangeStreamPartitionsRequest.php b/Bigtable/src/V2/GenerateInitialChangeStreamPartitionsRequest.php index 8bd603cf583..67233adb93b 100644 --- a/Bigtable/src/V2/GenerateInitialChangeStreamPartitionsRequest.php +++ b/Bigtable/src/V2/GenerateInitialChangeStreamPartitionsRequest.php @@ -24,7 +24,7 @@ class GenerateInitialChangeStreamPartitionsRequest extends \Google\Protobuf\Inte * * Generated from protobuf field string table_name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $table_name = ''; + protected $table_name = ''; /** * This value specifies routing for replication. If not specified, the * "default" application profile will be used. @@ -32,7 +32,7 @@ class GenerateInitialChangeStreamPartitionsRequest extends \Google\Protobuf\Inte * * Generated from protobuf field string app_profile_id = 2; */ - private $app_profile_id = ''; + protected $app_profile_id = ''; /** * @param string $tableName Required. The unique name of the table from which to get change stream diff --git a/Bigtable/src/V2/GenerateInitialChangeStreamPartitionsResponse.php b/Bigtable/src/V2/GenerateInitialChangeStreamPartitionsResponse.php index dc2e835d887..26f241b3bd8 100644 --- a/Bigtable/src/V2/GenerateInitialChangeStreamPartitionsResponse.php +++ b/Bigtable/src/V2/GenerateInitialChangeStreamPartitionsResponse.php @@ -21,7 +21,7 @@ class GenerateInitialChangeStreamPartitionsResponse extends \Google\Protobuf\Int * * Generated from protobuf field .google.bigtable.v2.StreamPartition partition = 1; */ - private $partition = null; + protected $partition = null; /** * Constructor. diff --git a/Bigtable/src/V2/MutateRowRequest.php b/Bigtable/src/V2/MutateRowRequest.php index e03d01a6211..50e64e6e021 100644 --- a/Bigtable/src/V2/MutateRowRequest.php +++ b/Bigtable/src/V2/MutateRowRequest.php @@ -23,7 +23,7 @@ class MutateRowRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table_name = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $table_name = ''; + protected $table_name = ''; /** * Optional. The unique name of the AuthorizedView to which the mutation * should be applied. @@ -32,20 +32,20 @@ class MutateRowRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string authorized_view_name = 6 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $authorized_view_name = ''; + protected $authorized_view_name = ''; /** * This value specifies routing for replication. If not specified, the * "default" application profile will be used. * * Generated from protobuf field string app_profile_id = 4; */ - private $app_profile_id = ''; + protected $app_profile_id = ''; /** * Required. The key of the row to which the mutation should be applied. * * Generated from protobuf field bytes row_key = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $row_key = ''; + protected $row_key = ''; /** * Required. Changes to be atomically applied to the specified row. Entries * are applied in order, meaning that earlier mutations can be masked by later diff --git a/Bigtable/src/V2/MutateRowsRequest.php b/Bigtable/src/V2/MutateRowsRequest.php index 8405df53f72..64ce09021ec 100644 --- a/Bigtable/src/V2/MutateRowsRequest.php +++ b/Bigtable/src/V2/MutateRowsRequest.php @@ -23,7 +23,7 @@ class MutateRowsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table_name = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $table_name = ''; + protected $table_name = ''; /** * Optional. The unique name of the AuthorizedView to which the mutations * should be applied. @@ -32,14 +32,14 @@ class MutateRowsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string authorized_view_name = 5 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $authorized_view_name = ''; + protected $authorized_view_name = ''; /** * This value specifies routing for replication. If not specified, the * "default" application profile will be used. * * Generated from protobuf field string app_profile_id = 3; */ - private $app_profile_id = ''; + protected $app_profile_id = ''; /** * Required. The row keys and corresponding mutations to be applied in bulk. * Each entry is applied as an atomic mutation, but the entries may be diff --git a/Bigtable/src/V2/MutateRowsRequest/Entry.php b/Bigtable/src/V2/MutateRowsRequest/Entry.php index 801cd61cc2d..96659f4574e 100644 --- a/Bigtable/src/V2/MutateRowsRequest/Entry.php +++ b/Bigtable/src/V2/MutateRowsRequest/Entry.php @@ -20,7 +20,7 @@ class Entry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes row_key = 1; */ - private $row_key = ''; + protected $row_key = ''; /** * Required. Changes to be atomically applied to the specified row. * Mutations are applied in order, meaning that earlier mutations can be diff --git a/Bigtable/src/V2/MutateRowsResponse.php b/Bigtable/src/V2/MutateRowsResponse.php index 2f0a9711e1e..9467b61e1b3 100644 --- a/Bigtable/src/V2/MutateRowsResponse.php +++ b/Bigtable/src/V2/MutateRowsResponse.php @@ -28,7 +28,7 @@ class MutateRowsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional .google.bigtable.v2.RateLimitInfo rate_limit_info = 3; */ - private $rate_limit_info = null; + protected $rate_limit_info = null; /** * Constructor. diff --git a/Bigtable/src/V2/MutateRowsResponse/Entry.php b/Bigtable/src/V2/MutateRowsResponse/Entry.php index 3b2d1c08381..a6049b0d079 100644 --- a/Bigtable/src/V2/MutateRowsResponse/Entry.php +++ b/Bigtable/src/V2/MutateRowsResponse/Entry.php @@ -21,7 +21,7 @@ class Entry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 index = 1; */ - private $index = 0; + protected $index = 0; /** * The result of the request Entry identified by `index`. * Depending on how requests are batched during execution, it is possible @@ -30,7 +30,7 @@ class Entry extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.rpc.Status status = 2; */ - private $status = null; + protected $status = null; /** * Constructor. diff --git a/Bigtable/src/V2/Mutation/AddToCell.php b/Bigtable/src/V2/Mutation/AddToCell.php index beb1e661db2..2ef613a1e01 100644 --- a/Bigtable/src/V2/Mutation/AddToCell.php +++ b/Bigtable/src/V2/Mutation/AddToCell.php @@ -22,28 +22,28 @@ class AddToCell extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string family_name = 1; */ - private $family_name = ''; + protected $family_name = ''; /** * The qualifier of the column into which new data should be added. This * must be a `raw_value`. * * Generated from protobuf field .google.bigtable.v2.Value column_qualifier = 2; */ - private $column_qualifier = null; + protected $column_qualifier = null; /** * The timestamp of the cell to which new data should be added. This must * be a `raw_timestamp_micros` that matches the table's `granularity`. * * Generated from protobuf field .google.bigtable.v2.Value timestamp = 3; */ - private $timestamp = null; + protected $timestamp = null; /** * The input value to be accumulated into the specified cell. This must be * compatible with the family's `value_type.input_type`. * * Generated from protobuf field .google.bigtable.v2.Value input = 4; */ - private $input = null; + protected $input = null; /** * Constructor. diff --git a/Bigtable/src/V2/Mutation/DeleteFromColumn.php b/Bigtable/src/V2/Mutation/DeleteFromColumn.php index 47c56247ae1..a91638edfa4 100644 --- a/Bigtable/src/V2/Mutation/DeleteFromColumn.php +++ b/Bigtable/src/V2/Mutation/DeleteFromColumn.php @@ -22,20 +22,20 @@ class DeleteFromColumn extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string family_name = 1; */ - private $family_name = ''; + protected $family_name = ''; /** * The qualifier of the column from which cells should be deleted. * Can be any byte string, including the empty string. * * Generated from protobuf field bytes column_qualifier = 2; */ - private $column_qualifier = ''; + protected $column_qualifier = ''; /** * The range of timestamps within which cells should be deleted. * * Generated from protobuf field .google.bigtable.v2.TimestampRange time_range = 3; */ - private $time_range = null; + protected $time_range = null; /** * Constructor. diff --git a/Bigtable/src/V2/Mutation/DeleteFromFamily.php b/Bigtable/src/V2/Mutation/DeleteFromFamily.php index b1a7ea953ef..66cdb291bf3 100644 --- a/Bigtable/src/V2/Mutation/DeleteFromFamily.php +++ b/Bigtable/src/V2/Mutation/DeleteFromFamily.php @@ -21,7 +21,7 @@ class DeleteFromFamily extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string family_name = 1; */ - private $family_name = ''; + protected $family_name = ''; /** * Constructor. diff --git a/Bigtable/src/V2/Mutation/SetCell.php b/Bigtable/src/V2/Mutation/SetCell.php index bfe91782bbe..b156e5d5d56 100644 --- a/Bigtable/src/V2/Mutation/SetCell.php +++ b/Bigtable/src/V2/Mutation/SetCell.php @@ -21,14 +21,14 @@ class SetCell extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string family_name = 1; */ - private $family_name = ''; + protected $family_name = ''; /** * The qualifier of the column into which new data should be written. * Can be any byte string, including the empty string. * * Generated from protobuf field bytes column_qualifier = 2; */ - private $column_qualifier = ''; + protected $column_qualifier = ''; /** * The timestamp of the cell into which new data should be written. * Use -1 for current Bigtable server time. @@ -38,13 +38,13 @@ class SetCell extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 timestamp_micros = 3; */ - private $timestamp_micros = 0; + protected $timestamp_micros = 0; /** * The value to be written into the specified cell. * * Generated from protobuf field bytes value = 4; */ - private $value = ''; + protected $value = ''; /** * Constructor. diff --git a/Bigtable/src/V2/PingAndWarmRequest.php b/Bigtable/src/V2/PingAndWarmRequest.php index 45cadd2fdaa..4daf892b444 100644 --- a/Bigtable/src/V2/PingAndWarmRequest.php +++ b/Bigtable/src/V2/PingAndWarmRequest.php @@ -22,14 +22,14 @@ class PingAndWarmRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $name = ''; + protected $name = ''; /** * This value specifies routing for replication. If not specified, the * "default" application profile will be used. * * Generated from protobuf field string app_profile_id = 2; */ - private $app_profile_id = ''; + protected $app_profile_id = ''; /** * @param string $name Required. The unique name of the instance to check permissions for as well diff --git a/Bigtable/src/V2/RateLimitInfo.php b/Bigtable/src/V2/RateLimitInfo.php index 72593d9d9b6..db1f756b6be 100644 --- a/Bigtable/src/V2/RateLimitInfo.php +++ b/Bigtable/src/V2/RateLimitInfo.php @@ -25,7 +25,7 @@ class RateLimitInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration period = 1; */ - private $period = null; + protected $period = null; /** * If it has been at least one `period` since the last load adjustment, the * client should multiply the current load by this value to get the new target @@ -38,7 +38,7 @@ class RateLimitInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field double factor = 2; */ - private $factor = 0.0; + protected $factor = 0.0; /** * Constructor. diff --git a/Bigtable/src/V2/ReadChangeStreamRequest.php b/Bigtable/src/V2/ReadChangeStreamRequest.php index b9fd1baa84e..cac57eea134 100644 --- a/Bigtable/src/V2/ReadChangeStreamRequest.php +++ b/Bigtable/src/V2/ReadChangeStreamRequest.php @@ -24,7 +24,7 @@ class ReadChangeStreamRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table_name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { */ - private $table_name = ''; + protected $table_name = ''; /** * This value specifies routing for replication. If not specified, the * "default" application profile will be used. @@ -32,13 +32,13 @@ class ReadChangeStreamRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string app_profile_id = 2; */ - private $app_profile_id = ''; + protected $app_profile_id = ''; /** * The partition to read changes from. * * Generated from protobuf field .google.bigtable.v2.StreamPartition partition = 3; */ - private $partition = null; + protected $partition = null; /** * If specified, OK will be returned when the stream advances beyond * this time. Otherwise, changes will be continuously delivered on the stream. @@ -46,14 +46,14 @@ class ReadChangeStreamRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp end_time = 5; */ - private $end_time = null; + protected $end_time = null; /** * If specified, the duration between `Heartbeat` messages on the stream. * Otherwise, defaults to 5 seconds. * * Generated from protobuf field .google.protobuf.Duration heartbeat_duration = 7; */ - private $heartbeat_duration = null; + protected $heartbeat_duration = null; protected $start_from; /** diff --git a/Bigtable/src/V2/ReadChangeStreamResponse/CloseStream.php b/Bigtable/src/V2/ReadChangeStreamResponse/CloseStream.php index bc432a594e2..4551bb34ed6 100644 --- a/Bigtable/src/V2/ReadChangeStreamResponse/CloseStream.php +++ b/Bigtable/src/V2/ReadChangeStreamResponse/CloseStream.php @@ -39,7 +39,7 @@ class CloseStream extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.rpc.Status status = 1; */ - private $status = null; + protected $status = null; /** * If non-empty, contains the information needed to resume reading their * associated partitions. diff --git a/Bigtable/src/V2/ReadChangeStreamResponse/DataChange.php b/Bigtable/src/V2/ReadChangeStreamResponse/DataChange.php index e1fd22a6fe6..9bb24720fb1 100644 --- a/Bigtable/src/V2/ReadChangeStreamResponse/DataChange.php +++ b/Bigtable/src/V2/ReadChangeStreamResponse/DataChange.php @@ -25,14 +25,14 @@ class DataChange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.ReadChangeStreamResponse.DataChange.Type type = 1; */ - private $type = 0; + protected $type = 0; /** * The cluster where the mutation was applied. * Not set when `type` is `GARBAGE_COLLECTION`. * * Generated from protobuf field string source_cluster_id = 2; */ - private $source_cluster_id = ''; + protected $source_cluster_id = ''; /** * The row key for all mutations that are part of this `DataChange`. * If the `DataChange` is chunked across multiple messages, then this field @@ -40,13 +40,13 @@ class DataChange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes row_key = 3; */ - private $row_key = ''; + protected $row_key = ''; /** * The timestamp at which the mutation was applied on the Bigtable server. * * Generated from protobuf field .google.protobuf.Timestamp commit_timestamp = 4; */ - private $commit_timestamp = null; + protected $commit_timestamp = null; /** * A value that lets stream consumers reconstruct Bigtable's * conflict resolution semantics. @@ -58,7 +58,7 @@ class DataChange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 tiebreaker = 5; */ - private $tiebreaker = 0; + protected $tiebreaker = 0; /** * The mutations associated with this change to the partition. * May contain complete mutations or chunks of a multi-message chunked @@ -73,14 +73,14 @@ class DataChange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool done = 8; */ - private $done = false; + protected $done = false; /** * An encoded position for this stream's partition to restart reading from. * This token is for the StreamPartition from the request. * * Generated from protobuf field string token = 9; */ - private $token = ''; + protected $token = ''; /** * An estimate of the commit timestamp that is usually lower than or equal * to any timestamp for a record that will be delivered in the future on the @@ -91,7 +91,7 @@ class DataChange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp estimated_low_watermark = 10; */ - private $estimated_low_watermark = null; + protected $estimated_low_watermark = null; /** * Constructor. diff --git a/Bigtable/src/V2/ReadChangeStreamResponse/Heartbeat.php b/Bigtable/src/V2/ReadChangeStreamResponse/Heartbeat.php index b2dd35fa7fb..e20a2f71123 100644 --- a/Bigtable/src/V2/ReadChangeStreamResponse/Heartbeat.php +++ b/Bigtable/src/V2/ReadChangeStreamResponse/Heartbeat.php @@ -22,7 +22,7 @@ class Heartbeat extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.StreamContinuationToken continuation_token = 1; */ - private $continuation_token = null; + protected $continuation_token = null; /** * An estimate of the commit timestamp that is usually lower than or equal * to any timestamp for a record that will be delivered in the future on the @@ -33,7 +33,7 @@ class Heartbeat extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Timestamp estimated_low_watermark = 2; */ - private $estimated_low_watermark = null; + protected $estimated_low_watermark = null; /** * Constructor. diff --git a/Bigtable/src/V2/ReadChangeStreamResponse/MutationChunk.php b/Bigtable/src/V2/ReadChangeStreamResponse/MutationChunk.php index c6bb931d5d0..861921c6235 100644 --- a/Bigtable/src/V2/ReadChangeStreamResponse/MutationChunk.php +++ b/Bigtable/src/V2/ReadChangeStreamResponse/MutationChunk.php @@ -21,7 +21,7 @@ class MutationChunk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.ReadChangeStreamResponse.MutationChunk.ChunkInfo chunk_info = 1; */ - private $chunk_info = null; + protected $chunk_info = null; /** * If this is a continuation of a chunked message (`chunked_value_offset` > * 0), ignore all fields except the `SetCell`'s value and merge it with @@ -29,7 +29,7 @@ class MutationChunk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.Mutation mutation = 2; */ - private $mutation = null; + protected $mutation = null; /** * Constructor. diff --git a/Bigtable/src/V2/ReadChangeStreamResponse/MutationChunk/ChunkInfo.php b/Bigtable/src/V2/ReadChangeStreamResponse/MutationChunk/ChunkInfo.php index 174f6858520..f8a6c673c8b 100644 --- a/Bigtable/src/V2/ReadChangeStreamResponse/MutationChunk/ChunkInfo.php +++ b/Bigtable/src/V2/ReadChangeStreamResponse/MutationChunk/ChunkInfo.php @@ -22,20 +22,20 @@ class ChunkInfo extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 chunked_value_size = 1; */ - private $chunked_value_size = 0; + protected $chunked_value_size = 0; /** * The byte offset of this chunk into the total value size of the * mutation. * * Generated from protobuf field int32 chunked_value_offset = 2; */ - private $chunked_value_offset = 0; + protected $chunked_value_offset = 0; /** * When true, this is the last chunk of a chunked `SetCell`. * * Generated from protobuf field bool last_chunk = 3; */ - private $last_chunk = false; + protected $last_chunk = false; /** * Constructor. diff --git a/Bigtable/src/V2/ReadEfficiencyStats.php b/Bigtable/src/V2/ReadEfficiencyStats.php deleted file mode 100644 index fcc7b28f05f..00000000000 --- a/Bigtable/src/V2/ReadEfficiencyStats.php +++ /dev/null @@ -1,137 +0,0 @@ -google.bigtable.v2.ReadEfficiencyStats - */ -class ReadEfficiencyStats extends \Google\Protobuf\Internal\Message -{ - /** - * Iteration stats describe how efficient the read is, e.g. comparing - * rows seen vs. rows returned or cells seen vs cells returned can provide an - * indication of read efficiency (the higher the ratio of seen to retuned the - * better). - * - * Generated from protobuf field .google.bigtable.v2.ReadIteratorStats read_iterator_stats = 1; - */ - private $read_iterator_stats = null; - /** - * Request latency stats describe the time taken to complete a request, from - * the server side. - * - * Generated from protobuf field .google.bigtable.v2.RequestLatencyStats request_latency_stats = 2; - */ - private $request_latency_stats = null; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type \Google\Cloud\Bigtable\V2\ReadIteratorStats $read_iterator_stats - * Iteration stats describe how efficient the read is, e.g. comparing - * rows seen vs. rows returned or cells seen vs cells returned can provide an - * indication of read efficiency (the higher the ratio of seen to retuned the - * better). - * @type \Google\Cloud\Bigtable\V2\RequestLatencyStats $request_latency_stats - * Request latency stats describe the time taken to complete a request, from - * the server side. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Bigtable\V2\RequestStats::initOnce(); - parent::__construct($data); - } - - /** - * Iteration stats describe how efficient the read is, e.g. comparing - * rows seen vs. rows returned or cells seen vs cells returned can provide an - * indication of read efficiency (the higher the ratio of seen to retuned the - * better). - * - * Generated from protobuf field .google.bigtable.v2.ReadIteratorStats read_iterator_stats = 1; - * @return \Google\Cloud\Bigtable\V2\ReadIteratorStats|null - */ - public function getReadIteratorStats() - { - return $this->read_iterator_stats; - } - - public function hasReadIteratorStats() - { - return isset($this->read_iterator_stats); - } - - public function clearReadIteratorStats() - { - unset($this->read_iterator_stats); - } - - /** - * Iteration stats describe how efficient the read is, e.g. comparing - * rows seen vs. rows returned or cells seen vs cells returned can provide an - * indication of read efficiency (the higher the ratio of seen to retuned the - * better). - * - * Generated from protobuf field .google.bigtable.v2.ReadIteratorStats read_iterator_stats = 1; - * @param \Google\Cloud\Bigtable\V2\ReadIteratorStats $var - * @return $this - */ - public function setReadIteratorStats($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\ReadIteratorStats::class); - $this->read_iterator_stats = $var; - - return $this; - } - - /** - * Request latency stats describe the time taken to complete a request, from - * the server side. - * - * Generated from protobuf field .google.bigtable.v2.RequestLatencyStats request_latency_stats = 2; - * @return \Google\Cloud\Bigtable\V2\RequestLatencyStats|null - */ - public function getRequestLatencyStats() - { - return $this->request_latency_stats; - } - - public function hasRequestLatencyStats() - { - return isset($this->request_latency_stats); - } - - public function clearRequestLatencyStats() - { - unset($this->request_latency_stats); - } - - /** - * Request latency stats describe the time taken to complete a request, from - * the server side. - * - * Generated from protobuf field .google.bigtable.v2.RequestLatencyStats request_latency_stats = 2; - * @param \Google\Cloud\Bigtable\V2\RequestLatencyStats $var - * @return $this - */ - public function setRequestLatencyStats($var) - { - GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\RequestLatencyStats::class); - $this->request_latency_stats = $var; - - return $this; - } - -} - diff --git a/Bigtable/src/V2/ReadIterationStats.php b/Bigtable/src/V2/ReadIterationStats.php index d956a7d0c9f..f226aa85abc 100644 --- a/Bigtable/src/V2/ReadIterationStats.php +++ b/Bigtable/src/V2/ReadIterationStats.php @@ -23,26 +23,26 @@ class ReadIterationStats extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 rows_seen_count = 1; */ - private $rows_seen_count = 0; + protected $rows_seen_count = 0; /** * The rows returned as part of the request. * * Generated from protobuf field int64 rows_returned_count = 2; */ - private $rows_returned_count = 0; + protected $rows_returned_count = 0; /** * The cells seen (scanned) as part of the request. This includes the count of * cells returned, as captured below. * * Generated from protobuf field int64 cells_seen_count = 3; */ - private $cells_seen_count = 0; + protected $cells_seen_count = 0; /** * The cells returned as part of the request. * * Generated from protobuf field int64 cells_returned_count = 4; */ - private $cells_returned_count = 0; + protected $cells_returned_count = 0; /** * Constructor. diff --git a/Bigtable/src/V2/ReadIteratorStats.php b/Bigtable/src/V2/ReadIteratorStats.php deleted file mode 100644 index 03a87f6900d..00000000000 --- a/Bigtable/src/V2/ReadIteratorStats.php +++ /dev/null @@ -1,213 +0,0 @@ -google.bigtable.v2.ReadIteratorStats - */ -class ReadIteratorStats extends \Google\Protobuf\Internal\Message -{ - /** - * The rows seen (scanned) as part of the request. This includes the count of - * rows returned, as captured below. - * - * Generated from protobuf field int64 rows_seen_count = 1; - */ - private $rows_seen_count = 0; - /** - * The rows returned as part of the request. - * - * Generated from protobuf field int64 rows_returned_count = 2; - */ - private $rows_returned_count = 0; - /** - * The cells seen (scanned) as part of the request. This includes the count of - * cells returned, as captured below. - * - * Generated from protobuf field int64 cells_seen_count = 3; - */ - private $cells_seen_count = 0; - /** - * The cells returned as part of the request. - * - * Generated from protobuf field int64 cells_returned_count = 4; - */ - private $cells_returned_count = 0; - /** - * The deletes seen as part of the request. - * - * Generated from protobuf field int64 deletes_seen_count = 5; - */ - private $deletes_seen_count = 0; - - /** - * Constructor. - * - * @param array $data { - * Optional. Data for populating the Message object. - * - * @type int|string $rows_seen_count - * The rows seen (scanned) as part of the request. This includes the count of - * rows returned, as captured below. - * @type int|string $rows_returned_count - * The rows returned as part of the request. - * @type int|string $cells_seen_count - * The cells seen (scanned) as part of the request. This includes the count of - * cells returned, as captured below. - * @type int|string $cells_returned_count - * The cells returned as part of the request. - * @type int|string $deletes_seen_count - * The deletes seen as part of the request. - * } - */ - public function __construct($data = NULL) { - \GPBMetadata\Google\Bigtable\V2\RequestStats::initOnce(); - parent::__construct($data); - } - - /** - * The rows seen (scanned) as part of the request. This includes the count of - * rows returned, as captured below. - * - * Generated from protobuf field int64 rows_seen_count = 1; - * @return int|string - */ - public function getRowsSeenCount() - { - return $this->rows_seen_count; - } - - /** - * The rows seen (scanned) as part of the request. This includes the count of - * rows returned, as captured below. - * - * Generated from protobuf field int64 rows_seen_count = 1; - * @param int|string $var - * @return $this - */ - public function setRowsSeenCount($var) - { - GPBUtil::checkInt64($var); - $this->rows_seen_count = $var; - - return $this; - } - - /** - * The rows returned as part of the request. - * - * Generated from protobuf field int64 rows_returned_count = 2; - * @return int|string - */ - public function getRowsReturnedCount() - { - return $this->rows_returned_count; - } - - /** - * The rows returned as part of the request. - * - * Generated from protobuf field int64 rows_returned_count = 2; - * @param int|string $var - * @return $this - */ - public function setRowsReturnedCount($var) - { - GPBUtil::checkInt64($var); - $this->rows_returned_count = $var; - - return $this; - } - - /** - * The cells seen (scanned) as part of the request. This includes the count of - * cells returned, as captured below. - * - * Generated from protobuf field int64 cells_seen_count = 3; - * @return int|string - */ - public function getCellsSeenCount() - { - return $this->cells_seen_count; - } - - /** - * The cells seen (scanned) as part of the request. This includes the count of - * cells returned, as captured below. - * - * Generated from protobuf field int64 cells_seen_count = 3; - * @param int|string $var - * @return $this - */ - public function setCellsSeenCount($var) - { - GPBUtil::checkInt64($var); - $this->cells_seen_count = $var; - - return $this; - } - - /** - * The cells returned as part of the request. - * - * Generated from protobuf field int64 cells_returned_count = 4; - * @return int|string - */ - public function getCellsReturnedCount() - { - return $this->cells_returned_count; - } - - /** - * The cells returned as part of the request. - * - * Generated from protobuf field int64 cells_returned_count = 4; - * @param int|string $var - * @return $this - */ - public function setCellsReturnedCount($var) - { - GPBUtil::checkInt64($var); - $this->cells_returned_count = $var; - - return $this; - } - - /** - * The deletes seen as part of the request. - * - * Generated from protobuf field int64 deletes_seen_count = 5; - * @return int|string - */ - public function getDeletesSeenCount() - { - return $this->deletes_seen_count; - } - - /** - * The deletes seen as part of the request. - * - * Generated from protobuf field int64 deletes_seen_count = 5; - * @param int|string $var - * @return $this - */ - public function setDeletesSeenCount($var) - { - GPBUtil::checkInt64($var); - $this->deletes_seen_count = $var; - - return $this; - } - -} - diff --git a/Bigtable/src/V2/ReadModifyWriteRowRequest.php b/Bigtable/src/V2/ReadModifyWriteRowRequest.php index d7d0a6df01b..ab877a010aa 100644 --- a/Bigtable/src/V2/ReadModifyWriteRowRequest.php +++ b/Bigtable/src/V2/ReadModifyWriteRowRequest.php @@ -23,7 +23,7 @@ class ReadModifyWriteRowRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table_name = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $table_name = ''; + protected $table_name = ''; /** * Optional. The unique name of the AuthorizedView to which the * read/modify/write rules should be applied. @@ -32,21 +32,21 @@ class ReadModifyWriteRowRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string authorized_view_name = 6 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $authorized_view_name = ''; + protected $authorized_view_name = ''; /** * This value specifies routing for replication. If not specified, the * "default" application profile will be used. * * Generated from protobuf field string app_profile_id = 4; */ - private $app_profile_id = ''; + protected $app_profile_id = ''; /** * Required. The key of the row to which the read/modify/write rules should be * applied. * * Generated from protobuf field bytes row_key = 2 [(.google.api.field_behavior) = REQUIRED]; */ - private $row_key = ''; + protected $row_key = ''; /** * Required. Rules specifying how the specified row's contents are to be * transformed into writes. Entries are applied in order, meaning that earlier diff --git a/Bigtable/src/V2/ReadModifyWriteRowResponse.php b/Bigtable/src/V2/ReadModifyWriteRowResponse.php index 74b5b8fb2ba..1b1c1cdac4a 100644 --- a/Bigtable/src/V2/ReadModifyWriteRowResponse.php +++ b/Bigtable/src/V2/ReadModifyWriteRowResponse.php @@ -20,7 +20,7 @@ class ReadModifyWriteRowResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.Row row = 1; */ - private $row = null; + protected $row = null; /** * Constructor. diff --git a/Bigtable/src/V2/ReadModifyWriteRule.php b/Bigtable/src/V2/ReadModifyWriteRule.php index e38ec7a115a..1afafb1f597 100644 --- a/Bigtable/src/V2/ReadModifyWriteRule.php +++ b/Bigtable/src/V2/ReadModifyWriteRule.php @@ -22,7 +22,7 @@ class ReadModifyWriteRule extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string family_name = 1; */ - private $family_name = ''; + protected $family_name = ''; /** * The qualifier of the column to which the read/modify/write should be * applied. @@ -30,7 +30,7 @@ class ReadModifyWriteRule extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes column_qualifier = 2; */ - private $column_qualifier = ''; + protected $column_qualifier = ''; protected $rule; /** diff --git a/Bigtable/src/V2/ReadRowsRequest.php b/Bigtable/src/V2/ReadRowsRequest.php index d5821fca794..d8401d3e4c4 100644 --- a/Bigtable/src/V2/ReadRowsRequest.php +++ b/Bigtable/src/V2/ReadRowsRequest.php @@ -22,7 +22,7 @@ class ReadRowsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table_name = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $table_name = ''; + protected $table_name = ''; /** * Optional. The unique name of the AuthorizedView from which to read. * Values are of the form @@ -30,41 +30,41 @@ class ReadRowsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string authorized_view_name = 9 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $authorized_view_name = ''; + protected $authorized_view_name = ''; /** * This value specifies routing for replication. If not specified, the * "default" application profile will be used. * * Generated from protobuf field string app_profile_id = 5; */ - private $app_profile_id = ''; + protected $app_profile_id = ''; /** * The row keys and/or ranges to read sequentially. If not specified, reads * from all rows. * * Generated from protobuf field .google.bigtable.v2.RowSet rows = 2; */ - private $rows = null; + protected $rows = null; /** * The filter to apply to the contents of the specified row(s). If unset, * reads the entirety of each row. * * Generated from protobuf field .google.bigtable.v2.RowFilter filter = 3; */ - private $filter = null; + protected $filter = null; /** * The read will stop after committing to N rows' worth of results. The * default (zero) is to return all results. * * Generated from protobuf field int64 rows_limit = 4; */ - private $rows_limit = 0; + protected $rows_limit = 0; /** * The view into RequestStats, as described above. * * Generated from protobuf field .google.bigtable.v2.ReadRowsRequest.RequestStatsView request_stats_view = 6; */ - private $request_stats_view = 0; + protected $request_stats_view = 0; /** * Experimental API - Please note that this API is currently experimental * and can change in the future. @@ -78,7 +78,7 @@ class ReadRowsRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bool reversed = 7; */ - private $reversed = false; + protected $reversed = false; /** * @param string $tableName Optional. The unique name of the table from which to read. diff --git a/Bigtable/src/V2/ReadRowsResponse.php b/Bigtable/src/V2/ReadRowsResponse.php index b6f30080211..024cc02abc0 100644 --- a/Bigtable/src/V2/ReadRowsResponse.php +++ b/Bigtable/src/V2/ReadRowsResponse.php @@ -32,7 +32,7 @@ class ReadRowsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes last_scanned_row_key = 2; */ - private $last_scanned_row_key = ''; + protected $last_scanned_row_key = ''; /** * If requested, provide enhanced query performance statistics. The semantics * dictate: @@ -54,7 +54,7 @@ class ReadRowsResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.RequestStats request_stats = 3; */ - private $request_stats = null; + protected $request_stats = null; /** * Constructor. diff --git a/Bigtable/src/V2/ReadRowsResponse/CellChunk.php b/Bigtable/src/V2/ReadRowsResponse/CellChunk.php index 152f9b5353d..0ff8217f7de 100644 --- a/Bigtable/src/V2/ReadRowsResponse/CellChunk.php +++ b/Bigtable/src/V2/ReadRowsResponse/CellChunk.php @@ -24,7 +24,7 @@ class CellChunk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes row_key = 1; */ - private $row_key = ''; + protected $row_key = ''; /** * The column family name for this chunk of data. If this message * is not present this CellChunk is a continuation of the same column @@ -35,7 +35,7 @@ class CellChunk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.StringValue family_name = 2; */ - private $family_name = null; + protected $family_name = null; /** * The column qualifier for this chunk of data. If this message * is not present, this CellChunk is a continuation of the same column @@ -45,7 +45,7 @@ class CellChunk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.BytesValue qualifier = 3; */ - private $qualifier = null; + protected $qualifier = null; /** * The cell's stored timestamp, which also uniquely identifies it * within its column. Values are always expressed in @@ -58,7 +58,7 @@ class CellChunk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 timestamp_micros = 4; */ - private $timestamp_micros = 0; + protected $timestamp_micros = 0; /** * Labels applied to the cell by a * [RowFilter][google.bigtable.v2.RowFilter]. Labels are only set @@ -76,7 +76,7 @@ class CellChunk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes value = 6; */ - private $value = ''; + protected $value = ''; /** * If this CellChunk is part of a chunked cell value and this is * not the final chunk of that cell, value_size will be set to the @@ -85,7 +85,7 @@ class CellChunk extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int32 value_size = 7; */ - private $value_size = 0; + protected $value_size = 0; protected $row_status; /** @@ -220,7 +220,7 @@ public function clearFamilyName() * Generated from protobuf field .google.protobuf.StringValue family_name = 2; * @return string|null */ - public function getFamilyNameValue() + public function getFamilyNameUnwrapped() { return $this->readWrapperValue("family_name"); } @@ -259,7 +259,7 @@ public function setFamilyName($var) * @param string|null $var * @return $this */ - public function setFamilyNameValue($var) + public function setFamilyNameUnwrapped($var) { $this->writeWrapperValue("family_name", $var); return $this;} @@ -301,7 +301,7 @@ public function clearQualifier() * Generated from protobuf field .google.protobuf.BytesValue qualifier = 3; * @return string|null */ - public function getQualifierValue() + public function getQualifierUnwrapped() { return $this->readWrapperValue("qualifier"); } @@ -338,7 +338,7 @@ public function setQualifier($var) * @param string|null $var * @return $this */ - public function setQualifierValue($var) + public function setQualifierUnwrapped($var) { $this->writeWrapperValue("qualifier", $var); return $this;} diff --git a/Bigtable/src/V2/RequestLatencyStats.php b/Bigtable/src/V2/RequestLatencyStats.php index 2630371a2f3..26a852ba8ea 100644 --- a/Bigtable/src/V2/RequestLatencyStats.php +++ b/Bigtable/src/V2/RequestLatencyStats.php @@ -36,7 +36,7 @@ class RequestLatencyStats extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.protobuf.Duration frontend_server_latency = 1; */ - private $frontend_server_latency = null; + protected $frontend_server_latency = null; /** * Constructor. diff --git a/Bigtable/src/V2/ResponseParams.php b/Bigtable/src/V2/ResponseParams.php index 201a3a42780..08a68a68ff0 100644 --- a/Bigtable/src/V2/ResponseParams.php +++ b/Bigtable/src/V2/ResponseParams.php @@ -23,14 +23,14 @@ class ResponseParams extends \Google\Protobuf\Internal\Message * * Generated from protobuf field optional string zone_id = 1; */ - private $zone_id = null; + protected $zone_id = null; /** * Identifier for a cluster that represents set of * bigtable resources. * * Generated from protobuf field optional string cluster_id = 2; */ - private $cluster_id = null; + protected $cluster_id = null; /** * Constructor. diff --git a/Bigtable/src/V2/Row.php b/Bigtable/src/V2/Row.php index 2b02b14d37e..ad1d56187e7 100644 --- a/Bigtable/src/V2/Row.php +++ b/Bigtable/src/V2/Row.php @@ -23,7 +23,7 @@ class Row extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes key = 1; */ - private $key = ''; + protected $key = ''; /** * May be empty, but only if the entire row is empty. * The mutual ordering of column families is not specified. diff --git a/Bigtable/src/V2/RowFilter/Condition.php b/Bigtable/src/V2/RowFilter/Condition.php index 546e900076d..f7e66bf8181 100644 --- a/Bigtable/src/V2/RowFilter/Condition.php +++ b/Bigtable/src/V2/RowFilter/Condition.php @@ -26,14 +26,14 @@ class Condition extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.RowFilter predicate_filter = 1; */ - private $predicate_filter = null; + protected $predicate_filter = null; /** * The filter to apply to the input row if `predicate_filter` returns any * results. If not provided, no results will be returned in the true case. * * Generated from protobuf field .google.bigtable.v2.RowFilter true_filter = 2; */ - private $true_filter = null; + protected $true_filter = null; /** * The filter to apply to the input row if `predicate_filter` does not * return any results. If not provided, no results will be returned in the @@ -41,7 +41,7 @@ class Condition extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.RowFilter false_filter = 3; */ - private $false_filter = null; + protected $false_filter = null; /** * Constructor. diff --git a/Bigtable/src/V2/SampleRowKeysRequest.php b/Bigtable/src/V2/SampleRowKeysRequest.php index 1ca9d18860c..de1a618ad0b 100644 --- a/Bigtable/src/V2/SampleRowKeysRequest.php +++ b/Bigtable/src/V2/SampleRowKeysRequest.php @@ -22,7 +22,7 @@ class SampleRowKeysRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string table_name = 1 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $table_name = ''; + protected $table_name = ''; /** * Optional. The unique name of the AuthorizedView from which to sample row * keys. @@ -31,14 +31,14 @@ class SampleRowKeysRequest extends \Google\Protobuf\Internal\Message * * Generated from protobuf field string authorized_view_name = 4 [(.google.api.field_behavior) = OPTIONAL, (.google.api.resource_reference) = { */ - private $authorized_view_name = ''; + protected $authorized_view_name = ''; /** * This value specifies routing for replication. If not specified, the * "default" application profile will be used. * * Generated from protobuf field string app_profile_id = 2; */ - private $app_profile_id = ''; + protected $app_profile_id = ''; /** * @param string $tableName Optional. The unique name of the table from which to sample row keys. diff --git a/Bigtable/src/V2/SampleRowKeysResponse.php b/Bigtable/src/V2/SampleRowKeysResponse.php index 2dc0b5c3b21..1c38c831d34 100644 --- a/Bigtable/src/V2/SampleRowKeysResponse.php +++ b/Bigtable/src/V2/SampleRowKeysResponse.php @@ -26,7 +26,7 @@ class SampleRowKeysResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field bytes row_key = 1; */ - private $row_key = ''; + protected $row_key = ''; /** * Approximate total storage space used by all rows in the table which precede * `row_key`. Buffering the contents of all rows between two subsequent @@ -35,7 +35,7 @@ class SampleRowKeysResponse extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 offset_bytes = 2; */ - private $offset_bytes = 0; + protected $offset_bytes = 0; /** * Constructor. diff --git a/Bigtable/src/V2/StreamContinuationToken.php b/Bigtable/src/V2/StreamContinuationToken.php index e0cf4401cf9..9a623c62eba 100644 --- a/Bigtable/src/V2/StreamContinuationToken.php +++ b/Bigtable/src/V2/StreamContinuationToken.php @@ -22,13 +22,13 @@ class StreamContinuationToken extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.StreamPartition partition = 1; */ - private $partition = null; + protected $partition = null; /** * An encoded position in the stream to restart reading from. * * Generated from protobuf field string token = 2; */ - private $token = ''; + protected $token = ''; /** * Constructor. diff --git a/Bigtable/src/V2/StreamPartition.php b/Bigtable/src/V2/StreamPartition.php index 41ba99037b3..2efb7f58fd2 100644 --- a/Bigtable/src/V2/StreamPartition.php +++ b/Bigtable/src/V2/StreamPartition.php @@ -22,7 +22,7 @@ class StreamPartition extends \Google\Protobuf\Internal\Message * * Generated from protobuf field .google.bigtable.v2.RowRange row_range = 1; */ - private $row_range = null; + protected $row_range = null; /** * Constructor. diff --git a/Bigtable/src/V2/TimestampRange.php b/Bigtable/src/V2/TimestampRange.php index a75b65d5f10..ddd1bcea30d 100644 --- a/Bigtable/src/V2/TimestampRange.php +++ b/Bigtable/src/V2/TimestampRange.php @@ -20,13 +20,13 @@ class TimestampRange extends \Google\Protobuf\Internal\Message * * Generated from protobuf field int64 start_timestamp_micros = 1; */ - private $start_timestamp_micros = 0; + protected $start_timestamp_micros = 0; /** * Exclusive upper bound. If left empty, interpreted as infinity. * * Generated from protobuf field int64 end_timestamp_micros = 2; */ - private $end_timestamp_micros = 0; + protected $end_timestamp_micros = 0; /** * Constructor. diff --git a/Bigtable/tests/System/BigtableTestCase.php b/Bigtable/tests/System/BigtableTestCase.php index fd5167a11fc..642eb5901be 100644 --- a/Bigtable/tests/System/BigtableTestCase.php +++ b/Bigtable/tests/System/BigtableTestCase.php @@ -53,11 +53,12 @@ public static function setUpBeforeClass(): void { self::setUsingEmulator(getenv('BIGTABLE_EMULATOR_HOST')); $keyFilePath = getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH'); + $credentials = self::isEmulatorUsed() ? null : $keyFilePath; self::$instanceAdminClient = new InstanceAdminClient([ - 'credentials' => $keyFilePath + 'credentials' => $credentials, ]); self::$tableAdminClient = new TableAdminClient([ - 'credentials' => $keyFilePath + 'credentials' => $credentials, ]); $keyFileData = json_decode(file_get_contents($keyFilePath), true); self::$projectId = $keyFileData['project_id']; @@ -65,7 +66,7 @@ public static function setUpBeforeClass(): void self::$clusterId = uniqid(self::CLUSTER_ID_PREFIX); self::$table = (new BigtableClient([ 'projectId' => self::$projectId, - 'credentials' => $keyFilePath + 'credentials' => $credentials, ]))->table(self::$instanceId, self::TABLE_ID); if (!self::isEmulatorUsed()) { self::createInstance(); diff --git a/Bigtable/tests/Unit/Admin/V2/Client/BigtableInstanceAdminClientTest.php b/Bigtable/tests/Unit/Admin/V2/Client/BigtableInstanceAdminClientTest.php index 0cbd730546e..a7f1ed41693 100644 --- a/Bigtable/tests/Unit/Admin/V2/Client/BigtableInstanceAdminClientTest.php +++ b/Bigtable/tests/Unit/Admin/V2/Client/BigtableInstanceAdminClientTest.php @@ -67,8 +67,7 @@ use stdClass; /** - * @group bigtable - * bigtable-admin + * @group admin * * @group gapic */ diff --git a/Bigtable/tests/Unit/Admin/V2/Client/BigtableTableAdminClientTest.php b/Bigtable/tests/Unit/Admin/V2/Client/BigtableTableAdminClientTest.php index b57e6f65fd2..5aa5d0df288 100644 --- a/Bigtable/tests/Unit/Admin/V2/Client/BigtableTableAdminClientTest.php +++ b/Bigtable/tests/Unit/Admin/V2/Client/BigtableTableAdminClientTest.php @@ -80,8 +80,7 @@ use stdClass; /** - * @group bigtable - * bigtable-admin + * @group admin * * @group gapic */ diff --git a/Bigtable/tests/Unit/V2/BigtableClientTest.php b/Bigtable/tests/Unit/V2/BigtableClientTest.php deleted file mode 100644 index 8f80cbdd27b..00000000000 --- a/Bigtable/tests/Unit/V2/BigtableClientTest.php +++ /dev/null @@ -1,771 +0,0 @@ -getMockBuilder(CredentialsWrapper::class)->disableOriginalConstructor()->getMock(); - } - - /** @return BigtableGapicClient */ - private function createClient(array $options = []) - { - $options += [ - 'credentials' => $this->createCredentials(), - ]; - return new BigtableGapicClient($options); - } - - /** @test */ - public function checkAndMutateRowTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $predicateMatched = true; - $expectedResponse = new CheckAndMutateRowResponse(); - $expectedResponse->setPredicateMatched($predicateMatched); - $transport->addResponse($expectedResponse); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $rowKey = '122'; - $request = new CheckAndMutateRowRequest([ - 'table_name' => $formattedTableName, - 'row_key' => $rowKey - ]); - $response = $gapicClient->checkAndMutateRow($request); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.v2.Bigtable/CheckAndMutateRow', $actualFuncCall); - $actualValue = $actualRequestObject->getTableName(); - $this->assertProtobufEquals($formattedTableName, $actualValue); - $actualValue = $actualRequestObject->getRowKey(); - $this->assertProtobufEquals($rowKey, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function checkAndMutateRowExceptionTest() - { - $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 - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $rowKey = '122'; - $request = new CheckAndMutateRowRequest([ - 'table_name' => $formattedTableName, - 'row_key' => $rowKey - ]); - try { - $gapicClient->checkAndMutateRow($request); - // 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 generateInitialChangeStreamPartitionsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new GenerateInitialChangeStreamPartitionsResponse(); - $transport->addResponse($expectedResponse); - $expectedResponse2 = new GenerateInitialChangeStreamPartitionsResponse(); - $transport->addResponse($expectedResponse2); - $expectedResponse3 = new GenerateInitialChangeStreamPartitionsResponse(); - $transport->addResponse($expectedResponse3); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $request = new GenerateInitialChangeStreamPartitionsRequest([ - 'table_name' => $formattedTableName - ]); - $serverStream = $gapicClient->generateInitialChangeStreamPartitions($request); - $this->assertInstanceOf(ServerStream::class, $serverStream); - $responses = iterator_to_array($serverStream->readAll()); - $expectedResponses = []; - $expectedResponses[] = $expectedResponse; - $expectedResponses[] = $expectedResponse2; - $expectedResponses[] = $expectedResponse3; - $this->assertEquals($expectedResponses, $responses); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.v2.Bigtable/GenerateInitialChangeStreamPartitions', $actualFuncCall); - $actualValue = $actualRequestObject->getTableName(); - $this->assertProtobufEquals($formattedTableName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function generateInitialChangeStreamPartitionsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $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->setStreamingStatus($status); - $this->assertTrue($transport->isExhausted()); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $request = new GenerateInitialChangeStreamPartitionsRequest([ - 'table_name' => $formattedTableName - ]); - $serverStream = $gapicClient->generateInitialChangeStreamPartitions($request); - $results = $serverStream->readAll(); - try { - iterator_to_array($results); - // If the close stream 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 mutateRowTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new MutateRowResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $rowKey = '122'; - $mutations = []; - $request = new MutateRowRequest([ - 'row_key' => $rowKey, - 'mutations' => $mutations, - 'table_name' => $formattedTableName - ]); - $response = $gapicClient->mutateRow($request); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.v2.Bigtable/MutateRow', $actualFuncCall); - $actualValue = $actualRequestObject->getTableName(); - $this->assertProtobufEquals($formattedTableName, $actualValue); - $actualValue = $actualRequestObject->getRowKey(); - $this->assertProtobufEquals($rowKey, $actualValue); - $actualValue = $actualRequestObject->getMutations(); - $this->assertProtobufEquals($mutations, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function mutateRowExceptionTest() - { - $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 - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $rowKey = '122'; - $mutations = []; - $request = new MutateRowRequest([ - 'row_key' => $rowKey, - 'mutations' => $mutations, - 'table_name' => $formattedTableName - ]); - try { - $gapicClient->mutateRow($request); - // 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 mutateRowsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new MutateRowsResponse(); - $transport->addResponse($expectedResponse); - $expectedResponse2 = new MutateRowsResponse(); - $transport->addResponse($expectedResponse2); - $expectedResponse3 = new MutateRowsResponse(); - $transport->addResponse($expectedResponse3); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $entries = []; - $request = new MutateRowsRequest([ - 'entries' => $entries, - 'table_name' => $formattedTableName - ]); - $serverStream = $gapicClient->mutateRows($request); - $this->assertInstanceOf(ServerStream::class, $serverStream); - $responses = iterator_to_array($serverStream->readAll()); - $expectedResponses = []; - $expectedResponses[] = $expectedResponse; - $expectedResponses[] = $expectedResponse2; - $expectedResponses[] = $expectedResponse3; - $this->assertEquals($expectedResponses, $responses); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.v2.Bigtable/MutateRows', $actualFuncCall); - $actualValue = $actualRequestObject->getTableName(); - $this->assertProtobufEquals($formattedTableName, $actualValue); - $actualValue = $actualRequestObject->getEntries(); - $this->assertProtobufEquals($entries, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function mutateRowsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $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->setStreamingStatus($status); - $this->assertTrue($transport->isExhausted()); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $entries = []; - $request = new MutateRowsRequest([ - 'entries' => $entries, - 'table_name' => $formattedTableName - ]); - $serverStream = $gapicClient->mutateRows($request); - $results = $serverStream->readAll(); - try { - iterator_to_array($results); - // If the close stream 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 pingAndWarmTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new PingAndWarmResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - $request = new PingAndWarmRequest([ - 'name' => $formattedName - ]); - $response = $gapicClient->pingAndWarm($request); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.v2.Bigtable/PingAndWarm', $actualFuncCall); - $actualValue = $actualRequestObject->getName(); - $this->assertProtobufEquals($formattedName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function pingAndWarmExceptionTest() - { - $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 - $formattedName = $gapicClient->instanceName('[PROJECT]', '[INSTANCE]'); - try { - $request = new PingAndWarmRequest([ - 'name' => $formattedName - ]); - $gapicClient->pingAndWarm($request); - // 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 readChangeStreamTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ReadChangeStreamResponse(); - $transport->addResponse($expectedResponse); - $expectedResponse2 = new ReadChangeStreamResponse(); - $transport->addResponse($expectedResponse2); - $expectedResponse3 = new ReadChangeStreamResponse(); - $transport->addResponse($expectedResponse3); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $request = new ReadChangeStreamRequest([ - 'table_name' => $formattedTableName - ]); - $serverStream = $gapicClient->readChangeStream($request); - $this->assertInstanceOf(ServerStream::class, $serverStream); - $responses = iterator_to_array($serverStream->readAll()); - $expectedResponses = []; - $expectedResponses[] = $expectedResponse; - $expectedResponses[] = $expectedResponse2; - $expectedResponses[] = $expectedResponse3; - $this->assertEquals($expectedResponses, $responses); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.v2.Bigtable/ReadChangeStream', $actualFuncCall); - $actualValue = $actualRequestObject->getTableName(); - $this->assertProtobufEquals($formattedTableName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function readChangeStreamExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $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->setStreamingStatus($status); - $this->assertTrue($transport->isExhausted()); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $request = new ReadChangeStreamRequest([ - 'table_name' => $formattedTableName - ]); - $serverStream = $gapicClient->readChangeStream($request); - $results = $serverStream->readAll(); - try { - iterator_to_array($results); - // If the close stream 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 readModifyWriteRowTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $expectedResponse = new ReadModifyWriteRowResponse(); - $transport->addResponse($expectedResponse); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $rowKey = '122'; - $rules = []; - $request = new ReadModifyWriteRowRequest([ - 'table_name' => $formattedTableName, - 'row_key' => $rowKey, - 'rules' => $rules - ]); - $response = $gapicClient->readModifyWriteRow($request); - $this->assertEquals($expectedResponse, $response); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.v2.Bigtable/ReadModifyWriteRow', $actualFuncCall); - $actualValue = $actualRequestObject->getTableName(); - $this->assertProtobufEquals($formattedTableName, $actualValue); - $actualValue = $actualRequestObject->getRowKey(); - $this->assertProtobufEquals($rowKey, $actualValue); - $actualValue = $actualRequestObject->getRules(); - $this->assertProtobufEquals($rules, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function readModifyWriteRowExceptionTest() - { - $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 - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $rowKey = '122'; - $rules = []; - try { - $request = new ReadModifyWriteRowRequest([ - 'table_name' => $formattedTableName, - 'row_key' => $rowKey, - 'rules' => $rules - ]); - $gapicClient->readModifyWriteRow($request); - // 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 readRowsTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $lastScannedRowKey = '-126'; - $expectedResponse = new ReadRowsResponse(); - $expectedResponse->setLastScannedRowKey($lastScannedRowKey); - $transport->addResponse($expectedResponse); - $lastScannedRowKey2 = '-75'; - $expectedResponse2 = new ReadRowsResponse(); - $expectedResponse2->setLastScannedRowKey($lastScannedRowKey2); - $transport->addResponse($expectedResponse2); - $lastScannedRowKey3 = '-74'; - $expectedResponse3 = new ReadRowsResponse(); - $expectedResponse3->setLastScannedRowKey($lastScannedRowKey3); - $transport->addResponse($expectedResponse3); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $request = new ReadRowsRequest([ - 'table_name' => $formattedTableName - ]); - $serverStream = $gapicClient->readRows($request); - $this->assertInstanceOf(ServerStream::class, $serverStream); - $responses = iterator_to_array($serverStream->readAll()); - $expectedResponses = []; - $expectedResponses[] = $expectedResponse; - $expectedResponses[] = $expectedResponse2; - $expectedResponses[] = $expectedResponse3; - $this->assertEquals($expectedResponses, $responses); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.v2.Bigtable/ReadRows', $actualFuncCall); - $actualValue = $actualRequestObject->getTableName(); - $this->assertProtobufEquals($formattedTableName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function readRowsExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $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->setStreamingStatus($status); - $this->assertTrue($transport->isExhausted()); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $request = new ReadRowsRequest([ - 'table_name' => $formattedTableName - ]); - $serverStream = $gapicClient->readRows($request); - $results = $serverStream->readAll(); - try { - iterator_to_array($results); - // If the close stream 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 sampleRowKeysTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $this->assertTrue($transport->isExhausted()); - // Mock response - $rowKey = '122'; - $offsetBytes = 889884095; - $expectedResponse = new SampleRowKeysResponse(); - $expectedResponse->setRowKey($rowKey); - $expectedResponse->setOffsetBytes($offsetBytes); - $transport->addResponse($expectedResponse); - $rowKey2 = '-83'; - $offsetBytes2 = 480126386; - $expectedResponse2 = new SampleRowKeysResponse(); - $expectedResponse2->setRowKey($rowKey2); - $expectedResponse2->setOffsetBytes($offsetBytes2); - $transport->addResponse($expectedResponse2); - $rowKey3 = '-82'; - $offsetBytes3 = 480126387; - $expectedResponse3 = new SampleRowKeysResponse(); - $expectedResponse3->setRowKey($rowKey3); - $expectedResponse3->setOffsetBytes($offsetBytes3); - $transport->addResponse($expectedResponse3); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $request = new SampleRowKeysRequest([ - 'table_name' => $formattedTableName - ]); - $serverStream = $gapicClient->sampleRowKeys($request); - $this->assertInstanceOf(ServerStream::class, $serverStream); - $responses = iterator_to_array($serverStream->readAll()); - $expectedResponses = []; - $expectedResponses[] = $expectedResponse; - $expectedResponses[] = $expectedResponse2; - $expectedResponses[] = $expectedResponse3; - $this->assertEquals($expectedResponses, $responses); - $actualRequests = $transport->popReceivedCalls(); - $this->assertSame(1, count($actualRequests)); - $actualFuncCall = $actualRequests[0]->getFuncCall(); - $actualRequestObject = $actualRequests[0]->getRequestObject(); - $this->assertSame('/google.bigtable.v2.Bigtable/SampleRowKeys', $actualFuncCall); - $actualValue = $actualRequestObject->getTableName(); - $this->assertProtobufEquals($formattedTableName, $actualValue); - $this->assertTrue($transport->isExhausted()); - } - - /** @test */ - public function sampleRowKeysExceptionTest() - { - $transport = $this->createTransport(); - $gapicClient = $this->createClient([ - 'transport' => $transport, - ]); - $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->setStreamingStatus($status); - $this->assertTrue($transport->isExhausted()); - // Mock request - $formattedTableName = $gapicClient->tableName('[PROJECT]', '[INSTANCE]', '[TABLE]'); - $request = new SampleRowKeysRequest([ - 'table_name' => $formattedTableName - ]); - $serverStream = $gapicClient->sampleRowKeys($request); - $results = $serverStream->readAll(); - try { - iterator_to_array($results); - // If the close stream 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()); - } -} From daa44f9dc73fd0c959b023bac2d19d997df803ca Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 3 Jun 2024 10:17:52 -0700 Subject: [PATCH 32/36] Update Bigtable/composer.json --- Bigtable/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bigtable/composer.json b/Bigtable/composer.json index 10f357195ef..9f27be00352 100644 --- a/Bigtable/composer.json +++ b/Bigtable/composer.json @@ -6,7 +6,7 @@ "require": { "php": "^8.0", "google/gax": "^1.30", - "google/cloud-core": "^1.52.7" + "google/cloud-core": "^1.55" }, "require-dev": { "phpunit/phpunit": "^9.0", From cb3108af4238e5aad98aedb0ef8c49c8f785dc33 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 3 Jun 2024 10:58:45 -0700 Subject: [PATCH 33/36] Update composer.json --- Bigtable/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bigtable/composer.json b/Bigtable/composer.json index 9f27be00352..6d49236e1b9 100644 --- a/Bigtable/composer.json +++ b/Bigtable/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "php": "^8.0", - "google/gax": "^1.30", + "google/gax": "^1.34", "google/cloud-core": "^1.55" }, "require-dev": { From d9c4fd0a1688b07f90614e2bf841d8eea4a97c1b Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 3 Jun 2024 11:54:48 -0700 Subject: [PATCH 34/36] fix filters --- Bigtable/src/Table.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Bigtable/src/Table.php b/Bigtable/src/Table.php index 2fbf2ab8b57..71d5d577f3c 100644 --- a/Bigtable/src/Table.php +++ b/Bigtable/src/Table.php @@ -316,16 +316,9 @@ public function readRows(array $options = []) ); } if ($filter !== null) { - if (!$filter instanceof FilterInterface) { - throw new \InvalidArgumentException( - sprintf( - 'Expected filter to be of type \'%s\', instead got \'%s\'.', - FilterInterface::class, - gettype($filter) - ) - ); - } - $data['filter'] = $filter->toProto(); + $data['filter'] = $filter instanceof FilterInterface + ? $filter->toProto() + : $filter; } $data['table_name'] = $this->tableName; From 26e9c4696450653f1b3899ad87ad12da1d38c88f Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 3 Jun 2024 13:26:56 -0700 Subject: [PATCH 35/36] update bigtable versions to 2.0.0-RC1 --- Bigtable/VERSION | 2 +- Bigtable/src/BigtableClient.php | 2 -- composer.json | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Bigtable/VERSION b/Bigtable/VERSION index 96cd6ee1e7a..54ef5dd137b 100644 --- a/Bigtable/VERSION +++ b/Bigtable/VERSION @@ -1 +1 @@ -1.32.1 +2.0.0-RC1 diff --git a/Bigtable/src/BigtableClient.php b/Bigtable/src/BigtableClient.php index ef2bb282304..7bca91745c7 100644 --- a/Bigtable/src/BigtableClient.php +++ b/Bigtable/src/BigtableClient.php @@ -46,8 +46,6 @@ class BigtableClient use DetectProjectIdTrait; use ClientOptionsTrait; - const VERSION = '1.32.1'; - /** * @var GapicClient */ diff --git a/composer.json b/composer.json index 992bf95f756..d0dad10aee5 100644 --- a/composer.json +++ b/composer.json @@ -107,7 +107,7 @@ "google/cloud-bigquery-reservation": "1.3.5", "google/cloud-bigquery-storage": "1.10.4", "google/cloud-bigquerydatatransfer": "1.8.5", - "google/cloud-bigtable": "1.32.1", + "google/cloud-bigtable": "2.0,0-RC1", "google/cloud-billing": "1.9.7", "google/cloud-billing-budgets": "1.4.5", "google/cloud-binary-authorization": "0.8.7", From 303b5ef350b71888f68f81fd11dfbaec17c9923c Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 3 Jun 2024 15:48:52 -0700 Subject: [PATCH 36/36] fix bigtable version in composer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d0dad10aee5..352f405e116 100644 --- a/composer.json +++ b/composer.json @@ -107,7 +107,7 @@ "google/cloud-bigquery-reservation": "1.3.5", "google/cloud-bigquery-storage": "1.10.4", "google/cloud-bigquerydatatransfer": "1.8.5", - "google/cloud-bigtable": "2.0,0-RC1", + "google/cloud-bigtable": "2.0.0-RC1", "google/cloud-billing": "1.9.7", "google/cloud-billing-budgets": "1.4.5", "google/cloud-binary-authorization": "0.8.7",