class Heroku::Client::HerokuPostgresqlApp
Constants
- Version
Public Class Methods
headers()
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 7 def self.headers Heroku::Client::HerokuPostgresql.headers end
new(app_name)
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 11 def initialize(app_name) @app_name = app_name end
Public Instance Methods
display_heroku_warning(response)
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 78 def display_heroku_warning(response) warning = response.headers[:x_heroku_warning] display warning if warning response end
heroku_postgresql_host()
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 35 def heroku_postgresql_host if ENV['SHOGUN'] "shogun-#{ENV['SHOGUN']}.herokuapp.com" else determine_host(ENV["HEROKU_POSTGRESQL_HOST"], "postgres-api.heroku.com") end end
heroku_postgresql_resource()
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 43 def heroku_postgresql_resource RestClient::Resource.new( "https://#{heroku_postgresql_host}/client/v11/apps", :user => Heroku::Auth.user, :password => Heroku::Auth.password, :headers => self.class.headers ) end
http_delete(path)
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 70 def http_delete(path) checking_client_version do response = heroku_postgresql_resource[path].delete display_heroku_warning response sym_keys(json_decode(response.to_s)) end end
http_get(path)
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 52 def http_get(path) checking_client_version do retry_on_exception(RestClient::Exception) do response = heroku_postgresql_resource[path].get display_heroku_warning response sym_keys(json_decode(response.to_s)) end end end
http_post(path, payload = {})
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 62 def http_post(path, payload = {}) checking_client_version do response = heroku_postgresql_resource[path].post(json_encode(payload)) display_heroku_warning response sym_keys(json_decode(response.to_s)) end end
transfers()
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 15 def transfers http_get "#{@app_name}/transfers" end
transfers_cancel(id)
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 27 def transfers_cancel(id) http_post "#{@app_name}/transfers/#{URI.encode(id.to_s)}/actions/cancel" end
transfers_delete(id)
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 23 def transfers_delete(id) http_delete "#{@app_name}/transfers/#{URI.encode(id.to_s)}" end
transfers_get(id, verbose=false)
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 19 def transfers_get(id, verbose=false) http_get "#{@app_name}/transfers/#{URI.encode(id.to_s)}?verbose=#{verbose}" end
transfers_public_url(id)
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 31 def transfers_public_url(id) http_post "#{@app_name}/transfers/#{URI.encode(id.to_s)}/actions/public-url" end
Private Instance Methods
checking_client_version() { || ... }
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 104 def checking_client_version begin yield rescue RestClient::BadRequest => e if message = json_decode(e.response.to_s)["upgrade_message"] abort(message) else raise e end end end
determine_host(value, default)
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 86 def determine_host(value, default) if value.nil? default else "#{value}.herokuapp.com" end end
sym_keys(c)
click to toggle source
# File lib/heroku/client/heroku_postgresql_backups.rb, line 94 def sym_keys(c) if c.is_a?(Array) c.map { |e| sym_keys(e) } else c.inject({}) do |h, (k, v)| h[k.to_sym] = v; h end end end