Created
December 18, 2013 18:00
-
-
Save lucemia/8026890 to your computer and use it in GitHub Desktop.
dynamic class
This file contains hidden or 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
| BigDataApi = RestEndpoint('BigDataApi', (_BigDataApi,), [Reducer]) | |
| BigDataApi = type( | |
| 'BigDataApi', | |
| (BigDataApi, ), | |
| { | |
| 'ReducerList': Reducer.method( | |
| request_fields=('id',), | |
| path='reducer/{id}', | |
| http_method="DELETE", | |
| name="reducer.delete", | |
| user_required=True, | |
| )(GenericList) | |
| } | |
| ) | |
| BigDataApi = endpoints.api( | |
| name="bigdata", | |
| version="v1", | |
| description="""The BigData API""", | |
| allowed_client_ids=ALLOWED_CLIENT_IDS, | |
| scopes=[endpoints.EMAIL_SCOPE] | |
| )(BigDataApi) | |
| import types | |
| from functools import partial, wraps | |
| def register_rest_api(api_server, endpoint_cls): | |
| name = endpoint_cls.__name__ | |
| # create list method | |
| query_method = types.MethodType( | |
| endpoint_cls.query_method( | |
| query_fields=('limit', 'pageToken'), | |
| path="%ss" % name, | |
| http_method="GET", | |
| name="%s.list" % name, | |
| user_required=True | |
| )(GenericList), api_server) | |
| setattr(api_server, "%sList" % name, query_method) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment