heroku-api-postgres 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.example.env +2 -1
- data/.github/FUNDING.yml +1 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -0
- data/README.md +31 -7
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/docs/services.md +8 -8
- data/heroku-api-postgres.gemspec +9 -1
- data/lib/heroku/api/postgres/backups.rb +21 -21
- data/lib/heroku/api/postgres/client.rb +33 -4
- data/lib/heroku/api/postgres/credentials.rb +34 -0
- data/lib/heroku/api/postgres/databases.rb +9 -12
- data/lib/heroku/api/postgres/version.rb +3 -1
- data/lib/heroku/api/postgres.rb +3 -0
- metadata +31 -11
- data/Gemfile.lock +0 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33fc320b5b73a7a140e6af276b8f7f69b9ae4ef97170edf19e462fab253991db
|
4
|
+
data.tar.gz: 14d7757c4b7a78e5f9a5cc7da37143c808d83622374fd333303eebedeecbe5b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfaaa61d427515bec615afb3bc59dfe7950238654e497e9784fd6965a0bc4b5ca2fec3a9388648644fa94d7f9dd7a1bbee4e2c05b47f02bbc115fe965262beef
|
7
|
+
data.tar.gz: 5503f7c5feda7c5cddbad119efccba8370e2a90117ffa30101f90317871c04cb501b715febbdf1f3e215788d3850d0e888434b261c7605a0f39fa56386f8ac23
|
data/.example.env
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
HEROKU_OAUTH_TOKEN=a_valid_oauth_token
|
2
2
|
VALID_APP_ID_WITH_DATABASE=valid_app_id_with_database
|
3
3
|
VALID_DATABASE_ID_WITH_SCHEDULES=a_valid_database_id_with_a_schedule
|
4
|
-
|
4
|
+
VALID_APP_ID_WITH_DB_IN_PRO_PLAN=a_valid_app_id_with_database_in_pro_plan
|
5
|
+
VALID_DATABASE_ID_WITH_PRO_PLAN=a_valid_database_id_in_pro_plan
|
5
6
|
VALID_APP_ID=valid_app_id
|
6
7
|
VALID_DUMP_URL=valid_dump_public_url
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: [coorasse]
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.3
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
## 0.12.0
|
2
|
+
|
3
|
+
* [#18](https://github.com/coorasse/heroku-api-postgres/pull/18): Support ruby 3.0. ([@louism517][])
|
4
|
+
* [#15](https://github.com/coorasse/heroku-api-postgres/pull/15): Return latest backup if backup_num is not provided. ([@deepakmahakale][])
|
5
|
+
* [#14](https://github.com/coorasse/heroku-api-postgres/pull/14): Add support for rotating credentials. ([@avokhmin][])
|
6
|
+
* [#13](https://github.com/coorasse/heroku-api-postgres/pull/13): Allow to use hour and timezone when scheduling backups. ([@avokhmin][])
|
7
|
+
|
8
|
+
[@avokhmin]: https://github.com/avokhmin
|
9
|
+
[@deepakmahakale]: https://github.com/deepakmahakale
|
10
|
+
[@louism517]: https://github.com/louism517
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# Heroku::Api::Postgres
|
2
2
|
|
3
|
+
**This gem has been extracted from https://db-backups.com.**
|
4
|
+
|
5
|
+
**Your "one click" backup solution for Heroku apps.**
|
6
|
+
|
3
7
|
Ruby library to invoke Heroku Postgres APIs.
|
4
|
-
An extension to the official [Platform API]() gem to introduce the missing APIs for Postgres.
|
8
|
+
An extension to the official [Platform API](https://github.com/heroku/platform-api) gem to introduce the missing APIs for Postgres.
|
5
9
|
|
6
10
|
[](https://travis-ci.org/coorasse/heroku-api-postgres)
|
7
11
|
[](https://codeclimate.com/github/coorasse/heroku-api-postgres/maintainability)
|
@@ -10,6 +14,7 @@ An extension to the official [Platform API]() gem to introduce the missing APIs
|
|
10
14
|
therefore is unrealistic that a breaking change in the APIs would break it, since it means it would break
|
11
15
|
both this gem and the official Heroku CLI.
|
12
16
|
|
17
|
+
|
13
18
|
Not all APIs are implemented at the moment but we are working hard on implementing all of them.
|
14
19
|
|
15
20
|
Please check the [list of implemented and not implemented services](docs/services.md).
|
@@ -34,7 +39,8 @@ Or install it yourself as:
|
|
34
39
|
|
35
40
|
## Usage
|
36
41
|
|
37
|
-
This gem client needs to be instantiated in a similar way to the PlatformAPI
|
42
|
+
This gem client needs to be instantiated in a similar way to the [PlatformAPI](https://github.com/heroku/platform-api).
|
43
|
+
You can use the same oauth key that you use for the PlatformAPI.
|
38
44
|
|
39
45
|
```ruby
|
40
46
|
postgres_api_client = Heroku::Api::Postgres.connect_oauth(ENV['HEROKU_OAUTH_TOKEN'])
|
@@ -52,7 +58,7 @@ databases_client = postgres_api_client.databases
|
|
52
58
|
---
|
53
59
|
|
54
60
|
```ruby
|
55
|
-
database_info = databases_client.info(database_id)
|
61
|
+
database_info = databases_client.info(app_id, database_id)
|
56
62
|
```
|
57
63
|
|
58
64
|
returns a [Database](docs/models.md#database).
|
@@ -60,13 +66,27 @@ returns a [Database](docs/models.md#database).
|
|
60
66
|
---
|
61
67
|
|
62
68
|
```ruby
|
63
|
-
database = postgres_api_client.databases.wait(database_id, wait_interval: 5)
|
69
|
+
database = postgres_api_client.databases.wait(app_id, database_id, wait_interval: 5)
|
64
70
|
```
|
65
71
|
|
66
72
|
Waits for the given database to be ready.
|
67
73
|
|
68
74
|
Polls every `wait_interval` seconds (default 3).
|
69
75
|
|
76
|
+
### Credentials
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
credentials_client = postgres_api_client.credentials
|
80
|
+
```
|
81
|
+
|
82
|
+
---
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
credentials_client.rotate(app_id, database_id)
|
86
|
+
```
|
87
|
+
|
88
|
+
Rotate the database credentials.
|
89
|
+
|
70
90
|
### Backups
|
71
91
|
|
72
92
|
```ruby
|
@@ -163,20 +183,24 @@ end
|
|
163
183
|
You can obtain a database id by calling the Heroku Platform API
|
164
184
|
|
165
185
|
```ruby
|
186
|
+
heroku = PlatformAPI.connect_oauth(ENV['HEROKU_OAUTH_TOKEN'])
|
166
187
|
addons = heroku.addon.list
|
167
188
|
databases = addons.select { |addon| addon['addon_service']['name'] == 'heroku-postgresql' }
|
168
189
|
databases_ids = databases.map{ |addon| addon['id'] }
|
169
190
|
```
|
170
191
|
|
171
|
-
Check also the [
|
192
|
+
Check also the [Official API](https://devcenter.heroku.com/articles/platform-api-reference#add-on)
|
172
193
|
|
173
194
|
## Development
|
174
195
|
|
175
196
|
After checking out the repo, run `bin/setup` to install dependencies.
|
176
|
-
Then, run `rake spec` to run the tests.
|
197
|
+
Then, run `rake spec` to run the tests.
|
177
198
|
You can run `bin/check` to run linter and the tests together.
|
178
199
|
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
179
200
|
|
201
|
+
You need some app and database ids to run the tests and record the cassettes.
|
202
|
+
In particular you need an app with a postgres database on the free plan and one with a database on a pro plan.
|
203
|
+
|
180
204
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
181
205
|
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`,
|
182
206
|
which will create a git tag for the version, push git commits and tags,
|
@@ -194,5 +218,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
194
218
|
|
195
219
|
## Code of Conduct
|
196
220
|
|
197
|
-
Everyone interacting in the Heroku::Api::Postgres project’s codebases, issue trackers, chat rooms and mailing lists is
|
221
|
+
Everyone interacting in the `Heroku::Api::Postgres` project’s codebases, issue trackers, chat rooms and mailing lists is
|
198
222
|
expected to follow the [code of conduct](https://github.com/coorasse/heroku-api-postgres/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/docs/services.md
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
This list contains all postgres commands supported by the official CLI.
|
4
4
|
Source: https://devcenter.heroku.com/articles/heroku-cli-commands
|
5
5
|
|
6
|
-
- [x] pg --> `client.databases.info(database_id)`
|
6
|
+
- [x] pg --> `client.databases.info(app_id, database_id)`
|
7
7
|
|
8
8
|
- [x] pg:backups --> `client.backups.list(app_id)`
|
9
9
|
|
10
10
|
- [ ] pg:backups:cancel
|
11
11
|
|
12
|
-
- [x] pg:backups:capture ---> `client.backups.capture(database_id)`
|
12
|
+
- [x] pg:backups:capture ---> `client.backups.capture(app_id, database_id)`
|
13
13
|
The command returns immediately, without waiting for the capture to be completed.
|
14
14
|
`--wait-interval` not implemented. `--snapshot` not implemented.
|
15
15
|
|
@@ -19,16 +19,16 @@ The command returns immediately, without waiting for the capture to be completed
|
|
19
19
|
|
20
20
|
- [x] pg:backups:info --> `client.backups.info(app_id, backup_id)`
|
21
21
|
|
22
|
-
- [x] pg:backups:restore --> `client.backups.restore(database_id, dump_url)`
|
22
|
+
- [x] pg:backups:restore --> `client.backups.restore(app_id, database_id, dump_url)`
|
23
23
|
The command works only with public URLs. It does not support all the features of the original
|
24
24
|
`heroku pg:backups:restore` command, like restoring directly from another database.
|
25
25
|
The command returns immediately, without waiting for the capture to be completed.
|
26
26
|
You can use the command `client.backups.wait(app_id, restore[:num])` to wait for it to be ready.
|
27
27
|
|
28
|
-
- [x] pg:backups:schedule --> `client.backups.schedule(database_id)`
|
28
|
+
- [x] pg:backups:schedule --> `client.backups.schedule(app_id, database_id)`
|
29
29
|
|
30
30
|
|
31
|
-
- [x] pg:backups:schedules --> `client.backups.schedules(database_id)`
|
31
|
+
- [x] pg:backups:schedules --> `client.backups.schedules(app_id, database_id)`
|
32
32
|
|
33
33
|
- [ ] pg:backups:unschedule
|
34
34
|
|
@@ -46,13 +46,13 @@ You can use the command `client.backups.wait(app_id, restore[:num])` to wait for
|
|
46
46
|
|
47
47
|
- [ ] pg:credentials:repair-default
|
48
48
|
|
49
|
-
- [
|
49
|
+
- [x] pg:credentials:rotate --> `client.credentials.rotate(app_id, database_id)`
|
50
50
|
|
51
51
|
- [ ] pg:credentials:url
|
52
52
|
|
53
53
|
- [ ] pg:diagnose
|
54
54
|
|
55
|
-
- [x] pg:info --> `client.databases.info(database_id)`
|
55
|
+
- [x] pg:info --> `client.databases.info(app_id, database_id)`
|
56
56
|
|
57
57
|
- [ ] pg:kill
|
58
58
|
|
@@ -96,5 +96,5 @@ You can use the command `client.backups.wait(app_id, restore[:num])` to wait for
|
|
96
96
|
|
97
97
|
- [ ] pg:upgrade
|
98
98
|
|
99
|
-
- [x] pg:wait --> `client.wait(database_id)`
|
99
|
+
- [x] pg:wait --> `client.wait(app_id, database_id)`
|
100
100
|
Waits for a database to be ready.
|
data/heroku-api-postgres.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'heroku/api/postgres/version'
|
@@ -13,6 +15,11 @@ Gem::Specification.new do |spec|
|
|
13
15
|
spec.homepage = 'https://github.com/coorasse/heroku-api-postgres'
|
14
16
|
spec.license = 'MIT'
|
15
17
|
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/coorasse/heroku-api-postgres"
|
20
|
+
spec.metadata["changelog_uri"] = "https://github.com/coorasse/heroku-api-postgres/blob/main/CHANGELOG.md"
|
21
|
+
spec.metadata["funding_uri"] = "https://github.com/sponsors/coorasse"
|
22
|
+
|
16
23
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
24
|
f.match(%r{^(test|spec|features)/})
|
18
25
|
end
|
@@ -23,7 +30,8 @@ Gem::Specification.new do |spec|
|
|
23
30
|
spec.add_dependency 'platform-api'
|
24
31
|
spec.add_development_dependency 'bundler', '~> 1.17'
|
25
32
|
spec.add_development_dependency 'dotenv'
|
26
|
-
spec.add_development_dependency '
|
33
|
+
spec.add_development_dependency 'pry'
|
34
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
27
35
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
36
|
spec.add_development_dependency 'rubocop', '0.60.0'
|
29
37
|
spec.add_development_dependency 'vcr', '~> 4.0.0'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'net/http'
|
2
4
|
require 'json'
|
3
5
|
require 'platform-api'
|
@@ -23,21 +25,30 @@ module Heroku
|
|
23
25
|
|
24
26
|
def schedules(app_id, database_id)
|
25
27
|
@client.perform_get_request("/client/v11/databases/#{database_id}/transfer-schedules",
|
26
|
-
host: db_host(app_id))
|
28
|
+
host: db_host(app_id, database_id))
|
27
29
|
end
|
28
30
|
|
29
|
-
def schedule(app_id, database_id)
|
31
|
+
def schedule(app_id, database_id, hour: 0o0, timezone: 'UTC')
|
30
32
|
@client.perform_post_request("/client/v11/databases/#{database_id}/transfer-schedules",
|
31
|
-
{ hour:
|
32
|
-
timezone:
|
33
|
-
schedule_name: 'DATABASE_URL' }, host: db_host(app_id))
|
33
|
+
{ hour: hour,
|
34
|
+
timezone: timezone,
|
35
|
+
schedule_name: 'DATABASE_URL' }, host: db_host(app_id, database_id))
|
34
36
|
end
|
35
37
|
|
36
38
|
def capture(app_id, database_id)
|
37
|
-
@client.perform_post_request("/client/v11/databases/#{database_id}/backups",
|
39
|
+
@client.perform_post_request("/client/v11/databases/#{database_id}/backups",
|
40
|
+
{},
|
41
|
+
host: db_host(app_id, database_id))
|
38
42
|
end
|
39
43
|
|
40
|
-
def url(app_id, backup_num)
|
44
|
+
def url(app_id, backup_num = nil)
|
45
|
+
unless backup_num
|
46
|
+
transfers = list(app_id)
|
47
|
+
last_transfer =
|
48
|
+
transfers.select { |t| t[:succeeded] && t[:to_type] == 'gof3r' }
|
49
|
+
.max_by { |t| t[:created_at] }
|
50
|
+
backup_num = last_transfer[:num]
|
51
|
+
end
|
41
52
|
@client.perform_post_request("/client/v11/apps/#{app_id}/transfers/#{backup_num}/actions/public-url")
|
42
53
|
end
|
43
54
|
|
@@ -55,24 +66,13 @@ module Heroku
|
|
55
66
|
|
56
67
|
def restore(app_id, database_id, backup_url)
|
57
68
|
@client.perform_post_request("/client/v11/databases/#{database_id}/restores",
|
58
|
-
{ backup_url: backup_url }, host: db_host(app_id))
|
69
|
+
{ backup_url: backup_url }, host: db_host(app_id, database_id))
|
59
70
|
end
|
60
71
|
|
61
72
|
private
|
62
73
|
|
63
|
-
def
|
64
|
-
@
|
65
|
-
end
|
66
|
-
|
67
|
-
def db_host(app_id)
|
68
|
-
database = heroku_client.addon.list_by_app(app_id).find do |addon|
|
69
|
-
addon['addon_service']['name'] == 'heroku-postgresql'
|
70
|
-
end
|
71
|
-
databases.host_for(database)
|
72
|
-
end
|
73
|
-
|
74
|
-
def heroku_client
|
75
|
-
@heroku_client ||= PlatformAPI.connect_oauth(@client.oauth_client_key)
|
74
|
+
def db_host(app_id, database_id)
|
75
|
+
@client.db_host(app_id, database_id)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Heroku
|
2
4
|
module Api
|
3
5
|
module Postgres
|
@@ -6,11 +8,15 @@ module Heroku
|
|
6
8
|
end
|
7
9
|
|
8
10
|
class Client
|
9
|
-
|
11
|
+
STARTER_HOST = 'https://postgres-starter-api.heroku.com'
|
12
|
+
PRO_HOST = 'https://postgres-api.heroku.com'
|
13
|
+
|
14
|
+
attr_reader :oauth_client_key, :heroku_client
|
10
15
|
|
11
16
|
def initialize(oauth_client_key)
|
12
17
|
@oauth_client_key = oauth_client_key
|
13
|
-
@basic_url =
|
18
|
+
@basic_url = STARTER_HOST
|
19
|
+
@heroku_client = PlatformAPI.connect_oauth(oauth_client_key)
|
14
20
|
end
|
15
21
|
|
16
22
|
def backups
|
@@ -21,8 +27,23 @@ module Heroku
|
|
21
27
|
@databases ||= Databases.new(self)
|
22
28
|
end
|
23
29
|
|
30
|
+
def credentials
|
31
|
+
@credentials ||= Credentials.new(self)
|
32
|
+
end
|
33
|
+
|
34
|
+
# the database id matches the field `id` in pro plans and the field addon_service.id in free plans
|
35
|
+
def db_host(app_id, database_id)
|
36
|
+
all_addons = heroku_client.addon.list_by_app(app_id)
|
37
|
+
database_json = all_addons.find do |addon|
|
38
|
+
[addon['id'], addon['addon_service']['id']].include?(database_id)
|
39
|
+
end
|
40
|
+
return STARTER_HOST if database_json.nil?
|
41
|
+
|
42
|
+
host_for(database_json)
|
43
|
+
end
|
44
|
+
|
24
45
|
def perform_get_request(path, options = {})
|
25
|
-
url = build_uri(path, options)
|
46
|
+
url = build_uri(path, **options)
|
26
47
|
req = Net::HTTP::Get.new(url)
|
27
48
|
add_auth_headers(req)
|
28
49
|
response = start_request(req, url)
|
@@ -30,7 +51,7 @@ module Heroku
|
|
30
51
|
end
|
31
52
|
|
32
53
|
def perform_post_request(path, params = {}, options = {})
|
33
|
-
url = build_uri(path, options)
|
54
|
+
url = build_uri(path, **options)
|
34
55
|
req = Net::HTTP::Post.new(url)
|
35
56
|
add_auth_headers(req)
|
36
57
|
req.body = params.to_json
|
@@ -40,6 +61,14 @@ module Heroku
|
|
40
61
|
|
41
62
|
private
|
42
63
|
|
64
|
+
def host_for(database_json)
|
65
|
+
starter_plan?(database_json) ? STARTER_HOST : PRO_HOST
|
66
|
+
end
|
67
|
+
|
68
|
+
def starter_plan?(database)
|
69
|
+
database['plan']['name'].match(/(dev|basic)$/)
|
70
|
+
end
|
71
|
+
|
43
72
|
def build_uri(path, host: @basic_url)
|
44
73
|
URI.join(host, path)
|
45
74
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'json'
|
5
|
+
require 'platform-api'
|
6
|
+
|
7
|
+
module Heroku
|
8
|
+
module Api
|
9
|
+
module Postgres
|
10
|
+
class Credentials
|
11
|
+
def initialize(client)
|
12
|
+
@client = client
|
13
|
+
end
|
14
|
+
|
15
|
+
# Public: Rotate the database credentials.
|
16
|
+
#
|
17
|
+
# @param app_id [String] the application name.
|
18
|
+
# @param database_id [String] the database UUID.
|
19
|
+
# @param name [String] the credential name to be rotated (default: `default`).
|
20
|
+
def rotate(app_id, database_id, name: 'default')
|
21
|
+
path = "/postgres/v0/databases/#{database_id}/credentials" \
|
22
|
+
"/#{URI.encode_www_form_component(name)}/credentials_rotation"
|
23
|
+
@client.perform_post_request(path, {}, host: db_host(app_id, database_id))
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def db_host(app_id, database_id)
|
29
|
+
@client.db_host(app_id, database_id)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'net/http'
|
2
4
|
require 'json'
|
3
5
|
|
@@ -5,19 +7,16 @@ module Heroku
|
|
5
7
|
module Api
|
6
8
|
module Postgres
|
7
9
|
class Databases
|
8
|
-
STARTER_HOST = 'https://postgres-starter-api.heroku.com'.freeze
|
9
|
-
PRO_HOST = 'https://postgres-api.heroku.com'.freeze
|
10
|
-
|
11
10
|
def initialize(client)
|
12
11
|
@client = client
|
13
12
|
end
|
14
13
|
|
15
14
|
# original call returns simply a database object, therefore I call the info API.
|
16
15
|
# perform_get_request "/client/v11/databases/#{database_id}/wait_status"
|
17
|
-
def wait(database_id, options = { wait_interval: 3 })
|
16
|
+
def wait(app_id, database_id, options = { wait_interval: 3 })
|
18
17
|
waiting = true
|
19
18
|
while waiting
|
20
|
-
database = info(database_id)
|
19
|
+
database = info(app_id, database_id)
|
21
20
|
break unless database[:waiting?]
|
22
21
|
|
23
22
|
sleep(options[:wait_interval])
|
@@ -25,16 +24,14 @@ module Heroku
|
|
25
24
|
database
|
26
25
|
end
|
27
26
|
|
28
|
-
def info(database_id)
|
29
|
-
@client.perform_get_request("/client/v11/databases/#{database_id}")
|
27
|
+
def info(app_id, database_id)
|
28
|
+
@client.perform_get_request("/client/v11/databases/#{database_id}", host: db_host(app_id, database_id))
|
30
29
|
end
|
31
30
|
|
32
|
-
|
33
|
-
starter_plan?(database) ? STARTER_HOST : PRO_HOST
|
34
|
-
end
|
31
|
+
private
|
35
32
|
|
36
|
-
def
|
37
|
-
|
33
|
+
def db_host(app_id, database_id)
|
34
|
+
@client.db_host(app_id, database_id)
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
data/lib/heroku/api/postgres.rb
CHANGED
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.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Rodi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: platform-api
|
@@ -52,20 +52,34 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
75
|
+
version: '13.0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '13.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,13 +144,15 @@ extensions: []
|
|
130
144
|
extra_rdoc_files: []
|
131
145
|
files:
|
132
146
|
- ".example.env"
|
147
|
+
- ".github/FUNDING.yml"
|
133
148
|
- ".gitignore"
|
134
149
|
- ".rspec"
|
135
150
|
- ".rubocop.yml"
|
151
|
+
- ".ruby-version"
|
136
152
|
- ".travis.yml"
|
153
|
+
- CHANGELOG.md
|
137
154
|
- CODE_OF_CONDUCT.md
|
138
155
|
- Gemfile
|
139
|
-
- Gemfile.lock
|
140
156
|
- LICENSE.txt
|
141
157
|
- README.md
|
142
158
|
- Rakefile
|
@@ -149,13 +165,18 @@ files:
|
|
149
165
|
- lib/heroku/api/postgres.rb
|
150
166
|
- lib/heroku/api/postgres/backups.rb
|
151
167
|
- lib/heroku/api/postgres/client.rb
|
168
|
+
- lib/heroku/api/postgres/credentials.rb
|
152
169
|
- lib/heroku/api/postgres/databases.rb
|
153
170
|
- lib/heroku/api/postgres/version.rb
|
154
171
|
homepage: https://github.com/coorasse/heroku-api-postgres
|
155
172
|
licenses:
|
156
173
|
- MIT
|
157
|
-
metadata:
|
158
|
-
|
174
|
+
metadata:
|
175
|
+
homepage_uri: https://github.com/coorasse/heroku-api-postgres
|
176
|
+
source_code_uri: https://github.com/coorasse/heroku-api-postgres
|
177
|
+
changelog_uri: https://github.com/coorasse/heroku-api-postgres/blob/main/CHANGELOG.md
|
178
|
+
funding_uri: https://github.com/sponsors/coorasse
|
179
|
+
post_install_message:
|
159
180
|
rdoc_options: []
|
160
181
|
require_paths:
|
161
182
|
- lib
|
@@ -170,9 +191,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
191
|
- !ruby/object:Gem::Version
|
171
192
|
version: '0'
|
172
193
|
requirements: []
|
173
|
-
|
174
|
-
|
175
|
-
signing_key:
|
194
|
+
rubygems_version: 3.3.10
|
195
|
+
signing_key:
|
176
196
|
specification_version: 4
|
177
197
|
summary: Ruby library to invoke Heroku Postgres APIs
|
178
198
|
test_files: []
|
data/Gemfile.lock
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
heroku-api-postgres (0.10.0)
|
5
|
-
platform-api
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
addressable (2.5.2)
|
11
|
-
public_suffix (>= 2.0.2, < 4.0)
|
12
|
-
ast (2.4.0)
|
13
|
-
crack (0.4.3)
|
14
|
-
safe_yaml (~> 1.0.0)
|
15
|
-
diff-lcs (1.3)
|
16
|
-
dotenv (2.5.0)
|
17
|
-
erubis (2.7.0)
|
18
|
-
excon (0.62.0)
|
19
|
-
hashdiff (0.3.7)
|
20
|
-
heroics (0.0.25)
|
21
|
-
erubis (~> 2.0)
|
22
|
-
excon
|
23
|
-
moneta
|
24
|
-
multi_json (>= 1.9.2)
|
25
|
-
jaro_winkler (1.5.1)
|
26
|
-
moneta (1.0.0)
|
27
|
-
multi_json (1.13.1)
|
28
|
-
parallel (1.12.1)
|
29
|
-
parser (2.5.3.0)
|
30
|
-
ast (~> 2.4.0)
|
31
|
-
platform-api (2.2.0)
|
32
|
-
heroics (~> 0.0.25)
|
33
|
-
moneta (~> 1.0.0)
|
34
|
-
powerpack (0.1.2)
|
35
|
-
public_suffix (3.0.3)
|
36
|
-
rainbow (3.0.0)
|
37
|
-
rake (10.5.0)
|
38
|
-
rspec (3.8.0)
|
39
|
-
rspec-core (~> 3.8.0)
|
40
|
-
rspec-expectations (~> 3.8.0)
|
41
|
-
rspec-mocks (~> 3.8.0)
|
42
|
-
rspec-core (3.8.0)
|
43
|
-
rspec-support (~> 3.8.0)
|
44
|
-
rspec-expectations (3.8.2)
|
45
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
-
rspec-support (~> 3.8.0)
|
47
|
-
rspec-mocks (3.8.0)
|
48
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.8.0)
|
50
|
-
rspec-support (3.8.0)
|
51
|
-
rubocop (0.60.0)
|
52
|
-
jaro_winkler (~> 1.5.1)
|
53
|
-
parallel (~> 1.10)
|
54
|
-
parser (>= 2.5, != 2.5.1.1)
|
55
|
-
powerpack (~> 0.1)
|
56
|
-
rainbow (>= 2.2.2, < 4.0)
|
57
|
-
ruby-progressbar (~> 1.7)
|
58
|
-
unicode-display_width (~> 1.4.0)
|
59
|
-
ruby-progressbar (1.10.0)
|
60
|
-
safe_yaml (1.0.4)
|
61
|
-
unicode-display_width (1.4.0)
|
62
|
-
vcr (4.0.0)
|
63
|
-
webmock (3.3.0)
|
64
|
-
addressable (>= 2.3.6)
|
65
|
-
crack (>= 0.3.2)
|
66
|
-
hashdiff
|
67
|
-
|
68
|
-
PLATFORMS
|
69
|
-
ruby
|
70
|
-
|
71
|
-
DEPENDENCIES
|
72
|
-
bundler (~> 1.17)
|
73
|
-
dotenv
|
74
|
-
heroku-api-postgres!
|
75
|
-
rake (~> 10.0)
|
76
|
-
rspec (~> 3.0)
|
77
|
-
rubocop (= 0.60.0)
|
78
|
-
vcr (~> 4.0.0)
|
79
|
-
webmock (~> 3.3.0)
|
80
|
-
|
81
|
-
BUNDLED WITH
|
82
|
-
1.17.1
|