# HG changeset patch # User Marcin Kuzminski # Date 2013-06-06 21:53:01 # Node ID 1cb0a1f82fb42fb75165f82e8227b40dd95a9ac0 # Parent b87def4b3cbb038e5be2a56af6317cfc9035d180 sync gist api and cli with rhodecode-pam. This will is a part of API cleanup and rewrite diff --git a/rhodecode/bin/rhodecode_gist.py b/rhodecode/bin/rhodecode_gist.py --- a/rhodecode/bin/rhodecode_gist.py +++ b/rhodecode/bin/rhodecode_gist.py @@ -135,8 +135,8 @@ def _run(argv): } margs = dict( - gist_lifetime=args.lifetime, - gist_description=args.description, + lifetime=args.lifetime, + description=args.description, gist_type='private' if args.private else 'public', files=files ) @@ -145,8 +145,9 @@ def _run(argv): if args.format == FORMAT_JSON: print json.dumps(json_data) elif args.format == FORMAT_PRETTY: - print 'Created %s gist %s' % (json_data['gist_type'], - json_data['gist_url']) + print json_data + print 'Created %s gist %s' % (json_data['gist']['type'], + json_data['gist']['url']) return 0 diff --git a/rhodecode/controllers/api/api.py b/rhodecode/controllers/api/api.py --- a/rhodecode/controllers/api/api.py +++ b/rhodecode/controllers/api/api.py @@ -1069,18 +1069,17 @@ class ApiController(JSONRPCController): ) def create_gist(self, apiuser, files, owner=Optional(OAttr('apiuser')), - gist_type=Optional(Gist.GIST_PUBLIC), - gist_lifetime=Optional(-1), - gist_description=Optional('')): + gist_type=Optional(Gist.GIST_PUBLIC), lifetime=Optional(-1), + description=Optional('')): try: if isinstance(owner, Optional): owner = apiuser.user_id owner = get_user_or_error(owner) - description = Optional.extract(gist_description) + description = Optional.extract(description) gist_type = Optional.extract(gist_type) - gist_lifetime = Optional.extract(gist_lifetime) + lifetime = Optional.extract(lifetime) # files: { # 'filename': {'content':'...', 'lexer': null}, @@ -1090,21 +1089,12 @@ class ApiController(JSONRPCController): owner=owner, gist_mapping=files, gist_type=gist_type, - lifetime=gist_lifetime) + lifetime=lifetime) Session().commit() return dict( msg='created new gist', - gist_url=gist.gist_url(), - gist_id=gist.gist_access_id, - gist_type=gist.gist_type, - files=files.keys() + gist=gist.get_api_data() ) except Exception: log.error(traceback.format_exc()) raise JSONRPCError('failed to create gist') - - def update_gist(self, apiuser): - pass - - def delete_gist(self, apiuser): - pass