aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2022-05-16 11:09:06 -0400
committerkuldipr <kuldip.rai@amdocs.com>2022-08-03 15:29:55 -0400
commitfa536ca8bd901dc51833cfe906f7b22846674d2f (patch)
tree57509fbcbaac90f45ec9869ef5b95c3759617680 /ms/blueprintsprocessor/modules
parenteb7eb24bf107bbd42537a9557e07b5ca82280c60 (diff)
Enable deleting resources by lastN occurrences
Also enable deletion using resource-type and resource-id. Issue-ID: CCSDK-3735 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca> Signed-off-by: kuldipr <kuldip.rai@amdocs.com> Change-Id: Id1b487fce97f582bd3781dfd5bcff61a8df08c5c
Diffstat (limited to 'ms/blueprintsprocessor/modules')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/DeleteResponse.kt19
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt36
2 files changed, 47 insertions, 8 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/DeleteResponse.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/DeleteResponse.kt
new file mode 100644
index 000000000..0ad5b5e17
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/DeleteResponse.kt
@@ -0,0 +1,19 @@
+/*
+ * Copyright © 2022 Bell Canada
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.resource.api
+
+data class DeleteResponse(val deletedEntries: Int)
diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt
index d2b7ac368..dbfc69738 100644
--- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/resource/api/ResourceController.kt
@@ -173,25 +173,45 @@ open class ResourceController(private var resourceResolutionDBService: ResourceR
notes = "Delete all the resources associated to a resolution-key using blueprint metadata, artifact name and the resolution-key."
)
@PreAuthorize("hasRole('USER')")
- fun deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(
+ suspend fun deleteResolutions(
@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 for which to retrieve a resolved resource", required = true)
- @RequestParam(value = "artifactName", required = false, defaultValue = "") artifactName: String,
- @ApiParam(value = "Resolution Key associated with the resolution", required = true)
- @RequestParam(value = "resolutionKey", required = true) resolutionKey: String
+ @RequestParam(value = "artifactName", required = true, defaultValue = "") artifactName: String,
+ @ApiParam(value = "Resolution Key associated with the resolution", required = false)
+ @RequestParam(value = "resolutionKey", required = false) resolutionKey: String?,
+ @ApiParam(value = "resourceType associated with the resolution, must be used with resourceId", required = false)
+ @RequestParam(value = "resourceType", required = false) resourceType: String?,
+ @ApiParam(value = "Resolution Key associated with the resolution, 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 {
- ResponseEntity.ok()
- .body(
- resourceResolutionDBService.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(
+ when {
+ resolutionKey?.isNotEmpty() == true -> resourceResolutionDBService.deleteResources(
+ bpName,
+ bpVersion,
+ artifactName,
+ resolutionKey,
+ lastN
+ )
+ resourceId?.isNotEmpty() == true && resourceType?.isNotEmpty() == true ->
+ resourceResolutionDBService.deleteResources(
bpName,
bpVersion,
artifactName,
- resolutionKey
+ 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)) }
}
@RequestMapping(