Skip to content

Commit

Permalink
Move to google.cloud.spanner_v1 (#4064)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukesneeringer committed Sep 26, 2017
1 parent cb6dbb8 commit 716c2f9
Show file tree
Hide file tree
Showing 38 changed files with 331 additions and 325 deletions.
4 changes: 1 addition & 3 deletions docs/spanner/batch-api.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Batch API
=========

.. automodule:: google.cloud.spanner.batch
.. automodule:: google.cloud.spanner_v1.batch
:members:
:show-inheritance:


2 changes: 1 addition & 1 deletion docs/spanner/client-api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Spanner Client
==============

.. automodule:: google.cloud.spanner.client
.. automodule:: google.cloud.spanner_v1.client
:members:
:show-inheritance:

2 changes: 1 addition & 1 deletion docs/spanner/database-api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Database API
============

.. automodule:: google.cloud.spanner.database
.. automodule:: google.cloud.spanner_v1.database
:members:
:show-inheritance:

Expand Down
2 changes: 1 addition & 1 deletion docs/spanner/instance-api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Instance API
============

.. automodule:: google.cloud.spanner.instance
.. automodule:: google.cloud.spanner_v1.instance
:members:
:show-inheritance:

Expand Down
2 changes: 1 addition & 1 deletion docs/spanner/keyset-api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Keyset API
==========

.. automodule:: google.cloud.spanner.keyset
.. automodule:: google.cloud.spanner_v1.keyset
:members:
:show-inheritance:

Expand Down
4 changes: 2 additions & 2 deletions docs/spanner/session-api.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Session API
===========

.. automodule:: google.cloud.spanner.session
.. automodule:: google.cloud.spanner_v1.session
:members:
:show-inheritance:


Session Pools API
=================

.. automodule:: google.cloud.spanner.pool
.. automodule:: google.cloud.spanner_v1.pool
:members:
:show-inheritance:

2 changes: 1 addition & 1 deletion docs/spanner/snapshot-api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Snapshot API
============

.. automodule:: google.cloud.spanner.snapshot
.. automodule:: google.cloud.spanner_v1.snapshot
:members:
:show-inheritance:

Expand Down
2 changes: 1 addition & 1 deletion docs/spanner/streamed-api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
StreamedResultSet API
=====================

.. automodule:: google.cloud.spanner.streamed
.. automodule:: google.cloud.spanner_v1.streamed
:members:
:show-inheritance:

Expand Down
2 changes: 1 addition & 1 deletion docs/spanner/transaction-api.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Transaction API
===============

.. automodule:: google.cloud.spanner.transaction
.. automodule:: google.cloud.spanner_v1.transaction
:members:
:show-inheritance:

Expand Down
42 changes: 42 additions & 0 deletions spanner/google/cloud/spanner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2016 Google Inc. 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.

"""Cloud Spanner API package."""

from __future__ import absolute_import

from google.cloud.spanner_v1 import __version__
from google.cloud.spanner_v1 import AbstractSessionPool
from google.cloud.spanner_v1 import BurstyPool
from google.cloud.spanner_v1 import Client
from google.cloud.spanner_v1 import enums
from google.cloud.spanner_v1 import FixedSizePool
from google.cloud.spanner_v1 import KeyRange
from google.cloud.spanner_v1 import KeySet
from google.cloud.spanner_v1 import param_types
from google.cloud.spanner_v1 import types


__all__ = (
'__version__',
'AbstractSessionPool',
'BurstyPool',
'Client',
'enums',
'FixedSizePool',
'KeyRange',
'KeySet',
'param_types',
'types',
)
60 changes: 0 additions & 60 deletions spanner/google/cloud/spanner/__init__.py

This file was deleted.

35 changes: 28 additions & 7 deletions spanner/google/cloud/spanner_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,38 @@

from __future__ import absolute_import

import pkg_resources
__version__ = pkg_resources.get_distribution('google-cloud-spanner').version

from google.cloud.spanner_v1 import param_types
from google.cloud.spanner_v1 import types
from google.cloud.spanner_v1.client import Client
from google.cloud.spanner_v1.gapic import enums
from google.cloud.spanner_v1.gapic import spanner_client
from google.cloud.spanner_v1.keyset import KeyRange
from google.cloud.spanner_v1.keyset import KeySet
from google.cloud.spanner_v1.pool import AbstractSessionPool
from google.cloud.spanner_v1.pool import BurstyPool
from google.cloud.spanner_v1.pool import FixedSizePool


class SpannerClient(spanner_client.SpannerClient):
__doc__ = spanner_client.SpannerClient.__doc__
enums = enums
__all__ = (
# google.cloud.spanner_v1
'__version__',
'param_types',
'types',

# google.cloud.spanner_v1.client
'Client',

__all__ = (
# google.cloud.spanner_v1.keyset
'KeyRange',
'KeySet',

# google.cloud.spanner_v1.pool
'AbstractSessionPool',
'BurstyPool',
'FixedSizePool',

# google.cloud.spanner_v1.gapic
'enums',
'types',
'SpannerClient', )
)
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def _parse_list_value_pbs(rows, row_type):
class _SessionWrapper(object):
"""Base class for objects wrapping a session.
:type session: :class:`~google.cloud.spanner.session.Session`
:type session: :class:`~google.cloud.spanner_v1.session.Session`
:param session: the session used to perform the commit
"""
def __init__(self, session):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@

# pylint: disable=ungrouped-imports
from google.cloud._helpers import _pb_timestamp_to_datetime
from google.cloud.spanner._helpers import _SessionWrapper
from google.cloud.spanner._helpers import _make_list_value_pbs
from google.cloud.spanner._helpers import _options_with_prefix
from google.cloud.spanner_v1._helpers import _SessionWrapper
from google.cloud.spanner_v1._helpers import _make_list_value_pbs
from google.cloud.spanner_v1._helpers import _options_with_prefix
# pylint: enable=ungrouped-imports


class _BatchBase(_SessionWrapper):
"""Accumulate mutations for transmission during :meth:`commit`.
:type session: :class:`~google.cloud.spanner.session.Session`
:type session: :class:`~google.cloud.spanner_v1.session.Session`
:param session: the session used to perform the commit
"""
def __init__(self, session):
Expand Down Expand Up @@ -111,7 +111,7 @@ def delete(self, table, keyset):
:type table: str
:param table: Name of the table to be modified.
:type keyset: :class:`~google.cloud.spanner.keyset.Keyset`
:type keyset: :class:`~google.cloud.spanner_v1.keyset.Keyset`
:param keyset: Keys/ranges identifying rows to delete.
"""
delete = Mutation.Delete(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
In the hierarchy of API concepts
* a :class:`~google.cloud.spanner.client.Client` owns an
:class:`~google.cloud.spanner.instance.Instance`
* a :class:`~google.cloud.spanner.instance.Instance` owns a
:class:`~google.cloud.spanner.database.Database`
* a :class:`~google.cloud.spanner_v1.client.Client` owns an
:class:`~google.cloud.spanner_v1.instance.Instance`
* a :class:`~google.cloud.spanner_v1.instance.Instance` owns a
:class:`~google.cloud.spanner_v1.database.Database`
"""

from google.api.core import page_iterator
Expand All @@ -35,10 +35,10 @@

from google.cloud._http import DEFAULT_USER_AGENT
from google.cloud.client import ClientWithProject
from google.cloud.spanner import __version__
from google.cloud.spanner._helpers import _options_with_prefix
from google.cloud.spanner.instance import DEFAULT_NODE_COUNT
from google.cloud.spanner.instance import Instance
from google.cloud.spanner_v1 import __version__
from google.cloud.spanner_v1._helpers import _options_with_prefix
from google.cloud.spanner_v1.instance import DEFAULT_NODE_COUNT
from google.cloud.spanner_v1.instance import Instance

SPANNER_ADMIN_SCOPE = 'https://www.googleapis.com/auth/spanner.admin'

Expand Down Expand Up @@ -197,7 +197,7 @@ def list_instance_configs(self, page_size=None, page_token=None):
:rtype: :class:`~google.api.core.page_iterator.Iterator`
:returns:
Iterator of
:class:`~google.cloud.spanner.instance.InstanceConfig`
:class:`~google.cloud.spanner_v1.instance.InstanceConfig`
resources within the client's project.
"""
if page_token is None:
Expand Down Expand Up @@ -236,7 +236,7 @@ def instance(self, instance_id,
:param node_count: (Optional) The number of nodes in the instance's
cluster; used to set up the instance's cluster.
:rtype: :class:`~google.cloud.spanner.instance.Instance`
:rtype: :class:`~google.cloud.spanner_v1.instance.Instance`
:returns: an instance owned by this client.
"""
return Instance(
Expand All @@ -260,7 +260,7 @@ def list_instances(self, filter_='', page_size=None, page_token=None):
:rtype: :class:`~google.api.core.page_iterator.Iterator`
:returns:
Iterator of :class:`~google.cloud.spanner.instance.Instance`
Iterator of :class:`~google.cloud.spanner_v1.instance.Instance`
resources within the client's project.
"""
if page_token is None:
Expand All @@ -285,7 +285,7 @@ def _item_to_instance_config(
:class:`~google.spanner.admin.instance.v1.InstanceConfig`
:param config_pb: An instance config returned from the API.
:rtype: :class:`~google.cloud.spanner.instance.InstanceConfig`
:rtype: :class:`~google.cloud.spanner_v1.instance.InstanceConfig`
:returns: The next instance config in the page.
"""
return InstanceConfig.from_pb(config_pb)
Expand All @@ -300,7 +300,7 @@ def _item_to_instance(iterator, instance_pb):
:type instance_pb: :class:`~google.spanner.admin.instance.v1.Instance`
:param instance_pb: An instance returned from the API.
:rtype: :class:`~google.cloud.spanner.instance.Instance`
:rtype: :class:`~google.cloud.spanner_v1.instance.Instance`
:returns: The next instance in the page.
"""
return Instance.from_pb(instance_pb, iterator.client)
Loading

0 comments on commit 716c2f9

Please sign in to comment.