aboutsummaryrefslogtreecommitdiffstats
path: root/pygithub3/requests/pull_requests/comments.py
blob: fa1e5b61d1a72637b4d183a83e58b62a7120dc11 (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
from pygithub3.requests.base import Request
from pygithub3.resources.pull_requests import Comment


class List(Request):
    uri = 'repos/{user}/{repo}/pulls/{number}/comments'
    resource = Comment


class Get(Request):
    uri = 'repos/{user}/{repo}/pulls/comments/{number}'
    resource = Comment


class Create(Request):
    uri = 'repos/{user}/{repo}/pulls/{number}/comments'
    resource = Comment
    body_schema = {
        'schema': ('body', 'commit_id', 'path', 'position', 'in_reply_to'),
        'required': ('body',),
    }

    def validate_body(self, body):
        if (not ('commit_id' in body and
                 'path' in body and
                 'position' in body) and
            not 'in_reply_to' in body):
            raise ValidationError('supply either in_reply_to or commit_id, '
                                  'path, and position')


class Edit(Request):
    uri = 'repos/{user}/{repo}/pulls/comments/{number}'
    resource = Comment
    body_schema = {
        'schema': ('body',),
        'required': ('body',),
    }


class Delete(Request):
    uri = 'repos/{user}/{repo}/pulls/comments/{number}'
    resource = Comment