Skip to content

Commit f03ed61

Browse files
committed
Fix indentation
1 parent cf07c92 commit f03ed61

2 files changed

Lines changed: 133 additions & 41 deletions

File tree

SAMtemplates/apis/main.yaml

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -564,47 +564,47 @@ Resources:
564564
Timeout: "1"
565565
Count: 0
566566

567-
NotificationsReportingResource:
568-
Condition: ShouldDeployNotificationsReporting
569-
Type: AWS::ApiGateway::Resource
570-
Properties:
571-
RestApiId: !Ref RestApiGateway
572-
ParentId: !GetAtt RestApiGateway.RootResourceId
573-
PathPart: notifications-reporting
574-
575-
NotificationsReportingMethod:
576-
Condition: ShouldDeployNotificationsReporting
577-
Type: AWS::ApiGateway::Method
578-
Properties:
579-
RestApiId: !Ref RestApiGateway
580-
ResourceId: !Ref NotificationsReportingResource
581-
HttpMethod: GET
582-
AuthorizationType: NONE
583-
Integration:
584-
Type: AWS_PROXY
585-
Credentials: !GetAtt RestApiGatewayResources.Outputs.ApiGwRoleArn
586-
IntegrationHttpMethod: POST
587-
Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NotificationsReportingFunctionArn}/invocations
588-
589-
NotificationsReportingHandle:
590-
Condition: ShouldDeployNotificationsReporting
591-
DependsOn: NotificationsReportingMethod
592-
Type: "AWS::CloudFormation::WaitConditionHandle"
593-
594-
NotificationsReportingWaitHandle:
595-
Type: "AWS::CloudFormation::WaitConditionHandle"
596-
597-
NotificationsReportingWaitCondition:
598-
Type: "AWS::CloudFormation::WaitCondition"
599-
Properties:
600-
Handle:
601-
!If [
602-
ShouldDeployNotificationsReporting,
603-
!Ref NotificationsReportingHandle,
604-
!Ref NotificationsReportingWaitHandle,
605-
]
606-
Timeout: "1"
607-
Count: 0
567+
NotificationsReportingResource:
568+
Condition: ShouldDeployNotificationsReporting
569+
Type: AWS::ApiGateway::Resource
570+
Properties:
571+
RestApiId: !Ref RestApiGateway
572+
ParentId: !GetAtt RestApiGateway.RootResourceId
573+
PathPart: notifications-reporting
574+
575+
NotificationsReportingMethod:
576+
Condition: ShouldDeployNotificationsReporting
577+
Type: AWS::ApiGateway::Method
578+
Properties:
579+
RestApiId: !Ref RestApiGateway
580+
ResourceId: !Ref NotificationsReportingResource
581+
HttpMethod: GET
582+
AuthorizationType: NONE
583+
Integration:
584+
Type: AWS_PROXY
585+
Credentials: !GetAtt RestApiGatewayResources.Outputs.ApiGwRoleArn
586+
IntegrationHttpMethod: POST
587+
Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${NotificationsReportingFunctionArn}/invocations
588+
589+
NotificationsReportingHandle:
590+
Condition: ShouldDeployNotificationsReporting
591+
DependsOn: NotificationsReportingMethod
592+
Type: "AWS::CloudFormation::WaitConditionHandle"
593+
594+
NotificationsReportingWaitHandle:
595+
Type: "AWS::CloudFormation::WaitConditionHandle"
596+
597+
NotificationsReportingWaitCondition:
598+
Type: "AWS::CloudFormation::WaitCondition"
599+
Properties:
600+
Handle:
601+
!If [
602+
ShouldDeployNotificationsReporting,
603+
!Ref NotificationsReportingHandle,
604+
!Ref NotificationsReportingWaitHandle,
605+
]
606+
Timeout: "1"
607+
Count: 0
608608

609609
# *********************************************************************
610610
# if you add a new endpoint, then change the name of this resource
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Notifications reporting lambda
2+
3+
This lambda exposes a lightweight, internal reporting endpoint for notification status records stored in the notifications DynamoDB table.
4+
5+
## Overview
6+
7+
- **API path**: `GET /notifications-reporting`
8+
- **Purpose**: return notification status records for troubleshooting and test reporting.
9+
- **Data source**: the notifications table (`PrescriptionNotificationStatesTableName`).
10+
- **Deployment**: controlled by the `DeployNotificationsReporting` parameter.
11+
12+
## Request
13+
14+
Query parameters (at least one is required):
15+
16+
- `prescriptionId` (string)
17+
- `nhsNumber` (string)
18+
- `odsCode` (string)
19+
20+
Notes:
21+
22+
- `odsCode` is upper‑cased before querying.
23+
- If `nhsNumber` is provided, the lambda performs a **query** by partition key and applies additional filters.
24+
- If only `prescriptionId` and/or `odsCode` are provided, the lambda performs a **scan** using those filters.
25+
26+
### Example
27+
28+
```
29+
GET /notifications-reporting?nhsNumber=9999999999&odsCode=A12345
30+
```
31+
32+
## Response
33+
34+
Success (200):
35+
36+
```json
37+
{
38+
"count": 2,
39+
"filters": {
40+
"prescriptionId": null,
41+
"odsCode": "A12345",
42+
"nhsNumberProvided": true
43+
},
44+
"notifications": [
45+
{
46+
"NHSNumber": "9999999999",
47+
"ODSCode": "A12345",
48+
"RequestId": "req-1",
49+
"PrescriptionID": "RX123",
50+
"LastNotifiedPrescriptionStatus": "DELIVERED",
51+
"LastNotificationRequestTimestamp": "2025-01-01T10:00:00.000Z",
52+
"ExpiryTime": 1735735200,
53+
"NotifyMessageReference": "ref-1",
54+
"MessageStatus": "delivered",
55+
"SupplierStatus": "delivered"
56+
}
57+
]
58+
}
59+
```
60+
61+
Error responses:
62+
63+
- **400** when no filters are provided.
64+
- **500** for unexpected failures reading DynamoDB.
65+
66+
## Data flow
67+
68+
```mermaid
69+
sequenceDiagram
70+
autonumber
71+
actor Client
72+
participant APIGW as API Gateway
73+
participant Lambda as NotificationsReporting Lambda
74+
participant DynamoDB as Notifications Table
75+
76+
Client->>APIGW: GET /notifications-reporting?filters
77+
APIGW->>Lambda: Invoke (event)
78+
Lambda->>Lambda: Normalize filters
79+
alt No filters
80+
Lambda-->>APIGW: 400 {message}
81+
APIGW-->>Client: 400
82+
else Filters present
83+
alt nhsNumber provided
84+
Lambda->>DynamoDB: Query by NHSNumber + filters
85+
else no nhsNumber
86+
Lambda->>DynamoDB: Scan by filters
87+
end
88+
DynamoDB-->>Lambda: Items
89+
Lambda-->>APIGW: 200 {count, filters, notifications}
90+
APIGW-->>Client: 200
91+
end
92+
```

0 commit comments

Comments
 (0)