Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spanner): [Spanner] add proto descriptors for proto and enum types in create/update/get database ddl requests #6991

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Spanner/metadata/Admin/Database/V1/SpannerDatabaseAdmin.php
Binary file not shown.
90 changes: 90 additions & 0 deletions Spanner/src/Admin/Database/V1/CreateDatabaseRequest.php

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

Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,22 @@ public function createBackup(
* @type int $databaseDialect
* Optional. The dialect of the Cloud Spanner Database.
* For allowed values, use constants defined on {@see \Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect}
* @type string $protoDescriptors
* Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements in
* 'extra_statements' above.
* Contains a protobuf-serialized
* [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto).
* To generate it, [install](https://grpc.io/docs/protoc-installation/) and
* run `protoc` with --include_imports and --descriptor_set_out. For example,
* to generate for moon/shot/app.proto, run
* ```
* $protoc --proto_path=/app_path --proto_path=/lib_path \
* --include_imports \
* --descriptor_set_out=descriptors.data \
* moon/shot/app.proto
* ```
* For more details, see protobuffer [self
* description](https://developers.google.com/protocol-buffers/docs/techniques#self-description).
* @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
Expand Down Expand Up @@ -861,6 +877,10 @@ public function createDatabase(
$request->setDatabaseDialect($optionalArgs['databaseDialect']);
}

if (isset($optionalArgs['protoDescriptors'])) {
$request->setProtoDescriptors($optionalArgs['protoDescriptors']);
}

$requestParams = new RequestParamsHeaderDescriptor(
$requestParamHeaders
);
Expand Down Expand Up @@ -2256,6 +2276,21 @@ public function updateDatabase(
* underscore. If the named operation already exists,
* [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] returns
* `ALREADY_EXISTS`.
* @type string $protoDescriptors
* Optional. Proto descriptors used by CREATE/ALTER PROTO BUNDLE statements.
* Contains a protobuf-serialized
* [google.protobuf.FileDescriptorSet](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/descriptor.proto).
* To generate it, [install](https://grpc.io/docs/protoc-installation/) and
* run `protoc` with --include_imports and --descriptor_set_out. For example,
* to generate for moon/shot/app.proto, run
* ```
* $protoc --proto_path=/app_path --proto_path=/lib_path \
* --include_imports \
* --descriptor_set_out=descriptors.data \
* moon/shot/app.proto
* ```
* For more details, see protobuffer [self
* description](https://developers.google.com/protocol-buffers/docs/techniques#self-description).
* @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
Expand All @@ -2280,6 +2315,10 @@ public function updateDatabaseDdl(
$request->setOperationId($optionalArgs['operationId']);
}

if (isset($optionalArgs['protoDescriptors'])) {
$request->setProtoDescriptors($optionalArgs['protoDescriptors']);
}

$requestParams = new RequestParamsHeaderDescriptor(
$requestParamHeaders
);
Expand Down
50 changes: 50 additions & 0 deletions Spanner/src/Admin/Database/V1/GetDatabaseDdlResponse.php

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

86 changes: 86 additions & 0 deletions Spanner/src/Admin/Database/V1/UpdateDatabaseDdlRequest.php

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

Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,9 @@ public function getDatabaseDdlTest()
]);
$this->assertTrue($transport->isExhausted());
// Mock response
$protoDescriptors = '13';
$expectedResponse = new GetDatabaseDdlResponse();
$expectedResponse->setProtoDescriptors($protoDescriptors);
$transport->addResponse($expectedResponse);
// Mock request
$formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,9 @@ public function getDatabaseDdlTest()
]);
$this->assertTrue($transport->isExhausted());
// Mock response
$protoDescriptors = '13';
$expectedResponse = new GetDatabaseDdlResponse();
$expectedResponse->setProtoDescriptors($protoDescriptors);
$transport->addResponse($expectedResponse);
// Mock request
$formattedDatabase = $gapicClient->databaseName('[PROJECT]', '[INSTANCE]', '[DATABASE]');
Expand Down
Loading