Skip to content

Commit a0bd8d0

Browse files
authored
Firestore: pick up fixes to GAPIC generator. (googleapis#6523)
* Firestore: pick up fixes to GAPIC generator. Closes googleapis#6497. Includes changes to generated tests. Includes fixes from these PRs: - googleapis/gapic-generator#2407 - googleapis/gapic-generator#2396 * Fix overlong lines introduced in PR googleapis#6481.
1 parent 88b6ecc commit a0bd8d0

7 files changed

Lines changed: 188 additions & 87 deletions

File tree

‎firestore/google/cloud/firestore_v1beta1/gapic/enums.py‎

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,34 @@
1818
import enum
1919

2020

21-
class NullValue(enum.IntEnum):
22-
"""
23-
``NullValue`` is a singleton enumeration to represent the null value for
24-
the ``Value`` type union.
25-
26-
The JSON representation for ``NullValue`` is JSON ``null``.
21+
class TargetChange(object):
22+
class TargetChangeType(enum.IntEnum):
23+
"""
24+
The type of change.
2725
28-
Attributes:
29-
NULL_VALUE (int): Null value.
30-
"""
31-
NULL_VALUE = 0
26+
Attributes:
27+
NO_CHANGE (int): No change has occurred. Used only to send an updated ``resume_token``.
28+
ADD (int): The targets have been added.
29+
REMOVE (int): The targets have been removed.
30+
CURRENT (int): The targets reflect all changes committed before the targets were added
31+
to the stream.
3232
33+
This will be sent after or with a ``read_time`` that is greater than or
34+
equal to the time at which the targets were added.
3335
34-
class DocumentTransform(object):
35-
class FieldTransform(object):
36-
class ServerValue(enum.IntEnum):
37-
"""
38-
A value that is calculated by the server.
36+
Listeners can wait for this change if read-after-write semantics are
37+
desired.
38+
RESET (int): The targets have been reset, and a new initial state for the targets
39+
will be returned in subsequent changes.
3940
40-
Attributes:
41-
SERVER_VALUE_UNSPECIFIED (int): Unspecified. This value must not be used.
42-
REQUEST_TIME (int): The time at which the server processed the request, with millisecond
43-
precision.
44-
"""
45-
SERVER_VALUE_UNSPECIFIED = 0
46-
REQUEST_TIME = 1
41+
After the initial state is complete, ``CURRENT`` will be returned even
42+
if the target was previously indicated to be ``CURRENT``.
43+
"""
44+
NO_CHANGE = 0
45+
ADD = 1
46+
REMOVE = 2
47+
CURRENT = 3
48+
RESET = 4
4749

4850

4951
class StructuredQuery(object):
@@ -110,31 +112,16 @@ class Operator(enum.IntEnum):
110112
IS_NULL = 3
111113

112114

113-
class TargetChange(object):
114-
class TargetChangeType(enum.IntEnum):
115-
"""
116-
The type of change.
117-
118-
Attributes:
119-
NO_CHANGE (int): No change has occurred. Used only to send an updated ``resume_token``.
120-
ADD (int): The targets have been added.
121-
REMOVE (int): The targets have been removed.
122-
CURRENT (int): The targets reflect all changes committed before the targets were added
123-
to the stream.
124-
125-
This will be sent after or with a ``read_time`` that is greater than or
126-
equal to the time at which the targets were added.
127-
128-
Listeners can wait for this change if read-after-write semantics are
129-
desired.
130-
RESET (int): The targets have been reset, and a new initial state for the targets
131-
will be returned in subsequent changes.
115+
class DocumentTransform(object):
116+
class FieldTransform(object):
117+
class ServerValue(enum.IntEnum):
118+
"""
119+
A value that is calculated by the server.
132120
133-
After the initial state is complete, ``CURRENT`` will be returned even
134-
if the target was previously indicated to be ``CURRENT``.
135-
"""
136-
NO_CHANGE = 0
137-
ADD = 1
138-
REMOVE = 2
139-
CURRENT = 3
140-
RESET = 4
121+
Attributes:
122+
SERVER_VALUE_UNSPECIFIED (int): Unspecified. This value must not be used.
123+
REQUEST_TIME (int): The time at which the server processed the request, with millisecond
124+
precision.
125+
"""
126+
SERVER_VALUE_UNSPECIFIED = 0
127+
REQUEST_TIME = 1

‎firestore/google/cloud/firestore_v1beta1/gapic/firestore_client.py‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def __init__(self,
137137
transport=None,
138138
channel=None,
139139
credentials=None,
140-
client_config=firestore_client_config.config,
140+
client_config=None,
141141
client_info=None):
142142
"""Constructor.
143143
@@ -170,13 +170,20 @@ def __init__(self,
170170
your own client library.
171171
"""
172172
# Raise deprecation warnings for things we want to go away.
173-
if client_config:
174-
warnings.warn('The `client_config` argument is deprecated.',
175-
PendingDeprecationWarning)
173+
if client_config is not None:
174+
warnings.warn(
175+
'The `client_config` argument is deprecated.',
176+
PendingDeprecationWarning,
177+
stacklevel=2)
178+
else:
179+
client_config = firestore_client_config.config
180+
176181
if channel:
177182
warnings.warn(
178183
'The `channel` argument is deprecated; use '
179-
'`transport` instead.', PendingDeprecationWarning)
184+
'`transport` instead.',
185+
PendingDeprecationWarning,
186+
stacklevel=2)
180187

