summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2022-05-16 11:12:51 -0400
committerkuldipr <kuldip.rai@amdocs.com>2022-08-29 16:01:31 -0400
commit4f0ff92093a006ec0f2e29f695660e5476d890cc (patch)
tree294c09ae658b24d6e4e577739cb0891c6616838c /ms/blueprintsprocessor/modules/inbounds
parentf85436b2dbe0da6b9951f913fc73a895d4f2924a (diff)
Add endpoint for deleting templates
Issue-ID: CCSDK-3735 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca> Signed-off-by: kuldipr <kuldip.rai@amdocs.com> Change-Id: I80d0da87651933da103e79d878902da743bb134e
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/TemplateController.kt37
1 files changed, 37 insertions, 0 deletions
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)) }
+ }
}