91 lines
2.8 KiB
Python
91 lines
2.8 KiB
Python
# Copyright 2010 OpenStack LLC.
|
|
# Copyright 2015 Clinton Knight
|
|
# 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.
|
|
|
|
import copy
|
|
|
|
from oslo_config import cfg
|
|
|
|
from manila.api import extensions
|
|
from manila.api import openstack
|
|
from manila.api.openstack import api_version_request
|
|
from manila.api.openstack import wsgi
|
|
from manila.api.views import versions as views_versions
|
|
|
|
CONF = cfg.CONF
|
|
|
|
|
|
_KNOWN_VERSIONS = {
|
|
'v1.0': {
|
|
'id': 'v1.0',
|
|
'status': 'CURRENT',
|
|
'version': api_version_request._MAX_API_VERSION,
|
|
'min_version': api_version_request._MIN_API_VERSION,
|
|
'updated': '2015-07-30T11:33:21Z',
|
|
'links': [
|
|
{
|
|
'rel': 'describedby',
|
|
'type': 'text/html',
|
|
'href': 'http://docs.openstack.org/',
|
|
},
|
|
],
|
|
'media-types': [
|
|
{
|
|
'base': 'application/json',
|
|
'type': 'application/vnd.openstack.share+json;version=1',
|
|
}
|
|
],
|
|
},
|
|
}
|
|
|
|
|
|
class VersionsRouter(openstack.APIRouter):
|
|
"""Route versions requests."""
|
|
|
|
ExtensionManager = extensions.ExtensionManager
|
|
|
|
def _setup_routes(self, mapper, ext_mgr):
|
|
self.resources['versions'] = create_resource()
|
|
mapper.connect('versions', '/',
|
|
controller=self.resources['versions'],
|
|
action='index')
|
|
mapper.redirect('', '/')
|
|
|
|
|
|
class VersionsController(wsgi.Controller):
|
|
|
|
def __init__(self):
|
|
super(VersionsController, self).__init__(None)
|
|
|
|
@wsgi.Controller.api_version('1.0', '1.0')
|
|
def index(self, req):
|
|
"""Return all versions."""
|
|
builder = views_versions.get_view_builder(req)
|
|
known_versions = copy.deepcopy(_KNOWN_VERSIONS)
|
|
known_versions['v1.0'].pop('min_version')
|
|
known_versions['v1.0'].pop('version')
|
|
return builder.build_versions(known_versions)
|
|
|
|
@wsgi.Controller.api_version('1.1') # noqa
|
|
def index(self, req): # pylint: disable=E0102
|
|
"""Return all versions."""
|
|
builder = views_versions.get_view_builder(req)
|
|
known_versions = copy.deepcopy(_KNOWN_VERSIONS)
|
|
return builder.build_versions(known_versions)
|
|
|
|
|
|
def create_resource():
|
|
return wsgi.Resource(VersionsController())
|