http://{Tcaplus_REST_URL}/{Version}/apps/{AppId}/zones/{ZoneId}/tables/{TableName}/records
http://10.123.9.70/ver1.0/apps/2/zones/1/tables/tb_rest_test/records
x-tcaplus-pwd-md5
此字段填写用户 app key 的 MD5 计算结果用于客户端权限验证。
请通过以下 bash 命令计算字符串的 MD5 值:# echo -n "c3eda5f013f92c81dda7afcdc273cf82" | md5sum879423b88d153cace7b31773a7f46039 -
x-tcaplus-target
指定 Tcaplus RESTful API 请求操作,具体包含以下操作类型:x-tcaplus-idl-type
指定 Tcaplus 表类型,目前只支持 protobuf(pb)类型。x-tcaplus-data-version-check
Specifies Tcaplus data version check policy use with x-tcaplus-data-version
. It can be set as:
指定 Tcaplus 数据版本号校验策略,实现乐观锁功能,与x-tcaplus-data-version
标记配合使用,可选值如下:1
:当设置为1,客户端的数据版本号必须与存储层数据版本号一致才能写操作,操作会令数据版本号+1。2
:当设置为2,就不检测客户端版本号与服务端版本号之间的关系,强制将客户端传入的版本号设置到存储层。3
:当设置为3,就不检测客户端版本号与服务端版本号之间的关系,写操作会将存储层数据版本号+1。x-tcaplus-data-version
与 x-tcaplus-data-version-check
标记相配合,设置客户端的数据版本号。可选值如下:x-tcaplus-result-flag
设置应答中是否包含完整数据的策略,可能的取值有:0
设置为0,应答中仅包含请求成功或失败。1
设置为1,应答中包含与请求一致的值。2
设置为2,应答中包含被修改的数据的所有字段最新值。3
设置为3,应答中包含记录被修改前的值。Request Data:{"ReturnValues": "...", // 用户设置的保留数据,随请求到达tcaplus并由应答原样带回"Record": {... // 数据记录,详细格式请参见“API简明示例”一节}}
Response Data{"ErrorCode": 0, // 返回码"ErrorMsg": "Succeed", // 返回信息"RecordVersion": 1, // 数据版本号"ReturnValues": "...", // 用户设置的保留数据,随请求到达tcaplus并由应答原样带回"Record": { // 数据记录,详细格式请参见“API简明示例”一节...}}
Response Data{"ErrorCode": 0, // 返回码"ErrorMsg": "Succeed", // 返回信息"MultiRecords": [ //多条数据构成的数组{"RecordVersion": 1, //每条数据的版本号"Record": {...} // 数据记录,详细格式请参见“API简明示例”一节},...],"RemainNum": 0, //还未访问到的数据条数"TotalNum": 5 //满足条件的总数据条数}
HTTP 状态码 | 返回码 | 返回信息 |
200 | 0 | 成功 |
400 | -2579 | 数据反序列化错误 |
401 | -279 | 鉴权错误 |
400 | -11539 | 非法请求 详细原因请参考返回信息字段 |
400 | -2067 | 操作类型不匹配 |
400 | -1811 | 非法参数 |
400 | -5395 | 没有设置主键字段 |
400 | -2323 | 数据序列化错误 |
400 | -7949 | 非法数据版本号 一般发生在写操作,应用数据版本检查策略时 |
400 | -1293 | 记录已经存在 |
404 | 261 | 记录不存在 |
404 | -34565 | 索引不存在 |
500 | - | 系统内部错误 请参考返回信息字段 |
GET /ver1.0/apps/{APP_ID}/zones/{ZONE_ID}/tables/{TABLE_NAME}/records?keys={JSONKeysObj}&select={JSONSelectObj}
keys
变量,而 select 变量则是可选项。keys 指所有主键的值,select 指需要显示的 value 字段的名称。并且您可以通过点分路径的方式指定嵌套结构中的字段,例如:“pay.total_money”。名称 | 类型 | 取值 |
x-tcaplus-target | String | Tcaplus.GetRecord |
x-tcaplus-version | String | Tcaplus3.32.0 |
x-tcaplus-pwd-md5 | String | MD5 of AppKey(Password) |
x-tcaplus-idl-type | String | protobuf |
http://10.123.9.70:31002/ver1.0/apps/2/zones/1/tables/tb_example/records?keys={'region': 101, 'name': 'calvinshao', 'uin': 100}
http://10.123.9.70:31002/ver1.0/apps/2/zones/1/tables/tb_example/records?keys=%7B%22region%22%3A%20101%2C%20%22name%22%3A%20%22calvinshao%22%2C%20%22uin%22%3A%20100%7D
["x-tcaplus-target:Tcaplus.GetRecord","x-tcaplus-version:Tcaplus3.32.0","x-tcaplus-pwd-md5:c3eda5f013f92c81dda7afcdc273cf82","x-tcaplus-idl-type:protobuf"]
{"ErrorCode": 0,"ErrorMsg": "Succeed","RecordVersion": 1,"Record": {"name": "calvinshao","lockid": [50,60,70],"pay": {"pay_times": 2,"total_money": 10000,"pay_id": 5,"auth": {"pay_keys": "adqwacsasafasda","update_time": 1528018372}},"region": 101,"uin": 100,"is_available": true,"gamesvrid": 4099,"logintime": 404}}
PUT /ver1.0/apps/{APP_ID}/zones/{ZONE_ID}/tables/{TABLE_NAME}/records
0
设置为0,应答中仅包含请求成功或失败1
设置为1,应答中包含与请求一致的值2
设置为2,应答中包含被修改的数据的所有字段最新值3
设置为3,应答中包含记录被修改前的值名称 | 类型 | 取值 |
x-tcaplus-target | String | Tcaplus.SetRecord |
x-tcaplus-version | String | Tcaplus3.32.0 |
x-tcaplus-pwd-md5 | String | MD5 of AppKey(Password) |
x-tcaplus-result-flag | Int | 2 |
x-tcaplus-data-version-check | Int | 2 |
x-tcaplus-data-version | Int | -1 |
x-tcaplus-idl-type | String | protobuf |
http://10.123.9.70/ver1.0/apps/2/zones/1/tables/tb_example/records
["x-tcaplus-target:Tcaplus.SetRecord","x-tcaplus-version:Tcaplus3.32.0","x-tcaplus-pwd-md5:c3eda5f013f92c81dda7afcdc273cf82","x-tcaplus-result-flag:2","x-tcaplus-data-version-check:2","x-tcaplus-data-version:-1","x-tcaplus-idl-type:Protobuf"]
{"ReturnValues": "Send to tcaplus by calvinshao","Record": {"name": "calvinshao","lockid": [50,60,70,80,90,100],"pay": {"pay_times": 3,"total_money": 12000,"pay_id": 5,"auth": {"pay_keys": "adqwacsasafasda","update_time": 1528018372}},"region": 101,"uin": 100,"is_available": false,"gamesvrid": 4099,"logintime": 404}}
{"ErrorCode": 0,"ErrorMsg": "Succeed","RecordVersion": 1,"ReturnValues": "Send to tcaplus by calvinshao","Record": {"name": "calvinshao","lockid": [50,60,70,80,90,100],"pay": {"pay_times": 3,"total_money": 12000,"pay_id": 5,"auth": {"pay_keys": "adqwacsasafasda","update_time": 1528018372}},"region": 101,"uin": 100,"is_available": false,"gamesvrid": 4099,"logintime": 404}}
POST /ver1.0/apps/{APP_ID}/zones/{ZONE_ID}/tables/{TABLE_NAME}/records
0
设置为0,应答中仅包含请求成功或失败1
设置为1,应答中包含与请求一致的值2
设置为2,应答中包含被修改的数据的所有字段最新值3
设置为3,应答中包含记录被修改前的值名称 | 类型 | 取值 |
x-tcaplus-target | String | Tcaplus.SetRecord |
x-tcaplus-version | String | Tcaplus3.32.0 |
x-tcaplus-pwd-md5 | String | MD5 of AppKey(Password) |
x-tcaplus-result-flag | Int | 1 |
x-tcaplus-idl-type | String | protobuf |
http://10.123.9.70/ver1.0/apps/2/zones/1/tables/tb_example/records
["x-tcaplus-target:Tcaplus.AddRecord","x-tcaplus-version:Tcaplus3.32.0","x-tcaplus-pwd-md5:c3eda5f013f92c81dda7afcdc273cf82","x-tcaplus-result-flag:1","x-tcaplus-idl-type:protobuf"]
{"ReturnValues": "Send to tcaplus by calvinshao","Record": {"name": "calvinshao","lockid": [50,60,70],"pay": {"pay_times": 2,"total_money": 10000,"pay_id": 5,"auth": {"pay_keys": "adqwacsasafasda","update_time": 1528018372}},"region": 101,"uin": 100,"is_available": true,"gamesvrid": 4099,"logintime": 404}}
{"ErrorCode": 0,"ErrorMsg": "Succeed","RecordVersion": 1,"ReturnValues": "Send to tcaplus by calvinshao","Record": {"name": "calvinshao","lockid": [50,60,70],"pay": {"pay_times": 2,"total_money": 10000,"pay_id": 5,"auth": {"pay_keys": "adqwacsasafasda","update_time": 1528018372}},"region": 101,"uin": 100,"is_available": true,"gamesvrid": 4099,"logintime": 404}}
DELETE /ver1.0/apps/{APP_ID}/zones/{ZONE_ID}/tables/{TABLE_NAME}/records
0
设置为0,应答中仅包含请求成功或失败1
设置为1,应答中包含与请求一致的值2
设置为2,应答中包含被修改的数据的所有字段最新值3
设置为3,应答中包含记录被修改前的值名称 | 类型 | 取值 |
x-tcaplus-target | String | Tcaplus.SetRecord |
x-tcaplus-version | String | Tcaplus3.32.0 |
x-tcaplus-pwd-md5 | String | MD5 of AppKey(Password) |
x-tcaplus-result-flag | Int | 1 |
x-tcaplus-idl-type | String | protobuf |
http://10.123.9.70/ver1.0/apps/2/zones/1/tables/tb_example/records
["x-tcaplus-target:Tcaplus.DeleteRecord","x-tcaplus-version:Tcaplus3.32.0","x-tcaplus-pwd-md5:c3eda5f013f92c81dda7afcdc273cf82","x-tcaplus-result-flag:1","x-tcaplus-idl-type:protobuf"]
{"ReturnValues": "Send to tcaplus by calvinshao","Record": {"region": 101,"name": "calvinshao","uin": 100}}
{"ErrorCode": 0,"Record": {},"RecordVersion": -1,"ReturnValues": "Send to tcaplus by calvinshao"}
GET /ver1.0/apps/{APP_ID}/zones/{ZONE_ID}/tables/{TABLE_NAME}/records?keys={JSONKeysObj}&select={JSONSelectObj}
keys
和select
变量。keys 指定所有主键的值,select 指定需要显示的 value 字段的名称。并且用户可以通过点分路径的方式指定嵌套结构中的字段,例如:“pay.total_money”。名称 | 类型 | 取值 |
x-tcaplus-target | String | Tcaplus.FieldGetRecord |
x-tcaplus-version | String | Tcaplus3.32.0 |
x-tcaplus-pwd-md5 | String | MD5 of AppKey(Password) |
x-tcaplus-idl-type | String | protobuf |
http://10.123.9.70/ver1.0/apps/2/zones/1/tables/tb_example/records?keys={'region': 101, 'name': 'calvinshao', 'uin': 100}&select=['gamesvrid', 'lockid', 'pay.auth.pay_keys', 'pay.total_money']
http://10.123.9.70/ver1.0/apps/2/zones/1/tables/tb_example/records?keys=%7B%22region%22%3A%20101%2C%20%22name%22%3A%20%22calvinshao%22%2C%20%22uin%22%3A%20100%7D&select=%5B%22gamesvrid%22%2C%20%22lockid%22%2C%20%22pay.auth.pay_keys%22%2C%20%22pay.total_money%22%5D
["x-tcaplus-target:Tcaplus.FieldGetRecord","x-tcaplus-version:Tcaplus3.32.0","x-tcaplus-pwd-md5:c3eda5f013f92c81dda7afcdc273cf82","x-tcaplus-idl-type:protobuf"]
{"ErrorCode": 0,"ErrorMsg": "Succeed","RecordVersion": 1,"Record": {"name": "calvinshao","lockid": [50,60,70],"pay": {"total_money": 10000,"auth": {"pay_keys": "adqwacsasafasda"}},"region": 101,"uin": 100,"gamesvrid": 4099}}
PUT /ver1.0/apps/{APP_ID}/zones/{ZONE_ID}/tables/{TABLE_NAME}/records
0
设置为0,应答中仅包含请求成功或失败1
设置为1,应答中包含与请求一致的值名称 | 类型 | 取值 |
x-tcaplus-target | String | Tcaplus.SetRecord |
x-tcaplus-version | String | Tcaplus3.32.0 |
x-tcaplus-pwd-md5 | String | MD5 of AppKey(Password) |
x-tcaplus-result-flag | Int | 2 |
x-tcaplus-data-version-check | Int | 2 |
x-tcaplus-data-version | Int | -1 |
x-tcaplus-idl-type | String | protobuf |
http://10.123.9.70/ver1.0/apps/2/zones/1/tables/tb_example/records
["x-tcaplus-target:Tcaplus.FieldSetRecord","x-tcaplus-version:Tcaplus3.32.0","x-tcaplus-pwd-md5:c3eda5f013f92c81dda7afcdc273cf82","x-tcaplus-result-flag:1","x-tcaplus-data-version-check:1","x-tcaplus-data-version:-1","x-tcaplus-idl-type:Protobuf"]
{"ReturnValues": "aaaaaaaaaa","FieldPath": [ // 显式指定需要更新的字段路径"gamesvrid","logintime","pay.total_money","pay.auth.pay_keys"],"Record": { // 设置需要更新的字段新值"name": "calvinshao","pay": {"total_money": 17190,"auth": {"pay_keys": "bingo"}},"region": 101,"uin": 100,"gamesvrid": 1719,"logintime": 1719}}
{"ErrorCode": 0,"ErrorMsg": "Succeed","RecordVersion": 3,"ReturnValues": "aaaaaaaaaa","Record": {"name": "calvinshao","pay": {"total_money": 17190,"auth": {"pay_keys": "bingo"}},"region": 101,"uin": 100,"gamesvrid": 1719,"logintime": 1719}}
PUT /ver1.0/apps/{APP_ID}/zones/{ZONE_ID}/tables/{TABLE_NAME}/records
int32
, int64
, uint32
和 uint64
类型字段。特性与 FieldSetRecord 类似。0
设置为0,应答中仅包含请求成功或失败1
设置为1,应答中包含指定字段修改后的值名称 | 类型 | 取值 |
x-tcaplus-target | String | Tcaplus.SetRecord |
x-tcaplus-version | String | Tcaplus3.32.0 |
x-tcaplus-pwd-md5 | String | MD5 of AppKey(Password) |
x-tcaplus-result-flag | Int | 2 |
x-tcaplus-data-version-check | Int | 2 |
x-tcaplus-data-version | Int | -1 |
x-tcaplus-idl-type | String | protobuf |
http://10.123.9.70/ver1.0/apps/2/zones/1/tables/tb_example/records
["x-tcaplus-target:Tcaplus.FieldIncRecord","x-tcaplus-version:Tcaplus3.32.0","x-tcaplus-pwd-md5:c3eda5f013f92c81dda7afcdc273cf82","x-tcaplus-result-flag:1","x-tcaplus-data-version-check:1","x-tcaplus-data-version:-1","x-tcaplus-idl-type:Protobuf"]
{"ReturnValues": "aaaaaaaaaa","Record": {"name": "calvinshao","pay": {"total_money": -1,"auth": {"update_time": -1}},"region": 101,"uin": 100,"gamesvrid": 2,"logintime": -2}}
{"ErrorCode": 0,"ErrorMsg": "Succeed","RecordVersion": 9,"ReturnValues": "aaaaaaaaaa","Record": {"name": "calvinshao","pay": {"total_money": 11999,"auth": {"update_time": 921}},"region": 101,"uin": 100,"gamesvrid": 4101,"logintime": 98}}
GET /ver1.0/apps/{APP_ID}/zones/{ZONE_ID}/tables/{TABLE_NAME}/records?keys={JSONKeysObj}&select={JSONSelectObj}
keys
变量,而 select 变量则是可选项。keys 指定所有主键的值,select 指定需要显示的 value 字段的名称。并且用户可以通过点分路径的方式指定嵌套结构中的字段,例如:“pay.total_money”。x-tcaplus-index-name
指定想要访问的索引名,索引名在表定义文件中可以找到。名称 | 类型 | 取值 |
x-tcaplus-target | String | Tcaplus.GetRecord |
x-tcaplus-version | String | Tcaplus3.32.0 |
x-tcaplus-pwd-md5 | String | MD5 of AppKey(Password) |
x-tcaplus-idl-type | String | protobuf |
x-tcaplus-index-name | String | {index_name} |
http://10.123.9.70/ver1.0/apps/2/zones/1/tables/tb_example/records?keys={'name': 'calvinshao', 'uin': 100}&select=['gamesvrid', 'lockid', 'pay.total_money', 'pay.auth.pay_keys']
http://10.123.9.70/ver1.0/apps/2/zones/1/tables/tb_example/records?keys=%7B%22name%22%3A%20%22calvinshao%22%2C%20%22uin%22%3A%20100%7D&select=%5B%22gamesvrid%22%2C%20%22lockid%22%2C%20%22pay.total_money%22%2C%20%22pay.auth.pay_keys%22%5D
["x-tcaplus-target:Tcaplus.PartkeyGetRecord","x-tcaplus-version:Tcaplus3.32.0","x-tcaplus-pwd-md5:c3eda5f013f92c81dda7afcdc273cf82","x-tcaplus-idl-type:protobuf""x-tcaplus-index-name:index_name"]
{"ErrorCode": 0,"ErrorMsg": "Succeed","MultiRecords": [{"RecordVersion": 9,"Record": {"name": "calvinshao","lockid": [50,60,70,80,90,100],"pay": {"total_money": 11999,"auth": {"pay_keys": "adqwacsasafasda"}},"region": 101,"uin": 100,"gamesvrid": 4101}},{"RecordVersion": 1,"Record": {"name": "calvinshao","lockid": [50,60,70,80],"pay": {"total_money": 10000,"auth": {"pay_keys": "adqwacsasafasda"}},"region": 102,"uin": 100,"gamesvrid": 4100}},{"RecordVersion": 1,"Record": {"name": "calvinshao","lockid": [60,70,80,90],"pay": {"total_money": 10000,"auth": {"pay_keys": "adqwacsasafasda"}},"region": 103,"uin": 100,"gamesvrid": 4101}}],"RemainNum": 0,"TotalNum": 3}
本页内容是否解决了您的问题?