Skip to content

Commit 9d50489

Browse files
committed
bump version
1 parent b662c0d commit 9d50489

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

lib/prometheus/api_client/client.rb

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,41 @@
11
# encoding: UTF-8
22

3+
require 'json'
34
require 'faraday'
45

56
module Prometheus
67
# Client is a ruby implementation for a Prometheus compatible api_client.
78
module ApiClient
89
# Client contains the implementation for a Prometheus compatible api_client.
910
class Client
11+
class RequestError < StandardError; end
12+
1013
def initialize(args)
1114
@client = Faraday.new(args)
1215
end
1316

14-
def get(args)
15-
@client.get(args)
17+
def query(options)
18+
run_command('query', options)
19+
end
20+
21+
def query_range(options)
22+
run_command('query_range', options)
23+
end
24+
25+
def label(tag, options)
26+
run_command("label/#{tag}/values", options)
27+
end
28+
29+
def get(command, options)
30+
@client.get(command, options)
31+
end
32+
33+
def run_command(command, options)
34+
response = get(command, options)
35+
36+
result = JSON.parse(response.body)["data"]
37+
rescue
38+
fail RequestError, "Bad response from server"
1639
end
1740
end
1841
end

lib/prometheus/api_client/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Prometheus
44
module ApiClient
5-
VERSION = '0.0.3'
5+
VERSION = '0.1.0'
66
end
77
end

0 commit comments

Comments
 (0)