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:
Submodule api/contract/openapi updated: d6f9073685...588064fe68
@ -101,6 +101,29 @@ func (c Client) List(ctx context.Context, params *ListParams) error {
|
|||||||
return c.printRemote(printOpts)
|
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 {
|
type printRemoteOpts struct {
|
||||||
remote *api.RemoteConnection
|
remote *api.RemoteConnection
|
||||||
remotes []api.RemoteConnection
|
remotes []api.RemoteConnection
|
||||||
|
@ -92,13 +92,29 @@ func newRemoteCreateCmd() cli.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newRemoteDeleteCmd() cli.Command {
|
func newRemoteDeleteCmd() cli.Command {
|
||||||
|
var remoteID string
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "delete",
|
Name: "delete",
|
||||||
Usage: "Delete an existing remote connection",
|
Usage: "Delete an existing remote connection",
|
||||||
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
Before: middleware.WithBeforeFns(withCli(), withApi(true), middleware.NoArgs),
|
||||||
Flags: commonFlags(),
|
Flags: append(
|
||||||
Action: func(ctx *cli.Context) {
|
commonFlags(),
|
||||||
fmt.Println("remote delete command was called")
|
&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)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user