aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/services/repos/forks.py
diff options
context:
space:
mode:
authorDavid Medina <davidmedina9@gmail.com>2012-03-01 19:57:59 +0100
committerDavid Medina <davidmedina9@gmail.com>2012-03-01 19:57:59 +0100
commitb891dfb211f9a58e5d834ccd148943286c45f61c (patch)
treec90ab9489c5217151c1f1c716aea8fa39b303393 /pygithub3/services/repos/forks.py
parentRepos.watchers service done (diff)
parentComplete services.repos doc (diff)
downloadpython-github3-b891dfb211f9a58e5d834ccd148943286c45f61c.tar.xz
python-github3-b891dfb211f9a58e5d834ccd148943286c45f61c.zip
Merge branch 'docs'
Diffstat (limited to 'pygithub3/services/repos/forks.py')
-rw-r--r--pygithub3/services/repos/forks.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/pygithub3/services/repos/forks.py b/pygithub3/services/repos/forks.py
new file mode 100644
index 0000000..df51347
--- /dev/null
+++ b/pygithub3/services/repos/forks.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+
+from . import Service
+
+
+class Forks(Service):
+ """ Consume `Forks API
+ <http://developer.github.com/v3/repos/forks>`_ """
+
+ def list(self, user=None, repo=None, sort='newest'):
+ """ Get repository's forks
+
+ :param str user: Username
+ :param str repo: Repository
+ :param str sort: Order resources (optional). See `github forks doc`_
+ :returns: A :doc:`result`
+
+ .. note::
+ Remember :ref:`config precedence`
+
+ ::
+
+ forks_service.list(user='octocat', repo='oct_repo', sort='oldest')
+ """
+ request = self.make_request('repos.forks.list', user=user, repo=repo)
+ return self._get_result(request, sort=sort)
+
+ def create(self, user=None, repo=None, org=None):
+ """ Fork a repository
+
+ :param str user: Username
+ :param str repo: Repository
+ :param str org: Organization name (optional)
+
+ .. note::
+ Remember :ref:`config precedence`
+
+ .. warning::
+ You must be authenticated
+
+ If you call it with ``org``, the repository will be forked into this
+ organization.
+ ::
+
+ forks_service.create(user='octocat', repo='oct_repo')
+ forks_service.create(user='octocat', repo='oct_repo',
+ org='myorganization'
+ """
+ request = self.make_request('repos.forks.create', user=user, repo=repo)
+ org = org and {'org': org} or {}
+ return self._post(request, **org)