aboutsummaryrefslogtreecommitdiffstats
path: root/model/model-api/src/main
diff options
context:
space:
mode:
authorRashmi Pujar <rashmi.pujar1@bell.ca>2022-01-22 00:37:28 -0500
committerRashmi Pujar <rashmi.pujar1@bell.ca>2022-01-24 14:06:57 -0500
commit632899642b6a1d1489a0b96932c9c38863a53a26 (patch)
treeab9665853aa637ab1d76d7c25523c77835d3ca3e /model/model-api/src/main
parentc719ee941bd4202b617544e351a11a35b20b8a6a (diff)
Add TOSCA policy status header field to APEX event create CLI
In order to expose the processing status of a TOSCA policy to APEX-PDP, a new header field for APEX concept "event" has been introduced to track this within an APEX policy implementation. This field will be leveraged to extract the TOSCA policy execution metrics. Note, that the field is marked as optional for backward compatibility. Unit tests have been augmented to test for the field wherever applicable and the default empty value is retained for the others. "example-grpc" module has been updated to include this field. Exposing the TOSCA policy execution metrics is outside the scope of this patch since the current changes are already very large owing to the atomic nature of the change introduced. Issue-ID: POLICY-3845 Signed-off-by: Rashmi Pujar <rashmi.pujar1@bell.ca> Change-Id: Ief6d70f9abcfc8414e10aa51a27815ee9028e4c8
Diffstat (limited to 'model/model-api/src/main')
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java10
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java14
-rw-r--r--model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java17
3 files changed, 28 insertions, 13 deletions
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
index fab6ba163..8974d1fa8 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/ApexEditorApi.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021-2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -205,10 +205,11 @@ public interface ApexEditorApi {
* @param target of the event, set to null to use the default value
* @param uuid event UUID, set to null to generate a UUID
* @param description event description, set to null to generate a description
+ * @param toscaPolicyState specifies TOSCA policy processing status
* @return result of the operation
*/
ApexApiResult createEvent(final String name, final String version, final String nameSpace, final String source,
- final String target, final String uuid, final String description);
+ final String target, final String uuid, final String description, final String toscaPolicyState);
/**
* Update an event.
@@ -220,10 +221,11 @@ public interface ApexEditorApi {
* @param target of the event, set to null to not update
* @param uuid event UUID, set to null to not update
* @param description event description, set to null to not update
+ * @param toscaPolicyState specifies TOSCA policy processing status
* @return result of the operation
*/
ApexApiResult updateEvent(final String name, final String version, final String nameSpace, final String source,
- final String target, final String uuid, final String description);
+ final String target, final String uuid, final String description, final String toscaPolicyState);
/**
* List events.
@@ -900,4 +902,4 @@ public interface ApexEditorApi {
*/
ApexApiResult deletePolicyStateContextRef(final String name, final String version, final String stateName,
final String contextAlbumName, final String contextAlbumVersion);
-}
+} \ No newline at end of file
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
index 05976c6ed..cca9d3454 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/ApexModelImpl.java
@@ -3,7 +3,7 @@
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Samsung Electronics Co., Ltd.
* Modifications Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -251,8 +251,9 @@ public final class ApexModelImpl implements ApexModel {
*/
@Override
public ApexApiResult createEvent(final String name, final String version, final String nameSpace,
- final String source, final String target, final String uuid, final String description) {
- return eventFacade.createEvent(name, version, nameSpace, source, target, uuid, description);
+ final String source, final String target, final String uuid, final String description,
+ final String toscaPolicyState) {
+ return eventFacade.createEvent(name, version, nameSpace, source, target, uuid, description, toscaPolicyState);
}
/**
@@ -260,8 +261,9 @@ public final class ApexModelImpl implements ApexModel {
*/
@Override
public ApexApiResult updateEvent(final String name, final String version, final String nameSpace,
- final String source, final String target, final String uuid, final String description) {
- return eventFacade.updateEvent(name, version, nameSpace, source, target, uuid, description);
+ final String source, final String target, final String uuid, final String description,
+ final String toscaPolicyState) {
+ return eventFacade.updateEvent(name, version, nameSpace, source, target, uuid, description, toscaPolicyState);
}
/**
@@ -892,4 +894,4 @@ public final class ApexModelImpl implements ApexModel {
return policyModel;
}
-}
+} \ No newline at end of file
diff --git a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java
index 0a758407b..f1f939397 100644
--- a/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java
+++ b/model/model-api/src/main/java/org/onap/policy/apex/model/modelapi/impl/EventFacade.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 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.
@@ -85,10 +86,12 @@ public class EventFacade {
* @param target of the event, set to null to use the default value
* @param uuid event UUID, set to null to generate a UUID
* @param description event description, set to null to generate a description
+ * @param toscaPolicyState specifies TOSCA policy processing status
* @return result of the operation
*/
public ApexApiResult createEvent(final String name, final String version, final String nameSpace,
- final String source, final String target, final String uuid, final String description) {
+ final String source, final String target, final String uuid, final String description,
+ final String toscaPolicyState) {
try {
final AxArtifactKey key = new AxArtifactKey();
key.setName(name);
@@ -107,6 +110,9 @@ public class EventFacade {
event.setNameSpace((nameSpace != null ? nameSpace : apexProperties.getProperty("DEFAULT_EVENT_NAMESPACE")));
event.setSource((source != null ? source : apexProperties.getProperty("DEFAULT_EVENT_SOURCE")));
event.setTarget((target != null ? target : apexProperties.getProperty("DEFAULT_EVENT_TARGET")));
+ if (toscaPolicyState != null) {
+ event.setToscaPolicyState(toscaPolicyState);
+ }
apexModel.getPolicyModel().getEvents().getEventMap().put(key, event);
@@ -130,10 +136,12 @@ public class EventFacade {
* @param target of the event, set to null to not update
* @param uuid event UUID, set to null to not update
* @param description event description, set to null to not update
+ * @param toscaPolicyState specifies TOSCA policy processing status
* @return result of the operation
*/
public ApexApiResult updateEvent(final String name, final String version, final String nameSpace,
- final String source, final String target, final String uuid, final String description) {
+ final String source, final String target, final String uuid, final String description,
+ final String toscaPolicyState) {
try {
final AxEvent event = apexModel.getPolicyModel().getEvents().get(name, version);
if (event == null) {
@@ -150,6 +158,9 @@ public class EventFacade {
if (target != null) {
event.setTarget(target);
}
+ if (toscaPolicyState != null) {
+ event.setToscaPolicyState(toscaPolicyState);
+ }
return keyInformationFacade.updateKeyInformation(name, version, uuid, description);
} catch (final Exception e) {
@@ -382,4 +393,4 @@ public class EventFacade {
return new ApexApiResult(ApexApiResult.Result.FAILED, e);
}
}
-}
+} \ No newline at end of file