Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to list cluster admins #14

Merged
merged 1 commit into from Nov 23, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -76,6 +76,16 @@ loop do
end
```

List cluster admins:

``` ruby
require 'influxdb'

influxdb = InfluxDB::Client.new

influxdb.get_cluster_admin_list
```

List databases:

``` ruby
Expand Down
7 changes: 7 additions & 0 deletions lib/influxdb/client.rb
Expand Up @@ -85,6 +85,13 @@ def delete_cluster_admin(username)
response = @http.request(Net::HTTP::Delete.new(url))
end

def get_cluster_admin_list
url = full_url("cluster_admins")

response = @http.request(Net::HTTP::Get.new(url))
JSON.parse(response.body)
end

def create_database_user(database, username, password)
url = full_url("db/#{database}/users")
data = JSON.generate({:name => username, :password => password})
Expand Down
11 changes: 11 additions & 0 deletions spec/influxdb/client_spec.rb
Expand Up @@ -94,6 +94,17 @@
end
end

describe "#get_cluster_admin_list" do
it "should GET a list of cluster admins" do
admin_list = [{"username"=>"root"}, {"username"=>"admin"}]
stub_request(:get, "http://influxdb.test:9999/cluster_admins").with(
:query => {:u => "username", :p => "password"}
).to_return(:body => JSON.generate(admin_list), :status => 200)

@influxdb.get_cluster_admin_list.should == admin_list
end
end

describe "#create_database_user" do
it "should POST to create a new database user" do
stub_request(:post, "http://influxdb.test:9999/db/foo/users").with(
Expand Down