Skip to content

Commit

Permalink
feat(cli): delete external integrations
Browse files Browse the repository at this point in the history
This commit is enabling the `lacework integration delete` command, you
can now delete external integrations by providing its integration GUID,
to find the list of integration configured on your Lacework account use
the command:

```
$ lacework int list
```

Signed-off-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
afiune committed Apr 30, 2020
1 parent d311ed4 commit fe802b4
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions cli/cmd/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,35 @@ var (

// integrationDeleteCmd represents the delete sub-command inside the integration command
integrationDeleteCmd = &cobra.Command{
Use: "delete",
Hidden: true,
Short: "delete an external integrations",
Args: cobra.NoArgs,
RunE: func(_ *cobra.Command, _ []string) error {
Use: "delete <int_guid>",
Short: "delete an external integrations",
Long: `Delete an external integration by providing its integration GUID, to find the
list of integration configured on your Lacework account use the command:
$ lacework int list`,
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
lacework, err := api.NewClient(cli.Account,
api.WithLogLevel(cli.LogLevel),
api.WithApiKeys(cli.KeyID, cli.Secret),
)
if err != nil {
return errors.Wrap(err, "unable to generate api client")
}

cli.Log.Info("deleting integration", "int_guid", args[0])
cli.StartProgress(" Deleting integration...")
response, err := lacework.Integrations.Delete(args[0])
cli.StopProgress()
if err != nil {
return errors.Wrap(err, "unable to delete integration")
}

if cli.JSONOutput() {
return cli.OutputJSON(response.Data)
}

cli.OutputHuman("The integration %s was deleted.\n", args[0])
return nil
},
}
Expand Down

0 comments on commit fe802b4

Please sign in to comment.