python-gitlab 5.5.0__py3-none-any.whl → 6.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gitlab/__init__.py +0 -1
- gitlab/_backends/protocol.py +9 -13
- gitlab/_backends/requests_backend.py +12 -12
- gitlab/_version.py +1 -1
- gitlab/base.py +48 -48
- gitlab/cli.py +14 -24
- gitlab/client.py +114 -140
- gitlab/config.py +16 -17
- gitlab/exceptions.py +7 -5
- gitlab/mixins.py +154 -238
- gitlab/types.py +13 -14
- gitlab/utils.py +32 -43
- gitlab/v4/cli.py +50 -53
- gitlab/v4/objects/__init__.py +1 -0
- gitlab/v4/objects/access_requests.py +11 -3
- gitlab/v4/objects/appearance.py +12 -14
- gitlab/v4/objects/applications.py +5 -6
- gitlab/v4/objects/artifacts.py +10 -17
- gitlab/v4/objects/audit_events.py +4 -19
- gitlab/v4/objects/award_emojis.py +13 -57
- gitlab/v4/objects/badges.py +4 -19
- gitlab/v4/objects/boards.py +7 -27
- gitlab/v4/objects/branches.py +3 -15
- gitlab/v4/objects/broadcast_messages.py +3 -13
- gitlab/v4/objects/bulk_imports.py +6 -14
- gitlab/v4/objects/ci_lint.py +7 -13
- gitlab/v4/objects/cluster_agents.py +3 -13
- gitlab/v4/objects/clusters.py +13 -23
- gitlab/v4/objects/commits.py +23 -28
- gitlab/v4/objects/container_registry.py +13 -19
- gitlab/v4/objects/custom_attributes.py +16 -21
- gitlab/v4/objects/deploy_keys.py +22 -19
- gitlab/v4/objects/deploy_tokens.py +14 -32
- gitlab/v4/objects/deployments.py +13 -15
- gitlab/v4/objects/discussions.py +13 -29
- gitlab/v4/objects/draft_notes.py +4 -14
- gitlab/v4/objects/environments.py +13 -21
- gitlab/v4/objects/epics.py +14 -17
- gitlab/v4/objects/events.py +27 -79
- gitlab/v4/objects/export_import.py +7 -19
- gitlab/v4/objects/features.py +11 -12
- gitlab/v4/objects/files.py +23 -38
- gitlab/v4/objects/geo_nodes.py +7 -11
- gitlab/v4/objects/group_access_tokens.py +6 -13
- gitlab/v4/objects/groups.py +42 -37
- gitlab/v4/objects/hooks.py +4 -17
- gitlab/v4/objects/integrations.py +7 -18
- gitlab/v4/objects/invitations.py +12 -23
- gitlab/v4/objects/issues.py +21 -27
- gitlab/v4/objects/iterations.py +4 -8
- gitlab/v4/objects/job_token_scope.py +18 -14
- gitlab/v4/objects/jobs.py +17 -32
- gitlab/v4/objects/keys.py +8 -11
- gitlab/v4/objects/labels.py +19 -30
- gitlab/v4/objects/ldap.py +25 -9
- gitlab/v4/objects/member_roles.py +102 -0
- gitlab/v4/objects/members.py +11 -29
- gitlab/v4/objects/merge_request_approvals.py +47 -38
- gitlab/v4/objects/merge_requests.py +30 -40
- gitlab/v4/objects/merge_trains.py +3 -6
- gitlab/v4/objects/milestones.py +23 -29
- gitlab/v4/objects/namespaces.py +4 -10
- gitlab/v4/objects/notes.py +26 -69
- gitlab/v4/objects/notification_settings.py +5 -14
- gitlab/v4/objects/package_protection_rules.py +8 -8
- gitlab/v4/objects/packages.py +22 -37
- gitlab/v4/objects/pages.py +8 -14
- gitlab/v4/objects/personal_access_tokens.py +7 -10
- gitlab/v4/objects/pipelines.py +38 -47
- gitlab/v4/objects/project_access_tokens.py +6 -13
- gitlab/v4/objects/projects.py +54 -76
- gitlab/v4/objects/push_rules.py +13 -15
- gitlab/v4/objects/registry_protection_repository_rules.py +6 -7
- gitlab/v4/objects/registry_protection_rules.py +7 -11
- gitlab/v4/objects/releases.py +6 -20
- gitlab/v4/objects/repositories.py +25 -34
- gitlab/v4/objects/resource_groups.py +10 -15
- gitlab/v4/objects/reviewers.py +4 -2
- gitlab/v4/objects/runners.py +14 -13
- gitlab/v4/objects/secure_files.py +8 -21
- gitlab/v4/objects/service_accounts.py +7 -5
- gitlab/v4/objects/settings.py +13 -14
- gitlab/v4/objects/sidekiq.py +17 -18
- gitlab/v4/objects/snippets.py +78 -66
- gitlab/v4/objects/statistics.py +8 -23
- gitlab/v4/objects/status_checks.py +6 -3
- gitlab/v4/objects/tags.py +3 -13
- gitlab/v4/objects/templates.py +11 -59
- gitlab/v4/objects/todos.py +3 -6
- gitlab/v4/objects/topics.py +10 -21
- gitlab/v4/objects/triggers.py +3 -13
- gitlab/v4/objects/users.py +87 -93
- gitlab/v4/objects/variables.py +4 -19
- gitlab/v4/objects/wikis.py +4 -19
- {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info}/METADATA +3 -2
- python_gitlab-6.0.0.dist-info/RECORD +107 -0
- {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info}/WHEEL +1 -1
- python_gitlab-5.5.0.dist-info/RECORD +0 -106
- {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info}/entry_points.txt +0 -0
- {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info/licenses}/AUTHORS +0 -0
- {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info/licenses}/COPYING +0 -0
- {python_gitlab-5.5.0.dist-info → python_gitlab-6.0.0.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,9 @@
|
|
1
|
-
from
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
from typing import Any, TYPE_CHECKING
|
2
4
|
|
3
5
|
from gitlab import exceptions as exc
|
4
|
-
from gitlab.base import
|
6
|
+
from gitlab.base import RESTObject
|
5
7
|
from gitlab.mixins import (
|
6
8
|
CreateMixin,
|
7
9
|
CRUDMixin,
|
@@ -16,6 +18,8 @@ from gitlab.mixins import (
|
|
16
18
|
from gitlab.types import RequiredOptional
|
17
19
|
|
18
20
|
__all__ = [
|
21
|
+
"GroupApprovalRule",
|
22
|
+
"GroupApprovalRuleManager",
|
19
23
|
"ProjectApproval",
|
20
24
|
"ProjectApprovalManager",
|
21
25
|
"ProjectApprovalRule",
|
@@ -29,11 +33,32 @@ __all__ = [
|
|
29
33
|
]
|
30
34
|
|
31
35
|
|
36
|
+
class GroupApprovalRule(SaveMixin, RESTObject):
|
37
|
+
_id_attr = "id"
|
38
|
+
_repr_attr = "name"
|
39
|
+
|
40
|
+
|
41
|
+
class GroupApprovalRuleManager(
|
42
|
+
RetrieveMixin[GroupApprovalRule],
|
43
|
+
CreateMixin[GroupApprovalRule],
|
44
|
+
UpdateMixin[GroupApprovalRule],
|
45
|
+
):
|
46
|
+
_path = "/groups/{group_id}/approval_rules"
|
47
|
+
_obj_cls = GroupApprovalRule
|
48
|
+
_from_parent_attrs = {"group_id": "id"}
|
49
|
+
_create_attrs = RequiredOptional(
|
50
|
+
required=("name", "approvals_required"),
|
51
|
+
optional=("user_ids", "group_ids", "rule_type"),
|
52
|
+
)
|
53
|
+
|
54
|
+
|
32
55
|
class ProjectApproval(SaveMixin, RESTObject):
|
33
56
|
_id_attr = None
|
34
57
|
|
35
58
|
|
36
|
-
class ProjectApprovalManager(
|
59
|
+
class ProjectApprovalManager(
|
60
|
+
GetWithoutIdMixin[ProjectApproval], UpdateMixin[ProjectApproval]
|
61
|
+
):
|
37
62
|
_path = "/projects/{project_id}/approvals"
|
38
63
|
_obj_cls = ProjectApproval
|
39
64
|
_from_parent_attrs = {"project_id": "id"}
|
@@ -44,13 +69,10 @@ class ProjectApprovalManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
|
|
44
69
|
"disable_overriding_approvers_per_merge_request",
|
45
70
|
"merge_requests_author_approval",
|
46
71
|
"merge_requests_disable_committers_approval",
|
47
|
-
)
|
72
|
+
)
|
48
73
|
)
|
49
74
|
_update_method = UpdateMethod.POST
|
50
75
|
|
51
|
-
def get(self, **kwargs: Any) -> ProjectApproval:
|
52
|
-
return cast(ProjectApproval, super().get(**kwargs))
|
53
|
-
|
54
76
|
|
55
77
|
class ProjectApprovalRule(SaveMixin, ObjectDeleteMixin, RESTObject):
|
56
78
|
_id_attr = "id"
|
@@ -58,7 +80,10 @@ class ProjectApprovalRule(SaveMixin, ObjectDeleteMixin, RESTObject):
|
|
58
80
|
|
59
81
|
|
60
82
|
class ProjectApprovalRuleManager(
|
61
|
-
RetrieveMixin,
|
83
|
+
RetrieveMixin[ProjectApprovalRule],
|
84
|
+
CreateMixin[ProjectApprovalRule],
|
85
|
+
UpdateMixin[ProjectApprovalRule],
|
86
|
+
DeleteMixin[ProjectApprovalRule],
|
62
87
|
):
|
63
88
|
_path = "/projects/{project_id}/approval_rules"
|
64
89
|
_obj_cls = ProjectApprovalRule
|
@@ -68,35 +93,30 @@ class ProjectApprovalRuleManager(
|
|
68
93
|
optional=("user_ids", "group_ids", "protected_branch_ids", "usernames"),
|
69
94
|
)
|
70
95
|
|
71
|
-
def get(
|
72
|
-
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
|
73
|
-
) -> ProjectApprovalRule:
|
74
|
-
return cast(ProjectApprovalRule, super().get(id=id, lazy=lazy, **kwargs))
|
75
|
-
|
76
96
|
|
77
97
|
class ProjectMergeRequestApproval(SaveMixin, RESTObject):
|
78
98
|
_id_attr = None
|
79
99
|
|
80
100
|
|
81
|
-
class ProjectMergeRequestApprovalManager(
|
101
|
+
class ProjectMergeRequestApprovalManager(
|
102
|
+
GetWithoutIdMixin[ProjectMergeRequestApproval],
|
103
|
+
UpdateMixin[ProjectMergeRequestApproval],
|
104
|
+
):
|
82
105
|
_path = "/projects/{project_id}/merge_requests/{mr_iid}/approvals"
|
83
106
|
_obj_cls = ProjectMergeRequestApproval
|
84
107
|
_from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"}
|
85
108
|
_update_attrs = RequiredOptional(required=("approvals_required",))
|
86
109
|
_update_method = UpdateMethod.POST
|
87
110
|
|
88
|
-
def get(self, **kwargs: Any) -> ProjectMergeRequestApproval:
|
89
|
-
return cast(ProjectMergeRequestApproval, super().get(**kwargs))
|
90
|
-
|
91
111
|
@exc.on_http_error(exc.GitlabUpdateError)
|
92
112
|
def set_approvers(
|
93
113
|
self,
|
94
114
|
approvals_required: int,
|
95
|
-
approver_ids:
|
96
|
-
approver_group_ids:
|
115
|
+
approver_ids: list[int] | None = None,
|
116
|
+
approver_group_ids: list[int] | None = None,
|
97
117
|
approval_rule_name: str = "name",
|
98
118
|
*,
|
99
|
-
approver_usernames:
|
119
|
+
approver_usernames: list[str] | None = None,
|
100
120
|
**kwargs: Any,
|
101
121
|
) -> RESTObject:
|
102
122
|
"""Change MR-level allowed approvers and approver groups.
|
@@ -145,17 +165,14 @@ class ProjectMergeRequestApprovalRule(SaveMixin, ObjectDeleteMixin, RESTObject):
|
|
145
165
|
_repr_attr = "name"
|
146
166
|
|
147
167
|
|
148
|
-
class ProjectMergeRequestApprovalRuleManager(
|
168
|
+
class ProjectMergeRequestApprovalRuleManager(
|
169
|
+
CRUDMixin[ProjectMergeRequestApprovalRule]
|
170
|
+
):
|
149
171
|
_path = "/projects/{project_id}/merge_requests/{merge_request_iid}/approval_rules"
|
150
172
|
_obj_cls = ProjectMergeRequestApprovalRule
|
151
173
|
_from_parent_attrs = {"project_id": "project_id", "merge_request_iid": "iid"}
|
152
174
|
_update_attrs = RequiredOptional(
|
153
|
-
required=(
|
154
|
-
"id",
|
155
|
-
"merge_request_iid",
|
156
|
-
"name",
|
157
|
-
"approvals_required",
|
158
|
-
),
|
175
|
+
required=("id", "merge_request_iid", "name", "approvals_required"),
|
159
176
|
optional=("user_ids", "group_ids", "usernames"),
|
160
177
|
)
|
161
178
|
# Important: When approval_project_rule_id is set, the name, users and
|
@@ -166,22 +183,14 @@ class ProjectMergeRequestApprovalRuleManager(CRUDMixin, RESTManager):
|
|
166
183
|
optional=("approval_project_rule_id", "user_ids", "group_ids", "usernames"),
|
167
184
|
)
|
168
185
|
|
169
|
-
def get(
|
170
|
-
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
|
171
|
-
) -> ProjectMergeRequestApprovalRule:
|
172
|
-
return cast(
|
173
|
-
ProjectMergeRequestApprovalRule, super().get(id=id, lazy=lazy, **kwargs)
|
174
|
-
)
|
175
|
-
|
176
186
|
|
177
187
|
class ProjectMergeRequestApprovalState(RESTObject):
|
178
188
|
pass
|
179
189
|
|
180
190
|
|
181
|
-
class ProjectMergeRequestApprovalStateManager(
|
191
|
+
class ProjectMergeRequestApprovalStateManager(
|
192
|
+
GetWithoutIdMixin[ProjectMergeRequestApprovalState]
|
193
|
+
):
|
182
194
|
_path = "/projects/{project_id}/merge_requests/{mr_iid}/approval_state"
|
183
195
|
_obj_cls = ProjectMergeRequestApprovalState
|
184
196
|
_from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"}
|
185
|
-
|
186
|
-
def get(self, **kwargs: Any) -> ProjectMergeRequestApprovalState:
|
187
|
-
return cast(ProjectMergeRequestApprovalState, super().get(**kwargs))
|
@@ -4,7 +4,9 @@ https://docs.gitlab.com/ee/api/merge_requests.html
|
|
4
4
|
https://docs.gitlab.com/ee/api/merge_request_approvals.html
|
5
5
|
"""
|
6
6
|
|
7
|
-
from
|
7
|
+
from __future__ import annotations
|
8
|
+
|
9
|
+
from typing import Any, TYPE_CHECKING
|
8
10
|
|
9
11
|
import requests
|
10
12
|
|
@@ -12,7 +14,7 @@ import gitlab
|
|
12
14
|
from gitlab import cli
|
13
15
|
from gitlab import exceptions as exc
|
14
16
|
from gitlab import types
|
15
|
-
from gitlab.base import
|
17
|
+
from gitlab.base import RESTObject, RESTObjectList
|
16
18
|
from gitlab.mixins import (
|
17
19
|
CRUDMixin,
|
18
20
|
ListMixin,
|
@@ -64,7 +66,7 @@ class MergeRequest(RESTObject):
|
|
64
66
|
pass
|
65
67
|
|
66
68
|
|
67
|
-
class MergeRequestManager(ListMixin
|
69
|
+
class MergeRequestManager(ListMixin[MergeRequest]):
|
68
70
|
_path = "/merge_requests"
|
69
71
|
_obj_cls = MergeRequest
|
70
72
|
_list_filters = (
|
@@ -111,7 +113,7 @@ class GroupMergeRequest(RESTObject):
|
|
111
113
|
pass
|
112
114
|
|
113
115
|
|
114
|
-
class GroupMergeRequestManager(ListMixin
|
116
|
+
class GroupMergeRequestManager(ListMixin[GroupMergeRequest]):
|
115
117
|
_path = "/groups/{group_id}/merge_requests"
|
116
118
|
_obj_cls = GroupMergeRequest
|
117
119
|
_from_parent_attrs = {"group_id": "id"}
|
@@ -159,7 +161,7 @@ class ProjectMergeRequest(
|
|
159
161
|
approval_state: ProjectMergeRequestApprovalStateManager
|
160
162
|
approvals: ProjectMergeRequestApprovalManager
|
161
163
|
awardemojis: ProjectMergeRequestAwardEmojiManager
|
162
|
-
diffs:
|
164
|
+
diffs: ProjectMergeRequestDiffManager
|
163
165
|
discussions: ProjectMergeRequestDiscussionManager
|
164
166
|
draft_notes: ProjectMergeRequestDraftNoteManager
|
165
167
|
notes: ProjectMergeRequestNoteManager
|
@@ -172,7 +174,7 @@ class ProjectMergeRequest(
|
|
172
174
|
|
173
175
|
@cli.register_custom_action(cls_names="ProjectMergeRequest")
|
174
176
|
@exc.on_http_error(exc.GitlabMROnBuildSuccessError)
|
175
|
-
def cancel_merge_when_pipeline_succeeds(self, **kwargs: Any) ->
|
177
|
+
def cancel_merge_when_pipeline_succeeds(self, **kwargs: Any) -> dict[str, str]:
|
176
178
|
"""Cancel merge when the pipeline succeeds.
|
177
179
|
|
178
180
|
Args:
|
@@ -201,11 +203,11 @@ class ProjectMergeRequest(
|
|
201
203
|
|
202
204
|
@cli.register_custom_action(cls_names="ProjectMergeRequest")
|
203
205
|
@exc.on_http_error(exc.GitlabListError)
|
204
|
-
def related_issues(self, **kwargs: Any) -> RESTObjectList:
|
206
|
+
def related_issues(self, **kwargs: Any) -> RESTObjectList[ProjectIssue]:
|
205
207
|
"""List issues related to this merge request."
|
206
208
|
|
207
209
|
Args:
|
208
|
-
|
210
|
+
get_all: If True, return all the items, without pagination
|
209
211
|
per_page: Number of items to retrieve per request
|
210
212
|
page: ID of the page to return (starts with page 1)
|
211
213
|
**kwargs: Extra options to send to the server (e.g. sudo)
|
@@ -230,11 +232,11 @@ class ProjectMergeRequest(
|
|
230
232
|
|
231
233
|
@cli.register_custom_action(cls_names="ProjectMergeRequest")
|
232
234
|
@exc.on_http_error(exc.GitlabListError)
|
233
|
-
def closes_issues(self, **kwargs: Any) -> RESTObjectList:
|
235
|
+
def closes_issues(self, **kwargs: Any) -> RESTObjectList[ProjectIssue]:
|
234
236
|
"""List issues that will close on merge."
|
235
237
|
|
236
238
|
Args:
|
237
|
-
|
239
|
+
get_all: If True, return all the items, without pagination
|
238
240
|
per_page: Number of items to retrieve per request
|
239
241
|
page: ID of the page to return (starts with page 1)
|
240
242
|
**kwargs: Extra options to send to the server (e.g. sudo)
|
@@ -255,11 +257,11 @@ class ProjectMergeRequest(
|
|
255
257
|
|
256
258
|
@cli.register_custom_action(cls_names="ProjectMergeRequest")
|
257
259
|
@exc.on_http_error(exc.GitlabListError)
|
258
|
-
def commits(self, **kwargs: Any) -> RESTObjectList:
|
260
|
+
def commits(self, **kwargs: Any) -> RESTObjectList[ProjectCommit]:
|
259
261
|
"""List the merge request commits.
|
260
262
|
|
261
263
|
Args:
|
262
|
-
|
264
|
+
get_all: If True, return all the items, without pagination
|
263
265
|
per_page: Number of items to retrieve per request
|
264
266
|
page: ID of the page to return (starts with page 1)
|
265
267
|
**kwargs: Extra options to send to the server (e.g. sudo)
|
@@ -283,7 +285,7 @@ class ProjectMergeRequest(
|
|
283
285
|
cls_names="ProjectMergeRequest", optional=("access_raw_diffs",)
|
284
286
|
)
|
285
287
|
@exc.on_http_error(exc.GitlabListError)
|
286
|
-
def changes(self, **kwargs: Any) ->
|
288
|
+
def changes(self, **kwargs: Any) -> dict[str, Any] | requests.Response:
|
287
289
|
"""List the merge request changes.
|
288
290
|
|
289
291
|
Args:
|
@@ -301,7 +303,7 @@ class ProjectMergeRequest(
|
|
301
303
|
|
302
304
|
@cli.register_custom_action(cls_names="ProjectMergeRequest", optional=("sha",))
|
303
305
|
@exc.on_http_error(exc.GitlabMRApprovalError)
|
304
|
-
def approve(self, sha:
|
306
|
+
def approve(self, sha: str | None = None, **kwargs: Any) -> dict[str, Any]:
|
305
307
|
"""Approve the merge request.
|
306
308
|
|
307
309
|
Args:
|
@@ -343,7 +345,7 @@ class ProjectMergeRequest(
|
|
343
345
|
https://docs.gitlab.com/ee/api/merge_request_approvals.html#unapprove-merge-request
|
344
346
|
"""
|
345
347
|
path = f"{self.manager.path}/{self.encoded_id}/unapprove"
|
346
|
-
data:
|
348
|
+
data: dict[str, Any] = {}
|
347
349
|
|
348
350
|
server_data = self.manager.gitlab.http_post(path, post_data=data, **kwargs)
|
349
351
|
if TYPE_CHECKING:
|
@@ -352,7 +354,7 @@ class ProjectMergeRequest(
|
|
352
354
|
|
353
355
|
@cli.register_custom_action(cls_names="ProjectMergeRequest")
|
354
356
|
@exc.on_http_error(exc.GitlabMRRebaseError)
|
355
|
-
def rebase(self, **kwargs: Any) ->
|
357
|
+
def rebase(self, **kwargs: Any) -> dict[str, Any] | requests.Response:
|
356
358
|
"""Attempt to rebase the source branch onto the target branch
|
357
359
|
|
358
360
|
Args:
|
@@ -363,14 +365,12 @@ class ProjectMergeRequest(
|
|
363
365
|
GitlabMRRebaseError: If rebasing failed
|
364
366
|
"""
|
365
367
|
path = f"{self.manager.path}/{self.encoded_id}/rebase"
|
366
|
-
data:
|
368
|
+
data: dict[str, Any] = {}
|
367
369
|
return self.manager.gitlab.http_put(path, post_data=data, **kwargs)
|
368
370
|
|
369
371
|
@cli.register_custom_action(cls_names="ProjectMergeRequest")
|
370
372
|
@exc.on_http_error(exc.GitlabMRResetApprovalError)
|
371
|
-
def reset_approvals(
|
372
|
-
self, **kwargs: Any
|
373
|
-
) -> Union[Dict[str, Any], requests.Response]:
|
373
|
+
def reset_approvals(self, **kwargs: Any) -> dict[str, Any] | requests.Response:
|
374
374
|
"""Clear all approvals of the merge request.
|
375
375
|
|
376
376
|
Args:
|
@@ -381,12 +381,12 @@ class ProjectMergeRequest(
|
|
381
381
|
GitlabMRResetApprovalError: If reset approval failed
|
382
382
|
"""
|
383
383
|
path = f"{self.manager.path}/{self.encoded_id}/reset_approvals"
|
384
|
-
data:
|
384
|
+
data: dict[str, Any] = {}
|
385
385
|
return self.manager.gitlab.http_put(path, post_data=data, **kwargs)
|
386
386
|
|
387
387
|
@cli.register_custom_action(cls_names="ProjectMergeRequest")
|
388
388
|
@exc.on_http_error(exc.GitlabGetError)
|
389
|
-
def merge_ref(self, **kwargs: Any) ->
|
389
|
+
def merge_ref(self, **kwargs: Any) -> dict[str, Any] | requests.Response:
|
390
390
|
"""Attempt to merge changes between source and target branches into
|
391
391
|
`refs/merge-requests/:iid/merge`.
|
392
392
|
|
@@ -410,11 +410,11 @@ class ProjectMergeRequest(
|
|
410
410
|
@exc.on_http_error(exc.GitlabMRClosedError)
|
411
411
|
def merge(
|
412
412
|
self,
|
413
|
-
merge_commit_message:
|
414
|
-
should_remove_source_branch:
|
415
|
-
merge_when_pipeline_succeeds:
|
413
|
+
merge_commit_message: str | None = None,
|
414
|
+
should_remove_source_branch: bool | None = None,
|
415
|
+
merge_when_pipeline_succeeds: bool | None = None,
|
416
416
|
**kwargs: Any,
|
417
|
-
) ->
|
417
|
+
) -> dict[str, Any]:
|
418
418
|
"""Accept the merge request.
|
419
419
|
|
420
420
|
Args:
|
@@ -430,7 +430,7 @@ class ProjectMergeRequest(
|
|
430
430
|
GitlabMRClosedError: If the merge failed
|
431
431
|
"""
|
432
432
|
path = f"{self.manager.path}/{self.encoded_id}/merge"
|
433
|
-
data:
|
433
|
+
data: dict[str, Any] = {}
|
434
434
|
if merge_commit_message:
|
435
435
|
data["merge_commit_message"] = merge_commit_message
|
436
436
|
if should_remove_source_branch is not None:
|
@@ -445,7 +445,7 @@ class ProjectMergeRequest(
|
|
445
445
|
return server_data
|
446
446
|
|
447
447
|
|
448
|
-
class ProjectMergeRequestManager(CRUDMixin
|
448
|
+
class ProjectMergeRequestManager(CRUDMixin[ProjectMergeRequest]):
|
449
449
|
_path = "/projects/{project_id}/merge_requests"
|
450
450
|
_obj_cls = ProjectMergeRequest
|
451
451
|
_from_parent_attrs = {"project_id": "id"}
|
@@ -485,7 +485,7 @@ class ProjectMergeRequestManager(CRUDMixin, RESTManager):
|
|
485
485
|
"allow_maintainer_to_push",
|
486
486
|
"squash",
|
487
487
|
"reviewer_ids",
|
488
|
-
)
|
488
|
+
)
|
489
489
|
)
|
490
490
|
_list_filters = (
|
491
491
|
"state",
|
@@ -517,11 +517,6 @@ class ProjectMergeRequestManager(CRUDMixin, RESTManager):
|
|
517
517
|
"labels": types.CommaSeparatedListAttribute,
|
518
518
|
}
|
519
519
|
|
520
|
-
def get(
|
521
|
-
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
|
522
|
-
) -> ProjectMergeRequest:
|
523
|
-
return cast(ProjectMergeRequest, super().get(id=id, lazy=lazy, **kwargs))
|
524
|
-
|
525
520
|
|
526
521
|
class ProjectDeploymentMergeRequest(MergeRequest):
|
527
522
|
pass
|
@@ -537,12 +532,7 @@ class ProjectMergeRequestDiff(RESTObject):
|
|
537
532
|
pass
|
538
533
|
|
539
534
|
|
540
|
-
class ProjectMergeRequestDiffManager(RetrieveMixin
|
535
|
+
class ProjectMergeRequestDiffManager(RetrieveMixin[ProjectMergeRequestDiff]):
|
541
536
|
_path = "/projects/{project_id}/merge_requests/{mr_iid}/versions"
|
542
537
|
_obj_cls = ProjectMergeRequestDiff
|
543
538
|
_from_parent_attrs = {"project_id": "project_id", "mr_iid": "iid"}
|
544
|
-
|
545
|
-
def get(
|
546
|
-
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
|
547
|
-
) -> ProjectMergeRequestDiff:
|
548
|
-
return cast(ProjectMergeRequestDiff, super().get(id=id, lazy=lazy, **kwargs))
|
@@ -1,17 +1,14 @@
|
|
1
|
-
from gitlab.base import
|
1
|
+
from gitlab.base import RESTObject
|
2
2
|
from gitlab.mixins import ListMixin
|
3
3
|
|
4
|
-
__all__ = [
|
5
|
-
"ProjectMergeTrain",
|
6
|
-
"ProjectMergeTrainManager",
|
7
|
-
]
|
4
|
+
__all__ = ["ProjectMergeTrain", "ProjectMergeTrainManager"]
|
8
5
|
|
9
6
|
|
10
7
|
class ProjectMergeTrain(RESTObject):
|
11
8
|
pass
|
12
9
|
|
13
10
|
|
14
|
-
class ProjectMergeTrainManager(ListMixin
|
11
|
+
class ProjectMergeTrainManager(ListMixin[ProjectMergeTrain]):
|
15
12
|
_path = "/projects/{project_id}/merge_trains"
|
16
13
|
_obj_cls = ProjectMergeTrain
|
17
14
|
_from_parent_attrs = {"project_id": "id"}
|
gitlab/v4/objects/milestones.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
from typing import Any,
|
1
|
+
from typing import Any, TYPE_CHECKING
|
2
2
|
|
3
3
|
from gitlab import cli
|
4
4
|
from gitlab import exceptions as exc
|
5
5
|
from gitlab import types
|
6
|
-
from gitlab.base import
|
6
|
+
from gitlab.base import RESTObject, RESTObjectList
|
7
|
+
from gitlab.client import GitlabList
|
7
8
|
from gitlab.mixins import (
|
8
9
|
CRUDMixin,
|
9
10
|
ObjectDeleteMixin,
|
@@ -16,6 +17,7 @@ from gitlab.types import RequiredOptional
|
|
16
17
|
from .issues import GroupIssue, GroupIssueManager, ProjectIssue, ProjectIssueManager
|
17
18
|
from .merge_requests import (
|
18
19
|
GroupMergeRequest,
|
20
|
+
GroupMergeRequestManager,
|
19
21
|
ProjectMergeRequest,
|
20
22
|
ProjectMergeRequestManager,
|
21
23
|
)
|
@@ -33,11 +35,11 @@ class GroupMilestone(SaveMixin, ObjectDeleteMixin, RESTObject):
|
|
33
35
|
|
34
36
|
@cli.register_custom_action(cls_names="GroupMilestone")
|
35
37
|
@exc.on_http_error(exc.GitlabListError)
|
36
|
-
def issues(self, **kwargs: Any) -> RESTObjectList:
|
38
|
+
def issues(self, **kwargs: Any) -> RESTObjectList[GroupIssue]:
|
37
39
|
"""List issues related to this milestone.
|
38
40
|
|
39
41
|
Args:
|
40
|
-
|
42
|
+
get_all: If True, return all the items, without pagination
|
41
43
|
per_page: Number of items to retrieve per request
|
42
44
|
page: ID of the page to return (starts with page 1)
|
43
45
|
**kwargs: Extra options to send to the server (e.g. sudo)
|
@@ -53,18 +55,18 @@ class GroupMilestone(SaveMixin, ObjectDeleteMixin, RESTObject):
|
|
53
55
|
path = f"{self.manager.path}/{self.encoded_id}/issues"
|
54
56
|
data_list = self.manager.gitlab.http_list(path, iterator=True, **kwargs)
|
55
57
|
if TYPE_CHECKING:
|
56
|
-
assert isinstance(data_list,
|
58
|
+
assert isinstance(data_list, GitlabList)
|
57
59
|
manager = GroupIssueManager(self.manager.gitlab, parent=self.manager._parent)
|
58
60
|
# FIXME(gpocentek): the computed manager path is not correct
|
59
61
|
return RESTObjectList(manager, GroupIssue, data_list)
|
60
62
|
|
61
63
|
@cli.register_custom_action(cls_names="GroupMilestone")
|
62
64
|
@exc.on_http_error(exc.GitlabListError)
|
63
|
-
def merge_requests(self, **kwargs: Any) -> RESTObjectList:
|
65
|
+
def merge_requests(self, **kwargs: Any) -> RESTObjectList[GroupMergeRequest]:
|
64
66
|
"""List the merge requests related to this milestone.
|
65
67
|
|
66
68
|
Args:
|
67
|
-
|
69
|
+
get_all: If True, return all the items, without pagination
|
68
70
|
per_page: Number of items to retrieve per request
|
69
71
|
page: ID of the page to return (starts with page 1)
|
70
72
|
**kwargs: Extra options to send to the server (e.g. sudo)
|
@@ -79,13 +81,15 @@ class GroupMilestone(SaveMixin, ObjectDeleteMixin, RESTObject):
|
|
79
81
|
path = f"{self.manager.path}/{self.encoded_id}/merge_requests"
|
80
82
|
data_list = self.manager.gitlab.http_list(path, iterator=True, **kwargs)
|
81
83
|
if TYPE_CHECKING:
|
82
|
-
assert isinstance(data_list,
|
83
|
-
manager =
|
84
|
+
assert isinstance(data_list, GitlabList)
|
85
|
+
manager = GroupMergeRequestManager(
|
86
|
+
self.manager.gitlab, parent=self.manager._parent
|
87
|
+
)
|
84
88
|
# FIXME(gpocentek): the computed manager path is not correct
|
85
89
|
return RESTObjectList(manager, GroupMergeRequest, data_list)
|
86
90
|
|
87
91
|
|
88
|
-
class GroupMilestoneManager(CRUDMixin
|
92
|
+
class GroupMilestoneManager(CRUDMixin[GroupMilestone]):
|
89
93
|
_path = "/groups/{group_id}/milestones"
|
90
94
|
_obj_cls = GroupMilestone
|
91
95
|
_from_parent_attrs = {"group_id": "id"}
|
@@ -93,16 +97,11 @@ class GroupMilestoneManager(CRUDMixin, RESTManager):
|
|
93
97
|
required=("title",), optional=("description", "due_date", "start_date")
|
94
98
|
)
|
95
99
|
_update_attrs = RequiredOptional(
|
96
|
-
optional=("title", "description", "due_date", "start_date", "state_event")
|
100
|
+
optional=("title", "description", "due_date", "start_date", "state_event")
|
97
101
|
)
|
98
102
|
_list_filters = ("iids", "state", "search")
|
99
103
|
_types = {"iids": types.ArrayAttribute}
|
100
104
|
|
101
|
-
def get(
|
102
|
-
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
|
103
|
-
) -> GroupMilestone:
|
104
|
-
return cast(GroupMilestone, super().get(id=id, lazy=lazy, **kwargs))
|
105
|
-
|
106
105
|
|
107
106
|
class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
|
108
107
|
_repr_attr = "title"
|
@@ -110,11 +109,11 @@ class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
|
|
110
109
|
|
111
110
|
@cli.register_custom_action(cls_names="ProjectMilestone")
|
112
111
|
@exc.on_http_error(exc.GitlabListError)
|
113
|
-
def issues(self, **kwargs: Any) -> RESTObjectList:
|
112
|
+
def issues(self, **kwargs: Any) -> RESTObjectList[ProjectIssue]:
|
114
113
|
"""List issues related to this milestone.
|
115
114
|
|
116
115
|
Args:
|
117
|
-
|
116
|
+
get_all: If True, return all the items, without pagination
|
118
117
|
per_page: Number of items to retrieve per request
|
119
118
|
page: ID of the page to return (starts with page 1)
|
120
119
|
**kwargs: Extra options to send to the server (e.g. sudo)
|
@@ -130,18 +129,18 @@ class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
|
|
130
129
|
path = f"{self.manager.path}/{self.encoded_id}/issues"
|
131
130
|
data_list = self.manager.gitlab.http_list(path, iterator=True, **kwargs)
|
132
131
|
if TYPE_CHECKING:
|
133
|
-
assert isinstance(data_list,
|
132
|
+
assert isinstance(data_list, GitlabList)
|
134
133
|
manager = ProjectIssueManager(self.manager.gitlab, parent=self.manager._parent)
|
135
134
|
# FIXME(gpocentek): the computed manager path is not correct
|
136
135
|
return RESTObjectList(manager, ProjectIssue, data_list)
|
137
136
|
|
138
137
|
@cli.register_custom_action(cls_names="ProjectMilestone")
|
139
138
|
@exc.on_http_error(exc.GitlabListError)
|
140
|
-
def merge_requests(self, **kwargs: Any) -> RESTObjectList:
|
139
|
+
def merge_requests(self, **kwargs: Any) -> RESTObjectList[ProjectMergeRequest]:
|
141
140
|
"""List the merge requests related to this milestone.
|
142
141
|
|
143
142
|
Args:
|
144
|
-
|
143
|
+
get_all: If True, return all the items, without pagination
|
145
144
|
per_page: Number of items to retrieve per request
|
146
145
|
page: ID of the page to return (starts with page 1)
|
147
146
|
**kwargs: Extra options to send to the server (e.g. sudo)
|
@@ -156,7 +155,7 @@ class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
|
|
156
155
|
path = f"{self.manager.path}/{self.encoded_id}/merge_requests"
|
157
156
|
data_list = self.manager.gitlab.http_list(path, iterator=True, **kwargs)
|
158
157
|
if TYPE_CHECKING:
|
159
|
-
assert isinstance(data_list,
|
158
|
+
assert isinstance(data_list, GitlabList)
|
160
159
|
manager = ProjectMergeRequestManager(
|
161
160
|
self.manager.gitlab, parent=self.manager._parent
|
162
161
|
)
|
@@ -164,7 +163,7 @@ class ProjectMilestone(PromoteMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
|
|
164
163
|
return RESTObjectList(manager, ProjectMergeRequest, data_list)
|
165
164
|
|
166
165
|
|
167
|
-
class ProjectMilestoneManager(CRUDMixin
|
166
|
+
class ProjectMilestoneManager(CRUDMixin[ProjectMilestone]):
|
168
167
|
_path = "/projects/{project_id}/milestones"
|
169
168
|
_obj_cls = ProjectMilestone
|
170
169
|
_from_parent_attrs = {"project_id": "id"}
|
@@ -173,12 +172,7 @@ class ProjectMilestoneManager(CRUDMixin, RESTManager):
|
|
173
172
|
optional=("description", "due_date", "start_date", "state_event"),
|
174
173
|
)
|
175
174
|
_update_attrs = RequiredOptional(
|
176
|
-
optional=("title", "description", "due_date", "start_date", "state_event")
|
175
|
+
optional=("title", "description", "due_date", "start_date", "state_event")
|
177
176
|
)
|
178
177
|
_list_filters = ("iids", "state", "search")
|
179
178
|
_types = {"iids": types.ArrayAttribute}
|
180
|
-
|
181
|
-
def get(
|
182
|
-
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
|
183
|
-
) -> ProjectMilestone:
|
184
|
-
return cast(ProjectMilestone, super().get(id=id, lazy=lazy, **kwargs))
|
gitlab/v4/objects/namespaces.py
CHANGED
@@ -1,29 +1,23 @@
|
|
1
|
-
from typing import Any,
|
1
|
+
from typing import Any, TYPE_CHECKING
|
2
2
|
|
3
3
|
from gitlab import cli
|
4
4
|
from gitlab import exceptions as exc
|
5
|
-
from gitlab.base import
|
5
|
+
from gitlab.base import RESTObject
|
6
6
|
from gitlab.mixins import RetrieveMixin
|
7
7
|
from gitlab.utils import EncodedId
|
8
8
|
|
9
|
-
__all__ = [
|
10
|
-
"Namespace",
|
11
|
-
"NamespaceManager",
|
12
|
-
]
|
9
|
+
__all__ = ["Namespace", "NamespaceManager"]
|
13
10
|
|
14
11
|
|
15
12
|
class Namespace(RESTObject):
|
16
13
|
pass
|
17
14
|
|
18
15
|
|
19
|
-
class NamespaceManager(RetrieveMixin
|
16
|
+
class NamespaceManager(RetrieveMixin[Namespace]):
|
20
17
|
_path = "/namespaces"
|
21
18
|
_obj_cls = Namespace
|
22
19
|
_list_filters = ("search",)
|
23
20
|
|
24
|
-
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Namespace:
|
25
|
-
return cast(Namespace, super().get(id=id, lazy=lazy, **kwargs))
|
26
|
-
|
27
21
|
@cli.register_custom_action(
|
28
22
|
cls_names="NamespaceManager", required=("namespace", "parent_id")
|
29
23
|
)
|