class Keen::AccessKeys
Attributes
client[R]
Public Class Methods
new(client)
click to toggle source
# File lib/keen/access_keys.rb, line 5 def initialize(client) @client = client end
Public Instance Methods
access_keys_base_url()
click to toggle source
# File lib/keen/access_keys.rb, line 69 def access_keys_base_url client.ensure_project_id! "/#{client.api_version}/projects/#{client.project_id}/keys" end
all()
click to toggle source
# File lib/keen/access_keys.rb, line 17 def all() client.ensure_master_key! response = access_keys_get(client.master_key) client.process_response(response.code.to_i, response.body) end
create(key_body)
click to toggle source
For information on the format of the key_body, see keen.io/docs/api/#access-keys
# File lib/keen/access_keys.rb, line 26 def create(key_body) client.ensure_master_key! path = "" response = access_keys_post(client.master_key, path, key_body) client.process_response(response.code.to_i, response.body) end
delete(key)
click to toggle source
# File lib/keen/access_keys.rb, line 58 def delete(key) client.ensure_master_key! response = Keen::HTTP::Sync.new(client.api_url, client.proxy_url, client.read_timeout, client.open_timeout).delete( path: access_keys_base_url + "/#{key}", headers: client.api_headers(client.master_key, "sync") ) client.process_response(response.code.to_i, response.body) end
get(key)
click to toggle source
# File lib/keen/access_keys.rb, line 9 def get(key) client.ensure_master_key! path = "/#{key}" response = access_keys_get(client.master_key, path) client.process_response(response.code.to_i, response.body) end
revoke(key)
click to toggle source
# File lib/keen/access_keys.rb, line 42 def revoke(key) client.ensure_master_key! path = "/#{key}/revoke" response = access_keys_post(client.master_key, path) client.process_response(response.code.to_i, response.body) end
unrevoke(key)
click to toggle source
# File lib/keen/access_keys.rb, line 50 def unrevoke(key) client.ensure_master_key! path = "/#{key}/unrevoke" response = access_keys_post(client.master_key, path) client.process_response(response.code.to_i, response.body) end
update(key, key_body)
click to toggle source
# File lib/keen/access_keys.rb, line 34 def update(key, key_body) client.ensure_master_key! path = "/#{key}" response = access_keys_post(client.master_key, path, key_body) client.process_response(response.code.to_i, response.body) end
Private Instance Methods
access_keys_get(api_key, path = "")
click to toggle source
# File lib/keen/access_keys.rb, line 78 def access_keys_get(api_key, path = "") Keen::HTTP::Sync.new(client.api_url, client.proxy_url, client.read_timeout, client.open_timeout).get( path: access_keys_base_url + path, headers: client.api_headers(api_key, "sync") ) end
access_keys_post(api_key, path = "", body = "")
click to toggle source
# File lib/keen/access_keys.rb, line 85 def access_keys_post(api_key, path = "", body = "") Keen::HTTP::Sync.new(client.api_url, client.proxy_url, client.read_timeout, client.open_timeout).post( path: access_keys_base_url + path, headers: client.api_headers(api_key, "sync"), body: MultiJson.dump(body) ) end