heroku-api-postgres 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +32 -22
- data/lib/heroku/api/postgres/backups.rb +10 -0
- data/lib/heroku/api/postgres/client.rb +0 -12
- data/lib/heroku/api/postgres/databases.rb +12 -0
- 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: c7a09cc3fbeffddb666ebaf4aea6bcbaba6484444324fea9a9e1ebae90cdd60d
|
4
|
+
data.tar.gz: 37b4d464d7aa946682746bd681d249b734c25c7af135765a5918f1d602871b5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c993332ae8a356df764756757fcedf7d49aa434c8798272ace192615efe69df3af8e02ecc7e7d0d0ea6f9f44ca5a83d77ec1acaef728f3a8ab24e1ee3270bf0b
|
7
|
+
data.tar.gz: 0cf779f3a5dc93ce0b908d1cdc02e086fae30c993d71b1c5020ae2ab27f4ca22f11832ee2e71e2a2e7dcc3ecb9acca33fb90358ddfec769e623f97cda2e2607e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -39,7 +39,6 @@ Even if this gem does not require `platform-api` to be installed, you probably w
|
|
39
39
|
```ruby
|
40
40
|
# from platform api gem
|
41
41
|
platform_api_client = PlatformAPI.connect_oauth(ENV['HEROKU_OAUTH_TOKEN'])
|
42
|
-
|
43
42
|
```
|
44
43
|
|
45
44
|
this gem client needs to be instantiated as well in a similar way
|
@@ -51,28 +50,29 @@ postgres_api_client = Heroku::Api::Postgres.connect_oauth(ENV['HEROKU_OAUTH_TOKE
|
|
51
50
|
Look into [Models](docs/models.rb) for a detailed description of the JSON objects returned by the APIs.
|
52
51
|
Those are the bare objects returned by the official Heroku API.
|
53
52
|
|
54
|
-
|
53
|
+
### Databases
|
55
54
|
|
56
55
|
```ruby
|
57
|
-
|
56
|
+
databases_client = postgres_api_client.databases
|
58
57
|
```
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
### Databases
|
59
|
+
---
|
64
60
|
|
65
61
|
```ruby
|
66
|
-
|
62
|
+
database_info = databases_client.info(database_id)
|
67
63
|
```
|
68
64
|
|
69
|
-
|
65
|
+
returns a [Database](docs/models.md#database).
|
66
|
+
|
67
|
+
---
|
70
68
|
|
71
69
|
```ruby
|
72
|
-
|
70
|
+
database = postgres_api_client.databases.wait(database_id, wait_interval: 5)
|
73
71
|
```
|
72
|
+
Waits for the given database to be ready.
|
73
|
+
|
74
|
+
Polls every `wait_interval` seconds (default 3).
|
74
75
|
|
75
|
-
returns a [Database](docs/models.md#database).
|
76
76
|
|
77
77
|
### Backups
|
78
78
|
|
@@ -80,7 +80,7 @@ returns a [Database](docs/models.md#database).
|
|
80
80
|
backups_client = postgres_api_client.backups
|
81
81
|
```
|
82
82
|
|
83
|
-
|
83
|
+
---
|
84
84
|
|
85
85
|
```ruby
|
86
86
|
backups = backups_client.info(app_id, backup_id)
|
@@ -88,7 +88,7 @@ backups = backups_client.info(app_id, backup_id)
|
|
88
88
|
|
89
89
|
returns a [Backup](docs/models.md#backup).
|
90
90
|
|
91
|
-
|
91
|
+
---
|
92
92
|
|
93
93
|
```ruby
|
94
94
|
backups = backups_client.list(app_id)
|
@@ -100,15 +100,17 @@ The app_id can be either the name of your heroku app or the id.
|
|
100
100
|
|
101
101
|
[Check official API](https://devcenter.heroku.com/articles/platform-api-reference#app)
|
102
102
|
|
103
|
-
|
103
|
+
---
|
104
104
|
|
105
105
|
```ruby
|
106
106
|
schedules = backups_client.schedules(database_id)
|
107
107
|
```
|
108
108
|
|
109
|
-
|
109
|
+
Returns all the backup schedules associated with the database.
|
110
110
|
|
111
|
-
|
111
|
+
Returns an array of [Schedule](docs/models.md#schedule)
|
112
|
+
|
113
|
+
---
|
112
114
|
|
113
115
|
```ruby
|
114
116
|
schedule = backups_client.schedule(database_id)
|
@@ -118,25 +120,33 @@ Schedules the backups at 00:00 UTC.
|
|
118
120
|
|
119
121
|
Returns a [Schedule](docs/models.md#schedule)
|
120
122
|
|
123
|
+
---
|
121
124
|
|
122
|
-
#### Capture
|
123
|
-
Captures a new backup for the given database
|
124
125
|
|
125
126
|
```ruby
|
126
127
|
backup = backups_client.capture(database_id)
|
127
128
|
```
|
129
|
+
Captures a new backup for the given database
|
128
130
|
|
129
|
-
|
131
|
+
Returns a [Backup](docs/models.md#backup)
|
130
132
|
|
131
|
-
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
backup_url = backups_client.url(app_id, backup_num)
|
136
|
+
```
|
132
137
|
Returns a temporary, public accessible URL to download a backup.
|
133
138
|
Needs the `num` attribute of a Backup.
|
134
139
|
|
140
|
+
Returns a [BackupUrl](docs/models.md#backup_url)
|
141
|
+
|
142
|
+
---
|
143
|
+
|
135
144
|
```ruby
|
136
|
-
|
145
|
+
backup = postgres_api_client.backups.wait(app_id, backup_id, wait_interval: 5)
|
137
146
|
```
|
147
|
+
Waits for the given backup to be ready.
|
138
148
|
|
139
|
-
|
149
|
+
Polls every `wait_interval` seconds (default 3).
|
140
150
|
|
141
151
|
|
142
152
|
### How do I get the database_id ?
|
@@ -38,6 +38,16 @@ module Heroku
|
|
38
38
|
def url(app_id, backup_num)
|
39
39
|
@client.perform_post_request("/client/v11/apps/#{app_id}/transfers/#{backup_num}/actions/public-url")
|
40
40
|
end
|
41
|
+
|
42
|
+
def wait(app_id, backup_id, options = { wait_interval: 3 })
|
43
|
+
waiting = true
|
44
|
+
while waiting do
|
45
|
+
backup = info(app_id, backup_id)
|
46
|
+
break if backup[:finished_at] && backup[:succeeded]
|
47
|
+
sleep(options[:wait_interval])
|
48
|
+
end
|
49
|
+
backup
|
50
|
+
end
|
41
51
|
end
|
42
52
|
end
|
43
53
|
end
|
@@ -11,18 +11,6 @@ module Heroku
|
|
11
11
|
@basic_url = 'https://postgres-starter-api.heroku.com'
|
12
12
|
end
|
13
13
|
|
14
|
-
# original call returns simply a database object, therefore I call the info API.
|
15
|
-
# perform_get_request "/client/v11/databases/#{database_id}/wait_status"
|
16
|
-
def wait(database_id, options = { wait_interval: 3 })
|
17
|
-
waiting = true
|
18
|
-
while waiting do
|
19
|
-
database = databases.info(database_id)
|
20
|
-
break unless database[:waiting?]
|
21
|
-
sleep(options[:wait_interval])
|
22
|
-
end
|
23
|
-
database
|
24
|
-
end
|
25
|
-
|
26
14
|
def backups
|
27
15
|
@backups ||= Backups.new(self)
|
28
16
|
end
|
@@ -9,6 +9,18 @@ module Heroku
|
|
9
9
|
@client = client
|
10
10
|
end
|
11
11
|
|
12
|
+
# original call returns simply a database object, therefore I call the info API.
|
13
|
+
# perform_get_request "/client/v11/databases/#{database_id}/wait_status"
|
14
|
+
def wait(database_id, options = { wait_interval: 3 })
|
15
|
+
waiting = true
|
16
|
+
while waiting do
|
17
|
+
database = info(database_id)
|
18
|
+
break unless database[:waiting?]
|
19
|
+
sleep(options[:wait_interval])
|
20
|
+
end
|
21
|
+
database
|
22
|
+
end
|
23
|
+
|
12
24
|
def info(database_id)
|
13
25
|
@client.perform_get_request("/client/v11/databases/#{database_id}")
|
14
26
|
end
|
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.8.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-03-
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|