summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects.py
diff options
context:
space:
mode:
authorMoritz Lipp <github@mlq.me>2017-11-13 15:12:36 +0100
committerMoritz Lipp <github@mlq.me>2017-11-13 15:12:36 +0100
commit34e32a0944b65583a57b97bf0124b8935ab49fa7 (patch)
treea3a220b5610057bf60f0ec47812b839e1bdb7821 /gitlab/v4/objects.py
parent9ede6529884e850532758ae218465c1b7584c2d4 (diff)
downloadgitlab-34e32a0944b65583a57b97bf0124b8935ab49fa7.tar.gz
Project pipeline schedules
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r--gitlab/v4/objects.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 85aba12..6a538e1 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -1764,6 +1764,65 @@ class ProjectPipelineManager(RetrieveMixin, CreateMixin, RESTManager):
return CreateMixin.create(self, data, path=path, **kwargs)
+class ProjectPipelineScheduleVariable(SaveMixin, ObjectDeleteMixin, RESTObject):
+ _id_attr = 'key'
+
+
+class ProjectPipelineScheduleVariableManager(CRUDMixin, RESTManager):
+ _path = '/projects/%(project_id)s/pipeline_schedules/%(pipeline_schedule_id)s/variables'
+ _obj_cls = ProjectPipelineScheduleVariable
+ _from_parent_attrs = {'project_id': 'project_id',
+ 'pipeline_schedule_id' : 'id'}
+ _create_attrs = (('pipeline_schedule_id', 'key', 'value'), tuple())
+ _create_attrs = (('key', 'value'), tuple())
+
+ def list(self):
+ array = []
+ if 'variables' in self._parent._attrs:
+ for variable in self._parent._attrs['variables']:
+ schedule_variable = self._obj_cls(self, variable)
+ array.append(schedule_variable)
+ else:
+ obj = self._parent.manager.get(self._parent.id)
+ for variable in obj._attrs['variables']:
+ schedule_variable = self._obj_cls(self, variable)
+ array.append(schedule_variable)
+
+ return array
+
+
+class ProjectPipelineSchedule(RESTObject):
+ _managers = (
+ ('variables', 'ProjectPipelineScheduleVariableManager'),
+ )
+
+
+class ProjectPipelineSchedulesManager(RetrieveMixin, CreateMixin, RESTManager):
+ _path = '/projects/%(project_id)s/pipeline_schedules'
+ _obj_cls = ProjectPipelineSchedule
+ _from_parent_attrs = {'project_id': 'id'}
+ _create_attrs = (('description', 'ref', 'cron'),
+ ('cron_timezone', 'active'))
+
+ def create(self, data, **kwargs):
+ """Creates a new object.
+
+ Args:
+ data (dict): Parameters to send to the server to create the
+ resource
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabCreateError: If the server cannot perform the request
+
+ Returns:
+ RESTObject: A new instance of the managed object class build with
+ the data sent by the server
+ """
+ return CreateMixin.create(self, data, path=self.path, **kwargs)
+
+
class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject):
pass
@@ -2035,6 +2094,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
('notificationsettings', 'ProjectNotificationSettingsManager'),
('pipelines', 'ProjectPipelineManager'),
('protectedbranches', 'ProjectProtectedBranchManager'),
+ ('pipeline_schedules', 'ProjectPipelineSchedulesManager'),
('runners', 'ProjectRunnerManager'),
('services', 'ProjectServiceManager'),
('snippets', 'ProjectSnippetManager'),