181188
# Instantiate the transport.
182189
# The transport is responsible for handling serialization and

‎firestore/google/cloud/firestore_v1beta1/gapic/transports/firestore_grpc_transport.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def __init__(self,
6565
credentials=credentials,
6666
)
6767

68+
self._channel = channel
69+
6870
# gRPC uses objects called "stubs" that are bound to the
6971
# channel and provide a basic method for each RPC.
7072
self._stubs = {
@@ -94,6 +96,15 @@ def create_channel(cls,
9496
scopes=cls._OAUTH_SCOPES,
9597
)
9698

99+
@property
100+
def channel(self):
101+
"""The gRPC channel used by the transport.
102+
103+
Returns:
104+
grpc.Channel: A gRPC channel object.
105+
"""
106+
return self._channel
107+
97108
@property
98109
def get_document(self):
99110
"""Return the gRPC stub for {$apiMethod.name}.

‎firestore/google/cloud/firestore_v1beta1/query.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@
3333
from google.cloud.firestore_v1beta1.watch import Watch
3434

3535
_EQ_OP = '=='
36+
_operator_enum = enums.StructuredQuery.FieldFilter.Operator
3637
_COMPARISON_OPERATORS = {
37-
'<': enums.StructuredQuery.FieldFilter.Operator.LESS_THAN,
38-
'<=': enums.StructuredQuery.FieldFilter.Operator.LESS_THAN_OR_EQUAL,
39-
_EQ_OP: enums.StructuredQuery.FieldFilter.Operator.EQUAL,
40-
'>=': enums.StructuredQuery.FieldFilter.Operator.GREATER_THAN_OR_EQUAL,
41-
'>': enums.StructuredQuery.FieldFilter.Operator.GREATER_THAN,
42-
'array_contains': enums.StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS,
38+
'<': _operator_enum.LESS_THAN,
39+
'<=': _operator_enum.LESS_THAN_OR_EQUAL,
40+
_EQ_OP: _operator_enum.EQUAL,
41+
'>=': _operator_enum.GREATER_THAN_OR_EQUAL,
42+
'>': _operator_enum.GREATER_THAN,
43+
'array_contains': _operator_enum.ARRAY_CONTAINS,
4344
}
4445
_BAD_OP_STRING = 'Operator string {!r} is invalid. Valid choices are: {}.'
4546
_BAD_OP_NAN_NULL = (

‎firestore/synth.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,16 @@
3030

3131
s.move(library / 'google/cloud/firestore_v1beta1/proto')
3232
s.move(library / 'google/cloud/firestore_v1beta1/gapic')
33+
s.move(library / 'tests/unit/gapic/v1beta1')
34+
35+
s.replace(
36+
'tests/unit/gapic/v1beta1/test_firestore_client_v1beta1.py',
37+
'from google.cloud import firestore_v1beta1',
38+
'from google.cloud.firestore_v1beta1.gapic import firestore_client',
39+
)
40+
41+
s.replace(
42+
'tests/unit/gapic/v1beta1/test_firestore_client_v1beta1.py',
43+
'client = firestore_v1beta1.FirestoreClient',
44+
'client = firestore_client.FirestoreClient',
45+
)

0 commit comments

Comments
 (0)