Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
Noah
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Noah
Commits
e8c7e089
Commit
e8c7e089
authored
Jan 22, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API changes
parent
c331b2ed
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
app.rb
app.rb
+6
-7
No files found.
app.rb
View file @
e8c7e089
...
@@ -56,7 +56,7 @@ namespace "/h" do
...
@@ -56,7 +56,7 @@ namespace "/h" do
end
end
end
end
put
'/?'
do
put
'/
:hostname/
?'
do
required_params
=
[
"name"
,
"status"
]
required_params
=
[
"name"
,
"status"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
.
keys
.
sort
==
required_params
.
sort
?
(
host
=
Host
.
find_or_create
(:
name
=>
data
[
'name'
],
:status
=>
data
[
'status'
]))
:
(
raise
"Missing Parameters"
)
data
.
keys
.
sort
==
required_params
.
sort
?
(
host
=
Host
.
find_or_create
(:
name
=>
data
[
'name'
],
:status
=>
data
[
'status'
]))
:
(
raise
"Missing Parameters"
)
...
@@ -74,7 +74,7 @@ namespace "/h" do
...
@@ -74,7 +74,7 @@ namespace "/h" do
services
=
[]
services
=
[]
Service
.
find
(
:host_id
=>
host
.
id
).
sort
.
each
{
|
x
|
services
<<
x
;
x
.
delete
}
if
host
.
services
.
size
>
0
Service
.
find
(
:host_id
=>
host
.
id
).
sort
.
each
{
|
x
|
services
<<
x
;
x
.
delete
}
if
host
.
services
.
size
>
0
host
.
delete
host
.
delete
r
=
{
"result"
=>
"success"
,
"id"
=>
"
#{
host
.
id
}
"
,
"name"
=>
"
#{
host
.
name
}
"
,
"service_count"
=>
"
#{
services
.
size
}
"
}
r
=
{
"result"
=>
"success"
,
"id"
=>
"
#{
host
.
id
}
"
,
"name"
=>
"
#{
hostname
}
"
,
"service_count"
=>
"
#{
services
.
size
}
"
}
r
.
to_json
r
.
to_json
else
else
halt
404
halt
404
...
@@ -114,16 +114,15 @@ namespace "/s" do
...
@@ -114,16 +114,15 @@ namespace "/s" do
end
end
put
'/:servicename/?'
do
|
servicename
|
put
'/:servicename/?'
do
|
servicename
|
# NYI
# message format: {"status":"initial_status", "host":"hostname"}
# message format: {"status":"initial_status", "host":"hostname"}
required_params
=
[
"status"
,
"host"
]
required_params
=
[
"status"
,
"host"
,
"name"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
if
data
.
keys
.
sort
==
required_params
.
sort
if
data
.
keys
.
sort
==
required_params
.
sort
h
=
Host
.
find
(
:name
=>
data
[
'host'
]).
first
||
(
raise
"Invalid Host"
)
h
=
Host
.
find
(
:name
=>
data
[
'host'
]).
first
||
(
raise
"Invalid Host"
)
service
=
Service
.
create
(
:name
=>
servicename
,
:status
=>
data
[
'status'
],
:host
=>
h
)
service
=
Service
.
create
(
:name
=>
servicename
,
:status
=>
data
[
'status'
],
:host
=>
h
)
if
service
.
valid?
if
service
.
valid?
service
.
save
service
.
save
r
=
{
"action"
=>
"add"
,
"result"
=>
"success"
,
"id"
=>
service
.
id
}
r
=
{
"action"
=>
"add"
,
"result"
=>
"success"
,
"id"
=>
service
.
id
,
"host"
=>
h
.
name
,
"name"
=>
service
.
name
}
r
.
to_json
r
.
to_json
else
else
raise
"
#{
service
.
errors
}
"
raise
"
#{
service
.
errors
}
"
...
@@ -138,7 +137,7 @@ namespace "/s" do
...
@@ -138,7 +137,7 @@ namespace "/s" do
service
=
Service
.
find
(
:name
=>
servicename
,
:host_id
=>
host
.
id
).
first
||
(
halt
404
)
service
=
Service
.
find
(
:name
=>
servicename
,
:host_id
=>
host
.
id
).
first
||
(
halt
404
)
if
host
&&
service
if
host
&&
service
service
.
delete
service
.
delete
r
=
{
"action"
=>
"delete"
,
"result"
=>
"success"
,
"id"
=>
service
.
id
,
"host"
=>
host
.
name
}
r
=
{
"action"
=>
"delete"
,
"result"
=>
"success"
,
"id"
=>
service
.
id
,
"host"
=>
host
.
name
,
"service"
=>
servicename
}
r
.
to_json
r
.
to_json
else
else
halt
404
halt
404
...
@@ -272,7 +271,7 @@ namespace '/c' do
...
@@ -272,7 +271,7 @@ namespace '/c' do
config
=
Configuration
.
find
(
:name
=>
element
,
:application_id
=>
app
.
id
).
first
config
=
Configuration
.
find
(
:name
=>
element
,
:application_id
=>
app
.
id
).
first
if
config
if
config
config
.
delete
config
.
delete
r
=
{
"result"
=>
"success"
,
"id"
=>
"
#{
config
.
id
}
"
,
"
item"
=>
"
#{
appname
}
/
#{
element
}
"
}
r
=
{
"result"
=>
"success"
,
"id"
=>
"
#{
config
.
id
}
"
,
"
action"
=>
"delete"
,
"application"
=>
"
#{
app
.
name
}
"
,
"item"
=>
"
#{
element
}
"
}
r
.
to_json
r
.
to_json
else
else
halt
404
halt
404
...
...
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