Skip to content

Commit

Permalink
Bigtable: pick up fixes to GAPIC generator. (#6630)
Browse files Browse the repository at this point in the history
Includes fixes from these PRs:

- googleapis/gapic-generator#2407
- googleapis/gapic-generator#2396

Includes changes to generated tests.

Closes #6492.
  • Loading branch information
tseaver authored Nov 21, 2018
1 parent 99d03c6 commit f550aba
Show file tree
Hide file tree
Showing 10 changed files with 440 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def __init__(self,
transport=None,
channel=None,
credentials=None,
client_config=bigtable_instance_admin_client_config.config,
client_config=None,
client_info=None):
"""Constructor.
Expand Down Expand Up @@ -165,13 +165,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 = bigtable_instance_admin_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 @@ -133,7 +133,7 @@ def __init__(self,
transport=None,
channel=None,
credentials=None,
client_config=bigtable_table_admin_client_config.config,
client_config=None,
client_info=None):
"""Constructor.
Expand Down Expand Up @@ -166,13 +166,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 = bigtable_table_admin_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
128 changes: 64 additions & 64 deletions bigtable/google/cloud/bigtable_admin_v2/gapic/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,70 @@ class StorageType(enum.IntEnum):
HDD = 2


class Instance(object):
class State(enum.IntEnum):
"""
Possible states of an instance.
Attributes:
STATE_NOT_KNOWN (int): The state of the instance could not be determined.
READY (int): The instance has been successfully created and can serve requests
to its tables.
CREATING (int): The instance is currently being created, and may be destroyed
if the creation process encounters an error.
"""
STATE_NOT_KNOWN = 0
READY = 1
CREATING = 2

class Type(enum.IntEnum):
"""
The type of the instance.
Attributes:
TYPE_UNSPECIFIED (int): The type of the instance is unspecified. If set when creating an
instance, a ``PRODUCTION`` instance will be created. If set when
updating an instance, the type will be left unchanged.
PRODUCTION (int): An instance meant for production use. ``serve_nodes`` must be set on the
cluster.
DEVELOPMENT (int): The instance is meant for development and testing purposes only; it has
no performance or uptime guarantees and is not covered by SLA. After a
development instance is created, it can be upgraded by updating the
instance to type ``PRODUCTION``. An instance created as a production
instance cannot be changed to a development instance. When creating a
development instance, ``serve_nodes`` on the cluster must not be set.
"""
TYPE_UNSPECIFIED = 0
PRODUCTION = 1
DEVELOPMENT = 2


class Cluster(object):
class State(enum.IntEnum):
"""
Possible states of a cluster.
Attributes:
STATE_NOT_KNOWN (int): The state of the cluster could not be determined.
READY (int): The cluster has been successfully created and is ready to serve requests.
CREATING (int): The cluster is currently being created, and may be destroyed
if the creation process encounters an error.
A cluster may not be able to serve requests while being created.
RESIZING (int): The cluster is currently being resized, and may revert to its previous
node count if the process encounters an error.
A cluster is still capable of serving requests while being resized,
but may exhibit performance as if its number of allocated nodes is
between the starting and requested states.
DISABLED (int): The cluster has no backing nodes. The data (tables) still
exist, but no operations can be performed on the cluster.
"""
STATE_NOT_KNOWN = 0
READY = 1
CREATING = 2
RESIZING = 3
DISABLED = 4


class Table(object):
class TimestampGranularity(enum.IntEnum):
"""
Expand Down Expand Up @@ -104,67 +168,3 @@ class State(enum.IntEnum):
STATE_NOT_KNOWN = 0
READY = 1
CREATING = 2


class Instance(object):
class State(enum.IntEnum):
"""
Possible states of an instance.
Attributes:
STATE_NOT_KNOWN (int): The state of the instance could not be determined.
READY (int): The instance has been successfully created and can serve requests
to its tables.
CREATING (int): The instance is currently being created, and may be destroyed
if the creation process encounters an error.
"""
STATE_NOT_KNOWN = 0
READY = 1
CREATING = 2

class Type(enum.IntEnum):
"""
The type of the instance.
Attributes:
TYPE_UNSPECIFIED (int): The type of the instance is unspecified. If set when creating an
instance, a ``PRODUCTION`` instance will be created. If set when
updating an instance, the type will be left unchanged.
PRODUCTION (int): An instance meant for production use. ``serve_nodes`` must be set on the
cluster.
DEVELOPMENT (int): The instance is meant for development and testing purposes only; it has
no performance or uptime guarantees and is not covered by SLA. After a
development instance is created, it can be upgraded by updating the
instance to type ``PRODUCTION``. An instance created as a production
instance cannot be changed to a development instance. When creating a
development instance, ``serve_nodes`` on the cluster must not be set.
"""
TYPE_UNSPECIFIED = 0
PRODUCTION = 1
DEVELOPMENT = 2


class Cluster(object):
class State(enum.IntEnum):
"""
Possible states of a cluster.
Attributes:
STATE_NOT_KNOWN (int): The state of the cluster could not be determined.
READY (int): The cluster has been successfully created and is ready to serve requests.
CREATING (int): The cluster is currently being created, and may be destroyed
if the creation process encounters an error.
A cluster may not be able to serve requests while being created.
RESIZING (int): The cluster is currently being resized, and may revert to its previous
node count if the process encounters an error.
A cluster is still capable of serving requests while being resized,
but may exhibit performance as if its number of allocated nodes is
between the starting and requested states.
DISABLED (int): The cluster has no backing nodes. The data (tables) still
exist, but no operations can be performed on the cluster.
"""
STATE_NOT_KNOWN = 0
READY = 1
CREATING = 2
RESIZING = 3
DISABLED = 4
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,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 @@ -110,6 +112,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 create_instance(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,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 @@ -113,6 +115,15 @@ def create_channel(cls,
}.items(),
)

@property
def channel(self):
"""The gRPC channel used by the transport.
Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def create_table(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down
17 changes: 12 additions & 5 deletions bigtable/google/cloud/bigtable_v2/gapic/bigtable_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self,
transport=None,
channel=None,
credentials=None,
client_config=bigtable_client_config.config,
client_config=None,
client_info=None):
"""Constructor.
Expand Down Expand Up @@ -115,13 +115,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 = bigtable_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 @@ -69,6 +69,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 @@ -102,6 +104,15 @@ def create_channel(cls,
}.items(),
)

@property
def channel(self):
"""The gRPC channel used by the transport.
Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def read_rows(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down
Loading

0 comments on commit f550aba

Please sign in to comment.