Skip to content

Commit

Permalink
Firestore: Add v1 API version. (#7494)
Browse files Browse the repository at this point in the history
* Update synth to generate 'v1' GAPIC libs.

* Use explicitly-versioned module in examples.

* Use versioned file for test protos in 'v1beta1' test runner.

* Fork manual 'v1beta1' code -> 'v1' and bash to fit.

* Use 'v1' rather than 'v1beta1' in unversioned wrapper.

* Re-run synth to pick up proto changes.

* Accomodate / apply changes for Bidi RPC metadata.
  • Loading branch information
tseaver authored and crwilcox committed Mar 28, 2019
1 parent 800a6bb commit 8942439
Show file tree
Hide file tree
Showing 295 changed files with 38,401 additions and 450 deletions.
37 changes: 37 additions & 0 deletions firestore/Makefile_v1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This makefile builds the protos needed for cross-language Firestore tests.

# Assume protoc is on the path. The proto compiler must be one that
# supports proto3 syntax.
PROTOC = protoc

# Dependent repos.
REPO_DIR=$(HOME)/git-repos
PROTOBUF_REPO = $(REPO_DIR)/protobuf
GOOGLEAPIS_REPO = $(REPO_DIR)/googleapis
TESTS_REPO = $(REPO_DIR)/gcp/google-cloud-common

TMPDIR = /tmp/python-fs-proto
TMPDIR_FS = $(TMPDIR)/google/cloud/firestore_v1/proto

.PHONY: sync-protos gen-protos

gen-protos: sync-protos tweak-protos
# TODO(jba): Put the generated proto somewhere more suitable.
$(PROTOC) --python_out=google/cloud/firestore_v1/proto \
-I $(TMPDIR) \
-I $(PROTOBUF_REPO)/src \
-I $(GOOGLEAPIS_REPO) \
$(TMPDIR)/test_v1.proto

tweak-protos:
mkdir -p $(TMPDIR_FS)
cp $(GOOGLEAPIS_REPO)/google/firestore/v1/*.proto $(TMPDIR_FS)
sed -i -e 's@google/firestore/v1@google/cloud/firestore_v1/proto@' $(TMPDIR_FS)/*.proto
cp $(TESTS_REPO)/testing/firestore/proto/test_v1.proto $(TMPDIR)
sed -i -e 's@package tests@package tests.v1@' $(TMPDIR)/test_v1.proto
sed -i -e 's@google/firestore/v1@google/cloud/firestore_v1/proto@' $(TMPDIR)/test_v1.proto

sync-protos:
cd $(PROTOBUF_REPO); git pull
cd $(GOOGLEAPIS_REPO); git pull
#cd $(TESTS_REPO); git pull
17 changes: 9 additions & 8 deletions firestore/Makefile → firestore/Makefile_v1beta1
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
PROTOC = protoc

# Dependent repos.
PROTOBUF_REPO = $(HOME)/git-repos/protobuf
GOOGLEAPIS_REPO = $(HOME)/git-repos/googleapis

TESTS_REPO = $(HOME)/git-repos/gcp/google-cloud-common
REPO_DIR = $(HOME)/git-repos
PROTOBUF_REPO = $(REPO_DIR)/protobuf
GOOGLEAPIS_REPO = $(REPO_DIR)/googleapis
TESTS_REPO = $(REPO_DIR)/gcp/google-cloud-common

TMPDIR = /tmp/python-fs-proto
TMPDIR_FS = $(TMPDIR)/google/cloud/firestore_v1beta1/proto
Expand All @@ -21,16 +21,17 @@ gen-protos: sync-protos tweak-protos
-I $(TMPDIR) \
-I $(PROTOBUF_REPO)/src \
-I $(GOOGLEAPIS_REPO) \
$(TMPDIR)/*.proto
$(TMPDIR)/test_v1beta1.proto

tweak-protos:
mkdir -p $(TMPDIR_FS)
cp $(GOOGLEAPIS_REPO)/google/firestore/v1beta1/*.proto $(TMPDIR_FS)
sed -i -e 's@google/firestore/v1beta1@google/cloud/firestore_v1beta1/proto@' $(TMPDIR_FS)/*.proto
cp $(TESTS_REPO)/testing/firestore/proto/*.proto $(TMPDIR)
sed -i -e 's@google/firestore/v1beta1@google/cloud/firestore_v1beta1/proto@' $(TMPDIR)/*.proto
cp $(TESTS_REPO)/testing/firestore/proto/test_v1beta1.proto $(TMPDIR)
sed -i -e 's@package tests@package tests.v1beta1@' $(TMPDIR)/test_v1beta1.proto
sed -i -e 's@google/firestore/v1beta1@google/cloud/firestore_v1beta1/proto@' $(TMPDIR)/test_v1beta1.proto

sync-protos:
cd $(PROTOBUF_REPO); git pull
cd $(GOOGLEAPIS_REPO); git pull
cd $(TESTS_REPO); git pull
#cd $(TESTS_REPO); git pull
38 changes: 19 additions & 19 deletions firestore/google/cloud/firestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
"""Python idiomatic client for Google Cloud Firestore."""


from google.cloud.firestore_v1beta1 import __version__
from google.cloud.firestore_v1beta1 import Client
from google.cloud.firestore_v1beta1 import CollectionReference
from google.cloud.firestore_v1beta1 import DELETE_FIELD
from google.cloud.firestore_v1beta1 import DocumentReference
from google.cloud.firestore_v1beta1 import DocumentSnapshot
from google.cloud.firestore_v1beta1 import enums
from google.cloud.firestore_v1beta1 import ExistsOption
from google.cloud.firestore_v1beta1 import GeoPoint
from google.cloud.firestore_v1beta1 import LastUpdateOption
from google.cloud.firestore_v1beta1 import Query
from google.cloud.firestore_v1beta1 import ReadAfterWriteError
from google.cloud.firestore_v1beta1 import SERVER_TIMESTAMP
from google.cloud.firestore_v1beta1 import Transaction
from google.cloud.firestore_v1beta1 import transactional
from google.cloud.firestore_v1beta1 import types
from google.cloud.firestore_v1beta1 import Watch
from google.cloud.firestore_v1beta1 import WriteBatch
from google.cloud.firestore_v1beta1 import WriteOption
from google.cloud.firestore_v1 import __version__
from google.cloud.firestore_v1 import Client
from google.cloud.firestore_v1 import CollectionReference
from google.cloud.firestore_v1 import DELETE_FIELD
from google.cloud.firestore_v1 import DocumentReference
from google.cloud.firestore_v1 import DocumentSnapshot
from google.cloud.firestore_v1 import enums
from google.cloud.firestore_v1 import ExistsOption
from google.cloud.firestore_v1 import GeoPoint
from google.cloud.firestore_v1 import LastUpdateOption
from google.cloud.firestore_v1 import Query
from google.cloud.firestore_v1 import ReadAfterWriteError
from google.cloud.firestore_v1 import SERVER_TIMESTAMP
from google.cloud.firestore_v1 import Transaction
from google.cloud.firestore_v1 import transactional
from google.cloud.firestore_v1 import types
from google.cloud.firestore_v1 import Watch
from google.cloud.firestore_v1 import WriteBatch
from google.cloud.firestore_v1 import WriteOption


__all__ = [
Expand Down
65 changes: 65 additions & 0 deletions firestore/google/cloud/firestore_v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2019 Google LLC All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Python idiomatic client for Google Cloud Firestore."""

from pkg_resources import get_distribution

__version__ = get_distribution("google-cloud-firestore").version

from google.cloud.firestore_v1 import types
from google.cloud.firestore_v1._helpers import GeoPoint
from google.cloud.firestore_v1._helpers import ExistsOption
from google.cloud.firestore_v1._helpers import LastUpdateOption
from google.cloud.firestore_v1._helpers import ReadAfterWriteError
from google.cloud.firestore_v1._helpers import WriteOption
from google.cloud.firestore_v1.batch import WriteBatch
from google.cloud.firestore_v1.client import Client
from google.cloud.firestore_v1.collection import CollectionReference
from google.cloud.firestore_v1.transforms import ArrayRemove
from google.cloud.firestore_v1.transforms import ArrayUnion
from google.cloud.firestore_v1.transforms import DELETE_FIELD
from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP
from google.cloud.firestore_v1.document import DocumentReference
from google.cloud.firestore_v1.document import DocumentSnapshot
from google.cloud.firestore_v1.gapic import enums
from google.cloud.firestore_v1.query import Query
from google.cloud.firestore_v1.transaction import Transaction
from google.cloud.firestore_v1.transaction import transactional
from google.cloud.firestore_v1.watch import Watch


__all__ = [
"__version__",
"ArrayRemove",
"ArrayUnion",
"Client",
"CollectionReference",
"DELETE_FIELD",
"DocumentReference",
"DocumentSnapshot",
"enums",
"ExistsOption",
"GeoPoint",
"LastUpdateOption",
"Query",
"ReadAfterWriteError",
"SERVER_TIMESTAMP",
"Transaction",
"transactional",
"types",
"Watch",
"WriteBatch",
"WriteOption",
]
Loading

0 comments on commit 8942439

Please sign in to comment.