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:
authorTomasz Maczukin <tomasz@maczukin.pl>2015-12-31 18:25:49 +0300
committerTomasz Maczukin <tomasz@maczukin.pl>2015-12-31 18:26:55 +0300
commita692ce1c079703c4f3947e1d0a29547189e94d0f (patch)
tree9a59e98e1143bf54fd877b3c7953dc5d40d898df /lib/api/variables.rb
parentea4777ff501e370a39ae30e76a955136afe3c1fa (diff)
Add update feature for variables API
Diffstat (limited to 'lib/api/variables.rb')
-rw-r--r--lib/api/variables.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/api/variables.rb b/lib/api/variables.rb
index 6517150f6f4..6522ecba70c 100644
--- a/lib/api/variables.rb
+++ b/lib/api/variables.rb
@@ -24,7 +24,7 @@ module API
# id (required) - The ID of a project
# variable_id (required) - The ID OR `key` of variable to show; if variable_id contains only digits it's treated
# as ID other ways it's treated as `key`
- # Example Reuest:
+ # Example Request:
# GET /projects/:id/variables/:variable_id
get ':id/variables/:variable_id' do
variable_id = params[:variable_id]
@@ -38,6 +38,25 @@ module API
present variables.first, with: Entities::Variable
end
+
+ # Update existing variable of a project
+ #
+ # Parameters:
+ # id (required) - The ID of a project
+ # variable_id (required) - The ID of a variable
+ # key (optional) - new value for `key` field of variable
+ # value (optional) - new value for `value` field of variable
+ # Example Request:
+ # PUT /projects/:id/variables/:variable_id
+ put ':id/variables/:variable_id' do
+ variable = user_project.variables.where(id: params[:variable_id].to_i).first
+
+ variable.key = params[:key]
+ variable.value = params[:value]
+ variable.save!
+
+ present variable, with: Entities::Variable
+ end
end
end
end