-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #309 from bevzzz/feature/backup_cancel
gh-297: support cancellation for backups
- Loading branch information
Showing
7 changed files
with
163 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/io/weaviate/client/v1/backup/api/BackupCanceler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.weaviate.client.v1.backup.api; | ||
|
||
import io.weaviate.client.Config; | ||
import io.weaviate.client.base.BaseClient; | ||
import io.weaviate.client.base.ClientResult; | ||
import io.weaviate.client.base.Response; | ||
import io.weaviate.client.base.Result; | ||
import io.weaviate.client.base.http.HttpClient; | ||
|
||
/** | ||
* BackupCanceler can cancel an in-progress backup by ID. | ||
* | ||
* <p> | ||
* Canceling backups which have successfully completed before being interrupted is not supported and will result in an error. | ||
*/ | ||
public class BackupCanceler extends BaseClient<Void> implements ClientResult<Void> { | ||
private String backend; | ||
private String backupId; | ||
|
||
public BackupCanceler(HttpClient client, Config config) { | ||
super(client, config); | ||
} | ||
|
||
public BackupCanceler withBackend(String backend) { | ||
this.backend = backend; | ||
return this; | ||
} | ||
|
||
public BackupCanceler withBackupId(String backupId) { | ||
this.backupId = backupId; | ||
return this; | ||
} | ||
|
||
@Override | ||
public Result<Void> run() { | ||
Response<Void> result = sendDeleteRequest(path(), null, Void.class); | ||
return new Result<>(result); | ||
} | ||
|
||
private String path() { | ||
return String.format("/backups/%s/%s", backend, backupId); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.