You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.2 KiB
122 lines
4.2 KiB
import {processesSchema} from "./schemas/processes";
|
|
import {ProcessInterface} 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 {CommandInterface} from "./responses/comamnds";
|
|
import commandsSchema from "./schemas/commands";
|
|
import runCommandsSchema from "./schemas/run-commands";
|
|
import {RepeatProcessRequest} from "./requests/repeat-process";
|
|
import {ApproveProcessRequest} from "./requests/approve-process";
|
|
import repeatProcessSchema from "./schemas/repeat-process";
|
|
import approveProcessSchema from "./schemas/approve-process";
|
|
import processOutputSchema from "./schemas/process-output";
|
|
import {ProcessOutputRequest} from "./requests/process-ouput";
|
|
import playProcessSchema from "./schemas/play-process";
|
|
import pauseProcessSchema from "./schemas/pause-process";
|
|
import stopProcessSchema from "./schemas/stop-process";
|
|
import killProcessSchema from "./schemas/kill-process";
|
|
import commandSchema from "./schemas/command";
|
|
import {UnlockProcessRequest} from "./requests/unlock-process";
|
|
import unlockProcessSchema from "./schemas/unlock-process";
|
|
|
|
export class SMClient extends SchemaClient {
|
|
async getCommands(): Promise<ResponseInterface<CommandInterface[]>> {
|
|
let { responseData, headers } = await this.send(commandsSchema, {})
|
|
return {
|
|
data: responseData,
|
|
headers: headers
|
|
}
|
|
}
|
|
|
|
async getCommand(name: string): Promise<ResponseInterface<CommandInterface>> {
|
|
let { responseData, headers } = await this.send(commandSchema, {
|
|
commandName: name
|
|
})
|
|
return {
|
|
data: responseData,
|
|
headers: headers
|
|
}
|
|
}
|
|
|
|
async runCommand(data: any): Promise<ResponseInterface> {
|
|
let { headers } = await this.send(runCommandsSchema, data)
|
|
return {
|
|
data: null,
|
|
headers: headers
|
|
}
|
|
}
|
|
|
|
async getProcesses(data: GetProcessesRequest | PaginationRequest): Promise<ResponseInterface<ProcessInterface[]>> {
|
|
let { responseData, headers } = await this.send(processesSchema, data)
|
|
return {
|
|
data: responseData,
|
|
headers: headers
|
|
}
|
|
}
|
|
|
|
async approveProcess(data: ApproveProcessRequest): Promise<ResponseInterface> {
|
|
let { responseData, headers } = await this.send(approveProcessSchema, data)
|
|
return {
|
|
data: responseData as ProcessInterface[],
|
|
headers: headers
|
|
}
|
|
}
|
|
|
|
async unlockProcess(data: UnlockProcessRequest): Promise<ResponseInterface> {
|
|
let { responseData, headers } = await this.send(unlockProcessSchema, data)
|
|
return {
|
|
data: responseData as ProcessInterface[],
|
|
headers: headers
|
|
}
|
|
}
|
|
|
|
async repeatProcess(data: RepeatProcessRequest): Promise<ResponseInterface> {
|
|
let { responseData, headers } = await this.send(repeatProcessSchema, data)
|
|
return {
|
|
data: responseData as ProcessInterface[],
|
|
headers: headers
|
|
}
|
|
}
|
|
|
|
async getProcessOutput(data: ProcessOutputRequest): Promise<ResponseInterface> {
|
|
let { responseData, headers } = await this.send(processOutputSchema, data)
|
|
return {
|
|
data: responseData,
|
|
headers: headers
|
|
}
|
|
}
|
|
|
|
async playProcess(id: string): Promise<ResponseInterface> {
|
|
let { headers } = await this.send(playProcessSchema, {id})
|
|
return {
|
|
data: null,
|
|
headers: headers
|
|
}
|
|
}
|
|
|
|
async pauseProcess(id: string): Promise<ResponseInterface> {
|
|
let { headers } = await this.send(pauseProcessSchema, {id})
|
|
return {
|
|
data: null,
|
|
headers: headers
|
|
}
|
|
}
|
|
|
|
async stopProcess(id: string): Promise<ResponseInterface> {
|
|
let { headers } = await this.send(stopProcessSchema, {id})
|
|
return {
|
|
data: null,
|
|
headers: headers
|
|
}
|
|
}
|
|
|
|
async killProcess(id: string): Promise<ResponseInterface> {
|
|
let { headers } = await this.send(killProcessSchema, {id})
|
|
return {
|
|
data: null,
|
|
headers: headers
|
|
}
|
|
}
|
|
}
|
|
|