Skip to content

Commit

Permalink
feat: add group runners api
Browse files Browse the repository at this point in the history
  • Loading branch information
max-wittig committed May 16, 2020
1 parent 74b3ddc commit 4943991
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docs/gl_objects/runners.rst
Expand Up @@ -78,7 +78,7 @@ Verify a registered runner token::
except GitlabVerifyError:
print("Invalid token")

Project runners
Project/Group runners
===============

Reference
Expand All @@ -89,6 +89,9 @@ Reference
+ :class:`gitlab.v4.objects.ProjectRunner`
+ :class:`gitlab.v4.objects.ProjectRunnerManager`
+ :attr:`gitlab.v4.objects.Project.runners`
+ :class:`gitlab.v4.objects.GroupRunner`
+ :class:`gitlab.v4.objects.GroupRunnerManager`
+ :attr:`gitlab.v4.objects.Group.runners`

* GitLab API: https://docs.gitlab.com/ce/api/runners.html

Expand Down
15 changes: 14 additions & 1 deletion gitlab/v4/objects.py
Expand Up @@ -1308,6 +1308,17 @@ class GroupProjectManager(ListMixin, RESTManager):
)


class GroupRunner(ObjectDeleteMixin, RESTObject):
pass


class GroupRunnerManager(NoUpdateMixin, RESTManager):
_path = "/groups/%(group_id)s/runners"
_obj_cls = GroupRunner
_from_parent_attrs = {"group_id": "id"}
_create_attrs = (("runner_id",), tuple())


class GroupSubgroup(RESTObject):
pass

Expand Down Expand Up @@ -1357,6 +1368,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject):
("milestones", "GroupMilestoneManager"),
("notificationsettings", "GroupNotificationSettingsManager"),
("projects", "GroupProjectManager"),
("runners", "GroupRunnerManager"),
("subgroups", "GroupSubgroupManager"),
("variables", "GroupVariableManager"),
("clusters", "GroupClusterManager"),
Expand Down Expand Up @@ -5382,7 +5394,8 @@ def all(self, scope=None, **kwargs):
query_data = {}
if scope is not None:
query_data["scope"] = scope
return self.gitlab.http_list(path, query_data, **kwargs)
obj = self.gitlab.http_list(path, query_data, **kwargs)
return [self._obj_cls(self, item) for item in obj]

@cli.register_custom_action("RunnerManager", ("token",))
@exc.on_http_error(exc.GitlabVerifyError)
Expand Down

0 comments on commit 4943991

Please sign in to comment.