diff --git a/cmd.pb.go b/cmd.pb.go index 538a24c..c65408e 100644 --- a/cmd.pb.go +++ b/cmd.pb.go @@ -2222,6 +2222,7 @@ 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 } @@ -2270,6 +2271,13 @@ func (x *Grant) GetGrantIndex() string { return "" } +func (x *Grant) GetDataspaceId() string { + if x != nil { + return x.DataspaceId + } + return "" +} + // ScriptRun 运行脚本 type ScriptRun struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -4879,11 +4887,12 @@ const file_cmd_proto_rawDesc = "" + "\n" + "BindDelete\x12#\n" + "\x05binds\x18\x02 \x03(\v2\r.saasapi.BindR\x05binds\"\v\n" + - "\tGrantList\"P\n" + + "\tGrantList\"s\n" + "\x05Grant\x12&\n" + "\x0fsrta_account_id\x18\x01 \x01(\rR\rsrtaAccountId\x12\x1f\n" + "\vgrant_index\x18\x02 \x01(\tR\n" + - "grantIndex\"\xa1\x01\n" + + "grantIndex\x12!\n" + + "\fdataspace_id\x18\x03 \x01(\tR\vdataspaceId\"\xa1\x01\n" + "\tScriptRun\x12\x1d\n" + "\n" + "lua_script\x18\x01 \x01(\tR\tluaScript\x12\x1d\n" + diff --git a/cmd.proto b/cmd.proto index b80d167..8dd525e 100644 --- a/cmd.proto +++ b/cmd.proto @@ -198,6 +198,7 @@ message GrantList { message Grant { uint32 srta_account_id = 1; // sRTA授权目标账号ID string grant_index = 2; // 授权索引。格式为 "index1, index2, index55-index64",例如 "1, 2, 55-64" + string dataspace_id = 3; // 授权数据空间ID } diff --git a/cmd/saastool/grant_add.go b/cmd/saastool/grant_add.go index 9920801..ee374a1 100644 --- a/cmd/saastool/grant_add.go +++ b/cmd/saastool/grant_add.go @@ -14,12 +14,14 @@ import ( type grantAddParams struct { srtaAccountId uint32 grantIndex string + ds string saasHttp *saashttp.SaasClient } func RunGrantAdd(args ...string) error { fs := flag.NewFlagSet("add", flag.ExitOnError) cfgFile := paramConfig(fs) + ds := paramDataSpaceId(fs) srtaAccountId := paramSrtaAccountId(fs) grantIndex := paramGrantIndex(fs) @@ -33,6 +35,12 @@ 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() @@ -54,6 +62,7 @@ func RunGrantAdd(args ...string) error { grantAddParams := grantAddParams{ srtaAccountId: uint32(*srtaAccountId), grantIndex: *grantIndex, + ds: *ds, saasHttp: &saashttp.SaasClient{ Client: &http.Client{}, ApiUrls: saashttp.InitAPIUrl(&cfg.ApiUrls), @@ -70,6 +79,7 @@ func doGrantAdd(params grantAddParams) error { GrantAdd: &saasapi.Grant{ SrtaAccountId: params.srtaAccountId, GrantIndex: params.grantIndex, + DataspaceId: params.ds, }, }, } diff --git a/cmd/saastool/grant_delete.go b/cmd/saastool/grant_delete.go index db85ae8..89fa2d8 100644 --- a/cmd/saastool/grant_delete.go +++ b/cmd/saastool/grant_delete.go @@ -14,12 +14,14 @@ import ( type grantDeleteParams struct { srtaAccountId uint32 grantIndex string + ds string saasHttp *saashttp.SaasClient } func RunGrantDelete(args ...string) error { fs := flag.NewFlagSet("delete", flag.ExitOnError) cfgFile := paramConfig(fs) + ds := paramDataSpaceId(fs) srtaAccountId := paramSrtaAccountId(fs) grantIndex := paramGrantIndex(fs) @@ -33,6 +35,12 @@ func RunGrantDelete(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() @@ -54,6 +62,7 @@ func RunGrantDelete(args ...string) error { grantDeleteParams := grantDeleteParams{ srtaAccountId: uint32(*srtaAccountId), grantIndex: *grantIndex, + ds: *ds, saasHttp: &saashttp.SaasClient{ Client: &http.Client{}, ApiUrls: saashttp.InitAPIUrl(&cfg.ApiUrls), @@ -70,6 +79,7 @@ func doGrantDelete(params grantDeleteParams) error { GrantDelete: &saasapi.Grant{ SrtaAccountId: params.srtaAccountId, GrantIndex: params.grantIndex, + DataspaceId: params.ds, }, }, }