FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-gitlab-python-gitlab/gitlab/v4/objects/issues.py at master · alvistack/python-gitlab-python-gitlab · GitHub
alvistack
python-gitlab-python-gitlab
Repository navigation
Code
Pull requests
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-gitlab-python-gitlab
/
gitlab
/
v4
/
objects
/
issues.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
257 lines (224 loc) · 7.46 KB
Breadcrumbs
python-gitlab-python-gitlab
/
gitlab
/
v4
/
objects
/
issues.py
Copy path
File metadata and controls
257 lines (224 loc) · 7.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
from
gitlab
import
cli
from
gitlab
import
exceptions
as
exc
from
gitlab
import
types
from
gitlab
.
base
import
RequiredOptional
,
RESTManager
,
RESTObject
from
gitlab
.
mixins
import
(
CreateMixin
,
CRUDMixin
,
DeleteMixin
,
ListMixin
,
ObjectDeleteMixin
,
ParticipantsMixin
,
RetrieveMixin
,
SaveMixin
,
SubscribableMixin
,
TimeTrackingMixin
,
TodoMixin
,
UserAgentDetailMixin
,
)
from
.
award_emojis
import
ProjectIssueAwardEmojiManager
# noqa: F401
from
.
discussions
import
ProjectIssueDiscussionManager
# noqa: F401
from
.
events
import
(
# noqa: F401
ProjectIssueResourceLabelEventManager
,
ProjectIssueResourceMilestoneEventManager
,
ProjectIssueResourceStateEventManager
,
)
from
.
notes
import
ProjectIssueNoteManager
# noqa: F401
__all__
=
[
"Issue"
,
"IssueManager"
,
"GroupIssue"
,
"GroupIssueManager"
,
"ProjectIssue"
,
"ProjectIssueManager"
,
"ProjectIssueLink"
,
"ProjectIssueLinkManager"
,
]
class
Issue
(
RESTObject
):
_url
=
"/issues"
_short_print_attr
=
"title"
class
IssueManager
(
RetrieveMixin
,
RESTManager
):
_path
=
"/issues"
_obj_cls
=
Issue
_list_filters
=
(
"state"
,
"labels"
,
"milestone"
,
"scope"
,
"author_id"
,
"assignee_id"
,
"my_reaction_emoji"
,
"iids"
,
"order_by"
,
"sort"
,
"search"
,
"created_after"
,
"created_before"
,
"updated_after"
,
"updated_before"
,
)
_types
=
{
"iids"
:
types
.
ListAttribute
,
"labels"
:
types
.
ListAttribute
}
class
GroupIssue
(
RESTObject
):
pass
class
GroupIssueManager
(
ListMixin
,
RESTManager
):
_path
=
"/groups/%(group_id)s/issues"
_obj_cls
=
GroupIssue
_from_parent_attrs
=
{
"group_id"
:
"id"
}
_list_filters
=
(
"state"
,
"labels"
,
"milestone"
,
"order_by"
,
"sort"
,
"iids"
,
"author_id"
,
"assignee_id"
,
"my_reaction_emoji"
,
"search"
,
"created_after"
,
"created_before"
,
"updated_after"
,
"updated_before"
,
)
_types
=
{
"iids"
:
types
.
ListAttribute
,
"labels"
:
types
.
ListAttribute
}
class
ProjectIssue
(
UserAgentDetailMixin
,
SubscribableMixin
,
TodoMixin
,
TimeTrackingMixin
,
ParticipantsMixin
,
SaveMixin
,
ObjectDeleteMixin
,
RESTObject
,
):
_short_print_attr
=
"title"
_id_attr
=
"iid"
_managers
=
(
(
"awardemojis"
,
"ProjectIssueAwardEmojiManager"
),
(
"discussions"
,
"ProjectIssueDiscussionManager"
),
(
"links"
,
"ProjectIssueLinkManager"
),
(
"notes"
,
"ProjectIssueNoteManager"
),
(
"resourcelabelevents"
,
"ProjectIssueResourceLabelEventManager"
),
(
"resourcemilestoneevents"
,
"ProjectIssueResourceMilestoneEventManager"
),
(
"resourcestateevents"
,
"ProjectIssueResourceStateEventManager"
),
)
@
cli
.
register_custom_action
(
"ProjectIssue"
, (
"to_project_id"
,))
@
exc
.
on_http_error
(
exc
.
GitlabUpdateError
)
def
move
(
self
,
to_project_id
,
**
kwargs
):
"""Move the issue to another project.
Args:
to_project_id(int): ID of the target project
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabUpdateError: If the issue could not be moved
"""
path
=
"%s/%s/move"
%
(
self
.
manager
.
path
,
self
.
get_id
())
data
=
{
"to_project_id"
:
to_project_id
}
server_data
=
self
.
manager
.
gitlab
.
http_post
(
path
,
post_data
=
data
,
**
kwargs
)
self
.
_update_attrs
(
server_data
)
@
cli
.
register_custom_action
(
"ProjectIssue"
)
@
exc
.
on_http_error
(
exc
.
GitlabGetError
)
def
related_merge_requests
(
self
,
**
kwargs
):
"""List merge requests related to the issue.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabGetErrot: If the merge requests could not be retrieved
Returns:
list: The list of merge requests.
"""
path
=
"%s/%s/related_merge_requests"
%
(
self
.
manager
.
path
,
self
.
get_id
())
return
self
.
manager
.
gitlab
.
http_get
(
path
,
**
kwargs
)
@
cli
.
register_custom_action
(
"ProjectIssue"
)
@
exc
.
on_http_error
(
exc
.
GitlabGetError
)
def
closed_by
(
self
,
**
kwargs
):
"""List merge requests that will close the issue when merged.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabGetErrot: If the merge requests could not be retrieved
Returns:
list: The list of merge requests.
"""
path
=
"%s/%s/closed_by"
%
(
self
.
manager
.
path
,
self
.
get_id
())
return
self
.
manager
.
gitlab
.
http_get
(
path
,
**
kwargs
)
class
ProjectIssueManager
(
CRUDMixin
,
RESTManager
):
_path
=
"/projects/%(project_id)s/issues"
_obj_cls
=
ProjectIssue
_from_parent_attrs
=
{
"project_id"
:
"id"
}
_list_filters
=
(
"iids"
,
"state"
,
"labels"
,
"milestone"
,
"scope"
,
"author_id"
,
"assignee_id"
,
"my_reaction_emoji"
,
"order_by"
,
"sort"
,
"search"
,
"created_after"
,
"created_before"
,
"updated_after"
,
"updated_before"
,
)
_create_attrs
=
RequiredOptional
(
required
=
(
"title"
,),
optional
=
(
"description"
,
"confidential"
,
"assignee_ids"
,
"assignee_id"
,
"milestone_id"
,
"labels"
,
"created_at"
,
"due_date"
,
"merge_request_to_resolve_discussions_of"
,
"discussion_to_resolve"
,
),
)
_update_attrs
=
RequiredOptional
(
optional
=
(
"title"
,
"description"
,
"confidential"
,
"assignee_ids"
,
"assignee_id"
,
"milestone_id"
,
"labels"
,
"state_event"
,
"updated_at"
,
"due_date"
,
"discussion_locked"
,
),
)
_types
=
{
"iids"
:
types
.
ListAttribute
,
"labels"
:
types
.
ListAttribute
}
class
ProjectIssueLink
(
ObjectDeleteMixin
,
RESTObject
):
_id_attr
=
"issue_link_id"
class
ProjectIssueLinkManager
(
ListMixin
,
CreateMixin
,
DeleteMixin
,
RESTManager
):
_path
=
"/projects/%(project_id)s/issues/%(issue_iid)s/links"
_obj_cls
=
ProjectIssueLink
_from_parent_attrs
=
{
"project_id"
:
"project_id"
,
"issue_iid"
:
"iid"
}
_create_attrs
=
RequiredOptional
(
required
=
(
"target_project_id"
,
"target_issue_iid"
))
@
exc
.
on_http_error
(
exc
.
GitlabCreateError
)
def
create
(
self
,
data
,
**
kwargs
):
"""Create a new object.
Args:
data (dict): parameters to send to the server to create the
resource
**kwargs: Extra options to send to the server (e.g. sudo)
Returns:
RESTObject, RESTObject: The source and target issues
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server cannot perform the request
"""
self
.
_check_missing_create_attrs
(
data
)
server_data
=
self
.
gitlab
.
http_post
(
self
.
path
,
post_data
=
data
,
**
kwargs
)
source_issue
=
ProjectIssue
(
self
.
_parent
.
manager
,
server_data
[
"source_issue"
])
target_issue
=
ProjectIssue
(
self
.
_parent
.
manager
,
server_data
[
"target_issue"
])
return
source_issue
,
target_issue
Back
|
FazBrowse Home
|
New Git URL