##// END OF EJS Templates
API get_user and get_repo methods can fetch by id or names
marcink -
r2010:14dffcfe beta
parent child Browse files
Show More
@@ -87,7 +87,7 b' OUTPUT::'
87 87 get_user
88 88 --------
89 89
90 Get's an user by username, Returns empty result if user is not found.
90 Get's an user by username or user_id, Returns empty result if user is not found.
91 91 This command can be executed only using api_key belonging to user with admin
92 92 rights.
93 93
@@ -97,7 +97,7 b' INPUT::'
97 97 api_key : "<api_key>"
98 98 method : "get_user"
99 99 args : {
100 "username" : "<username>"
100 "userid" : "<username or user_id>"
101 101 }
102 102
103 103 OUTPUT::
@@ -370,8 +370,8 b' OUTPUT::'
370 370 get_repo
371 371 --------
372 372
373 Gets an existing repository. This command can be executed only using api_key
374 belonging to user with admin rights
373 Gets an existing repository by it's name or repository_id. This command can
374 be executed only using api_key belonging to user with admin rights.
375 375
376 376
377 377 INPUT::
@@ -379,7 +379,7 b' INPUT::'
379 379 api_key : "<api_key>"
380 380 method : "get_repo"
381 381 args: {
382 "repo_name" : "<reponame>"
382 "repoid" : "<reponame or repo_id>"
383 383 }
384 384
385 385 OUTPUT::
@@ -80,7 +80,7 b' class ApiController(JSONRPCController):'
80 80 raise JSONRPCError('Unable to pull changes from "%s"' % repo_name)
81 81
82 82 @HasPermissionAllDecorator('hg.admin')
83 def get_user(self, apiuser, username):
83 def get_user(self, apiuser, userid):
84 84 """"
85 85 Get a user by username
86 86
@@ -88,7 +88,7 b' class ApiController(JSONRPCController):'
88 88 :param username:
89 89 """
90 90
91 user = User.get_by_username(username)
91 user = UserModel().get_user(userid)
92 92 if user is None:
93 93 return user
94 94
@@ -342,7 +342,7 b' class ApiController(JSONRPCController):'
342 342 raise JSONRPCError('failed to remove user from group')
343 343
344 344 @HasPermissionAnyDecorator('hg.admin')
345 def get_repo(self, apiuser, repo_name):
345 def get_repo(self, apiuser, repoid):
346 346 """"
347 347 Get repository by name
348 348
@@ -350,7 +350,7 b' class ApiController(JSONRPCController):'
350 350 :param repo_name:
351 351 """
352 352
353 repo = Repository.get_by_repo_name(repo_name)
353 repo = RepoModel().get_repo(repoid)
354 354 if repo is None:
355 355 raise JSONRPCError('unknown repository %s' % repo)
356 356
@@ -82,6 +82,9 b' class RepoModel(BaseModel):'
82 82 "get_repo_%s" % repo_id))
83 83 return repo.scalar()
84 84
85 def get_repo(self, repository):
86 return self.__get_repo(repository)
87
85 88 def get_by_repo_name(self, repo_name, cache=False):
86 89 repo = self.sa.query(Repository)\
87 90 .filter(Repository.repo_name == repo_name)
General Comments 0
You need to be logged in to leave comments. Login now