heroku-api-postgres 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.example.env +2 -0
- data/Gemfile.lock +2 -2
- data/README.md +18 -1
- data/lib/heroku/api/postgres/backups.rb +6 -2
- data/lib/heroku/api/postgres/client.rb +11 -2
- data/lib/heroku/api/postgres/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e17b99dc543d3fd1e6f2a6715ac43d13755396889f8f31ce0446d2d21a388bf
|
4
|
+
data.tar.gz: f3ce7542620d9795cce4be9905ac2eb5858641a1b4e53ae23991dbd4177a3646
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9574ed0d23a7ecfbfa42ad9bdc840adb62c99838000e21c752ca26da8e71add8b2130014560f660b1480e8617672b2b217d597b16e488729262c3159cc12384a
|
7
|
+
data.tar.gz: b96833ab4c871a9c6af5fe2a642dafb66c6a011d69e5b6c57c619d64b1f1ec52bb4aed80e2ceeaaaf6dbcf6af360f469fbdfcf2b0b081a5079770caa307edcfe
|
data/.example.env
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -141,13 +141,30 @@ Returns a [BackupUrl](docs/models.md#backup_url)
|
|
141
141
|
|
142
142
|
---
|
143
143
|
|
144
|
+
```ruby
|
145
|
+
backup = backups_client.restore(database_id, dump_url)
|
146
|
+
```
|
147
|
+
Restores a dump from a public URL.
|
148
|
+
|
149
|
+
Returns a [Backup](docs/models.md#backup)
|
150
|
+
|
151
|
+
---
|
152
|
+
|
144
153
|
```ruby
|
145
154
|
backup = postgres_api_client.backups.wait(app_id, backup_id, wait_interval: 5)
|
146
155
|
```
|
147
|
-
Waits for the given backup to be ready.
|
156
|
+
Waits for the given backup/restore to be ready.
|
148
157
|
|
149
158
|
Polls every `wait_interval` seconds (default 3).
|
150
159
|
|
160
|
+
You can pass a block to be executed at each interval:
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
backup = postgres_api_client.backups.wait(app_id, backup_id) do |info|
|
164
|
+
puts "Processed #{info[:processed_bytes]} bytes"
|
165
|
+
end
|
166
|
+
```
|
167
|
+
|
151
168
|
|
152
169
|
### How do I get the database_id ?
|
153
170
|
You can obtain a database id by calling the Heroku Platform API
|
@@ -40,14 +40,18 @@ module Heroku
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def wait(app_id, backup_id, options = { wait_interval: 3 })
|
43
|
-
|
44
|
-
while waiting do
|
43
|
+
while true do
|
45
44
|
backup = info(app_id, backup_id)
|
45
|
+
yield(backup)
|
46
46
|
break if backup[:finished_at] && backup[:succeeded]
|
47
47
|
sleep(options[:wait_interval])
|
48
48
|
end
|
49
49
|
backup
|
50
50
|
end
|
51
|
+
|
52
|
+
def restore(database_id, backup_url)
|
53
|
+
@client.perform_post_request("/client/v11/databases/#{database_id}/restores", backup_url: backup_url)
|
54
|
+
end
|
51
55
|
end
|
52
56
|
end
|
53
57
|
end
|
@@ -36,9 +36,18 @@ module Heroku
|
|
36
36
|
parse_response(response)
|
37
37
|
end
|
38
38
|
|
39
|
+
def host_for(database)
|
40
|
+
starter_plan?(database) ? 'https://postgres-starter-api.heroku.com' : 'https://postgres-api.heroku.com'
|
41
|
+
end
|
42
|
+
|
43
|
+
def starter_plan?(database)
|
44
|
+
database[:plan].match(/(dev|basic)$/)
|
45
|
+
end
|
46
|
+
|
39
47
|
private
|
40
|
-
|
41
|
-
|
48
|
+
|
49
|
+
def build_uri(path, host: @basic_url)
|
50
|
+
URI.join(host, path)
|
42
51
|
end
|
43
52
|
|
44
53
|
def set_headers(req)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku-api-postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Rodi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|