-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from Ouranosinc/api+unittests
- Loading branch information
Showing
99 changed files
with
4,139 additions
and
7,821 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import sys | ||
import gunicorn.app.wsgiapp | ||
import sys | ||
|
||
|
||
if __name__ == '__main__': | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ | |
General meta information on the magpie package. | ||
""" | ||
|
||
|
||
__version__ = '0.6.2' | ||
__version__ = '0.6.3' | ||
__author__ = "Francois-Xavier Derue, Francis Charette-Migneault" | ||
__maintainer__ = "Francis Charette-Migneault" | ||
__email__ = '[email protected]' | ||
__url__ = 'https://github.com/Ouranosinc/Magpie' | ||
__description__ = "Magpie is a service for AuthN and AuthZ based on Ziggurat-Foundations" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from magpie.definitions.pyramid_definitions import * | ||
from magpie.api.api_except import * | ||
from magpie.api.api_rest_schemas import * | ||
from magpie import __meta__, db | ||
|
||
|
||
@VersionAPI.get(tags=[APITag], api_security=SecurityEveryoneAPI, response_schemas=Version_GET_responses) | ||
@view_config(route_name='version', request_method='GET', permission=NO_PERMISSION_REQUIRED) | ||
def get_version(request): | ||
""" | ||
Version information of the API. | ||
""" | ||
return valid_http(httpSuccess=HTTPOk, | ||
content={u'version': __meta__.__version__, u'db_version': db.get_database_revision(request.db)}, | ||
detail=Version_GET_OkResponseSchema.description, contentType='application/json') | ||
|
||
|
||
@notfound_view_config() | ||
def not_found(request): | ||
content = get_request_info(request, default_msg=NotFoundResponseSchema.description) | ||
return raise_http(nothrow=True, httpError=HTTPNotFound, contentType='application/json', | ||
detail=content['detail'], content=content) | ||
|
||
|
||
@exception_view_config() | ||
def internal_server_error(request): | ||
content = get_request_info(request, default_msg=InternalServerErrorResponseSchema.description) | ||
return raise_http(nothrow=True, httpError=HTTPInternalServerError, contentType='application/json', | ||
detail=content['detail'], content=content) | ||
|
||
|
||
@forbidden_view_config() | ||
def unauthorized_access(request): | ||
# if not overridden, default is HTTPForbidden [403], which is for a slightly different situation | ||
# this better reflects the HTTPUnauthorized [401] user access with specified AuthZ headers | ||
# [http://www.restapitutorial.com/httpstatuscodes.html] | ||
content = get_request_info(request, default_msg=UnauthorizedResponseSchema.description) | ||
return raise_http(nothrow=True, httpError=HTTPUnauthorized, contentType='application/json', | ||
detail=content['detail'], content=content) | ||
|
||
|
||
def get_request_info(request, default_msg="undefined"): | ||
content = {u'route_name': str(request.upath_info), u'request_url': str(request.url), u'detail': default_msg} | ||
if hasattr(request, 'exception'): | ||
if hasattr(request.exception, 'json'): | ||
if type(request.exception.json) is dict: | ||
content.update(request.exception.json) | ||
elif isinstance(request.exception, HTTPServerError) and hasattr(request.exception, 'message'): | ||
content.update({u'exception': str(request.exception.message)}) | ||
elif hasattr(request, 'matchdict'): | ||
if request.matchdict is not None and request.matchdict != '': | ||
content.update(request.matchdict) | ||
return content |
Oops, something went wrong.