package apemanager import ( internalclient "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key" commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common" apeCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common/ape" client_sdk "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client" "github.com/spf13/cobra" ) var removeCmd = &cobra.Command{ Use: "remove", Short: "Remove rule chain for a target", Run: remove, PersistentPreRun: func(cmd *cobra.Command, _ []string) { commonflags.Bind(cmd) }, } func remove(cmd *cobra.Command, _ []string) { target := parseTarget(cmd) key := key.Get(cmd) cli := internalclient.GetSDKClientByFlag(cmd, key, commonflags.RPC) chainID := apeCmd.ParseChainID(cmd) chainIDRaw := []byte(chainID) _, err := cli.APEManagerRemoveChain(cmd.Context(), client_sdk.PrmAPEManagerRemoveChain{ ChainTarget: target, ChainID: chainIDRaw, }) commonCmd.ExitOnErr(cmd, "remove chain error: %w", err) cmd.Println("\nRule has been removed.") } func initRemoveCmd() { commonflags.Init(removeCmd) ff := removeCmd.Flags() ff.String(apeCmd.TargetNameFlag, "", apeCmd.TargetNameFlagDesc) ff.String(apeCmd.TargetTypeFlag, "", apeCmd.TargetTypeFlagDesc) _ = removeCmd.MarkFlagRequired(apeCmd.TargetTypeFlag) ff.String(apeCmd.ChainIDFlag, "", apeCmd.ChainIDFlagDesc) _ = removeCmd.MarkFlagRequired(apeCmd.ChainIDFlag) ff.Bool(apeCmd.ChainIDHexFlag, false, apeCmd.ChainIDHexFlagDesc) }