Class: Grafana::Client
- Inherits:
-
Object
- Object
- Grafana::Client
- Defined in:
- lib/grafana/client.rb
Constant Summary collapse
- Error =
Class.new(StandardError)
Instance Method Summary collapse
- #get_dashboard(uid:) ⇒ Object
- #get_datasource(name:) ⇒ Object
-
#initialize(api_url:, token:) ⇒ Client
constructor
A new instance of Client.
- #proxy_datasource(datasource_id:, proxy_path:, query: {}) ⇒ Object
Constructor Details
#initialize(api_url:, token:) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/grafana/client.rb', line 9 def initialize(api_url:, token:) @api_url = api_url @token = token end |
Instance Method Details
#get_dashboard(uid:) ⇒ Object
15 16 17 |
# File 'lib/grafana/client.rb', line 15 def get_dashboard(uid:) http_get("#{@api_url}/api/dashboards/uid/#{uid}") end |
#get_datasource(name:) ⇒ Object
20 21 22 23 24 |
# File 'lib/grafana/client.rb', line 20 def get_datasource(name:) # CGI#escape formats strings such that the Grafana endpoint # will not recognize the dashboard name. Prefer Addressable::URI#encode_component. http_get("#{@api_url}/api/datasources/name/#{Addressable::URI.encode_component(name)}") end |
#proxy_datasource(datasource_id:, proxy_path:, query: {}) ⇒ Object
28 29 30 |
# File 'lib/grafana/client.rb', line 28 def proxy_datasource(datasource_id:, proxy_path:, query: {}) http_get("#{@api_url}/api/datasources/proxy/#{datasource_id}/#{proxy_path}", query: query) end |