diff --git a/api/public/swagger.yaml b/api/public/swagger.yaml index 2db3115..c9b00c6 100644 --- a/api/public/swagger.yaml +++ b/api/public/swagger.yaml @@ -603,21 +603,6 @@ components: - sessionId type: object additionalProperties: false - TriggerProgramPayload: - properties: - _program: - type: string - description: 'Location of SAS program' - example: /Public/somefolder/some.file - expiresAfterMins: - type: number - format: double - description: "Amount of minutes after the completion of the program when the session must be\ndestroyed." - example: 15 - required: - - _program - type: object - additionalProperties: false LoginPayload: properties: username: @@ -1936,8 +1921,8 @@ paths: application/json: schema: $ref: '#/components/schemas/TriggerProgramResponse' - description: 'Trigger Program on the Specified Runtime' - summary: 'Triggers program and returns SessionId immediately - does not wait for program completion' + description: 'Trigger Program on the Specified Runtime.' + summary: 'Triggers program and returns SessionId immediately - does not wait for program completion.' tags: - STP security: @@ -1945,19 +1930,31 @@ paths: bearerAuth: [] parameters: - - description: 'Location of code in SASjs Drive' + description: 'Location of code in SASjs Drive.' in: query name: _program - required: false + required: true schema: type: string example: /Projects/myApp/some/program - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/TriggerProgramPayload' + - + description: 'Optional query param for setting debug mode.' + in: query + name: _debug + required: false + schema: + format: double + type: number + example: 131 + - + description: 'Optional query param for setting amount of minutes after the completion of the program when the session must be destroyed.' + in: query + name: expiresAfterMins + required: false + schema: + format: double + type: number + example: 15 /: get: operationId: Home diff --git a/api/src/controllers/stp.ts b/api/src/controllers/stp.ts index 573cf0a..3e66e88 100644 --- a/api/src/controllers/stp.ts +++ b/api/src/controllers/stp.ts @@ -22,7 +22,7 @@ interface ExecutePostRequestPayload { interface TriggerProgramPayload { /** - * Location of SAS program + * Location of SAS program. * @example "/Public/somefolder/some.file" */ _program: string @@ -32,6 +32,10 @@ interface TriggerProgramPayload { * @example 15 */ expiresAfterMins?: number + /** + * Query param for setting debug mode. + */ + _debug?: number } interface TriggerProgramResponse { @@ -108,19 +112,23 @@ export class STPController { } /** - * Trigger Program on the Specified Runtime - * @summary Triggers program and returns SessionId immediately - does not wait for program completion - * @param _program Location of code in SASjs Drive + * Trigger Program on the Specified Runtime. + * @summary Triggers program and returns SessionId immediately - does not wait for program completion. + * @param _program Location of code in SASjs Drive. + * @param expiresAfterMins Optional query param for setting amount of minutes after the completion of the program when the session must be destroyed. + * @param _debug Optional query param for setting debug mode. * @example _program "/Projects/myApp/some/program" - * @param expiresAfterMins Amount of minutes after the completion of the program when the session must be destroyed + * @example _debug 131 * @example expiresAfterMins 15 */ @Post('/trigger') public async triggerProgram( @Request() request: express.Request, - @Body() body: TriggerProgramPayload + @Query() _program: string, + @Query() _debug?: number, + @Query() expiresAfterMins?: number ): Promise { - return triggerProgram(request, body) + return triggerProgram(request, { _program, _debug, expiresAfterMins }) } } @@ -163,14 +171,18 @@ const execute = async ( const triggerProgram = async ( req: express.Request, - { _program, expiresAfterMins }: TriggerProgramPayload + { _program, _debug, expiresAfterMins }: TriggerProgramPayload ): Promise => { try { - const vars = { ...req.body } - const filesNamesMap = req.files?.length - ? makeFilesNamesMap(req.files as MulterFile[]) - : null - const otherArgs = { filesNamesMap: filesNamesMap } + // put _program query param into vars object + const vars: { [key: string]: string | number } = { _program } + + // if present add _debug query param to vars object + if (_debug) { + vars._debug = _debug + } + + // get code path and runTime const { codePath, runTime } = await getRunTimeAndFilePath(_program) // get session controller based on runTime @@ -191,7 +203,6 @@ const triggerProgram = async ( runTime, preProgramVariables: getPreProgramVariables(req), vars, - otherArgs, session }) diff --git a/api/src/routes/api/stp.ts b/api/src/routes/api/stp.ts index 632bcbd..6f418e5 100644 --- a/api/src/routes/api/stp.ts +++ b/api/src/routes/api/stp.ts @@ -73,12 +73,17 @@ stpRouter.post( ) stpRouter.post('/trigger', async (req, res) => { - const { error, value: body } = triggerProgramValidation(req.body) + const { error, value: query } = triggerProgramValidation(req.query) if (error) return res.status(400).send(error.details[0].message) try { - const response = await controller.triggerProgram(req, body) + const response = await controller.triggerProgram( + req, + query._program, + query._debug, + query.expiresAfterMins + ) res.status(200) res.send(response)