Skip to content

Commit 06a7021

Browse files
wip: feat: add Project CI Lint support
Add support for validating a project's CI configuration [1] TODO: Add docs [1] https://docs.gitlab.com/ee/api/lint.html#validate-a-projects-ci-configuration
1 parent 85a734f commit 06a7021

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

gitlab/v4/objects/projects.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
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+
"""
16
from typing import Any, Callable, cast, Dict, List, Optional, TYPE_CHECKING, Union
27

38
import requests
@@ -9,6 +14,7 @@
914
from gitlab.mixins import (
1015
CreateMixin,
1116
CRUDMixin,
17+
GetMixin,
1218
ListMixin,
1319
ObjectDeleteMixin,
1420
RefreshMixin,
@@ -80,6 +86,8 @@
8086
"ProjectForkManager",
8187
"ProjectRemoteMirror",
8288
"ProjectRemoteMirrorManager",
89+
"ProjectCiLint",
90+
"ProjectCiLintManager",
8391
]
8492

8593

@@ -141,6 +149,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
141149
badges: ProjectBadgeManager
142150
boards: ProjectBoardManager
143151
branches: ProjectBranchManager
152+
ci_lint: "ProjectCiLintManager"
144153
clusters: ProjectClusterManager
145154
commits: ProjectCommitManager
146155
customattributes: ProjectCustomAttributeManager
@@ -1013,3 +1022,27 @@ class ProjectRemoteMirrorManager(ListMixin, CreateMixin, UpdateMixin, RESTManage
10131022
required=("url",), optional=("enabled", "only_protected_branches")
10141023
)
10151024
_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

Comments
 (0)