Skip to content

Commit a06bd64

Browse files
authored
Merge pull request #341 from NHSDigital/release/2024-10-02
Release/2024 10 02
2 parents 99c0581 + 5722b60 commit a06bd64

File tree

45 files changed

+1111
-538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1111
-538
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2024-10-02
4+
- [PI-497] Read a CPM Product
5+
- [PI-543] Remove snapshot from etl
6+
37
## 2024-09-30
48
- [PI-473] Serialise tags more nicer
59
- [PI-522] Shorten lambda name

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024.09.30
1+
2024.10.02

changelog/2024-10-02.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [PI-497] Read a CPM Product
2+
- [PI-543] Remove snapshot from etl

docs/public_swagger/swagger.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,48 @@ paths:
438438
application/fhir+json:
439439
schema:
440440
$ref: "#/components/schemas/OperationOutcome"
441+
/ProductTeam/{product_team_id}/Product/{product_id}:
442+
get:
443+
operationId: readproductendpoint
444+
summary: readProduct endpoint for APIGEE integration
445+
parameters:
446+
- name: product_team_id
447+
in: path
448+
required: true
449+
description: logical identifier
450+
schema:
451+
type: string
452+
- name: product_id
453+
in: path
454+
required: true
455+
description: logical identifier
456+
schema:
457+
type: string
458+
- in: header
459+
name: version
460+
schema:
461+
$ref: "#/components/schemas/Version"
462+
- in: header
463+
name: x-request-id
464+
schema:
465+
$ref: "#/components/schemas/RequestId"
466+
- in: header
467+
name: x-correlation-id
468+
schema:
469+
$ref: "#/components/schemas/CorrelationId"
470+
responses:
471+
"200":
472+
description: Read Product operation successful
473+
content:
474+
application/fhir+json:
475+
schema:
476+
$ref: "#/components/schemas/Bundle"
477+
"4XX":
478+
description: "Client Error"
479+
content:
480+
application/fhir+json:
481+
schema:
482+
$ref: "#/components/schemas/OperationOutcome"
441483
/searchSdsDevice:
442484
get:
443485
operationId: searchsdsdevice

infrastructure/swagger/05_paths.yaml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -189,42 +189,42 @@ paths:
189189
- ${authoriser_name}: []
190190
- app-level0: []
191191

192-
# /ProductTeam/{product_team_id}/Product/{product_id}:
193-
# get:
194-
# operationId: readproductendpoint
195-
# summary: readProduct endpoint for APIGEE integration
196-
# parameters:
197-
# - name: product_team_id
198-
# in: path
199-
# required: true
200-
# description: logical identifier
201-
# schema:
202-
# type: string
203-
# - name: product_id
204-
# in: path
205-
# required: true
206-
# description: logical identifier
207-
# schema:
208-
# type: string
209-
# - *RequestHeaderVersion
210-
# - *RequestHeaderRequestId
211-
# - *RequestHeaderCorrelationId
212-
# responses:
213-
# responses:
214-
# "200":
215-
# description: Read Product operation successful
216-
# content:
217-
# application/fhir+json:
218-
# schema:
219-
# $ref: "#/components/schemas/Bundle"
220-
# "4XX":
221-
# <<: *Response4XX
222-
# x-amazon-apigateway-integration:
223-
# <<: *ApiGatewayIntegration
224-
# uri: ${method_readCpmProduct}
225-
# security:
226-
# - ${authoriser_name}: []
227-
# - app-level0: []
192+
/ProductTeam/{product_team_id}/Product/{product_id}:
193+
get:
194+
operationId: readproductendpoint
195+
summary: readProduct endpoint for APIGEE integration
196+
parameters:
197+
- name: product_team_id
198+
in: path
199+
required: true
200+
description: logical identifier
201+
schema:
202+
type: string
203+
- name: product_id
204+
in: path
205+
required: true
206+
description: logical identifier
207+
schema:
208+
type: string
209+
- *RequestHeaderVersion
210+
- *RequestHeaderRequestId
211+
- *RequestHeaderCorrelationId
212+
responses:
213+
responses:
214+
"200":
215+
description: Read Product operation successful
216+
content:
217+
application/fhir+json:
218+
schema:
219+
$ref: "#/components/schemas/Bundle"
220+
"4XX":
221+
<<: *Response4XX
222+
x-amazon-apigateway-integration:
223+
<<: *ApiGatewayIntegration
224+
uri: ${method_readCpmProduct}
225+
security:
226+
- ${authoriser_name}: []
227+
- app-level0: []
228228

229229
/Device:
230230
post:

infrastructure/terraform/per_workspace/modules/etl/sds/etl-diagram.asl.json

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -262,39 +262,7 @@
262262
"Next": "fail"
263263
}
264264
],
265-
"Default": "set-snapshot-bucket"
266-
},
267-
"set-snapshot-bucket": {
268-
"Type": "Pass",
269-
"Next": "check-snapshot-bucket",
270-
"Result": {
271-
"snapshot_bucket": "${etl_snapshot_bucket}"
272-
}
273-
},
274-
"check-snapshot-bucket": {
275-
"Type": "Choice",
276-
"Choices": [
277-
{
278-
"Variable": "$.snapshot_bucket",
279-
"StringEquals": "snapshot_not_required",
280-
"Next": "skip-export"
281-
}
282-
],
283-
"Default": "export-dynamodb-to-s3"
284-
},
285-
"export-dynamodb-to-s3": {
286-
"Type": "Task",
287-
"Parameters": {
288-
"S3Bucket": "${etl_snapshot_bucket}",
289-
"S3Prefix.$": "$$.Execution.Name",
290-
"TableArn": "${table_arn}"
291-
},
292-
"Resource": "arn:aws:states:::aws-sdk:dynamodb:exportTableToPointInTime",
293-
"Next": "delete-state-lock"
294-
},
295-
"skip-export": {
296-
"Type": "Pass",
297-
"Next": "delete-state-lock"
265+
"Default": "delete-state-lock"
298266
},
299267
"delete-state-lock": {
300268
"Type": "Task",

infrastructure/terraform/per_workspace/modules/etl/sds/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ module "schedule_trigger_update" {
558558
source = "./schedule/"
559559
lambda_arn = module.trigger_update.lambda_function.lambda_function_arn
560560
lambda_name = module.trigger_update.lambda_function.lambda_function_name
561-
schedule_expression = contains(["qa", "prod"], var.environment) ? "rate(15 minutes)" : "cron(0 0 1 1 ? 2000)" # changelog schedule only active for qa & prod
561+
schedule_expression = contains(["prod"], var.environment) ? "rate(15 minutes)" : "cron(0 0 1 1 ? 2000)" # changelog schedule only active for prod
562562
}
563563

564564
module "bulk_trigger_notification" {

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "connecting-party-manager"
3-
version = "2024.09.30"
3+
version = "2024.10.02"
44
description = "Repository for the Connecting Party Manager API and related services"
55
authors = ["NHS England"]
66
license = "LICENSE.md"
Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,60 @@
11
from http import HTTPStatus
22

33
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
4-
from domain.core.cpm_product import CpmProduct, CpmProductIncomingParams
4+
from domain.core.cpm_product import CpmProduct
55
from domain.core.cpm_system_id import ProductId
66
from domain.core.product_team.v3 import ProductTeam
7+
from domain.repository.cpm_product_repository.v3 import CpmProductRepository
78
from domain.repository.product_team_repository.v2 import ProductTeamRepository
9+
from domain.request_models.v1 import (
10+
CreateCpmProductIncomingParams,
11+
ProductTeamPathParams,
12+
)
813
from domain.response.validation_errors import (
914
InboundValidationError,
1015
mark_json_decode_errors_as_inbound,
16+
mark_validation_errors_as_inbound,
1117
)
12-
from event.aws.client import dynamodb_client
1318
from event.step_chain import StepChain
1419
from pydantic import ValidationError
1520

1621

22+
@mark_validation_errors_as_inbound
23+
def parse_path_params(data, cache) -> ProductTeamPathParams:
24+
event = APIGatewayProxyEvent(data[StepChain.INIT])
25+
return ProductTeamPathParams(**event.path_parameters)
26+
27+
1728
@mark_json_decode_errors_as_inbound
1829
def parse_event_body(data, cache) -> dict:
1930
event = APIGatewayProxyEvent(data[StepChain.INIT])
2031
return event.json_body if event.body else {}
2132

2233

23-
def parse_incoming_cpm_product(data, cache) -> CpmProductIncomingParams:
34+
def parse_incoming_cpm_product(data, cache) -> CreateCpmProductIncomingParams:
2435
json_body = data[parse_event_body]
2536
try:
26-
incoming_product = CpmProductIncomingParams(**json_body)
37+
incoming_product = CreateCpmProductIncomingParams(**json_body)
2738
return incoming_product
2839
except ValidationError as exc:
2940
raise InboundValidationError(errors=exc.raw_errors, model=exc.model)
3041

3142

3243
def read_product_team(data, cache) -> ProductTeam:
33-
incoming_product = data[parse_incoming_cpm_product]
34-
event = APIGatewayProxyEvent(data[StepChain.INIT])
35-
product_team_id = event.path_parameters["product_team_id"]
44+
path_params: ProductTeamPathParams = data[parse_path_params]
45+
3646
product_team_repo = ProductTeamRepository(
37-
table_name=cache["DYNAMODB_TABLE"], dynamodb_client=dynamodb_client()
47+
table_name=cache["DYNAMODB_TABLE"], dynamodb_client=cache["DYNAMODB_CLIENT"]
3848
)
39-
return product_team_repo.read(id=product_team_id)
49+
return product_team_repo.read(id=path_params.product_team_id)
4050

4151

4252
def generate_cpm_product_id(data, cache) -> str:
4353
generated_product_id = ProductId.create()
4454
return generated_product_id.id
4555

4656

57+
@mark_validation_errors_as_inbound
4758
def create_cpm_product(data, cache) -> CpmProduct:
4859
incoming_product = data[parse_incoming_cpm_product]
4960
product_team: ProductTeam = data[read_product_team]
@@ -54,17 +65,26 @@ def create_cpm_product(data, cache) -> CpmProduct:
5465
return product
5566

5667

68+
def save_cpm_product(data, cache) -> dict:
69+
cpm_product = data[create_cpm_product]
70+
cpm_product_repo = CpmProductRepository(
71+
table_name=cache["DYNAMODB_TABLE"], dynamodb_client=cache["DYNAMODB_CLIENT"]
72+
)
73+
return cpm_product_repo.write(entity=cpm_product)
74+
75+
5776
def set_http_status(data, cache) -> tuple[HTTPStatus, str]:
58-
product: Product = data[create_cpm_product]
77+
product: CpmProduct = data[create_cpm_product]
5978
return HTTPStatus.CREATED, str(product.id)
6079

6180

6281
steps = [
82+
parse_path_params,
6383
parse_event_body,
6484
parse_incoming_cpm_product,
6585
read_product_team,
6686
generate_cpm_product_id,
6787
create_cpm_product,
68-
# save_product_team,
88+
save_cpm_product,
6989
set_http_status,
7090
]

src/api/createCpmProduct/tests/test_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from unittest import mock
44

55
import pytest
6-
from domain.core.root import Root
6+
from domain.core.root.v3 import Root
77
from domain.repository.product_team_repository.v2 import ProductTeamRepository
88
from nhs_context_logging import app_logger
99

0 commit comments

Comments
 (0)