From 367e6dc782407237315c5b085ed5a851585e08e3 Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Fri, 2 Aug 2024 10:47:16 +0200 Subject: [PATCH] refs #536 add openapi specification --- openapi.yml | 297 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 297 insertions(+) create mode 100644 openapi.yml diff --git a/openapi.yml b/openapi.yml new file mode 100644 index 0000000..315a8df --- /dev/null +++ b/openapi.yml @@ -0,0 +1,297 @@ +openapi: 3.0.3 + +info: + title: OgAgent API + description: OgAgent API + version: 0.0.1 + +paths: + /opengnsys/status: + post: + summary: Get status of the agent + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/StatusReq' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/StatusRes' + + /opengnsys/poweroff: + post: + summary: Power agent off + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmptyObj' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/LaunchedRes' + + /opengnsys/reboot: + post: + summary: Reboot agent + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmptyObj' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/LaunchedRes' + + /opengnsys/script: + post: + summary: Run script on agent + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ScriptReq' + required: true + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ScriptRes' + + /opengnsys/terminatescript: + post: + summary: Terminate running script on agent + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TerminateScriptReq' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/EmptyObj' + + /opengnsys/preparescripts: + post: + summary: Prepare list of scripts running on agent + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmptyObj' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/EmptyObj' + + /opengnsys/getscripts: + post: + summary: Get the list of scripts running on agent + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmptyObj' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/GetScriptsRes' + + /opengnsys/logoff: + post: + summary: Log remote user off + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EmptyObj' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/LogoffRes' + + /opengnsys/popup: + post: + summary: Show message on agent + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Popup' + required: true + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/LaunchedRes' + +components: + schemas: + EmptyObj: + type: object + additionalProperties: false + + Jobid: + type: string + example: + - "deadbeef" + + StatusReq: + type: object + properties: + detail: + type: boolean + + StatusRes: + type: object + required: + - status + properties: + status: + type: string + enum: + - "LNX" + - "OSX" + - "WIN" + loggedin: + type: boolean + session: + type: string + example: + - "x11" + agent_version: + type: string + os_version: + type: string + sys_load: + type: number + + LaunchedRes: + type: object + required: + - op + properties: + op: + type: string + enum: + - "launched" + + ScriptReq: + type: object + required: + - script + properties: + script: + type: string + example: + - "uptime\nwho" + - "Start-Process notepad.exe" + client: + type: boolean + default: false + + ScriptRes: + type: object + required: + - op + properties: + op: + type: string + enum: + - "launched" + jobid: + $ref: '#/components/schemas/Jobid' + + TerminateScriptReq: + type: object + required: + - jobid + properties: + jobid: + $ref: '#/components/schemas/Jobid' + + + RunningScript: + type: object + required: + - jobid + - pid + - starttime + - script + - client + - status + - stdout + - stderr + properties: + jobid: + $ref: '#/components/schemas/Jobid' + pid: + type: integer + starttime: + type: string + example: "2024-12-31 23:59:59.123456+0000" + script: + type: string + client: + type: boolean + status: + type: string + enum: + - "running" + - "finished" + stdout: + type: string + stderr: + type: string + rc: + type: integer + + GetScriptsRes: + type: array + items: + $ref: '#/components/schemas/RunningScript' + + LogoffRes: + type: object + required: + - op + properties: + op: + type: string + enum: + - "sent to client" + + Popup: + type: object + properties: + title: + type: string + message: + type: string