
from mvpn.api.openstack import wsgi
from mvpn.api.openstack.mvpn.views import versions as views_versions

LINKS = {
       'v2.0': {
                  'pdf': 'http://docs.flftuu.com/'
                          'api/openstack-compute/2/os-compute-devguide-2.pdf',
                  'wadl': 'http://docs.flftuu.com/'
                          'api/openstack-compute/2/wadl/os-compute-2.wadl'
               },
       'v3.0': {
                  'pdf': 'http://docs.flftuu.com/'
                          'api/openstack-compute/3/os-compute-devguide-3.pdf',
                  'wadl': 'http://docs.flftuu.com/'
                          'api/openstack-compute/3/wadl/os-compute-3.wadl'
               },
}
VERSIONS = {
    "v2.0": {
        "id": "v2.0",
        "status": "CURRENT",
        "updated": "2015-10-21T11:33:21Z",
        "links": [
            {
                "rel": "describedby",
                "type": "application/pdf",
                "href": LINKS['v2.0']['pdf'],
            },
            {
                "rel": "describedby",
                "type": "application/vnd.sun.wadl+xml",
                "href": LINKS['v2.0']['wadl'],
            },
        ],
        "media-types": [
            {
                "base": "application/xml",
                "type": "application/vnd.openstack.compute+xml;version=2",
            },
            {
                "base": "application/json",
                "type": "application/vnd.openstack.compute+json;version=2",
            }
        ],
    },
    "v3.0": {
        "id": "v3.0",
        "status": "EXPERIMENTAL",
        "updated": "2016-02-23T11:33:21Z",
        "links": [
            {
                "rel": "describedby",
                "type": "application/pdf",
                "href": LINKS['v3.0']['pdf'],
            },
            {
                "rel": "describedby",
                "type": "application/vnd.sun.wadl+xml",
                "href": LINKS['v3.0']['wadl'],
            },
        ],
        "media-types": [
            {
                "base": "application/json",
                "type": "application/vnd.openstack.compute+json;version=3",
            }
        ],
    }
}


class VersionV2(object):
    #@wsgi.serializers(xml=VersionTemplate,
    #                  atom=VersionAtomSerializer)
    def show(self, req):
        builder = views_versions.get_view_builder(req)
        return builder.build_version(VERSIONS['v2.0'])


def create_resource():
    return wsgi.Resource(VersionV2())
