8000 feat: add project cluster api · erezu2/python-gitlab@9ebd9d0 · GitHub
[go: up one dir, main page]

Skip to content {"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}

Commit 9ebd9d0

Browse files
committed
feat: add project cluster api
1 parent 4efa6e6 commit 9ebd9d0

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

gitlab/tests/test_gitlab.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,40 @@ def resp_update_submodule(url, request):
770770
self.assertEqual(ret["message"], "Message")
771771
self.assertEqual(ret["id"], "ed899a2f4b50b4370feeea94676502b42383c746")
772772

773+
def test_todo_mark_all_as_done(self):
774+
@urlmatch(
775+
scheme="http",
776+
netloc="localhost",
777+
path="/api/v4/projects/1/clusters",
778+
method="get",
779+
)
780+
def resp_cluster_list(url, request):
781+
headers = {"content-type": "application/json"}
782+
return response(
783+
200,
784+
"""
785+
[{
786+
"id":18,
787+
"name":"cluster-1",
788+
"domain":"example.com",
789+
"created_at":"2019-01-02T20:18:12.563Z",
790+
"provider_type":"user",
791+
"platform_type":"kubernetes",
792+
"environment_scope":"*",
793+
"cluster_type":"project_type",
794+
"user": {},
795+
}]
796+
{}""",
797+
headers,
798+
None,
799+
5,
800+
request,
801+
)
802+
803+
with HTTMock(resp_cluster_list):
804+
project = self.gl.projects.get(1, lazy=True)
805+
project.clusters.list()
806+
773807
def _default_config(self):
774808
fd, temp_path = tempfile.mkstemp()
775809
os.write(fd, valid_config)

gitlab/v4/objects.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3897,6 +3897,16 @@ class ProjectImportManager(GetWithoutIdMixin, RESTManager):
38973897
_from_parent_attrs = {"project_id": "id"}
38983898

38993899

3900+
class ProjectCluster:
3901+
pass
3902+
3903+
3904+
class ProjectClusterManager(ListMixin, RestObject):
3905+
_path = "/projects/%(project_id)s/clusters"
3906+
_obj_cls = ProjectCluster
3907+
_from_parent_attrs = {"project_id": "id"}
3908+
390 7629 9+
39003910
class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
39013911
_short_print_attr = "path"
39023912
_managers = (
@@ -3906,6 +3916,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
39063916
("badges", "ProjectBadgeManager"),
39073917
("boards", "ProjectBoardManager"),
39083918
("branches", "ProjectBranchManager"),
3919+
("clusters", "ProjectClusterManager"),
39093920
("jobs", "ProjectJobManager"),
39103921
("commits", "ProjectCommitManager"),
39113922
("customattributes", "ProjectCustomAttributeManager"),

0 commit comments

Comments
 (0)
0