Class: Heroku::Client::HerokuPostgresql

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/heroku/client/heroku_postgresql.rb

Direct Known Subclasses

HerokuPostgresql::Client

Constant Summary collapse

Version =
11

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#action, #ask, #confirm, #confirm_billing, #confirm_command, #create_git_remote, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #error, error_with_failure, error_with_failure=, extended, extended_into, #fail, #format_bytes, #format_date, #format_error, #format_with_bang, #get_terminal_environment, #git, #has_git?, #home_directory, #host_name, #hprint, #hputs, included, included_into, #json_decode, #json_encode, #launchy, #line_formatter, #longest, #output_with_bang, #quantify, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #time_ago, #truncate, #with_tty

Constructor Details

#initialize(attachment) ⇒ HerokuPostgresql

Returns a new instance of HerokuPostgresql.



19
20
21
22
# File 'lib/heroku/client/heroku_postgresql.rb', line 19

def initialize(attachment)
  @attachment = attachment
  require 'rest_client'
end

Instance Attribute Details

#attachmentObject (readonly)

Returns the value of attribute attachment.



18
19
20
# File 'lib/heroku/client/heroku_postgresql.rb', line 18

def attachment
  @attachment
end

Class Method Details

.add_headers(headers) ⇒ Object



10
11
12
# File 'lib/heroku/client/heroku_postgresql.rb', line 10

def self.add_headers(headers)
  @headers.merge! headers
end

.headersObject



14
15
16
# File 'lib/heroku/client/heroku_postgresql.rb', line 14

def self.headers
  @headers
end

Instance Method Details

#get_database(extended = false) ⇒ Object



61
62
63
64
# File 'lib/heroku/client/heroku_postgresql.rb', line 61

def get_database(extended=false)
  query = extended ? '?extended=true' : ''
  http_get resource_name + query
end

#get_wait_statusObject



66
67
68
# File 'lib/heroku/client/heroku_postgresql.rb', line 66

def get_wait_status
  http_get "#{resource_name}/wait_status"
end

#heroku_postgresql_hostObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/heroku/client/heroku_postgresql.rb', line 24

def heroku_postgresql_host
  if attachment.starter_plan?
    ENV["HEROKU_POSTGRESQL_HOST"] || "postgres-starter-api"
  else
    if ENV['SHOGUN']
      "shogun-#{ENV['SHOGUN']}"
    else
      ENV["HEROKU_POSTGRESQL_HOST"] || "postgres-api"
    end
  end
end

#heroku_postgresql_resourceObject



40
41
42
43
44
45
46
47
# File 'lib/heroku/client/heroku_postgresql.rb', line 40

def heroku_postgresql_resource
  RestClient::Resource.new(
    "https://#{heroku_postgresql_host}.heroku.com/client/v11/databases",
    :user => Heroku::Auth.user,
    :password => Heroku::Auth.password,
    :headers => self.class.headers
    )
end

#ingressObject



49
50
51
# File 'lib/heroku/client/heroku_postgresql.rb', line 49

def ingress
  http_put "#{resource_name}/ingress"
end

#resetObject



53
54
55
# File 'lib/heroku/client/heroku_postgresql.rb', line 53

def reset
  http_put "#{resource_name}/reset"
end

#resource_nameObject



36
37
38
# File 'lib/heroku/client/heroku_postgresql.rb', line 36

def resource_name
  attachment.resource_name
end

#rotate_credentialsObject



57
58
59
# File 'lib/heroku/client/heroku_postgresql.rb', line 57

def rotate_credentials
  http_post "#{resource_name}/credentials_rotation"
end

#unfollowObject



70
71
72
# File 'lib/heroku/client/heroku_postgresql.rb', line 70

def unfollow
  http_put "#{resource_name}/unfollow"
end