Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2025-02-07
- [PI-746] Deactivate a Product
- [PI-765] Feature test for create ProductTeam endpoint request containing an empty key_value

## 2025-02-05
- [PI-691] Changelog ETL - modify / replace in an AS
- [PI-726] Update AS tags - Adding an AS
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2025.02.05
2025.02.07
2 changes: 2 additions & 0 deletions changelog/2025-02-07.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [PI-746] Deactivate a Product
- [PI-765] Feature test for create ProductTeam endpoint request containing an empty key_value
44 changes: 24 additions & 20 deletions infrastructure/swagger/05_paths.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -229,26 +229,30 @@ paths:
security:
- ${authoriser_name}: []
- app-level0: []
# delete:
# operationId: deleteproductendpoint
# summary: Delete a Product resource (DELETE)
# parameters:
# - $ref: "#/components/parameters/ProductTeamId"
# - $ref: "#/components/parameters/ProductId"
# - $ref: "#/components/parameters/HeaderVersion"
# - $ref: "#/components/parameters/HeaderRequestId"
# - $ref: "#/components/parameters/HeaderCorrelationId"
# responses:
# "204":
# description: Delete Product operation successful
# "404":
# $ref: "#/components/responses/NotFound"
# x-amazon-apigateway-integration:
# <<: *ApiGatewayIntegration
# uri: ${method_deleteCpmProduct}
# security:
# - ${authoriser_name}: []
# - app-level0: []
delete:
operationId: deleteproductendpoint
summary: Delete a Product resource (DELETE)
description: |
- Delete a product using a product team ID and product ID.
tags:
- Core Product ID Endpointsurce (DELETE)
parameters:
- $ref: "#/components/parameters/ProductTeamId"
- $ref: "#/components/parameters/ProductId"
- $ref: "#/components/parameters/HeaderVersion"
- $ref: "#/components/parameters/HeaderRequestId"
- $ref: "#/components/parameters/HeaderCorrelationId"
responses:
"200":
$ref: "#/components/responses/ProductDelete"
"404":
$ref: "#/components/responses/NotFound"
x-amazon-apigateway-integration:
<<: *ApiGatewayIntegration
uri: ${method_deleteCpmProduct}
security:
- ${authoriser_name}: []
- app-level0: []

/ProductTeamEpr/{product_team_id}/ProductEpr:
post:
Expand Down
11 changes: 10 additions & 1 deletion infrastructure/swagger/07_components--schemas--domain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,16 @@ components:
created_on: "2024-10-15T10:00:00Z"
updated_on: "null"
deleted_on: "null"

CPMProductDeleteResponse:
type: object
properties:
code:
type: string
message:
type: string
example:
code: "RESOURCE_DELETED"
message: "P.XYZ-123 has been deleted."
Questionnaire:
type: object
properties:
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/swagger/12_components--responses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ components:
application/json:
schema:
$ref: "#/components/schemas/CPMProductResponse"
ProductDelete:
description: Delete Product operation successful
content:
application/json:
schema:
$ref: "#/components/schemas/CPMProductDeleteResponse"
EprProductCreate:
description: Create Epr Product operation successful
content:
Expand Down
18 changes: 13 additions & 5 deletions infrastructure/terraform/per_workspace/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,23 @@ module "cpmtable" {
attributes = [
{ name = "pk", type = "S" },
{ name = "sk", type = "S" },
{ name = "pk_read", type = "S" },
{ name = "sk_read", type = "S" },
{ name = "pk_read_1", type = "S" },
{ name = "sk_read_1", type = "S" },
{ name = "pk_read_2", type = "S" },
{ name = "sk_read_2", type = "S" },
]

global_secondary_indexes = [
{
name = "idx_gsi_read"
hash_key = "pk_read"
range_key = "sk_read"
name = "idx_gsi_read_1"
hash_key = "pk_read_1"
range_key = "sk_read_1"
projection_type = "ALL"
},
{
name = "idx_gsi_read_2"
hash_key = "pk_read_2"
range_key = "sk_read_2"
projection_type = "ALL"
}
]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "connecting-party-manager"
version = "2025.02.05"
version = "2025.02.07"
description = "Repository for the Connecting Party Manager API and related services"
authors = ["NHS England"]
license = "LICENSE.md"
Expand Down
6 changes: 3 additions & 3 deletions src/api/createCpmProduct/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from domain.repository.product_team_repository import ProductTeamRepository
from event.json import json_loads

from test_helpers.dynamodb import mock_table
from test_helpers.dynamodb import mock_table_cpm
from test_helpers.response_assertions import _response_assertions

from .data import product_payload, product_team_payload
Expand All @@ -22,7 +22,7 @@ def _mock_test(version, params):
name=product_team_payload["name"], keys=product_team_payload["keys"]
)

