File size: 1,040 Bytes
4b445f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b9da50c
 
 
4b445f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b9da50c
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
"""GitHub webhook event payload schemas."""

from __future__ import annotations

from pydantic import BaseModel


class GitHubUser(BaseModel):
    login: str
    id: int


class GitHubRepo(BaseModel):
    id: int
    full_name: str
    private: bool
    default_branch: str = "main"


class PullRequestHead(BaseModel):
    sha: str
    ref: str


class PullRequest(BaseModel):
    number: int
    title: str
    state: str
    head: PullRequestHead
    draft: bool = False
    changed_files: int | None = None
    additions: int | None = None
    deletions: int | None = None


class PullRequestEvent(BaseModel):
    """GitHub pull_request webhook event."""

    action: str  # opened, synchronize, reopened, ready_for_review
    number: int
    pull_request: PullRequest
    repository: GitHubRepo
    sender: GitHubUser


class Installation(BaseModel):
    id: int


class PullRequestEventWithInstallation(PullRequestEvent):
    """Pull request event with GitHub App installation context."""

    installation: Installation | None = None