module TreasureData::API::User
Public Instance Methods
add_apikey(user)
click to toggle source
@param [String] user @return [true]
# File lib/td/client/api/user.rb, line 89 def add_apikey(user) code, body, res = post("/v3/user/apikey/add/#{e user}") if code != "200" raise_error("Adding API key failed", res) end return true end
add_user(name, org, email, password)
click to toggle source
@param [String] name @param [String] org @param [String] email @param [String] password @return [true]
# File lib/td/client/api/user.rb, line 45 def add_user(name, org, email, password) params = {'organization'=>org, :email=>email, :password=>password} code, body, res = post("/v3/user/add/#{e name}", params) if code != "200" raise_error("Adding user failed", res) end return true end
authenticate(user, password)
click to toggle source
@param [String] user @param [String] password @return [String] API
key
# File lib/td/client/api/user.rb, line 11 def authenticate(user, password) code, body, res = post("/v3/user/authenticate", {'user'=>user, 'password'=>password}) if code != "200" if code == "400" raise_error("Authentication failed", res, AuthError) else raise_error("Authentication failed", res) end end js = checked_json(body, %w[apikey]) apikey = js['apikey'] return apikey end
change_email(user, email)
click to toggle source
@param [String] user @param [String] email @return [true]
# File lib/td/client/api/user.rb, line 67 def change_email(user, email) params = {'email' => email} code, body, res = post("/v3/user/email/change/#{e user}", params) if code != "200" raise_error("Changing email failed", res) end return true end
change_my_password(old_password, password)
click to toggle source
@param [String] old_password @param [String] password @return [true]
# File lib/td/client/api/user.rb, line 124 def change_my_password(old_password, password) params = {'old_password' => old_password, 'password' => password} code, body, res = post("/v3/user/password/change", params) if code != "200" raise_error("Changing password failed", res) end return true end
change_password(user, password)
click to toggle source
@param [String] user @param [String] password @return [true]
# File lib/td/client/api/user.rb, line 112 def change_password(user, password) params = {'password' => password} code, body, res = post("/v3/user/password/change/#{e user}", params) if code != "200" raise_error("Changing password failed", res) end return true end
list_apikeys(user)
click to toggle source
@param [String] user @return [Array<String>] API
keys as array
# File lib/td/client/api/user.rb, line 78 def list_apikeys(user) code, body, res = get("/v3/user/apikey/list/#{e user}") if code != "200" raise_error("List API keys failed", res) end js = checked_json(body, %w[apikeys]) return js['apikeys'] end
list_users()
click to toggle source
@return [Array]
# File lib/td/client/api/user.rb, line 26 def list_users code, body, res = get("/v3/user/list") if code != "200" raise_error("List users failed", res) end js = checked_json(body, %w[users]) result = js["users"].map {|roleinfo| name = roleinfo['name'] email = roleinfo['email'] [name, nil, nil, email] # set nil to org and role for API compatibility } return result end
remove_apikey(user, apikey)
click to toggle source
@param [String] user @param [String] apikey @return [true]
# File lib/td/client/api/user.rb, line 100 def remove_apikey(user, apikey) params = {'apikey' => apikey} code, body, res = post("/v3/user/apikey/remove/#{e user}", params) if code != "200" raise_error("Removing API key failed", res) end return true end
remove_user(user)
click to toggle source
@param [String] user @return [true]
# File lib/td/client/api/user.rb, line 56 def remove_user(user) code, body, res = post("/v3/user/remove/#{e user}") if code != "200" raise_error("Removing user failed", res) end return true end