Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit39a0429

Browse files
author
Gauvain Pocentek
committed
Merge branch 'mlq-feature/pipeline-schedules'
2 parentsfd726cd +6a87d38 commit39a0429

File tree

2 files changed

+39
-40
lines changed

2 files changed

+39
-40
lines changed

‎gitlab/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ class GitlabHousekeepingError(GitlabOperationError):
193193
pass
194194

195195

196+
classGitlabOwnershipError(GitlabOperationError):
197+
pass
198+
199+
196200
defraise_error_from_response(response,error,expected_code=200):
197201
"""Tries to parse gitlab error message from response and raises error.
198202

‎gitlab/v4/objects.py

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,59 +2028,45 @@ class ProjectPipelineScheduleVariable(SaveMixin, ObjectDeleteMixin, RESTObject):
20282028
_id_attr='key'
20292029

20302030

2031-
classProjectPipelineScheduleVariableManager(CRUDMixin,RESTManager):
2032-
_path='/projects/%(project_id)s/pipeline_schedules/%(pipeline_schedule_id)s/variables'
2031+
classProjectPipelineScheduleVariableManager(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-
deflist(self):
2040-
array= []
2041-
if'variables'inself._parent._attrs:
2042-
forvariableinself._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-
forvariableinobj._attrs['variables']:
2048-
schedule_variable=self._obj_cls(self,variable)
2049-
array.append(schedule_variable)
20502041

2051-
returnarray
2042+
classProjectPipelineSchedule(SaveMixin,ObjectDeleteMixin,RESTObject):
2043+
_managers= (('variables','ProjectPipelineScheduleVariableManager'),)
20522044

2045+
@cli.register_custom_action('ProjectPipelineSchedule')
2046+
@exc.on_http_error(exc.GitlabOwnershipError)
2047+
deftake_ownership(self,**kwargs):
2048+
"""Update the owner of a pipeline schedule.
20532049
2054-
classProjectPipelineSchedule(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-
classProjectPipelineSchedulesManager(RetrieveMixin,CreateMixin,RESTManager):
2062+
classProjectPipelineScheduleManager(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-
defcreate(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-
returnCreateMixin.create(self,data,path=self.path,**kwargs)
2068+
_update_attrs= (tuple(),
2069+
('description','ref','cron','cron_timezone','active'))
20842070

20852071

20862072
classProjectSnippetNote(SaveMixin,ObjectDeleteMixin,RESTObject):
@@ -2181,8 +2167,17 @@ class ProjectSnippetManager(CRUDMixin, RESTManager):
21812167

21822168
classProjectTrigger(SaveMixin,ObjectDeleteMixin,RESTObject):
21832169
@cli.register_custom_action('ProjectTrigger')
2170+
@exc.on_http_error(exc.GitlabOwnershipError)
21842171
deftake_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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp