Overview
You can call this API to create a tenant.
Note
To create a tenant of the specified specifications, the cluster must have enough available resources.
API details
Constraints
The caller must have an AccessKey for accessing APIs of OceanBase Cloud. For information about how to obtain the AccessKey ID and AccessKey secret, see Manage AccessKeys.
Request path
POST /api/v2/instances/{instanceId}/tenants
Request parameters
Path
| Name | Type | Required | Description | Example value |
|---|---|---|---|---|
| instanceId | String | Yes | The ID of the database instance. | ob317v4uif**** |
Query
| Name | Type | Required | Description | Example value |
|---|---|---|---|---|
| requestId | String | Yes | The ID of the request. This parameter is used for tracing. | dc302d76-66b5-48d8-ab53-a035******** |
Body
| Name | Type | Required | Description | Example value |
|---|---|---|---|---|
| tenantName | String | Yes | The name of the tenant. The name can be partially matched. | pay_**** |
| tenantId | String | No | The ID of the tenant. | t33h8y08k**** |
| tenantMode | String | Yes | The mode of the tenant. Valid values:
|
Oracle |
| primaryZone | String | Yes | The primary zone of the tenant. This zone must be one of the zones in the cluster. | cn-hangzhou-h |
| charset | String | Yes | The character set.
Notice
|
utf8mb4 |
| collation | String | No | The collation. | utf8mb4_general_ci |
| description | String | No | The description of the database. | this is a test database |
| whitelist | String | No | The IP address whitelist. | 192.168.1.0/24,10.0.0.1 |
| timeZone | String | Yes | The time zone of the tenant. For more information, see DescribeTimeZones. | Asia/Shanghai |
| cpu | Integer | Yes | The number of CPU cores of the tenant. | 2 |
| memory | Integer | Yes | The size of the memory of the tenant, in GiB. | 10 |
| diskSize | Integer | No | The size of the disk of the tenant, in GiB. | 100 |
| unitNum | Integer | No | The number of resource distribution nodes of the tenant. This parameter is related to the deployment mode of the cluster. For example, if the deployment mode of the cluster is 2-2-2, the number of resource distribution nodes of the tenant can be at most 2. | 2 |
| environment | String | No | The environment of the tenant. | production |
| enablePublicLink | Boolean | No | Specifies whether to create a public endpoint.
|
false |
| parameterTemplate | String | No | The parameter template. | default_template |
| createParams | object | No | The parameters for creating the tenant. This parameter specifies whether the names of tables are case-sensitive. The parameter is of the hashMap type. Example: createParams":{"lower_case_table_names":"1"} |
{"lower_case_table_names":"1"} |
| tenantCompatibilityModeEnum | String | No | The compatibility mode of the tenant. | MYSQL |
| proxyAddressMasterZone | String | No | The primary zone of the proxy address. | cn-hangzhou-h |
Response parameters
| Name | Type | Description | Example value |
|---|---|---|---|
| data | object | The information about the tenant. | |
| tenantId | String | The ID of the tenant. | t33h8y08k**** |
Examples
Request example
curl --request POST 'https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/tenants?requestId={requestId}' \
--digest -u '<your ak:sk>' \
-H 'X-Ob-Project-Id: <Project ID>' \
-H 'Content-Type: application/json' \
--data '{"tenantName":"pay_test","tenantMode":"MySQL","primaryZone":"cn-hangzhou-h","charset":"utf8mb4","timeZone":"Asia/Shanghai","cpu":2,"memory":10,"unitNum":1,"description":"This is a test tenant."}'
Note
- A project ID uniquely identifies a project. For information about how to obtain the project ID of an instance, see Manage projects.
- Make sure that the project ID corresponding to the specified instanceId is consistent with the specified project ID.
Response example
JSON format
{
"success": true,
"data": {
"tenantId": "t33h8y08k****"
},
"requestId": "dc302d76-66b5-48d8-ab53-a035********",
"server": "xxx.xxx.x.xxx:xxxx"
}
