From 7c430791f4da63135d47c981a74cb9208b91446b Mon Sep 17 00:00:00 2001 From: Marcus Aspin Date: Thu, 13 Jun 2024 17:27:39 +0100 Subject: [PATCH] PI-2268 Auto-generate AsyncAPI specs (#3897) * PI-2268 Auto-generate AsyncAPI specs * Update schemas --- .github/workflows/docs.yml | 42 +- .../security/CommonSecurityConfigurer.kt | 3 +- libs/messaging/build.gradle.kts | 1 + .../documentation/AsyncApiCommonConfig.kt | 29 + .../AsyncApiReferencingSerializer.kt | 30 + .../digital/hmpps/message/HmppsDomainEvent.kt | 28 +- .../HmppsDomainEventConverterTest.kt | 11 +- .../hmpps/message/HmppsDomainEventTest.kt | 5 +- .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../digital/hmpps/messaging/Handler.kt | 19 + .../source/async-api-reference.html.md.erb | 9 - .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/spec/async-api.yaml | 48 -- .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 30 + .../digital/hmpps/messaging/Handler.kt | 6 + .../digital/hmpps/service/RiskService.kt | 29 +- .../source/asyncapi-reference.html.md.erb | 12 + .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 30 + .../digital/hmpps/messaging/Handler.kt | 17 + .../source/asyncapi-reference.html.md.erb | 12 + .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 30 + .../digital/hmpps/messaging/Handler.kt | 45 ++ .../source/asyncapi-reference.html.md.erb | 12 + .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 30 + .../{api => }/config/RestClientConfig.kt | 2 +- .../digital/hmpps/messaging/Handler.kt | 6 + .../source/asyncapi-reference.html.md.erb | 12 + .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../digital/hmpps/service/CvlHandler.kt | 5 + .../source/async-api-reference.html.md.erb | 9 - .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/spec/async-api.yaml | 23 - .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../digital/hmpps/messaging/Handler.kt | 15 + .../source/async-api-reference.html.md.erb | 9 - .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/spec/async-api.yaml | 128 ----- .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../digital/hmpps/messaging/Handler.kt | 15 + .../source/async-api-reference.html.md.erb | 9 - .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/source/draft-api-spec.yaml | 521 ------------------ .../tech-docs/spec/async-api.yaml | 28 - .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../digital/hmpps/messaging/Handler.kt | 5 + .../source/async-api-reference.html.md.erb | 9 - .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/spec/async-api.yaml | 23 - .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../hmpps/messaging/PomCaseMessageHandler.kt | 10 + .../source/async-api-reference.html.md.erb | 9 - .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/spec/async-api.yaml | 28 - .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 30 + .../digital/hmpps/messaging/Handler.kt | 6 + .../source/asyncapi-reference.html.md.erb | 12 + .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../delius/document/DocumentService.kt | 5 +- .../digital/hmpps/messaging/Handler.kt | 6 +- .../source/async-api-reference.html.md.erb | 9 - .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/spec/async-api.yaml | 23 - .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../digital/hmpps/messaging/Handler.kt | 5 + .../digital/hmpps/messaging/HandlerTest.kt | 4 +- .../source/async-api-reference.html.md.erb | 9 - .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/spec/async-api.yaml | 23 - .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 30 + .../digital/hmpps/messaging/Handler.kt | 22 +- .../digital/hmpps/messaging/HandlerTest.kt | 16 +- .../source/asyncapi-reference.html.md.erb | 12 + .../digital/hmpps/MergeIntegrationTest.kt | 22 +- .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 30 + .../digital/hmpps/messaging/Handler.kt | 30 + .../digital/hmpps/messaging/Notifier.kt | 24 +- .../digital/hmpps/messaging/OffenderEvent.kt | 3 + .../source/asyncapi-reference.html.md.erb | 12 + .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../hmpps/messaging/ReferAndMonitorHandler.kt | 13 + .../hmpps/messaging/FeedbackSubmittedTest.kt | 28 +- .../messaging/ReferAndMonitorHandlerTest.kt | 15 +- .../messaging/ReferralEndSubmittedTest.kt | 17 +- .../source/async-api-reference.html.md.erb | 9 - .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/spec/async-api.yaml | 47 -- .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../digital/hmpps/messaging/Handler.kt | 5 + .../source/async-api-reference.html.md.erb | 9 - .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/spec/async-api.yaml | 23 - .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../upwassessment/UPWAssessmentService.kt | 7 +- .../digital/hmpps/messaging/Handler.kt | 5 + .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/spec/async-api.yaml | 23 - .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 31 ++ .../digital/hmpps/messaging/Handler.kt | 11 + .../source/async-api-reference.html.md.erb | 9 - .../source/asyncapi-reference.html.md.erb | 12 + .../tech-docs/spec/async-api.yaml | 33 -- settings.gradle.kts | 1 + .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 30 + .../digital/hmpps/messaging/Handler.kt | 10 + .../source/asyncapi-reference.html.md.erb | 12 + .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 30 + .../digital/hmpps/messaging/Handler.kt | 10 + .../source/asyncapi-reference.html.md.erb | 12 + .../uk/gov/justice/digital/hmpps/App.kt | 2 + .../digital/hmpps/config/AsyncApiConfig.kt | 30 + .../digital/hmpps/messaging/Handler.kt | 10 + .../source/asyncapi-reference.html.md.erb | 12 + 133 files changed, 1437 insertions(+), 1211 deletions(-) create mode 100644 libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/documentation/AsyncApiCommonConfig.kt create mode 100644 libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/documentation/AsyncApiReferencingSerializer.kt create mode 100644 projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt delete mode 100644 projects/approved-premises-and-delius/tech-docs/source/async-api-reference.html.md.erb create mode 100644 projects/approved-premises-and-delius/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/approved-premises-and-delius/tech-docs/spec/async-api.yaml create mode 100644 projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt create mode 100644 projects/assessment-summary-and-delius/tech-docs/source/asyncapi-reference.html.md.erb create mode 100644 projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt create mode 100644 projects/cas2-and-delius/tech-docs/source/asyncapi-reference.html.md.erb create mode 100644 projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt create mode 100644 projects/cas3-and-delius/tech-docs/source/asyncapi-reference.html.md.erb create mode 100644 projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt rename projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/{api => }/config/RestClientConfig.kt (90%) create mode 100644 projects/court-case-and-delius/tech-docs/source/asyncapi-reference.html.md.erb create mode 100644 projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt delete mode 100644 projects/create-and-vary-a-licence-and-delius/tech-docs/source/async-api-reference.html.md.erb create mode 100644 projects/create-and-vary-a-licence-and-delius/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/create-and-vary-a-licence-and-delius/tech-docs/spec/async-api.yaml create mode 100644 projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt delete mode 100644 projects/custody-key-dates-and-delius/tech-docs/source/async-api-reference.html.md.erb create mode 100644 projects/custody-key-dates-and-delius/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/custody-key-dates-and-delius/tech-docs/spec/async-api.yaml create mode 100644 projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt delete mode 100644 projects/make-recall-decisions-and-delius/tech-docs/source/async-api-reference.html.md.erb create mode 100644 projects/make-recall-decisions-and-delius/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/make-recall-decisions-and-delius/tech-docs/source/draft-api-spec.yaml delete mode 100644 projects/make-recall-decisions-and-delius/tech-docs/spec/async-api.yaml create mode 100644 projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt delete mode 100644 projects/manage-offences-and-delius/tech-docs/source/async-api-reference.html.md.erb create mode 100644 projects/manage-offences-and-delius/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/manage-offences-and-delius/tech-docs/spec/async-api.yaml create mode 100644 projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt delete mode 100644 projects/manage-pom-cases-and-delius/tech-docs/source/async-api-reference.html.md.erb create mode 100644 projects/manage-pom-cases-and-delius/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/manage-pom-cases-and-delius/tech-docs/spec/async-api.yaml create mode 100644 projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt create mode 100644 projects/opd-and-delius/tech-docs/source/asyncapi-reference.html.md.erb create mode 100644 projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt delete mode 100644 projects/pre-sentence-reports-to-delius/tech-docs/source/async-api-reference.html.md.erb create mode 100644 projects/pre-sentence-reports-to-delius/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/pre-sentence-reports-to-delius/tech-docs/spec/async-api.yaml create mode 100644 projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt delete mode 100644 projects/prison-case-notes-to-probation/tech-docs/source/async-api-reference.html.md.erb create mode 100644 projects/prison-case-notes-to-probation/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/prison-case-notes-to-probation/tech-docs/spec/async-api.yaml create mode 100644 projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt create mode 100644 projects/prison-custody-status-to-delius/tech-docs/source/asyncapi-reference.html.md.erb create mode 100644 projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt create mode 100644 projects/prison-identifier-and-delius/tech-docs/source/asyncapi-reference.html.md.erb create mode 100644 projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt delete mode 100644 projects/refer-and-monitor-and-delius/tech-docs/source/async-api-reference.html.md.erb create mode 100644 projects/refer-and-monitor-and-delius/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/refer-and-monitor-and-delius/tech-docs/spec/async-api.yaml create mode 100644 projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt delete mode 100644 projects/tier-to-delius/tech-docs/source/async-api-reference.html.md.erb create mode 100644 projects/tier-to-delius/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/tier-to-delius/tech-docs/spec/async-api.yaml create mode 100644 projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt create mode 100644 projects/unpaid-work-and-delius/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/unpaid-work-and-delius/tech-docs/spec/async-api.yaml create mode 100644 projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt delete mode 100644 projects/workforce-allocations-to-delius/tech-docs/source/async-api-reference.html.md.erb create mode 100644 projects/workforce-allocations-to-delius/tech-docs/source/asyncapi-reference.html.md.erb delete mode 100644 projects/workforce-allocations-to-delius/tech-docs/spec/async-api.yaml create mode 100644 templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt create mode 100644 templates/projects/message-listener-with-api-client-and-server/tech-docs/source/asyncapi-reference.html.md.erb create mode 100644 templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt create mode 100644 templates/projects/message-listener-with-api-client/tech-docs/source/asyncapi-reference.html.md.erb create mode 100644 templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt create mode 100644 templates/projects/message-listener/tech-docs/source/asyncapi-reference.html.md.erb diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0d94eed4f8..19da8d302e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -61,28 +61,36 @@ jobs: bundler-cache: true working-directory: projects/${{ matrix.project }}/tech-docs - - name: Check if OpenAPI is configured + - name: Check if OpenAPI or AsyncAPI is configured id: check_config - run: echo "api_path=$(yq '.api_path' 'projects/${{ matrix.project }}/tech-docs/config/tech-docs.yml')" | tee -a "$GITHUB_OUTPUT" + run: | + echo "has_rest_api=$(yq '. | has("api_path")' 'projects/${{ matrix.project }}/tech-docs/config/tech-docs.yml')" | tee -a "$GITHUB_OUTPUT" + echo "has_async_api=$(test -f 'projects/${{ matrix.project }}/tech-docs/source/asyncapi-reference.html.md.erb' && echo 'true' || echo 'false')" | tee -a "$GITHUB_OUTPUT" + - uses: actions/setup-java@v4 - if: startsWith(steps.check_config.outputs.api_path, 'http') + if: steps.check_config.outputs.has_rest_api == 'true' || steps.check_config.outputs.has_async_api == 'true' with: java-version: '21' distribution: 'temurin' + - uses: gradle/actions/setup-gradle@v3 - if: startsWith(steps.check_config.outputs.api_path, 'http') + if: steps.check_config.outputs.has_rest_api || steps.check_config.outputs.has_async_api with: cache-read-only: true - - name: Host OpenAPI spec - if: startsWith(steps.check_config.outputs.api_path, 'http') + + - name: Host API specs + if: steps.check_config.outputs.has_rest_api == 'true' || steps.check_config.outputs.has_async_api == 'true' run: | ./gradlew '${{ matrix.project }}:bootRun' & timeout 300 sh -c 'until curl -s localhost:8080/v3/api-docs.yaml; do sleep 5; done' - yq -i '.api_path = "http://localhost:8080/v3/api-docs.yaml"' 'projects/${{ matrix.project }}/tech-docs/config/tech-docs.yml' env: SPRING_PROFILES_ACTIVE: dev - - name: Set branch + - name: Update configured OpenAPI path + if: steps.check_config.outputs.has_rest_api == 'true' + run: yq -i '.api_path = "http://localhost:8080/v3/api-docs.yaml"' 'projects/${{ matrix.project }}/tech-docs/config/tech-docs.yml' + + - name: Set branch in index if: github.ref_name != 'main' run: sed -i "s|$REPOSITORY/main|$REPOSITORY/$BRANCH|" index.html.md.erb working-directory: projects/${{ matrix.project }}/tech-docs/source @@ -90,19 +98,33 @@ jobs: REPOSITORY: ${{ github.repository }} BRANCH: ${{ github.ref_name }} + - name: Set branch in asyncapi-reference + if: github.ref_name != 'main' && steps.check_config.outputs.has_async_api == 'true' + run: sed -i "s|/tech-docs/|/tech-docs-drafts/$BRANCH/|" asyncapi-reference.html.md.erb + working-directory: projects/${{ matrix.project }}/tech-docs/source + env: + REPOSITORY: ${{ github.repository }} + BRANCH: ${{ github.ref_name }} + - name: Build run: | gem install middleman bundle exec middleman build --verbose working-directory: projects/${{ matrix.project }}/tech-docs - - name: Bundle API specs - if: startsWith(steps.check_config.outputs.api_path, 'http') + - name: Bundle OpenAPI specs + if: steps.check_config.outputs.has_rest_api == 'true' run: | curl -sf localhost:8080/v3/api-docs -o api-docs.json curl -sf localhost:8080/v3/api-docs.yaml -o api-docs.yaml working-directory: projects/${{ matrix.project }}/tech-docs/build + - name: Bundle AsyncAPI specs + if: steps.check_config.outputs.has_async_api == 'true' + run: | + curl -sf localhost:8080/docs/asyncapi -o asyncapi-docs.json + working-directory: projects/${{ matrix.project }}/tech-docs/build + - uses: actions/upload-artifact@v4 with: name: ${{ matrix.project }} diff --git a/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/CommonSecurityConfigurer.kt b/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/CommonSecurityConfigurer.kt index ad3c79fbf4..f48b643641 100644 --- a/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/CommonSecurityConfigurer.kt +++ b/libs/commons/src/main/kotlin/uk/gov/justice/digital/hmpps/config/security/CommonSecurityConfigurer.kt @@ -14,7 +14,8 @@ class CommonSecurityConfigurer : SecurityConfigurer { AntPathRequestMatcher("/info/**"), AntPathRequestMatcher("/swagger-ui/**"), AntPathRequestMatcher("/v3/api-docs.yaml"), - AntPathRequestMatcher("/v3/api-docs/**") + AntPathRequestMatcher("/v3/api-docs/**"), + AntPathRequestMatcher("/docs/**") ).permitAll().anyRequest().authenticated() } .csrf { it.disable() } diff --git a/libs/messaging/build.gradle.kts b/libs/messaging/build.gradle.kts index 7161d900a4..c11ad1fb8d 100644 --- a/libs/messaging/build.gradle.kts +++ b/libs/messaging/build.gradle.kts @@ -7,6 +7,7 @@ dependencies { compileOnly("org.springframework.boot:spring-boot-starter-data-jpa") api(libs.bundles.aws.messaging) + api(libs.asyncapi) testImplementation(project(":libs:dev-tools")) testImplementation(libs.bundles.mockito) diff --git a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/documentation/AsyncApiCommonConfig.kt b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/documentation/AsyncApiCommonConfig.kt new file mode 100644 index 0000000000..0a926ba210 --- /dev/null +++ b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/documentation/AsyncApiCommonConfig.kt @@ -0,0 +1,29 @@ +package uk.gov.justice.digital.hmpps.documentation + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiCommonConfig { + @Bean + fun asyncApiCommonInfo() = AsyncApiExtension.builder { + info { + title("Async API Reference") + version("1.0") + contact { + name("Probation Integration Team") + email("probation-integration-team@digital.justice.gov.uk") + url("https://mojdt.slack.com/archives/C02HQ4M2YQN") // #probation-integration-tech Slack channel + } + license { + name("MIT") + url("https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/LICENSE") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/") + } + defaultContentType("application/json") + } +} diff --git a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/documentation/AsyncApiReferencingSerializer.kt b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/documentation/AsyncApiReferencingSerializer.kt new file mode 100644 index 0000000000..31a3d339f7 --- /dev/null +++ b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/documentation/AsyncApiReferencingSerializer.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.documentation + +import com.fasterxml.jackson.databind.ObjectMapper +import org.openfolder.kotlinasyncapi.model.AsyncApi +import org.openfolder.kotlinasyncapi.model.channel.* +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiSerializer +import org.springframework.context.annotation.Primary +import org.springframework.stereotype.Component + +@Primary +@Component +class AsyncApiReferencingSerializer(val objectMapper: ObjectMapper) : AsyncApiSerializer { + override fun AsyncApi.serialize(): String = objectMapper.writeValueAsString(this.also { asyncApi -> + asyncApi.components?.channels?.values?.forEach { value -> + val channel = value as Channel + listOfNotNull(channel.publish, channel.subscribe).forEach { it.replaceMessagesWithReferences() } + } + }) + + private fun Operation.replaceMessagesWithReferences() { + val messages = (message as OneOfReferencableMessages?)?.oneOf + val messageNames = messages?.filterIsInstance()?.mapNotNull { it.name } + messageNames?.forEach { messages.replaceWithReference(it) } + } + + private fun ReferencableMessagesList.replaceWithReference(name: String) { + reference { ref("https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/$name.yml") } + removeIf { it is Message && it.name == name } + } +} \ No newline at end of file diff --git a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEvent.kt b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEvent.kt index b18a90ec1d..4a4fe958ba 100644 --- a/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEvent.kt +++ b/libs/messaging/src/main/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEvent.kt @@ -1,21 +1,21 @@ package uk.gov.justice.digital.hmpps.message -import com.fasterxml.jackson.annotation.JsonAlias -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonSetter +import com.fasterxml.jackson.annotation.Nulls +import org.openfolder.kotlinasyncapi.annotation.channel.Message import java.time.ZonedDateTime +@Message data class HmppsDomainEvent( val eventType: String, val version: Int, val detailUrl: String? = null, val occurredAt: ZonedDateTime = ZonedDateTime.now(), val description: String? = null, - @JsonAlias("additionalInformation") private val nullableAdditionalInformation: AdditionalInformation? = AdditionalInformation(), + @JsonSetter(nulls = Nulls.SKIP) + val additionalInformation: Map = emptyMap(), val personReference: PersonReference = PersonReference() -) { - val additionalInformation = nullableAdditionalInformation ?: AdditionalInformation() -} +) data class PersonReference(val identifiers: List = listOf()) { fun findCrn() = get("CRN") @@ -24,17 +24,3 @@ data class PersonReference(val identifiers: List = listOf()) { } data class PersonIdentifier(val type: String, val value: String) - -data class AdditionalInformation( - @JsonAnyGetter @JsonAnySetter - private val info: MutableMap = mutableMapOf() -) { - operator fun get(key: String): Any? = info[key] - operator fun set(key: String, value: Any) { - info[key] = value - } - - fun containsKey(key: String): Boolean { - return info.containsKey(key) - } -} diff --git a/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/converter/HmppsDomainEventConverterTest.kt b/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/converter/HmppsDomainEventConverterTest.kt index e30d4fca29..5b01d1a612 100644 --- a/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/converter/HmppsDomainEventConverterTest.kt +++ b/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/converter/HmppsDomainEventConverterTest.kt @@ -13,12 +13,7 @@ import org.junit.jupiter.api.extension.ExtendWith import org.mockito.junit.jupiter.MockitoExtension import uk.gov.justice.digital.hmpps.datetime.EuropeLondon import uk.gov.justice.digital.hmpps.datetime.ZonedDateTimeDeserializer -import uk.gov.justice.digital.hmpps.message.AdditionalInformation -import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent -import uk.gov.justice.digital.hmpps.message.MessageAttributes -import uk.gov.justice.digital.hmpps.message.Notification -import uk.gov.justice.digital.hmpps.message.PersonIdentifier -import uk.gov.justice.digital.hmpps.message.PersonReference +import uk.gov.justice.digital.hmpps.message.* import java.time.ZonedDateTime @ExtendWith(MockitoExtension::class) @@ -76,7 +71,7 @@ class HmppsDomainEventConverterTest { "http://detail/url", ZonedDateTime.parse("2022-07-27T15:22:08.509+01:00"), "A description for the event", - AdditionalInformation(mutableMapOf("specialId" to "6aafe304-861f-4479-8380-fec5f90f6d17")), + mapOf("specialId" to "6aafe304-861f-4479-8380-fec5f90f6d17"), PersonReference(listOf(PersonIdentifier("CRN", "X123456"))) ), attributes = MessageAttributes("attribute.event.type") @@ -88,7 +83,7 @@ class HmppsDomainEventConverterTest { message, equalTo( """ - |{"Message":"{\"eventType\":\"message.event.type\",\"version\":1,\"detailUrl\":\"http://detail/url\",\"occurredAt\":\"2022-07-27T15:22:08.509+01:00\",\"description\":\"A description for the event\",\"personReference\":{\"identifiers\":[{\"type\":\"CRN\",\"value\":\"X123456\"}]},\"additionalInformation\":{\"specialId\":\"6aafe304-861f-4479-8380-fec5f90f6d17\"}}", + |{"Message":"{\"eventType\":\"message.event.type\",\"version\":1,\"detailUrl\":\"http://detail/url\",\"occurredAt\":\"2022-07-27T15:22:08.509+01:00\",\"description\":\"A description for the event\",\"additionalInformation\":{\"specialId\":\"6aafe304-861f-4479-8380-fec5f90f6d17\"},\"personReference\":{\"identifiers\":[{\"type\":\"CRN\",\"value\":\"X123456\"}]}}", |"MessageAttributes":{"eventType":{"Type":"String","Value":"attribute.event.type"}},"MessageId":"${hmppsEvent.id}"} """.trimMargin().replace("\\n".toRegex(), "") ) diff --git a/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEventTest.kt b/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEventTest.kt index 256eb39ee4..0e5ca31f11 100644 --- a/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEventTest.kt +++ b/libs/messaging/src/test/kotlin/uk/gov/justice/digital/hmpps/message/HmppsDomainEventTest.kt @@ -57,11 +57,10 @@ class HmppsDomainEventTest { "test.event.type", 1, "https//detail/url", - ZonedDateTime.now() + ZonedDateTime.now(), + additionalInformation = mapOf("specialId" to "SP12345") ) - hmppsEvent.additionalInformation["specialId"] = "SP12345" - assertThat(hmppsEvent.additionalInformation["specialId"], equalTo("SP12345")) } } diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..09b22687e0 --- /dev/null +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("approved-premises-and-delius") + info.description("Reflect progress of approved premises referrals in Delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-approved-premises-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-approved-premises-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-approved-premises-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/approved-premises-and-delius/") + } + } +} diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 00150b88d8..e12e71acf9 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,9 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException @@ -10,11 +14,26 @@ import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import java.net.URI @Component +@Channel("approved-premises-and-delius-queue") class Handler( private val telemetryService: TelemetryService, private val approvedPremisesService: ApprovedPremisesService, override val converter: NotificationConverter ) : NotificationHandler { + + @Publish( + messages = [ + Message(name = "approved-premises/application-submitted"), + Message(name = "approved-premises/application-assessed"), + Message(name = "approved-premises/application-withdrawn"), + Message(name = "approved-premises/booking-made"), + Message(name = "approved-premises/booking-changed"), + Message(name = "approved-premises/booking-cancelled"), + Message(messageId = "approved-premises.person.not-arrived", payload = Schema(HmppsDomainEvent::class)), + Message(messageId = "approved-premises.person.arrived", payload = Schema(HmppsDomainEvent::class)), + Message(messageId = "approved-premises.person.departed", payload = Schema(HmppsDomainEvent::class)), + ] + ) override fun handle(notification: Notification) { val event = notification.message try { diff --git a/projects/approved-premises-and-delius/tech-docs/source/async-api-reference.html.md.erb b/projects/approved-premises-and-delius/tech-docs/source/async-api-reference.html.md.erb deleted file mode 100644 index 7b47576d7a..0000000000 --- a/projects/approved-premises-and-delius/tech-docs/source/async-api-reference.html.md.erb +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: AsyncAPI Reference -source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/approved-premises-and-delius/tech-docs/source/async-api-reference.html.md.erb' -weight: 30 ---- - -# ASyncAPI Reference - - diff --git a/projects/approved-premises-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/approved-premises-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..076dd56647 --- /dev/null +++ b/projects/approved-premises-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/approved-premises-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/approved-premises-and-delius/tech-docs/spec/async-api.yaml b/projects/approved-premises-and-delius/tech-docs/spec/async-api.yaml deleted file mode 100644 index fa2c136631..0000000000 --- a/projects/approved-premises-and-delius/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,48 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Approved Premises and Delius - description: Reflect progress of approved premises referrals in Delius - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-approved-premises-and-delius-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-approved-premises-and-delius-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-approved-premises-and-delius-queue - protocol: sqs - -channels: - hmpps-domain-events/approved-premises-and-delius/application-submitted: - subscribe: - operationId: approved-premises.application.submitted - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/approved-premises/application-submitted.yml - hmpps-domain-events/approved-premises-and-delius/application-assessed: - subscribe: - operationId: approved-premises.application.assessed - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/approved-premises/application-assessed.yml - hmpps-domain-events/approved-premises-and-delius/application-withdrawn: - subscribe: - operationId: approved-premises.application.withdrawn - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/approved-premises/application-withdrawn.yml - hmpps-domain-events/approved-premises-and-delius/booking-made: - subscribe: - operationId: approved-premises.booking.made - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/approved-premises/booking-made.yml - hmpps-domain-events/approved-premises-and-delius/booking-not-made: - subscribe: - operationId: approved-premises.booking.not-made - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/approved-premises/booking-not-made.yml - hmpps-domain-events/approved-premises-and-delius/booking-cancelled: - subscribe: - operationId: approved-premises.booking.cancelled - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/approved-premises/booking-cancelled.yml diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..e8a64ad8f5 --- /dev/null +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("assessment-summary-and-delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-assessment-summary-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-assessment-summary-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-assessment-summary-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/assessment-summary-and-delius/") + } + } +} diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index bd929af923..cc3c58d089 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,9 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.flags.FeatureFlags @@ -12,12 +16,14 @@ import java.net.URI const val AssessmentSummaryProduced = "assessment.summary.produced" @Component +@Channel("assessment-summary-and-delius-queue") class Handler( override val converter: NotificationConverter, private val ordsClient: OrdsClient, private val assessmentSubmitted: AssessmentSubmitted, private val featureFlags: FeatureFlags ) : NotificationHandler { + @Publish(messages = [Message(messageId = AssessmentSummaryProduced, payload = Schema(HmppsDomainEvent::class))]) override fun handle(notification: Notification) { if (notification.message.eventType == AssessmentSummaryProduced && featureFlags.enabled("assessment-summary-produced")) { notification.message.detailUrl diff --git a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/RiskService.kt b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/RiskService.kt index 30f400ff4d..442bd64416 100644 --- a/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/RiskService.kt +++ b/projects/assessment-summary-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/RiskService.kt @@ -7,7 +7,6 @@ import uk.gov.justice.digital.hmpps.integrations.delius.contact.entity.ContactTy import uk.gov.justice.digital.hmpps.integrations.delius.person.entity.* import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.entity.ReferenceData import uk.gov.justice.digital.hmpps.integrations.oasys.AssessmentSummary -import uk.gov.justice.digital.hmpps.message.AdditionalInformation import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.PersonIdentifier import uk.gov.justice.digital.hmpps.message.PersonReference @@ -111,14 +110,12 @@ fun Registration.deRegEvent(crn: String): HmppsDomainEvent = HmppsDomainEvent( version = 1, occurredAt = ZonedDateTime.now(), personReference = forCrn(crn), - nullableAdditionalInformation = AdditionalInformation( - listOfNotNull( - "registerTypeCode" to type.code, - "registerTypeDescription" to type.description, - "deregistrationId" to deregistration!!.id, - "deregistrationDate" to deregistration!!.date, - "createdDateAndTime" to deregistration!!.createdDatetime - ).toMap().toMutableMap() + additionalInformation = mapOf( + "registerTypeCode" to type.code, + "registerTypeDescription" to type.description, + "deregistrationId" to deregistration!!.id, + "deregistrationDate" to deregistration!!.date, + "createdDateAndTime" to deregistration!!.createdDatetime ) ) @@ -126,14 +123,12 @@ fun Registration.regEvent(crn: String): HmppsDomainEvent = HmppsDomainEvent( eventType = ReferenceData.Code.REGISTRATION_ADDED.value, version = 1, personReference = forCrn(crn), - nullableAdditionalInformation = AdditionalInformation( - listOfNotNull( - "registrationId" to id, - "registerTypeCode" to type.code, - "registerTypeDescription" to type.description, - "registrationDate" to date, - "createdDateAndTime" to createdDatetime - ).toMap().toMutableMap() + additionalInformation = mapOf( + "registrationId" to id, + "registerTypeCode" to type.code, + "registerTypeDescription" to type.description, + "registrationDate" to date, + "createdDateAndTime" to createdDatetime ) ) diff --git a/projects/assessment-summary-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/assessment-summary-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..be538f5d23 --- /dev/null +++ b/projects/assessment-summary-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/assessment-summary-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..907343896d --- /dev/null +++ b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("cas2-and-delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-cas2-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-cas2-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-cas2-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/cas2-and-delius/") + } + } +} diff --git a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index e1ac390e62..5612c27d37 100644 --- a/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/cas2-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,9 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.beans.factory.annotation.Value import org.springframework.http.HttpStatus import org.springframework.stereotype.Component @@ -12,12 +16,25 @@ import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component +@Channel("cas2-and-delius-queue") class Handler( @Value("\${event.exception.throw-not-found:true}") private val throwNotFound: Boolean, override val converter: NotificationConverter, private val telemetryService: TelemetryService, private val cas2Service: Cas2Service, ) : NotificationHandler { + @Publish( + messages = [ + Message( + messageId = "applications.cas2.application.submitted", + payload = Schema(HmppsDomainEvent::class) + ), + Message( + messageId = "applications.cas2.application.status-updated", + payload = Schema(HmppsDomainEvent::class) + ), + ] + ) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) val event = notification.message diff --git a/projects/cas2-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/cas2-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..866048d0fc --- /dev/null +++ b/projects/cas2-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/cas2-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..856b825bea --- /dev/null +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("cas3-and-delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-cas3-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-cas3-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-cas3-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/cas3-and-delius/") + } + } +} diff --git a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index cd975c4352..9927a9a9ce 100644 --- a/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/cas3-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,9 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import org.springframework.transaction.annotation.Transactional import uk.gov.justice.digital.hmpps.converter.NotificationConverter @@ -17,6 +21,7 @@ import java.net.URI @Component @Transactional +@Channel("cas3-and-delius-queue") class Handler( override val converter: NotificationConverter, private val telemetryService: TelemetryService, @@ -25,6 +30,46 @@ class Handler( private val cas3ApiClient: Cas3ApiClient, private val personRepository: PersonRepository ) : NotificationHandler { + @Publish( + messages = [ + Message( + messageId = "accommodation.cas3.referral.submitted", + payload = Schema(HmppsDomainEvent::class) + ), + Message( + messageId = "accommodation.cas3.booking.cancelled", + payload = Schema(HmppsDomainEvent::class) + ), + Message( + messageId = "accommodation.cas3.booking.confirmed", + payload = Schema(HmppsDomainEvent::class) + ), + Message( + messageId = "accommodation.cas3.booking.provisionally-made", + payload = Schema(HmppsDomainEvent::class) + ), + Message( + messageId = "accommodation.cas3.person.arrived", + payload = Schema(HmppsDomainEvent::class) + ), + Message( + messageId = "accommodation.cas3.person.departed", + payload = Schema(HmppsDomainEvent::class) + ), + Message( + messageId = "accommodation.cas3.person.arrived.updated", + payload = Schema(HmppsDomainEvent::class) + ), + Message( + messageId = "accommodation.cas3.person.departed.updated", + payload = Schema(HmppsDomainEvent::class) + ), + Message( + messageId = "accommodation.cas3.booking.cancelled.updated", + payload = Schema(HmppsDomainEvent::class) + ), + ] + ) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) val event = notification.message diff --git a/projects/cas3-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/cas3-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..344bfc36b3 --- /dev/null +++ b/projects/cas3-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/cas3-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..c69d160496 --- /dev/null +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("court-case-and-delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-court-case-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-court-case-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-court-case-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/court-case-and-delius/") + } + } +} diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/config/RestClientConfig.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/RestClientConfig.kt similarity index 90% rename from projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/config/RestClientConfig.kt rename to projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/RestClientConfig.kt index f7fed2860e..c40ab44e54 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/config/RestClientConfig.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/RestClientConfig.kt @@ -1,4 +1,4 @@ -package uk.gov.justice.digital.hmpps.api.config +package uk.gov.justice.digital.hmpps.config import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration diff --git a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 8caca22c98..c42bc9dbb7 100644 --- a/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/court-case-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,9 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.http.HttpStatus @@ -17,6 +21,7 @@ import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI @Component +@Channel("court-case-and-delius-queue") class Handler( val courtCaseClient: CourtCaseClient, val deliusIntegrationService: DeliusIntegrationService, @@ -28,6 +33,7 @@ class Handler( val log: Logger = LoggerFactory.getLogger(this::class.java) } + @Publish(messages = [Message(messageId = "court-case-note.published", payload = Schema(HmppsDomainEvent::class))]) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) val event = notification.message diff --git a/projects/court-case-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/court-case-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..6b53c29244 --- /dev/null +++ b/projects/court-case-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/court-case-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index 2c6b3789ed..f972f0644f 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,9 +1,11 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication(exclude = [LdapRepositoriesAutoConfiguration::class]) class App diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..e7b9eae832 --- /dev/null +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("create-and-vary-a-licence-and-delius") + info.description("Reflect licence conditions in Delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-create-and-vary-a-licence-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-create-and-vary-a-licence-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-create-and-vary-a-licence-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/create-and-vary-a-licence-and-delius/") + } + } +} diff --git a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CvlHandler.kt b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CvlHandler.kt index 326be35707..a53aa7f364 100644 --- a/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CvlHandler.kt +++ b/projects/create-and-vary-a-licence-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/CvlHandler.kt @@ -1,5 +1,8 @@ package uk.gov.justice.digital.hmpps.service +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent @@ -8,12 +11,14 @@ import uk.gov.justice.digital.hmpps.messaging.NotificationHandler import uk.gov.justice.digital.hmpps.telemetry.TelemetryService @Component +@Channel("create-and-vary-a-licence-and-delius-queue") class CvlHandler( override val converter: NotificationConverter, private val telemetryService: TelemetryService, private val licenceActivatedHandler: LicenceActivatedHandler ) : NotificationHandler { + @Publish(messages = [Message(name = "create-and-vary-a-licence/licence-activated")]) override fun handle(notification: Notification) { val results = when (val eventType = diff --git a/projects/create-and-vary-a-licence-and-delius/tech-docs/source/async-api-reference.html.md.erb b/projects/create-and-vary-a-licence-and-delius/tech-docs/source/async-api-reference.html.md.erb deleted file mode 100644 index 83d30b992e..0000000000 --- a/projects/create-and-vary-a-licence-and-delius/tech-docs/source/async-api-reference.html.md.erb +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: AsyncAPI Reference -source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/create-and-vary-a-licence-and-delius/tech-docs/source/async-api-reference.html.md.erb' -weight: 30 ---- - -# ASyncAPI Reference - - diff --git a/projects/create-and-vary-a-licence-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/create-and-vary-a-licence-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..6b53c29244 --- /dev/null +++ b/projects/create-and-vary-a-licence-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/court-case-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/create-and-vary-a-licence-and-delius/tech-docs/spec/async-api.yaml b/projects/create-and-vary-a-licence-and-delius/tech-docs/spec/async-api.yaml deleted file mode 100644 index 4c75d51401..0000000000 --- a/projects/create-and-vary-a-licence-and-delius/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,23 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Create and Vary a Licence and Delius - description: Reflect licence conditions in Delius - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-create-and-vary-a-licence-and-delius-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-create-and-vary-a-licence-and-delius-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-create-and-vary-a-licence-and-delius-queue - protocol: sqs - -channels: - hmpps-domain-events/create-and-vary-a-licence/licence-activated: - subscribe: - operationId: create-and-vary-a-licence.licence.activated - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/create-and-vary-a-licence/licence-activated.yml diff --git a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..eec2568d23 --- /dev/null +++ b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("custody-key-dates-and-delius") + info.description("Reflect changes to custody key dates in Delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-custody-key-dates-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-custody-key-dates-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-custody-key-dates-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/custody-key-dates-and-delius/") + } + } +} diff --git a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 481c0524f9..69aa5474e9 100644 --- a/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/custody-key-dates-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -2,6 +2,10 @@ package uk.gov.justice.digital.hmpps.messaging import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.context.annotation.Primary import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter @@ -12,11 +16,22 @@ import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component +@Channel("custody-key-dates-and-delius-queue") class Handler( override val converter: KeyDateChangedEventConverter, private val cduService: CustodyDateUpdateService, private val telemetryService: TelemetryService ) : NotificationHandler { + @Publish( + messages = [ + Message(messageId = "probation-case.prison-identifier.added", payload = Schema(HmppsDomainEvent::class)), + Message(messageId = "probation-case.prison-identifier.updated", payload = Schema(HmppsDomainEvent::class)), + Message(messageId = "SENTENCE_DATES-CHANGED", payload = Schema(CustodyDateChanged::class)), + Message(messageId = "CONFIRMED_RELEASE_DATE-CHANGED", payload = Schema(CustodyDateChanged::class)), + Message(messageId = "KEY_DATE_ADJUSTMENT_UPSERTED", payload = Schema(CustodyDateChanged::class)), + Message(messageId = "KEY_DATE_ADJUSTMENT_DELETED", payload = Schema(CustodyDateChanged::class)), + ] + ) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) when (val message = notification.message) { diff --git a/projects/custody-key-dates-and-delius/tech-docs/source/async-api-reference.html.md.erb b/projects/custody-key-dates-and-delius/tech-docs/source/async-api-reference.html.md.erb deleted file mode 100644 index d59b6040cb..0000000000 --- a/projects/custody-key-dates-and-delius/tech-docs/source/async-api-reference.html.md.erb +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: AsyncAPI Reference -source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/custody-key-dates-and-delius/tech-docs/source/async-api-reference.html.md.erb' -weight: 30 ---- - -# ASyncAPI Reference - - diff --git a/projects/custody-key-dates-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/custody-key-dates-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..8dc00cc770 --- /dev/null +++ b/projects/custody-key-dates-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/custody-key-dates-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/custody-key-dates-and-delius/tech-docs/spec/async-api.yaml b/projects/custody-key-dates-and-delius/tech-docs/spec/async-api.yaml deleted file mode 100644 index fd8181494b..0000000000 --- a/projects/custody-key-dates-and-delius/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,128 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Custody Key Dates and Delius - description: Reflect changes to custody key dates in Delius - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-custody-key-dates-and-delius-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-custody-key-dates-and-delius-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-custody-key-dates-and-delius-queue - protocol: sqs - -channels: - hmpps-offender-events/custody-key-dates-and-delius/sentence-dates-changed: - subscribe: - operationId: SENTENCE_DATES-CHANGED - message: - name: Sentence Dates Changed - title: Sentence Dates Changed - summary: Sentence Dates have been updated in NOMIS - contentType: application/json - payload: - type: object - properties: - eventType: - type: string - example: SENTENCE_DATES-CHANGED - eventDateTime: - type: string - example: "2023-10-18T06:38:58Z" - bookingId: - type: integer - example: 1200835 - sentenceCalculationId: - type: integer - example: 5628783 - nomisEventType: - type: string - example: "S2_RESULT" - hmpps-offender-events/custody-key-dates-and-delius/confirmed-release-date-changed: - subscribe: - operationId: CONFIRMED_RELEASE_DATE-CHANGED - message: - name: Confirmed Release Date Changed - title: Confirmed Release Date Changed - summary: Confirmed release date has been updated in NOMIS - contentType: application/json - payload: - type: object - properties: - eventType: - type: string - example: CONFIRMED_RELEASE_DATE-CHANGED - eventDateTime: - type: string - example: "2023-10-18T06:38:58Z" - bookingId: - type: integer - example: 1200835 - hmpps-offender-events/custody-key-dates-and-delius/key-dates-adjusted: - subscribe: - operationId: KEY_DATE_ADJUSTMENT_UPSERTED - message: - name: Key Date Adjustment Changed - title: Key Date Adjustment Changed - summary: Custody key Dates have been updated in NOMIS - contentType: application/json - payload: - type: object - properties: - eventType: - type: string - example: KEY_DATE_ADJUSTMENT_UPSERTED - eventDateTime: - type: string - example: "2023-10-18T06:38:58Z" - bookingId: - type: integer - example: 585671 - offenderIdDisplay: - type: string - example: G9100VF - nomisEventType: - type: string - example: "OFF_KEY_DATES_ADJ-UPDATED" - auditModuleName: - type: string - example: "DPS_SYNCHRONISATION" - adjustmentId: - type: integer - example: 315427 - hmpps-offender-events/custody-key-dates-and-delius/key-dates-adjustment-deleted: - subscribe: - operationId: KEY_DATE_ADJUSTMENT_DELETED - message: - name: Key Date Adjustment Deleted - title: Key Date Adjustment Deleted - summary: Custody key dates have been updated in NOMIS - contentType: application/json - payload: - type: object - properties: - eventType: - type: string - example: KEY_DATE_ADJUSTMENT_DELETED - eventDateTime: - type: string - example: "2023-10-18T06:38:58Z" - bookingId: - type: integer - example: 585671 - offenderIdDisplay: - type: string - example: G9100VF - nomisEventType: - type: string - example: "OFF_KEY_DATES_ADJ-UPDATED" - auditModuleName: - type: string - example: "DPS_SYNCHRONISATION" - adjustmentId: - type: integer - example: 315427 diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index 2c6b3789ed..f972f0644f 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,9 +1,11 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication(exclude = [LdapRepositoriesAutoConfiguration::class]) class App diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..2ec8809186 --- /dev/null +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("make-recall-decisions-and-delius") + info.description("Reflect Activity in the Consider a Recall Service in Delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-make-recall-decisions-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-make-recall-decisions-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-make-recall-decisions-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/make-recall-decisions-and-delius/") + } + } +} diff --git a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 67229fe58c..e4569b0a06 100644 --- a/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/make-recall-decisions-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,9 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.integrations.makerecalldecisions.MakeRecallDecisionsClient @@ -11,12 +15,23 @@ import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI @Component +@Channel("make-recall-decisions-and-delius-queue") class Handler( override val converter: NotificationConverter, private val recommendationService: RecommendationService, private val makeRecallDecisionsClient: MakeRecallDecisionsClient, private val telemetryService: TelemetryService ) : NotificationHandler { + @Publish( + messages = [ + Message(name = "consider-a-recall/management_oversight"), + Message(messageId = "prison-recall.recommendation.deleted", payload = Schema(HmppsDomainEvent::class)), + Message( + messageId = "prison-recall.recommendation.consideration", + payload = Schema(HmppsDomainEvent::class) + ), + ] + ) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) val crn = notification.message.personReference.findCrn() diff --git a/projects/make-recall-decisions-and-delius/tech-docs/source/async-api-reference.html.md.erb b/projects/make-recall-decisions-and-delius/tech-docs/source/async-api-reference.html.md.erb deleted file mode 100644 index 4200b9f7eb..0000000000 --- a/projects/make-recall-decisions-and-delius/tech-docs/source/async-api-reference.html.md.erb +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: AsyncAPI Reference -source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/make-recall-decisions-and-delius/tech-docs/source/async-api-reference.html.md.erb' -weight: 30 ---- - -# ASyncAPI Reference - -* [ASyncAPI Spec](https://studio.asyncapi.com/?url=https://raw.githubusercontent.com/ministryofjustice/hmpps-probation-integration-services/main/projects/make-recall-decisions-and-delius/tech-docs/spec/async-api.yaml&readOnly) diff --git a/projects/make-recall-decisions-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/make-recall-decisions-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..e0352cc259 --- /dev/null +++ b/projects/make-recall-decisions-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/make-recall-decisions-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/make-recall-decisions-and-delius/tech-docs/source/draft-api-spec.yaml b/projects/make-recall-decisions-and-delius/tech-docs/source/draft-api-spec.yaml deleted file mode 100644 index 0f836daa76..0000000000 --- a/projects/make-recall-decisions-and-delius/tech-docs/source/draft-api-spec.yaml +++ /dev/null @@ -1,521 +0,0 @@ -openapi: 3.0.1 -info: - title: API Reference - description: A probation integration service to share data between the Making a Recall Decision API and the Delius probation case management system. - termsOfService: "" - version: "1" -servers: - - description: dev - url: https://make-recall-decisions-and-delius-dev.hmpps.service.justice.gov.uk - - description: preprod - url: https://make-recall-decisions-and-delius-preprod.hmpps.service.justice.gov.uk - - description: prod - url: https://make-recall-decisions-and-delius.hmpps.service.justice.gov.uk -paths: - /case-summary/{crn}/personal-details: - get: - tags: - - Case Summary - summary: Personal details e.g. name, date of birth, address. - parameters: - - name: crn - in: path - description: The CRN (case reference number) - required: true - schema: - type: string - responses: - 200: - description: if the case exists - content: - 'application/json': - schema: - type: object - properties: - personalDetails: - $ref: '#/components/schemas/PersonalDetails' - communityManager: - $ref: '#/components/schemas/CommunityManager' - mainAddress: - $ref: '#/components/schemas/Address' - 404: - description: if the case does not exist, has been soft-deleted, or merged - /case-summary/{crn}/overview: - get: - tags: - - Case Summary - summary: Delius case overview e.g. active events/convictions, register flags. - parameters: - - name: crn - in: path - description: The CRN (case reference number) - required: true - schema: - type: string - responses: - 200: - description: if the case exists - content: - 'application/json': - schema: - $ref: '#/components/schemas/CaseOverview' - 404: - description: if the case does not exist, has been soft-deleted, or merged - /case-summary/{crn}/mappa-and-rosh-history: - get: - tags: - - Case Summary - summary: Current MAPPA and historical RoSH registrations - description:

This is intended to populate the MAPPA (Multi-agency public protection arrangements) and RoSH (Risk of Serious Harm) widgets.

Note that risk assessment information is generally held in OASys, and this endpoint only surfaces supplementary Delius registration/register details. - parameters: - - name: crn - in: path - description: The CRN (case reference number) - required: true - schema: - type: string - responses: - 200: - description: if the case exists - content: - 'application/json': - schema: - $ref: '#/components/schemas/MappaAndRoshHistory' - 404: - description: if the case does not exist, has been soft-deleted, or merged - /case-summary/{crn}/contact-history: - get: - tags: - - Case Summary - summary: Contact history - description: Returns matching historical records from the Delius contact log, including linked documents, and a summary showing the total number of contacts on the case grouped by type. - parameters: - - name: crn - in: path - description: The CRN (case reference number) - required: true - schema: - type: string - - name: query - in: query - description: Search for contacts that contain the provided text - - > If we decide to get this information from the database, then this will be a simple substring match on the notes field. However, we could potentially switch to using the contact search service when it's ready, which would improve the performance and quality of results. - required: false - schema: - type: string - example: e.g. appointment with joe bloggs - - name: from - in: query - description: Return only contacts that start after this date - required: false - schema: - type: string - format: date - example: "2022-06-01" - - name: to - in: query - description: Return only contacts that start before this date. If provided, this value must be on or before the current date. - required: false - schema: - type: string - format: date - example: "2023-01-01" - - name: type - in: query - description: Filter on contact type codes - required: false - schema: - type: array - example: ["COAI", "ROC"] - items: - type: string - - name: includeSystemGenerated - in: query - description: Include (true) or exclude (false) any contact types that are system-generated - required: false - schema: - type: boolean - default: true - responses: - 200: - description: if the case exists - content: - 'application/json': - schema: - type: object - properties: - personalDetails: - $ref: '#/components/schemas/PersonalDetails' - contacts: - type: array - items: - $ref: '#/components/schemas/Contact' - summary: - type: object - properties: - types: - type: array - items: - type: object - properties: - code: - type: string - example: COAI - description: - type: string - example: Initial appointment in office - total: - type: integer - example: 1 - hits: - type: integer - example: 1 - total: - type: integer - example: 123 - 404: - description: if the case does not exist, has been soft-deleted, or merged - /document/{crn}/{id}: - get: - tags: - - Documents - summary: Download document content - parameters: - - name: crn - in: path - description: The CRN (case reference number) - required: true - schema: - type: string - - name: id - in: path - description: The Delius document id - required: true - schema: - type: string - responses: - 200: - description: if the document exists and it belongs to the case - content: - 'application/octet-stream': - example: Document content (e.g. Word or PDF) - 404: - description: if the document does not exist - /case-summary/{crn}/licence-conditions: - get: - tags: - - Case Summary - summary: Active events/convictions, with licence conditions - description: Only returns active licence conditions that are associated to active events/convictions. Licence documents are not returned, as they appear to be unused in the MRD UI - . - parameters: - - name: crn - in: path - description: The CRN (case reference number) - required: true - schema: - type: string - responses: - 200: - description: if the case exists - content: - 'application/json': - schema: - type: object - properties: - personalDetails: - $ref: '#/components/schemas/PersonalDetails' - activeConvictions: - type: array - items: - $ref: '#/components/schemas/EventWithLicenceConditions' - 404: - description: if the case does not exist, has been soft-deleted, or merged -components: - schemas: - Address: - type: object - properties: - buildingName: - type: string - addressNumber: - type: string - streetName: - type: string - town: - type: string - county: - type: string - postcode: - type: string - noFixedAbode: - type: boolean - CaseOverview: - type: object - properties: - personalDetails: - $ref: '#/components/schemas/PersonalDetails' - registerFlags: - type: array - description: List of type.description for active registrations - items: - type: string - example: ["MAPPA 1", "High risk of serious harm"] - lastRelease: - type: object - properties: - releaseDate: - type: string - format: date - recallDate: - type: string - format: date - activeConvictions: - type: array - items: - $ref: '#/components/schemas/Event' - CommunityManager: - type: object - description: Currently active offender_manager - properties: - staffCode: - example: N01A001 - type: string - name: - $ref: '#/components/schemas/Name' - provider: - $ref: '#/components/schemas/Provider' - team: - $ref: '#/components/schemas/Team' - Contact: - type: object - properties: - description: - type: string - example: Initial appointment at Durham office - documents: - type: array - items: - $ref: '#/components/schemas/Document' - enforcementAction: - type: string - example: Refer to manager - notes: - type: string - example: Missed appointment with Joe Bloggs - outcome: - type: string - example: Failed to attend - sensitive: - type: boolean - startDateTime: - type: string - format: date-time - type: - type: object - properties: - code: - type: string - example: COAI - description: - type: string - example: Initial appointment in office - Document: - type: object - properties: - id: - type: number - name: - type: string - Event: - type: object - properties: - number: - example: 4 - type: string - description: - type: string - example: ORA Suspended Sentence Order - mainOffence: - description: Main offence description - example: Burglary - type: string - additionalOffences: - description: List of additional offence descriptions - example: ["Assault"] - type: array - items: - type: string - sentence: - type: object - properties: - length: - type: number - example: 2 - lengthUnits: - type: string - example: Months - isCustodial: - type: boolean - custodialStatusCode: - type: string - example: B - licenceExpiryDate: - type: string - format: date - sentenceExpiryDate: - type: string - format: date - EventWithLicenceConditions: - type: object - properties: - number: - example: 4 - type: string - description: - type: string - example: ORA Suspended Sentence Order - length: - type: number - example: 2 - lengthUnits: - type: string - example: Months - mainOffence: - description: Main offence description - example: Burglary - type: string - additionalOffences: - description: List of additional offence descriptions - example: ["Assault"] - type: array - items: - type: string - isCustodial: - type: boolean - custodialStatusCode: - type: string - example: B - licenceExpiryDate: - type: string - format: date - sentenceExpiryDate: - type: string - format: date - licenceConditions: - type: array - items: - $ref: '#/components/schemas/LicenceCondition' - LicenceCondition: - type: object - properties: - mainCategory: - type: string - example: Freedom of movement - subCategory: - type: string - example: Police escort - notes: - type: string - MappaAndRoshHistory: - type: object - properties: - personalDetails: - $ref: '#/components/schemas/PersonalDetails' - mappa: - description: The first active registration of register type `MAPP` - type: object - properties: - category: - type: integer - example: 2 - level: - type: integer - example: 3 - startDate: - type: string - format: date - roshHistory: - description: Any active or inactive registrations with a register type flag of `1` (RoSH). - type: array - items: - type: object - properties: - active: - type: boolean - example: true - type: - type: string - example: RHRH - typeDescription: - type: string - example: High RoSH - notes: - type: string - startDate: - type: string - format: date - Name: - type: object - properties: - forename: - type: string - middleName: - type: string - surname: - type: string - PersonalDetails: - type: object - properties: - name: - $ref: '#/components/schemas/Name' - identifiers: - type: object - properties: - pncNumber: - type: string - croNumber: - type: string - nomsNumber: - type: string - bookingNumber: - description: Same as mostRecentPrisonerNumber in Community API, this comes from the custody.prisoner_number on the latest disposal - type: string - dateOfBirth: - type: string - format: date - gender: - type: string - example: Female - ethnicity: - type: string - primaryLanguage: - type: string - Provider: - type: object - properties: - code: - type: string - example: N01 - name: - type: string - example: London - Team: - type: object - properties: - code: - type: string - example: N01T01 - name: - type: string - example: Recall team - localAdminUnit: - type: string - description: The team.district.description in the database. This was called localDeliveryUnit in Community API. - example: North London - telephone: - type: string - example: '0123456789' - email: - type: string - example: example@example.com \ No newline at end of file diff --git a/projects/make-recall-decisions-and-delius/tech-docs/spec/async-api.yaml b/projects/make-recall-decisions-and-delius/tech-docs/spec/async-api.yaml deleted file mode 100644 index 36da52f083..0000000000 --- a/projects/make-recall-decisions-and-delius/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,28 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Make Recall Decisions/Consider a Recall and Delius Integration - description: Reflect Activity in the Consider a Recall Service in Delius - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-make-recall-decisions-and-delius-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-make-recall-decisions-and-delius-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-make-recall-decisions-and-delius-queue - protocol: sqs - -channels: - hmpps-domain-events/make-recall-decisions/recommendation-started: - subscribe: - operationId: prison-recall.recommendation.started - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/consider-a-recall/recommendation_started.yml - hmpps-domain-events/make-recall-decisions/management-oversight: - subscribe: - operationId: prison-recall.recommendation.management-oversight - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/consider-a-recall/management_oversight.yml diff --git a/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..7adcd28c09 --- /dev/null +++ b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("manage-offences-and-delius") + info.description("Reflect changes to CJS offence codes in Delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-manage-offences-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-manage-offences-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-manage-offences-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/manage-offences-and-delius/") + } + } +} diff --git a/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index fcdbd986e6..cf0220f692 100644 --- a/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/manage-offences-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,8 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import org.springframework.transaction.annotation.Transactional import uk.gov.justice.digital.hmpps.client.ManageOffencesClient @@ -25,6 +28,7 @@ const val FF_UPDATE_OFFENCE = "manage-offences-update-offence" @Component @Transactional +@Channel("manage-offences-and-delius-queue") class Handler( override val converter: NotificationConverter, private val telemetryService: TelemetryService, @@ -34,6 +38,7 @@ class Handler( private val referenceDataRepository: ReferenceDataRepository, private val featureFlags: FeatureFlags ) : NotificationHandler { + @Publish(messages = [Message(name = "manage-offences/offence-changed")]) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) diff --git a/projects/manage-offences-and-delius/tech-docs/source/async-api-reference.html.md.erb b/projects/manage-offences-and-delius/tech-docs/source/async-api-reference.html.md.erb deleted file mode 100644 index 1a21c8e4b7..0000000000 --- a/projects/manage-offences-and-delius/tech-docs/source/async-api-reference.html.md.erb +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: AsyncAPI Reference -source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/manage-offences-and-delius/tech-docs/source/async-api-reference.html.md.erb' -weight: 30 ---- - -# ASyncAPI Reference - - diff --git a/projects/manage-offences-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/manage-offences-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..676b539ddb --- /dev/null +++ b/projects/manage-offences-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/manage-offences-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/manage-offences-and-delius/tech-docs/spec/async-api.yaml b/projects/manage-offences-and-delius/tech-docs/spec/async-api.yaml deleted file mode 100644 index 9b779937d9..0000000000 --- a/projects/manage-offences-and-delius/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,23 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Manage Offences and Delius - description: Reflect changes to CJS offence codes in Delius - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-manage-offences-and-delius-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-manage-offences-and-delius-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-manage-offences-and-delius-queue - protocol: sqs - -channels: - hmpps-domain-events/manage-offences-and-delius/offence-changed: - subscribe: - operationId: manage-offences.offence.changed - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/manage-offences/offence-changed.yml diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index 2c6b3789ed..f972f0644f 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,9 +1,11 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication(exclude = [LdapRepositoriesAutoConfiguration::class]) class App diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..a91c0ab1a4 --- /dev/null +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("manage-pom-cases-and-delius") + info.description("Reflect changes to POM allocation and handover dates in Delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-manage-pom-cases-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-manage-pom-cases-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-manage-pom-cases-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/manage-pom-cases-and-delius/") + } + } +} diff --git a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/PomCaseMessageHandler.kt b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/PomCaseMessageHandler.kt index 979bec944c..f34a81ee73 100644 --- a/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/PomCaseMessageHandler.kt +++ b/projects/manage-pom-cases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/PomCaseMessageHandler.kt @@ -1,5 +1,8 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent @@ -10,12 +13,19 @@ import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component +@Channel("manage-pom-cases-and-delius-queue") class PomCaseMessageHandler( override val converter: NotificationConverter, private val handoverDatesChanged: HandoverDatesChanged, private val pomAllocated: PomAllocated, private val telemetryService: TelemetryService ) : NotificationHandler { + @Publish( + messages = [ + Message(name = "offender-management/handover-changed"), + Message(name = "offender-management/pom-allocated") + ] + ) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) when (notification.eventType) { diff --git a/projects/manage-pom-cases-and-delius/tech-docs/source/async-api-reference.html.md.erb b/projects/manage-pom-cases-and-delius/tech-docs/source/async-api-reference.html.md.erb deleted file mode 100644 index 309714a492..0000000000 --- a/projects/manage-pom-cases-and-delius/tech-docs/source/async-api-reference.html.md.erb +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: AsyncAPI Reference -source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/manage-pom-cases-and-delius/tech-docs/source/async-api-reference.html.md.erb' -weight: 30 ---- - -# ASyncAPI Reference - - diff --git a/projects/manage-pom-cases-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/manage-pom-cases-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..00695125cf --- /dev/null +++ b/projects/manage-pom-cases-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/manage-pom-cases-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/manage-pom-cases-and-delius/tech-docs/spec/async-api.yaml b/projects/manage-pom-cases-and-delius/tech-docs/spec/async-api.yaml deleted file mode 100644 index d38aa81101..0000000000 --- a/projects/manage-pom-cases-and-delius/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,28 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Manage POM Cases and Delius - description: Reflect changes to POM allocation and handover dates in Delius - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-manage-pom-cases-and-delius-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-manage-pom-cases-and-delius-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-manage-pom-cases-and-delius-queue - protocol: sqs - -channels: - hmpps-domain-events/manage-pom-cases-and-delius/handover-changed: - subscribe: - operationId: offender-management.handover.changed - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/offender-management/handover-changed.yml - hmpps-domain-events/manage-pom-cases-and-delius/allocation-changed: - subscribe: - operationId: offender-management.pom.allocated - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/offender-management/pom-allocated.yml diff --git a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..00a4bf7e9a --- /dev/null +++ b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("opd-and-delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-opd-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-opd-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-opd-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/opd-and-delius/") + } + } +} diff --git a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 8736ac4c8c..7b8b1ff067 100644 --- a/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/opd-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,9 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.datetime.DeliusDateTimeFormatter @@ -16,12 +20,14 @@ const val FeatureFlag = "opd-assessment-processing" const val OpdProduced = "opd.produced" @Component +@Channel("opd-and-delius-queue") class Handler( override val converter: NotificationConverter, private val telemetryService: TelemetryService, private val opdService: OpdService, private val featureFlags: FeatureFlags ) : NotificationHandler { + @Publish(messages = [Message(messageId = OpdProduced, payload = Schema(HmppsDomainEvent::class))]) override fun handle(notification: Notification) { if (notification.message.eventType != OpdProduced) return val opdAssessment = notification.message.opdAssessment() diff --git a/projects/opd-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/opd-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..e23be9d38b --- /dev/null +++ b/projects/opd-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/opd-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..c902d8baac --- /dev/null +++ b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("pre-sentence-reports-to-delius") + info.description("Trigger Upload of Pre-Sentence Report to Delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-pre-sentence-reports-to-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-pre-sentence-reports-to-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-pre-sentence-reports-to-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/pre-sentence-reports-to-delius/") + } + } +} diff --git a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentService.kt b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentService.kt index 191549256f..e9d325378d 100644 --- a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentService.kt +++ b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/document/DocumentService.kt @@ -14,7 +14,6 @@ import uk.gov.justice.digital.hmpps.integrations.alfresco.AlfrescoUploadClient import uk.gov.justice.digital.hmpps.integrations.delius.audit.BusinessInteractionCode import uk.gov.justice.digital.hmpps.integrations.delius.audit.entity.User import uk.gov.justice.digital.hmpps.integrations.delius.courtreport.CourtReportRepository -import uk.gov.justice.digital.hmpps.message.AdditionalInformation import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.security.ServiceContext import java.time.ZonedDateTime @@ -26,12 +25,12 @@ class DocumentService( private val courtReportRepository: CourtReportRepository, private val alfrescoUploadClient: AlfrescoUploadClient ) : AuditableService(auditedInteractionService) { - fun AdditionalInformation.reportId() = this["reportId"] as String + fun HmppsDomainEvent.reportId() = additionalInformation["reportId"] as String @Transactional fun updateCourtReportDocument(hmppsEvent: HmppsDomainEvent, file: ByteArray) = audit(BusinessInteractionCode.UPLOAD_DOCUMENT) { - val reportId = hmppsEvent.additionalInformation.reportId() + val reportId = hmppsEvent.reportId() val document = documentRepository.findByExternalReference(reportId) ?: throw NotFoundException("Document", "externalReference", reportId) it["documentId"] = document.id diff --git a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index dee3affc06..d719e27da3 100644 --- a/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/pre-sentence-reports-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,8 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.integrations.delius.document.DocumentService @@ -11,13 +14,14 @@ import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI @Component +@Channel("pre-sentence-reports-to-delius-queue") class Handler( private val telemetryService: TelemetryService, private val psrClient: PsrClient, private val documentService: DocumentService, override val converter: NotificationConverter ) : NotificationHandler { - + @Publish(messages = [Message(name = "pre-sentence/pre-sentence_report_completed")]) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) val hmppsEvent = notification.message diff --git a/projects/pre-sentence-reports-to-delius/tech-docs/source/async-api-reference.html.md.erb b/projects/pre-sentence-reports-to-delius/tech-docs/source/async-api-reference.html.md.erb deleted file mode 100644 index fcca306485..0000000000 --- a/projects/pre-sentence-reports-to-delius/tech-docs/source/async-api-reference.html.md.erb +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: AsyncAPI Reference -source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/pre-sentence-reports-to-delius/tech-docs/source/async-api-reference.html.md.erb' -weight: 30 ---- - -# ASyncAPI Reference - -* [ASyncAPI Spec](https://studio.asyncapi.com/?url=https://raw.githubusercontent.com/ministryofjustice/hmpps-probation-integration-services/main/projects/pre-sentence-reports-to-delius/tech-docs/spec/async-api.yaml&readOnly) diff --git a/projects/pre-sentence-reports-to-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/pre-sentence-reports-to-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..9601f36791 --- /dev/null +++ b/projects/pre-sentence-reports-to-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/pre-sentence-reports-to-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/pre-sentence-reports-to-delius/tech-docs/spec/async-api.yaml b/projects/pre-sentence-reports-to-delius/tech-docs/spec/async-api.yaml deleted file mode 100644 index 9834aac9d8..0000000000 --- a/projects/pre-sentence-reports-to-delius/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,23 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Pre-Sentence Report Upload - description: Trigger Upload of Pre-Sentence Report to Delius - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-pre-sentence-reports-to-delius-queue-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-pre-sentence-reports-to-delius-queue-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-pre-sentence-reports-to-delius-queue-queue - protocol: sqs - -channels: - hmpps-domain-events/pre-sentence: - subscribe: - operationId: pre-sentence.report.completed - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/pre-sentence/pre-sentence_report_completed.yml diff --git a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..af8c91098c --- /dev/null +++ b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("prison-case-notes-to-probation") + info.description("Import Prison Case Notes to the Delius Contact Log") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-prison-case-notes-to-probation-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-prison-case-notes-to-probation-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-prison-case-notes-to-probation-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/prison-case-notes-to-probation/") + } + } +} diff --git a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 2d49ee36cf..a46e348940 100644 --- a/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/prison-case-notes-to-probation/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,8 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.http.HttpStatus @@ -20,6 +23,7 @@ import java.net.URI const val ProcessResettlementPassport = "case-note-resettlement-passport" @Component +@Channel("prison-case-notes-to-probation-queue") class Handler( val prisonCaseNotesClient: PrisonCaseNotesClient, val deliusService: DeliusService, @@ -32,6 +36,7 @@ class Handler( val log: Logger = LoggerFactory.getLogger(this::class.java) } + @Publish(messages = [Message(name = "prison/case-note-published")]) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) val event = notification.message diff --git a/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index a4278160a7..ab922ece5b 100644 --- a/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/projects/prison-case-notes-to-probation/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -18,7 +18,6 @@ import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.delius.service.DeliusService import uk.gov.justice.digital.hmpps.integrations.prison.PrisonCaseNote import uk.gov.justice.digital.hmpps.integrations.prison.PrisonCaseNotesClient -import uk.gov.justice.digital.hmpps.message.AdditionalInformation import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.prepMessage @@ -131,8 +130,7 @@ internal class HandlerTest { @Test fun `get case note from NOMIS has null caseNoteId`() { val message = prepMessage(CaseNoteMessageGenerator.EXISTS_IN_DELIUS).message - val prisonOffenderEvent = - Notification(message = message.copy(nullableAdditionalInformation = AdditionalInformation())) + val prisonOffenderEvent = Notification(message = message.copy(additionalInformation = emptyMap())) handler.handle(prisonOffenderEvent) verify(deliusService, times(0)).mergeCaseNote(any()) verify(prisonCaseNotesClient, times(0)).getCaseNote(any()) diff --git a/projects/prison-case-notes-to-probation/tech-docs/source/async-api-reference.html.md.erb b/projects/prison-case-notes-to-probation/tech-docs/source/async-api-reference.html.md.erb deleted file mode 100644 index 74ba8b94f3..0000000000 --- a/projects/prison-case-notes-to-probation/tech-docs/source/async-api-reference.html.md.erb +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: AsyncAPI Reference -source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/prison-case-notes-to-probation/tech-docs/source/async-api-reference.html.md.erb' -weight: 30 ---- - -# ASyncAPI Reference - - diff --git a/projects/prison-case-notes-to-probation/tech-docs/source/asyncapi-reference.html.md.erb b/projects/prison-case-notes-to-probation/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..96deed8a56 --- /dev/null +++ b/projects/prison-case-notes-to-probation/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/prison-case-notes-to-probation/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/prison-case-notes-to-probation/tech-docs/spec/async-api.yaml b/projects/prison-case-notes-to-probation/tech-docs/spec/async-api.yaml deleted file mode 100644 index 3a7cab50ef..0000000000 --- a/projects/prison-case-notes-to-probation/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,23 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Prison Case Notes to Probation - description: Import Prison Case Notes to the Delius Contact Log - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-prison-case-notes-to-probation-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-prison-case-notes-to-probation-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-prison-case-notes-to-probation-queue - protocol: sqs - -channels: - hmpps-domain-events/prison-case-notes-to-probation/prison.case-note.published: - subscribe: - operationId: prison.case-note.published - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/prison/case-note-published.yml diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index 91c5062239..29eee61e17 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,10 +1,12 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.boot.runApplication import uk.gov.justice.digital.hmpps.messaging.PrisonerMovementConfigs +@EnableAsyncApi @EnableConfigurationProperties(PrisonerMovementConfigs::class) @SpringBootApplication class App diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..4306f0b65f --- /dev/null +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("prison-custody-status-to-delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-prison-custody-status-to-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-prison-custody-status-to-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-prison-custody-status-to-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/prison-custody-status-to-delius/") + } + } +} diff --git a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 3e95ce2788..5a3509df92 100644 --- a/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/prison-custody-status-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,9 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import org.springframework.transaction.annotation.Transactional import uk.gov.justice.digital.hmpps.converter.NotificationConverter @@ -9,7 +13,6 @@ import uk.gov.justice.digital.hmpps.flags.FeatureFlags import uk.gov.justice.digital.hmpps.integrations.prison.Booking import uk.gov.justice.digital.hmpps.integrations.prison.Movement import uk.gov.justice.digital.hmpps.integrations.prison.PrisonApiClient -import uk.gov.justice.digital.hmpps.message.AdditionalInformation import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.messaging.DomainEventType.* @@ -18,6 +21,7 @@ import java.time.ZonedDateTime @Component @Transactional(noRollbackFor = [IgnorableMessageException::class]) +@Channel("prison-custody-status-to-delius-queue") class Handler( configContainer: PrisonerMovementConfigs, private val featureFlags: FeatureFlags, @@ -28,6 +32,14 @@ class Handler( ) : NotificationHandler { private val configs = configContainer.configs + @Publish( + messages = [ + Message(messageId = "prison-offender-events.prisoner.released", payload = Schema(HmppsDomainEvent::class)), + Message(messageId = "prison-offender-events.prisoner.received", payload = Schema(HmppsDomainEvent::class)), + Message(messageId = "probation-case.prison-identifier.added", payload = Schema(HmppsDomainEvent::class)), + Message(messageId = "probation-case.prison-identifier.updated", payload = Schema(HmppsDomainEvent::class)), + ] + ) override fun handle(notification: Notification) { val message = notification.message val eventType = DomainEventType.of(message.eventType) @@ -106,13 +118,13 @@ class Handler( ?: throw IgnorableMessageException("BookingInactive", mapOf("nomsNumber" to nomsId)) } -fun AdditionalInformation.prisonId() = this["prisonId"] as String? -fun AdditionalInformation.details() = this["details"] as String? +fun HmppsDomainEvent.prisonId() = additionalInformation["prisonId"] as String? +fun HmppsDomainEvent.details() = additionalInformation["details"] as String? fun HmppsDomainEvent.telemetryProperties() = listOfNotNull( "occurredAt" to occurredAt.toString(), "nomsNumber" to personReference.findNomsNumber()!!, - additionalInformation.prisonId()?.let { "institution" to it }, - additionalInformation.details()?.let { "details" to it } + prisonId()?.let { "institution" to it }, + details()?.let { "details" to it } ).toMap() fun PrisonerMovement?.telemetryProperties(): Map = if (this == null) { diff --git a/projects/prison-custody-status-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt b/projects/prison-custody-status-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt index 55609daf09..561e7363f1 100644 --- a/projects/prison-custody-status-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt +++ b/projects/prison-custody-status-to-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/HandlerTest.kt @@ -67,14 +67,12 @@ internal class HandlerTest { 1, "https//detail/url", ZonedDateTime.now(), - nullableAdditionalInformation = AdditionalInformation( - mutableMapOf( - "nomsNumber" to "Z0001ZZ", - "prisonId" to "ZZZ", - "reason" to "RETURN_FROM_COURT", - "nomisMovementReasonCode" to "OPA", - "details" to "CRT-OPA" - ) + additionalInformation = mapOf( + "nomsNumber" to "Z0001ZZ", + "prisonId" to "ZZZ", + "reason" to "RETURN_FROM_COURT", + "nomisMovementReasonCode" to "OPA", + "details" to "CRT-OPA" ), personReference = PersonReference(listOf(PersonIdentifier("NOMS", "Z0001ZZ"))) ), @@ -275,7 +273,7 @@ internal class HandlerTest { val hospitalNotification = notification.copy( message = notification.message.copy( - nullableAdditionalInformation = AdditionalInformation(mutableMapOf("nomsNumber" to nomsId)) + additionalInformation = mapOf("nomsNumber" to nomsId) ) ) handler.handle(hospitalNotification) diff --git a/projects/prison-custody-status-to-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/prison-custody-status-to-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..c93219ea8a --- /dev/null +++ b/projects/prison-custody-status-to-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/prison-custody-status-to-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MergeIntegrationTest.kt b/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MergeIntegrationTest.kt index 959863dad4..eece2daaeb 100644 --- a/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MergeIntegrationTest.kt +++ b/projects/prison-identifier-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MergeIntegrationTest.kt @@ -47,8 +47,15 @@ internal class MergeIntegrationTest { @Test fun `logs event if the new noms number is already assigned`() { - val event = prepEvent("prisoner-merged", wireMockServer.port()).apply { - message.additionalInformation["nomsNumber"] = PERSON_WITH_NOMS.nomsNumber!! + val event = prepEvent("prisoner-merged", wireMockServer.port()).let { + it.copy( + it.message.copy( + additionalInformation = mapOf( + "nomsNumber" to PERSON_WITH_NOMS.nomsNumber!!, + "removedNomsNumber" to "A0007AA", + ) + ) + ) } channelManager.getChannel(queueName).publishAndWait(event) @@ -63,8 +70,15 @@ internal class MergeIntegrationTest { @Test fun `merge ignored if the old noms number is not in Delius`() { - val event = prepEvent("prisoner-merged", wireMockServer.port()).apply { - message.additionalInformation["removedNomsNumber"] = "Z9999ZZ" + val event = prepEvent("prisoner-merged", wireMockServer.port()).let { + it.copy( + it.message.copy( + additionalInformation = mapOf( + "nomsNumber" to "B0007BB", + "removedNomsNumber" to "Z9999ZZ" + ) + ) + ) } channelManager.getChannel(queueName).publishAndWait(event) diff --git a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..647746eb79 --- /dev/null +++ b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("prison-identifier-and-delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-prison-identifier-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-prison-identifier-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-prison-identifier-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/prison-identifier-and-delius/") + } + } +} diff --git a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index f96ebfb02b..62712b5fdd 100644 --- a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,9 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent @@ -11,12 +15,38 @@ import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component +@Channel("prison-identifier-and-delius-queue") class Handler( override val converter: NotificationConverter, private val telemetryService: TelemetryService, private val probationMatchingService: ProbationMatchingService, private val prisonMatchingService: PrisonMatchingService, ) : NotificationHandler { + @Publish( + messages = [ + Message( + messageId = "prison-offender-events.prisoner.sentence-dates-changed", + payload = Schema(HmppsDomainEvent::class) + ), + Message( + messageId = "prison-offender-events.prisoner.imprisonment-status-changed", + payload = Schema(HmppsDomainEvent::class) + ), + Message(messageId = "prison-offender-events.prisoner.merged", payload = Schema(HmppsDomainEvent::class)), + Message(messageId = "OFFENDER_DETAILS_CHANGED", payload = Schema(OffenderEvent::class)), + Message(messageId = "SENTENCE_CHANGED", payload = Schema(OffenderEvent::class)), + Message( + messageId = "prison-identifier.internal.prison-match-requested", + summary = "Internal use - attempt to match a case", + payload = Schema(HmppsDomainEvent::class) + ), + Message( + messageId = "prison-identifier.internal.probation-match-requested", + summary = "Internal use - attempt to match a case", + payload = Schema(HmppsDomainEvent::class) + ), + ] + ) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) when (val message = notification.message) { diff --git a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Notifier.kt b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Notifier.kt index 100486a9f2..35940e79a1 100644 --- a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Notifier.kt +++ b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Notifier.kt @@ -1,6 +1,10 @@ package uk.gov.justice.digital.hmpps.messaging import jakarta.transaction.Transactional +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Subscribe import org.springframework.beans.factory.annotation.Qualifier import org.springframework.scheduling.annotation.Async import org.springframework.stereotype.Service @@ -11,6 +15,7 @@ import uk.gov.justice.digital.hmpps.publisher.NotificationPublisher import kotlin.streams.asSequence @Service +@Channel("hmpps-domain-events-topic") class Notifier( private val personRepository: PersonRepository, @Qualifier("queuePublisher") private val queuePublisher: NotificationPublisher, @@ -42,6 +47,12 @@ class Notifier( .forEach { queuePublisher.publish(it) } } + @Subscribe( + messages = [ + Message(messageId = "probation-case.prison-identifier.added", payload = Schema(HmppsDomainEvent::class)), + Message(messageId = "probation-case.prison-identifier.updated", payload = Schema(HmppsDomainEvent::class)), + ] + ) fun identifierAdded(crn: String, prisonIdentifiers: PrisonIdentifiers) { topicPublisher.publish( Notification( @@ -55,13 +66,8 @@ class Notifier( PersonIdentifier("NOMS", prisonIdentifiers.prisonerNumber), ), ), - nullableAdditionalInformation = prisonIdentifiers.bookingNumber?.let { - AdditionalInformation( - info = mutableMapOf( - "bookingNumber" to it - ) - ) - } + additionalInformation = prisonIdentifiers.bookingNumber?.let { mapOf("bookingNumber" to it) } + ?: emptyMap() ), attributes = MessageAttributes("probation-case.prison-identifier.added") ) @@ -81,7 +87,7 @@ class Notifier( PersonIdentifier("NOMS", nomsNumber), ), ), - nullableAdditionalInformation = AdditionalInformation(info = mutableMapOf("previousNomsNumber" to previousNomsNumber)), + additionalInformation = mapOf("previousNomsNumber" to previousNomsNumber) ), attributes = MessageAttributes("probation-case.prison-identifier.updated") ) @@ -93,7 +99,7 @@ class Notifier( message = HmppsDomainEvent( eventType = eventType, version = 1, - nullableAdditionalInformation = AdditionalInformation(mutableMapOf("dryRun" to dryRun)), + additionalInformation = mapOf("dryRun" to dryRun), personReference = PersonReference(listOf(identifier)) ), attributes = MessageAttributes(eventType) diff --git a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/OffenderEvent.kt b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/OffenderEvent.kt index 846af81242..8a0a18a7a7 100644 --- a/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/OffenderEvent.kt +++ b/projects/prison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/OffenderEvent.kt @@ -1,5 +1,8 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Message + +@Message data class OffenderEvent( val crn: String, ) diff --git a/projects/prison-identifier-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/prison-identifier-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..c39853db16 --- /dev/null +++ b/projects/prison-identifier-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/prison-identifier-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index 2c6b3789ed..f972f0644f 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,9 +1,11 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication(exclude = [LdapRepositoriesAutoConfiguration::class]) class App diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..7c65654fc8 --- /dev/null +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("refer-and-monitor-and-delius") + info.description("Reflect progress of interventions in Delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-refer-and-monitor-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-refer-and-monitor-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-refer-and-monitor-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/refer-and-monitor-and-delius/") + } + } +} diff --git a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandler.kt b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandler.kt index 6da09dfbad..f723f852b3 100644 --- a/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandler.kt +++ b/projects/refer-and-monitor-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandler.kt @@ -1,5 +1,8 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.exception.UnprocessableException @@ -9,6 +12,7 @@ import uk.gov.justice.digital.hmpps.messaging.EventProcessingResult.* import uk.gov.justice.digital.hmpps.telemetry.TelemetryService @Component +@Channel("refer-and-monitor-and-delius-queue") class ReferAndMonitorHandler( override val converter: NotificationConverter, private val telemetryService: TelemetryService, @@ -17,6 +21,15 @@ class ReferAndMonitorHandler( private val eventHandlers: Map EventProcessingResult> = eventHandlers.flatMap { it.handledEvents.entries }.associate { it.key to it.value } + @Publish( + messages = [ + Message(name = "refer-and-monitor/action-plan-submitted"), + Message(name = "refer-and-monitor/action-plan-approved"), + Message(name = "refer-and-monitor/initial-assessment-appointment-feedback-submitted"), + Message(name = "refer-and-monitor/session-appointment-feedback-submitted"), + Message(name = "refer-and-monitor/referral-ended"), + ] + ) override fun handle(notification: Notification) { requireNotNull(notification.message.detailUrl) { "Detail Url Missing" } val event = DomainEventType.of(notification.eventType ?: notification.message.eventType) diff --git a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/FeedbackSubmittedTest.kt b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/FeedbackSubmittedTest.kt index a762d783d3..dd4dbb25ac 100644 --- a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/FeedbackSubmittedTest.kt +++ b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/FeedbackSubmittedTest.kt @@ -11,13 +11,7 @@ import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.argumentCaptor import org.mockito.kotlin.verify import org.mockito.kotlin.whenever -import uk.gov.justice.digital.hmpps.integrations.randm.Appointment -import uk.gov.justice.digital.hmpps.integrations.randm.AppointmentFeedback -import uk.gov.justice.digital.hmpps.integrations.randm.AttendanceFeedback -import uk.gov.justice.digital.hmpps.integrations.randm.ReferAndMonitorClient -import uk.gov.justice.digital.hmpps.integrations.randm.SessionFeedback -import uk.gov.justice.digital.hmpps.integrations.randm.SupplierAssessment -import uk.gov.justice.digital.hmpps.message.AdditionalInformation +import uk.gov.justice.digital.hmpps.integrations.randm.* import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.PersonIdentifier import uk.gov.justice.digital.hmpps.message.PersonReference @@ -26,7 +20,7 @@ import uk.gov.justice.digital.hmpps.service.Attended import uk.gov.justice.digital.hmpps.service.UpdateAppointmentOutcome import java.net.URI import java.time.ZonedDateTime -import java.util.UUID +import java.util.* @ExtendWith(MockitoExtension::class) internal class FeedbackSubmittedTest { @@ -49,16 +43,14 @@ internal class FeedbackSubmittedTest { DomainEventType.InitialAppointmentSubmitted.name, 1, "https://interventions-service/referral/$referralId/supplier-assessment", - nullableAdditionalInformation = AdditionalInformation( - mutableMapOf( - "serviceUserCRN" to crn, - "referralId" to referralId.toString(), - "referralReference" to referralReference, - "contractTypeName" to contractTypeName, - "primeProviderName" to primeProviderName, - "deliusAppointmentId" to deliusAppointmentId.toString(), - "referralProbationUserURL" to "http://url/pp/$referralId/supplier-assessment" - ) + additionalInformation = mapOf( + "serviceUserCRN" to crn, + "referralId" to referralId.toString(), + "referralReference" to referralReference, + "contractTypeName" to contractTypeName, + "primeProviderName" to primeProviderName, + "deliusAppointmentId" to deliusAppointmentId.toString(), + "referralProbationUserURL" to "http://url/pp/$referralId/supplier-assessment" ), personReference = PersonReference(listOf(PersonIdentifier("CRN", crn))) ) diff --git a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandlerTest.kt b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandlerTest.kt index 1ef26aa964..fd891edef3 100644 --- a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandlerTest.kt +++ b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferAndMonitorHandlerTest.kt @@ -13,16 +13,11 @@ import org.mockito.kotlin.eq import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import uk.gov.justice.digital.hmpps.converter.NotificationConverter -import uk.gov.justice.digital.hmpps.message.AdditionalInformation -import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent -import uk.gov.justice.digital.hmpps.message.MessageAttributes -import uk.gov.justice.digital.hmpps.message.Notification -import uk.gov.justice.digital.hmpps.message.PersonIdentifier -import uk.gov.justice.digital.hmpps.message.PersonReference +import uk.gov.justice.digital.hmpps.message.* import uk.gov.justice.digital.hmpps.messaging.DomainEventType.SessionAppointmentSubmitted import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import java.time.ZonedDateTime -import java.util.UUID +import java.util.* @ExtendWith(MockitoExtension::class) internal class ReferAndMonitorHandlerTest { @@ -144,11 +139,7 @@ internal class ReferAndMonitorHandlerTest { 1, occurredAt = ZonedDateTime.now(), detailUrl = "DetailUrl", - nullableAdditionalInformation = AdditionalInformation( - mutableMapOf( - "referralId" to UUID.randomUUID().toString() - ) - ), + additionalInformation = mapOf("referralId" to UUID.randomUUID().toString()), personReference = PersonReference(listOf(PersonIdentifier("CRN", "T123456"))) ), MessageAttributes(SessionAppointmentSubmitted.name) diff --git a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferralEndSubmittedTest.kt b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferralEndSubmittedTest.kt index ee73126729..cbfba4e2f8 100644 --- a/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferralEndSubmittedTest.kt +++ b/projects/refer-and-monitor-and-delius/src/test/kotlin/uk/gov/justice/digital/hmpps/messaging/ReferralEndSubmittedTest.kt @@ -16,7 +16,6 @@ import org.mockito.kotlin.never import org.mockito.kotlin.verify import org.mockito.kotlin.whenever import uk.gov.justice.digital.hmpps.integrations.randm.ReferAndMonitorClient -import uk.gov.justice.digital.hmpps.message.AdditionalInformation import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.PersonIdentifier import uk.gov.justice.digital.hmpps.message.PersonReference @@ -42,11 +41,7 @@ internal class ReferralEndSubmittedTest { DomainEventType.ReferralEnded.name, 1, "https://fake.org/url", - nullableAdditionalInformation = AdditionalInformation( - mutableMapOf( - "referralId" to UUID.randomUUID().toString() - ) - ), + additionalInformation = mapOf("referralId" to UUID.randomUUID().toString()), personReference = PersonReference(listOf(PersonIdentifier("CRN", "T123456"))) ) @@ -77,12 +72,10 @@ internal class ReferralEndSubmittedTest { 1, "https://fake.org/url", personReference = PersonReference(listOf(PersonIdentifier("CRN", "T123456"))), - nullableAdditionalInformation = AdditionalInformation( - mutableMapOf( - "referralURN" to UUID.randomUUID().toString(), - "deliveryState" to "CANCELLED", - "referralProbationUserURL" to "https://fake.ui/index.html" - ) + additionalInformation = mapOf( + "referralURN" to UUID.randomUUID().toString(), + "deliveryState" to "CANCELLED", + "referralProbationUserURL" to "https://fake.ui/index.html" ) ) val referral = sentReferral.copy(endRequestedAt = null, concludedAt = null) diff --git a/projects/refer-and-monitor-and-delius/tech-docs/source/async-api-reference.html.md.erb b/projects/refer-and-monitor-and-delius/tech-docs/source/async-api-reference.html.md.erb deleted file mode 100644 index 2bd2546eb4..0000000000 --- a/projects/refer-and-monitor-and-delius/tech-docs/source/async-api-reference.html.md.erb +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: AsyncAPI Reference -source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/refer-and-monitor-and-delius/tech-docs/source/async-api-reference.html.md.erb' -weight: 30 ---- - -# ASyncAPI Reference - - diff --git a/projects/refer-and-monitor-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/refer-and-monitor-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..effd8694a2 --- /dev/null +++ b/projects/refer-and-monitor-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/refer-and-monitor-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/refer-and-monitor-and-delius/tech-docs/spec/async-api.yaml b/projects/refer-and-monitor-and-delius/tech-docs/spec/async-api.yaml deleted file mode 100644 index 3616c3c0ff..0000000000 --- a/projects/refer-and-monitor-and-delius/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,47 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Refer & Monitor and Delius - description: Reflect progress of interventions in Delius - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-refer-and-monitor-and-delius-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-refer-and-monitor-and-delius-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-refer-and-monitor-and-delius-queue - protocol: sqs - -channels: - hmpps-domain-events/interventions/action-plan-submitted: - subscribe: - operationId: intervention.action-plan.submitted - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/refer-and-monitor/action-plan-submitted.yml - - hmpps-domain-events/interventions/action-plan-approved: - subscribe: - operationId: intervention.action-plan.approved - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/refer-and-monitor/action-plan-approved.yml - - hmpps-domain-events/interventions/initial-assessment-appointment-feedback-submitted: - subscribe: - operationId: intervention.initial-assessment-appointment.session-feedback-submitted - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/refer-and-monitor/initial-assessment-appointment-feedback-submitted.yml - - hmpps-domain-events/interventions/session-appointment-feedback-submitted: - subscribe: - operationId: intervention.session-appointment.session-feedback-submitted - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/refer-and-monitor/session-appointment-feedback-submitted.yml - - hmpps-domain-events/interventions/referral-ended: - subscribe: - operationId: intervention.referral.ended - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/refer-and-monitor/referral-ended.yml diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..c100e10340 --- /dev/null +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("tier-to-delius") + info.description("Reflect new management tier calculations in Delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-tier-to-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-tier-to-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-tier-to-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/tier-to-delius/") + } + } +} diff --git a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 284101ef31..332a4074e5 100644 --- a/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/tier-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,8 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.integrations.tier.TierCalculation @@ -12,12 +15,14 @@ import uk.gov.justice.digital.hmpps.telemetry.notificationReceived import java.net.URI @Component +@Channel("tier-to-delius-queue") class Handler( private val telemetryService: TelemetryService, private val tierClient: TierClient, private val tierService: TierService, override val converter: NotificationConverter ) : NotificationHandler { + @Publish(messages = [Message(name = "tiering/tier_calculation_complete")]) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) val crn = notification.message.personReference.findCrn()!! diff --git a/projects/tier-to-delius/tech-docs/source/async-api-reference.html.md.erb b/projects/tier-to-delius/tech-docs/source/async-api-reference.html.md.erb deleted file mode 100644 index 74b17e2807..0000000000 --- a/projects/tier-to-delius/tech-docs/source/async-api-reference.html.md.erb +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: AsyncAPI Reference -source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/tier-to-delius/tech-docs/source/async-api-reference.html.md.erb' -weight: 30 ---- - -# ASyncAPI Reference - -* [ASyncAPI Spec](https://studio.asyncapi.com/?url=https://raw.githubusercontent.com/ministryofjustice/hmpps-probation-integration-services/main/projects/tier-to-delius/tech-docs/spec/async-api.yaml&readOnly) diff --git a/projects/tier-to-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/tier-to-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..f45cb6f895 --- /dev/null +++ b/projects/tier-to-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/tier-to-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/tier-to-delius/tech-docs/spec/async-api.yaml b/projects/tier-to-delius/tech-docs/spec/async-api.yaml deleted file mode 100644 index 45398acd73..0000000000 --- a/projects/tier-to-delius/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,23 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Tier to Delius - description: Reflect new management tier calculations in Delius - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-tier-to-delius-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-tier-to-delius-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-tier-to-delius-queue - protocol: sqs - -channels: - hmpps-domain-events/tier-to-delius/tier-calculation-complete: - subscribe: - operationId: tier.calculation.complete - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/tiering/tier_calculation_complete.yml diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..e1bd468a0a --- /dev/null +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("unpaid-work-and-delius") + info.description("Upload of Unpaid Work Assessment Document to Delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-unpaid-work-and-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-unpaid-work-and-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-unpaid-work-and-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/unpaid-work-and-delius/") + } + } +} diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/upwassessment/UPWAssessmentService.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/upwassessment/UPWAssessmentService.kt index 073c898179..690e0a7bfa 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/upwassessment/UPWAssessmentService.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/upwassessment/UPWAssessmentService.kt @@ -9,7 +9,6 @@ import uk.gov.justice.digital.hmpps.integrations.arn.ArnClient import uk.gov.justice.digital.hmpps.integrations.common.entity.person.PersonWithManager import uk.gov.justice.digital.hmpps.integrations.common.entity.person.PersonWithManagerRepository import uk.gov.justice.digital.hmpps.integrations.document.DocumentService -import uk.gov.justice.digital.hmpps.message.AdditionalInformation import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent import uk.gov.justice.digital.hmpps.message.Notification import uk.gov.justice.digital.hmpps.telemetry.TelemetryService @@ -23,7 +22,7 @@ class UPWAssessmentService( private val eventRepository: EventRepository, private val arnClient: ArnClient ) { - fun AdditionalInformation.episodeId() = this["episodeId"] as String + fun HmppsDomainEvent.episodeId() = additionalInformation["episodeId"] as String fun processMessage(notification: Notification) { val crn = notification.message.personReference.findCrn()!! @@ -37,7 +36,7 @@ class UPWAssessmentService( private fun uploadDocument(notification: Notification, person: PersonWithManager, eventId: Long) { // get the episode id from the message then get the document content from the UPW/ARN Service - val episodeId = notification.message.additionalInformation.episodeId() + val episodeId = notification.message.episodeId() val response = arnClient.getUPWAssessment(URI(notification.message.detailUrl!!)) val reg = Regex("[^A-Za-z0-9-. ]") val filename = "${person.forename}-${person.surname}-${person.crn}-UPW.pdf".replace(reg, "") @@ -60,7 +59,7 @@ class UPWAssessmentService( return telemetryService.trackEvent( "DuplicateMessageReceived", mapOf( - "episodeId" to notification.message.additionalInformation.episodeId(), + "episodeId" to notification.message.episodeId(), "crn" to notification.message.personReference.findCrn()!! ) ) diff --git a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index 9219bea402..b53006b390 100644 --- a/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/unpaid-work-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,8 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.integrations.upwassessment.UPWAssessmentService @@ -9,12 +12,14 @@ import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component +@Channel("unpaid-work-and-delius-queue") class Handler( override val converter: NotificationConverter, private val telemetryService: TelemetryService, private val upwAssessmentService: UPWAssessmentService ) : NotificationHandler { + @Publish(messages = [Message(name = "unpaid-work/unpaid-work_assessment_completed")]) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) upwAssessmentService.processMessage(notification) diff --git a/projects/unpaid-work-and-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/unpaid-work-and-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..cf806575c8 --- /dev/null +++ b/projects/unpaid-work-and-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/unpaid-work-and-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/unpaid-work-and-delius/tech-docs/spec/async-api.yaml b/projects/unpaid-work-and-delius/tech-docs/spec/async-api.yaml deleted file mode 100644 index 2b82e4f096..0000000000 --- a/projects/unpaid-work-and-delius/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,23 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Unpaid Work Document Upload - description: Upload of Unpaid Work Assessment Document to Delius - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-unpaid-work-and-delius-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-unpaid-work-and-delius-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-unpaid-work-and-delius-queue - protocol: sqs - -channels: - hmpps-domain-events/unpaid-work: - subscribe: - operationId: unpaid-work.assessment.completed - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/unpaid-work/unpaid-work_assessment_completed.yml diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index 2c6b3789ed..f972f0644f 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,9 +1,11 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication(exclude = [LdapRepositoriesAutoConfiguration::class]) class App diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..fb3f498536 --- /dev/null +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,31 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension(asyncApiCommonInfo: AsyncApiExtension) = AsyncApiExtension.builder(order = 1) { + info.title("workforce-allocations-to-delius") + info.description("Reflect allocation of people on probation, events and requirements to probation practitioners in Delius") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-workforce-allocations-to-delius-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-workforce-allocations-to-delius-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-workforce-allocations-to-delius-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/workforce-allocations-to-delius/") + } + } +} diff --git a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index e6d07cdcc7..cb46e3cf9d 100644 --- a/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/projects/workforce-allocations-to-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,8 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.exception.IgnorableMessageException @@ -14,6 +17,7 @@ import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import java.net.URI.create @Component +@Channel("workforce-allocations-to-delius-queue") class Handler( private val allocationsClient: WorkforceAllocationsClient, private val allocatePersonService: AllocatePersonService, @@ -22,6 +26,13 @@ class Handler( private val telemetryService: TelemetryService, override val converter: NotificationConverter ) : NotificationHandler { + @Publish( + messages = [ + Message(name = "workforce/person_allocation"), + Message(name = "workforce/event_allocation"), + Message(name = "workforce/requirement_allocation"), + ] + ) override fun handle(notification: Notification) { val allocationEvent = notification.message val detailUrl = checkNotNull(allocationEvent.detailUrl) diff --git a/projects/workforce-allocations-to-delius/tech-docs/source/async-api-reference.html.md.erb b/projects/workforce-allocations-to-delius/tech-docs/source/async-api-reference.html.md.erb deleted file mode 100644 index 3b409d7004..0000000000 --- a/projects/workforce-allocations-to-delius/tech-docs/source/async-api-reference.html.md.erb +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: AsyncAPI Reference -source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/workforce-allocations-to-delius/tech-docs/source/async-api-reference.html.md.erb' -weight: 30 ---- - -# ASyncAPI Reference - -* [ASyncAPI Spec](https://studio.asyncapi.com/?url=https://raw.githubusercontent.com/ministryofjustice/hmpps-probation-integration-services/main/projects/workforce-allocations-to-delius/tech-docs/spec/async-api.yaml&readOnly) diff --git a/projects/workforce-allocations-to-delius/tech-docs/source/asyncapi-reference.html.md.erb b/projects/workforce-allocations-to-delius/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..8805dedce9 --- /dev/null +++ b/projects/workforce-allocations-to-delius/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/workforce-allocations-to-delius/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/projects/workforce-allocations-to-delius/tech-docs/spec/async-api.yaml b/projects/workforce-allocations-to-delius/tech-docs/spec/async-api.yaml deleted file mode 100644 index c0ed7e5f69..0000000000 --- a/projects/workforce-allocations-to-delius/tech-docs/spec/async-api.yaml +++ /dev/null @@ -1,33 +0,0 @@ -asyncapi: 2.6.0 -info: - title: Workforce Allocations to Delius - description: Reflect allocation of people on probation, events and requirements to probation practitioners in Delius - version: 0.1.0 - -servers: - development: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-workforce-allocations-to-delius-queue - protocol: sqs - preproduction: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-workforce-allocations-to-delius-queue - protocol: sqs - production: - url: https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-workforce-allocations-to-delius-queue - protocol: sqs - -channels: - hmpps-domain-events/workforce-allocations-to-delius/person-allocation: - subscribe: - operationId: person.community.manager.allocated - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/workforce/person_allocation.yml - hmpps-domain-events/workforce-allocations-to-delius/event-allocation: - subscribe: - operationId: event.manager.allocated - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/workforce/event_allocation.yml - hmpps-domain-events/workforce-allocations-to-delius/requirement-allocation: - subscribe: - operationId: requirement.manager.allocated - message: - $ref: https://raw.githubusercontent.com/ministryofjustice/hmpps-domain-events/main/spec/schemas/workforce/requirement_allocation.yml diff --git a/settings.gradle.kts b/settings.gradle.kts index 6bac357218..1bc2f233b2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -87,6 +87,7 @@ dependencyResolutionManagement { ) bundle("telemetry", listOf("insights", "opentelemetry-annotations", "sentry")) library("springdoc", "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0") + library("asyncapi", "org.openfolder:kotlin-asyncapi-spring-web:3.0.3") library("wiremock", "org.wiremock:wiremock-standalone:3.6.0") library("flipt", "io.flipt:flipt-java:1.1.1") } diff --git a/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..7336a243eb --- /dev/null +++ b/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension() = AsyncApiExtension.builder(order = 1) { + info.title("$SERVICE_NAME") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-$SERVICE_NAME-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-$SERVICE_NAME-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-$SERVICE_NAME-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/$SERVICE_NAME/") + } + } +} diff --git a/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index b3f03191d7..0107ffb74c 100644 --- a/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/templates/projects/message-listener-with-api-client-and-server/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,7 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent @@ -8,10 +10,18 @@ import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component +@Channel("$SERVICE_NAME-queue") class Handler( override val converter: NotificationConverter, private val telemetryService: TelemetryService ) : NotificationHandler { + @Publish( + messages = [ + // TODO list the event types here that this service will subscribe to. For example, + // Message(name = "approved-premises/application-assessed"), + // Message(messageId = "probation-case.prison-identifier.added"), + ] + ) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) TODO("Not yet implemented") diff --git a/templates/projects/message-listener-with-api-client-and-server/tech-docs/source/asyncapi-reference.html.md.erb b/templates/projects/message-listener-with-api-client-and-server/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..c05cfdfb05 --- /dev/null +++ b/templates/projects/message-listener-with-api-client-and-server/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/$SERVICE_NAME/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..7336a243eb --- /dev/null +++ b/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension() = AsyncApiExtension.builder(order = 1) { + info.title("$SERVICE_NAME") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-$SERVICE_NAME-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-$SERVICE_NAME-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-$SERVICE_NAME-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/$SERVICE_NAME/") + } + } +} diff --git a/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index b3f03191d7..0107ffb74c 100644 --- a/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/templates/projects/message-listener-with-api-client/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,7 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent @@ -8,10 +10,18 @@ import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component +@Channel("$SERVICE_NAME-queue") class Handler( override val converter: NotificationConverter, private val telemetryService: TelemetryService ) : NotificationHandler { + @Publish( + messages = [ + // TODO list the event types here that this service will subscribe to. For example, + // Message(name = "approved-premises/application-assessed"), + // Message(messageId = "probation-case.prison-identifier.added"), + ] + ) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) TODO("Not yet implemented") diff --git a/templates/projects/message-listener-with-api-client/tech-docs/source/asyncapi-reference.html.md.erb b/templates/projects/message-listener-with-api-client/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..c05cfdfb05 --- /dev/null +++ b/templates/projects/message-listener-with-api-client/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/$SERVICE_NAME/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + + diff --git a/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt b/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt index c7faac5b26..fe1c2e7f71 100644 --- a/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt +++ b/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/App.kt @@ -1,8 +1,10 @@ package uk.gov.justice.digital.hmpps +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@EnableAsyncApi @SpringBootApplication class App diff --git a/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt b/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt new file mode 100644 index 0000000000..7336a243eb --- /dev/null +++ b/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/config/AsyncApiConfig.kt @@ -0,0 +1,30 @@ +package uk.gov.justice.digital.hmpps.config + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +class AsyncApiConfig { + @Bean + fun asyncApiExtension() = AsyncApiExtension.builder(order = 1) { + info.title("$SERVICE_NAME") + servers { + server("dev") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-dev-$SERVICE_NAME-queue") + protocol("sqs") + } + server("preprod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-preprod-$SERVICE_NAME-queue") + protocol("sqs") + } + server("prod") { + url("https://sqs.eu-west-2.amazonaws.com/754256621582/probation-integration-prod-$SERVICE_NAME-queue") + protocol("sqs") + } + } + externalDocs { + url("https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/$SERVICE_NAME/") + } + } +} diff --git a/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt b/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt index b3f03191d7..0107ffb74c 100644 --- a/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt +++ b/templates/projects/message-listener/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Handler.kt @@ -1,5 +1,7 @@ package uk.gov.justice.digital.hmpps.messaging +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Publish import org.springframework.stereotype.Component import uk.gov.justice.digital.hmpps.converter.NotificationConverter import uk.gov.justice.digital.hmpps.message.HmppsDomainEvent @@ -8,10 +10,18 @@ import uk.gov.justice.digital.hmpps.telemetry.TelemetryService import uk.gov.justice.digital.hmpps.telemetry.notificationReceived @Component +@Channel("$SERVICE_NAME-queue") class Handler( override val converter: NotificationConverter, private val telemetryService: TelemetryService ) : NotificationHandler { + @Publish( + messages = [ + // TODO list the event types here that this service will subscribe to. For example, + // Message(name = "approved-premises/application-assessed"), + // Message(messageId = "probation-case.prison-identifier.added"), + ] + ) override fun handle(notification: Notification) { telemetryService.notificationReceived(notification) TODO("Not yet implemented") diff --git a/templates/projects/message-listener/tech-docs/source/asyncapi-reference.html.md.erb b/templates/projects/message-listener/tech-docs/source/asyncapi-reference.html.md.erb new file mode 100644 index 0000000000..c05cfdfb05 --- /dev/null +++ b/templates/projects/message-listener/tech-docs/source/asyncapi-reference.html.md.erb @@ -0,0 +1,12 @@ +--- +title: AsyncAPI Reference +source_url: 'https://github.com/ministryofjustice/hmpps-probation-integration-services/blob/main/projects/$SERVICE_NAME/tech-docs/source/asyncapi-reference.html.md.erb' +weight: 30 +--- + +# AsyncAPI Reference + + + + +