package delete import ( "context" "github.com/peterbourgon/ff/v3" "edge-infra.dev/pkg/edge/api/graph/model" "edge-infra.dev/pkg/edge/edgeadmin/commands/operatorintervention/edgeextension" "edge-infra.dev/pkg/edge/edgecli" "edge-infra.dev/pkg/edge/edgecli/flagutil" "edge-infra.dev/pkg/lib/cli/command" "edge-infra.dev/pkg/lib/cli/rags" ) var deleteCommandLongHelp = ` This edgeadmin command can be used to delete a single OI command from the database. The --command flag is required and the value should be set to the command to be removed. Example Usage: $ edgeadmin operatorintervention delete command --command ls ` func NewDeleteCommand(cfg *edgecli.Config) *command.Command { var ( edge = &edgeextension.Ext{Cfg: cfg} ) var cmd *command.Command cmd = &command.Command{ ShortUsage: "edgeadmin operatorintervention delete command", ShortHelp: "Deletes a single command from the database", LongHelp: deleteCommandLongHelp, Options: []ff.Option{}, Flags: []*rags.Rag{ { Name: flagutil.OICommand, Usage: "command to be removed", Value: &rags.String{}, Required: true, }, }, Extensions: []command.Extension{ edge, }, Exec: func(ctx context.Context, _ []string) error { var mutation struct { DeleteOperatorInterventionCommand struct { model.DeleteOperatorInterventionCommandResponse } `graphql:"deleteOperatorInterventionCommand(command: $command)"` } var variables = map[string]interface{}{ "command": model.OperatorInterventionCommandInput{ Name: flagutil.GetStringFlag(cmd.Rags, flagutil.OICommand), }, } err := edge.Client.Mutate(ctx, &mutation, variables) if err != nil { return err } return handleResponseFormatting( "Command", mutation.DeleteOperatorInterventionCommand.Errors, ) }, } return cmd }