From 5ef6d930f1ade3a80a983762bd7c7b0ecc96cde9 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Tue, 17 Sep 2019 15:56:20 -0400 Subject: Add cba GRPC remove options. Change-Id: Iaba18e145f11fc608f5b6efa8bdfb46c623d7ccf Issue-ID: CCSDK-1682 Signed-off-by: Brinda Santh --- .../proto/BluePrintManagement.proto | 10 ++++++++-- .../designer/api/BluePrintManagementGRPCHandler.kt | 22 ++++++++++++++++++---- .../api/BluePrintManagementGRPCHandlerTest.kt | 6 ++++-- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/components/model-catalog/proto-definition/proto/BluePrintManagement.proto b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto index 2e0693c28..8c6cadb4c 100644 --- a/components/model-catalog/proto-definition/proto/BluePrintManagement.proto +++ b/components/model-catalog/proto-definition/proto/BluePrintManagement.proto @@ -21,8 +21,9 @@ message BluePrintDownloadInput { message BluePrintRemoveInput { org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader commonHeader = 1; - string blueprintName = 2; - string blueprintVersion = 3; + org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers actionIdentifiers = 2; + // Extra optional dynamic properties used to remove. + google.protobuf.Struct properties = 3; } message BluePrintManagementOutput { @@ -55,6 +56,11 @@ enum UploadAction { PUBLISH = 3; } +enum RemoveAction { + // Delete CBA from database, deploy path and clean cache. + DEFAULT = 0; +} + service BluePrintManagementService { rpc downloadBlueprint (BluePrintDownloadInput) returns (BluePrintManagementOutput); rpc uploadBlueprint (BluePrintUploadInput) returns (BluePrintManagementOutput); diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt index a3bf3709d..0f804b8b2 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt @@ -129,14 +129,28 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu StreamObserver) { runBlocking { - val blueprintName = request.blueprintName - val blueprintVersion = request.blueprintVersion + val blueprintName = request.actionIdentifiers.blueprintName + val blueprintVersion = request.actionIdentifiers.blueprintVersion val blueprint = "blueprint $blueprintName:$blueprintVersion" log.info("request(${request.commonHeader.requestId}): Received delete $blueprint") + + /** Get the Remove Action */ + val removeAction = request.actionIdentifiers?.actionName.emptyTONull() + ?: RemoveAction.DEFAULT.toString() + try { - bluePrintModelHandler.deleteBlueprintModel(blueprintName, blueprintVersion) - responseObserver.onNext(successStatus(request.commonHeader)) + when (removeAction) { + RemoveAction.DEFAULT.toString() -> { + bluePrintModelHandler.deleteBlueprintModel(blueprintName, blueprintVersion) + responseObserver.onNext(successStatus(request.commonHeader)) + } + else -> { + responseObserver.onNext(failStatus(request.commonHeader, + "Remove action($removeAction) not implemented", + BluePrintProcessorException("Not implemented"))) + } + } } catch (e: Exception) { responseObserver.onNext(failStatus(request.commonHeader, "request(${request.commonHeader.requestId}): Failed to delete $blueprint", e)) diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt index 691cfd760..54dd46ef7 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt @@ -183,8 +183,10 @@ class BluePrintManagementGRPCHandlerTest { return BluePrintRemoveInput.newBuilder() .setCommonHeader(commonHeader) - .setBlueprintName("sample") - .setBlueprintVersion("1.0.0") + .setActionIdentifiers(ActionIdentifiers.newBuilder() + .setBlueprintName("sample") + .setBlueprintVersion("1.0.0") + .setActionName(RemoveAction.DEFAULT.toString()).build()) .build() } } -- cgit 1.2.3-korg