mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 13:28:42 -05:00
Properly handle token requests
This commit is contained in:
parent
ad003d474b
commit
8616397c8e
1 changed files with 22 additions and 3 deletions
|
|
@ -12,7 +12,13 @@ class Auth
|
|||
end
|
||||
|
||||
resp_body = JSON.parse(resp.body)
|
||||
resp_body
|
||||
if resp_body["ok"]
|
||||
return resp_body["token"]
|
||||
else
|
||||
STDERR.puts "There was a problem with your request:"
|
||||
puts resp_body
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
def self.delete_token(verbose, url, user, password, token)
|
||||
|
|
@ -25,7 +31,13 @@ class Auth
|
|||
|
||||
response = conn.delete "/token/#{token}"
|
||||
res_body = JSON.parse(response)
|
||||
puts res_body
|
||||
if resp_body["ok"]
|
||||
puts resp_body
|
||||
else
|
||||
STDERR.puts "There was a problem with your request:"
|
||||
puts resp_body
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
def self.token_status(verbose, url, user, password, token)
|
||||
|
|
@ -38,6 +50,13 @@ class Auth
|
|||
|
||||
response = conn.get "/token/#{token}"
|
||||
res_body = JSON.parse(response.body)
|
||||
puts res_body
|
||||
|
||||
if resp_body["ok"]
|
||||
puts resp_body
|
||||
else
|
||||
STDERR.puts "There was a problem with your request:"
|
||||
puts resp_body
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue