Class: OpenObserve::Dashboard
- Defined in:
- lib/openobserve/dashboard.rb
Overview
A dashboard, in either of the two shapes OpenObserve answers with.
GET/POST/PUT on a single dashboard return a version envelope — hash,
updatedAt, version and eight v1…v8 slots of which exactly one is filled. The
list endpoint returns a flatter item: the same version/v{n} pair, plus
dashboard_id, title, hash and the folder at the top level.
The two are reconciled here so callers never branch on which endpoint produced the record: #id and #title read the top level first and fall back to the definition, and #definition always yields the dashboard body itself.
Note the name of #revision. The API field is called hash, but Record#hash
implements Ruby's Object#hash contract so records key Hashes and Sets correctly;
shadowing it with a String would break every such use, silently. The raw field stays
reachable as dashboard['hash'].
Instance Attribute Summary
Attributes inherited from Record
Instance Method Summary collapse
-
#definition ⇒ Hash
The dashboard body, unwrapped from the
v{version}slot it travels in. -
#folder_id ⇒ String?
The folder the dashboard lives in; only list items carry it.
-
#id ⇒ String?
The server-assigned dashboard id.
-
#revision ⇒ String?
The server's content hash, which OpenObserve::Dashboards#update must echo back for OpenObserve to accept the write.
-
#title ⇒ String?
The dashboard title, which OpenObserve::Dashboards#sync keys on.
-
#version ⇒ Integer?
The dashboard schema version (5 for the current format).
Methods inherited from Record
#==, #[], from, #hash, #initialize, #to_h
Constructor Details
This class inherits a constructor from OpenObserve::Record
Instance Method Details
#definition ⇒ Hash
The dashboard body, unwrapped from the v{version} slot it travels in.
27 28 29 |
# File 'lib/openobserve/dashboard.rb', line 27 def definition version.nil? ? {} : (self["v#{version}"] || {}) end |
#folder_id ⇒ String?
Returns the folder the dashboard lives in; only list items carry it.
42 43 44 |
# File 'lib/openobserve/dashboard.rb', line 42 def folder_id self['folder_id'] end |
#id ⇒ String?
Returns the server-assigned dashboard id.
32 33 34 |
# File 'lib/openobserve/dashboard.rb', line 32 def id self['dashboard_id'] || definition['dashboardId'] end |
#revision ⇒ String?
The server's content hash, which OpenObserve::Dashboards#update must echo back for
OpenObserve to accept the write. Named revision rather than hash — see the class note.
50 51 52 |
# File 'lib/openobserve/dashboard.rb', line 50 def revision self['hash'] end |
#title ⇒ String?
Returns the dashboard title, which OpenObserve::Dashboards#sync keys on.
37 38 39 |
# File 'lib/openobserve/dashboard.rb', line 37 def title self['title'] || definition['title'] end |
#version ⇒ Integer?
Returns the dashboard schema version (5 for the current format).
21 22 23 |
# File 'lib/openobserve/dashboard.rb', line 21 def version self['version'] end |