aboutsummaryrefslogtreecommitdiffstats
path: root/github3/handlers/gists.py
diff options
context:
space:
mode:
authorDavid Medina <davidmedina9@gmail.com>2011-12-03 13:22:12 +0100
committerDavid Medina <davidmedina9@gmail.com>2011-12-03 13:22:12 +0100
commitbb52626bda2a1d61833fe9c4cf9276b1feeb4e2e (patch)
tree43eb435554c89dd475a99b4fca85082770976dd7 /github3/handlers/gists.py
parentAdded owner filter (diff)
downloadpython-github3-bb52626bda2a1d61833fe9c4cf9276b1feeb4e2e.tar.xz
python-github3-bb52626bda2a1d61833fe9c4cf9276b1feeb4e2e.zip
Complete AuthGist handler
Diffstat (limited to 'github3/handlers/gists.py')
-rw-r--r--github3/handlers/gists.py94
1 files changed, 89 insertions, 5 deletions
diff --git a/github3/handlers/gists.py b/github3/handlers/gists.py
index 37b1c3d..ed03c31 100644
--- a/github3/handlers/gists.py
+++ b/github3/handlers/gists.py
@@ -53,9 +53,93 @@ class Gist(Handler, MimeTypeMixin):
class AuthGist(Gist):
- def create_gist(self, description, public=True, files={}):
- """ Create a gist """
- data = {'description': description,
- 'public': public,
- 'files': files}
+ def all_gists(self, limit=None):
+ """ Return all public gists
+
+ NOTE: It returns all gists in github environment. Maybe you
+ want to use `limit` parameter
+ """
+
+ return self._get_resources('public', model=models.Gist, limit=limit)
+
+ def my_gists(self, limit=None):
+ """ Return authenticated user's gists
+
+ param `limit`: Number of gists
+ """
+
+ return self._get_resources('', model=models.Gist, limit=limit)
+
+ def my_starred_gists(self, limit=None):
+ """ Return authenticated user's starred gists
+
+ param `limit`: Number of gists
+ """
+
+ return self._get_resources('starred', model=models.Gist, limit=limit)
+
+ def create_gist(self, is_public, files, desc=None):
+ """ Create and return a gist """
+
+ data = {
+ 'public': bool(is_public),
+ 'files': files, # TODO: Issue #1
+ 'desc': desc or '',
+ }
return self._post_resource('', data=data, model=models.Gist)
+
+ def star_gist(self, gist_id):
+ """ Star a gist
+
+ param `gist_id`: Gist id to star
+ """
+
+ return self._put('%s/star' % gist_id)
+
+ def unstar_gist(self, gist_id):
+ """ Unstar a gist
+
+ param `gist_id`: Gist id to unstar
+ """
+
+ return self._delete('%s/star' % gist_id)
+
+ def is_starred(self, gist_id):
+ """ True if gist is starred
+
+ param `gist_id`: Gist id
+ """
+
+ return self._bool('%s/star' % gist_id)
+
+ def fork_gist(self, gist_id):
+ """ Return forked gist from id
+
+ param `gist_id`: Gist id to be forked...
+ """
+
+ return self._post_resource('%s/fork' % gist_id, data=None,
+ model=models.Gist)
+
+ def delete_gist(self, gist_id):
+ """ Delete the gist
+
+ param `gist_id`: Gist id
+ """
+
+ return self._delete(str(gist_id))
+
+ def create_comment(self, gist_id, comment):
+ """ Create comment into gist """
+
+ data = {'body': comment}
+ return self._post_resource('%s/comments' % gist_id, data=data,
+ model=models.GistComment)
+
+ def delete_comment(self, comment_id):
+ """ Delete comment
+
+ param `comment_id`: Comment id
+ """
+
+ return self._delete('comments/%s' % comment_id)