summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-02-05 15:46:41 +0100
committerGauvain Pocentek <gauvain@pocentek.net>2018-02-05 15:46:41 +0100
commit39a04297d2661f82980f1b1921a3aba1ab1feb32 (patch)
tree763941f43fdcfd900c998b8a036c5354843eb9a8 /gitlab/v4/objects.py
parentfd726cdb61a78aafb780cae56a7909e7b648e4dc (diff)
parent6a87d38b0c5ffdfa9c78dcf5232ec78986010ce6 (diff)
downloadgitlab-39a04297d2661f82980f1b1921a3aba1ab1feb32.tar.gz
Merge branch 'mlq-feature/pipeline-schedules'
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r--gitlab/v4/objects.py75
1 files changed, 35 insertions, 40 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 19adb62..f6dcb08 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -2028,59 +2028,45 @@ class ProjectPipelineScheduleVariable(SaveMixin, ObjectDeleteMixin, RESTObject):
_id_attr = 'key'
-class ProjectPipelineScheduleVariableManager(CRUDMixin, RESTManager):
- _path = '/projects/%(project_id)s/pipeline_schedules/%(pipeline_schedule_id)s/variables'
+class ProjectPipelineScheduleVariableManager(CreateMixin, UpdateMixin,
+ DeleteMixin, 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())
+ _update_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(SaveMixin, ObjectDeleteMixin, RESTObject):
+ _managers = (('variables', 'ProjectPipelineScheduleVariableManager'),)
+ @cli.register_custom_action('ProjectPipelineSchedule')
+ @exc.on_http_error(exc.GitlabOwnershipError)
+ def take_ownership(self, **kwargs):
+ """Update the owner of a pipeline schedule.
-class ProjectPipelineSchedule(RESTObject):
- _managers = (
- ('variables', 'ProjectPipelineScheduleVariableManager'),
- )
+ Args:
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabOwnershipError: If the request failed
+ """
+ path = '%s/%s/take_ownership' % (self.manager.path, self.get_id())
+ server_data = self.manager.gitlab.http_post(path, **kwargs)
+ self._update_attrs(server_data)
-class ProjectPipelineSchedulesManager(RetrieveMixin, CreateMixin, RESTManager):
+class ProjectPipelineScheduleManager(CRUDMixin, 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)
+ _update_attrs = (tuple(),
+ ('description', 'ref', 'cron', 'cron_timezone', 'active'))
class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject):
@@ -2181,8 +2167,17 @@ class ProjectSnippetManager(CRUDMixin, RESTManager):
class ProjectTrigger(SaveMixin, ObjectDeleteMixin, RESTObject):
@cli.register_custom_action('ProjectTrigger')
+ @exc.on_http_error(exc.GitlabOwnershipError)
def take_ownership(self, **kwargs):
- """Update the owner of a trigger."""
+ """Update the owner of a trigger.
+
+ Args:
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabOwnershipError: If the request failed
+ """
path = '%s/%s/take_ownership' % (self.manager.path, self.get_id())
server_data = self.manager.gitlab.http_post(path, **kwargs)
self._update_attrs(server_data)
@@ -2398,7 +2393,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
('pagesdomains', 'ProjectPagesDomainManager'),
('pipelines', 'ProjectPipelineManager'),
('protectedbranches', 'ProjectProtectedBranchManager'),
- ('pipeline_schedules', 'ProjectPipelineSchedulesManager'),
+ ('pipelineschedules', 'ProjectPipelineScheduleManager'),
('runners', 'ProjectRunnerManager'),
('services', 'ProjectServiceManager'),
('snippets', 'ProjectSnippetManager'),