with mock_table(table_name=TABLE_NAME) as client, mock.patch.dict(
with mock_table_cpm(table_name=TABLE_NAME) as client, mock.patch.dict(
os.environ,
{
"DYNAMODB_TABLE": TABLE_NAME,
Expand Down Expand Up @@ -113,7 +113,7 @@ def test_incoming_errors(params, error, status_code, version):
],
)
def test_index_no_such_product_team(version):
with mock_table(TABLE_NAME), mock.patch.dict(
with mock_table_cpm(TABLE_NAME), mock.patch.dict(
os.environ,
{
"DYNAMODB_TABLE": TABLE_NAME,
Expand Down
8 changes: 4 additions & 4 deletions src/api/createProductTeam/tests/v1/test_index_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
from event.json import json_loads

from test_helpers.dynamodb import mock_table
from test_helpers.dynamodb import mock_table_cpm
from test_helpers.response_assertions import _response_assertions
from test_helpers.sample_data import (
CPM_PRODUCT_TEAM_NO_ID,
Expand All @@ -22,7 +22,7 @@
],
)
def test_index(version):
with mock_table(table_name=TABLE_NAME), mock.patch.dict(
with mock_table_cpm(table_name=TABLE_NAME), mock.patch.dict(
os.environ,
{
"DYNAMODB_TABLE": TABLE_NAME,
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_index(version):
],
)
def test_index_bad_payload(version):
with mock_table(table_name=TABLE_NAME), mock.patch.dict(
with mock_table_cpm(table_name=TABLE_NAME), mock.patch.dict(
os.environ,
{
"DYNAMODB_TABLE": TABLE_NAME,
Expand Down Expand Up @@ -120,7 +120,7 @@ def test_index_bad_payload(version):
],
)
def test_index(version):
with mock_table(table_name=TABLE_NAME), mock.patch.dict(
with mock_table_cpm(table_name=TABLE_NAME), mock.patch.dict(
os.environ,
{
"DYNAMODB_TABLE": TABLE_NAME,
Expand Down
30 changes: 30 additions & 0 deletions src/api/deleteCpmProduct/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from api_utils.api_step_chain import execute_step_chain
from domain.logging.step_decorators import logging_step_decorators
from event.aws.client import dynamodb_client
from event.environment import BaseEnvironment
from event.logging.logger import setup_logger

from .src.v1.steps import steps as v1_steps


class Environment(BaseEnvironment):
DYNAMODB_TABLE: str


versioned_steps = {"1": v1_steps}
cache = {
**Environment.build().dict(),
"DYNAMODB_CLIENT": dynamodb_client(),
}


def handler(event: dict, context=None):
setup_logger(service_name=__file__)
return execute_step_chain(
event=event,
cache=cache,
versioned_steps=versioned_steps,
)


STEP_DECORATORS = [*logging_step_decorators]
4 changes: 4 additions & 0 deletions src/api/deleteCpmProduct/make/make.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from builder.lambda_build import build

if __name__ == "__main__":
build(__file__)
6 changes: 6 additions & 0 deletions src/api/deleteCpmProduct/policies/dynamodb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"dynamodb:Query",
"dynamodb:PutItem",
"dynamodb:UpdateItem",
"dynamodb:DeleteItem"
]
1 change: 1 addition & 0 deletions src/api/deleteCpmProduct/policies/kms.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["kms:Decrypt"]
29 changes: 29 additions & 0 deletions src/api/deleteCpmProduct/src/v1/steps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from http import HTTPStatus

from domain.api.common_steps.read_cpm_product import before_steps, read_product
from domain.core.cpm_product import CpmProduct
from domain.repository.cpm_product_repository import CpmProductRepository


def delete_product(data, cache) -> CpmProduct:
product: CpmProduct = data[read_product]
product_repo: CpmProductRepository = CpmProductRepository(
table_name=cache["DYNAMODB_TABLE"], dynamodb_client=cache["DYNAMODB_CLIENT"]
)
product.delete()
return product_repo.write(product)


def set_http_status(data, cache) -> tuple[int, None]:
product: CpmProduct = data[read_product]
return HTTPStatus.OK, {
"code": "RESOURCE_DELETED",
"message": f"{product.id} has been deleted.",
}


steps = [
*before_steps,
delete_product,
set_http_status,
]
Loading
Loading