diff options
author | 2012-04-13 17:06:09 -0500 | |
---|---|---|
committer | 2012-04-16 13:36:39 -0500 | |
commit | 4ce1a90038b23d931858ad22815dbe29f74d7d98 (patch) | |
tree | 880428e5a6e23c472cfa14183884c0ac79bbf718 /pygithub3/services/git_data/references.py | |
parent | :sparkles: Release 0.3 :sparkles: (diff) | |
download | python-github3-4ce1a90038b23d931858ad22815dbe29f74d7d98.tar.xz python-github3-4ce1a90038b23d931858ad22815dbe29f74d7d98.zip |
add Git Data API support
Diffstat (limited to 'pygithub3/services/git_data/references.py')
-rw-r--r-- | pygithub3/services/git_data/references.py | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/pygithub3/services/git_data/references.py b/pygithub3/services/git_data/references.py new file mode 100644 index 0000000..8ae0865 --- /dev/null +++ b/pygithub3/services/git_data/references.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from pygithub3.services.base import Service + + +class References(Service): + """Consume `References API <http://developer.github.com/v3/git/refs/>`_""" + + def get(self, ref, user=None, repo=None): + """Get a reference. + + .. note:: + Remember that branch references look like "heads/<branch_name>" + + """ + return self._get( + self.make_request('git_data.references.get', ref=ref, user=user, + repo=repo) + ) + + def list(self, namespace='', user=None, repo=None): + """List all the references + + :param str namespace: Limit the request to a particular type of + reference. For example, ``heads`` or ``tags``. + + """ + return self._get( + self.make_request('git_data.references.list', user=user, repo=repo) + ) + + def create(self, body, user=None, repo=None): + """Create a reference + + :param dict body: Data describing the reference to create + :param str user: username + :param str repo: repository name + + """ + return self._post( + self.make_request('git_data.references.create', body=body, + user=user, repo=repo) + ) + + def update(self, ref, body, user=None, repo=None): + """Update an existing reference + + :param str ref: The SHA of the reference to update + :param dict body: data + + """ + return self._patch( + self.make_request('git_data.references.update', ref=ref, body=body, + user=user, repo=repo) + ) + + def delete(self, ref, user=None, repo=None): + """Delete a reference + + :param str ref: The SHA of the reference to delete + + """ + return self._delete( + self.make_request('git_data.references.delete', ref=ref, user=user, + repo=repo) + ) |