实例操作
所有文档
menu

云数据库 TableStorage

实例操作

产品详情

创建实例CreateInstance

描述

创建一个实例,要求名称不能和同Region内现有任何一个Instance重名,限制字符个数3-255,满足正则:[a-zA-Z_][a-za-z0-9\_]{2,254}。 实例名称不能包含 [‘baidu’, ‘bidu’, ‘bce’, ‘bts’] 这几个单词,不能以‘__’(两个下划线)开头。

请求

Verb URI
PUT /v{version}/instance/{instanceName}

请求参数

参数名称 是否必须 参数类型 说明
storageType string 该Instance下表的默认存储类型。
若创建表时未指定存储类型,则默认使用所属Instance的表存储类型.

响应参数

错误码

http_code code 说明
201 - 创建成功
401 AuthenticationFailed 认证失败
400 InvalidURI URI非法
405 MethodNotAllowed 传递了不支持的HTTP方法
400 InvalidContentType 请求头域Content-Type是不支持的类型
400 InvalidAutherization 请求头域Autherization没有传递
400 EmptyDate 请求头域Date或x-bce-date都没有传递
400 InvalidContentLength 请求头域Content-Length没有传递
400 ContentLengthMismatchBodySize 请求头域的Content-Length和实际Request body大小不等
400 MalformedJSON 请求体传递的json无法解析
500 InternalError 服务内部错误,需联系技术人员解决
403 ReachMaxInstanceCount 达到可建立的instance上限20个
409 InstanceAlreadyExist Instance已存在
400 InvalidInstanceName Instance名称不合法

请求示例

(1) 未设置 Instance 表格存储类型(默认使用高性能型存储类型)

PUT /v1/instance/ins1 HTTP/1.1
HOST: bts.bd.baidubce.com
Authorization: bce-auth-v1/table-access-key/2018-05-24T13:41:13Z/1800/x-bce-date/{signature}
Content-Type: application/json
Content-Length: {payloadSizeBytes}
x-bce-date: 2018-05-24T13:41:13Z

(2) 设置 Instance 表格存储类型

PUT /v1/instance/ins1 HTTP/1.1
HOST: bts.bd.baidubce.com
Authorization: bce-auth-v1/table-access-key/2018-05-24T13:41:13Z/1800/x-bce-date/{signature}
Content-Type: application/json
Content-Length: {payloadSizeBytes}
x-bce-date: 2018-05-24T13:41:13Z

{
    "storageType": "HighPerformance"
}

响应示例

HTTP/1.1 201 Created
Date: Sat, 18 Aug 2018 18:18:18 GMT
Content-Type: application/json; charset=utf-8
Content-Length: {payloadSizeBytes}
x-bce-request-id: 7869616F-7A68-6977-656E-406261696475

{}

删除实例DropInstance

描述

删除一个实例,要求实例下不存在任何表,否则删除失败。删除实例是一个同步操作过程,一旦返回成功,实例将不复存在。

请求

Verb URI
DELETE /v{version}/instance/{instanceName}

请求参数

响应参数

错误码

http_code code 说明
20x - 返回20x类均表示删除成功
401 AuthenticationFailed 认证失败
400 InvalidURI URI非法
405 MethodNotAllowed 传递了不支持的HTTP方法
400 InvalidContentType 请求头域Content-Type是不支持的类型
400 InvalidAutherization 请求头域Autherization没有传递
400 EmptyDate 请求头域Date或x-bce-date都没有传递
400 InvalidContentLength 请求头域Content-Length没有传递
400 ContentLengthMismatchBodySize 请求头域的Content-Length和实际Request body大小不等
400 MalformedJSON 请求体传递的json无法解析
500 InternalError 服务内部错误,需联系技术人员解决
404 InstanceNotExist Instance不存在
403 AccessDenied 请求被拒绝,Instance下有未清除的表存在
400 InvalidInstanceName Instance名称不合法
403 InstanceCreating 实例创建中,请稍候

请求示例

DELETE /v1/instance/ins1 HTTP/1.1
HOST: bts.bd.baidubce.com
Authorization: bce-auth-v1/table-access-key/2018-05-24T13:41:13Z/1800/x-bce-date/{signature}
Content-Type: application/json
Content-Length: {payloadSizeBytes}
x-bce-date: 2018-05-24T13:41:13Z

响应示例

HTTP/1.1 200 OK
Date: Sat, 18 Aug 2018 18:18:18 GMT
Content-Type: application/json; charset=utf-8
Content-Length: {payloadSizeBytes}
x-bce-request-id: 7869616F-7A68-6977-656E-406261696475

