44 lines
907 B
Go
44 lines
907 B
Go
/*
|
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
*/
|
|
package account
|
|
|
|
import (
|
|
"context"
|
|
|
|
"mbase/pkg/client"
|
|
"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
|
|
res := ListAccountsResult{}
|
|
|
|
grpcConn, cli, err := client.NewClient(&util.access)
|
|
if err != nil {
|
|
return res, err
|
|
}
|
|
defer grpcConn.Close()
|
|
operParams := &mbctl.ListAccountsParams{}
|
|
ctx := context.Background()
|
|
operRes, err := cli.ListAccounts(ctx, operParams)
|
|
if err != nil {
|
|
return res, err
|
|
}
|
|
res.Accounts = operRes.Accounts
|
|
return res, err
|
|
}
|