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
25e96169
Commit
25e96169
authored
Aug 04, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving tags out of primitive routes into helper
parent
17cacf42
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
2 additions
and
66 deletions
+2
-66
app.rb
lib/noah/app.rb
+1
-0
applications.rb
lib/noah/routes/applications.rb
+0
-16
configurations.rb
lib/noah/routes/configurations.rb
+1
-16
hosts.rb
lib/noah/routes/hosts.rb
+0
-18
services.rb
lib/noah/routes/services.rb
+0
-16
No files found.
lib/noah/app.rb
View file @
25e96169
...
@@ -5,6 +5,7 @@ require File.join(File.dirname(__FILE__), 'models')
...
@@ -5,6 +5,7 @@ require File.join(File.dirname(__FILE__), 'models')
module
Noah
module
Noah
class
App
<
Sinatra
::
Base
class
App
<
Sinatra
::
Base
helpers
Noah
::
SinatraBaseHelpers
helpers
Noah
::
SinatraBaseHelpers
helpers
Noah
::
SinatraTagHelpers
configure
do
configure
do
set
:app_file
,
__FILE__
set
:app_file
,
__FILE__
...
...
lib/noah/routes/applications.rb
View file @
25e96169
...
@@ -13,22 +13,6 @@ class Noah::App
...
@@ -13,22 +13,6 @@ class Noah::App
app
.
to_json
app
.
to_json
end
end
put
'/applications/:appname/tag'
do
|
appname
|
required_params
=
[
"tags"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
a
=
Noah
::
Application
.
find
(:
name
=>
appname
).
first
)
:
(
raise
"Missing Parameters"
)
a
.
nil?
?
(
halt
404
)
:
(
a
.
tag!
(
data
[
'tags'
]))
a
.
to_json
end
delete
'/applications/:appname/tag'
do
|
appname
|
required_params
=
[
"tags"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
a
=
Noah
::
Application
.
find
(:
name
=>
appname
).
first
)
:
(
raise
"Missing Parameters"
)
a
.
nil?
?
(
halt
404
)
:
(
a
.
untag!
(
data
[
'tags'
]))
a
.
to_json
end
put
'/applications/:appname/watch'
do
|
appname
|
put
'/applications/:appname/watch'
do
|
appname
|
required_params
=
[
"endpoint"
]
required_params
=
[
"endpoint"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
...
...
lib/noah/routes/configurations.rb
View file @
25e96169
...
@@ -31,22 +31,7 @@ class Noah::App
...
@@ -31,22 +31,7 @@ class Noah::App
a
.
nil?
?
(
halt
404
)
:
(
a
.
link!
data
[
"link_name"
])
a
.
nil?
?
(
halt
404
)
:
(
a
.
link!
data
[
"link_name"
])
a
.
to_json
a
.
to_json
end
end
# Add a tag to a configuration object
put
'/configurations/:configname/tag'
do
|
configname
|
required_params
=
[
"tags"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
c
=
Noah
::
Configuration
.
find
(:
name
=>
configname
).
first
)
:
(
raise
"Missing Parameters"
)
c
.
nil?
?
(
halt
404
)
:
(
c
.
tag!
(
data
[
'tags'
]))
c
.
to_json
end
# Delete a tag[s] from a configuration object
delete
'/configurations/:configname/tag'
do
|
configname
|
required_params
=
[
"tags"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
c
=
Noah
::
Configuration
.
find
(:
name
=>
configname
).
first
)
:
(
raise
"Missing Parameters"
)
c
.
nil?
?
(
halt
404
)
:
(
c
.
untag!
(
data
[
'tags'
]))
c
.
to_json
end
# Add a watch to a configuration object
# Add a watch to a configuration object
put
'/configurations/:configname/watch'
do
|
configname
|
put
'/configurations/:configname/watch'
do
|
configname
|
required_params
=
[
"endpoint"
]
required_params
=
[
"endpoint"
]
...
...
lib/noah/routes/hosts.rb
View file @
25e96169
...
@@ -32,24 +32,6 @@ class Noah::App
...
@@ -32,24 +32,6 @@ class Noah::App
end
end
end
end
put
'/hosts/:hostname/tag'
do
|
hostname
|
required_params
=
[
"tags"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
raise
"Missing parameters"
if
data
.
nil?
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
a
=
Noah
::
Host
.
find
(:
name
=>
hostname
).
first
)
:
(
raise
"Missing Parameters"
)
a
.
nil?
?
(
halt
404
)
:
(
a
.
tag!
(
data
[
'tags'
]))
a
.
to_json
end
delete
'/hosts/:hostname/tag'
do
|
hostname
|
required_params
=
[
"tags"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
raise
"Missing parameters"
if
data
.
nil?
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
a
=
Noah
::
Host
.
find
(:
name
=>
hostname
).
first
)
:
(
raise
"Missing Parameters"
)
a
.
nil?
?
(
halt
404
)
:
(
a
.
untag!
(
data
[
'tags'
]))
a
.
to_json
end
put
'/hosts/:hostname/watch'
do
|
hostname
|
put
'/hosts/:hostname/watch'
do
|
hostname
|
required_params
=
[
"endpoint"
]
required_params
=
[
"endpoint"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
...
...
lib/noah/routes/services.rb
View file @
25e96169
...
@@ -38,22 +38,6 @@ class Noah::App
...
@@ -38,22 +38,6 @@ class Noah::App
a
.
to_json
a
.
to_json
end
end
put
'/services/:servicename/:hostname/tag'
do
|
servicename
,
hostname
|
required_params
=
[
"tags"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
a
=
host_service
(
hostname
,
servicename
))
:
(
raise
"Missing Parameters"
)
a
.
nil?
?
(
halt
404
)
:
(
a
.
tag!
(
data
[
'tags'
]))
a
.
to_json
end
delete
'/services/:servicename/:hostname/tag'
do
|
servicename
,
hostname
|
required_params
=
[
"tags"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
(
data
.
keys
.
sort
==
required_params
.
sort
)
?
(
a
=
host_service
(
hostname
,
servicename
))
:
(
raise
"Missing Parameters"
)
a
.
nil?
?
(
halt
404
)
:
(
a
.
untag!
(
data
[
'tags'
]))
a
.
to_json
end
put
'/services/:servicename/watch'
do
|
servicename
|
put
'/services/:servicename/watch'
do
|
servicename
|
required_params
=
[
"endpoint"
]
required_params
=
[
"endpoint"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
=
JSON
.
parse
(
request
.
body
.
read
)
...
...
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