调整授权功能
This commit is contained in:
40
cmd.pb.go
40
cmd.pb.go
@@ -157,7 +157,7 @@ const (
|
||||
ErrorCode_DATA_ERROR ErrorCode = 201 // 数据错误
|
||||
ErrorCode_CMD_ERROR ErrorCode = 202 // 命令行执行错误
|
||||
ErrorCode_API_ERROR ErrorCode = 301 // 调用内部API错误
|
||||
ErrorCode_TARGET_ERROR ErrorCode = 401 // Target参数错误
|
||||
ErrorCode_PARAM_ERROR ErrorCode = 401 // 参数错误
|
||||
)
|
||||
|
||||
// Enum value maps for ErrorCode.
|
||||
@@ -189,7 +189,7 @@ var (
|
||||
201: "DATA_ERROR",
|
||||
202: "CMD_ERROR",
|
||||
301: "API_ERROR",
|
||||
401: "TARGET_ERROR",
|
||||
401: "PARAM_ERROR",
|
||||
}
|
||||
ErrorCode_value = map[string]int32{
|
||||
"SUCC": 0,
|
||||
@@ -218,7 +218,7 @@ var (
|
||||
"DATA_ERROR": 201,
|
||||
"CMD_ERROR": 202,
|
||||
"API_ERROR": 301,
|
||||
"TARGET_ERROR": 401,
|
||||
"PARAM_ERROR": 401,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -2219,12 +2219,12 @@ func (*GrantList) Descriptor() ([]byte, []int) {
|
||||
|
||||
// Grant 数据授权信息
|
||||
type Grant struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
SrtaAccountId uint32 `protobuf:"varint,1,opt,name=srta_account_id,json=srtaAccountId,proto3" json:"srta_account_id,omitempty"` // sRTA授权目标账号ID
|
||||
GrantIndex string `protobuf:"bytes,2,opt,name=grant_index,json=grantIndex,proto3" json:"grant_index,omitempty"` // 授权索引。格式为 "index1, index2, index55-index64",例如 "1, 2, 55-64"
|
||||
DataspaceId string `protobuf:"bytes,3,opt,name=dataspace_id,json=dataspaceId,proto3" json:"dataspace_id,omitempty"` // 授权数据空间ID
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
TargetAccountId uint32 `protobuf:"varint,1,opt,name=target_account_id,json=targetAccountId,proto3" json:"target_account_id,omitempty"` // sRTA授权目标账号ID
|
||||
GrantIndex string `protobuf:"bytes,2,opt,name=grant_index,json=grantIndex,proto3" json:"grant_index,omitempty"` // 授权索引。格式为 "index1, index2, index55-index64",例如 "1, 2, 55-64"
|
||||
DataspaceId uint32 `protobuf:"varint,3,opt,name=dataspace_id,json=dataspaceId,proto3" json:"dataspace_id,omitempty"` // 授权数据空间ID(数字型)
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Grant) Reset() {
|
||||
@@ -2257,9 +2257,9 @@ func (*Grant) Descriptor() ([]byte, []int) {
|
||||
return file_cmd_proto_rawDescGZIP(), []int{24}
|
||||
}
|
||||
|
||||
func (x *Grant) GetSrtaAccountId() uint32 {
|
||||
func (x *Grant) GetTargetAccountId() uint32 {
|
||||
if x != nil {
|
||||
return x.SrtaAccountId
|
||||
return x.TargetAccountId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -2271,11 +2271,11 @@ func (x *Grant) GetGrantIndex() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Grant) GetDataspaceId() string {
|
||||
func (x *Grant) GetDataspaceId() uint32 {
|
||||
if x != nil {
|
||||
return x.DataspaceId
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
// ScriptRun 运行脚本
|
||||
@@ -4887,12 +4887,12 @@ const file_cmd_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"BindDelete\x12#\n" +
|
||||
"\x05binds\x18\x02 \x03(\v2\r.saasapi.BindR\x05binds\"\v\n" +
|
||||
"\tGrantList\"s\n" +
|
||||
"\x05Grant\x12&\n" +
|
||||
"\x0fsrta_account_id\x18\x01 \x01(\rR\rsrtaAccountId\x12\x1f\n" +
|
||||
"\tGrantList\"w\n" +
|
||||
"\x05Grant\x12*\n" +
|
||||
"\x11target_account_id\x18\x01 \x01(\rR\x0ftargetAccountId\x12\x1f\n" +
|
||||
"\vgrant_index\x18\x02 \x01(\tR\n" +
|
||||
"grantIndex\x12!\n" +
|
||||
"\fdataspace_id\x18\x03 \x01(\tR\vdataspaceId\"\xa1\x01\n" +
|
||||
"\fdataspace_id\x18\x03 \x01(\rR\vdataspaceId\"\xa1\x01\n" +
|
||||
"\tScriptRun\x12\x1d\n" +
|
||||
"\n" +
|
||||
"lua_script\x18\x01 \x01(\tR\tluaScript\x12\x1d\n" +
|
||||
@@ -5098,7 +5098,7 @@ const file_cmd_proto_rawDesc = "" +
|
||||
"\x03ADQ\x10\x02\x12\x06\n" +
|
||||
"\x02MP\x10\x03\x12\n" +
|
||||
"\n" +
|
||||
"\x06MktApi\x10\x04*\x8d\x04\n" +
|
||||
"\x06MktApi\x10\x04*\x8c\x04\n" +
|
||||
"\tErrorCode\x12\b\n" +
|
||||
"\x04SUCC\x10\x00\x12\x13\n" +
|
||||
"\x0fINVALID_ACCOUNT\x10e\x12\x15\n" +
|
||||
@@ -5127,8 +5127,8 @@ const file_cmd_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"DATA_ERROR\x10\xc9\x01\x12\x0e\n" +
|
||||
"\tCMD_ERROR\x10\xca\x01\x12\x0e\n" +
|
||||
"\tAPI_ERROR\x10\xad\x02\x12\x11\n" +
|
||||
"\fTARGET_ERROR\x10\x91\x03*\x16\n" +
|
||||
"\tAPI_ERROR\x10\xad\x02\x12\x10\n" +
|
||||
"\vPARAM_ERROR\x10\x91\x03*\x16\n" +
|
||||
"\fCmdErrorCode\x12\x06\n" +
|
||||
"\x02OK\x10\x00*^\n" +
|
||||
"\n" +
|
||||
|
||||
@@ -196,9 +196,9 @@ message GrantList {
|
||||
|
||||
// Grant 数据授权信息
|
||||
message Grant {
|
||||
uint32 srta_account_id = 1; // sRTA授权目标账号ID
|
||||
uint32 target_account_id = 1; // sRTA授权目标账号ID
|
||||
string grant_index = 2; // 授权索引。格式为 "index1, index2, index55-index64",例如 "1, 2, 55-64"
|
||||
string dataspace_id = 3; // 授权数据空间ID
|
||||
uint32 dataspace_id = 3; // 授权数据空间ID(数字型)
|
||||
}
|
||||
|
||||
|
||||
@@ -527,7 +527,7 @@ enum ErrorCode {
|
||||
|
||||
API_ERROR = 301; // 调用内部API错误
|
||||
|
||||
TARGET_ERROR = 401; // Target参数错误
|
||||
PARAM_ERROR = 401; // 参数错误
|
||||
}
|
||||
|
||||
enum CmdErrorCode {
|
||||
|
||||
@@ -68,11 +68,13 @@ func RunExpGet(args ...string) error {
|
||||
|
||||
if *beginDay < 20250101 || *beginDay > 21001231 || *endDay < 20250101 || *endDay > 21001231 {
|
||||
fmt.Fprintln(os.Stderr, "begin/end day error")
|
||||
fs.PrintDefaults()
|
||||
return nil
|
||||
}
|
||||
|
||||
if *target == "" {
|
||||
fmt.Fprintln(os.Stderr, "target error")
|
||||
fs.PrintDefaults()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -14,15 +14,15 @@ import (
|
||||
type grantAddParams struct {
|
||||
srtaAccountId uint32
|
||||
grantIndex string
|
||||
ds string
|
||||
ds uint32
|
||||
saasHttp *saashttp.SaasClient
|
||||
}
|
||||
|
||||
func RunGrantAdd(args ...string) error {
|
||||
fs := flag.NewFlagSet("add", flag.ExitOnError)
|
||||
cfgFile := paramConfig(fs)
|
||||
ds := paramDataSpaceId(fs)
|
||||
srtaAccountId := paramSrtaAccountId(fs)
|
||||
dsid := paramRawDataSpaceId(fs)
|
||||
grantIndex := paramGrantIndex(fs)
|
||||
|
||||
if err := fs.Parse(args); err != nil {
|
||||
@@ -35,12 +35,6 @@ func RunGrantAdd(args ...string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(*ds) == 0 {
|
||||
fmt.Fprintln(os.Stderr, "Error: data space is required")
|
||||
fs.PrintDefaults()
|
||||
return fmt.Errorf("data space is required")
|
||||
}
|
||||
|
||||
if *srtaAccountId == 0 {
|
||||
fmt.Fprintln(os.Stderr, "Error: sRTA account ID is required")
|
||||
fs.PrintDefaults()
|
||||
@@ -53,6 +47,12 @@ func RunGrantAdd(args ...string) error {
|
||||
return fmt.Errorf("grant index is required")
|
||||
}
|
||||
|
||||
if *dsid == 0 {
|
||||
fmt.Fprintln(os.Stderr, "Error: data space ID is required")
|
||||
fs.PrintDefaults()
|
||||
return fmt.Errorf("data space ID is required")
|
||||
}
|
||||
|
||||
cfg, err := LoadConfigFile(*cfgFile)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "LoadConfigFile error", "err", err)
|
||||
@@ -62,7 +62,7 @@ func RunGrantAdd(args ...string) error {
|
||||
grantAddParams := grantAddParams{
|
||||
srtaAccountId: uint32(*srtaAccountId),
|
||||
grantIndex: *grantIndex,
|
||||
ds: *ds,
|
||||
ds: uint32(*dsid),
|
||||
saasHttp: &saashttp.SaasClient{
|
||||
Client: &http.Client{},
|
||||
ApiUrls: saashttp.InitAPIUrl(&cfg.ApiUrls),
|
||||
@@ -77,9 +77,9 @@ func doGrantAdd(params grantAddParams) error {
|
||||
saasReq := &saasapi.SaasReq{
|
||||
Cmd: &saasapi.SaasReq_GrantAdd{
|
||||
GrantAdd: &saasapi.Grant{
|
||||
SrtaAccountId: params.srtaAccountId,
|
||||
GrantIndex: params.grantIndex,
|
||||
DataspaceId: params.ds,
|
||||
TargetAccountId: params.srtaAccountId,
|
||||
GrantIndex: params.grantIndex,
|
||||
DataspaceId: params.ds,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@ import (
|
||||
type grantDeleteParams struct {
|
||||
srtaAccountId uint32
|
||||
grantIndex string
|
||||
ds string
|
||||
ds uint32
|
||||
saasHttp *saashttp.SaasClient
|
||||
}
|
||||
|
||||
func RunGrantDelete(args ...string) error {
|
||||
fs := flag.NewFlagSet("delete", flag.ExitOnError)
|
||||
cfgFile := paramConfig(fs)
|
||||
ds := paramDataSpaceId(fs)
|
||||
dsid := paramRawDataSpaceId(fs)
|
||||
srtaAccountId := paramSrtaAccountId(fs)
|
||||
grantIndex := paramGrantIndex(fs)
|
||||
|
||||
@@ -35,10 +35,10 @@ func RunGrantDelete(args ...string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(*ds) == 0 {
|
||||
fmt.Fprintln(os.Stderr, "Error: data space is required")
|
||||
if *dsid == 0 {
|
||||
fmt.Fprintln(os.Stderr, "Error: data space ID is required")
|
||||
fs.PrintDefaults()
|
||||
return fmt.Errorf("data space is required")
|
||||
return fmt.Errorf("data space ID is required")
|
||||
}
|
||||
|
||||
if *srtaAccountId == 0 {
|
||||
@@ -62,7 +62,7 @@ func RunGrantDelete(args ...string) error {
|
||||
grantDeleteParams := grantDeleteParams{
|
||||
srtaAccountId: uint32(*srtaAccountId),
|
||||
grantIndex: *grantIndex,
|
||||
ds: *ds,
|
||||
ds: uint32(*dsid),
|
||||
saasHttp: &saashttp.SaasClient{
|
||||
Client: &http.Client{},
|
||||
ApiUrls: saashttp.InitAPIUrl(&cfg.ApiUrls),
|
||||
@@ -77,9 +77,9 @@ func doGrantDelete(params grantDeleteParams) error {
|
||||
saasReq := &saasapi.SaasReq{
|
||||
Cmd: &saasapi.SaasReq_GrantDelete{
|
||||
GrantDelete: &saasapi.Grant{
|
||||
SrtaAccountId: params.srtaAccountId,
|
||||
GrantIndex: params.grantIndex,
|
||||
DataspaceId: params.ds,
|
||||
TargetAccountId: params.srtaAccountId,
|
||||
GrantIndex: params.grantIndex,
|
||||
DataspaceId: params.ds,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -157,8 +157,12 @@ func paramSrtaAccountId(fs *flag.FlagSet) *uint64 {
|
||||
return fs.Uint64("account", 0, "sRTA account ID")
|
||||
}
|
||||
|
||||
func paramRawDataSpaceId(fs *flag.FlagSet) *uint64 {
|
||||
return fs.Uint64("ds", 0, "Raw data space ID")
|
||||
}
|
||||
|
||||
func paramGrantIndex(fs *flag.FlagSet) *string {
|
||||
return fs.String("index", "", "Grant index. Format: \"index1, index2, index55-index64\"")
|
||||
return fs.String("index", "", "Grant index. Format: \"1, 2, 4, 55-64\"")
|
||||
}
|
||||
|
||||
// ParseByteSize 解析字节大小字符串为字节数
|
||||
|
||||
Reference in New Issue
Block a user