140 lines
3.6 KiB
TypeScript
Executable File
140 lines
3.6 KiB
TypeScript
Executable File
export namespace config {
|
|
|
|
export class Config {
|
|
s3Bucket: string;
|
|
localDest: string;
|
|
awsProfile: string;
|
|
concurrency: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new Config(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.s3Bucket = source["s3Bucket"];
|
|
this.localDest = source["localDest"];
|
|
this.awsProfile = source["awsProfile"];
|
|
this.concurrency = source["concurrency"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export namespace detect {
|
|
|
|
export class SDCard {
|
|
mountpoint: string;
|
|
label: string;
|
|
device: string;
|
|
fstype: string;
|
|
totalBytes: number;
|
|
freeBytes: number;
|
|
mediaFiles: string[];
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SDCard(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.mountpoint = source["mountpoint"];
|
|
this.label = source["label"];
|
|
this.device = source["device"];
|
|
this.fstype = source["fstype"];
|
|
this.totalBytes = source["totalBytes"];
|
|
this.freeBytes = source["freeBytes"];
|
|
this.mediaFiles = source["mediaFiles"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export namespace main {
|
|
|
|
export class SlotPayload {
|
|
slot: string;
|
|
mountpoint: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SlotPayload(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.slot = source["slot"];
|
|
this.mountpoint = source["mountpoint"];
|
|
}
|
|
}
|
|
export class SlotState {
|
|
slot: string;
|
|
mountpoint: string;
|
|
label: string;
|
|
status: string;
|
|
filesTotal: number;
|
|
filesDone: number;
|
|
bytesTotal: number;
|
|
bytesDone: number;
|
|
speedMBs: number;
|
|
error?: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SlotState(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.slot = source["slot"];
|
|
this.mountpoint = source["mountpoint"];
|
|
this.label = source["label"];
|
|
this.status = source["status"];
|
|
this.filesTotal = source["filesTotal"];
|
|
this.filesDone = source["filesDone"];
|
|
this.bytesTotal = source["bytesTotal"];
|
|
this.bytesDone = source["bytesDone"];
|
|
this.speedMBs = source["speedMBs"];
|
|
this.error = source["error"];
|
|
}
|
|
}
|
|
export class Snapshot {
|
|
sessionID: string;
|
|
slots: SlotState[];
|
|
running: boolean;
|
|
dryRun: boolean;
|
|
config: config.Config;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new Snapshot(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.sessionID = source["sessionID"];
|
|
this.slots = this.convertValues(source["slots"], SlotState);
|
|
this.running = source["running"];
|
|
this.dryRun = source["dryRun"];
|
|
this.config = this.convertValues(source["config"], config.Config);
|
|
}
|
|
|
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
|
if (!a) {
|
|
return a;
|
|
}
|
|
if (a.slice && a.map) {
|
|
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
|
} else if ("object" === typeof a) {
|
|
if (asMap) {
|
|
for (const key of Object.keys(a)) {
|
|
a[key] = new classs(a[key]);
|
|
}
|
|
return a;
|
|
}
|
|
return new classs(a);
|
|
}
|
|
return a;
|
|
}
|
|
}
|
|
|
|
}
|
|
|