Примеры: curl
StableПрактические curl‑сценарии для API v2: create, describe и чтение новых autoscaler‑полей БД.
Обновлено: 21 марта 2026 г.
Ниже — несколько полезных пользовательских сценариев для API v2.
Подготовка
export CP_URL="https://<cp-host>"
export SPG99_TOKEN="<api-key>"
1. Создать tenant
curl -sS -X POST "$CP_URL/v2/tenants" -H "Authorization: Bearer $SPG99_TOKEN" -H "Content-Type: application/json" -d '{"name":"acme"}'
2. Создать базу внутри tenant
curl -sS -X POST "$CP_URL/v2/tenants/acme/dbs" -H "Authorization: Bearer $SPG99_TOKEN" -H "Content-Type: application/json" -d '{"name":"app","size":"L1"}'
В текущем managed‑сценарии не передавайте start_immediately=true или initial_scale=1: публичный Control Plane их отключает.
3. Получить tenant credentials повторно
curl -sS "$CP_URL/v2/tenants/acme/credentials" -H "Authorization: Bearer $SPG99_TOKEN"
4. Получить список баз tenant
curl -sS "$CP_URL/v2/tenants/acme/dbs?state=ready&limit=20&offset=0" -H "Authorization: Bearer $SPG99_TOKEN"
5. Прочитать БД и посмотреть autoscaler‑поля
curl -sS "$CP_URL/v2/tenants/acme/dbs/app" -H "Authorization: Bearer $SPG99_TOKEN"
На что особенно полезно смотреть в ответе:
statecurrent_scaletarget_scalecurrent_profiletarget_profilecandidate_profilescale_statefreeze_new_checkoutsscale_failure_reason
6. Вытащить profile handoff в jq
curl -sS "$CP_URL/v2/tenants/acme/dbs/app" -H "Authorization: Bearer $SPG99_TOKEN" | jq '{state,current_scale,target_scale,current_profile,target_profile,scale_state,freeze_new_checkouts,scale_failure_reason}'
7. Обновить контактный профиль аккаунта
curl -sS -X POST "$CP_URL/v2/account/contact" -H "Authorization: Bearer $SPG99_TOKEN" -H "Content-Type: application/json" -d '{"email":"you@company.com","name":"Ivan Ivanov","company":"Acme"}'
8. Удалить tenant со всеми базами
curl -sS -X DELETE "$CP_URL/v2/tenants/acme?cascade=true" -H "Authorization: Bearer $SPG99_TOKEN"
Удаление асинхронное, поэтому сразу после вызова ресурс ещё может оставаться в deleting.
Чего не нужно делать
Не закладывайте в пользовательский workflow такие вызовы:
POST /v2/tenants/:tenant/dbs/:db/startPOST /v2/tenants/:tenant/dbs/:db/stopPOST /v2/tenants/:tenant/dbs/:db/scale
В текущем публичном managed‑контракте эти операции намеренно отключены.
