##// END OF EJS Templates
sync gist api and cli with rhodecode-pam....
marcink -
r3958:1cb0a1f8 beta
parent child Browse files
Show More
@@ -135,8 +135,8 b' def _run(argv):'
135 }
135 }
136
136
137 margs = dict(
137 margs = dict(
138 gist_lifetime=args.lifetime,
138 lifetime=args.lifetime,
139 gist_description=args.description,
139 description=args.description,
140 gist_type='private' if args.private else 'public',
140 gist_type='private' if args.private else 'public',
141 files=files
141 files=files
142 )
142 )
@@ -145,8 +145,9 b' def _run(argv):'
145 if args.format == FORMAT_JSON:
145 if args.format == FORMAT_JSON:
146 print json.dumps(json_data)
146 print json.dumps(json_data)
147 elif args.format == FORMAT_PRETTY:
147 elif args.format == FORMAT_PRETTY:
148 print 'Created %s gist %s' % (json_data['gist_type'],
148 print json_data
149 json_data['gist_url'])
149 print 'Created %s gist %s' % (json_data['gist']['type'],
150 json_data['gist']['url'])
150 return 0
151 return 0
151
152
152
153
@@ -1069,18 +1069,17 b' class ApiController(JSONRPCController):'
1069 )
1069 )
1070
1070
1071 def create_gist(self, apiuser, files, owner=Optional(OAttr('apiuser')),
1071 def create_gist(self, apiuser, files, owner=Optional(OAttr('apiuser')),
1072 gist_type=Optional(Gist.GIST_PUBLIC),
1072 gist_type=Optional(Gist.GIST_PUBLIC), lifetime=Optional(-1),
1073 gist_lifetime=Optional(-1),
1073 description=Optional('')):
1074 gist_description=Optional('')):
1075
1074
1076 try:
1075 try:
1077 if isinstance(owner, Optional):
1076 if isinstance(owner, Optional):
1078 owner = apiuser.user_id
1077 owner = apiuser.user_id
1079
1078
1080 owner = get_user_or_error(owner)
1079 owner = get_user_or_error(owner)
1081 description = Optional.extract(gist_description)
1080 description = Optional.extract(description)
1082 gist_type = Optional.extract(gist_type)
1081 gist_type = Optional.extract(gist_type)
1083 gist_lifetime = Optional.extract(gist_lifetime)
1082 lifetime = Optional.extract(lifetime)
1084
1083
1085 # files: {
1084 # files: {
1086 # 'filename': {'content':'...', 'lexer': null},
1085 # 'filename': {'content':'...', 'lexer': null},
@@ -1090,21 +1089,12 b' class ApiController(JSONRPCController):'
1090 owner=owner,
1089 owner=owner,
1091 gist_mapping=files,
1090 gist_mapping=files,
1092 gist_type=gist_type,
1091 gist_type=gist_type,
1093 lifetime=gist_lifetime)
1092 lifetime=lifetime)
1094 Session().commit()
1093 Session().commit()
1095 return dict(
1094 return dict(
1096 msg='created new gist',
1095 msg='created new gist',
1097 gist_url=gist.gist_url(),
1096 gist=gist.get_api_data()
1098 gist_id=gist.gist_access_id,
1099 gist_type=gist.gist_type,
1100 files=files.keys()
1101 )
1097 )
1102 except Exception:
1098 except Exception:
1103 log.error(traceback.format_exc())
1099 log.error(traceback.format_exc())
1104 raise JSONRPCError('failed to create gist')
1100 raise JSONRPCError('failed to create gist')
1105
1106 def update_gist(self, apiuser):
1107 pass
1108
1109 def delete_gist(self, apiuser):
1110 pass
General Comments 0
You need to be logged in to leave comments. Login now