Version discovery for root URI
Version discovery is now available by accessing the root URI path Implements: blueprint api-version-discovery Change-Id: I8716a718265230b5ce022daabec6484769e42467
This commit is contained in:
parent
65b267a23f
commit
c08ff747ad
69
tests/functional/wsgi/test_version.py
Normal file
69
tests/functional/wsgi/test_version.py
Normal file
@ -0,0 +1,69 @@
|
||||
# Copyright (c) 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
|
||||
import falcon
|
||||
from oslo.serialization import jsonutils
|
||||
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
|
||||
EXPECTED_VERSIONS = [
|
||||
{
|
||||
'id': '1',
|
||||
'status': 'SUPPORTED',
|
||||
'updated': '2014-9-11T17:47:05Z',
|
||||
'media-types': [
|
||||
{
|
||||
'base': 'application/json',
|
||||
'type': 'application/vnd.openstack.messaging-v1+json'
|
||||
}
|
||||
],
|
||||
'links': [
|
||||
{
|
||||
'href': '/v1/',
|
||||
'rel': 'self'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': '1.1',
|
||||
'status': 'CURRENT',
|
||||
'updated': '2014-9-24T04:06:47Z',
|
||||
'media-types': [
|
||||
{
|
||||
'base': 'application/json',
|
||||
'type': 'application/vnd.openstack.messaging-v1_1+json'
|
||||
}
|
||||
],
|
||||
'links': [
|
||||
{
|
||||
'href': '/v1.1/',
|
||||
'rel': 'self'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
class TestVersion(base.TestBase):
|
||||
|
||||
config_file = 'wsgi_sqlalchemy.conf'
|
||||
|
||||
def test_get(self):
|
||||
response = self.simulate_get('/')
|
||||
versions = jsonutils.loads(response[0])['versions']
|
||||
|
||||
self.assertEqual(self.srmock.status, falcon.HTTP_300)
|
||||
self.assertEqual(len(versions), 2)
|
||||
self.assertEqual(EXPECTED_VERSIONS, versions)
|
@ -28,6 +28,7 @@ from zaqar.transport import auth
|
||||
from zaqar.transport import validation
|
||||
from zaqar.transport.wsgi import v1_0
|
||||
from zaqar.transport.wsgi import v1_1
|
||||
from zaqar.transport.wsgi import version
|
||||
|
||||
_WSGI_OPTIONS = (
|
||||
cfg.StrOpt('bind', default='127.0.0.1',
|
||||
@ -82,6 +83,7 @@ class Driver(transport.DriverBase):
|
||||
catalog = [
|
||||
('/v1', v1_0.public_endpoints(self, self._conf)),
|
||||
('/v1.1', v1_1.public_endpoints(self, self._conf)),
|
||||
('/', [('', version.Resource())])
|
||||
]
|
||||
|
||||
if self._conf.admin_mode:
|
||||
|
@ -21,6 +21,24 @@ from zaqar.transport.wsgi.v1_0 import pools
|
||||
from zaqar.transport.wsgi.v1_0 import queues
|
||||
from zaqar.transport.wsgi.v1_0 import stats
|
||||
|
||||
VERSION = {
|
||||
'id': '1',
|
||||
'status': 'SUPPORTED',
|
||||
'updated': '2014-9-11T17:47:05Z',
|
||||
'media-types': [
|
||||
{
|
||||
'base': 'application/json',
|
||||
'type': 'application/vnd.openstack.messaging-v1+json'
|
||||
}
|
||||
],
|
||||
'links': [
|
||||
{
|
||||
'href': '/v1/',
|
||||
'rel': 'self'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def public_endpoints(driver, conf):
|
||||
queue_controller = driver._storage.queue_controller
|
||||
|
@ -22,6 +22,24 @@ from zaqar.transport.wsgi.v1_1 import pools
|
||||
from zaqar.transport.wsgi.v1_1 import queues
|
||||
from zaqar.transport.wsgi.v1_1 import stats
|
||||
|
||||
VERSION = {
|
||||
'id': '1.1',
|
||||
'status': 'CURRENT',
|
||||
'updated': '2014-9-24T04:06:47Z',
|
||||
'media-types': [
|
||||
{
|
||||
'base': 'application/json',
|
||||
'type': 'application/vnd.openstack.messaging-v1_1+json'
|
||||
}
|
||||
],
|
||||
'links': [
|
||||
{
|
||||
'href': '/v1.1/',
|
||||
'rel': 'self'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def public_endpoints(driver, conf):
|
||||
queue_controller = driver._storage.queue_controller
|
||||
|
37
zaqar/transport/wsgi/version.py
Normal file
37
zaqar/transport/wsgi/version.py
Normal file
@ -0,0 +1,37 @@
|
||||
# Copyright (c) 2014 OpenStack Foundation
|
||||
#
|
||||
# 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.
|
||||
|
||||
import falcon
|
||||
|
||||
from zaqar.transport import utils
|
||||
from zaqar.transport.wsgi import v1_0
|
||||
from zaqar.transport.wsgi import v1_1
|
||||
|
||||
VERSIONS = {
|
||||
'versions': [
|
||||
v1_0.VERSION,
|
||||
v1_1.VERSION
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
class Resource(object):
|
||||
|
||||
def __init__(self):
|
||||
self.versions = utils.to_json(VERSIONS)
|
||||
|
||||
def on_get(self, req, resp, project_id):
|
||||
resp.data = self.versions
|
||||
|
||||
resp.status = falcon.HTTP_300
|
Loading…
x
Reference in New Issue
Block a user