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>2016-01-01 00:30:07 +0300
committerTomasz Maczukin <tomasz@maczukin.pl>2016-01-01 00:30:07 +0300
commit937567b767e6d7b34dcaa1d9c83fc75464638683 (patch)
tree2e3dc598ddd4c06c8a0ce2d33a1d55f40fd61e7e /lib/api/variables.rb
parentc5177dd5e2171b047a695802c979cf779522ba8a (diff)
Add create feature to variables API
Diffstat (limited to 'lib/api/variables.rb')
-rw-r--r--lib/api/variables.rb20
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