influxdb-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +12 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +208 -0
  8. data/Rakefile +6 -0
  9. data/influxdb-api.gemspec +27 -0
  10. data/lib/influxdb-api.rb +2 -0
  11. data/lib/influxdb.rb +4 -0
  12. data/lib/influxdb/api.rb +38 -0
  13. data/lib/influxdb/api/client.rb +99 -0
  14. data/lib/influxdb/api/client/connection.rb +55 -0
  15. data/lib/influxdb/api/client/connection_pool.rb +52 -0
  16. data/lib/influxdb/api/client/errors.rb +62 -0
  17. data/lib/influxdb/api/client/response.rb +14 -0
  18. data/lib/influxdb/api/client/selector.rb +27 -0
  19. data/lib/influxdb/api/configuration.rb +116 -0
  20. data/lib/influxdb/api/database.rb +29 -0
  21. data/lib/influxdb/api/extensions.rb +15 -0
  22. data/lib/influxdb/api/namespaces.rb +50 -0
  23. data/lib/influxdb/api/namespaces/base.rb +61 -0
  24. data/lib/influxdb/api/namespaces/cluster_admins.rb +14 -0
  25. data/lib/influxdb/api/namespaces/continuous_queries.rb +13 -0
  26. data/lib/influxdb/api/namespaces/databases.rb +13 -0
  27. data/lib/influxdb/api/namespaces/series.rb +52 -0
  28. data/lib/influxdb/api/namespaces/servers.rb +12 -0
  29. data/lib/influxdb/api/namespaces/shard_spaces.rb +33 -0
  30. data/lib/influxdb/api/namespaces/shards.rb +10 -0
  31. data/lib/influxdb/api/namespaces/users.rb +18 -0
  32. data/lib/influxdb/api/namespaces/with_database.rb +20 -0
  33. data/lib/influxdb/api/server_version.rb +62 -0
  34. data/lib/influxdb/api/version.rb +5 -0
  35. data/spec/lib/influxdb/api/client/connection_pool_spec.rb +61 -0
  36. data/spec/lib/influxdb/api/client/connection_spec.rb +72 -0
  37. data/spec/lib/influxdb/api/client/response_spec.rb +11 -0
  38. data/spec/lib/influxdb/api/client/selector_spec.rb +24 -0
  39. data/spec/lib/influxdb/api/client_spec.rb +110 -0
  40. data/spec/lib/influxdb/api/configuration_spec.rb +54 -0
  41. data/spec/lib/influxdb/api/database_spec.rb +32 -0
  42. data/spec/lib/influxdb/api/namespaces/cluster_admins_spec.rb +46 -0
  43. data/spec/lib/influxdb/api/namespaces/continuous_queries_spec.rb +42 -0
  44. data/spec/lib/influxdb/api/namespaces/databases_spec.rb +36 -0
  45. data/spec/lib/influxdb/api/namespaces/series_spec.rb +119 -0
  46. data/spec/lib/influxdb/api/namespaces/servers_spec.rb +30 -0
  47. data/spec/lib/influxdb/api/namespaces/shard_spaces_spec.rb +55 -0
  48. data/spec/lib/influxdb/api/namespaces/shards_spec.rb +52 -0
  49. data/spec/lib/influxdb/api/namespaces/users_spec.rb +55 -0
  50. data/spec/lib/influxdb/api/namespaces_spec.rb +65 -0
  51. data/spec/lib/influxdb/api/server_version_spec.rb +51 -0
  52. data/spec/spec_helper.rb +28 -0
  53. metadata +183 -0
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Influxdb::Api::Namespaces::Users do
4
+ let(:config){ Influxdb::Api::Configuration.new }
5
+ let(:client){ Influxdb::Api::Client.new(config) }
6
+
7
+ subject{ Influxdb::Api::Namespaces::Users.new(client, 'dbname') }
8
+
9
+ describe '#all' do
10
+ before do
11
+ stub_request(:get, 'http://root:root@localhost:8086/db/dbname/users').
12
+ to_return(status: 200, body: '[{"name":"username"}]', headers: { 'Content-Type' => 'application/json' })
13
+ end
14
+
15
+ specify{ expect(subject.all).to eq([{ 'name' => 'username' }]) }
16
+ end
17
+
18
+ describe '#find' do
19
+ before do
20
+ stub_request(:get, 'http://root:root@localhost:8086/db/dbname/users/username').
21
+ to_return(status: 200, body: '{"name":"username"}', headers: { 'Content-Type' => 'application/json' })
22
+ end
23
+
24
+ specify{ expect(subject.find('username')).to eq('name' => 'username') }
25
+ end
26
+
27
+ describe '#create' do
28
+ before do
29
+ stub_request(:post, 'http://root:root@localhost:8086/db/dbname/users').
30
+ with(body: '{"name":"username","password":"pass"}', headers: { 'Content-Type' => 'application/json' }).
31
+ to_return(status: 200, body: '', headers: { 'Content-Type' => 'text/plain' })
32
+ end
33
+
34
+ specify{ expect(subject.create(name: 'username', password: 'pass')).to be_truthy }
35
+ end
36
+
37
+ describe '#update' do
38
+ before do
39
+ stub_request(:post, 'http://root:root@localhost:8086/db/dbname/users/username').
40
+ with(body: '{"password":"newpass"}', headers: { 'Content-Type' => 'application/json' }).
41
+ to_return(status: 200, body: '', headers: { 'Content-Type' => 'text/plain' })
42
+ end
43
+
44
+ specify{ expect(subject.update('username', password: 'newpass')).to be_truthy }
45
+ end
46
+
47
+ describe '#delete' do
48
+ before do
49
+ stub_request(:delete, 'http://root:root@localhost:8086/db/dbname/users/username').
50
+ to_return(status: 200, body: '', headers: { 'Content-Type' => 'text/plain' })
51
+ end
52
+
53
+ specify{ expect(subject.delete('username')).to be_truthy }
54
+ end
55
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe Influxdb::Api::Namespaces do
4
+ let(:config){ Influxdb::Api::Configuration.new }
5
+
6
+ subject{ Influxdb::Api::Client.new(config) }
7
+
8
+ describe '#databases' do
9
+ context 'with argument' do
10
+ specify{ expect(subject.databases('dbname')).to be_instance_of(Influxdb::Api::Database) }
11
+ specify{ expect(subject.databases('dbname').client).to eq(subject) }
12
+ specify{ expect(subject.databases('dbname').name).to eq('dbname') }
13
+ end
14
+
15
+ context 'without argument' do
16
+ specify{ expect(subject.databases).to be_instance_of(Influxdb::Api::Namespaces::Databases) }
17
+ specify{ expect(subject.databases.client).to eq(subject) }
18
+ end
19
+ end
20
+
21
+ describe '#cluster_admins' do
22
+ specify{ expect(subject.cluster_admins).to be_instance_of(Influxdb::Api::Namespaces::ClusterAdmins) }
23
+ specify{ expect(subject.cluster_admins.client).to eq(subject) }
24
+ end
25
+
26
+ describe '#shards' do
27
+ specify{ expect(subject.shards).to be_instance_of(Influxdb::Api::Namespaces::Shards) }
28
+ specify{ expect(subject.shards.client).to eq(subject) }
29
+ end
30
+
31
+ describe '#servers' do
32
+ specify{ expect(subject.servers).to be_instance_of(Influxdb::Api::Namespaces::Servers) }
33
+ specify{ expect(subject.servers.client).to eq(subject) }
34
+ end
35
+
36
+ describe '#version' do
37
+ let(:version){ 'InfluxDB v0.7.3 (git: 023abcdef) (leveldb: 1.8)' }
38
+
39
+ before do
40
+ stub_request(:get, 'http://root:root@localhost:8086/ping').
41
+ to_return(status: 200, body: '{}', headers: { 'X-Influxdb-Version' => version })
42
+ end
43
+
44
+ specify{ expect(subject.version).to be_instance_of(Influxdb::Api::ServerVersion) }
45
+ specify{ expect(subject.version.to_s).to eq(version) }
46
+ end
47
+
48
+ describe '#sync?' do
49
+ before do
50
+ stub_request(:get, 'http://root:root@localhost:8086/sync').
51
+ to_return(status: 200, body: 'true', headers: { 'Content-Type' => 'text/plain' })
52
+ end
53
+
54
+ specify{ expect(subject.sync?).to be_truthy }
55
+ end
56
+
57
+ describe '#interfaces' do
58
+ before do
59
+ stub_request(:get, 'http://root:root@localhost:8086/interfaces').
60
+ to_return(status: 200, body: '["default"]', headers: { 'Content-Type' => 'application/json' })
61
+ end
62
+
63
+ specify{ expect(subject.interfaces).to eq(["default"])}
64
+ end
65
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Influxdb::Api::ServerVersion do
4
+ let(:source){ 'InfluxDB v0.7.3 (git: 023abcdef) (leveldb: 1.8)' }
5
+
6
+ subject{ Influxdb::Api::ServerVersion.new(source) }
7
+
8
+ describe '#to_s' do
9
+ specify{ expect(subject.to_s).to eq(source) }
10
+ end
11
+
12
+ describe '#major' do
13
+ specify{ expect(subject.major).to eq(0) }
14
+ end
15
+
16
+ describe '#minor' do
17
+ specify{ expect(subject.minor).to eq(7) }
18
+ end
19
+
20
+ describe '#patch' do
21
+ specify{ expect(subject.patch).to eq(3) }
22
+ end
23
+
24
+ describe '#git' do
25
+ specify{ expect(subject.git).to eq('023abcdef') }
26
+ end
27
+
28
+ context 'engine' do
29
+ subject{ Influxdb::Api::ServerVersion.new(source).engine }
30
+
31
+ describe '#to_s' do
32
+ specify{ expect(subject.to_s).to eq('leveldb: 1.8.0') }
33
+ end
34
+
35
+ describe '#name' do
36
+ specify{ expect(subject.name).to eq('leveldb') }
37
+ end
38
+
39
+ describe '#major' do
40
+ specify{ expect(subject.major).to eq(1) }
41
+ end
42
+
43
+ describe '#minor' do
44
+ specify{ expect(subject.minor).to eq(8) }
45
+ end
46
+
47
+ describe '#patch' do
48
+ specify{ expect(subject.patch).to eq(0) }
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,28 @@
1
+ require 'bundler'
2
+ Bundler.require(:default, :test)
3
+
4
+ WebMock.disable_net_connect!(allow_localhost: false)
5
+
6
+ RSpec.configure do |config|
7
+ config.mock_with :rspec
8
+
9
+ config.around :each, time_freeze: ->(v){ v.is_a?(Date) || v.is_a?(Time) || v.is_a?(String) } do |example|
10
+ datetime = if example.metadata[:time_freeze].is_a?(String)
11
+ DateTime.parse(example.metadata[:time_freeze])
12
+ else
13
+ example.metadata[:time_freeze]
14
+ end
15
+
16
+ Timecop.freeze(datetime){ example.run }
17
+ end
18
+
19
+ config.around :each, time_travel: ->(v){ v.is_a?(Date) || v.is_a?(Time) || v.is_a?(String) } do |example|
20
+ datetime = if example.metadata[:time_travel].is_a?(String)
21
+ DateTime.parse(example.metadata[:time_travel])
22
+ else
23
+ example.metadata[:time_travel]
24
+ end
25
+
26
+ Timecop.travel(datetime){ example.run }
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: influxdb-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - undr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: 'Ruby client for InfluxDB '
84
+ email:
85
+ - undr@yandex.ru
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - influxdb-api.gemspec
98
+ - lib/influxdb-api.rb
99
+ - lib/influxdb.rb
100
+ - lib/influxdb/api.rb
101
+ - lib/influxdb/api/client.rb
102
+ - lib/influxdb/api/client/connection.rb
103
+ - lib/influxdb/api/client/connection_pool.rb
104
+ - lib/influxdb/api/client/errors.rb
105
+ - lib/influxdb/api/client/response.rb
106
+ - lib/influxdb/api/client/selector.rb
107
+ - lib/influxdb/api/configuration.rb
108
+ - lib/influxdb/api/database.rb
109
+ - lib/influxdb/api/extensions.rb
110
+ - lib/influxdb/api/namespaces.rb
111
+ - lib/influxdb/api/namespaces/base.rb
112
+ - lib/influxdb/api/namespaces/cluster_admins.rb
113
+ - lib/influxdb/api/namespaces/continuous_queries.rb
114
+ - lib/influxdb/api/namespaces/databases.rb
115
+ - lib/influxdb/api/namespaces/series.rb
116
+ - lib/influxdb/api/namespaces/servers.rb
117
+ - lib/influxdb/api/namespaces/shard_spaces.rb
118
+ - lib/influxdb/api/namespaces/shards.rb
119
+ - lib/influxdb/api/namespaces/users.rb
120
+ - lib/influxdb/api/namespaces/with_database.rb
121
+ - lib/influxdb/api/server_version.rb
122
+ - lib/influxdb/api/version.rb
123
+ - spec/lib/influxdb/api/client/connection_pool_spec.rb
124
+ - spec/lib/influxdb/api/client/connection_spec.rb
125
+ - spec/lib/influxdb/api/client/response_spec.rb
126
+ - spec/lib/influxdb/api/client/selector_spec.rb
127
+ - spec/lib/influxdb/api/client_spec.rb
128
+ - spec/lib/influxdb/api/configuration_spec.rb
129
+ - spec/lib/influxdb/api/database_spec.rb
130
+ - spec/lib/influxdb/api/namespaces/cluster_admins_spec.rb
131
+ - spec/lib/influxdb/api/namespaces/continuous_queries_spec.rb
132
+ - spec/lib/influxdb/api/namespaces/databases_spec.rb
133
+ - spec/lib/influxdb/api/namespaces/series_spec.rb
134
+ - spec/lib/influxdb/api/namespaces/servers_spec.rb
135
+ - spec/lib/influxdb/api/namespaces/shard_spaces_spec.rb
136
+ - spec/lib/influxdb/api/namespaces/shards_spec.rb
137
+ - spec/lib/influxdb/api/namespaces/users_spec.rb
138
+ - spec/lib/influxdb/api/namespaces_spec.rb
139
+ - spec/lib/influxdb/api/server_version_spec.rb
140
+ - spec/spec_helper.rb
141
+ homepage: https://github.com/undr/influxdb-api
142
+ licenses:
143
+ - MIT
144
+ metadata: {}
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 2.2.2
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: Ruby client for InfluxDB
165
+ test_files:
166
+ - spec/lib/influxdb/api/client/connection_pool_spec.rb
167
+ - spec/lib/influxdb/api/client/connection_spec.rb
168
+ - spec/lib/influxdb/api/client/response_spec.rb
169
+ - spec/lib/influxdb/api/client/selector_spec.rb
170
+ - spec/lib/influxdb/api/client_spec.rb
171
+ - spec/lib/influxdb/api/configuration_spec.rb
172
+ - spec/lib/influxdb/api/database_spec.rb
173
+ - spec/lib/influxdb/api/namespaces/cluster_admins_spec.rb
174
+ - spec/lib/influxdb/api/namespaces/continuous_queries_spec.rb
175
+ - spec/lib/influxdb/api/namespaces/databases_spec.rb
176
+ - spec/lib/influxdb/api/namespaces/series_spec.rb
177
+ - spec/lib/influxdb/api/namespaces/servers_spec.rb
178
+ - spec/lib/influxdb/api/namespaces/shard_spaces_spec.rb
179
+ - spec/lib/influxdb/api/namespaces/shards_spec.rb
180
+ - spec/lib/influxdb/api/namespaces/users_spec.rb
181
+ - spec/lib/influxdb/api/namespaces_spec.rb
182
+ - spec/lib/influxdb/api/server_version_spec.rb
183
+ - spec/spec_helper.rb