Skip to content

Commit 34e32a0

Browse files
committed
Project pipeline schedules
1 parent 9ede652 commit 34e32a0

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

gitlab/v3/objects.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,18 @@ class ProjectFileManager(BaseManager):
14961496
obj_cls = ProjectFile
14971497

14981498

1499+
class ProjectPipelineSchedule(GitlabObject):
1500+
_url = '/projects/%(project_id)s/pipeline_schedules'
1501+
_create_url = '/projects/%(project_id)s/pipeline_schedules'
1502+
1503+
requiredUrlAttrs = ['project_id']
1504+
requiredCreateAttrs = ['description', 'ref', 'cron']
1505+
1506+
1507+
class ProjectPipelineSchedulesManager(BaseManager):
1508+
obj_cls = ProjectPipelineSchedule
1509+
1510+
14991511
class ProjectPipeline(GitlabObject):
15001512
_url = '/projects/%(project_id)s/pipelines'
15011513
_create_url = '/projects/%(project_id)s/pipeline'
@@ -1803,6 +1815,7 @@ class Project(GitlabObject):
18031815
('notificationsettings', 'ProjectNotificationSettingsManager',
18041816
[('project_id', 'id')]),
18051817
('pipelines', 'ProjectPipelineManager', [('project_id', 'id')]),
1818+
('pipeline_schedules', 'ProjectPipelineSchedulesManager', [('project_id', 'id')]),
18061819
('runners', 'ProjectRunnerManager', [('project_id', 'id')]),
18071820
('services', 'ProjectServiceManager', [('project_id', 'id')]),
18081821
('snippets', 'ProjectSnippetManager', [('project_id', 'id')]),

gitlab/v4/objects.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,65 @@ def create(self, data, **kwargs):
17641764
return CreateMixin.create(self, data, path=path, **kwargs)
17651765

17661766

1767+
class ProjectPipelineScheduleVariable(SaveMixin, ObjectDeleteMixin, RESTObject):
1768+
_id_attr = 'key'
1769+
1770+
1771+
class ProjectPipelineScheduleVariableManager(CRUDMixin, RESTManager):
1772+
_path = '/projects/%(project_id)s/pipeline_schedules/%(pipeline_schedule_id)s/variables'
1773+
_obj_cls = ProjectPipelineScheduleVariable
1774+
_from_parent_attrs = {'project_id': 'project_id',
1775+
'pipeline_schedule_id' : 'id'}
1776+
_create_attrs = (('pipeline_schedule_id', 'key', 'value'), tuple())
1777+
_create_attrs = (('key', 'value'), tuple())
1778+
1779+
def list(self):
1780+
array = []
1781+
if 'variables' in self._parent._attrs:
1782+
for variable in self._parent._attrs['variables']:
1783+
schedule_variable = self._obj_cls(self, variable)
1784+
array.append(schedule_variable)
1785+
else:
1786+
obj = self._parent.manager.get(self._parent.id)
1787+
for variable in obj._attrs['variables']:
1788+
schedule_variable = self._obj_cls(self, variable)
1789+
array.append(schedule_variable)
1790+
1791+
return array
1792+
1793+
1794+
class ProjectPipelineSchedule(RESTObject):
1795+
_managers = (
1796+
('variables', 'ProjectPipelineScheduleVariableManager'),
1797+
)
1798+
1799+
1800+
class ProjectPipelineSchedulesManager(RetrieveMixin, CreateMixin, RESTManager):
1801+
_path = '/projects/%(project_id)s/pipeline_schedules'
1802+
_obj_cls = ProjectPipelineSchedule
1803+
_from_parent_attrs = {'project_id': 'id'}
1804+
_create_attrs = (('description', 'ref', 'cron'),
1805+
('cron_timezone', 'active'))
1806+
1807+
def create(self, data, **kwargs):
1808+
"""Creates a new object.
1809+
1810+
Args:
1811+
data (dict): Parameters to send to the server to create the
1812+
resource
1813+
**kwargs: Extra options to send to the server (e.g. sudo)
1814+
1815+
Raises:
1816+
GitlabAuthenticationError: If authentication is not correct
1817+
GitlabCreateError: If the server cannot perform the request
1818+
1819+
Returns:
1820+
RESTObject: A new instance of the managed object class build with
1821+
the data sent by the server
1822+
"""
1823+
return CreateMixin.create(self, data, path=self.path, **kwargs)
1824+
1825+
17671826
class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject):
17681827
pass
17691828

@@ -2035,6 +2094,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
20352094
('notificationsettings', 'ProjectNotificationSettingsManager'),
20362095
('pipelines', 'ProjectPipelineManager'),
20372096
('protectedbranches', 'ProjectProtectedBranchManager'),
2097+
('pipeline_schedules', 'ProjectPipelineSchedulesManager'),
20382098
('runners', 'ProjectRunnerManager'),
20392099
('services', 'ProjectServiceManager'),
20402100
('snippets', 'ProjectSnippetManager'),

0 commit comments

Comments
 (0)