Files
saasapi/cmd.proto
algotao 095a0b9b01 更新
2025-08-30 14:22:05 +08:00

368 lines
15 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
syntax = "proto3";
package saasapi;
option go_package = "e.coding.net/rta/public/saasapi";
// SaasReq 命令请求
message SaasReq {
oneof cmd {
Info info = 5; // 获取账号设置
Read read = 10; // 批量读取
Write write = 11; // 批量写入
ColumnWrite column_write = 12; // 全量列式写入
Task task_create = 20; // 任务创建
TaskList task_list = 21; // 列出任务
TaskRun task_run = 22; // 执行任务
TaskDelete task_delete = 23; // 删除任务
TaskInfo task_info = 24; // 任务详情
TargetList target_list = 50; // 列出策略及绑定
BindSet bind_set = 61; // 设置绑定
BindDelete bind_delete = 62; // 解除绑定
ScriptRun script_run = 90; // 运行脚本
ScriptUpdate script_update = 91; // 脚本升级
}
}
// Info 获取账号信息
message Info {
}
// Read 批量读取命令
message Read {
string dataspace_id = 1; // 数据空间ID
string appid = 2; // 小程序/小游戏/公众号/视频号的appid
repeated ReadItem read_items = 3; // 批量获取命令
}
// ReadItem 读取命令
message ReadItem {
string userid = 1; // 用户ID
}
// Write 批量写入命令
message Write {
string dataspace_id = 1; // 数据空间ID
string appid = 2; // 小程序/小游戏/公众号/视频号的appid
bool is_clear_all_first = 3; // 是否先清空该用户所有数据
repeated WriteItem write_items = 4; // 批量写入命令
}
// WriteItem 写入命令
message WriteItem {
string userid = 1; // 用户ID
Bytes write_bytes = 2; // byte区域
Uint32s write_uint32s = 3; // uint32区域
FlagsWithExpire write_flags_with_expire = 4; // 标志位区域
}
// Bytes 写入byte区域
message Bytes {
bytes bytes = 1; // 写入的byte
uint64 index_1 = 2; // 写入byte的索引值(0..63)
uint64 index_2 = 3; // 写入byte的索引值(64..127)
}
// Uint32s 写入uint32区域
message Uint32s {
repeated uint32 uint32s = 1; // 写入的uint32
uint64 index_1 = 2; // 写入uint32的索引值(0..15) 最多 16 个
//uint64 index_2 = 3; // 写入uint32的索引值(当前不支持)
}
// FlagsWithExpire 写入标志位区域
message FlagsWithExpire {
repeated FlagWithExpire flags_with_expire = 1; // 写入的标志位
uint64 index_1 = 2; // 写入标志位的索引值
}
// FlagWithExpire 标志位
message FlagWithExpire {
bool flag = 1; // 标志位
bool default_flag = 2; // 默认值。超时后则回到默认值。
uint32 expire = 3; // 过期时间,为 0 则永不过期
}
// ColumnWrite 全量列式写入命令
message ColumnWrite {
string dataspace_id = 1; // 数据空间ID
bool is_clear_all_first = 2; // 是否先执行清空
Bytes write_bytes = 3; // byte区域
Uint32s write_uint32s = 4; // uint32区域
FlagsWithExpire write_flags_with_expire = 5; // 标志位区域
}
message Task {
string dataspace_id = 1; // 数据空间ID
string appid = 2; // 小程序/小游戏/公众号/视频号的appid
string task_sha256 = 3; // 任务sha256
string task_description = 4; // 任务描述
repeated FileInfo task_file_infos = 5; // 文件列表
uint64 task_block_size = 6; // 文件块字节大小推荐50M
string source_path = 7; // 任务数据源路径
uint64 task_size = 8; // 任务所有文件的总大小
// 以下字段只在返回时填写,用于提供服务端的任务状态。在请求时填写会被忽略
string create_time = 10; // 创建时间
string run_time = 11; // 运行时间
string finish_time = 12; // 完成时间
TaskStatus status = 15; // 任务状态
}
// TaskList 任务列表
message TaskList {
TaskStatus status_filter = 1; // 只显示指定状态的任务
}
// TaskRun 任务运行
message TaskRun {
string task_sha256 = 1; // 任务sha256
}
// TaskDelete 取消任务
message TaskDelete {
string task_sha256 = 1; // 任务sha256
}
// TaskInfo 任务详情
message TaskInfo {
string task_sha256 = 1; // 任务sha256
}
// FileInfo 任务文件信息
message FileInfo {
string file_name = 1; // 文件名
uint64 file_size = 2; // 文件大小
repeated FileBlock file_blocks = 3; // 文件块列表
}
// FileBlock 文件块信息
message FileBlock {
string block_sha256 = 1; // 块的sha256
uint64 block_length = 2; // 块的字节长度
bool uploaded = 3; // 是否已上传在TaskCreate/TaskInfo请求返回
}
// TargetList 列出策略
message TargetList {
repeated string targets = 1; // 指定要列出的绑定的策略列表,如不指定则返回全部
bool list_bind = 2; // 是否同时列出绑定信息
}
// BindSet 设置绑定
message BindSet {
repeated Bind binds = 2; // 设置绑定内容
}
// BindDelete 删除绑定
message BindDelete {
repeated Bind binds = 2; // 解除绑定内容
}
// ScriptRun 运行脚本
message ScriptRun {
string lua_script = 1; // 要调试的lua脚本
string server_did = 2; // 将从服务端读取该DID下的数据
string appid = 3; // 小程序/小游戏/公众号/视频号的appid
string server_openid = 4; // 将从服务端读取该openid下的数据需与appid配对使用
OS os = 5; // 操作系统
}
// ScriptUpdate 升级脚本
message ScriptUpdate {
}
// SaasRes 命令返回
message SaasRes {
ErrorCode code = 1; // 返回码
string status = 2; // 返回信息的文本提示
oneof res {
InfoRes info_res = 5; // 账号信息返回
ReadRes read_res = 10; // 读取命令返回
WriteRes write_res = 11; // 写入命令返回
Task task_create_res = 20; // 创建任务返回状态
TaskListRes task_list_res = 21; // 任务列表返回状态
Task task_run_res = 22; // 运行任务返回状态
Task task_delete_res = 23; // 删除任务返回状态
Task task_info_res = 24; // 任务详情返回状态
TargetListRes target_list_res = 50; // 列出策略及绑定返回状态
BindSetRes bind_set_res = 61; // 设置绑定返回状态
BindDeleteRes bind_delete_res = 62; // 删除绑定返回状态
ScriptRunRes script_run_res = 90; // 运行脚本返回
ScriptUpdateRes script_update_res = 91; // 升级脚本返回
}
}
// InfoRes 账号信息返回
message InfoRes {
repeated string dataspace_id = 1; // 可用数据区列表
repeated string target_id = 2; // 策略ID列表
}
// ReadRes 读记录返回
message ReadRes {
uint32 succ_cmd_count = 1; // 成功的命令数量
uint32 fail_cmd_count = 2; // 失败的命令数量
repeated ValueItem cmd_res = 3; // 返回的命令
}
// WriteRes 写记录返回
message WriteRes {
//uint32 succ_cmd_count = 1; // 成功的命令数量
//uint32 fail_cmd_count = 2; // 失败的命令数量
repeated string failed_userid = 3; // 返回的失败的用户ID
}
// ValueItem 读取命令返回内容
message ValueItem {
uint32 cmd_index = 1; // 命令索引
CmdErrorCode cmd_code = 2; // 状态
bytes bytes = 3; // byte区域
repeated uint32 uint32s = 4; // uint32区域
repeated FlagWithExpire flags_with_expire = 5; // 标志位区域
uint32 last_modify_time = 6; // 最后修改时间
}
// TaskListRes 任务列表返回
message TaskListRes {
repeated Task tasks = 1; // 任务列表
}
// TargetListRes 策略列表返回
message TargetListRes {
map<string, Binds> target_list = 1; // 绑定列表
}
message Binds {
repeated Bind binds = 1;
}
// Bind 绑定信息
message Bind {
int64 bind_id = 1; //绑定的ID
BindType bind_type = 2; //绑定类型
string target_id = 3; //策略ID
int64 account_id = 4; //广告主ID
BindSourceType bind_source = 5; //绑定操作来源
}
// BindType 绑定类型
enum BindType {
UnknownBindType = 0;
AdgroupId = 1; //广告
AccountId = 3; //广告主
}
// BindSourceType 绑定操作来源
enum BindSourceType {
DefaultBindSourceType = 0; //广告主或未填写
ThirdPartyApi = 1; //第三方API
ADQ = 2; //ADQ平台
MP = 3; //MP平台
MktApi = 4; //MarketingAPI
}
// BindSetRes 设置绑定返回
message BindSetRes {
int32 success_num = 1; //成功数
int32 error_num = 2; //错误数
repeated BindError errors = 3; //绑定错误的记录
}
// BindDeleteRes 删除绑定返回
message BindDeleteRes {
int32 success_num = 1; //成功数
int32 error_num = 2; //错误数
repeated BindError errors = 3; //绑定错误的记录
}
// BindError 绑定错误信息
message BindError {
int64 bind_id = 1; //错误绑定的绑定ID
int32 bind_type = 2; //绑定类型
string reason = 3; //错误绑定原因
}
// ScriptRunRes 运行脚本返回
message ScriptRunRes {
string print_output = 1; // print输出
string error = 2; // 错误信息
string targets_output = 3; // 策略输出
}
// ScriptUpdateRes 升级脚本返回
message ScriptUpdateRes {
}
// ErrorCode 返回码
enum ErrorCode {
SUCC = 0; // 成功
INVALID_ACCOUNT = 101; // Account不合法
INVALID_TIMESTAMP = 102; // 头信息缺少时间戳或不正确
INVALID_SIGNATURE = 103; // 头信息缺少签名
AUTH_FAIL = 104; // 签名较验失败
DISABLED_ACCOUNT = 105; // 账号已禁用
INVALID_CONTENT_TYPE = 110; // 非法的Content-Type
READ_BODY = 111; // 读取 http body 失败
DECODE_BODY = 112; // 解码 body 失败
QPS_LIMIT = 113; // 并发请求量超限
CMDS_LIMIT = 114; // 命令数量超限
CMDS_NULL = 115; // 命令为空
DATASPACE_NOT_EXISTS = 116; // 数据空间不存在
TASK_EXISTS = 120; // 任务已存在
TASK_IS_NOT_EXISTS = 121; // 任务不存在
TASK_NUM_LIMIT = 122; // 任务数达到上限
TASK_BLOCK_SIZE = 123; // 块大小超限
TASK_TOTAL_SIZE = 124; // 总文件大小超限
TASK_MARSHAL = 125; // 序列化
TASK_IS_WATING = 130; // 任务未上传完毕
TASK_IS_RUNNING = 131; // 任务已经在运行
TASK_FAILED = 132; // 任务已失败
TASK_FINISHED = 133; // 任务已完成
DATA_ERROR = 201; // 数据错误
CMD_ERROR = 202; // 命令行执行错误
API_ERROR = 301; // 调用内部API错误
}
enum CmdErrorCode {
OK = 0; // 成功
}
enum TaskStatus {
ALL = 0; // 全部
WAITING = 1; // 等待中
READY = 2; // 上传完毕
RUNNING = 3; // 运行中
SUCCESS = 4; // 成功
FAIL = 5; // 失败
DELETED = 10; // 已删除,仅在执行删除成功时返回
}
enum OS {
UNKNOWN = 0;
IOS = 1;
ANDROID = 2;
}