mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 21:38:41 -05:00
Add http class for api token requests
This commit is contained in:
parent
e194f04ea9
commit
eee7aab760
2 changed files with 32 additions and 13 deletions
|
|
@ -36,4 +36,25 @@ class Http
|
|||
|
||||
return conn
|
||||
end
|
||||
|
||||
def self.get_conn_with_token(verbose, url, token)
|
||||
if url.nil?
|
||||
STDERR.puts "The url you provided was empty"
|
||||
exit 1
|
||||
end
|
||||
|
||||
if token.nil?
|
||||
STDERR.puts "The token you provided was empty"
|
||||
exit 1
|
||||
end
|
||||
|
||||
conn = Faraday.new(:url => url) do |faraday|
|
||||
faraday.request :url_encoded
|
||||
faraday.request :token_auth, token
|
||||
faraday.response :logger if verbose
|
||||
faraday.adapter Faraday.default_adapter
|
||||
end
|
||||
|
||||
return conn
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue