Skip to content

Commit 3a5da13

Browse files
patchLetters to patchLetter
1 parent 8a8bcc4 commit 3a5da13

File tree

14 files changed

+43
-43
lines changed

14 files changed

+43
-43
lines changed

infrastructure/terraform/components/api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ No requirements.
3737
| <a name="module_get_letters"></a> [get\_letters](#module\_get\_letters) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.20/terraform-lambda.zip | n/a |
3838
| <a name="module_kms"></a> [kms](#module\_kms) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.20/terraform-kms.zip | n/a |
3939
| <a name="module_logging_bucket"></a> [logging\_bucket](#module\_logging\_bucket) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.20/terraform-s3bucket.zip | n/a |
40-
| <a name="module_patch_letters"></a> [patch\_letters](#module\_patch\_letters) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.20/terraform-lambda.zip | n/a |
40+
| <a name="module_patch_letter"></a> [patch\_letter](#module\_patch\_letter) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.20/terraform-lambda.zip | n/a |
4141
| <a name="module_s3bucket_test_letters"></a> [s3bucket\_test\_letters](#module\_s3bucket\_test\_letters) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.20/terraform-s3bucket.zip | n/a |
4242
| <a name="module_supplier_ssl"></a> [supplier\_ssl](#module\_supplier\_ssl) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.20/terraform-ssl.zip | n/a |
4343
## Outputs

infrastructure/terraform/components/api/iam_role_api_gateway_execution_role.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ data "aws_iam_policy_document" "api_gateway_execution_policy" {
5050
resources = [
5151
module.authorizer_lambda.function_arn,
5252
module.get_letters.function_arn,
53-
module.patch_letters.function_arn
53+
module.patch_letter.function_arn
5454
]
5555
}
5656
}

infrastructure/terraform/components/api/locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ locals {
99
AWS_REGION = var.region
1010
AUTHORIZER_LAMBDA_ARN = module.authorizer_lambda.function_arn
1111
GET_LETTERS_LAMBDA_ARN = module.get_letters.function_arn
12-
PATCH_LETTERS_LAMBDA_ARN = module.patch_letters.function_arn
12+
PATCH_LETTER_LAMBDA_ARN = module.patch_letter.function_arn
1313
})
1414

1515
destination_arn = "arn:aws:logs:${var.region}:${var.shared_infra_account_id}:destination:nhs-main-obs-firehose-logs"

infrastructure/terraform/components/api/module_lambda_patch_letters.tf renamed to infrastructure/terraform/components/api/module_lambda_patch_letter.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
module "patch_letters" {
1+
module "patch_letter" {
22
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.20/terraform-lambda.zip"
33

4-
function_name = "patch_letters"
4+
function_name = "patch_letter"
55
description = "Update the status of a letter"
66

77
aws_account_id = var.aws_account_id
@@ -15,14 +15,14 @@ module "patch_letters" {
1515
kms_key_arn = module.kms.key_arn
1616

1717
iam_policy_document = {
18-
body = data.aws_iam_policy_document.patch_letters_lambda.json
18+
body = data.aws_iam_policy_document.patch_letter_lambda.json
1919
}
2020

2121
function_s3_bucket = local.acct.s3_buckets["lambda_function_artefacts"]["id"]
2222
function_code_base_path = local.aws_lambda_functions_dir_path
2323
function_code_dir = "api-handler/dist"
2424
function_include_common = true
25-
handler_function_name = "patchLetters"
25+
handler_function_name = "patchLetter"
2626
runtime = "nodejs22.x"
2727
memory = 128
2828
timeout = 5
@@ -38,7 +38,7 @@ module "patch_letters" {
3838
lambda_env_vars = merge(local.common_lambda_env_vars, {})
3939
}
4040

41-
data "aws_iam_policy_document" "patch_letters_lambda" {
41+
data "aws_iam_policy_document" "patch_letter_lambda" {
4242
statement {
4343
sid = "KMSPermissions"
4444
effect = "Allow"

infrastructure/terraform/components/api/resources/spec.tmpl.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
],
6868
"patch": {
6969
"description": "Update the status of a letter by providing the new status in the request body.",
70-
"operationId": "patchLetters",
70+
"operationId": "patchLetter",
7171
"requestBody": {
7272
"required": true
7373
},
@@ -102,7 +102,7 @@
102102
},
103103
"timeoutInMillis": 29000,
104104
"type": "AWS_PROXY",
105-
"uri": "arn:aws:apigateway:${AWS_REGION}:lambda:path/2015-03-31/functions/${PATCH_LETTERS_LAMBDA_ARN}/invocations"
105+
"uri": "arn:aws:apigateway:${AWS_REGION}:lambda:path/2015-03-31/functions/${PATCH_LETTER_LAMBDA_ARN}/invocations"
106106
}
107107
}
108108
}

lambdas/api-handler/src/handlers/__tests__/patch-letters.test.ts renamed to lambdas/api-handler/src/handlers/__tests__/patch-letter.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { patchLetters } from '../../index';
1+
import { patchLetter } from '../../index';
22
import { APIGatewayProxyResult, Context } from 'aws-lambda';
33
import { mockDeep } from 'jest-mock-extended';
44
import { makeApiGwEvent } from './utils/test-utils';
@@ -45,7 +45,7 @@ beforeEach(() => {
4545
jest.clearAllMocks();
4646
});
4747

48-
describe('patchLetters API Handler', () => {
48+
describe('patchLetter API Handler', () => {
4949

5050
it('returns 200 OK with updated resource', async () => {
5151
const event = makeApiGwEvent({
@@ -72,7 +72,7 @@ describe('patchLetters API Handler', () => {
7272
};
7373
mockedPatchLetterStatus.mockResolvedValue(updateLetterServiceResponse);
7474

75-
const result = await patchLetters(event, context, callback);
75+
const result = await patchLetter(event, context, callback);
7676

7777
expect(result).toEqual({
7878
statusCode: 200,
@@ -89,7 +89,7 @@ describe('patchLetters API Handler', () => {
8989
const context = mockDeep<Context>();
9090
const callback = jest.fn();
9191

92-
const result = await patchLetters(event, context, callback);
92+
const result = await patchLetter(event, context, callback);
9393

9494
expect(mockedMapErrorToResponse).toHaveBeenCalledWith(new ValidationError(errors.ApiErrorDetail.InvalidRequestMissingBody), 'correlationId');
9595
expect(result).toEqual(expectedErrorResponse);
@@ -103,7 +103,7 @@ describe('patchLetters API Handler', () => {
103103
});
104104
const context = mockDeep<Context>();
105105
const callback = jest.fn();
106-
const result = await patchLetters(event, context, callback);
106+
const result = await patchLetter(event, context, callback);
107107

108108
expect(mockedMapErrorToResponse).toHaveBeenCalledWith(new ValidationError(errors.ApiErrorDetail.InvalidRequestMissingLetterIdPathParameter), 'correlationId');
109109
expect(result).toEqual(expectedErrorResponse);
@@ -122,7 +122,7 @@ describe('patchLetters API Handler', () => {
122122
const context = mockDeep<Context>();
123123
const callback = jest.fn();
124124

125-
const result = await patchLetters(event, context, callback);
125+
const result = await patchLetter(event, context, callback);
126126

127127
expect(mockedMapErrorToResponse).toHaveBeenCalledWith(error, 'correlationId');
128128
expect(result).toEqual(expectedErrorResponse);
@@ -138,7 +138,7 @@ describe('patchLetters API Handler', () => {
138138
const context = mockDeep<Context>();
139139
const callback = jest.fn();
140140

141-
const result = await patchLetters(event, context, callback);
141+
const result = await patchLetter(event, context, callback);
142142

143143
expect(mockedMapErrorToResponse).toHaveBeenCalledWith(new ValidationError(errors.ApiErrorDetail.InvalidRequestMissingSupplierId), 'correlationId');
144144
expect(result).toEqual(expectedErrorResponse);
@@ -154,7 +154,7 @@ describe('patchLetters API Handler', () => {
154154
const context = mockDeep<Context>();
155155
const callback = jest.fn();
156156

157-
const result = await patchLetters(event, context, callback);
157+
const result = await patchLetter(event, context, callback);
158158

159159
expect(mockedMapErrorToResponse).toHaveBeenCalledWith(new ValidationError(errors.ApiErrorDetail.InvalidRequestBody), 'correlationId');
160160
expect(result).toEqual(expectedErrorResponse);
@@ -170,7 +170,7 @@ describe('patchLetters API Handler', () => {
170170
const context = mockDeep<Context>();
171171
const callback = jest.fn();
172172

173-
const result = await patchLetters(event, context, callback);
173+
const result = await patchLetter(event, context, callback);
174174

175175
expect(mockedMapErrorToResponse).toHaveBeenCalledWith(new ValidationError(errors.ApiErrorDetail.InvalidRequestBody), 'correlationId');
176176
expect(result).toEqual(expectedErrorResponse);
@@ -191,7 +191,7 @@ describe('patchLetters API Handler', () => {
191191
throw error;
192192
});
193193

194-
const result = await patchLetters(event, context, callback);
194+
const result = await patchLetter(event, context, callback);
195195

196196
expect(mockedMapErrorToResponse).toHaveBeenCalledWith(error, 'correlationId');
197197
expect(result).toEqual(expectedErrorResponse);
@@ -209,7 +209,7 @@ describe('patchLetters API Handler', () => {
209209
const context = mockDeep<Context>();
210210
const callback = jest.fn();
211211

212-
const result = await patchLetters(event, context, callback);
212+
const result = await patchLetter(event, context, callback);
213213

214214
expect(mockedMapErrorToResponse).toHaveBeenCalledWith(new Error("The request headers don't contain the APIM correlation id"), undefined);
215215
expect(result).toEqual(expectedErrorResponse);
@@ -225,7 +225,7 @@ describe('patchLetters API Handler', () => {
225225
const context = mockDeep<Context>();
226226
const callback = jest.fn();
227227

228-
const result = await patchLetters(event, context, callback);
228+
const result = await patchLetter(event, context, callback);
229229

230230
expect(mockedMapErrorToResponse).toHaveBeenCalledWith(new Error('The request headers are empty'), undefined);
231231
expect(result).toEqual(expectedErrorResponse);

lambdas/api-handler/src/handlers/patch-letters.ts renamed to lambdas/api-handler/src/handlers/patch-letter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { assertNotEmpty } from '../utils/validation';
1010
import { mapToLetterDto } from '../mappers/letter-mapper';
1111

1212
const letterRepo = createLetterRepository();
13-
export const patchLetters: APIGatewayProxyHandler = async (event) => {
13+
export const patchLetter: APIGatewayProxyHandler = async (event) => {
1414

1515
let correlationId;
1616

lambdas/api-handler/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Export all handlers for ease of access
22
export { getLetters } from './handlers/get-letters';
3-
export { patchLetters } from './handlers/patch-letters';
3+
export { patchLetter } from './handlers/patch-letter';

postman/Sandbox.postman_collection.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@
641641
}
642642
}
643643
],
644-
"name": "200 - PatchLetters",
644+
"name": "200 - PatchLetter",
645645
"request": {
646646
"body": {
647647
"mode": "raw",
@@ -745,7 +745,7 @@
745745
"body": null,
746746
"cookie": [],
747747
"header": null,
748-
"name": "200 - PatchLetters-CANCELLED",
748+
"name": "200 - PatchLetter-CANCELLED",
749749
"originalRequest": {
750750
"body": {
751751
"mode": "raw",

sandbox/api/openapi.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ paths:
609609
patch:
610610
description: Update the status of a letter by providing the new status in the
611611
request body.
612-
operationId: patchLetters
612+
operationId: patchLetter
613613
parameters:
614614
- description: "Unique request identifier, in the format of a GUID"
615615
explode: false
@@ -755,7 +755,7 @@ paths:
755755
id: "123654789"
756756
type: Letter
757757
schema:
758-
$ref: "#/components/schemas/patchLetters_request"
758+
$ref: "#/components/schemas/patchLetter_request"
759759
required: true
760760
responses:
761761
"200":
@@ -1183,7 +1183,7 @@ components:
11831183
- specificationId
11841184
- status
11851185
type: object
1186-
patchLetters_request:
1186+
patchLetter_request:
11871187
properties:
11881188
data:
11891189
$ref: "#/components/schemas/postLetters_request_data_inner"

0 commit comments

Comments
 (0)