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-07 15:49:38 +0300
committerTomasz Maczukin <tomasz@maczukin.pl>2016-01-07 15:49:38 +0300
commitb60c146267dfa8dc1c170426e1817c6b2a168d1a (patch)
tree1eb9a3417f802616e884f68548576fdbb5beadf8 /lib/api/variables.rb
parent16bd4df083135e2e4a263b2e1bdd71b78a875ef7 (diff)
Change :variable_id to :key as resource ID in API
Diffstat (limited to 'lib/api/variables.rb')
-rw-r--r--lib/api/variables.rb41
1 files changed, 16 insertions, 25 deletions
diff --git a/lib/api/variables.rb b/lib/api/variables.rb
index b8bbcb6ce3b..cc038e5731d 100644
--- a/lib/api/variables.rb
+++ b/lib/api/variables.rb
@@ -22,19 +22,12 @@ module API
#
# Parameters:
# 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`
+ # key (required) - The `key` of variable
# Example Request:
- # GET /projects/:id/variables/:variable_id
- get ':id/variables/:variable_id' do
- variable_id = params[:variable_id]
- variables = user_project.variables
- variables =
- if variable_id.match(/^\d+$/)
- variables.where(id: variable_id.to_i)
- else
- variables.where(key: variable_id)
- end
+ # GET /projects/:id/variables/:key
+ get ':id/variables/:key' do
+ key = params[:key]
+ variables = user_project.variables.where(key: key)
return not_found!('Variable') if variables.empty?
@@ -45,8 +38,8 @@ module API
#
# Parameters:
# id (required) - The ID of a project
- # key (required) - The key of variable being created
- # value (required) - The value of variable being created
+ # key (required) - The key of variable
+ # value (required) - The value of variable
# Example Request:
# POST /projects/:id/variables
post ':id/variables' do
@@ -63,17 +56,15 @@ module API
#
# 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
+ # key (optional) - The `key` 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
+ # PUT /projects/:id/variables/:key
+ put ':id/variables/:key' do
+ variable = user_project.variables.where(key: params[:key]).first
return not_found!('Variable') unless variable
- variable.key = params[:key]
variable.value = params[:value]
variable.save!
@@ -84,11 +75,11 @@ module API
#
# Parameters:
# id (required) - The ID of a project
- # variable_id (required) - The ID of a variable
+ # key (required) - The ID of a variable
# Exanoke Reqyest:
- # DELETE /projects/:id/variables/:variable_id
- delete ':id/variables/:variable_id' do
- variable = user_project.variables.where(id: params[:variable_id].to_i).first
+ # DELETE /projects/:id/variables/:key
+ delete ':id/variables/:key' do
+ variable = user_project.variables.where(key: params[:key]).first
return not_found!('Variable') unless variable