diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2015-12-31 22:30:07 +0100 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2015-12-31 22:30:07 +0100 |
commit | 937567b767e6d7b34dcaa1d9c83fc75464638683 (patch) | |
tree | 2e3dc598ddd4c06c8a0ce2d33a1d55f40fd61e7e /lib/api/variables.rb | |
parent | c5177dd5e2171b047a695802c979cf779522ba8a (diff) | |
download | gitlab-ce-937567b767e6d7b34dcaa1d9c83fc75464638683.tar.gz |
Add create feature to variables API
Diffstat (limited to 'lib/api/variables.rb')
-rw-r--r-- | lib/api/variables.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/api/variables.rb b/lib/api/variables.rb index dac2ba679c7..fc63ac2f56a 100644 --- a/lib/api/variables.rb +++ b/lib/api/variables.rb @@ -41,6 +41,24 @@ module API present variables.first, with: Entities::Variable end + # Create a new variable in project + # + # Parameters: + # id (required) - The ID of a project + # key (required) - The key of variable being created + # value (required) - The value of variable being created + # Example Request: + # POST /projects/:id/variables + post ':id/variables' do + required_attributes! [:key, :value] + + variable = user_project.variables.create(key: params[:key], value: params[:value]) + return render_validation_error!(variable) unless variable.valid? + variable.save! + + present variable, with: Entities::Variable + end + # Update existing variable of a project # # Parameters: @@ -75,6 +93,8 @@ module API return not_found!('Variable') unless variable variable.destroy + + present variable, with: Entities::Variable end end end |