package account import ( "context" "net/http" "repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators" ) // DeleteRequest struct to delete account type DeleteRequest struct { // ID of account to delete // Required: true AccountID uint64 `url:"accountId" json:"accountId" validate:"required"` // Whether to completely delete the account // Required: false Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"` // Name of account // Required: false Name string `url:"name,omitempty" json:"name,omitempty"` } type wrapperDeleteRequest struct { DeleteRequest AsyncMode bool `url:"async_mode" json:"async_mode"` } // Delete deletes an account from the system func (a Account) Delete(ctx context.Context, req DeleteRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/account/delete" reqWrapped := wrapperDeleteRequest{ DeleteRequest: req, AsyncMode: false, } result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) if err != nil { return "", err } return string(result), nil } // DeleteAsync deletes an account from the system in async mode func (a Account) DeleteAsync(ctx context.Context, req DeleteRequest) (string, error) { err := validators.ValidateRequest(req) if err != nil { return "", validators.ValidationErrors(validators.GetErrors(err)) } url := "/cloudbroker/account/delete" reqWrapped := wrapperDeleteRequest{ DeleteRequest: req, AsyncMode: true, } res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped) if err != nil { return "", err } return string(res), nil }