Class: Updown::Check

Inherits:
Object
  • Object
show all
Defined in:
lib/updown/check.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Check

Returns a new instance of Check.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/updown/check.rb', line 21

def initialize(json)
  @token         = json['token']
  @url           = json['url']
  @alias         = json['alias']
  @last_status   = json['last_status']
  @enabled       = json['enabled']
  @period        = json['period']
  @apdex_t       = json['apdex_t']
  @published     = json['published']
  @uptime        = json['uptime']
  @down          = json['down']
  @error         = json['error']
  @metrics       = json['metrics']
  @down_since    = Time.parse(json['down_since']) if json['down_since']
  @last_check_at = Time.parse(json['last_check_at']) if json['last_check_at']
  @next_check_at = Time.parse(json['next_check_at']) if json['next_check_at']
  if ssl = json['ssl']
    @ssl_tested_at = Time.parse(ssl['tested_at']) if ssl['tested_at']
    @ssl_valid     = ssl['valid']
    @ssl_error     = ssl['error']
  end
end

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



5
6
7
# File 'lib/updown/check.rb', line 5

def alias
  @alias
end

#apdex_tObject

Returns the value of attribute apdex_t.



5
6
7
# File 'lib/updown/check.rb', line 5

def apdex_t
  @apdex_t
end

#downObject

Returns the value of attribute down.



5
6
7
# File 'lib/updown/check.rb', line 5

def down
  @down
end

#down_sinceObject

Returns the value of attribute down_since.



5
6
7
# File 'lib/updown/check.rb', line 5

def down_since
  @down_since
end

#enabledObject

Returns the value of attribute enabled.



5
6
7
# File 'lib/updown/check.rb', line 5

def enabled
  @enabled
end

#errorObject

Returns the value of attribute error.



5
6
7
# File 'lib/updown/check.rb', line 5

def error
  @error
end

#last_check_atObject

Returns the value of attribute last_check_at.



5
6
7
# File 'lib/updown/check.rb', line 5

def last_check_at
  @last_check_at
end

#last_statusObject

Returns the value of attribute last_status.



5
6
7
# File 'lib/updown/check.rb', line 5

def last_status
  @last_status
end

#metricsObject

Returns the value of attribute metrics.



5
6
7
# File 'lib/updown/check.rb', line 5

def metrics
  @metrics
end

#next_check_atObject

Returns the value of attribute next_check_at.



5
6
7
# File 'lib/updown/check.rb', line 5

def next_check_at
  @next_check_at
end

#periodObject

Returns the value of attribute period.



5
6
7
# File 'lib/updown/check.rb', line 5

def period
  @period
end

#publishedObject

Returns the value of attribute published.



5
6
7
# File 'lib/updown/check.rb', line 5

def published
  @published
end

#ssl_errorObject

Returns the value of attribute ssl_error.



5
6
7
# File 'lib/updown/check.rb', line 5

def ssl_error
  @ssl_error
end

#ssl_tested_atObject

Returns the value of attribute ssl_tested_at.



5
6
7
# File 'lib/updown/check.rb', line 5

def ssl_tested_at
  @ssl_tested_at
end

#ssl_validObject

Returns the value of attribute ssl_valid.



5
6
7
# File 'lib/updown/check.rb', line 5

def ssl_valid
  @ssl_valid
end

#tokenObject

Returns the value of attribute token.



5
6
7
# File 'lib/updown/check.rb', line 5

def token
  @token
end

#uptimeObject

Returns the value of attribute uptime.



5
6
7
# File 'lib/updown/check.rb', line 5

def uptime
  @uptime
end

#urlObject

Returns the value of attribute url.



5
6
7
# File 'lib/updown/check.rb', line 5

def url
  @url
end

Class Method Details

.allObject



7
8
9
10
11
# File 'lib/updown/check.rb', line 7

def self.all
  Updown::Call.checks.map do |check|
    Check.new check
  end
end

.create(url, attributes = {}) ⇒ Object



13
14
15
# File 'lib/updown/check.rb', line 13

def self.create(url, attributes = {})
  Check.new Updown::Call.create_check(attributes.merge(url: url))
end

.get(token, attributes = {}) ⇒ Object



17
18
19
# File 'lib/updown/check.rb', line 17

def self.get(token, attributes = {})
  Check.new Updown::Call.get_check(token, attributes)
end

Instance Method Details

#destroyObject



56
57
58
# File 'lib/updown/check.rb', line 56

def destroy
  Updown::Call.destroy_check(@token)['deleted']
end

#downtimes(page: 1) ⇒ Object



44
45
46
# File 'lib/updown/check.rb', line 44

def downtimes page: 1
  Downtime.find(@token, page: page)
end

#get_metrics(filters = {}) ⇒ Object



48
49
50
# File 'lib/updown/check.rb', line 48

def get_metrics filters = {}
  Updown::Call.metrics(@token, filters)
end

#update(attributes = {}) ⇒ Object



52
53
54
# File 'lib/updown/check.rb', line 52

def update(attributes={})
  Check.new Updown::Call.update_check(@token, attributes)
end