-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitlab_model.py
More file actions
147 lines (111 loc) · 3.28 KB
/
gitlab_model.py
File metadata and controls
147 lines (111 loc) · 3.28 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env python3
from typing import Any
from typing import Literal
from pydantic import BaseModel
from pydantic import Field
class GenericPayload(BaseModel, extra="allow"):
object_kind: Literal["test"]
class GLMRRepo(BaseModel, extra="allow"):
homepage: str
name: str
class GLUser(BaseModel, extra="allow"):
id: int
name: str
username: str
email: str
class GLProject(BaseModel, extra="allow"):
id: int
path_with_namespace: str
web_url: str
class GLMRAttributes(BaseModel, extra="allow"):
id: int # ID is this instance wide merge request id
iid: int # IID is this project's merge request id
title: str
created_at: str
draft: bool
state: str
url: str
action: str
updated_at: str
oldrev: str | None = None
# https://docs.gitlab.com/ee/api/merge_requests.html#merge-status
detailed_merge_status: str # mergeable, not_approved
head_pipeline_id: int | None
work_in_progress: bool
source_project_id: int
source_branch: str
target_project_id: int
target_branch: str
class MergeRequestPayload(BaseModel, extra="allow"):
object_kind: Literal["merge_request"]
event_type: str
repository: GLMRRepo
user: GLUser
project: GLProject
object_attributes: GLMRAttributes
changes: dict[str, dict[str, Any]]
assignees: list[GLUser] = Field(default_factory=list)
reviewers: list[GLUser] = Field(default_factory=list)
class GLPipelineBuild(BaseModel, extra="allow"):
id: int
stage: str
name: str
status: str
failure_reason: str | None
class GLPipelineAttributes(BaseModel, extra="allow"):
id: int
detailed_status: str
class PipelinePayload(BaseModel, extra="allow"):
object_kind: Literal["pipeline"]
object_attributes: GLPipelineAttributes
builds: list[GLPipelineBuild]
project: GLProject
class GLEmojiAttributes(BaseModel, extra="allow"):
id: int
user_id: int
name: str
awarded_on_url: str
awardable_type: str
class GLEmojiMRAttributes(BaseModel, extra="allow"):
id: int # ID is this instance wide merge request id
iid: int # IID is this project's merge request id
title: str
created_at: str
draft: bool
state: str
url: str
# https://docs.gitlab.com/ee/api/merge_requests.html#merge-status
detailed_merge_status: str # mergeable, not_approved
head_pipeline_id: int | None
work_in_progress: bool
source_project_id: int
source_branch: str
target_project_id: int
target_branch: str
class EmojiPayload(BaseModel, extra="allow"):
object_kind: Literal["emoji"]
event_type: Literal["award"] | Literal["revoke"]
user: GLUser
object_attributes: GLEmojiAttributes
merge_request: GLEmojiMRAttributes
class GLNoteAttributes(BaseModel, extra="allow"):
id: int
note: str
noteable_type: str
noteable_id: int
url: str
class GLNoteMRAttributes(BaseModel, extra="allow"):
id: int
iid: int
title: str
state: str
url: str
source_project_id: int
target_project_id: int
class NotePayload(BaseModel, extra="allow"):
object_kind: Literal["note"]
event_type: Literal["note"]
user: GLUser
project: GLProject
object_attributes: GLNoteAttributes
merge_request: GLNoteMRAttributes | None = None