Skip to content

Commit d727851

Browse files
docs(platform): add API-based database creation guide (#149)
Signed-off-by: Arnob kumar saha <arnob@appscode.com>
1 parent 9e80d93 commit d727851

4 files changed

Lines changed: 6421 additions & 0 deletions

File tree

docs/platform/guides/database-management/create-database/_index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ The overall flow is the same for every engine and is documented once in
2121
and a handful of engine-specific settings — pick your engine below for a guide tailored to
2222
it, then follow the common steps for everything else.
2323

24+
Prefer to automate this instead of using the UI? See
25+
[**Using the API**](using-api/_index.md) for the equivalent flow driven entirely by API calls.
26+
2427
---
2528

2629
## Supported Engines
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
layout: docs
3+
menu:
4+
docsplatform_{{.version}}:
5+
identifier: database-management-create-api
6+
name: Using the API
7+
parent: database-management-create
8+
weight: 6
9+
menu_name: docsplatform_{{.version}}
10+
section_menu_id: guides
11+
---
12+
13+
# Creating a Database via API
14+
15+
Everything the **Create Database** wizard does (see [Common Steps](../../common-steps.md)) can
16+
also be done directly against the platform API — useful for scripting, CI/CD pipelines, or
17+
automating database provisioning without the UI.
18+
19+
The flow is the same for every database engine: fetch the engine's default form values,
20+
render them into a full values model (dry-run), then submit to create the database. Only the
21+
`spec` fields you customize (mode, version, replicas, resources, storage) differ per engine.
22+
23+
## Before You Start
24+
25+
- **Base URL**: `https://<your-host>/api/v1/clusters/<org>/<cluster>`
26+
- **Auth**: every call needs your session cookie and CSRF token:
27+
```
28+
-H "Cookie: <your-session-cookie>"
29+
-H "x-csrf-token: <your-csrf-token>"
30+
-H "content-type: application/json"
31+
```
32+
33+
## The 3-Call Flow
34+
35+
| # | Call | Purpose |
36+
|---|------|---------|
37+
| 1 | `GET /helm/packageview/values` | Get the default form values for the engine |
38+
| 2 | `PUT /helm/options/model` | Render your inputs into a full values model (dry-run) |
39+
| 3 | `PUT /helm/editor` | **Submit — this creates the database** |
40+
41+
Call 1 returns the default config for the engine (all the fields the UI shows, with their
42+
defaults). Note the shape: `form`, `metadata`, and `spec` are **top-level siblings** — the
43+
editable database config lives under the top-level `spec`, not under `form`. Fields like the
44+
available versions and storage classes usually come back empty — set your preferred values
45+
before moving to call 2.
46+
47+
Call 2 takes the `form` object from call 1 with your choices filled in (name, namespace,
48+
version, mode, replicas, resources, storage, etc.) and renders it into the full set of
49+
Kubernetes manifests that would be applied — without creating anything. The response's
50+
`resources` map (e.g. `resources.kubedbCom<Engine>`) is exactly what call 3 will apply, so
51+
this is the point to verify your configuration before submitting.
52+
53+
Call 3 takes the same `form`/`metadata` plus the rendered `resources` map from call 2 and
54+
submits it via `?response-id=<uuid>` (any client-generated UUID, used only to correlate the
55+
request with a progress stream). A `200` response means the database — and its
56+
autoscaler/binding/backup config — has been created.
57+
58+
## Supported Engines
59+
60+
- [MongoDB](../mongodb.md)
61+
- [PostgreSQL](../postgres.md)
62+
63+
> More engines will be documented here as their API flows are captured. Until then, follow
64+
> the pattern above against `GET /helm/packageview/values` with your engine's `kind` (e.g.
65+
> `Redis`, `MySQL`) to discover its fields.

0 commit comments

Comments
 (0)