API接口说明
更新时间:2019-11-04
如果您是初次调用百度智能云产品的API,可以观看API入门视频指南,快速掌握调用API的方法。
获取实例列表
请求方法 | API |
---|---|
GET | /json-api/v1/cluster |
请求参数
参数名称 | 参数类型 | 是否必须 | 参数描述 |
---|---|---|---|
< 公共请求参数 > | - | - | 参考 公共请求参数 |
返回参数
参数名称 | 参数类型 | 参数描述 |
---|---|---|
< 公共返回参数 > | - | 参考 公共返回参数 |
clusters | List | 由cluster组成的数组,cluster详细参数参考下述API |
请求示例
Plain Text
1GET /json-api/v1/cluster HTTP/1.1
2HOST: xxx.baidu.com
3Authorization: bce-auth-v1/rdsak/2014-07-03T06:13:13Z/1800/x-bce-date/{signature}
返回示例
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 7869616F-7A68-6977-656E-406261696475
3Content-Type: application/json
4[
5 "clusters" : [
6 {
7 "clusterId": "xxxjxjkp1fimpb",
8 "clusterName": "xxxtest",
9 "endpoint": {
10 "port": 6600,
11 "address": "xxx.xxxjxjkp1fimpb.baidu.com",
12 "vnetIp" : "192.0.0.4",
13 "inetIp" : "180.0.0.4",
14 },
15 "region": "bj",
16 "instanceClass": "db1.large",
17 "engineVeresion": "5.x",
18 "allocatedMemoryInMB": 32768,
19 "allocatedStorageInGB": 320,
20 "usedStorageInMB": 0,
21 "instanceStatus": "available",
22 "lockMode": "unlock",
23 "eipStatus": "closed",
24 "publiclyAccessible": false,
25 "instanceCreateTime": "2017-05-15 07:05:56",
26 "sliceAmount": 1,
27 "instanceAmount": 2,
28 "subInstanceAmount": 4,
29 "azone": "zoneA",
30 "vpcId": "98c700ed-fed4-4d4e-bdd0-a17f6433d471",
31 "subnetId": {
32 "zoneA" : "66051292-093c-49df-8648-c1f744f0c302"
33 },
34 }
35 ]
36]
获取实例详情信息
获取集群信息,包括集群ID、集群名、连接信息、计算节点数、计算节点套餐规格(内存、存储空间)、集群状态、锁定模式、创建时间、区域等信息。
请求方法 | API |
---|---|
GET | /json-api/v1/cluster/{clusterId} |
请求参数
参数名称 | 参数类型 | 是否必须 | 参数描述 |
---|---|---|---|
< 公共请求参数 \> | - | - | 参考 公共请求参数 |
返回参数
参数名称 | 参数类型 | 参数描述 |
---|---|---|
< 公共返回参数 > | 参考 公共返回参数 | |
cluster | Object | 一个cluster对象 |
Cluster对象
参数名称 | 参数类型 | 参数描述 |
---|---|---|
clusterId | String | 集群id |
clusterName | String | 集群实例名字 |
endpoint | Object | 集群入口信息: { "port": 6600, //数据库端口 "address": "xxx.xxxjxjkp1fimpb.baidu.com", //数据库连接地址 "vnetIp" : "192.0.0.4", //vnet IP地址 "inetIp" : "180.0.0.4", //EIP地址 } |
instanceClass | String | 实例规格 |
allocatedMemoryInMB | Int | 单个存储节点的内存 |
allocatedStorageInGB | Int | 单个存储节点的空间 |
usedStorageInMB | Int | 总体已用存储空间 |
instanceStatus | String | 集群状态: creating;available;rebooting;backuping;renaming;failed;restoring;deleting;deleted |
lockMode | String | 集群锁定状态: unlock;lockExpiration;lockRestoration;lockDiskQuota |
instanceCreateTime | String | 集群创建时间 |
publiclyAccessible | bool | 是否开放外网访问权限 |
eipStatus | String | 公网访问开放状态 |
region | String | 集群区域 |
azone | String | 可用区 |
vpcId | String | vpc id信息 |
subnetId | object | 子网id信息 { "zoneA":"5087d05d-3818-4dc6-b87d-8810a921c453" } |
azone | String | 可用区 |
sliceAmount | int | 分片数,该值为"1" |
instanceAmount | int | 计算节点数 |
subInstanceAmount | int | 单个节点上主实例个数 |
engineVersion | string | 云数据库 FusionDB 版本:"5.x" |
请求示例
Plain Text
1GET /json-api/v1/cluster/xxxmxiaozhiwen0
2HTTP/1.1HOST: xxx.baidu.com
3Authorization: bce-auth-v1/rdsak/2014-07-03T06:13:13Z/1800/x-bce-date/{signature}
返回示例
Plain Text
1{
2 "cluster" : {
3 "clusterId": "xxxjxjkp1fimpb",
4 "clusterName": "xxxtest",
5 "engineVersion": "5.x",
6 "endpoint": {
7 "port": 6600,
8 "address": "xxx.xxxjxjkp1fimpb.baidu.com",
9 "vnetIp" : "192.0.0.4",
10 "inetIp" : "180.0.0.4",
11 },
12 "region": "bj",
13 "instanceClass": "db1.large",
14 "allocatedMemoryInMB": 32768,
15 "allocatedStorageInGB": 320,
16 "usedStorageInMB": 0,
17 "instanceStatus": "available",
18 "lockMode": "unlock",
19 "eipStatus": "closed",
20 "publiclyAccessible": false,
21 "instanceCreateTime": "2017-05-15 07:05:56",
22 "sliceAmount": 1,
23 "instanceAmount": 2,
24 "subInstanceAmount": 4,
25 "azone": "default",
26 "vpcId": "98c700ed-fad4-424e-bdd0-a17f64ead471",
27 "subnetId": {
28 "zoneA" : "66051292-493c-4ddf-8648-c18742f0c302"
29 },
30 "sliceList": [
31 {
32 "sliceId": "slice946t28kt1k",
33 "usedStorageInMB" : 10,
34 "status" : "available",
35 "instanceIds": [
36 {
37 "role": "master",
38 "instanceId": "5a63a4c5-5d7c-44ac-89bd-cded7ac2ec44",
39 "instanceShortId":"dr-asdf1",
40 "status" : "available",
41 "usedStorageInMB" : 10
42 },
43 {
44 "role": "standbymaster",
45 "instanceId": "a9419e43-f3c0-4527-a995-9a27478af22c",
46 "instanceShortId":"dr-asdf2",
47 "status" : "available",
48 "usedStorageInMB" : 10
49 },
50 {
51 "role": "slave",
52 "instanceId": "a9419e43-f3c0-4527-a995-9a27478af22c",
53 "instanceShortId":"dr-asdf2",
54 "status" : "available",
55 "usedStorageInMB" : 10
56 }
57 ]
58 }
59 ]
60 }
61}
创建实例
请求方法 | API |
---|---|
POST | /json-api/v1/cluster |
创建集群,需要选定计算节点数、计算节点套餐等信息。
请求参数
参数名称 | 参数类型 | 是否必须 | 参数描述 |
---|---|---|---|
< 公共请求参数 > | - | - | 参考 公共请求参数 |
orderId | String | Yes | 订单号 |
clusterName | string | Yes | 集群名字 |
instanceClass | string | Yes | 套餐名称 |
allocatedMemoryInMB | Int | Yes | 单个节点内存大小 |
instanceAmount | int | Yes | 计算节点数 |
subInstanceAmount | int | Yes | 单个节点上主实例个数(当前对于小套餐,此参数值是1;中套餐,此参数值是2) |
vpcId | String | Yes | vpcId |
subnetId | Object | Yes | 子网id信息 { "zoneA":"5087d05d-3818-4dc6-b87d-8810a921c453" } |
azone | string | Yes | 可用区 |
engineVersion | string | Yes | 云数据库 FusionDB 版本:"5.x" |
返回参数
参数名称 | 参数类型 | 参数描述 |
---|---|---|
< 公共返回参数 > | - | 参考 公共返回参数 |
clusters | List | 由cluster对象组成的数组 |
请求示例
Plain Text
1POST /json-api/v1/cluster HTTP/1.1
2HOST: xxx.baidu.com
3Authorization:bce-auth-v1/rdsak/2014-07-03T06:13:13Z/1800/x-bce-date/{signature}
4
5{
6 "orderId": "20170607012312400345676",
7 "clusterAmount": 1,
8 "clusterParameters":{
9 "clusterName": "xxxtest",
10 "engineVersion": "5.x",
11 "instanceClass": "db1.large",
12 "allocatedMemoryInMB": 32768,
13 "instanceAmount": 2,
14 "subInstanceAmount": 4,
15 "vpcId": "98c700ed-fed4-4d56-bdd0-a17f64ead471",
16 "subnetId" : {
17 "azoneA" : "66033292-093c-49d4-8648-c18742f0c302"
18 }
19 }
20}
返回示例
请求成功:
Plain Text
1{
2 "clusters": [
3 {
4 "clusterId": "xxxm59yzsvvk81",
5 "clusterName": "xxxtest",
6 "endpoint": {
7 "port": 6600,
8 "address": "xxx.xxxjxjkp1fimpb.baidu.com",
9 "vnetIp" : "192.0.0.4",
10 "inetIp" : "180.0.0.4",
11 },
12 "region": "bj",
13 "instanceClass": "db1.large",
14 "allocatedMemoryInMB": 32768,
15 "allocatedStorageInGB": 320,
16 "usedStorageInMB": 0,
17 "instanceStatus": "creating",
18 "lockMode": "unlock",
19 "eipStatus": "closed",
20 "publiclyAccessible": false,
21 "instanceCreateTime": "2017-06-07 05:56:57",
22 "sliceAmount": 1,
23 "instanceAmount": 2,
24 "subInstanceAmount": 4,
25 "azone": "azoneA",
26 "vpcId": "983740ed-fed4-4d4e-bdd0-a17f64ead471"
27 }
28 ]
29}
请求失败:
Plain Text
1{
2 "requestId":"35663333-3033-3766-3536-373564633661",
3 "code":"ClusterInstanceIsExist",
4 "message":"Cluster Instance is exist."
5}
删除实例
请求方法 | API |
---|---|
DELETE | /json-api/V1/cluster/{clusterId} |
集群当前lockMode必须为lockExpiration。
请求参数
参数名称 | 参数类型 | 是否必须 | 参数描述 |
---|---|---|---|
< 公共请求参数 > | - | - | 参考 公共请求参数 |
返回参数
参数名称 | 参数类型 | 参数描述 |
---|---|---|
< 公共返回参数 > | - | 参考 公共返回参数 |
请求示例
Plain Text
1DELETE /json-api/v1/cluster/testclusterId HTTP/1.1
2HOST: xxx.baidu.com
3Authorization: bce-auth-v1/rdsak/2014-07-03T06:13:13Z/1800/x-bce-date/{signature}
返回示例
Plain Text
1HTTP/1.1 200 OK
2x-bce-request-id: 7869616F-7A68-6977-656E-406261696475
3Content-Type: application/json
4Content-Length: 0