stashboard 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +22 -0
- data/README.md +25 -0
- data/Rakefile +28 -0
- data/lib/stashboard/stashboard.rb +162 -0
- data/lib/stashboard/version.rb +3 -0
- data/lib/stashboard.rb +4 -0
- data/stashboard.gemspec +27 -0
- metadata +123 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
stashboard (0.0.1)
|
5
|
+
oauth (>= 0.4.4)
|
6
|
+
yajl-ruby (>= 0.8.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
oauth (0.4.4)
|
12
|
+
yajl-ruby (0.8.1)
|
13
|
+
yard (0.6.4)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
oauth (>= 0.4.4)
|
20
|
+
stashboard!
|
21
|
+
yajl-ruby (>= 0.8.1)
|
22
|
+
yard (>= 0.6.4)
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Stashboard gem
|
2
|
+
|
3
|
+
Simple little ruby library for interacting with a Stashboard instance
|
4
|
+
([http://www.stashboard.org]((http://www.stashboard.org)).
|
5
|
+
|
6
|
+
Stashboard is a Python application designed to be run on the Google App Engine,
|
7
|
+
which provides a system status type page for your application similar to the
|
8
|
+
status pages offered by [Amazon AWS](http://status.aws.amazon.com/), or
|
9
|
+
[Google Apps](http://www.google.com/appsstatus).
|
10
|
+
|
11
|
+
This library doesn't address setting up your Stashboard instance, but
|
12
|
+
simplifies interacting with it from Ruby.
|
13
|
+
|
14
|
+
# Usage
|
15
|
+
|
16
|
+
stashboard = Stashboard.new("https://your-app.appspot.com", "<stashboard_oauth_token>", "<stashboard_oauth_secret>")
|
17
|
+
|
18
|
+
# get all services
|
19
|
+
stashboard.services
|
20
|
+
|
21
|
+
# get individual service details
|
22
|
+
stashboard.service("website")
|
23
|
+
|
24
|
+
# create new event for a service
|
25
|
+
stashboard.create_event("website", "down", "Server unavailable, attempting to restart")
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
CLEAN.include("pkg")
|
7
|
+
CLOBBER.include("doc")
|
8
|
+
|
9
|
+
namespace :doc do
|
10
|
+
project_root = File.expand_path(File.dirname(__FILE__))
|
11
|
+
doc_destination = File.join(project_root, 'doc', 'rdoc')
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'yard'
|
15
|
+
require 'yard/rake/yardoc_task'
|
16
|
+
|
17
|
+
YARD::Rake::YardocTask.new(:generate) do |yt|
|
18
|
+
yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
|
19
|
+
[File.join(project_root, 'README.md') ]
|
20
|
+
yt.options = ['--output-dir', doc_destination, '--readme', 'README.md']
|
21
|
+
end
|
22
|
+
rescue LoadError
|
23
|
+
desc "Generate YARD Documentation"
|
24
|
+
task :generate do
|
25
|
+
abort "Please install the YARD gem to generate rdoc."
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'oauth'
|
3
|
+
require 'yajl/json_gem'
|
4
|
+
|
5
|
+
module Stashboard
|
6
|
+
# Main class for interacting with Stashboard.
|
7
|
+
class Stashboard
|
8
|
+
|
9
|
+
# Create a new Stashboard instance.
|
10
|
+
#
|
11
|
+
# @param [String] the url of your stashboard instance (this should use https)
|
12
|
+
# @param [String] the oauth_token generated by your Stashboard instance (this is the long one)
|
13
|
+
# @param [String] the oauth_secret generated by your Stashboard instance (this is the shorter one)
|
14
|
+
def initialize(base_url, oauth_token, oauth_secret)
|
15
|
+
@consumer = OAuth::Consumer.new("anonymous", "anonymous", { :site => base_url })
|
16
|
+
@client = OAuth::AccessToken.new(@consumer, oauth_token, oauth_secret)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Gets a list of all services currently managed by the Stashboard instance
|
20
|
+
#
|
21
|
+
# @return [Array] an array of service detail hashes
|
22
|
+
def services
|
23
|
+
response = @client.get("/api/v1/services")
|
24
|
+
return JSON.parse(response.body)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get the details of an individual service managed by the Stashboard instance.
|
28
|
+
#
|
29
|
+
# @param [String] the unique id of the service (generated by Stashboard)
|
30
|
+
# @return [Hash] hash containing the service details
|
31
|
+
def service(service_id)
|
32
|
+
response = @client.get("/api/v1/services/#{service_id}")
|
33
|
+
return JSON.parse(response.body)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Create a new service.
|
37
|
+
#
|
38
|
+
# @param [String] the name of the service
|
39
|
+
# @param [String] the description of the service
|
40
|
+
# @return [Hash] response containing the complete service details generated by Stashboard
|
41
|
+
def create_service(name, description)
|
42
|
+
response = @client.post("/api/v1/services", { "name" => name, "description" => description })
|
43
|
+
return JSON.parse(response.body)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Delete a service. This will delete all alerts for this service, so be careful.
|
47
|
+
#
|
48
|
+
# @param [String] the service id to delete
|
49
|
+
# @return [Hash] details of the service we've just deleted
|
50
|
+
def delete_service(service_id)
|
51
|
+
response = @client.delete("/api/v1/services/#{service_id}")
|
52
|
+
return JSON.parse(response.body)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Updates details of an existing service with a new name or description.
|
56
|
+
# You can't change the service_id however.
|
57
|
+
#
|
58
|
+
# @param [String] the id of the service to update
|
59
|
+
# @param [String] the new name
|
60
|
+
# @param [String] the new description
|
61
|
+
# @return [Hash] the updated service details
|
62
|
+
def update_service(service_id, name, description)
|
63
|
+
response = @client.post("/api/v1/services/#{service_id}", { "name" => name, "description" => description })
|
64
|
+
return JSON.parse(response.body)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns the different levels that new statuses can use.
|
68
|
+
#
|
69
|
+
# @return [Array] an array of the level strings
|
70
|
+
def levels
|
71
|
+
response = @client.get("/api/v1/levels")
|
72
|
+
return JSON.parse(response.body)["levels"]
|
73
|
+
end
|
74
|
+
|
75
|
+
# Get events for the specified service.
|
76
|
+
#
|
77
|
+
# @param [String] the service id we wer interested in
|
78
|
+
# @param [Hash] optional hash that restricts the returned events. Only keys that do anything are "start" and "end" which can be used to constrain the time period from which events will be returned.
|
79
|
+
# @return [Array] an array of event hashes describing events for the service
|
80
|
+
def events(service_id, options = {})
|
81
|
+
response = @client.get("/api/v1/services/#{service_id}/events", options)
|
82
|
+
return JSON.parse(response.body)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Create an event of a service. Events are the main way we
|
86
|
+
# indicate problems or resolutions of issues.
|
87
|
+
#
|
88
|
+
# @param [String] the id of the service
|
89
|
+
# @param [String] the id of an already existing status (i.e. "up", "down", "warning")
|
90
|
+
# @param [String] a descriptive message
|
91
|
+
# @return [Hash] the event details
|
92
|
+
def create_event(service_id, status_id, message)
|
93
|
+
response = @client.post("/api/v1/services/#{service_id}/events", { "status" => status_id, "message" => message })
|
94
|
+
return JSON.parse(response.body)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Get the current event for the specified service.
|
98
|
+
#
|
99
|
+
# @param [String] the id of the service
|
100
|
+
# @return [Hash] hash containing the current event details
|
101
|
+
def current_event(service_id)
|
102
|
+
response = @client.get("/api/v1/services/#{service_id}/events/current")
|
103
|
+
return JSON.parse(response.body)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Get details of an individual event
|
107
|
+
#
|
108
|
+
# @param [String] the id of the service
|
109
|
+
# @param [String] the sid of the event. This is a unique key returned in the response when an event is created
|
110
|
+
# @return [Hash] hash containing the current event details
|
111
|
+
def event(service_id, event_sid)
|
112
|
+
response = @client.get("/api/v1/services/#{service_id}/events/#{event_sid}")
|
113
|
+
return JSON.parse(response.body)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Delete an event.
|
117
|
+
#
|
118
|
+
# (see #event)
|
119
|
+
def delete_event(service_id, event_sid)
|
120
|
+
response = @client.delete("/api/v1/services/#{service_id}/events/#{event_sid}")
|
121
|
+
return JSON.parse(response.body)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Get all statuses.
|
125
|
+
#
|
126
|
+
# @return [Array] an array of status hashes, each hash is an individual status
|
127
|
+
def statuses
|
128
|
+
response = @client.get("/api/v1/statuses")
|
129
|
+
return JSON.parse(response.body)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Get the details of the individual status.
|
133
|
+
#
|
134
|
+
# @param [String] the id of the status
|
135
|
+
# @return [Hash] hash containing the status details
|
136
|
+
def status(status_id)
|
137
|
+
response = @client.get("/api/v1/statuses/#{status_id}")
|
138
|
+
return JSON.parse(response.body)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Create a new status. Statuses exist independently of any Service, and are
|
142
|
+
# required before creating any events that use this status
|
143
|
+
#
|
144
|
+
# @param [String] the name of this status
|
145
|
+
# @param [String] description of the status
|
146
|
+
# @param [String] level string. Must be one of the levels returned from #levels
|
147
|
+
# @param [String] name of an image to use for this status. The complete list of images can be retrieved using #status_images, and this value should just be the image name without the directory name or the file extension.
|
148
|
+
# @return [Hash] hash containing the created statuses details
|
149
|
+
def create_status(name, description, level, image)
|
150
|
+
response = @client.post("/api/v1/statuses", { "name" => name, "description" => description, "level" => level, "image" => image })
|
151
|
+
return JSON.parse(response.body)
|
152
|
+
end
|
153
|
+
|
154
|
+
# Return a list of all the status images that the Stashboard server knows about.
|
155
|
+
#
|
156
|
+
# @return [Array] array of image hashes
|
157
|
+
def status_images
|
158
|
+
response = @client.get("/api/v1/status-images")
|
159
|
+
return JSON.parse(response.body)["images"]
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
data/lib/stashboard.rb
ADDED
data/stashboard.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "stashboard/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "stashboard"
|
7
|
+
s.version = Stashboard::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Sam Mulube"]
|
10
|
+
s.email = ["sam@connectedenvironments.com"]
|
11
|
+
s.homepage = "http://github.com/smulube/stashboard"
|
12
|
+
s.summary = %q{Library for interacting with the Stashboard api.}
|
13
|
+
s.description = %q{Little library written to make interacting with the stashboard api a bit easier}
|
14
|
+
|
15
|
+
s.rubyforge_project = "stashboard"
|
16
|
+
s.rubygems_version = ">= 1.3.6"
|
17
|
+
|
18
|
+
s.add_dependency('yajl-ruby', '>= 0.8.1')
|
19
|
+
s.add_dependency('oauth', '>= 0.4.4')
|
20
|
+
|
21
|
+
s.add_development_dependency('yard', '>= 0.6.4')
|
22
|
+
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
|
+
s.require_paths = ["lib"]
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stashboard
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Sam Mulube
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-04 00:00:00 +00:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: yajl-ruby
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 61
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 8
|
33
|
+
- 1
|
34
|
+
version: 0.8.1
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: oauth
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 7
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 4
|
49
|
+
- 4
|
50
|
+
version: 0.4.4
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: yard
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 15
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 6
|
65
|
+
- 4
|
66
|
+
version: 0.6.4
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
description: Little library written to make interacting with the stashboard api a bit easier
|
70
|
+
email:
|
71
|
+
- sam@connectedenvironments.com
|
72
|
+
executables: []
|
73
|
+
|
74
|
+
extensions: []
|
75
|
+
|
76
|
+
extra_rdoc_files: []
|
77
|
+
|
78
|
+
files:
|
79
|
+
- .gitignore
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- lib/stashboard.rb
|
85
|
+
- lib/stashboard/stashboard.rb
|
86
|
+
- lib/stashboard/version.rb
|
87
|
+
- stashboard.gemspec
|
88
|
+
has_rdoc: true
|
89
|
+
homepage: http://github.com/smulube/stashboard
|
90
|
+
licenses: []
|
91
|
+
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
requirements: []
|
116
|
+
|
117
|
+
rubyforge_project: stashboard
|
118
|
+
rubygems_version: 1.3.7
|
119
|
+
signing_key:
|
120
|
+
specification_version: 3
|
121
|
+
summary: Library for interacting with the Stashboard api.
|
122
|
+
test_files: []
|
123
|
+
|