diff --git a/README.rst b/README.rst index 9b3d9f0db64e3..3de445aba7622 100644 --- a/README.rst +++ b/README.rst @@ -20,6 +20,7 @@ The following client libraries have **GA** support: - `Google Cloud Datastore`_ (`Datastore README`_) - `Stackdriver Logging`_ (`Logging README`_) - `Google Cloud Storage`_ (`Storage README`_) +- `Google Cloud Translation`_ (`Translation README`_) **GA** (general availability) indicates that the client library for a particular service is stable, and that the code surface will not change in @@ -33,7 +34,6 @@ The following client libraries have **beta** support: - `Google BigQuery`_ (`BigQuery README`_) - `Google Cloud Vision`_ (`Vision README`_) - `Google Cloud Natural Language`_ (`Natural Language README`_) -- `Google Cloud Translation`_ (`Translation README`_) - `Google Cloud Video Intelligence`_ (`Video Intelligence README`_) **Beta** indicates that the client library for a particular service is diff --git a/translate/google/cloud/translate.py b/translate/google/cloud/translate.py new file mode 100644 index 0000000000000..9a24ceebcd10f --- /dev/null +++ b/translate/google/cloud/translate.py @@ -0,0 +1,32 @@ +# Copyright 2017 Google Inc. +# +# 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. + +"""Google Cloud Translation API wrapper.""" + + +from google.cloud.translate_v2 import __version__ +from google.cloud.translate_v2.client import Client + +# These constants are essentially deprecated; strings should be used instead. +# They are imported here for backwards compatibility. +from google.cloud.translate_v2.client import BASE +from google.cloud.translate_v2.client import NMT + + +__all__ = ( + '__version__', + 'BASE', + 'Client', + 'NMT', +) diff --git a/translate/google/cloud/translate/__init__.py b/translate/google/cloud/translate_v2/__init__.py similarity index 79% rename from translate/google/cloud/translate/__init__.py rename to translate/google/cloud/translate_v2/__init__.py index bf20faa86bdfc..11b762101cf7e 100644 --- a/translate/google/cloud/translate/__init__.py +++ b/translate/google/cloud/translate_v2/__init__.py @@ -18,9 +18,10 @@ from pkg_resources import get_distribution __version__ = get_distribution('google-cloud-translate').version -from google.cloud.translate.client import BASE -from google.cloud.translate.client import Client -from google.cloud.translate.client import NMT +from google.cloud.translate_v2.client import Client -__all__ = ['__version__', 'BASE', 'Client', 'NMT'] +__all__ = ( + '__version__', + 'Client', +) diff --git a/translate/google/cloud/translate/_http.py b/translate/google/cloud/translate_v2/_http.py similarity index 96% rename from translate/google/cloud/translate/_http.py rename to translate/google/cloud/translate_v2/_http.py index 0c404f2a4a3bb..dedb17ec9e14c 100644 --- a/translate/google/cloud/translate/_http.py +++ b/translate/google/cloud/translate_v2/_http.py @@ -16,7 +16,7 @@ from google.cloud import _http -from google.cloud.translate import __version__ +from google.cloud.translate_v2 import __version__ _CLIENT_INFO = _http.CLIENT_INFO_TEMPLATE.format(__version__) diff --git a/translate/google/cloud/translate/client.py b/translate/google/cloud/translate_v2/client.py similarity index 98% rename from translate/google/cloud/translate/client.py rename to translate/google/cloud/translate_v2/client.py index 9acd7d65cc470..d72993f0fffdc 100644 --- a/translate/google/cloud/translate/client.py +++ b/translate/google/cloud/translate_v2/client.py @@ -20,7 +20,7 @@ from google.cloud._helpers import _to_bytes from google.cloud.client import Client as BaseClient -from google.cloud.translate._http import Connection +from google.cloud.translate_v2._http import Connection ENGLISH_ISO_639 = 'en' @@ -189,8 +189,8 @@ def translate(self, values, target_language=None, format_=None, in the query. :type model: str - :param model: (Optional) The model used to translate the text. The - only accepted values are :attr:`BASE` and :attr:`NMT`. + :param model: (Optional) The model used to translate the text, such + as ``'base'`` or ``'nmt'``. :rtype: str or list :returns: A list of dictionaries for each queried value. Each diff --git a/translate/setup.py b/translate/setup.py index edfaf5cbdc963..12934c6b4e964 100644 --- a/translate/setup.py +++ b/translate/setup.py @@ -35,7 +35,7 @@ 'include_package_data': True, 'zip_safe': False, 'classifiers': [ - 'Development Status :: 4 - Beta', + 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Operating System :: OS Independent', @@ -56,7 +56,7 @@ setup( name='google-cloud-translate', - version='0.25.0', + version='1.0.0', description='Python Client for Google Cloud Translation API', long_description=README, namespace_packages=[ diff --git a/translate/tests/system.py b/translate/tests/system.py index e4b971e238f02..7403ed3c05105 100644 --- a/translate/tests/system.py +++ b/translate/tests/system.py @@ -56,7 +56,7 @@ def test_translate(self): values = ['hvala ti', 'dankon', 'Me llamo Jeff', 'My name is Jeff'] translations = Config.CLIENT.translate( - values, target_language='de', model=translate.NMT) + values, target_language='de', model='nmt') self.assertEqual(len(values), len(translations)) self.assertEqual( diff --git a/translate/tests/unit/test__http.py b/translate/tests/unit/test__http.py index 1d7f7b4c6c188..2dc6b015d6dec 100644 --- a/translate/tests/unit/test__http.py +++ b/translate/tests/unit/test__http.py @@ -21,7 +21,7 @@ class TestConnection(unittest.TestCase): @staticmethod def _get_target_class(): - from google.cloud.translate._http import Connection + from google.cloud.translate_v2._http import Connection return Connection @@ -57,7 +57,7 @@ def test_build_api_url_w_extra_query_params(self): def test_extra_headers(self): from google.cloud import _http as base_http - from google.cloud.translate import _http as MUT + from google.cloud.translate_v2 import _http as MUT http = mock.Mock(spec=['request']) response = mock.Mock(status=200, spec=['status']) diff --git a/translate/tests/unit/test_client.py b/translate/tests/unit/test_client.py index d2c26cec96c46..18c19c436e45e 100644 --- a/translate/tests/unit/test_client.py +++ b/translate/tests/unit/test_client.py @@ -19,16 +19,15 @@ class TestClient(unittest.TestCase): @staticmethod def _get_target_class(): - from google.cloud.translate.client import Client - + from google.cloud.translate import Client return Client def _make_one(self, *args, **kw): return self._get_target_class()(*args, **kw) def test_constructor(self): - from google.cloud.translate._http import Connection - from google.cloud.translate.client import ENGLISH_ISO_639 + from google.cloud.translate_v2._http import Connection + from google.cloud.translate_v2.client import ENGLISH_ISO_639 http = object() client = self._make_one(_http=http) @@ -38,7 +37,7 @@ def test_constructor(self): self.assertEqual(client.target_language, ENGLISH_ISO_639) def test_constructor_non_default(self): - from google.cloud.translate._http import Connection + from google.cloud.translate_v2._http import Connection http = object() target = 'es' @@ -49,7 +48,7 @@ def test_constructor_non_default(self): self.assertEqual(client.target_language, target) def test_get_languages(self): - from google.cloud.translate.client import ENGLISH_ISO_639 + from google.cloud.translate_v2.client import ENGLISH_ISO_639 client = self._make_one(_http=object()) supported = [