Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@internxt/sdk",
"author": "Internxt <[email protected]>",
"version": "1.9.22",
"version": "1.9.23",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
65 changes: 65 additions & 0 deletions src/drive/backups/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { HttpClient } from '../../shared/http/client';
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
import { Device, DeviceBackup } from './types';
import { headersWithToken } from '../../shared/headers';
import { DriveFolderData } from '../storage/types';

export class Backups {
private readonly client: HttpClient;
Expand All @@ -18,6 +19,10 @@ export class Backups {
this.apiSecurity = apiSecurity;
}

/**
* @deprecated Use `getBackupDevices` instead.
* This method uses the old drive backend, while `getBackupDevices` uses the new drive backend.
*/
public getAllDevices(): Promise<Device[]> {
return this.client
.get(
Expand All @@ -26,6 +31,42 @@ export class Backups {
);
}

/**
* Retrieves the list of backup devices associated with the user's account.
*
* @returns {Promise<Device[]>} A promise that resolves to an array of Devices.
*/
public getBackupDevices(): Promise<Device[]> {
return this.client
.get(
'/backup/devices',
this.headers()
);
}

/**
* Retrieves a list of all devices represented as folders.
*
* This method sends a GET request to the `/backup/deviceAsFolder` endpoint
* and returns an array of `DriveFolderData` objects, each representing a device
* as a folder in the drive.
*
* @returns {Promise<DriveFolderData[]>} A promise that resolves to an array of DriveFolderData.
*/
public getAllDevicesAsFolder(): Promise<DriveFolderData[]> {
return this.client
.get(
'/backup/deviceAsFolder',
this.headers()
);
}

/**
* Retrieves all backups associated with a specific device identified by its mac ID.
*
* @param mac - The mac ID of the device for which backups are to be retrieved.
* @returns A promise that resolves to an array of DeviceBackups.
*/
public getAllBackups(mac: string): Promise<DeviceBackup[]> {
return this.client
.get(
Expand All @@ -34,6 +75,12 @@ export class Backups {
);
}

/**
* Deletes a backup by its ID.
*
* @param backupId - The unique identifier of the backup to be deleted.
* @returns A promise that resolves when the backup is successfully deleted.
*/
public deleteBackup(backupId: number): Promise<void> {
return this.client
.delete(
Expand All @@ -42,6 +89,10 @@ export class Backups {
);
}

/**
* @deprecated Use `deleteBackupDevice` instead.
* This method uses the old drive backend, while `deleteBackupDevice` uses the new drive backend.
*/
public deleteDevice(deviceId: number): Promise<void> {
return this.client
.delete(
Expand All @@ -50,6 +101,20 @@ export class Backups {
);
}

/**
* Deletes a backup device by its ID.
*
* @param deviceId - The unique identifier of the device to be deleted.
* @returns A promise that resolves when the device is successfully deleted.
*/
public deleteBackupDevice(deviceId: number): Promise<void> {
return this.client
.delete(
`/backup/devices/${deviceId}`,
this.headers()
);
}

/**
* Returns the needed headers for the module requests
* @private
Expand Down
1 change: 1 addition & 0 deletions src/drive/storage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface DriveFolderData {
icon_id: number | null;
name: string;
plain_name: string;
plainName?: string | null;
parentId: number | null;
parent_id: number | null;
parentUuid: string;
Expand Down