Skip to content

Commit f315ba8

Browse files
committed
feat: add return fields for list backups and support ordering
1 parent cef88c5 commit f315ba8

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/backup/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import BackupRestorer from './backupRestorer.js';
77
export type Backend = 'filesystem' | 's3' | 'gcs' | 'azure';
88
export type BackupStatus = 'STARTED' | 'TRANSFERRING' | 'TRANSFERRED' | 'SUCCESS' | 'FAILED';
99
export type BackupCompressionLevel = 'DefaultCompression' | 'BestSpeed' | 'BestCompression';
10+
export type BackupListOrder = 'asc' | 'desc';
1011

1112
export interface Backup {
1213
creator: () => BackupCreator;

src/collections/backup/client.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
Backend,
33
BackupCreateStatusGetter,
44
BackupCreator,
5+
BackupListOrder,
56
BackupRestoreStatusGetter,
67
BackupRestorer,
78
} from '../../backup/index.js';
@@ -205,8 +206,12 @@ export const backup = (connection: Connection): Backup => {
205206
}
206207
: parseResponse(res);
207208
},
208-
list: (backend: Backend): Promise<BackupReturn[]> => {
209-
return connection.get<BackupReturn[]>(`/backups/${backend}`);
209+
list: (backend: Backend, order?: BackupListOrder): Promise<BackupReturn[]> => {
210+
let url = `/backups/${backend}`;
211+
if (order) {
212+
url += `?order=${order}`;
213+
}
214+
return connection.get<BackupReturn[]>(url);
210215
},
211216
};
212217
};
@@ -261,7 +266,8 @@ export interface Backup {
261266
/** List existing backups (completed and in-progress) created in a given backend.
262267
*
263268
* @param {Backend} backend Backend whence to list backups.
269+
* @param {BackupListOrder} [order] Order in which to list backups.
264270
* @returns {Promise<BackupReturn[]>} The response from Weaviate.
265271
* */
266-
list(backend: Backend): Promise<BackupReturn[]>;
272+
list(backend: Backend, order?: BackupListOrder): Promise<BackupReturn[]>;
267273
}

src/collections/backup/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export type BackupReturn = BackupStatusReturn & {
2121
backend: Backend;
2222
/** The collections that were included in the backup */
2323
collections: string[];
24+
/** Timestamp when the backup process started */
25+
startedAt?: Date;
26+
/** Timestamp when the backup process completed (successfully or with failure) */
27+
completedAt?: Date;
28+
/** Size of the backup in Gibs */
29+
size?: number;
2430
};
2531

2632
/** Configuration options available when creating a backup */

0 commit comments

Comments
 (0)