Skip to content

Commit

Permalink
Updating datastore URI template for v1beta3.
Browse files Browse the repository at this point in the history
Also updating the docs link in the README.
  • Loading branch information
dhermes committed Jan 15, 2016
1 parent 3f18953 commit 9d7f232
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 94 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ writes, strong consistency for reads and ancestor queries, and eventual
consistency for all other queries.

.. _Cloud Datastore: https://cloud.google.com/datastore/docs
.. _Datastore API docs: https://cloud.google.com/datastore/docs/apis/v1beta2/
.. _Datastore API docs: https://cloud.google.com/datastore/docs/apis/v1beta3/

See the ``gcloud-python`` API `datastore documentation`_ to learn how to
interact with the Cloud Datastore using this Client Library.
Expand Down
11 changes: 5 additions & 6 deletions gcloud/datastore/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ class Connection(connection.Connection):
:attr:`API_BASE_URL`.
"""

API_BASE_URL = 'https://www.googleapis.com'
API_BASE_URL = 'https://datastore.googleapis.com'
"""The base of the API call URL."""

API_VERSION = 'v1beta2'
API_VERSION = 'v1beta3'
"""The version of the API, used in building the API call's URL."""

API_URL_TEMPLATE = ('{api_base}/datastore/{api_version}'
'/datasets/{project}/{method}')
API_URL_TEMPLATE = ('{api_base}/{api_version}/projects'
'/{project}:{method}')
"""A template for the URL of a particular API call."""

SCOPE = ('https://www.googleapis.com/auth/datastore',
'https://www.googleapis.com/auth/userinfo.email')
SCOPE = ('https://www.googleapis.com/auth/datastore',)
"""The scopes required for authenticating as a Cloud Datastore consumer."""

def __init__(self, credentials=None, http=None, api_base_url=None):
Expand Down
131 changes: 44 additions & 87 deletions gcloud/datastore/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ def _verifyProtobufCall(self, called_with, URI, conn):
conn.USER_AGENT)

def test_default_url(self):
from gcloud.connection import API_BASE_URL

klass = self._getTargetClass()
conn = self._makeOne()
self.assertEqual(conn.api_base_url, API_BASE_URL)
self.assertEqual(conn.api_base_url, klass.API_BASE_URL)

def test_custom_url_from_env(self):
import os
Expand Down Expand Up @@ -143,11 +142,9 @@ def test__request_w_200(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
METHOD,
'projects',
PROJECT + ':' + METHOD,
])
http = conn._http = Http({'status': '200'}, 'CONTENT')
self.assertEqual(conn._request(PROJECT, METHOD, DATA), 'CONTENT')
Expand Down Expand Up @@ -189,11 +186,9 @@ def FromString(cls, pb):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
METHOD,
'projects',
PROJECT + ':' + METHOD,
])
http = conn._http = Http({'status': '200'}, 'CONTENT')
response = conn._rpc(PROJECT, METHOD, ReqPB(), RspPB)
Expand All @@ -208,11 +203,9 @@ def test_build_api_url_w_default_base_version(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
METHOD,
'projects',
PROJECT + ':' + METHOD,
])
self.assertEqual(conn.build_api_url(PROJECT, METHOD), URI)

