Description
The interface used to create a database.
Call instructions
Interface constraints
The caller needs to be authenticated through the OCP application service.
The caller must have the permission to modify the specified tenant.
Request path
POST /api/v2/ob/clusters/{id}/tenants/{tenantId}/databases
Request parameters
path:
Parameter |
Type |
Required |
Example Value |
Description |
|---|---|---|---|---|
| id | Integer | Yes | 1 | The cluster ID. |
| tenantId | Integer | Yes | 5 | The tenant ID. |
body:
Parameter |
Type |
Required |
Example Value |
Description |
|---|---|---|---|---|
| dbName | String | Yes | db1 | The name of the database. |
| collation | String | No | utf8mb4_general_ci | The collation. Valid values: |
| primaryZone | String | No | zone1;zone2,zone3 | The zone priority. |
| readonly | Boolean | Yes | false | Specifies whether the database is read-only. |
Returned results
Basic data structure
Parameter |
Type |
Description |
|---|---|---|
| data | Object | The database object. The data structure of the database is described in the following table. |
| successful | Boolean | Indicates whether the request is successful. |
| timestamp | Datetime | The timestamp indicating the time when the server finishes the request. |
| duration | Integer | The time taken by the server to process the request, in milliseconds. |
| status | Integer | The HTTP status code that conforms to the HTTP status specification. |
| traceId | String | The Trace ID of the request, which is used to troubleshoot issues. |
| server | String | The address of the application service that responds to the request. |
Data structure of the database
Parameter |
Type |
Description |
|---|---|---|
| dbName | String | The name of the database. |
| charset | String | The character set. |
| collation | String | The collation. |
| readonly | Boolean | Indicates whether the database is read-only. |
| createTime | Datetime | The creation time. |
| connectionUrls | Array | The list of OBProxy connection strings. |
| ├─ connectionStringType | String | The type of the connection string. Valid values: |
| ├─ obProxyAddress | String | The address of OBProxy, which is valid only when the connection string type is OBPROXY. |
| ├─ obProxyPort | Integer | The port of OBProxy, which is valid only when the connection string type is OBPROXY. |
| ├─ connectionString | String | The connection string. |
| requiredSize | Integer | The required_size of the database. |
| id | Integer | The ID of the database. |
Examples
Request example
Create a database in cluster 1 and tenant 1000001.
POST /api/v2/ob/clusters/1/tenants/1000001/databases?id=1&tenantId=1000001
{
"dbName": "db1",
"collation": "utf8mb4_general_ci",
"readonly": false,
}
Response example
{
"data": {
"charset": "utf8mb4",
"collation": "utf8mb4_general_ci",
"createTime": "2021-09-07T10:34:22.583681+08:00",
"dbName": "db1",
"id": 1100611139404827,
"readonly": false
},
"duration": 311,
"server": "a83ad33525",
"status": 200,
"successful": true,
"timestamp": "2021-09-07T10:34:22.626+08:00",
"traceId": "2442edacd20f4442"
}
