Beispiel #1
0
 def get_version_v3(self, context):
     versions = self._get_versions_list(context)
     if 'v3' in _VERSIONS:
         return wsgi.render_response(body={
             'version': versions['v3']
         })
     else:
         raise exception.VersionNotFound(version='v3')
Beispiel #2
0
 def get_version_v2(self, request):
     versions = self._get_versions_list(request.context_dict)
     if 'v2.0' in _VERSIONS:
         return wsgi.render_response(body={
             'version': versions['v2.0']
         })
     else:
         raise exception.VersionNotFound(version='v2.0')
Beispiel #3
0
    def get_version_v3(self, context):
        versions = self._get_versions_list(context)
        if 'v3' in _VERSIONS:
            req_mime_type = v3_mime_type_best_match(context)

            if req_mime_type == MimeTypes.JSON_HOME:
                return wsgi.render_response(body=self._get_json_home_v3(),
                                            headers=(('Content-Type',
                                                      MimeTypes.JSON_HOME), ))

            return wsgi.render_response(body={'version': versions['v3']})
        else:
            raise exception.VersionNotFound(version='v3')
Beispiel #4
0
def get_version_v3():
    if 'v3' not in _VERSIONS:
        raise exception.VersionNotFound(version='v3')

    if v3_mime_type_best_match() == MimeTypes.JSON_HOME:
        # RENDER JSON-Home form, we have a clever client who will
        # understand the JSON-Home document.
        content = _v3_json_home_content()
        return flask.Response(response=jsonutils.dumps(content),
                              mimetype=MimeTypes.JSON_HOME)
    else:
        identity_url = '%s/' % ks_flask.base_url()
        versions = _get_versions_list(identity_url)
        return flask.Response(response=jsonutils.dumps(
            {'version': versions['v3']}),
                              mimetype=MimeTypes.JSON)
Beispiel #5
0
def get_version_v3():
    if 'v3' not in _VERSIONS:
        raise exception.VersionNotFound(version='v3')

    if v3_mime_type_best_match() == MimeTypes.JSON_HOME:
        # RENDER JSON-Home form, we have a clever client who will
        # understand the JSON-Home document.
        content = _v3_json_home_content()
        return flask.Response(response=jsonutils.dumps(content),
                              mimetype=MimeTypes.JSON_HOME)
    else:
        # NOTE(morgan): wsgi.Application.base_url will eventually need to
        # be moved to a better "common" location. For now, we'll just lean
        # on it for the sake of leaning on common code where possible.
        identity_url = '%s/v3/' % wsgi.Application.base_url(
            context={'environment': request.environ})
        versions = _get_versions_list(identity_url)
        return flask.Response(response=jsonutils.dumps(
            {'version': versions['v3']}),
                              mimetype=MimeTypes.JSON)