支持ds重置(当前限geo)
This commit is contained in:
@@ -94,7 +94,7 @@ func RunExpGet(args ...string) error {
|
||||
groupBySlice = strings.Split(*groupBy, ",")
|
||||
for _, group := range groupBySlice {
|
||||
if !validGroupBy[group] {
|
||||
return fmt.Errorf("Group by error. group:", group)
|
||||
return fmt.Errorf("Group by error. group: %v", group)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ Commands:
|
||||
write Write user's 'bytes / uint32s / flags'
|
||||
read Read user's 'bytes / uint32s / flags'
|
||||
columnwrite Write columns for 'deviceid / openid' users
|
||||
resetds Reset data space
|
||||
|
||||
convert Convert data to write format
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ func Run(args ...string) error {
|
||||
return RunRead(args...)
|
||||
case "columnwrite":
|
||||
return RunColumnWrite(args...)
|
||||
case "resetds":
|
||||
return RunResetDs(args...)
|
||||
case "convert":
|
||||
return RunConvert(args...)
|
||||
case "verify":
|
||||
|
||||
71
cmd/saastool/resetds.go
Normal file
71
cmd/saastool/resetds.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"git.algo.com.cn/public/saasapi"
|
||||
"git.algo.com.cn/public/saasapi/pkg/saashttp"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
type resetDsParams struct {
|
||||
ds string
|
||||
saasHttp *saashttp.SaasClient
|
||||
}
|
||||
|
||||
func RunResetDs(args ...string) error {
|
||||
fs := flag.NewFlagSet("resetds", flag.ExitOnError)
|
||||
cfgFile := paramConfig(fs)
|
||||
ds := paramDataSpaceId(fs)
|
||||
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return fmt.Errorf("Command line parse error: %w", err)
|
||||
}
|
||||
|
||||
if fs.NArg() > 0 || len(*ds) == 0 {
|
||||
fs.PrintDefaults()
|
||||
return nil
|
||||
}
|
||||
|
||||
cfg, err := LoadConfigFile(*cfgFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("LoadConfigFile error: %w", err)
|
||||
}
|
||||
|
||||
resetDsParams := resetDsParams{
|
||||
ds: *ds,
|
||||
saasHttp: &saashttp.SaasClient{
|
||||
Client: &http.Client{},
|
||||
ApiUrls: saashttp.InitAPIUrl(&cfg.ApiUrls),
|
||||
Auth: &cfg.Auth,
|
||||
},
|
||||
}
|
||||
|
||||
return doResetDs(resetDsParams)
|
||||
}
|
||||
|
||||
func doResetDs(resetDsParams resetDsParams) error {
|
||||
saasReq := &saasapi.SaasReq{
|
||||
Cmd: &saasapi.SaasReq_ResetDs{
|
||||
ResetDs: &saasapi.ResetDs{
|
||||
DataspaceId: resetDsParams.ds,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
res, err := resetDsParams.saasHttp.ResetDS(saasReq)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Submit Command error: %w", err)
|
||||
}
|
||||
|
||||
if res.Code != saasapi.ErrorCode_SUCC {
|
||||
return fmt.Errorf("Command failed. code:%v, status:%v", res.Code, res.Status)
|
||||
}
|
||||
|
||||
resetRes := res.GetResetDsRes()
|
||||
|
||||
fmt.Printf("ResetDS res: %v\n", protojson.Format(resetRes))
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user