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

Firestore: pick up fixes to GAPIC generator. #6523

Merged
merged 2 commits into from
Nov 15, 2018
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
85 changes: 36 additions & 49 deletions firestore/google/cloud/firestore_v1beta1/gapic/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,34 @@
import enum


class NullValue(enum.IntEnum):
"""
``NullValue`` is a singleton enumeration to represent the null value for
the ``Value`` type union.

The JSON representation for ``NullValue`` is JSON ``null``.
class TargetChange(object):
class TargetChangeType(enum.IntEnum):
"""
The type of change.

Attributes:
NULL_VALUE (int): Null value.
"""
NULL_VALUE = 0
Attributes:
NO_CHANGE (int): No change has occurred. Used only to send an updated ``resume_token``.
ADD (int): The targets have been added.
REMOVE (int): The targets have been removed.
CURRENT (int): The targets reflect all changes committed before the targets were added
to the stream.

This will be sent after or with a ``read_time`` that is greater than or
equal to the time at which the targets were added.

class DocumentTransform(object):
class FieldTransform(object):
class ServerValue(enum.IntEnum):
"""
A value that is calculated by the server.
Listeners can wait for this change if read-after-write semantics are
desired.
RESET (int): The targets have been reset, and a new initial state for the targets
will be returned in subsequent changes.

Attributes:
SERVER_VALUE_UNSPECIFIED (int): Unspecified. This value must not be used.
REQUEST_TIME (int): The time at which the server processed the request, with millisecond
precision.
"""
SERVER_VALUE_UNSPECIFIED = 0
REQUEST_TIME = 1
After the initial state is complete, ``CURRENT`` will be returned even
if the target was previously indicated to be ``CURRENT``.
"""
NO_CHANGE = 0
ADD = 1
REMOVE = 2
CURRENT = 3
RESET = 4


class StructuredQuery(object):
Expand Down Expand Up @@ -110,31 +112,16 @@ class Operator(enum.IntEnum):
IS_NULL = 3


class TargetChange(object):
class TargetChangeType(enum.IntEnum):
"""
The type of change.

Attributes:
NO_CHANGE (int): No change has occurred. Used only to send an updated ``resume_token``.
ADD (int): The targets have been added.
REMOVE (int): The targets have been removed.
CURRENT (int): The targets reflect all changes committed before the targets were added
to the stream.

This will be sent after or with a ``read_time`` that is greater than or
equal to the time at which the targets were added.

Listeners can wait for this change if read-after-write semantics are
desired.
RESET (int): The targets have been reset, and a new initial state for the targets
will be returned in subsequent changes.
class DocumentTransform(object):
class FieldTransform(object):
class ServerValue(enum.IntEnum):
"""
A value that is calculated by the server.

After the initial state is complete, ``CURRENT`` will be returned even
if the target was previously indicated to be ``CURRENT``.
"""
NO_CHANGE = 0
ADD = 1
REMOVE = 2
CURRENT = 3
RESET = 4
Attributes:
SERVER_VALUE_UNSPECIFIED (int): Unspecified. This value must not be used.
REQUEST_TIME (int): The time at which the server processed the request, with millisecond
precision.
"""
SERVER_VALUE_UNSPECIFIED = 0
REQUEST_TIME = 1
17 changes: 12 additions & 5 deletions firestore/google/cloud/firestore_v1beta1/gapic/firestore_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def __init__(self,
transport=None,
channel=None,
credentials=None,
client_config=firestore_client_config.config,
client_config=None,
client_info=None):
"""Constructor.

Expand Down Expand Up @@ -170,13 +170,20 @@ def __init__(self,
your own client library.
"""
# Raise deprecation warnings for things we want to go away.
if client_config:
warnings.warn('The `client_config` argument is deprecated.',
PendingDeprecationWarning)
if client_config is not None:
warnings.warn(
'The `client_config` argument is deprecated.',
PendingDeprecationWarning,
stacklevel=2)
else:
client_config = firestore_client_config.config

if channel:
warnings.warn(
'The `channel` argument is deprecated; use '
'`transport` instead.', PendingDeprecationWarning)
'`transport` instead.',
PendingDeprecationWarning,
stacklevel=2)

# Instantiate the transport.
# The transport is responsible for handling serialization and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def __init__(self,
credentials=credentials,
)

self._channel = channel

# gRPC uses objects called "stubs" that are bound to the
# channel and provide a basic method for each RPC.
self._stubs = {
Expand Down Expand Up @@ -94,6 +96,15 @@ def create_channel(cls,
scopes=cls._OAUTH_SCOPES,
)

@property
def channel(self):
"""The gRPC channel used by the transport.

Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def get_document(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down
13 changes: 7 additions & 6 deletions firestore/google/cloud/firestore_v1beta1/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@
from google.cloud.firestore_v1beta1.watch import Watch

_EQ_OP = '=='
_operator_enum = enums.StructuredQuery.FieldFilter.Operator
_COMPARISON_OPERATORS = {
'<': enums.StructuredQuery.FieldFilter.Operator.LESS_THAN,
'<=': enums.StructuredQuery.FieldFilter.Operator.LESS_THAN_OR_EQUAL,
_EQ_OP: enums.StructuredQuery.FieldFilter.Operator.EQUAL,
'>=': enums.StructuredQuery.FieldFilter.Operator.GREATER_THAN_OR_EQUAL,
'>': enums.StructuredQuery.FieldFilter.Operator.GREATER_THAN,
'array_contains': enums.StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS,
'<': _operator_enum.LESS_THAN,
'<=': _operator_enum.LESS_THAN_OR_EQUAL,
_EQ_OP: _operator_enum.EQUAL,
'>=': _operator_enum.GREATER_THAN_OR_EQUAL,
'>': _operator_enum.GREATER_THAN,
'array_contains': _operator_enum.ARRAY_CONTAINS,
}
_BAD_OP_STRING = 'Operator string {!r} is invalid. Valid choices are: {}.'
_BAD_OP_NAN_NULL = (
Expand Down
13 changes: 13 additions & 0 deletions firestore/synth.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,16 @@

s.move(library / 'google/cloud/firestore_v1beta1/proto')
s.move(library / 'google/cloud/firestore_v1beta1/gapic')
s.move(library / 'tests/unit/gapic/v1beta1')

s.replace(
'tests/unit/gapic/v1beta1/test_firestore_client_v1beta1.py',
'from google.cloud import firestore_v1beta1',
'from google.cloud.firestore_v1beta1.gapic import firestore_client',
)

s.replace(
'tests/unit/gapic/v1beta1/test_firestore_client_v1beta1.py',
'client = firestore_v1beta1.FirestoreClient',
'client = firestore_client.FirestoreClient',
)
Loading