Class: Opower::TimeSeries::Query
- Inherits:
-
Object
- Object
- Opower::TimeSeries::Query
- Defined in:
- lib/time_series/query.rb
Overview
Represents a query that can be sent to an OpenTSDB instance through a [TSDBClient] object.
Defined Under Namespace
Classes: GraphingRequest, MetricQuery
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#metrics ⇒ Object
Returns the value of attribute metrics.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#as_graph ⇒ String
Returns the current query as a URL to a PNG generated by OpenTSDB.
-
#initialize(config = {}) ⇒ Query
constructor
Creates a new Query object.
Constructor Details
#initialize(config = {}) ⇒ Query
Creates a new Query object.
This object also supports all of the options available to the REST API for OpenTSDB. See opentsdb.net/http-api.html#/q_Parameters for more information.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/time_series/query.rb', line 28 def initialize(config = {}) @request = config @format = config.delete(:format) # Check that 'start' and 'm' parameters required by OpenTSDB are present @requirements = [:start, :m] validate_metrics @metrics = @request.delete(:m) check_metrics convert_dates # Create 'm' array - this is the @request[:m] = @metrics.map(&MetricQuery.method(:new)) end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
7 8 9 |
# File 'lib/time_series/query.rb', line 7 def format @format end |
#metrics ⇒ Object
Returns the value of attribute metrics.
7 8 9 |
# File 'lib/time_series/query.rb', line 7 def metrics @metrics end |
#request ⇒ Object
Returns the value of attribute request.
7 8 9 |
# File 'lib/time_series/query.rb', line 7 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
7 8 9 |
# File 'lib/time_series/query.rb', line 7 def response @response end |
Instance Method Details
#as_graph ⇒ String
Returns the current query as a URL to a PNG generated by OpenTSDB
47 48 49 |
# File 'lib/time_series/query.rb', line 47 def as_graph GraphingRequest.new(@request).to_s end |