changeset 3958:1cb0a1f82fb4 beta

sync gist api and cli with rhodecode-pam. This will is a part of API cleanup and rewrite
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 06 Jun 2013 23:53:01 +0200
parents b87def4b3cbb
children e1a0fdaecf63
files rhodecode/bin/rhodecode_gist.py rhodecode/controllers/api/api.py
diffstat 2 files changed, 11 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/bin/rhodecode_gist.py	Thu Jun 06 23:47:06 2013 +0200
+++ b/rhodecode/bin/rhodecode_gist.py	Thu Jun 06 23:53:01 2013 +0200
@@ -135,8 +135,8 @@
         }
 
         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 @@
         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
 
 
--- a/rhodecode/controllers/api/api.py	Thu Jun 06 23:47:06 2013 +0200
+++ b/rhodecode/controllers/api/api.py	Thu Jun 06 23:53:01 2013 +0200
@@ -1069,18 +1069,17 @@
             )
 
     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 @@
                                       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