feat: added functionality for remote delete
command (#283)
* feat: added functionality for remote delete command * chore: pulled recent openapi changes and ran make fmt
This commit is contained in:
parent
d0640ad6c4
commit
b7627a33c8
@ -1 +1 @@
|
||||
Subproject commit d6f9073685dfb58e36f20c2ed351cf872ad31a86
|
||||
Subproject commit 588064fe68e7dfeebd019695aa805832632cbfb6
|
@ -101,6 +101,29 @@ func (c Client) List(ctx context.Context, params *ListParams) error {
|
||||
return c.printRemote(printOpts)
|
||||
}
|
||||
|
||||
func (c Client) Delete(ctx context.Context, remoteID string) error {
|
||||
connection, err := c.GetRemoteConnectionByID(ctx, remoteID).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete remote connection %q: %w", remoteID, err)
|
||||
}
|
||||
|
||||
req := c.DeleteRemoteConnectionByID(ctx, remoteID)
|
||||
|
||||
// send delete request
|
||||
err = req.Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete remote connection %q: %w", remoteID, err)
|
||||
}
|
||||
|
||||
// print deleted connection info
|
||||
printOpts := printRemoteOpts{
|
||||
remote: &connection,
|
||||
deleted: true,
|
||||
}
|
||||
|
||||
return c.printRemote(printOpts)
|
||||
}
|
||||
|
||||
type printRemoteOpts struct {
|
||||
remote *api.RemoteConnection
|
||||
remotes []api.RemoteConnection
|
||||
|
@ -92,13 +92,29 @@ func newRemoteCreateCmd() cli.Command {
|
||||
}
|
||||
|
||||
func newRemoteDeleteCmd() cli.Command {
|
||||
var remoteID string
|
||||
return cli.Command{
|
||||
Name: "delete",
|
||||
Usage: "Delete an existing remote connection",
|
||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||
Flags: commonFlags(),
|
||||
Action: func(ctx *cli.Context) {
|
||||
fmt.Println("remote delete command was called")
|
||||
Flags: append(
|
||||
commonFlags(),
|
||||
&cli.StringFlag{
|
||||
Name: "remote-id, id",
|
||||
Usage: "ID of the remote connection to be deleted",
|
||||
Required: true,
|
||||
Destination: &remoteID,
|
||||
},
|
||||
),
|
||||
Action: func(ctx *cli.Context) error {
|
||||
api := getAPI(ctx)
|
||||
|
||||
client := remote.Client{
|
||||
CLI: getCLI(ctx),
|
||||
RemoteConnectionsApi: api.RemoteConnectionsApi,
|
||||
}
|
||||
|
||||
return client.Delete(getContext(ctx), remoteID)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user