working commit
This commit is contained in:
+31
-1
@@ -151,7 +151,7 @@ func (cli *Client) UpdateAccount(ctx context.Context, hosturi, id, username, new
|
|||||||
return err
|
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
|
var err error
|
||||||
|
|
||||||
apipath, err := setApiPath(hosturi, "/v3/api/account/delete")
|
apipath, err := setApiPath(hosturi, "/v3/api/account/delete")
|
||||||
@@ -160,6 +160,36 @@ func (cli *Client) DeleteAccount(ctx context.Context, hosturi, id, username stri
|
|||||||
}
|
}
|
||||||
operParams := operator.DeleteAccountParams{
|
operParams := operator.DeleteAccountParams{
|
||||||
Username: username,
|
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")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
operParams := operator.DeleteAccountParams{
|
||||||
AccountID: id,
|
AccountID: id,
|
||||||
}
|
}
|
||||||
paramsJson, err := json.Marshal(operParams)
|
paramsJson, err := json.Marshal(operParams)
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ func TestAccountLife(t *testing.T) {
|
|||||||
fmt.Printf("accounts:\n%s\n", string(accountsYAML))
|
fmt.Printf("accounts:\n%s\n", string(accountsYAML))
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// DeleteAccount
|
// DeleteAccount
|
||||||
@@ -124,21 +123,8 @@ func TestAccountLife(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
ctx, _ = context.WithTimeout(ctx, 1*time.Second)
|
||||||
|
|
||||||
err = cli.DeleteAccount(ctx, srvaddr+"/foo.bin")
|
err = cli.DeleteAccountByID(ctx, srvaddr, accountID)
|
||||||
require.NoError(t, err)
|
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