|
|
|
import {processesSchema} from "./schemas/processes";
|
|
|
|
import {ProcessesResponseInterface} from "./responses/processes";
|
|
|
|
import {SchemaClient} from "../schema-client";
|
|
|
|
import {GetProcessesRequest} from "./requests/get-processes";
|
|
|
|
import {PaginationRequest} from "./requests/pagination";
|
|
|
|
import {ResponseInterface} from "./responses/response";
|
|
|
|
import {CommandResponseInterface} from "./responses/comamnds";
|
|
|
|
import commandsSchema from "./schemas/commands";
|
|
|
|
import runCommandsSchema from "./schemas/run-commands";
|
|
|
|
import {RepeatProcessRequest} from "./requests/repeat-process";
|
|
|
|
import repeatProcessSchema from "./schemas/repeat-process";
|
|
|
|
import processOutputSchema from "./schemas/process-output";
|
|
|
|
import {ProcessOutputRequest} from "./requests/process-ouput";
|
|
|
|
|
|
|
|
export class SMClient {
|
|
|
|
schemaClient: SchemaClient
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
this.schemaClient = new SchemaClient({
|
|
|
|
baseUrl: 'http://fmw.sipachev.sv'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
async getCommands(): Promise<ResponseInterface> {
|
|
|
|
let { responseData, headers } = await this.schemaClient.send(commandsSchema, {})
|
|
|
|
return {
|
|
|
|
data: responseData as CommandResponseInterface[],
|
|
|
|
headers: headers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async runCommand(data: any): Promise<ResponseInterface> {
|
|
|
|
let { headers } = await this.schemaClient.send(runCommandsSchema, data)
|
|
|
|
return {
|
|
|
|
data: null,
|
|
|
|
headers: headers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async getProcesses(data: GetProcessesRequest | PaginationRequest): Promise<ResponseInterface> {
|
|
|
|
let { responseData, headers } = await this.schemaClient.send(processesSchema, data)
|
|
|
|
return {
|
|
|
|
data: responseData as ProcessesResponseInterface[],
|
|
|
|
headers: headers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async repeatProcess(data: RepeatProcessRequest): Promise<ResponseInterface> {
|
|
|
|
let { responseData, headers } = await this.schemaClient.send(repeatProcessSchema, data)
|
|
|
|
return {
|
|
|
|
data: responseData as ProcessesResponseInterface[],
|
|
|
|
headers: headers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async getProcessOutput(data: ProcessOutputRequest): Promise<ResponseInterface> {
|
|
|
|
let { responseData, headers } = await this.schemaClient.send(processOutputSchema, data)
|
|
|
|
return {
|
|
|
|
data: responseData,
|
|
|
|
headers: headers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export let smClient = new SMClient
|
|
|
|
export default smClient
|