bin/acquia in acquia_toolbelt-1.0.0 vs bin/acquia in acquia_toolbelt-1.1.0

- old
+ new

@@ -39,12 +39,17 @@ # Returns a JSON string of the body. def acquia_api_call(resource, method = "GET", data = {}) n = Netrc.read @acquia_user, @acquia_password = n["cloudapi.acquia.com"] - #conn = Faraday.new(:proxy => "http://csydl217.au.fcl.internal:3128") - conn = Faraday.new + # Check if the user is behind a proxy and add the proxy settings if found. + if using_proxy? + conn = Faraday.new(:proxy => ENV["HTTPS_PROXY"]) + else + conn = Faraday.new + end + conn.basic_auth(@acquia_user, @acquia_password) case method when "GET" response = conn.get "https://cloudapi.acquia.com/v1/#{resource}.json" @@ -102,9 +107,20 @@ return end purge_request = acquia_api_call "sites/#{subscription}/envs/#{environment}/domains/#{domain}/cache", "DELETE" success "#{domain} has been successfully purged." if purge_request["id"] + end + + # Internal: Check whether a proxy is in use. + # + # Return boolean based on whether HTTPS_PROXY is set. + def using_proxy? + if ENV["HTTPS_PROXY"] + true + else + false + end end } # Public: Log into the Acquia Cloud API. # \ No newline at end of file