44 lines
936 B
Go
44 lines
936 B
Go
/*
|
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
*/
|
|
package grant
|
|
|
|
import (
|
|
"context"
|
|
|
|
"mbase/pkg/mbctl"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func (util *Util) DeleteGrant(cmd *cobra.Command, args []string) {
|
|
util.deleteGrantParams.Username = args[0]
|
|
util.deleteGrantParams.Operation = args[1]
|
|
res, err := util.deleteGrant(&util.deleteGrantParams)
|
|
printResponse(res, err)
|
|
}
|
|
|
|
type DeleteGrantParams struct {
|
|
Username string
|
|
Operation string
|
|
}
|
|
type DeleteGrantResult struct {
|
|
GrantID string `json:"grantId"`
|
|
}
|
|
|
|
func (util *Util) deleteGrant(params *DeleteGrantParams) (*DeleteGrantResult, error) {
|
|
var err error
|
|
res := &DeleteGrantResult{}
|
|
ctx := context.Background()
|
|
operParams := &mbctl.SetGrantParams{
|
|
Username: params.Username,
|
|
Operation: params.Operation,
|
|
}
|
|
operRes, err := util.oper.SetGrant(ctx, util.operID, operParams)
|
|
if err != nil {
|
|
return res, err
|
|
}
|
|
res.GrantID = operRes.GrantID
|
|
return res, err
|
|
}
|