|
|
|
@ -17,17 +17,11 @@ import stopProcessSchema from "./schemas/stop-process"; |
|
|
|
|
import killProcessSchema from "./schemas/kill-process"; |
|
|
|
|
import commandSchema from "./schemas/command"; |
|
|
|
|
|
|
|
|
|
export class SMClient { |
|
|
|
|
schemaClient: SchemaClient |
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
|
this.schemaClient = new SchemaClient({ |
|
|
|
|
baseUrl: 'http://fmw.sipachev.sv' |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
export class SMClient extends SchemaClient { |
|
|
|
|
baseUrl = 'http://fmw.sipachev.sv' |
|
|
|
|
|
|
|
|
|
async getCommands(): Promise<ResponseInterface<CommandResponseInterface[]>> { |
|
|
|
|
let { responseData, headers } = await this.schemaClient.send(commandsSchema, {}) |
|
|
|
|
let { responseData, headers } = await this.send(commandsSchema, {}) |
|
|
|
|
return { |
|
|
|
|
data: responseData, |
|
|
|
|
headers: headers |
|
|
|
@ -35,7 +29,7 @@ export class SMClient { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getCommand(name: string): Promise<ResponseInterface<CommandResponseInterface>> { |
|
|
|
|
let { responseData, headers } = await this.schemaClient.send(commandSchema, { |
|
|
|
|
let { responseData, headers } = await this.send(commandSchema, { |
|
|
|
|
commandName: name |
|
|
|
|
}) |
|
|
|
|
return { |
|
|
|
@ -45,7 +39,7 @@ export class SMClient { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async runCommand(data: any): Promise<ResponseInterface> { |
|
|
|
|
let { headers } = await this.schemaClient.send(runCommandsSchema, data) |
|
|
|
|
let { headers } = await this.send(runCommandsSchema, data) |
|
|
|
|
return { |
|
|
|
|
data: null, |
|
|
|
|
headers: headers |
|
|
|
@ -53,7 +47,7 @@ export class SMClient { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getProcesses(data: GetProcessesRequest | PaginationRequest): Promise<ResponseInterface<ProcessesResponseInterface[]>> { |
|
|
|
|
let { responseData, headers } = await this.schemaClient.send(processesSchema, data) |
|
|
|
|
let { responseData, headers } = await this.send(processesSchema, data) |
|
|
|
|
return { |
|
|
|
|
data: responseData, |
|
|
|
|
headers: headers |
|
|
|
@ -61,7 +55,7 @@ export class SMClient { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async repeatProcess(data: RepeatProcessRequest): Promise<ResponseInterface> { |
|
|
|
|
let { responseData, headers } = await this.schemaClient.send(repeatProcessSchema, data) |
|
|
|
|
let { responseData, headers } = await this.send(repeatProcessSchema, data) |
|
|
|
|
return { |
|
|
|
|
data: responseData as ProcessesResponseInterface[], |
|
|
|
|
headers: headers |
|
|
|
@ -69,7 +63,7 @@ export class SMClient { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getProcessOutput(data: ProcessOutputRequest): Promise<ResponseInterface> { |
|
|
|
|
let { responseData, headers } = await this.schemaClient.send(processOutputSchema, data) |
|
|
|
|
let { responseData, headers } = await this.send(processOutputSchema, data) |
|
|
|
|
return { |
|
|
|
|
data: responseData, |
|
|
|
|
headers: headers |
|
|
|
@ -77,7 +71,7 @@ export class SMClient { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async playProcess(id: string): Promise<ResponseInterface> { |
|
|
|
|
let { headers } = await this.schemaClient.send(playProcessSchema, {id}) |
|
|
|
|
let { headers } = await this.send(playProcessSchema, {id}) |
|
|
|
|
return { |
|
|
|
|
data: null, |
|
|
|
|
headers: headers |
|
|
|
@ -85,7 +79,7 @@ export class SMClient { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async pauseProcess(id: string): Promise<ResponseInterface> { |
|
|
|
|
let { headers } = await this.schemaClient.send(pauseProcessSchema, {id}) |
|
|
|
|
let { headers } = await this.send(pauseProcessSchema, {id}) |
|
|
|
|
return { |
|
|
|
|
data: null, |
|
|
|
|
headers: headers |
|
|
|
@ -93,7 +87,7 @@ export class SMClient { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async stopProcess(id: string): Promise<ResponseInterface> { |
|
|
|
|
let { headers } = await this.schemaClient.send(stopProcessSchema, {id}) |
|
|
|
|
let { headers } = await this.send(stopProcessSchema, {id}) |
|
|
|
|
return { |
|
|
|
|
data: null, |
|
|
|
|
headers: headers |
|
|
|
@ -101,7 +95,7 @@ export class SMClient { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async killProcess(id: string): Promise<ResponseInterface> { |
|
|
|
|
let { headers } = await this.schemaClient.send(killProcessSchema, {id}) |
|
|
|
|
let { headers } = await this.send(killProcessSchema, {id}) |
|
|
|
|
return { |
|
|
|
|
data: null, |
|
|
|
|
headers: headers |
|
|
|
|