working commit
This commit is contained in:
+32
-2
@@ -151,7 +151,38 @@ func (cli *Client) UpdateAccount(ctx context.Context, hosturi, id, username, new
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) DeleteAccount(ctx context.Context, hosturi, id, username string) error {
|
||||
func (cli *Client) DeleteAccountByName(ctx context.Context, hosturi, username string) error {
|
||||
var err error
|
||||
|
||||
apipath, err := setApiPath(hosturi, "/v3/api/account/delete")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
operParams := operator.DeleteAccountParams{
|
||||
Username: username,
|
||||
}
|
||||
paramsJson, err := json.Marshal(operParams)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
respBytes, err := doHTTPCall(ctx, apipath, paramsJson)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
operRes := handler.NewResponse[operator.DeleteAccountResult]()
|
||||
err = json.Unmarshal(respBytes, operRes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if operRes.Error {
|
||||
err = fmt.Errorf("%s", operRes.Message)
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi, id string) error {
|
||||
var err error
|
||||
|
||||
apipath, err := setApiPath(hosturi, "/v3/api/account/delete")
|
||||
@@ -159,7 +190,6 @@ func (cli *Client) DeleteAccount(ctx context.Context, hosturi, id, username stri
|
||||
return err
|
||||
}
|
||||
operParams := operator.DeleteAccountParams{
|
||||
Username: username,
|
||||
AccountID: id,
|
||||
}
|
||||
paramsJson, err := json.Marshal(operParams)
|
||||
|
||||
@@ -115,30 +115,16 @@ func TestAccountLife(t *testing.T) {
|
||||
fmt.Printf("accounts:\n%s\n", string(accountsYAML))
|
||||
|
||||
}
|
||||
/*
|
||||
|
||||
{
|
||||
// DeleteAccount
|
||||
fmt.Printf("=== DeleteAccount ===\n")
|
||||
cli := NewClient()
|
||||
ctx := context.Background()
|
||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||
{
|
||||
// DeleteAccount
|
||||
fmt.Printf("=== DeleteAccount ===\n")
|
||||
cli := NewClient()
|
||||
ctx := context.Background()
|
||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||
|
||||
err = cli.DeleteAccount(ctx, srvaddr+"/foo.bin")
|
||||
require.NoError(t, err)
|
||||
}
|
||||
err = cli.DeleteAccountByID(ctx, srvaddr, accountID)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
{
|
||||
// !AccountExists
|
||||
fmt.Printf("=== AccountExists ===\n")
|
||||
cli := NewClient()
|
||||
ctx := context.Background()
|
||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||
|
||||
exists, _, err := cli.AccountInfo(ctx, srvaddr+"/foo.bin")
|
||||
require.NoError(t, err)
|
||||
require.False(t, exists)
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user