generated from ministryofjustice/hmpps-template-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BR-12 : Subject Access Report endpoint & Tests
- Loading branch information
1 parent
f1847af
commit 0ddb952
Showing
6 changed files
with
592 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/kotlin/uk/gov/justice/digital/hmpps/breachnoticeapi/controller/SarController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package uk.gov.justice.digital.hmpps.breachnoticeapi.controller | ||
|
||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.media.Content | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
import io.swagger.v3.oas.annotations.security.SecurityRequirement | ||
import org.springframework.security.access.prepost.PreAuthorize | ||
import org.springframework.validation.annotation.Validated | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RequestParam | ||
import org.springframework.web.bind.annotation.RestController | ||
import uk.gov.justice.digital.hmpps.breachnoticeapi.service.BreachNoticeService | ||
import uk.gov.justice.hmpps.kotlin.common.ErrorResponse | ||
import java.util.* | ||
|
||
@Validated | ||
@RestController | ||
@PreAuthorize("hasRole('ROLE_BREACH_NOTICE')") | ||
@RequestMapping(value = ["/subject-access-request"], produces = ["application/json"]) | ||
class SarController(private val breachNoticeService: BreachNoticeService) { | ||
|
||
@GetMapping | ||
@PreAuthorize("hasRole('ROLE_SAR_DATA_ACCESS')") | ||
@Operation( | ||
summary = "API call to retrieve SAR data from a product", | ||
description = "Calls through the breach notice service to retrieve a any SAR related information ", | ||
security = [SecurityRequirement(name = "breach-notice-api-ui-role")], | ||
responses = [ | ||
ApiResponse(responseCode = "200", description = "Request successfully processed - content found"), | ||
ApiResponse(responseCode = "204", description = "Request successfully processed - no content found"), | ||
ApiResponse(responseCode = "209", description = "Subject Identifier is not recognised by this service"), | ||
ApiResponse( | ||
responseCode = "400", | ||
description = "The request was not formed correctly", | ||
content = [Content(mediaType = "application/json", schema = Schema(implementation = ErrorResponse::class))], | ||
), | ||
ApiResponse( | ||
responseCode = "401", | ||
description = "Unauthorized to access this endpoint", | ||
content = [Content(mediaType = "application/json", schema = Schema(implementation = ErrorResponse::class))], | ||
), | ||
], | ||
) | ||
fun getSAR( | ||
@RequestParam prn: String?, | ||
@RequestParam crn: String?, | ||
@RequestParam fromDate: String?, | ||
@RequestParam toDate: String?, | ||
) = breachNoticeService.getSARDetails(prn, crn, fromDate, toDate) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.