{}

列举实例ListInstances

描述

列出账户一个Region内创建的所有实例。

请求

Verb URI
GET /v{version}/instances

请求参数

响应参数

参数名称 参数类型 说明
instances list instance列表
+id string instance ID
+name string instanceName
+region string 所属百度智能云region
+state string instance当前状态,目前只有Normal状态:
- Normal:instance处于正常状态
+createTime string instance创建的UTC时间
+storageType string 该Instance下表的默认存储类型

错误码

http_code code 说明
200 - 请求成功
401 AuthenticationFailed 认证失败
400 InvalidURI URI非法
405 MethodNotAllowed 传递了不支持的HTTP方法
400 InvalidContentType 请求头域Content-Type是不支持的类型
400 InvalidAutherization 请求头域Autherization没有传递
400 EmptyDate 请求头域Date或x-bce-date都没有传递
400 InvalidContentLength 请求头域Content-Length没有传递
400 ContentLengthMismatchBodySize 请求头域的Content-Length和实际Request body大小不等
400 MalformedJSON 请求体传递的json无法解析
500 InternalError 服务内部错误,需联系技术人员解决
400 InvalidInstanceName Instance名称不合法

请求示例

GET /v1/instances HTTP/1.1
HOST: bts.bd.baidubce.com
Authorization: bce-auth-v1/table-access-key/2018-05-24T13:41:13Z/1800/x-bce-date/{signature}
Content-Type: application/json
Content-Length: {payloadSizeBytes}
x-bce-date: 2018-05-24T13:41:13Z

响应示例

HTTP/1.1 200 OK
Date: Sat, 18 Aug 2018 18:18:18 GMT
Content-Type: application/json; charset=utf-8
Content-Length: {payloadSizeBytes}
x-bce-request-id: 7869616F-7A68-6977-656E-406261696475

{
    "instances": [
        {
            "id": "btsi-123456789",
            "name": "ins1",
            "region": "bd",
            "state": "Normal",
            "createTime": "2018-05-06T14:32:09Z"
            "storageType": "HighPerformance"
        },
        {
            "id": "btsi-345678932",
            "name": "ins2",
            "region": "bd",
            "state": "Normal",
            "createTime": "2018-05-06T14:32:09Z"
            "storageType": "CommonPerformance"
        }
    ]
}

显示实例信息ShowInstance

描述

显示指定实例信息。

请求

Verb URI
GET /v{version}/instance/{instanceName}

请求参数

响应参数

参数名称 参数类型 说明
id string instance ID
name string instanceName
region string 所属百度智能云region
state string instance当前状态,目前只有Normal状态。
- Normal:instance处于正常状态
createTime string instance创建的UTC时间
storageType string 该Instance下表的默认存储类型

错误码

http_code code 说明
200 - 请求成功
401 AuthenticationFailed 认证失败
400 InvalidURI URI非法
405 MethodNotAllowed 传递了不支持的HTTP方法
400 InvalidContentType 请求头域Content-Type是不支持的类型
400 InvalidAutherization 请求头域Autherization没有传递
400 EmptyDate 请求头域Date或x-bce-date都没有传递
400 InvalidContentLength 请求头域Content-Length没有传递
400 ContentLengthMismatchBodySize 请求头域的Content-Length和实际Request body大小不等
400 MalformedJSON 请求体传递的json无法解析
500 InternalError 服务内部错误,需联系技术人员解决
404 InstanceNotExist Instance不存在
403 AccessDenied 请求了不属于自己创建的Instance
400 InvalidInstanceName Instance名称不合法

请求示例

GET /v1/instance/ins1 HTTP/1.1
HOST: bts.bd.baidubce.com
Authorization: bce-auth-v1/table-access-key/2018-05-24T13:41:13Z/1800/x-bce-date/{signature}
Content-Type: application/json
Content-Length: {payloadSizeBytes}
x-bce-date: 2018-05-24T13:41:13Z

响应示例

HTTP/1.1 200 OK
Date: Sat, 18 Aug 2018 18:18:18 GMT
Content-Type: application/json; charset=utf-8
Content-Length: {payloadSizeBytes}
x-bce-request-id: 7869616F-7A68-6977-656E-406261696475

{
    "id": "btsi-123456789",
    "name": "ins1",
    "region": "bd",
    "state": "Normal",
    "createTime": "2018-05-06T11:22:33Z"
    "storageType": "HighPerformance"
}
上一篇
临时授权访问
下一篇
表操作