From 4039c8cfc6c7783270f0da1e235ef5d70b420ba9 Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Fri, 28 Aug 2020 21:40:04 +0200 Subject: chore: make latest black happy with existing code --- gitlab/v4/objects.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'gitlab/v4') diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 2a3615f..37c33e2 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -711,8 +711,14 @@ class ProjectDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager _from_parent_attrs = {"project_id": "id"} _obj_cls = ProjectDeployToken _create_attrs = ( - ("name", "scopes",), - ("expires_at", "username",), + ( + "name", + "scopes", + ), + ( + "expires_at", + "username", + ), ) @@ -725,8 +731,14 @@ class GroupDeployTokenManager(ListMixin, CreateMixin, DeleteMixin, RESTManager): _from_parent_attrs = {"group_id": "id"} _obj_cls = GroupDeployToken _create_attrs = ( - ("name", "scopes",), - ("expires_at", "username",), + ( + "name", + "scopes", + ), + ( + "expires_at", + "username", + ), ) @@ -4181,7 +4193,11 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM ), ), "jira": ( - ("url", "username", "password",), + ( + "url", + "username", + "password", + ), ( "api_url", "active", -- cgit v1.2.1 From b7a07fca775b278b1de7d5cb36c8421b7d9bebb7 Mon Sep 17 00:00:00 2001 From: Nejc Habjan Date: Fri, 28 Aug 2020 21:42:12 +0200 Subject: feat(api): add endpoint for latest ref artifacts --- gitlab/v4/objects.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'gitlab/v4') diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 37c33e2..5289635 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -5087,6 +5087,40 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject): path, post_data={"namespace": to_namespace}, **kwargs ) + @cli.register_custom_action("Project", ("ref_name", "job"), ("job_token",)) + @exc.on_http_error(exc.GitlabGetError) + def artifacts( + self, ref_name, job, streamed=False, action=None, chunk_size=1024, **kwargs + ): + """Get the job artifacts archive from a specific tag or branch. + + Args: + ref_name (str): Branch or tag name in repository. HEAD or SHA references + are not supported. + artifact_path (str): Path to a file inside the artifacts archive. + job (str): The name of the job. + job_token (str): Job token for multi-project pipeline triggers. + streamed (bool): If True the data will be processed by chunks of + `chunk_size` and each chunk is passed to `action` for + treatment + action (callable): Callable responsible of dealing with chunk of + data + chunk_size (int): Size of each chunk + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabGetError: If the artifacts could not be retrieved + + Returns: + str: The artifacts if `streamed` is False, None otherwise. + """ + path = "/projects/%s/jobs/artifacts/%s/download" % (self.get_id(), ref_name) + result = self.manager.gitlab.http_get( + path, job=job, streamed=streamed, raw=True, **kwargs + ) + return utils.response_content(result, streamed, action, chunk_size) + @cli.register_custom_action("Project", ("ref_name", "artifact_path", "job")) @exc.on_http_error(exc.GitlabGetError) def artifact( -- cgit v1.2.1