Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 169 additions & 0 deletions _scalingo_api/databases_dr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
---
title: Databases
layout: default
---

# Databases
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: shouldn't we mention a small text about the fact these are for dedicated resources?


--- row ---

**Database attributes**

{:.table}
| field | type | description |
| ----------- | ------ | ----------------------------------------------------- |
| id | string | unique ID |
| name | string | name of the database |
| project_id | string | ID of the project the database belongs to |
| technology | string | database technology (e.g., postgresql-ng)|
| plan | string | plan name (e.g., postgresql-ng-starter-4096) |

||| col |||

Example object:

```json
{
"id": "54100930736f7563d5030000",
"name": "my-postgres-db",
"project_id": "pr-82a3cac5-9b25-473e-b33d-6272b87e636f",
"technology": "postgresql-ng",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is this the definitive name? (just to be sure technology and plan names are future proof)

"plan": "postgresql-ng-starter-4096"
}
```

--- row ---

## Create a Database

--- row ---

`POST https://$SCALINGO_API_URL/v1/databases`

### Parameters

* `database.name`: Database name. Should have between 6 and 48 lower case alphanumerical characters and hyphens.
* `database.technology`: Database technology identifier. Only `postgresql-ng` is supported for now.
* `database.plan`: Plan identifier (e.g., `postgresql-ng-starter-4096`). Available plans can be retrieved via the [Addon Providers endpoint](/addon_providers).
* `database.project_id`: (*Optional*) ID of the project to assign the database to. If not provided, the database will be assigned to your default project.

**Note:** To provision other database types (MySQL, MongoDB, Redis, etc.), please use the [Addons provisioning endpoint](/addons#provision-an-addon).

||| col |||

Example

```sh
curl -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer $BEARER_TOKEN" \
-X POST https://$SCALINGO_API_URL/v1/databases -d \
'{
"database": {
"name": "my-postgres-db",
"technology": "postgresql-ng",
"plan": "postgresql-ng-starter-4096",
"project_id": "pr-82a3cac5-9b25-473e-b33d-6272b87e636f"
}
}'
```

Returns 201 Created

```json
{
"database": {
"id": "54100930736f7563d5030000",
"name": "my-postgres-db",
"project_id": "pr-82a3cac5-9b25-473e-b33d-6272b87e636f",
"technology": "postgresql-ng",
"plan": "postgresql-ng-starter-4096"
}
}
```

--- row ---

## List Your Databases

--- row ---

`GET https://$SCALINGO_API_URL/v1/databases`

List all your databases.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not list all the databases. Only the "ng" ones.

Maybe, until we have more technology, we could have something like "list all databases of postgresql-ng technology"?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree and set a reminder to raise a TASK ticket when we come to MySQL


||| col |||

Example

```shell
curl -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer $BEARER_TOKEN" \
-X GET https://$SCALINGO_API_URL/v1/databases
```

Returns 200 OK

```json
{
"databases": [
{
"id": "54100930736f7563d5030000",
"name": "my-postgres-db",
"project_id": "pr-82a3cac5-9b25-473e-b33d-6272b87e636f",
"technology": "postgresql-ng",
"plan": "postgresql-ng-starter-4096"
},
{
"id": "54100930736f7563d5030001",
"name": "backup-db",
"project_id": "pr-82a3cac5-9b25-473e-b33d-6272b87e636f",
"technology": "postgresql-ng",
"plan": "postgresql-ng-starter-4096"
}
]
}
```

--- row ---

## Get a Precise Database

--- row ---

`GET https://$SCALINGO_API_URL/v1/databases/[:database]`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Is it by name, id, both?


Display a precise database.

||| col |||

Example request

```shell
curl -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer $BEARER_TOKEN" \
-X GET https://$SCALINGO_API_URL/v1/databases/my-postgres-db
```

Returns 200 OK

```json
{
"database": {
"id": "54100930736f7563d5030000",
"name": "my-postgres-db",
"project_id": "pr-82a3cac5-9b25-473e-b33d-6272b87e636f",
"technology": "postgresql-ng",
"plan": "postgresql-ng-starter-4096"
}
}
```

Returns 404 Not Found if the database doesn't exist

```json
{
"error": "Database not found"
}
```

--- row ---