Skip to content

Commit dbce610

Browse files
author
Costin Bleotu
committed
List user repos
1 parent 4efbf3f commit dbce610

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

gogs_client/interface.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,23 @@ def get_repo(self, auth, username, repo_name):
178178
response = self._check_ok(self._get(path, auth=auth))
179179
return GogsRepo.from_json(response.json())
180180

181+
def get_user_repos(self, auth, username):
182+
"""
183+
Returns the repositories owned by
184+
the user with username ``username``.
185+
186+
:param auth.Authentication auth: authentication object
187+
:param str username: username of owner of repository
188+
:return: a list of repositories
189+
:rtype: List[GogsRepo]
190+
:raises NetworkFailure: if there is an error communicating with the server
191+
:raises ApiFailure: if the request cannot be serviced
192+
"""
193+
path = "/users/{u}/repos".format(u=username)
194+
response = self._check_ok(self._get(path, auth=auth))
195+
print response
196+
return [GogsRepo.from_json(repo_json) for repo_json in response.json()]
197+
181198
def delete_repo(self, auth, username, repo_name):
182199
"""
183200
Deletes the repository with name ``repo_name`` owned by the user with username ``username``.

0 commit comments

Comments
 (0)