Skip to content

Commit 95b34bb

Browse files
feat: Datastore V2 (#8609)
1 parent 849a258 commit 95b34bb

File tree

124 files changed

+2795
-8326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+2795
-8326
lines changed

Core/src/ApiHelperTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ protected function constructGapic($gapicName, array $config)
243243
*/
244244
private function convertDataToProtos(array $input, array $map): array
245245
{
246+
if (!isset($this->serializer)) {
247+
throw new \LogicException('Serializer must be set to use this function');
248+
}
246249
foreach ($map as $key => $className) {
247250
if (isset($input[$key])) {
248251
$input[$key] = $this->serializer->decodeMessage(new $className(), $input[$key]);

Core/tests/Snippet/ServiceBuilderTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public function serviceBuilderMethods()
5151
{
5252
return [
5353
['bigQuery', BigQueryClient::class, 'bigQuery'],
54-
['datastore', DatastoreClient::class, 'datastore'],
5554
['firestore', FirestoreClient::class, 'firestore', true],
5655
['logging', LoggingClient::class, 'logging'],
5756
['language', LanguageClient::class, 'language'],

Core/tests/Unit/ServiceBuilderTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Google\Cloud\Core\ServiceBuilder;
2121
use Google\Cloud\Core\Testing\CheckForClassTrait;
2222
use Google\Cloud\Core\Testing\GrpcTestTrait;
23-
use Google\Cloud\Datastore\DatastoreClient;
2423
use Google\Cloud\Firestore\FirestoreClient;
2524
use Google\Cloud\Language\LanguageClient;
2625
use Google\Cloud\Logging\LoggingClient;
@@ -147,10 +146,7 @@ public function serviceProvider()
147146
[
148147
'bigQuery',
149148
BigQueryClient::class
150-
], [
151-
'datastore',
152-
DatastoreClient::class
153-
], [
149+
],[
154150
'firestore',
155151
FirestoreClient::class,
156152
[],

Datastore/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"minimum-stability": "stable",
66
"require": {
77
"php": "^8.1",
8-
"google/cloud-core": "^1.63.0",
8+
"google/cloud-core": "^1.66",
99
"google/gax": "^1.38.0"
1010
},
1111
"require-dev": {
@@ -14,7 +14,8 @@
1414
"squizlabs/php_codesniffer": "2.*",
1515
"phpdocumentor/reflection": "^5.3.3||^6.0",
1616
"phpdocumentor/reflection-docblock": "^5.3",
17-
"erusev/parsedown": "^1.6"
17+
"erusev/parsedown": "^1.6",
18+
"dg/bypass-finals": "^1.9"
1819
},
1920
"extra": {
2021
"component": {

Datastore/owlbot.py

Lines changed: 19 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 Google LLC
1+
# Copyright 2024 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -30,65 +30,27 @@
3030
# Added so that we can pass copy_excludes in the owlbot_main() call
3131
_tracked_paths.add(src)
3232

33-
php.owlbot_main(
34-
src=src,
35-
dest=dest,
36-
copy_excludes=[
37-
src / "*/proto/src/Google/Cloud/Datastore/V1/TransactionOptions/ReadOnly.php"
38-
]
39-
)
33+
php.owlbot_main(src=src, dest=dest)
4034

41-
42-
# Fix class references in gapic samples
43-
for version in ['V1']:
44-
pathExpr = 'src/' + version + '/Gapic/DatastoreGapicClient.php'
45-
46-
types = {
47-
'= new DatastoreClient': r'= new Google\\Cloud\\Datastore\\' + version + r'\\DatastoreClient',
48-
'= Mode::': r'= Google\\Cloud\\Datastore\\' + version + r'\\CommitRequest\\Mode::',
49-
'new PartitionId': r'new Google\\Cloud\\Datastore\\' + version + r'\\PartitionId',
50-
}
51-
52-
for search, replace in types.items():
53-
s.replace(
54-
pathExpr,
55-
search,
56-
replace)
57-
58-
# remove ReadOnly class_alias code
35+
# remove class_alias code
5936
s.replace(
60-
"src/V*/**/PBReadOnly.php",
61-
r"^// Adding a class alias for backwards compatibility with the \"readonly\" keyword.$"
37+
"src/V*/**/*.php",
38+
r"^// Adding a class alias for backwards compatibility with the previous class name.$"
6239
+ "\n"
63-
+ r"^class_alias\(PBReadOnly::class, __NAMESPACE__ . '\\ReadOnly'\);$"
40+
+ r"^class_alias\(.*\);$"
6441
+ "\n",
6542
'')
6643

67-
### [START] protoc backwards compatibility fixes
68-
69-
# roll back to private properties.
70-
s.replace(
71-
"src/**/V*/**/*.php",
72-
r"Generated from protobuf field ([^\n]{0,})\n\s{5}\*/\n\s{4}protected \$",
73-
r"""Generated from protobuf field \1
74-
*/
75-
private $""")
76-
77-
# Replace "Unwrapped" with "Value" for method names.
78-
s.replace(
79-
"src/**/V*/**/*.php",
80-
r"public function ([s|g]\w{3,})Unwrapped",
81-
r"public function \1Value"
82-
)
83-
84-
### [END] protoc backwards compatibility fixes
85-
86-
# fix relative cloud.google.com links
87-
s.replace(
88-
"src/**/V*/**/*.php",
89-
r"(.{0,})\]\((/.{0,})\)",
90-
r"\1](https://cloud.google.com\2)"
91-
)
92-
93-
# Address breaking changes
94-
subprocess.run('git show 8ada2c97c72ffabf5c3031021378874f8caa8804 | git apply', shell=True)
44+
# format generated clients
45+
subprocess.run([
46+
'npm',
47+
'exec',
48+
'--yes',
49+
'--package=@prettier/plugin-php@^0.19',
50+
'--',
51+
'prettier',
52+
'**/Client/*',
53+
'--write',
54+
'--parser=php',
55+
'--single-quote',
56+
'--print-width=120'])

Datastore/phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/Unit/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
33
<coverage>
44
<include>
55
<directory suffix=".php">src</directory>

Datastore/src/Connection/ConnectionInterface.php

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)