diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2015-12-31 16:25:49 +0100 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2015-12-31 16:26:55 +0100 |
commit | a692ce1c079703c4f3947e1d0a29547189e94d0f (patch) | |
tree | 9a59e98e1143bf54fd877b3c7953dc5d40d898df /lib/api/variables.rb | |
parent | ea4777ff501e370a39ae30e76a955136afe3c1fa (diff) | |
download | gitlab-ce-a692ce1c079703c4f3947e1d0a29547189e94d0f.tar.gz |
Add update feature for variables API
Diffstat (limited to 'lib/api/variables.rb')
-rw-r--r-- | lib/api/variables.rb | 21 |
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 |