diff --git a/lib/constructs/business/rest-api-service.ts b/lib/constructs/business/rest-api-service.ts index ee599e918..59d5cafde 100644 --- a/lib/constructs/business/rest-api-service.ts +++ b/lib/constructs/business/rest-api-service.ts @@ -408,6 +408,9 @@ export class TimetableApiService extends RestApiService { const patchIntegration = new apigw.LambdaIntegration( timetableFunctions.patchFunction, { proxy: true }, ); + const putIntergation = new apigw.LambdaIntegration( + timetableFunctions.putFunction, { proxy: true }, + ); // const importIntegration = new apigw.LambdaIntegration( // timetableFunctions.importFunction, {proxy: true}, // ); @@ -447,6 +450,15 @@ export class TimetableApiService extends RestApiService { authorizer: props.authorizer, requestValidator: props.validator, }); + const putTimetable = root.addMethod(apigw2.HttpMethod.PUT, putIntergation, { + operationName: 'PutTimetable', + methodResponses: [{ + statusCode: '200', + responseParameters: lambdaRespParams, + }], + authorizer: props.authorizer, + requestValidator: props.validator, + }); // [timetableImport, timetableExport].forEach(value => value.addCorsPreflight({ // allowOrigins: allowOrigins, @@ -476,6 +488,7 @@ export class TimetableApiService extends RestApiService { [apigw2.HttpMethod.GET]: getTimetable, [apigw2.HttpMethod.PATCH]: patchTimetable, [apigw2.HttpMethod.POST]: postTimetable, + [apigw2.HttpMethod.PUT]: putTimetable, }, // "/timetable/export": { // [apigw2.HttpMethod.POST]: exportTimetable, diff --git a/lib/constructs/common/lambda-functions.ts b/lib/constructs/common/lambda-functions.ts index 78cc99344..f24182f4c 100644 --- a/lib/constructs/common/lambda-functions.ts +++ b/lib/constructs/common/lambda-functions.ts @@ -189,6 +189,7 @@ export class TimetableFunctions extends Construct { readonly postFunction: lambda.Function; readonly patchFunction: lambda.Function; readonly deleteFunction: lambda.Function; + readonly putFunction: lambda.Function; // readonly importFunction: lambda.Function; // readonly exportFunction: lambda.Function; @@ -257,6 +258,18 @@ export class TimetableFunctions extends Construct { environment: props.envVars, }); + this.putFunction = new lambda_py.PythonFunction(this, 'put-timetable', { + entry: 'src/lambda/put-timetable', + description: 'Put timetable in the database.', + functionName: 'put-timetable', + logRetention: logs.RetentionDays.ONE_MONTH, + memorySize: 128, + role: dynamoDBPutRole, + runtime: lambda.Runtime.PYTHON_3_9, + timeout: Duration.seconds(3), + environment: props.envVars, + }); + // this.importFunction = new lambda_py.PythonFunction(this, 'import-timetable', { // entry: 'src/lambda/import-timetable', // description: "Import timetable from pdf.",