4 saastool工具
saastool 是提供给客户的便捷命令行工具,使客户在不开发或少开发的情况下即可实现【数据管理】【策略管理】的对应功能。
开发者也可以参考该工具的功能源码(golang),实现贴合自身业务的处理逻辑。
源码:saastool
4.1 命令行模式
saastool help
Usage: saastool COMMAND [OPTIONS]
Commands:
info Saas Info
write Write user's 'bytes / uint32s / flags'
read Read user's 'bytes / uint32s / flags'
columnclear Clear columns for data space
resetds Reset data space
convert Convert data to write format
task Task commands
target Target commands
bind Bind commands
grant Grant commands
script Script commands
exp Exp commands
admincode Admin code commands
daemon Run in daemon mode
web Run web management console
"help" is the default command.
Use "saastool COMMAND -help" for more information about a command.
4.1.1 cfg.toml配置文件
saastool需要一个配置文件,其中可填写自己的Account、Token。使用配置文件可实现多账号多环境的区分。
该配置文件默认名称为 cfg.toml,请置于saastool 同目录下。也可以通过 -cfg 参数指定别的配置文件,例如 saastool -config my.toml。
# 样例
[auth]
account = "2000"
token = "test"
[apiurls]
baseurl = "https://api.rta.qq.com" # 正式环境
#baseurl = "https://srta.algo.com.cn" # 演示环境
4.1.2 info(获取Saas信息)
获取sRTA服务的基本信息,包括数据空间、策略ID等配置信息。
saastool info -help
Usage of info:
-config string
Config file. (default "cfg.toml")
参数说明
| 参数 | 必填 | 含义 | 样例 |
|---|---|---|---|
| -config | 否 | 配置文件路径 | cfg.toml(默认) |
使用示例
saastool info
4.1.3 read(读取用户数据)
读取指定用户在数据空间中的数据(包括字节、uint32和标志位)。
saastool read -help
Usage of read:
-appid string
Wechat appid
-config string
Config file. (default "cfg.toml")
-ds string
Data space ID (required)
-userids string
Device ID or Wechat UserID, separated by comma (required)
参数说明
| 参数 | 必填 | 含义 | 样例 |
|---|---|---|---|
| -userids | 是 | 用户ID列表,多个ID用逗号分隔;设备号MD5值(小写)或微信openid | cfcd208495d565ef66e7dff9f98764da |
| -ds | 是 | 数据空间ID | did、wuid、geo、geoip 或 geofac |
| -appid | 否 | 小程序ID,当ds为wuid时必填 | wx1111111111111111 |
| -config | 否 | 配置文件路径 | cfg.toml(默认) |
使用示例
# 读取did数据空间的用户数据
saastool read -ds did -userids cfcd208495d565ef66e7dff9f98764da
# 读取多个用户数据
saastool read -ds did -userids cfcd208495d565ef66e7dff9f98764da,a87ff679a2f3e71d9181a67b7542122c
# 读取wuid数据空间的用户数据
saastool read -ds wuid -userids o_e3j4ggVPO2CP8iCPBLunzKL79n -appid wx1111111111111111