feat: added functionality for replication update
command (#299)
* feat: added functionality for replication update command * refactor: changed replication update usage text for clarity * fix: added closing bracket back in * chore: ran make fmt
This commit is contained in:
@ -104,6 +104,48 @@ func (c Client) List(ctx context.Context, params *ListParams) error {
|
||||
return c.printReplication(printOpts)
|
||||
}
|
||||
|
||||
type UpdateParams struct {
|
||||
ReplicationID string
|
||||
Name string
|
||||
Description string
|
||||
RemoteID string
|
||||
RemoteBucketID string
|
||||
MaxQueueSize int64
|
||||
}
|
||||
|
||||
func (c Client) Update(ctx context.Context, params *UpdateParams) error {
|
||||
// build request
|
||||
body := api.ReplicationUpdateRequest{}
|
||||
|
||||
if params.Name != "" {
|
||||
body.SetName(params.Name)
|
||||
}
|
||||
|
||||
if params.Description != "" {
|
||||
body.SetDescription(params.Description)
|
||||
}
|
||||
|
||||
if params.RemoteID != "" {
|
||||
body.SetRemoteID(params.RemoteID)
|
||||
}
|
||||
|
||||
if params.RemoteBucketID != "" {
|
||||
body.SetRemoteBucketID(params.RemoteBucketID)
|
||||
}
|
||||
|
||||
if params.MaxQueueSize != 0 {
|
||||
body.SetMaxQueueSizeBytes(params.MaxQueueSize)
|
||||
}
|
||||
|
||||
// send patch request
|
||||
res, err := c.PatchReplicationByID(ctx, params.ReplicationID).ReplicationUpdateRequest(body).Execute()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update replication stream %q: %w", params.ReplicationID, err)
|
||||
}
|
||||
// print updated replication stream info
|
||||
return c.printReplication(printReplicationOpts{replication: &res})
|
||||
}
|
||||
|
||||
func (c Client) Delete(ctx context.Context, replicationID string) error {
|
||||
// get replication stream via ID
|
||||
connection, err := c.GetReplicationByID(ctx, replicationID).Execute()
|
||||
|
Reference in New Issue
Block a user