Class: Grafana::Dashboard
- Inherits:
-
Object
- Object
- Grafana::Dashboard
- Defined in:
- lib/grafana/dashboard.rb
Overview
Representation of one specific dashboard in a Grafana instance.
Instance Attribute Summary collapse
-
#grafana ⇒ Grafana
readonly
Parent Grafana object.
-
#panels ⇒ Object
readonly
Returns the value of attribute panels.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
-
#from_time ⇒ String
from
time configured in the dashboard. -
#id ⇒ String
Dashboard UID.
-
#initialize(model, grafana) ⇒ Dashboard
constructor
A new instance of Dashboard.
-
#panel(id) ⇒ Panel
Panel for the specified ID.
-
#title ⇒ String
Dashboard title.
-
#to_time ⇒ String
to
time configured in the dashboard.
Constructor Details
#initialize(model, grafana) ⇒ Dashboard
Returns a new instance of Dashboard.
12 13 14 15 16 17 18 |
# File 'lib/grafana/dashboard.rb', line 12 def initialize(model, grafana) @grafana = grafana @model = model init_panels init_variables end |
Instance Attribute Details
#grafana ⇒ Grafana (readonly)
Returns parent Grafana object.
7 8 9 |
# File 'lib/grafana/dashboard.rb', line 7 def grafana @grafana end |
#panels ⇒ Object (readonly)
Returns the value of attribute panels.
8 9 10 |
# File 'lib/grafana/dashboard.rb', line 8 def panels @panels end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
8 9 10 |
# File 'lib/grafana/dashboard.rb', line 8 def variables @variables end |
Instance Method Details
#from_time ⇒ String
Returns from
time configured in the dashboard.
21 22 23 24 25 |
# File 'lib/grafana/dashboard.rb', line 21 def from_time return @model['time']['from'] if @model['time'] nil end |
#id ⇒ String
Returns dashboard UID.
34 35 36 |
# File 'lib/grafana/dashboard.rb', line 34 def id @model['uid'] end |
#panel(id) ⇒ Panel
Returns panel for the specified ID.
44 45 46 47 48 49 |
# File 'lib/grafana/dashboard.rb', line 44 def panel(id) panels = @panels.select { |item| item.field('id') == id.to_i } raise PanelDoesNotExistError.new(id, self) if panels.empty? panels.first end |
#title ⇒ String
Returns dashboard title.
39 40 41 |
# File 'lib/grafana/dashboard.rb', line 39 def title @model['title'] end |
#to_time ⇒ String
Returns to
time configured in the dashboard.
28 29 30 31 |
# File 'lib/grafana/dashboard.rb', line 28 def to_time @model['time']['to'] if @model['time'] nil end |