Skip to content

Commit

Permalink
PI-1508 Migrate to the new Delius integration API (#1515)
Browse files Browse the repository at this point in the history
This is part of the move to deprecate Community API. The new API endpoints used in this PR are provided by the dedicated integration service for [HDC Licences and Delius](https://ministryofjustice.github.io/hmpps-probation-integration-services/tech-docs/projects/hdc-licences-and-delius/api-reference.html). The data returned by this API should be the same as before, but please reach out to us on Slack at [#probation-integration-tech](https://moj.enterprise.slack.com/archives/C02HQ4M2YQN) if you see any problems.
  • Loading branch information
marcus-bcl authored Nov 24, 2023
1 parent f3f525c commit d7b0cd9
Show file tree
Hide file tree
Showing 28 changed files with 278 additions and 465 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
ENABLE_TEST_UTILS: true
NOMIS_API_URL: http://localhost:8080/prisonApi
NOMIS_AUTH_URL: http://hmpps-auth:9090/auth
DELIUS_API_URL: http://localhost:8080/communityapi
DELIUS_API_URL: http://localhost:8080/delius
PROBATION_TEAMS_API_URL: http://localhost:8080/probationteams
TOKENVERIFICATION_API_ENABLED: false
GOTENBERG_API_URL: http://localhost:3001
Expand Down
2 changes: 1 addition & 1 deletion Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ For,

```
CA and DM: prisonApi, /offender-sentences/home-detention-curfew-candidates -> OffenderSentenceCalc
RO: deliusApi, /staff/staffCode/${deliusStaffCode}/managedOffenders -> OffenderSummary
RO: deliusApi, /staff/${deliusStaffCode}/managedPrisonerIds -> OffenderSummary
```

Every row links to a taskList: hdc/taskList/:bookingId
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ To run locally you need:
- redis
- auth server
- nomis
- community api
- delius api
- probation teams
- gotenberg
- nomis-user-roles-api
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
NOMIS_AUTH_EXTERNAL_URL: "http://localhost:9090/auth"
TOKENVERIFICATION_API_URL: "http://token-verification-api:8080"
NOMIS_API_URL: "http://stubs:3000/prisonApi"
DELIUS_API_URL: "http://stubs:3000/communityapi"
DELIUS_API_URL: "http://stubs:3000/delius"
PROBATION_TEAMS_API_URL: "http://stubs:3000/probationteams"
HDC_URL: "http://licences:3000"
GOTENBERG_API_URL: "http://gotenberg:3000"
Expand Down
3 changes: 1 addition & 2 deletions feature.env
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ ADMIN_API_CLIENT_ID=licencesadmin
ADMIN_API_CLIENT_SECRET=clientsecret

# DELIUS API
DELIUS_API_URL=http://localhost:8080/communityapi
DELIUS_API_URL=http://localhost:8080/delius
DELIUS_AUTH_URL=http://localhost:9090/auth
DELIUS_API_CLIENT_ID=licencesadmin
DELIUS_API_CLIENT_SECRET=clientsecret
DELIUS_API_PREFIX=/api
DELIUS_RO_ROLE_ID=LHDCBT002
DELIUS_RO_VARY_ROLE_ID=LHDCBT003

Expand Down
3 changes: 0 additions & 3 deletions helm_deploy/licences/templates/_envs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ env:
- name: DELIUS_API_URL
value: {{ .Values.env.DELIUS_API_URL | quote }}

- name: DELIUS_API_PREFIX
value: {{ .Values.env.DELIUS_API_PREFIX | quote }}

- name: PROBATION_TEAMS_API_URL
value: {{ .Values.env.PROBATION_TEAMS_API_URL | quote }}

Expand Down
3 changes: 1 addition & 2 deletions helm_deploy/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ env:
SCHEDULED_JOBS_OVERLAP: "5000"
NOTIFY_ACTIVE_TEMPLATES: "CA_RETURN,CA_DECISION,RO_NEW,RO_TWO_DAYS,RO_DUE,RO_OVERDUE,DM_NEW,DM_TO_CA_RETURN"
RO_SERVICE_TYPE: "DELIUS"
DELIUS_API_URL: "https://community-api-secure.test.delius.probation.hmpps.dsd.io"
DELIUS_API_PREFIX: "/secure"
DELIUS_API_URL: "https://hdc-licences-and-delius-dev.hmpps.service.justice.gov.uk"
PROBATION_TEAMS_API_URL: "https://probation-teams-dev.prison.service.justice.gov.uk"
PRISONER_SEARCH_API_URL: "https://prisoner-search-dev.prison.service.justice.gov.uk"
EXIT_LOCATION_URL: "https://digital-dev.prison.service.justice.gov.uk/"
Expand Down
3 changes: 1 addition & 2 deletions helm_deploy/values-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ env:
SCHEDULED_JOBS_AUTOSTART: "yes"
SCHEDULED_JOBS_OVERLAP: "5000"
NOTIFY_ACTIVE_TEMPLATES: "CA_RETURN,CA_DECISION,RO_NEW,DM_NEW,DM_TO_CA_RETURN"
DELIUS_API_URL: "https://community-api-secure.pre-prod.delius.probation.hmpps.dsd.io"
DELIUS_API_PREFIX: "/secure"
DELIUS_API_URL: "https://hdc-licences-and-delius-preprod.hmpps.service.justice.gov.uk"
PROBATION_TEAMS_API_URL: "https://probation-teams-preprod.prison.service.justice.gov.uk"
PRISONER_SEARCH_API_URL: "https://prisoner-search-preprod.prison.service.justice.gov.uk"
EXIT_LOCATION_URL: "https://digital-preprod.prison.service.justice.gov.uk/"
Expand Down
3 changes: 1 addition & 2 deletions helm_deploy/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ env:
SCHEDULED_JOBS_AUTOSTART: "yes"
SCHEDULED_JOBS_OVERLAP: "5000"
NOTIFY_ACTIVE_TEMPLATES: "CA_RETURN,CA_DECISION,RO_NEW,DM_NEW,DM_TO_CA_RETURN"
DELIUS_API_URL: "https://community-api-secure.probation.service.justice.gov.uk"
DELIUS_API_PREFIX: "/secure"
DELIUS_API_URL: "https://hdc-licences-and-delius.hmpps.service.justice.gov.uk"
PROBATION_TEAMS_API_URL: "https://probation-teams.prison.service.justice.gov.uk"
PRISONER_SEARCH_API_URL: "https://prisoner-search.prison.service.justice.gov.uk"
EXIT_LOCATION_URL: "https://digital.prison.service.justice.gov.uk/"
Expand Down
4 changes: 2 additions & 2 deletions mock-server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ app.use('/prisonApi/api/agencies', agenciesRouter)
app.use('/prisonApi/api/movements', movementsRouter)
app.use('/prisonApi/api/prisoners', prisonersRouter)

app.use('/communityapi/api', deliusRouter)
app.use('/delius', deliusRouter)
app.use('/probationteams', probationteamsRouter)

app.get('/prisonApi/health/ping', (req, res) => {
Expand All @@ -53,7 +53,7 @@ app.get('/probationteams/health/ping', (req, res) => {
res.send({ status: 'UP' })
})

app.get('/communityapi/health/ping', (req, res) => {
app.get('/delius/health/ping', (req, res) => {
res.send('pong')
})

Expand Down
110 changes: 44 additions & 66 deletions mock-server/routes/delius.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ const teamC01T04 = {
code: 'C01T04',
description: 'OMU A',
telephone: '01234567890',
localDeliveryUnit: { code: 'ABC124', description: 'ABC124 delivery unit' },
district: { code: 'D', description: 'E' },
borough: { code: 'F', description: 'G' },
localAdminUnit: { code: 'ABC124', description: 'ABC124 delivery unit' },
}

const deliusTeams = [teamC01T04]

const AUTH_RO_USER_TEST = {
username: 'AUTH_RO_USER_TEST',
staffCode: 'DELIUS_ID_TEST',
staffIdentifier: 1,
code: 'DELIUS_ID_TEST',
staffId: 1,
email: '[email protected]',
staff: {
name: {
forenames: 'FIRSTA',
surname: 'LASTA',
},
Expand All @@ -26,10 +24,10 @@ const AUTH_RO_USER_TEST = {

const RO_USER_TEST = {
username: 'RO_USER_TEST',
staffCode: 'AUTH_DELIUS_ID_TEST',
staffIdentifier: 2,
code: 'AUTH_DELIUS_ID_TEST',
staffId: 2,
email: '[email protected]',
staff: {
name: {
forenames: 'FIRSTA',
surname: 'LASTA',
},
Expand All @@ -38,10 +36,10 @@ const RO_USER_TEST = {

const RO_USER = {
username: 'RO_USER',
staffCode: 'DELIUS_ID',
staffIdentifier: 3,
code: 'DELIUS_ID',
staffId: 3,
email: '[email protected]',
staff: {
name: {
forenames: 'JESSY',
surname: 'SMITH',
},
Expand Down Expand Up @@ -69,14 +67,22 @@ const staffDetailsByStaffIdentifier = {

const router = express.Router()

router.get('/staff/username/:username', (req, res) => {
const { username } = req.params
const staffDetails = staffDetailsByUsername[username]
if (staffDetails) {
res.send(staffDetails)
} else {
res.sendStatus(404)
router.get('/staff', (req, res) => {
const { username, id } = req.query
if (username) {
const staffDetails = staffDetailsByUsername[username]
if (staffDetails) {
res.send(staffDetails)
return
}
} else if (id) {
const staffDetails = staffDetailsByStaffIdentifier[id]
if (staffDetails) {
res.send(staffDetails)
return
}
}
res.sendStatus(404)
})

/*
Expand Down Expand Up @@ -112,55 +118,23 @@ router.get('/staff/staffCode/:staffCode/managedOffenders', (req, res) => {
})
*/

router.get('/staff/staffIdentifier/:staffIdentifier', (req, res) => {
const { staffIdentifier } = req.params
const staffDetails = staffDetailsByStaffIdentifier[staffIdentifier]
if (staffDetails) {
res.send(staffDetails)
} else {
res.sendStatus(404)
}
})

router.get('/staff/staffIdentifier/:staffIdentifier/managedOffenders', (req, res) => {
const { staffIdentifier } = req.params

const offenders = [
{
staffIdentifier,
offenderId: 1234567,
nomsNumber: 'A5001DY',
crnNumber: 1234567,
offenderSurname: 'Andrews',
isCurrentRo: true,
isCurrentOm: true,
isCurrentPom: true,
omStartDate: '01/01/2001',
omEndDate: '01/01/2001',
},
]

res.send(offenders)
router.get('/managedPrisonerIds', (req, res) => {
res.send(['A5001DY'])
})

router.get('/offenders/nomsNumber/:nomsNumber/allOffenderManagers', (req, res) => {
const ros = [
{
isPrisonOffenderManager: false,
isUnallocated: false,
isResponsibleOfficer: true,
staff: { forenames: 'Ryan', surname: 'Orton' },
staffCode: 'DELIUS_ID',
staffId: 2,
team: teamC01T04,
probationArea: { code: 'ABC', description: 'ABC probation area' },
},
]

res.send(ros)
router.get('/case/:nomsNumber/communityManager', (req, res) => {
res.send({
code: 'DELIUS_ID',
staffId: 2,
name: { forenames: 'Ryan', surname: 'Orton' },
team: teamC01T04,
provider: { code: 'ABC', description: 'ABC probation area' },
localAdminUnit: { code: 'ABC124', description: 'ABC124 delivery unit' },
isUnallocated: false,
})
})

router.get('/probationAreas', (req, res) => {
router.get('/providers', (req, res) => {
// return all probation areas
const allProbationAreas = probationAreas.map((probArea) => ({
code: probArea.code,
Expand All @@ -170,11 +144,15 @@ router.get('/probationAreas', (req, res) => {
res.send(response)
})

router.get('/probationAreas/code/:code/localDeliveryUnits', (req, res) => {
router.get('/providers/:code', (req, res) => {
// return the LDUs for a specific probation area
const { code: probationAreaCode } = req.params
const probationArea = probationAreas.filter((probArea) => probArea.code === probationAreaCode)
const response = { content: probationArea[0].ldus }
const response = {
code: probationArea[0].code,
description: probationArea[0].description,
localAdminUnits: probationArea[0].ldus,
}
res.send(response)
})

Expand Down
3 changes: 1 addition & 2 deletions server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = {
},

delius: {
apiUrl: get('DELIUS_API_URL', 'http://localhost:8080/communityapi'),
apiUrl: get('DELIUS_API_URL', 'http://localhost:8080/delius'),
authUrl: get('DELIUS_AUTH_URL', get('NOMIS_AUTH_URL', 'http://localhost:9090/auth')),
admin: {
apiClientId: get('DELIUS_API_CLIENT_ID', get('ADMIN_API_CLIENT_ID', 'licencesadmin')),
Expand All @@ -73,7 +73,6 @@ module.exports = {
maxFreeSockets: 10,
freeSocketTimeout: 30000,
},
apiPrefix: get('DELIUS_API_PREFIX', '/api'),
// this refers to the 'HDC Digital Update' RBAC which is mapped to LICENCE_RO and GLOBAL_SEARCH in the auth server
responsibleOfficerRoleId: get('DELIUS_RO_ROLE_ID', 'LHDCBT002'),
// this refers to the 'HDC Digital Update' RBAC which is mapped to LICENCE_RO, GLOBAL_SEARCH and LICENCE_VARY in the auth server
Expand Down
Loading

0 comments on commit d7b0cd9

Please sign in to comment.