kapacitor-ruby 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 795cb8cba13bf7643718aff7e5d2755fed163b3e
4
- data.tar.gz: c25770257f9f8a8836c5149c34ac25574742a6f1
3
+ metadata.gz: 82ce3690bdcf6c10b5f3470557f61812dacdf11b
4
+ data.tar.gz: bf3d8bfb1845055a22735db2450808c63c72b6e4
5
5
  SHA512:
6
- metadata.gz: 0d12403ece9d64cb88e01194fc69cc53ded04bcd4c568d1e90cee2862ddab4eb2a4fa52d45d6cb657a8d9807edd2d0ec673a7cf48900f728f379bad40bf93a11
7
- data.tar.gz: fddd0de75f3592fbf0f6297b297a2f32b6072266b0df22db761ea09a56d3aaefcd70403ec65d98cd8c8a671eccd9eb6daed5eb26da74e348be0b26a13f4a061d
6
+ metadata.gz: 2cdf19fe98d1d673e0ca8a340a9f8f2934e4cc77cd2624f16f7cdda2f4abd6916e5896edc61df80b015fe0ac9f3579564ebf4775fc94b0155179da7431143662
7
+ data.tar.gz: 8e8f9f3bf74a98f6e67cd456a34605626d3a42b6f4ad10d83cb01303a5b9d70a630561c759c2b67bbdbabc4c55474fa16fb8da21879dbae881ddae424923d4e1
@@ -1,8 +1,6 @@
1
1
  #
2
2
  # client.rb
3
3
  #
4
- # Author: Matteo Cerutti <matteo.cerutti@hotmail.co.uk>
5
- #
6
4
 
7
5
  require 'net/http'
8
6
  require 'json'
@@ -52,8 +50,17 @@ module Kapacitor
52
50
  api_delete("/templates/#{id}")
53
51
  end
54
52
 
55
- def templates
56
- api_get('/templates')['templates']
53
+ def templates(offset: 0, limit: 100)
54
+ templates = []
55
+
56
+ loop do
57
+ res = api_get("/templates?offset=#{offset}&limit=#{limit}")['templates']
58
+ break unless res.size > 0
59
+ templates += res
60
+ offset += limit
61
+ end
62
+
63
+ templates
57
64
  end
58
65
 
59
66
  def define_task(id, opts = {})
@@ -115,11 +122,18 @@ module Kapacitor
115
122
  api_delete("/tasks/#{id}")
116
123
  end
117
124
 
118
- def tasks
125
+ def tasks(offset: 0, limit: 100)
119
126
  tasks = []
120
127
 
121
- api_get('/tasks?fields=id')['tasks'].each do |task|
122
- tasks << api_get("/tasks/#{task['id']}")
128
+ loop do
129
+ res = api_get("/tasks?fields=id&offset=#{offset}&limit=#{limit}")['tasks']
130
+ break unless res.size > 0
131
+
132
+ res.each do |task|
133
+ tasks << api_get("/tasks/#{task['id']}")
134
+ end
135
+
136
+ offset += limit
123
137
  end
124
138
 
125
139
  tasks
@@ -1,11 +1,9 @@
1
1
  #
2
2
  # version.rb
3
3
  #
4
- # Author: Matteo Cerutti <matteo.cerutti@hotmail.co.uk>
5
- #
6
4
 
7
5
  module Kapacitor
8
- VERSION = "0.0.13"
6
+ VERSION = "0.0.14"
9
7
 
10
8
  def self.version
11
9
  VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kapacitor-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Cerutti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-24 00:00:00.000000000 Z
11
+ date: 2017-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json