Commit 9ebd9d0c authored by Max Wittig's avatar Max Wittig 🌍
Browse files

feat: add project cluster api

parent 4efa6e6e
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -770,6 +770,40 @@ class TestGitlab(unittest.TestCase):
            self.assertEqual(ret["message"], "Message")
            self.assertEqual(ret["id"], "ed899a2f4b50b4370feeea94676502b42383c746")

    def test_todo_mark_all_as_done(self):
        @urlmatch(
            scheme="http",
            netloc="localhost",
            path="/api/v4/projects/1/clusters",
            method="get",
        )
        def resp_cluster_list(url, request):
            headers = {"content-type": "application/json"}
            return response(
                200,
                """
            [{
                "id":18,
                "name":"cluster-1",
                "domain":"example.com",
                "created_at":"2019-01-02T20:18:12.563Z",
                "provider_type":"user",
                "platform_type":"kubernetes",
                "environment_scope":"*",
                "cluster_type":"project_type",
                "user": {},
            }]
            {}""",
                headers,
                None,
                5,
                request,
            )

        with HTTMock(resp_cluster_list):
            project = self.gl.projects.get(1, lazy=True)
            project.clusters.list()

    def _default_config(self):
        fd, temp_path = tempfile.mkstemp()
        os.write(fd, valid_config)
+11 −0
Original line number Diff line number Diff line
@@ -3897,6 +3897,16 @@ class ProjectImportManager(GetWithoutIdMixin, RESTManager):
    _from_parent_attrs = {"project_id": "id"}


class ProjectCluster:
    pass


class ProjectClusterManager(ListMixin, RestObject):
    _path = "/projects/%(project_id)s/clusters"
    _obj_cls = ProjectCluster
    _from_parent_attrs = {"project_id": "id"}


class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
    _short_print_attr = "path"
    _managers = (
@@ -3906,6 +3916,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
        ("badges", "ProjectBadgeManager"),
        ("boards", "ProjectBoardManager"),
        ("branches", "ProjectBranchManager"),
        ("clusters", "ProjectClusterManager"),
        ("jobs", "ProjectJobManager"),
        ("commits", "ProjectCommitManager"),
        ("customattributes", "ProjectCustomAttributeManager"),