feat: added functionality for replication delete command (#298)
* feat: added functionality for replication delete command * refactor: changed naming of remote-id flag to be consistent with other influx commands * refactor: reduced lines of code and improved error message based on code review
This commit is contained in:
@ -104,6 +104,27 @@ func (c Client) List(ctx context.Context, params *ListParams) error {
|
||||
return c.printReplication(printOpts)
|
||||
}
|
||||
|
||||
func (c Client) Delete(ctx context.Context, replicationID string) error {
|
||||
// get replication stream via ID
|
||||
connection, err := c.GetReplicationByID(ctx, replicationID).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not find replication stream with ID %q: %w", replicationID, err)
|
||||
}
|
||||
|
||||
// send delete request
|
||||
if err := c.DeleteReplicationByID(ctx, replicationID).Execute(); err != nil {
|
||||
return fmt.Errorf("failed to delete replication stream %q: %w", replicationID, err)
|
||||
}
|
||||
|
||||
// print deleted replication stream info
|
||||
printOpts := printReplicationOpts{
|
||||
replication: &connection,
|
||||
deleted: true,
|
||||
}
|
||||
|
||||
return c.printReplication(printOpts)
|
||||
}
|
||||
|
||||
type printReplicationOpts struct {
|
||||
replication *api.Replication
|
||||
replications []api.Replication
|
||||
|
Reference in New Issue
Block a user