From 4f0ff92093a006ec0f2e29f695660e5476d890cc Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Mon, 16 May 2022 11:12:51 -0400 Subject: Add endpoint for deleting templates Issue-ID: CCSDK-3735 Signed-off-by: Jozsef Csongvai Signed-off-by: kuldipr Change-Id: I80d0da87651933da103e79d878902da743bb134e --- .../resource/api/TemplateController.kt | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'ms/blueprintsprocessor/modules/inbounds') diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt index 03ba347fd..49e03137b 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt @@ -255,4 +255,41 @@ open class TemplateController(private val templateResolutionService: TemplateRes ResponseEntity.ok().body(resultStored) } + + @RequestMapping( + path = [""], + method = [RequestMethod.DELETE], produces = [MediaType.APPLICATION_JSON_VALUE] + ) + @PreAuthorize("hasRole('USER')") + fun deleteTemplates( + @ApiParam(value = "Name of the CBA", required = true) + @RequestParam(value = "bpName", required = true) bpName: String, + @ApiParam(value = "Version of the CBA", required = true) + @RequestParam(value = "bpVersion", required = true) bpVersion: String, + @ApiParam(value = "Artifact name", required = true) + @RequestParam(value = "artifactName", required = true, defaultValue = "") artifactName: String, + @ApiParam(value = "Resolution Key associated with the template", required = false) + @RequestParam(value = "resolutionKey", required = false) resolutionKey: String?, + @ApiParam(value = "resourceType associated with the template, must be used with resourceId", required = false) + @RequestParam(value = "resourceType", required = false) resourceType: String?, + @ApiParam(value = "Resolution Key associated with the template, must be used with resourceType", required = false) + @RequestParam(value = "resourceId", required = false) resourceId: String?, + @ApiParam(value = "Only delete last N occurrences", required = false) + @RequestParam(value = "lastN", required = false) lastN: Int? + ) = runBlocking { + when { + resolutionKey?.isNotBlank() == true -> templateResolutionService.deleteTemplates( + bpName, bpVersion, artifactName, resolutionKey, lastN + ) + resourceType?.isNotBlank() == true && resourceId?.isNotBlank() == true -> + templateResolutionService.deleteTemplates( + bpName, bpVersion, artifactName, resourceType, resourceId, lastN + ) + else -> throw httpProcessorException( + ErrorCatalogCodes.REQUEST_NOT_FOUND, + ResourceApiDomains.RESOURCE_API, + "Either use resolutionKey or resourceType + resourceId. Values cannot be blank" + ) + }.let { ResponseEntity.ok().body(DeleteResponse(it)) } + } } -- cgit 1.2.3-korg rep'>log msg
blob: 50f48363edbd1df677b3fccf4c0d22518edb17ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35