Expand All @@ -224,11 +217,9 @@ def test_build_api_url_w_explicit_base_version(self):
conn = self._makeOne()
URI = '/'.join([
BASE,
'datastore',
VER,
'datasets',
PROJECT,
METHOD,
'projects',
PROJECT + ':' + METHOD,
])
self.assertEqual(conn.build_api_url(PROJECT, METHOD, BASE, VER),
URI)
Expand All @@ -242,11 +233,9 @@ def test_lookup_single_key_empty_response(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'lookup',
'projects',
PROJECT + ':lookup',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
found, missing, deferred = conn.lookup(PROJECT, [key_pb])
Expand All @@ -271,11 +260,9 @@ def test_lookup_single_key_empty_response_w_eventual(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'lookup',
'projects',
PROJECT + ':lookup',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
found, missing, deferred = conn.lookup(PROJECT, [key_pb],
Expand Down Expand Up @@ -313,11 +300,9 @@ def test_lookup_single_key_empty_response_w_transaction(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'lookup',
'projects',
PROJECT + ':lookup',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
found, missing, deferred = conn.lookup(PROJECT, [key_pb],
Expand Down Expand Up @@ -348,11 +333,9 @@ def test_lookup_single_key_nonempty_response(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'lookup',
'projects',
PROJECT + ':lookup',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
(found,), missing, deferred = conn.lookup(PROJECT, [key_pb])
Expand All @@ -379,11 +362,9 @@ def test_lookup_multiple_keys_empty_response(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'lookup',
'projects',
PROJECT + ':lookup',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
found, missing, deferred = conn.lookup(PROJECT, [key_pb1, key_pb2])
Expand Down Expand Up @@ -414,11 +395,9 @@ def test_lookup_multiple_keys_w_missing(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'lookup',
'projects',
PROJECT + ':lookup',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
result, missing, deferred = conn.lookup(PROJECT, [key_pb1, key_pb2])
Expand Down Expand Up @@ -448,11 +427,9 @@ def test_lookup_multiple_keys_w_deferred(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'lookup',
'projects',
PROJECT + ':lookup',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
result, missing, deferred = conn.lookup(PROJECT, [key_pb1, key_pb2])
Expand Down Expand Up @@ -490,11 +467,9 @@ def test_run_query_w_eventual_no_transaction(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'runQuery',
'projects',
PROJECT + ':runQuery',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
pbs, end, more, skipped = conn.run_query(PROJECT, q_pb,
Expand Down Expand Up @@ -531,11 +506,9 @@ def test_run_query_wo_eventual_w_transaction(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'runQuery',
'projects',
PROJECT + ':runQuery',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
pbs, end, more, skipped = conn.run_query(
Expand Down Expand Up @@ -589,11 +562,9 @@ def test_run_query_wo_namespace_empty_result(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'runQuery',
'projects',
PROJECT + ':runQuery',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
pbs, end, more, skipped = conn.run_query(PROJECT, q_pb)
Expand Down Expand Up @@ -624,11 +595,9 @@ def test_run_query_w_namespace_nonempty_result(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'runQuery',
'projects',
PROJECT + ':runQuery',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
pbs = conn.run_query(PROJECT, q_pb, 'NS')[0]
Expand All @@ -651,11 +620,9 @@ def test_begin_transaction(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'beginTransaction',
'projects',
PROJECT + ':beginTransaction',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
self.assertEqual(conn.begin_transaction(PROJECT), TRANSACTION)
Expand Down Expand Up @@ -684,11 +651,9 @@ def test_commit_wo_transaction(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'commit',
'projects',
PROJECT + ':commit',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())

Expand Down Expand Up @@ -732,11 +697,9 @@ def test_commit_w_transaction(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'commit',
'projects',
PROJECT + ':commit',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())

Expand Down Expand Up @@ -771,11 +734,9 @@ def test_rollback_ok(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'rollback',
'projects',
PROJECT + ':rollback',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
self.assertEqual(conn.rollback(PROJECT, TRANSACTION), None)
Expand All @@ -794,11 +755,9 @@ def test_allocate_ids_empty(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'allocateIds',
'projects',
PROJECT + ':allocateIds',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
self.assertEqual(conn.allocate_ids(PROJECT, []), [])
Expand Down Expand Up @@ -827,11 +786,9 @@ def test_allocate_ids_non_empty(self):
conn = self._makeOne()
URI = '/'.join([
conn.api_base_url,
'datastore',
conn.API_VERSION,
'datasets',
PROJECT,
'allocateIds',
'projects',
PROJECT + ':allocateIds',
])
http = conn._http = Http({'status': '200'}, rsp_pb.SerializeToString())
self.assertEqual(conn.allocate_ids(PROJECT, before_key_pbs),
Expand Down

0 comments on commit 9d7f232

Please sign in to comment.