| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -193,6 +193,10 @@ class GitlabHousekeepingError(GitlabOperationError): | |||
| 193 | 193 | pass | |
| 194 | 194 | ||
| 195 | 195 | ||
| 196 | + class GitlabOwnershipError(GitlabOperationError): | ||
| 197 | + pass | ||
| 198 | + | ||
| 199 | + | ||
| 196 | 200 | def raise_error_from_response(response, error, expected_code=200): | |
| 197 | 201 | """Tries to parse gitlab error message from response and raises error. | |
| 198 | 202 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2012,6 +2012,55 @@ def create(self, data, **kwargs): | |||
| 2012 | 2012 | return CreateMixin.create(self, data, path=path, **kwargs) | |
| 2013 | 2013 | ||
| 2014 | 2014 | ||
| 2015 | + class ProjectPipelineScheduleVariable(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 2016 | + _id_attr = 'key' | ||
| 2017 | + | ||
| 2018 | + | ||
| 2019 | + class ProjectPipelineScheduleVariableManager(CreateMixin, UpdateMixin, | ||
| 2020 | + DeleteMixin, RESTManager): | ||
| 2021 | + _path = ('/projects/%(project_id)s/pipeline_schedules/' | ||
| 2022 | + '%(pipeline_schedule_id)s/variables') | ||
| 2023 | + _obj_cls = ProjectPipelineScheduleVariable | ||
| 2024 | + _from_parent_attrs = {'project_id': 'project_id', | ||
| 2025 | + 'pipeline_schedule_id' : 'id'} | ||
| 2026 | + _create_attrs = (('key', 'value'), tuple()) | ||
| 2027 | + _update_attrs = (('key', 'value'), tuple()) | ||
| 2028 | + | ||
| 2029 | + | ||
| 2030 | + class ProjectPipelineSchedule(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 2031 | + _managers = (('variables', 'ProjectPipelineScheduleVariableManager'),) | ||
| 2032 | + | ||
| 2033 | + @cli.register_custom_action('ProjectPipelineSchedule') | ||
| 2034 | + @exc.on_http_error(exc.GitlabOwnershipError) | ||
| 2035 | + def take_ownership(self, **kwargs): | ||
| 2036 | + """Update the owner of a pipeline schedule. | ||
| 2037 | + | ||
| 2038 | + Args: | ||
| 2039 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 2040 | + | ||
| 2041 | + Raises: | ||
| 2042 | + GitlabAuthenticationError: If authentication is not correct | ||
| 2043 | + GitlabOwnershipError: If the request failed | ||
| 2044 | + """ | ||
| 2045 | + path = '%s/%s/take_ownership' % (self.manager.path, self.get_id()) | ||
| 2046 | + server_data = self.manager.gitlab.http_post(path, **kwargs) | ||
| 2047 | + self._update_attrs(server_data) | ||
| 2048 | + | ||
| 2049 | + | ||
| 2050 | + class ProjectPipelineScheduleManager(CRUDMixin, RESTManager): | ||
| 2051 | + _path = '/projects/%(project_id)s/pipeline_schedules' | ||
| 2052 | + _obj_cls = ProjectPipelineSchedule | ||
| 2053 | + _from_parent_attrs = {'project_id': 'id'} | ||
| 2054 | + _create_attrs = (('description', 'ref', 'cron'), | ||
| 2055 | + ('cron_timezone', 'active')) | ||
| 2056 | + _update_attrs = (tuple(), | ||
| 2057 | + ('description', 'ref', 'cron', 'cron_timezone', 'active')) | ||
| 2058 | + | ||
| 2059 | + | ||
| 2060 | + class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 2061 | + pass | ||
| 2062 | + | ||
| 2063 | + | ||
| 2015 | 2064 | class ProjectPipelineJob(ProjectJob): | |
| 2016 | 2065 | pass | |
| 2017 | 2066 | ||
@@ -2106,8 +2155,17 @@ class ProjectSnippetManager(CRUDMixin, RESTManager): | |||
| 2106 | 2155 | ||
| 2107 | 2156 | class ProjectTrigger(SaveMixin, ObjectDeleteMixin, RESTObject): | |
| 2108 | 2157 | @cli.register_custom_action('ProjectTrigger') | |
| 2158 | + @exc.on_http_error(exc.GitlabOwnershipError) | ||
| 2109 | 2159 | def take_ownership(self, **kwargs): | |
| 2110 | - """Update the owner of a trigger.""" | ||
| 2160 | + """Update the owner of a trigger. | ||
| 2161 | + | ||
| 2162 | + Args: | ||
| 2163 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 2164 | + | ||
| 2165 | + Raises: | ||
| 2166 | + GitlabAuthenticationError: If authentication is not correct | ||
| 2167 | + GitlabOwnershipError: If the request failed | ||
| 2168 | + """ | ||
| 2111 | 2169 | path = '%s/%s/take_ownership' % (self.manager.path, self.get_id()) | |
| 2112 | 2170 | server_data = self.manager.gitlab.http_post(path, **kwargs) | |
| 2113 | 2171 | self._update_attrs(server_data) | |
@@ -2323,6 +2381,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject): | |||
| 2323 | 2381 | ('pagesdomains', 'ProjectPagesDomainManager'), | |
| 2324 | 2382 | ('pipelines', 'ProjectPipelineManager'), | |
| 2325 | 2383 | ('protectedbranches', 'ProjectProtectedBranchManager'), | |
| 2384 | + ('pipelineschedules', 'ProjectPipelineScheduleManager'), | ||
| 2326 | 2385 | ('runners', 'ProjectRunnerManager'), | |
| 2327 | 2386 | ('services', 'ProjectServiceManager'), | |
| 2328 | 2387 | ('snippets', 'ProjectSnippetManager'), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments