Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
df548285
Commit
df548285
authored
Jan 13, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some fixes after review
parent
efb3395b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
13 deletions
+16
-13
lib/api/variables.rb
lib/api/variables.rb
+16
-13
No files found.
lib/api/variables.rb
View file @
df548285
...
@@ -27,11 +27,11 @@ module API
...
@@ -27,11 +27,11 @@ module API
# GET /projects/:id/variables/:key
# GET /projects/:id/variables/:key
get
':id/variables/:key'
do
get
':id/variables/:key'
do
key
=
params
[
:key
]
key
=
params
[
:key
]
variable
s
=
user_project
.
variables
.
where
(
key:
key
)
variable
=
user_project
.
variables
.
find_by
(
key:
key
.
to_s
)
return
not_found!
(
'Variable'
)
if
variables
.
empty?
return
not_found!
(
'Variable'
)
unless
variable
present
variable
s
.
first
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Variable
end
end
# Create a new variable in project
# Create a new variable in project
...
@@ -46,10 +46,12 @@ module API
...
@@ -46,10 +46,12 @@ module API
required_attributes!
[
:key
,
:value
]
required_attributes!
[
:key
,
:value
]
variable
=
user_project
.
variables
.
create
(
key:
params
[
:key
],
value:
params
[
: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
if
variable
.
valid?
present
variable
,
with:
Entities
::
Variable
else
render_validation_error!
(
variable
)
end
end
end
# Update existing variable of a project
# Update existing variable of a project
...
@@ -61,14 +63,16 @@ module API
...
@@ -61,14 +63,16 @@ module API
# Example Request:
# Example Request:
# PUT /projects/:id/variables/:key
# PUT /projects/:id/variables/:key
put
':id/variables/:key'
do
put
':id/variables/:key'
do
variable
=
user_project
.
variables
.
where
(
key:
params
[
:key
]).
first
variable
=
user_project
.
variables
.
find_by
(
key:
params
[
:key
].
to_s
)
return
not_found!
(
'Variable'
)
unless
variable
return
not_found!
(
'Variable'
)
unless
variable
variable
.
value
=
params
[
:value
]
attrs
=
attributes_for_keys
[
:value
]
variable
.
save!
if
variable
.
update
(
attrs
)
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Variable
else
render_validation_error!
(
variable
)
end
end
end
# Delete existing variable of a project
# Delete existing variable of a project
...
@@ -79,10 +83,9 @@ module API
...
@@ -79,10 +83,9 @@ module API
# Exanoke Reqyest:
# Exanoke Reqyest:
# DELETE /projects/:id/variables/:key
# DELETE /projects/:id/variables/:key
delete
':id/variables/:key'
do
delete
':id/variables/:key'
do
variable
=
user_project
.
variables
.
where
(
key:
params
[
:key
]).
first
variable
=
user_project
.
variables
.
find_by
(
key:
params
[
:key
].
to_s
)
return
not_found!
(
'Variable'
)
unless
variable
return
not_found!
(
'Variable'
)
unless
variable
variable
.
destroy
variable
.
destroy
present
variable
,
with:
Entities
::
Variable
present
variable
,
with:
Entities
::
Variable
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment