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, #app_owner, #ask, #confirm, #confirm_command, #create_git_remote, #debug, #debugging?, #default_org_host, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #error, #error_log, #error_log_path, 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?, #has_git_remote?, #has_http_git_entry_in_netrc, #home_directory, #hprint, #hputs, included, included_into, #json_decode, #json_encode, #launchy, #line_formatter, #longest, #org?, #org_host, #output_with_bang, #quantify, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #stderr_print, #stderr_puts, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #time_ago, #truncate, #update_git_remote, #warn_if_using_jruby, #with_tty

Constructor Details

#initialize(attachment) ⇒ HerokuPostgresql

Returns a new instance of HerokuPostgresql


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

def initialize(attachment)
  @attachment = attachment
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

#backupsObject

backups


102
103
104
# File 'lib/heroku/client/heroku_postgresql.rb', line 102

def backups
  http_get "#{resource_name}/transfers"
end

#backups_captureObject


110
111
112
# File 'lib/heroku/client/heroku_postgresql.rb', line 110

def backups_capture
  http_post "#{resource_name}/backups"
end

#backups_delete(id) ⇒ Object


118
119
120
# File 'lib/heroku/client/heroku_postgresql.rb', line 118

def backups_delete(id)
  http_delete "#{resource_name}/backups/#{URI.encode(id)}"
end

#backups_get(id, verbose = false) ⇒ Object


106
107
108
# File 'lib/heroku/client/heroku_postgresql.rb', line 106

def backups_get(id, verbose=false)
  http_get "#{resource_name}/transfers/#{URI.encode(id)}?verbose=#{verbose}"
end

#backups_restore(backup_url) ⇒ Object


114
115
116
# File 'lib/heroku/client/heroku_postgresql.rb', line 114

def backups_restore(backup_url)
  http_post "#{resource_name}/restores", 'backup_url' => backup_url
end

#connection_resetObject


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

def connection_reset
  http_post "#{resource_name}/connection_reset"
end

#get_database(extended = false) ⇒ Object


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

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

#get_wait_statusObject


73
74
75
# File 'lib/heroku/client/heroku_postgresql.rb', line 73

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

#heroku_postgresql_hostObject


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

def heroku_postgresql_host
  if attachment.starter_plan?
    determine_host(ENV["HEROKU_POSTGRESQL_HOST"], "postgres-starter-api.heroku.com")
  else
    if ENV['SHOGUN']
      "shogun-#{ENV['SHOGUN']}.herokuapp.com"
    else
      determine_host(ENV["HEROKU_POSTGRESQL_HOST"], "postgres-api.heroku.com")
    end
  end
end

#heroku_postgresql_resourceObject


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

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

#ingressObject


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

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

#maintenance_infoObject


89
90
91
# File 'lib/heroku/client/heroku_postgresql.rb', line 89

def maintenance_info
  http_get "#{resource_name}/maintenance"
end

#maintenance_runObject


93
94
95
# File 'lib/heroku/client/heroku_postgresql.rb', line 93

def maintenance_run
  http_post "#{resource_name}/maintenance"
end

#maintenance_window_set(description) ⇒ Object


97
98
99
# File 'lib/heroku/client/heroku_postgresql.rb', line 97

def maintenance_window_set(description)
  http_put "#{resource_name}/maintenance_window", 'description' => description
end

#metricsObject


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

def metrics
  http_get "#{resource_name}/metrics"
end

#pg_copy(source_name, source_url, target_name, target_url) ⇒ Object


122
123
124
125
126
127
128
129
# File 'lib/heroku/client/heroku_postgresql.rb', line 122

def pg_copy(source_name, source_url, target_name, target_url)
  http_post "#{resource_name}/transfers", {
    'from_name' => source_name,
    'from_url' => source_url,
    'to_name' => target_name,
    'to_url' => target_url,
  }
end

#resetObject


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

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

#resource_nameObject


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

def resource_name
  attachment.resource_name
end

#rotate_credentialsObject


64
65
66
# File 'lib/heroku/client/heroku_postgresql.rb', line 64

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

#schedule(opts = {}) ⇒ Object


135
136
137
# File 'lib/heroku/client/heroku_postgresql.rb', line 135

def schedule(opts={})
  http_post "#{resource_name}/transfer-schedules", opts
end

#schedulesObject


131
132
133
# File 'lib/heroku/client/heroku_postgresql.rb', line 131

def schedules
  http_get "#{resource_name}/transfer-schedules"
end

#unfollowObject


77
78
79
# File 'lib/heroku/client/heroku_postgresql.rb', line 77

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

#unschedule(id) ⇒ Object


139
140
141
# File 'lib/heroku/client/heroku_postgresql.rb', line 139

def unschedule(id)
  http_delete "#{resource_name}/transfer-schedules/#{URI.encode(id.to_s)}"
end

#upgradeObject


81
82
83
# File 'lib/heroku/client/heroku_postgresql.rb', line 81

def upgrade
  http_post "#{resource_name}/upgrade"
end

#upgrade_statusObject


85
86
87
# File 'lib/heroku/client/heroku_postgresql.rb', line 85

def upgrade_status
  http_get "#{resource_name}/upgrade_status"
end