调整授权功能
This commit is contained in:
@@ -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