diff --git a/src/Core/ServiceBuilder.php b/src/Core/ServiceBuilder.php index 653e055a0e99..83a8a56aa944 100644 --- a/src/Core/ServiceBuilder.php +++ b/src/Core/ServiceBuilder.php @@ -20,8 +20,9 @@ use Google\Auth\HttpHandler\HttpHandlerFactory; use Google\Cloud\BigQuery\BigQueryClient; use Google\Cloud\Datastore\DatastoreClient; -use Google\Cloud\Logging\LoggingClient; +use Google\Cloud\Firestore\FirestoreClient; use Google\Cloud\Language\LanguageClient; +use Google\Cloud\Logging\LoggingClient; use Google\Cloud\PubSub\PubSubClient; use Google\Cloud\Spanner\SpannerClient; use Google\Cloud\Speech\SpeechClient; @@ -145,6 +146,30 @@ public function datastore(array $config = []) return $this->createClient(DatastoreClient::class, 'datastore', $config); } + /** + * Cloud Firestore is a flexible, scalable, realtime database for mobile, + * web, and server development. Find more information at the + * [Google Cloud firestore docs](https://cloud.google.com/firestore/docs/). + * + * Example: + * ``` + * $firestore = $cloud->firestore(); + * ``` + * + * @param array $config [optional] { + * Configuration options. See + * {@see Google\Cloud\Core\ServiceBuilder::__construct()} for the other available options. + * + * @type bool $returnInt64AsObject If true, 64 bit integers will be + * returned as a {@see Google\Cloud\Core\Int64} object for 32 bit + * platform compatibility. **Defaults to** false. + * @return FirestoreClient + */ + public function firestore(array $config = []) + { + return $this->createClient(FirestoreClient::class, 'firestore', $config); + } + /** * Google Stackdriver Logging allows you to store, search, analyze, monitor, * and alert on log data and events from Google Cloud Platform and Amazon diff --git a/tests/snippets/Core/ServiceBuilderTest.php b/tests/snippets/Core/ServiceBuilderTest.php index 0ff668203be3..461eb632f3ce 100644 --- a/tests/snippets/Core/ServiceBuilderTest.php +++ b/tests/snippets/Core/ServiceBuilderTest.php @@ -21,8 +21,9 @@ use Google\Cloud\Core\ServiceBuilder; use Google\Cloud\Datastore\DatastoreClient; use Google\Cloud\Dev\Snippet\SnippetTestCase; -use Google\Cloud\Logging\LoggingClient; +use Google\Cloud\Firestore\FirestoreClient; use Google\Cloud\Language\LanguageClient; +use Google\Cloud\Logging\LoggingClient; use Google\Cloud\PubSub\PubSubClient; use Google\Cloud\Spanner\SpannerClient; use Google\Cloud\Speech\SpeechClient; @@ -54,6 +55,7 @@ public function serviceBuilderMethods() return [ ['bigQuery', BigQueryClient::class, 'bigQuery'], ['datastore', DatastoreClient::class, 'datastore'], + ['firestore', FirestoreClient::class, 'firestore', true], ['logging', LoggingClient::class, 'logging'], ['language', LanguageClient::class, 'language'], ['pubsub', PubSubClient::class, 'pubsub'], diff --git a/tests/unit/Core/ServiceBuilderTest.php b/tests/unit/Core/ServiceBuilderTest.php index 14b665c6751c..9e37e544df5f 100644 --- a/tests/unit/Core/ServiceBuilderTest.php +++ b/tests/unit/Core/ServiceBuilderTest.php @@ -17,11 +17,12 @@ namespace Google\Cloud\Tests\Unit; use Google\Cloud\BigQuery\BigQueryClient; +use Google\Cloud\Core\ServiceBuilder; use Google\Cloud\Datastore\DatastoreClient; +use Google\Cloud\Firestore\FirestoreClient; use Google\Cloud\Language\LanguageClient; use Google\Cloud\Logging\LoggingClient; use Google\Cloud\PubSub\PubSubClient; -use Google\Cloud\Core\ServiceBuilder; use Google\Cloud\Spanner\SpannerClient; use Google\Cloud\Speech\SpeechClient; use Google\Cloud\Storage\StorageClient; @@ -80,6 +81,11 @@ public function serviceProvider() ], [ 'datastore', DatastoreClient::class + ], [ + 'firestore', + FirestoreClient::class, + [], + [$this, 'checkAndSkipGrpcTests'] ], [ 'logging', LoggingClient::class