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
dd40590f
Commit
dd40590f
authored
Apr 13, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quick reorg of route files
parent
f11cdec6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
32 additions
and
35 deletions
+32
-35
app.rb
lib/noah/app.rb
+8
-8
applications.rb
lib/noah/models/applications.rb
+1
-0
applications.rb
lib/noah/routes/applications.rb
+0
-0
configurations.rb
lib/noah/routes/configurations.rb
+23
-27
ephemerals.rb
lib/noah/routes/ephemerals.rb
+0
-0
hosts.rb
lib/noah/routes/hosts.rb
+0
-0
links.rb
lib/noah/routes/links.rb
+0
-0
services.rb
lib/noah/routes/services.rb
+0
-0
tags.rb
lib/noah/routes/tags.rb
+0
-0
watchers.rb
lib/noah/routes/watchers.rb
+0
-0
No files found.
lib/noah/app.rb
View file @
dd40590f
...
...
@@ -58,14 +58,14 @@ module Noah
erb
:'500'
end
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
tag_route
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
host_route
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
service_rout
es.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
application_route
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
configuration_route
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
watcher_route
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
ephemeral_route
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
link_route
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
routes/tag
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
routes/host
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
routes/servic
es.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
routes/application
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
routes/configuration
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
routes/watcher
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
routes/ephemeral
s.rb'
)
load
File
.
join
(
File
.
dirname
(
__FILE__
),
'
routes/link
s.rb'
)
end
end
lib/noah/models/applications.rb
View file @
dd40590f
...
...
@@ -7,6 +7,7 @@ module Noah
set
:configurations
,
Configuration
index
:name
index
:configurations
def
validate
super
...
...
lib/noah/
application_route
s.rb
→
lib/noah/
routes/application
s.rb
View file @
dd40590f
File moved
lib/noah/
configuration_route
s.rb
→
lib/noah/
routes/configuration
s.rb
View file @
dd40590f
...
...
@@ -5,35 +5,26 @@ class Noah::App
:xml
=>
"text/xml"
,
:string
=>
"text/plain"
}
# Configuration URIs
get
'/configurations/:appname/:element/?'
do
|
appname
,
element
|
a
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
if
a
.
nil?
halt
404
else
c
=
a
.
configurations
.
find
(
:name
=>
element
).
first
content_type
content_type_mapping
[
c
.
format
.
to_sym
]
if
content_type_mapping
[
c
.
format
.
to_sym
]
c
.
body
end
# GET the raw data of a configuration object
get
'/configurations/:configname/data/?'
do
|
configname
|
c
=
Noah
::
Configuration
.
find
(
:name
=>
configname
).
first
(
halt
404
)
if
c
.
empty?
content_type
content_type_mapping
[
c
.
format
.
to_sym
]
if
content_type_mapping
[
c
.
format
.
to_sym
]
c
.
body
end
get
'/configurations/:appname/?'
do
|
appname
|
config
=
[]
a
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
if
a
.
nil?
halt
404
else
a
.
configurations
.
sort
.
each
{
|
c
|
config
<<
c
.
to_hash
}
config
.
to_json
end
# GET the JSON representation of a configuration object
get
'/configurations/:configname/?'
do
|
configname
|
c
=
Noah
::
Configuration
.
find
(
:name
=>
configname
).
first
(
halt
404
)
if
c
.
empty?
c
.
to_json
end
# GET all configurations
get
'/configurations/?'
do
configs
=
Noah
::
Configurations
.
all
.
to_hash
(
halt
404
)
if
configs
.
size
==
0
configs
.
to_json
end
# Add configuration object to a custom link hierarchy
put
'/configurations/:configname/link'
do
|
configname
|
required_params
=
[
"link_name"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
...
...
@@ -41,7 +32,7 @@ class Noah::App
a
.
nil?
?
(
halt
404
)
:
(
a
.
link!
data
[
"link_name"
])
a
.
to_json
end
# Add a tag to a configuration object
put
'/configurations/:configname/tag'
do
|
configname
|
required_params
=
[
"tags"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
...
...
@@ -50,6 +41,7 @@ class Noah::App
c
.
to_json
end
# Add a watch to a configuration object
put
'/configurations/:configname/watch'
do
|
configname
|
required_params
=
[
"endpoint"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
...
...
@@ -57,11 +49,11 @@ class Noah::App
c
.
nil?
?
(
halt
404
)
:
(
w
=
c
.
watch!
(
:endpoint
=>
data
[
'endpoint'
]))
w
.
to_json
end
put
'/configurations/:
appname/:element?'
do
|
appname
,
element
|
# Attach a configuration object to an application object
put
'/configurations/:
configname/:appname?'
do
|
configname
,
appname
|
app
=
Noah
::
Application
.
find_or_create
(
:name
=>
appname
)
dependency_action
=
app
.
is_new?
?
"created"
:
"updated"
config
=
Noah
::
Configuration
.
find_or_create
(
:name
=>
element
)
config
=
Noah
::
Configuration
.
find_or_create
(
:name
=>
configname
)
required_params
=
[
"format"
,
"body"
]
data
=
JSON
.
parse
(
request
.
body
.
read
)
data
.
keys
.
sort
==
required_params
.
sort
?
(
config
.
format
=
data
[
"format"
];
config
.
body
=
data
[
"body"
])
:
(
raise
"Missing Parameters"
)
...
...
@@ -77,8 +69,12 @@ class Noah::App
end
end
delete
'/configurations/:
appname/:element?'
do
|
appname
,
element
|
delete
'/configurations/:
configname/:appname?'
do
|
configname
,
appname
|
app
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
cfg
=
app
.
configurations
.
find
(
:name
=>
configname
).
first
# Check with soveran. If we delete the member from the set using .delete, it removes the object. That would break any other users of that object.
(
halt
404
)
if
app
.
empty?
(
halt
404
)
if
config
.
empty?
if
app
config
=
app
.
configurations
.
find
(
:name
=>
element
).
first
if
config
...
...
lib/noah/
ephemeral_route
s.rb
→
lib/noah/
routes/ephemeral
s.rb
View file @
dd40590f
File moved
lib/noah/
host_route
s.rb
→
lib/noah/
routes/host
s.rb
View file @
dd40590f
File moved
lib/noah/
link_route
s.rb
→
lib/noah/
routes/link
s.rb
View file @
dd40590f
File moved
lib/noah/
service_rout
es.rb
→
lib/noah/
routes/servic
es.rb
View file @
dd40590f
File moved
lib/noah/
tag_route
s.rb
→
lib/noah/
routes/tag
s.rb
View file @
dd40590f
File moved
lib/noah/
watcher_route
s.rb
→
lib/noah/
routes/watcher
s.rb
View file @
dd40590f
File moved
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