Class: RunscopeStatuspage::RunscopeAPI
- Inherits:
-
Object
- Object
- RunscopeStatuspage::RunscopeAPI
- Includes:
- HTTParty
- Defined in:
- lib/runscope_statuspage/runscope_api.rb
Instance Method Summary collapse
- #bucket_id_by_name(name) ⇒ Object
-
#buckets ⇒ Object
Get list of buckets.
-
#get_radar(bucket, radar) ⇒ Object
Get a radar, from a bucket.
-
#initialize(token) ⇒ RunscopeAPI
constructor
Set credentials.
-
#latest_radar_result(bucket, radar) ⇒ Object
Get latest result from radar.
-
#message_detail(bucket, message) ⇒ Object
Get message detail.
-
#messages(bucket, count) ⇒ Object
Get latest messages.
-
#radars(bucket) ⇒ Object
Get list of radars for bucket.
Constructor Details
#initialize(token) ⇒ RunscopeAPI
Set credentials
11 12 13 |
# File 'lib/runscope_statuspage/runscope_api.rb', line 11 def initialize(token) @options = { headers: {"Authorization" => "Bearer #{token}"} } end |
Instance Method Details
#bucket_id_by_name(name) ⇒ Object
27 28 29 30 31 |
# File 'lib/runscope_statuspage/runscope_api.rb', line 27 def bucket_id_by_name(name) self.buckets.each do |bucket| return bucket["key"] if bucket["name"] == name end end |
#buckets ⇒ Object
Get list of buckets
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/runscope_statuspage/runscope_api.rb', line 16 def buckets buckets = self.class.get('/buckets', @options) if buckets.has_key?('meta') and buckets.has_key?('data') if buckets['meta']['status'] == 'success' buckets['data'] else raise RunscopeAPIException.new, buckets['error'] end end end |
#get_radar(bucket, radar) ⇒ Object
Get a radar, from a bucket.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/runscope_statuspage/runscope_api.rb', line 46 def get_radar(bucket, radar) get_radar = self.class.get("/buckets/#{bucket}/radar/#{radar}", @options) if get_radar.has_key?('meta') and get_radar.has_key?('data') if get_radar['meta']['status'] == 'success' get_radar['data'] else raise RunscopeAPIException.new, get_radar['error'] end end end |
#latest_radar_result(bucket, radar) ⇒ Object
Get latest result from radar
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/runscope_statuspage/runscope_api.rb', line 58 def latest_radar_result(bucket, radar) lrr = self.class.get("/buckets/#{bucket}/radar/#{radar}/results/latest", @options) if lrr.has_key?('meta') and lrr.has_key?('data') if lrr['meta']['status'] == 'success' lrr['data'] else raise RunscopeAPIException.new, lrr['error'] end end end |
#message_detail(bucket, message) ⇒ Object
Get message detail
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/runscope_statuspage/runscope_api.rb', line 82 def (bucket, ) detail = self.class.get("/buckets/#{bucket}/messages/#{}", @options) if detail.has_key?('meta') and detail.has_key?('data') if detail['meta']['status'] == 'success' detail['data'] else raise RunscopeAPIException.new, detail['error'] end end end |
#messages(bucket, count) ⇒ Object
Get latest messages
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/runscope_statuspage/runscope_api.rb', line 70 def (bucket, count) = self.class.get("/buckets/#{bucket_id_by_name(bucket)}/messages?count=#{count}", @options) if .has_key?('meta') and .has_key?('data') if ['meta']['status'] == 'success' ['data'] else raise RunscopeAPIException.new, ['error'] end end end |
#radars(bucket) ⇒ Object
Get list of radars for bucket
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/runscope_statuspage/runscope_api.rb', line 34 def radars(bucket) radars = self.class.get("/buckets/#{bucket}/radar", @options) if radars.has_key?('meta') and radars.has_key?('data') if radars['meta']['status'] == 'success' radars['data'] else raise RunscopeAPIException.new, radars['error'] end end end |