|
| 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