@@ -2028,59 +2028,45 @@ class ProjectPipelineScheduleVariable(SaveMixin, ObjectDeleteMixin, RESTObject):
20282028 _id_attr = 'key'
20292029
20302030
2031- class ProjectPipelineScheduleVariableManager (CRUDMixin , RESTManager ):
2032- _path = '/projects/%(project_id)s/pipeline_schedules/%(pipeline_schedule_id)s/variables'
2031+ class ProjectPipelineScheduleVariableManager (CreateMixin , UpdateMixin ,
2032+ DeleteMixin , RESTManager ):
2033+ _path = ('/projects/%(project_id)s/pipeline_schedules/'
2034+ '%(pipeline_schedule_id)s/variables' )
20332035 _obj_cls = ProjectPipelineScheduleVariable
20342036 _from_parent_attrs = {'project_id' : 'project_id' ,
20352037 'pipeline_schedule_id' : 'id' }
2036- _create_attrs = (('pipeline_schedule_id' , 'key' , 'value' ), tuple ())
20372038 _create_attrs = (('key' , 'value' ), tuple ())
2039+ _update_attrs = (('key' , 'value' ), tuple ())
20382040
2039- def list (self ):
2040- array = []
2041- if 'variables' in self ._parent ._attrs :
2042- for variable in self ._parent ._attrs ['variables' ]:
2043- schedule_variable = self ._obj_cls (self , variable )
2044- array .append (schedule_variable )
2045- else :
2046- obj = self ._parent .manager .get (self ._parent .id )
2047- for variable in obj ._attrs ['variables' ]:
2048- schedule_variable = self ._obj_cls (self , variable )
2049- array .append (schedule_variable )
20502041
2051- return array
2042+ class ProjectPipelineSchedule (SaveMixin , ObjectDeleteMixin , RESTObject ):
2043+ _managers = (('variables' , 'ProjectPipelineScheduleVariableManager' ),)
20522044
2045+ @cli .register_custom_action ('ProjectPipelineSchedule' )
2046+ @exc .on_http_error (exc .GitlabOwnershipError )
2047+ def take_ownership (self , ** kwargs ):
2048+ """Update the owner of a pipeline schedule.
20532049
2054- class ProjectPipelineSchedule (RESTObject ):
2055- _managers = (
2056- ('variables' , 'ProjectPipelineScheduleVariableManager' ),
2057- )
2050+ Args:
2051+ **kwargs: Extra options to send to the server (e.g. sudo)
2052+
2053+ Raises:
2054+ GitlabAuthenticationError: If authentication is not correct
2055+ GitlabOwnershipError: If the request failed
2056+ """
2057+ path = '%s/%s/take_ownership' % (self .manager .path , self .get_id ())
2058+ server_data = self .manager .gitlab .http_post (path , ** kwargs )
2059+ self ._update_attrs (server_data )
20582060
20592061
2060- class ProjectPipelineSchedulesManager ( RetrieveMixin , CreateMixin , RESTManager ):
2062+ class ProjectPipelineScheduleManager ( CRUDMixin , RESTManager ):
20612063 _path = '/projects/%(project_id)s/pipeline_schedules'
20622064 _obj_cls = ProjectPipelineSchedule
20632065 _from_parent_attrs = {'project_id' : 'id' }
20642066 _create_attrs = (('description' , 'ref' , 'cron' ),
20652067 ('cron_timezone' , 'active' ))
2066-
2067- def create (self , data , ** kwargs ):
2068- """Creates a new object.
2069-
2070- Args:
2071- data (dict): Parameters to send to the server to create the
2072- resource
2073- **kwargs: Extra options to send to the server (e.g. sudo)
2074-
2075- Raises:
2076- GitlabAuthenticationError: If authentication is not correct
2077- GitlabCreateError: If the server cannot perform the request
2078-
2079- Returns:
2080- RESTObject: A new instance of the managed object class build with
2081- the data sent by the server
2082- """
2083- return CreateMixin .create (self , data , path = self .path , ** kwargs )
2068+ _update_attrs = (tuple (),
2069+ ('description' , 'ref' , 'cron' , 'cron_timezone' , 'active' ))
20842070
20852071
20862072class ProjectSnippetNote (SaveMixin , ObjectDeleteMixin , RESTObject ):
@@ -2181,8 +2167,17 @@ class ProjectSnippetManager(CRUDMixin, RESTManager):
21812167
21822168class ProjectTrigger (SaveMixin , ObjectDeleteMixin , RESTObject ):
21832169 @cli .register_custom_action ('ProjectTrigger' )
2170+ @exc .on_http_error (exc .GitlabOwnershipError )
21842171 def take_ownership (self , ** kwargs ):
2185- """Update the owner of a trigger."""
2172+ """Update the owner of a trigger.
2173+
2174+ Args:
2175+ **kwargs: Extra options to send to the server (e.g. sudo)
2176+
2177+ Raises:
2178+ GitlabAuthenticationError: If authentication is not correct
2179+ GitlabOwnershipError: If the request failed
2180+ """
21862181 path = '%s/%s/take_ownership' % (self .manager .path , self .get_id ())
21872182 server_data = self .manager .gitlab .http_post (path , ** kwargs )
21882183 self ._update_attrs (server_data )
@@ -2398,7 +2393,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
23982393 ('pagesdomains' , 'ProjectPagesDomainManager' ),
23992394 ('pipelines' , 'ProjectPipelineManager' ),
24002395 ('protectedbranches' , 'ProjectProtectedBranchManager' ),
2401- ('pipeline_schedules ' , 'ProjectPipelineSchedulesManager ' ),
2396+ ('pipelineschedules ' , 'ProjectPipelineScheduleManager ' ),
24022397 ('runners' , 'ProjectRunnerManager' ),
24032398 ('services' , 'ProjectServiceManager' ),
24042399 ('snippets' , 'ProjectSnippetManager' ),
0 commit comments