Cloud Databases API
第 2 代
Cloud Databases API 通常會利用 Resource Controller API 來執行各項操作。 請參閱此 API 文件,以操作您的資料服務。
鑑別
存取 API 採用令牌驗證機制,需透過 Authorization: Bearer <token> 這個標頭進行驗證。 該代幣必須由 IAM 發行。 您可以直接將 IAM API 金鑰作為憑證傳送,或 使用該 API 金鑰來產生 IAM 承載者憑證。
要呼叫每個方法,您必須是 被指派一個角色,且該角色必須包含所需的 IAM 動作。 每個方法都會列出其對應的操作。 有關 IAM 操作及其與角色的對應關係的更多資訊,請參閱《 管理 IBM Cloud® 的存取權限 》。
錯誤處理
此 API 使用標準的 HTTP 回應代碼,用以指示方法是否成功完成。 200 的回應總是表示成功。 4xx 類型的回應代表某種失敗,而 500 類型的回應通常表示發生內部系統錯誤。 上述任何回應都可能附帶一個 JSON 格式的內容,其中包含更詳細的錯誤資訊。
事件追蹤
您可以透過 IBM Cloud® Activity Tracker 服務,監控您帳戶內的 API 活動。 每當呼叫 API 方法時,系統便會產生一個事件,您可透過 Activity Tracker 進行追蹤與稽核。 每個方法都會列出其對應的特定事件類型。
部署識別碼與 CRN
在 Cloud Data Services 平台上,部署 ID 即為 CRN。 使用 CRN 時,請記得將 CRN 值進行 URL 編碼,因為其中可能包含正斜線 (/) %2F 字元。
範例:以下 CRN
crn:v1:bluemix:public:databases-for-redis:us-south:a/274074dce64e9c423ffc238516c755e1:29caf0e7-120f-4da8-9551-3abf57ebcfc7::
當以 URL 編碼時,結果如下:
crn:v1:bluemix:public:databases-for-redis:us-south:a%2F274074dce64e9c423ffc238516c755e1:29caf0e7-120f-4da8-9551-3abf57ebcfc7::
分頁
目前沒有任何端點會傳回分頁資料。
速率限制
目前沒有任何端點實作流量限制。
方法
列出所有已部署的產品
回傳所有已部署雲端服務的清單。
GET /v2/resource_instances
要求範例:
curl -X GET https://resource-controller.cloud.ibm.com/v2/resource_instances -H "Authorization: Bearer <IAM token>"
回應範例:
{
"rows_count": 100,
"next_url": "/v2/resource_instances?start=<token>",
"resources": [
{
"id": "crn:v1:bluemix:public:databases-for-redis:eu-de:a/40ddc34a953a8c02f10987b59085b60e:07d523b1-6eea-4263-bd03-c17edf355e0b::",
"guid": "07d523b1-6eea-4263-bd03-c17edf355e0b",
"url": "/v2/resource_instances/07d523b1-6eea-4263-bd03-c17edf355e0b",
"created_at": "2026-07-17T06:41:51.267012883Z",
"updated_at": "2026-07-17T06:42:11.22949657Z",
"deleted_at": null,
"created_by": "Id-270000000X",
"updated_by": "",
"deleted_by": "",
"scheduled_reclaim_at": null,
"restored_at": null,
"scheduled_reclaim_by": "",
"restored_by": "",
"name": "test-redis-gen2",
"region_id": "eu-de",
"account_id": "40ddc34a953a8c02f10987b59085b60e",
"reseller_channel_id": "",
"resource_plan_id": "databases-for-redis-gen2-standard",
"resource_group_id": "eb922ba0717f47589ca26d202c5cc915",
"resource_group_crn": "crn:v1:bluemix:public:resource-controller::a/40ddc34a953a8c02f10987b59085b60e::resource-group:eb922ba0717f47589ca26d202c5cc915",
"target_crn": "crn:v1:bluemix:public:globalcatalog::::deployment:databases-for-redis-standard-gen2%3Aeu-de",
"parameters": {
"dataservices": {
"redis": {
"host_flavor": "bxf.4x16",
"members": 2,
"storage_gb": 15,
"version": "8.2"
}
}
},
"allow_cleanup": false,
"crn": "crn:v1:bluemix:public:databases-for-redis:eu-de:a/40ddc34a953a8c02f10987b59085b60e:07d523b1-6eea-4263-bd03-c17edf355e0b::",
"state": "provisioning",
"type": "service_instance",
"sub_type": "Public",
"resource_id": "databases-for-redis",
"dashboard_url": null,
"last_operation": {
"type": "create",
"state": "in progress",
"async": true,
"description": "Provision in progress",
"cancelable": true,
"poll": true
},
"resource_keys_url": "/v2/resource_instances/07d523b1-6eea-4263-bd03-c17edf355e0b/resource_keys",
"plan_history": [
{
"resource_plan_id": "databases-for-redis-gen2-standard",
"start_date": "2026-07-17T06:41:51.267012883Z",
"requestor_id": "Id-270000000X"
}
],
"migrated": false,
"controlled_by": "",
"locked": false,
"onetime_credentials": false
}
]
}
resources 陣列中會傳回其他資源物件。 請使用代碼 next_url 來擷取下一頁的結果。
取得部署資訊
取得與某個部署相關的完整資料。 這些資料包含 ID、名稱、資料庫類型及版本。
GET /v2/resource_instances/{id}
要求範例:
curl -X GET https://resource-controller.cloud.ibm.com/v2/resource_instances/95004d03-9fec-443b-9f6e-083f2b25e73a -H "Authorization: Bearer <IAM token>" \
回應範例:
{
"id": "crn:v1:bluemix:public:databases-for-postgresql:us-east:a/23b09aee04da4545b6e32805fa93249d:95004d03-9fec-443b-9f6e-083f2b25e73a::",
"guid": "95004d03-9fec-443b-9f6e-083f2b25e73a",
"url": "/v2/resource_instances/95004d03-9fec-443b-9f6e-083f2b25e73a",
"created_at": "2026-07-02T14:04:29.613949688Z",
"updated_at": "2026-07-02T14:15:54.226535327Z",
"deleted_at": null,
"created_by": "Id-4700030B2K",
"updated_by": "",
"deleted_by": "",
"scheduled_reclaim_at": null,
"restored_at": null,
"scheduled_reclaim_by": "",
"restored_by": "",
"name": "Databases for PostgreSQL-3b",
"region_id": "us-east",
"account_id": "23b09aee04da4545b6e32805fa93249d",
"reseller_channel_id": "",
"resource_plan_id": "databases-for-postgresql-gen2-standard",
"resource_group_id": "c21a4e8564c14d1aab2a9a8b441904eb",
"resource_group_crn": "crn:v1:bluemix:public:resource-controller::a/23b09aee04da4545b6e32805fa93249d::resource-group:c21a4e8564c14d1aab2a9a8b441904eb",
"target_crn": "crn:v1:bluemix:public:globalcatalog::::deployment:databases-for-postgresql-standard-gen2%3Aus-east",
"parameters": {
"dataservices": {
"postgresql": {
"host_flavor": "bx3d.4x20",
"members": 2,
"storage_gb": 10,
"version": "18"
}
}
},
"allow_cleanup": false,
"crn": "crn:v1:bluemix:public:databases-for-postgresql:us-east:a/23b09aee04da4545b6e32805fa93249d:95004d03-9fec-443b-9f6e-083f2b25e73a::",
"state": "active",
"type": "service_instance",
"sub_type": "Public",
"resource_id": "databases-for-postgresql",
"dashboard_url": null,
"last_operation": {
"type": "create",
"state": "succeeded",
"async": true,
"description": "Provision completed successfully",
"cancelable": true,
"poll": true
},
"resource_keys_url": "/v2/resource_instances/95004d03-9fec-443b-9f6e-083f2b25e73a/resource_keys",
"plan_history": [
{
"resource_plan_id": "databases-for-postgresql-gen2-standard",
"start_date": "2026-07-02T14:04:29.613949688Z",
"requestor_id": "Id-4700030B2K"
}
],
"migrated": false,
"extensions": {
"dataservices": {
"$schema": {
"version": "1.0.0"
},
"connection": {
"cli": {
"arguments": [
"host=95004d03-9fec-443b-9f6e-083f2b25e73a.private.uhp.postgresql.us-east.dataservices.appdomain.cloud port=5432 dbname=postgres user=$PGUSER password=$PGPASSWORD sslmode=verify-full"
],
"bin": "psql",
"composed": [
"PGUSER=$PGUSER PGPASSWORD=$PGPASSWORD PGSSLMODE=verify-full PGSSLROOTCERT=system psql 'host=95004d03-9fec-443b-9f6e-083f2b25e73a.private.uhp.postgresql.us-east.dataservices.appdomain.cloud port=5432 dbname=postgres'"
],
"environment": {
"PGPASSWORD": "$PGPASSWORD",
"PGSSLMODE": "verify-full",
"PGSSLROOTCERT": "system",
"PGUSER": "$PGUSER"
},
"type": "cli"
},
"postgres": {
"authentication": {
"method": "direct",
"password": "$PGPASSWORD",
"username": "$PGUSER"
},
"composed": [
"postgres://$PGUSER:$PGPASSWORD@95004d03-9fec-443b-9f6e-083f2b25e73a.private.uhp.postgresql.us-east.dataservices.appdomain.cloud:5432/postgres?sslmode=verify-full"
],
"database": "postgres",
"hosts": [
{
"hostname": "95004d03-9fec-443b-9f6e-083f2b25e73a.private.uhp.postgresql.us-east.dataservices.appdomain.cloud",
"port": 5432
}
],
"path": "/postgres",
"port": 5432,
"query_options": {
"sslmode": "verify-full"
},
"scheme": "postgres",
"type": "uri"
}
},
"postgresql": {
"configuration": {
"max_connections": 115
},
"cpu_count": 4,
"host_flavor": "bx3d.4x20",
"members": 2,
"memory_gb": 20,
"storage_gb": 10,
"version": "18"
}
},
"virtual_private_endpoints": {
"dns_domain": "95004d03-9fec-443b-9f6e-083f2b25e73a.private.uhp.postgresql.us-east.dataservices.appdomain.cloud",
"dns_hosts": [
"",
"*"
],
"endpoints": [
{
"ip_address": "10.51.217.34",
"zone": "us-east-1"
},
{
"ip_address": "10.51.219.57",
"zone": "us-east-2"
},
{
"ip_address": "10.51.221.12",
"zone": "us-east-3"
}
],
"origin_type": "vpc",
"ports": [
{
"port_max": 5432,
"port_min": 5432
}
]
}
},
"controlled_by": "",
"locked": false,
"onetime_credentials": false
}
您可以從 API 回應中取得以下資訊:
last_operation物件 - 顯示您最近執行的任務。connectionobject - 顯示產品連線資訊。- 產品相關資訊顯示於產品物件下方(例如:
postgresql)。
如何配置您的資料庫
POST /v2/resource_instances
要求範例:
curl -X POST https://resource-controller.cloud.ibm.com/v2/resource_instances \
-H "Authorization: Bearer <IAM token>" \
-H 'Content-Type: application/json' \
-d '{
"name": "my-instance",
"target": "ca-mon",
"resource_group": "5c49eabc-f5e8-5881-a37e-2d100a33b3df",
"resource_plan_id": "databases-for-postgresql-gen2-standard",
"parameters": {
"dataservices": {
"postgresql": {
"storage_gb": 10,
"members": 2,
"host_flavor": "b3c.8x32.encrypted",
"version": "18"
},
"encryption": {
"disk": "crn:v1..."
},
"$schema": {
"version": "1.0.0"
}
}
}
}'
輸入參數
name(字串)- 實例的名稱。target(字串)- 要部署到的區域(例如:us-south、eu-de)。resource_group(字串)- 資源群組的識別碼。resource_plan_id(字串)- 方案 ID(例如:databases-for-postgresql-gen2-standard)。parameters(物件)dataservices(物件)<service>(物件)- 服務名稱金鑰(例如:postgresql、mysql)。storage_gb(整數)- 儲存空間大小(以 GB 為單位)。members(整數)- 成員人數。host_flavor(字串)- 主機類型識別碼(例如:b3c.8x32.encrypted)。version(字串)- 資料庫版本(例如:"18")。
encryption(物件,可選)- 磁碟加密設定。disk(字串)- 用於磁碟加密的「Key Protect」金鑰的 CRN。
$schema(物件)- 模式元資料。version(字串)- 模式版本,必須為"1.0.0"。
如何擴展您的資料庫
PATCH /v2/resource_instances/{id}
要求範例:
curl -X PATCH https://resource-controller.cloud.ibm.com/v2/resource_instances/ed9d2c9b-444b-421d-bbc0-503ca8dd3036 \
-H "Authorization: Bearer <IAM token>" \
-H 'Content-Type: application/json' \
-d '{
"parameters": {
"dataservices": {
"postgresql": {
"storage_gb": 12,
"members": 2,
"host_flavor": "bxf.4x16"
}
}
}
}'
輸入參數
parameters(物件)dataservices(物件)<service>(物件)- 服務名稱金鑰(例如:postgresql、mysql)。storage_gb(整數)- 儲存空間大小(以 GB 為單位)。members(整數)- 成員人數。host_flavor(字串)- 主機類型識別碼(例如:bxf.4x16)。