aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/services/git_data/references.py
blob: 3a24f90189c78f4c68bbe10e4394fdee5ea477b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/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>"

        :param str ref: the name of the reference to get
        :param str user: Username
        :param str repo: Repository

        """
        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``.
        :param str user: Username
        :param str repo: Repository

        """
        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

        """
        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 to update the reference with
        :param str user: Username
        :param str repo: Repository

        """
        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
        :param str user: Username
        :param str repo: Repository

        """
        return self._delete(
            self.make_request('git_data.references.delete', ref=ref, user=user,
                              repo=repo)
        )