36 lines
791 B
Go
36 lines
791 B
Go
/*
|
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
*/
|
|
package account
|
|
|
|
import (
|
|
"context"
|
|
|
|
"mbase/pkg/mbctl"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func (util *Util) ListAccounts(cmd *cobra.Command, args []string) {
|
|
res, err := util.listAccounts(&util.listAccountsParams)
|
|
printResponse(res, err)
|
|
}
|
|
|
|
type ListAccountsParams struct{}
|
|
type ListAccountsResult struct {
|
|
Accounts []*mbctl.AccountShortDescr `json:"accounts"`
|
|
}
|
|
|
|
func (util *Util) listAccounts(params *ListAccountsParams) (*ListAccountsResult, error) {
|
|
var err error
|
|
ctx := context.Background()
|
|
res := &ListAccountsResult{}
|
|
operParams := &mbctl.ListAccountsParams{}
|
|
operRes, err := util.oper.ListAccounts(ctx, util.operID, operParams)
|
|
if err != nil {
|
|
return res, err
|
|
}
|
|
res.Accounts = operRes.Accounts
|
|
return res, err
|
|
}
|