Skip to content

Commit 2657af6

Browse files
committed
feat(backup): support cancelRestore operation
Deprecate WeaviateBackupClient#cancel method, as it is now ambiguous
1 parent fb88139 commit 2657af6

3 files changed

Lines changed: 73 additions & 7 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package io.weaviate.client6.v1.api.backup;
2+
3+
import java.util.Collections;
4+
5+
import io.weaviate.client6.v1.internal.rest.Endpoint;
6+
import io.weaviate.client6.v1.internal.rest.SimpleEndpoint;
7+
8+
public record CancelBackupRestoreRequest(String backupId, String backend) {
9+
10+
public static Endpoint<CancelBackupRestoreRequest, Void> _ENDPOINT = SimpleEndpoint.sideEffect(
11+
request -> "DELETE",
12+
request -> "/backups/" + request.backend + "/" + request.backupId + "/restore",
13+
request -> Collections.emptyMap());
14+
}

src/main/java/io/weaviate/client6/v1/api/backup/WeaviateBackupClient.java

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,49 @@ public List<Backup> list(String backend, Function<ListBackupsRequest.Builder, Ob
179179
/**
180180
* Cancel in-progress backup.
181181
*
182-
* <p>
183-
* This method cannot be called cancel backup restore.
184-
*
185182
* @param backupId Backup ID.
186183
* @param backend Backup storage backend.
187184
* @throws WeaviateApiException in case the server returned with an
188185
* error status code.
189186
* @throws IOException in case the request was not sent successfully
190187
* due to a malformed request, a networking error
191188
* or the server being unavailable.
189+
* @deprecated This method forwards to {@link #cancelCreate}. Prefer using the
190+
* latter, as it is less ambiguous.
192191
*/
192+
@Deprecated
193193
public void cancel(String backupId, String backend) throws IOException {
194+
cancelCreate(backupId, backend);
195+
}
196+
197+
/**
198+
* Cancel in-progress backup creation.
199+
*
200+
* @param backupId Backup ID.
201+
* @param backend Backup storage backend.
202+
* @throws WeaviateApiException in case the server returned with an
203+
* error status code.
204+
* @throws IOException in case the request was not sent successfully
205+
* due to a malformed request, a networking error
206+
* or the server being unavailable.
207+
*/
208+
public void cancelCreate(String backupId, String backend) throws IOException {
194209
this.restTransport.performRequest(new CancelBackupRequest(backupId, backend), CancelBackupRequest._ENDPOINT);
195210
}
211+
212+
/**
213+
* Cancel in-progress backup restore.
214+
*
215+
* @param backupId Backup ID.
216+
* @param backend Backup storage backend.
217+
* @throws WeaviateApiException in case the server returned with an
218+
* error status code.
219+
* @throws IOException in case the request was not sent successfully
220+
* due to a malformed request, a networking error
221+
* or the server being unavailable.
222+
*/
223+
public void cancelRestore(String backupId, String backend) throws IOException {
224+
this.restTransport.performRequest(new CancelBackupRestoreRequest(backupId, backend),
225+
CancelBackupRestoreRequest._ENDPOINT);
226+
}
196227
}

src/main/java/io/weaviate/client6/v1/api/backup/WeaviateBackupClientAsync.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,37 @@ public CompletableFuture<List<Backup>> list(String backend,
124124
}
125125

126126
/**
127-
* Cancel in-progress backup.
128-
*
129-
* <p>
130-
* This method cannot be called cancel backup restore.
127+
* Cancel in-progress backup creation.
131128
*
132129
* @param backupId Backup ID.
133130
* @param backend Backup storage backend.
131+
* @deprecated This method forwards to {@link #cancelCreate}. Prefer using the
132+
* latter, as it is less ambiguous.
134133
*/
134+
@Deprecated
135135
public CompletableFuture<Void> cancel(String backupId, String backend) {
136+
return cancelCreate(backupId, backend);
137+
}
138+
139+
/**
140+
* Cancel in-progress backup creation.
141+
*
142+
* @param backupId Backup ID.
143+
* @param backend Backup storage backend.
144+
*/
145+
public CompletableFuture<Void> cancelCreate(String backupId, String backend) {
136146
return this.restTransport.performRequestAsync(new CancelBackupRequest(backupId, backend),
137147
CancelBackupRequest._ENDPOINT);
138148
}
149+
150+
/**
151+
* Cancel in-progress backup restore.
152+
*
153+
* @param backupId Backup ID.
154+
* @param backend Backup storage backend.
155+
*/
156+
public CompletableFuture<Void> cancelRestore(String backupId, String backend) {
157+
return this.restTransport.performRequestAsync(new CancelBackupRestoreRequest(backupId, backend),
158+
CancelBackupRestoreRequest._ENDPOINT);
159+
}
139160
}

0 commit comments

Comments
 (0)