107 lines
2.8 KiB
TypeScript
107 lines
2.8 KiB
TypeScript
export namespace main {
|
|
|
|
export class SSLConfig {
|
|
privateKey: string;
|
|
publicKey: string;
|
|
certificateAuthority: string;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SSLConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.privateKey = source["privateKey"];
|
|
this.publicKey = source["publicKey"];
|
|
this.certificateAuthority = source["certificateAuthority"];
|
|
}
|
|
}
|
|
export class SSHConfig {
|
|
host: string;
|
|
port: number;
|
|
username: string;
|
|
password: string;
|
|
privateKey: string;
|
|
overtime: number;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new SSHConfig(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.host = source["host"];
|
|
this.port = source["port"];
|
|
this.username = source["username"];
|
|
this.password = source["password"];
|
|
this.privateKey = source["privateKey"];
|
|
this.overtime = source["overtime"];
|
|
}
|
|
}
|
|
export class RedisConnect {
|
|
id: string;
|
|
name: string;
|
|
address: string;
|
|
port: string;
|
|
auth: string;
|
|
username: string;
|
|
splitChart: string;
|
|
readOnly: boolean;
|
|
sshConfig?: SSHConfig;
|
|
sslConfig?: SSLConfig;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new RedisConnect(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.id = source["id"];
|
|
this.name = source["name"];
|
|
this.address = source["address"];
|
|
this.port = source["port"];
|
|
this.auth = source["auth"];
|
|
this.username = source["username"];
|
|
this.splitChart = source["splitChart"];
|
|
this.readOnly = source["readOnly"];
|
|
this.sshConfig = this.convertValues(source["sshConfig"], SSHConfig);
|
|
this.sslConfig = this.convertValues(source["sslConfig"], SSLConfig);
|
|
}
|
|
|
|
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
|
if (!a) {
|
|
return a;
|
|
}
|
|
if (a.slice) {
|
|
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;
|
|
}
|
|
}
|
|
export class Result {
|
|
msg: string;
|
|
data: any;
|
|
|
|
static createFrom(source: any = {}) {
|
|
return new Result(source);
|
|
}
|
|
|
|
constructor(source: any = {}) {
|
|
if ('string' === typeof source) source = JSON.parse(source);
|
|
this.msg = source["msg"];
|
|
this.data = source["data"];
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|