Skip to content

DEFRA/pha-import-notifications

Repository files navigation

Defra PHA Import Notifications

This service provides Port Health Authorities (PHAs) access to a mixture of IPAFFS, ALVS, CDS and GVMS data.

The solution supplies an endpoint for querying for updated records within a certain time period and then provides the ability to retrieve all the data for those records.

Prerequisites

The solution requires:

  • .NET 9

    brew tap isen-ng/dotnet-sdk-versions
    brew install --cask dotnet-sdk9
  • Docker (optional)

Installation

  1. Clone this repository
  2. Install the required tools with dotnet tool restore
  3. Check the solution builds with dotnet build
  4. Check the service builds with docker build .

Running

  1. Run the application via your favourite IDE or via Docker:
    docker build -t pha-import-notifications .
    docker run -p 8080:8080 \
     -e ASPNETCORE_ENVIRONMENT=Development \
     -e ENVIRONMENT=Local \
     pha-import-notifications
    
  2. Navigate to http://localhost:8080/redoc

Endpoints

The endpoints are detailed in the OpenAPI spec which is available either via the Redoc URL, or alternatively via the OpenAPI Spec URL.

A JWT is required to authenticate the user when making requests.
A local one can be generated by running ./scripts/generate-jwt.sh and then including it as a Bearer token in the Authorization header.

Get all updated import notifications within a time period:

http://localhost:8080/import-notifications?bcp=BCP1&from=2025-02-12T12:00:00+00:00&to=2025-02-12T12:30:00+00:00

Get an import notification:

http://localhost:8080/import-notifications/CHEDA.GB.2024.4792831

Update Trade Imports Data Schema

When a schema change in Trade Data Imports is made we need to update our models.

At the moment this is a manual process:

  1. Fetch the openapi.json artifact from the latest build of trade-imports-data-api
  2. In the PHA API repository, extract and copy this to the tools/SchemaToCSharp folder
  3. Run make update-tradeimportsdataapi-schema in the root of the repository
  4. Observe any changes that have been made and commit them

Update Trade Imports Data Stub Scenarios

Following a schema change, we need to update the response JSON that Trade Imports Data will give us.

At the moment this is a manual process:

  1. Checkout main from trade-imports-data-api
  2. Locate the integration test called ShouldImportPhaStubScenario
  3. Update the test so it will save the generated output
  4. Understand and act on any redaction work needed before committing anything
  5. Run the test and take the output from the generated PhaScenarioTestsOutput folder
  6. Replace the TradeImportsDataApiStub/Scenarios folder in this repo with the contents of the folder above
  7. Do the same for the Trade Imports Data Stub Scenarios
  8. Observe any changes that have been made and commit them

Development

It is possible to configure the PHA API to query a deployed Trade Imports Data instance.

Fill out the TradeImportsDataApiOptions configuration to point at a Trade Imports Data instance and then perform a request to the PHA API whilst connected to the VPN.

The Username and Password are Basic Auth credentials.

Testing

The unit and integration tests can either be run via your IDE or alternatively with dotnet test .

A SonarCloud setup will run static analysis on the code when raising a PR.

Linting

We use CSharpier to lint our code.

You can run the linter with dotnet csharpier check .

License

This project is licensed under The Open Government Licence (OGL) Version 3.
See the LICENSE for more details.

About

Git repository for service pha-import-notifications

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 8

Languages