-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from Scalingo/feat/db-api-compat
feat(db-api) Add database and backup APIs
- Loading branch information
Showing
27 changed files
with
700 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require "scalingo/api/client" | ||
|
||
module Scalingo | ||
class RegionalDatabase < API::Client | ||
require "scalingo/regional_database/databases" | ||
require "scalingo/regional_database/backups" | ||
|
||
register_handlers!( | ||
databases: Databases, | ||
backups: Backups, | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require "scalingo/api/endpoint" | ||
|
||
module Scalingo | ||
class RegionalDatabase::Backups < API::Endpoint | ||
def create(addon_id, headers = nil, &block) | ||
data = nil | ||
|
||
response = database_connection(addon_id).post( | ||
"databases/#{addon_id}/backups", | ||
data, | ||
headers, | ||
&block | ||
) | ||
|
||
unpack { response } | ||
end | ||
|
||
def for(addon_id, headers = nil, &block) | ||
data = nil | ||
|
||
response = database_connection(addon_id).get( | ||
"databases/#{addon_id}/backups", | ||
data, | ||
headers, | ||
&block | ||
) | ||
|
||
unpack(:database_backups) { response } | ||
end | ||
|
||
def archive(addon_id, backup_id, headers = nil, &block) | ||
data = nil | ||
|
||
response = database_connection(addon_id).get( | ||
"databases/#{addon_id}/backups/#{backup_id}/archive", | ||
data, | ||
headers, | ||
&block | ||
) | ||
|
||
unpack { response } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require "scalingo/api/endpoint" | ||
|
||
module Scalingo | ||
class RegionalDatabase::Databases < API::Endpoint | ||
def find(id, headers = nil, &block) | ||
data = nil | ||
|
||
response = database_connection(id).get( | ||
"databases/#{id}", | ||
data, | ||
headers, | ||
&block | ||
) | ||
|
||
unpack(:database) { response } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"addon_id": "ad-5ed10967884fef000f5e4fff", | ||
"backup_id": "5bb95a904ffb096e9a2831b8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"path": "/databases/ad-5ed10967884fef000f5e4fff/backups/5bb95a904ffb096e9a2831b8/archive", | ||
"method": "get", | ||
"request": { | ||
"headers": { | ||
"Authorization": "Bearer the-bearer-token" | ||
} | ||
}, | ||
"response": { | ||
"status": 200, | ||
"headers": { | ||
"Date": "Fri, 29 May 2020 13:08:59 GMT", | ||
"Etag": "W/\"a9504bb2f6f87c65ff68074ae787831e\"", | ||
"Content-Type": "application/json; charset=utf-8", | ||
"Transfer-Encoding": "chunked", | ||
"Connection": "keep-alive", | ||
"Cache-Control": "max-age=0, private, must-revalidate", | ||
"Referrer-Policy": "strict-origin-when-cross-origin" | ||
}, | ||
"json_body": { | ||
"download_url": "https://regional-database.scalingo.test/databases/ad-5ed10967884fef000f5e4fff/backups/5bb95a904ffb096e9a2831b8/download?token=token1234" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"path": "/databases/ad-5ed10967884fef000f5e4fff/backups/5bb95a904ffb096e9a2831b8/archive", | ||
"method": "get", | ||
"request": { | ||
"headers": { | ||
"Authorization": "Bearer the-bearer-token" | ||
} | ||
}, | ||
"response": { | ||
"status": 400, | ||
"headers": { | ||
"Date": "Fri, 29 May 2020 13:08:59 GMT", | ||
"Etag": "W/\"a9504bb2f6f87c65ff68074ae787831e\"", | ||
"Content-Type": "application/json; charset=utf-8", | ||
"Transfer-Encoding": "chunked", | ||
"Connection": "keep-alive", | ||
"Cache-Control": "max-age=0, private, must-revalidate", | ||
"Referrer-Policy": "strict-origin-when-cross-origin" | ||
}, | ||
"json_body": { | ||
"error": "unauthorized" | ||
} | ||
} | ||
} |
Oops, something went wrong.