Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-08-18 11:25:35 +0300
committerShinya Maeda <shinya@gitlab.com>2017-09-04 15:10:34 +0300
commit8ca5c333fd5170a900c7fa28b6bfcbe1a8bc6477 (patch)
tree4754644a463464ccda3dee28d7d822dc4110b404 /lib/api/pipeline_schedules.rb
parent970af9964ea9404942818d8c3394d2903955ed69 (diff)
Extend API: Pipeline Schedule Variable
Diffstat (limited to 'lib/api/pipeline_schedules.rb')
-rw-r--r--lib/api/pipeline_schedules.rb70
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/api/pipeline_schedules.rb b/lib/api/pipeline_schedules.rb
index ef01cbc7875..e82b974c8cd 100644
--- a/lib/api/pipeline_schedules.rb
+++ b/lib/api/pipeline_schedules.rb
@@ -119,6 +119,76 @@ module API
destroy_conditionally!(pipeline_schedule)
end
+
+ params do
+ requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule id'
+ end
+ resource :variables, requirements: { pipeline_schedule_id: %r{[^/]+} } do
+ desc 'Create a new pipeline schedule variable' do
+ success Entities::PipelineScheduleDetails
+ end
+ params do
+ requires :key, type: String, desc: 'The key of the variable'
+ requires :value, type: String, desc: 'The value of the variable'
+ end
+ post ':id/pipeline_schedules/:pipeline_schedule_id/variables' do
+ authorize! :read_pipeline_schedule, user_project
+
+ not_found!('PipelineSchedule') unless pipeline_schedule
+ authorize! :update_pipeline_schedule, pipeline_schedule
+
+ variable_params = declared_params(include_missing: false)
+ variable = pipeline_schedule.variables.create(variable_params)
+
+ if variable.persisted?
+ present variable, with: Entities::Variable
+ else
+ render_validation_error!(variable)
+ end
+ end
+
+ desc 'Edit a pipeline schedule variable' do
+ success Entities::PipelineScheduleDetails
+ end
+ params do
+ optional :key, type: String, desc: 'The key of the variable'
+ optional :value, type: String, desc: 'The value of the variable'
+ end
+ put ':id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do
+ authorize! :read_pipeline_schedule, user_project
+
+ not_found!('PipelineSchedule') unless pipeline_schedule
+ authorize! :update_pipeline_schedule, pipeline_schedule
+
+ variable = pipeline_schedule.variables.find_by(key: params[:key])
+ not_found!('Variable') unless variable
+
+ if variable.update(declared_params(include_missing: false))
+ present variable, with: Entities::Variable
+ else
+ render_validation_error!(variable)
+ end
+ end
+
+ desc 'Delete a pipeline schedule variable' do
+ success Entities::PipelineScheduleDetails
+ end
+ params do
+ requires :key, type: String, desc: 'The key of the variable'
+ end
+ delete ':id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do
+ authorize! :read_pipeline_schedule, user_project
+
+ not_found!('PipelineSchedule') unless pipeline_schedule
+ authorize! :admin_pipeline_schedule, pipeline_schedule
+
+ variable = pipeline_schedule.variables.find_by(key: params[:key])
+ not_found!('Variable') unless variable
+
+ status :accepted
+ present variable, with: Entities::Variable
+ end
+ end
end
helpers do