|
| 1 | +""" |
| 2 | +GitLab API: |
| 3 | +https://docs.gitlab.com/ee/api/projects.html |
| 4 | +https://docs.gitlab.com/ee/api/lint.html#validate-a-projects-ci-configuration |
| 5 | +""" |
1 | 6 | from typing import Any, Callable, cast, Dict, List, Optional, TYPE_CHECKING, Union |
2 | 7 |
|
3 | 8 | import requests |
|
9 | 14 | from gitlab.mixins import ( |
10 | 15 | CreateMixin, |
11 | 16 | CRUDMixin, |
| 17 | + GetMixin, |
12 | 18 | ListMixin, |
13 | 19 | ObjectDeleteMixin, |
14 | 20 | RefreshMixin, |
|
80 | 86 | "ProjectForkManager", |
81 | 87 | "ProjectRemoteMirror", |
82 | 88 | "ProjectRemoteMirrorManager", |
| 89 | + "ProjectCiLint", |
| 90 | + "ProjectCiLintManager", |
83 | 91 | ] |
84 | 92 |
|
85 | 93 |
|
@@ -141,6 +149,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO |
141 | 149 | badges: ProjectBadgeManager |
142 | 150 | boards: ProjectBoardManager |
143 | 151 | branches: ProjectBranchManager |
| 152 | + ci_lint: "ProjectCiLintManager" |
144 | 153 | clusters: ProjectClusterManager |
145 | 154 | commits: ProjectCommitManager |
146 | 155 | customattributes: ProjectCustomAttributeManager |
@@ -1013,3 +1022,27 @@ class ProjectRemoteMirrorManager(ListMixin, CreateMixin, UpdateMixin, RESTManage |
1013 | 1022 | required=("url",), optional=("enabled", "only_protected_branches") |
1014 | 1023 | ) |
1015 | 1024 | _update_attrs = RequiredOptional(optional=("enabled", "only_protected_branches")) |
| 1025 | + |
| 1026 | + |
| 1027 | +class ProjectCiLint(RESTObject): |
| 1028 | + pass |
| 1029 | + |
| 1030 | + |
| 1031 | +class ProjectCiLintManager(GetMixin, RESTManager): |
| 1032 | + _path = "/projects/{project_id}/ci/lint" |
| 1033 | + _obj_cls = ProjectCiLint |
| 1034 | + _from_parent_attrs = {"project_id": "id"} |
| 1035 | + # https://docs.gitlab.com/ee/api/lint.html#validate-a-projects-ci-configuration |
| 1036 | + |
| 1037 | + def get( |
| 1038 | + self, id: Optional[Union[int, str]] = None, lazy: bool = False, **kwargs: Any |
| 1039 | + ) -> ProjectCiLint: |
| 1040 | + if id is not None: |
| 1041 | + raise AttributeError("Unsupported attribute: id") |
| 1042 | + |
| 1043 | + if TYPE_CHECKING: |
| 1044 | + assert self.path is not None |
| 1045 | + server_data = self.gitlab.http_get(self.path, **kwargs) |
| 1046 | + if TYPE_CHECKING: |
| 1047 | + assert isinstance(server_data, dict) |
| 1048 | + return self._obj_cls(self, server_data) |
0 commit comments