summaryrefslogtreecommitdiffstats
path: root/examples/examples-grpc/src/main
diff options
context:
space:
mode:
authora.sreekumar <ajith.sreekumar@est.tech>2020-03-20 18:30:43 +0000
committera.sreekumar <ajith.sreekumar@est.tech>2020-03-23 17:23:41 +0000
commitf46af3394f85598eaa718f22312f9b7a6485c636 (patch)
treefdc1120cc3650e050f5215ffb66a51e40e2c395b /examples/examples-grpc/src/main
parent2d56e9183b619893e33705a77da0ce0c15d6e74c (diff)
Adding example for APEX gRPC plugin for CDS interaction
Change-Id: I8361eb0cbe74c3548ca98f3005bc37f5a1f91747 Issue-ID: POLICY-2436 Signed-off-by: a.sreekumar <ajith.sreekumar@est.tech>
Diffstat (limited to 'examples/examples-grpc/src/main')
-rw-r--r--examples/examples-grpc/src/main/resources/examples/config/APEXgRPC/ApexConfig.json112
-rw-r--r--examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CreateSubscriptionEvent.json54
-rw-r--r--examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CreateSubscriptionResponseEvent.json29
-rw-r--r--examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/LogEvent.json13
-rw-r--r--examples/examples-grpc/src/main/resources/logic/CreateOrDeleteStateTSL.js33
-rw-r--r--examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js45
-rw-r--r--examples/examples-grpc/src/main/resources/logic/CreateSubscriptionRequestTask.js44
-rw-r--r--examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionPayloadTask.js45
-rw-r--r--examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionRequestTask.js44
-rw-r--r--examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js48
-rw-r--r--examples/examples-grpc/src/main/resources/logic/ResponseTask.js44
-rw-r--r--examples/examples-grpc/src/main/resources/policy/APEXgRPCPolicy.apex232
-rw-r--r--examples/examples-grpc/src/main/resources/schemas/CDSActionIdentifiersType.avsc23
-rw-r--r--examples/examples-grpc/src/main/resources/schemas/CDSCreateSubscriptionPayloadType.avsc91
-rw-r--r--examples/examples-grpc/src/main/resources/schemas/CDSDeleteSubscriptionPayloadType.avsc91
-rw-r--r--examples/examples-grpc/src/main/resources/schemas/CDSRequestCommonHeaderType.avsc19
-rw-r--r--examples/examples-grpc/src/main/resources/schemas/CDSResponseCommonHeaderType.avsc23
-rw-r--r--examples/examples-grpc/src/main/resources/schemas/CDSResponsePayloadType.avsc29
-rw-r--r--examples/examples-grpc/src/main/resources/schemas/CDSResponseStatusType.avsc23
-rw-r--r--examples/examples-grpc/src/main/resources/schemas/PMSubscriptionType.avsc101
-rw-r--r--examples/examples-grpc/src/main/resources/schemas/SubscriptionStatusType.avsc23
-rw-r--r--examples/examples-grpc/src/main/resources/schemas/SubscriptionType.avsc75
-rw-r--r--examples/examples-grpc/src/main/resources/tosca/ToscaPolicyType.json260
-rw-r--r--examples/examples-grpc/src/main/resources/tosca/ToscaTemplate.json16
24 files changed, 1517 insertions, 0 deletions
diff --git a/examples/examples-grpc/src/main/resources/examples/config/APEXgRPC/ApexConfig.json b/examples/examples-grpc/src/main/resources/examples/config/APEXgRPC/ApexConfig.json
new file mode 100644
index 000000000..553f16ba8
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/examples/config/APEXgRPC/ApexConfig.json
@@ -0,0 +1,112 @@
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 2,
+ "deploymentPort": 12561,
+ "engineParameters": {
+ "executorParameters": {
+ "JAVASCRIPT": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
+ }
+ },
+ "contextParameters": {
+ "parameterClassName": "org.onap.policy.apex.context.parameters.ContextParameters",
+ "schemaParameters": {
+ "Avro": {
+ "parameterClassName": "org.onap.policy.apex.plugins.context.schema.avro.AvroSchemaHelperParameters"
+ },
+ "Java": {
+ "parameterClassName": "org.onap.policy.apex.context.impl.schema.java.JavaSchemaHelperParameters",
+ "jsonAdapters": {
+ "Instant": {
+ "adaptedClass": "java.time.Instant",
+ "adaptorClass": "org.onap.policy.controlloop.util.Serialization$GsonInstantAdapter"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "DCAEConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:54321/GrpcTestRestSim/sim/events/unauthenticated.DCAE_CL_OUTPUT/APEX/1?timeout=30000"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON",
+ "parameters": {
+ "nameAlias": "testPolicyB"
+ }
+ },
+ "eventName": "testPolicyB",
+ "eventNameFilter": "testPolicyB"
+ },
+ "CDSRequestConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "GRPC",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters"
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventName": "CDSResponseEvent",
+ "eventNameFilter": "CDSResponseEvent",
+ "requestorMode": true,
+ "requestorPeer": "CDSRequestProducer",
+ "requestorTimeout": 500
+ }
+ },
+ "eventOutputParameters": {
+ "logOutputter": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "FILE",
+ "parameters": {
+ "fileName": "outputevents.log"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ },
+ "CDSRequestProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "GRPC",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.grpc.GrpcCarrierTechnologyParameters",
+ "parameters": {
+ "host": "localhost",
+ "port": 54322,
+ "username": "ccsdkapps",
+ "password": "ccsdkapps",
+ "timeout": 10
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventNameFilter": "(Create|Delete)SubscriptionRequestEvent",
+ "requestorMode": true,
+ "requestorPeer": "CDSRequestConsumer",
+ "requestorTimeout": 500
+ },
+ "CDSReplyProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:54321/GrpcTestRestSim/sim/events/POLICY_CL_MGT"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ },
+ "eventNameFilter": "CDSResponseStatusEvent"
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CreateSubscriptionEvent.json b/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CreateSubscriptionEvent.json
new file mode 100644
index 000000000..7cdfc66fc
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CreateSubscriptionEvent.json
@@ -0,0 +1,54 @@
+{
+ "changeType": "CREATE",
+ "closedLoopControlName": "test",
+ "policyName": "test",
+ "nfName": "pnf300",
+ "subscription": {
+ "subscriptionName": "testPolicyB",
+ "administrativeState": "UNLOCKED",
+ "fileBasedGP": 15,
+ "fileLocation": "/pm/pm.xml",
+ "measurementGroups": [
+ {
+ "measurementGroup": {
+ "measurementTypes": [
+ {
+ "measurementType": "countera"
+ },
+ {
+ "measurementType": "counterb"
+ }
+ ],
+ "managedObjectDNsBasic": [
+ {
+ "DN": "dna"
+ },
+ {
+ "DN": "dnb"
+ }
+ ]
+ }
+ },
+ {
+ "measurementGroup": {
+ "measurementTypes": [
+ {
+ "measurementType": "counterc"
+ },
+ {
+ "measurementType": "counterd"
+ }
+ ],
+ "managedObjectDNsBasic": [
+ {
+ "DN": "dnc"
+ },
+ {
+ "DN": "dnd"
+ }
+ ]
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CreateSubscriptionResponseEvent.json b/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CreateSubscriptionResponseEvent.json
new file mode 100644
index 000000000..adb51adcb
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/CreateSubscriptionResponseEvent.json
@@ -0,0 +1,29 @@
+{
+ "commonHeader": {
+ "timestamp": "2020-03-20T14:00:25.217Z",
+ "requestId": "123456-1000",
+ "subRequestId": "sub-123456-1000",
+ "flag": {
+ },
+ "originatorId": "sdnc"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "pm_control",
+ "blueprintVersion": "1.0.0",
+ "actionName": "create-subscription",
+ "mode": "sync"
+ },
+ "status": {
+ "code": 200,
+ "message": "success",
+ "eventType": "EVENT_COMPONENT_EXECUTED",
+ "timestamp": "Fri Mar 20 14:00:26 GMT 2020"
+ },
+ "payload": {
+ "create-subscription-response": {
+ "odl-response": {
+ "status": "success"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/LogEvent.json b/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/LogEvent.json
new file mode 100644
index 000000000..a86ccd1d7
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/examples/events/APEXgRPC/LogEvent.json
@@ -0,0 +1,13 @@
+{
+ "name": "CDSResponseStatusEvent",
+ "version": "0.0.1",
+ "nameSpace": "org.onap.policy.apex.onap.pmcontrol",
+ "source": "APEX",
+ "target": "DCAE",
+ "status": {
+ "subscriptionName": "testPolicyB",
+ "nfName": "pnf300",
+ "changeType": "CREATE",
+ "message": "success"
+ }
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/logic/CreateOrDeleteStateTSL.js b/examples/examples-grpc/src/main/resources/logic/CreateOrDeleteStateTSL.js
new file mode 100644
index 000000000..010a71dff
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/logic/CreateOrDeleteStateTSL.js
@@ -0,0 +1,33 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+executor.logger.info(executor.subject.id);
+
+var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+var changeType = pmSubscriptionInfo.get("changeType").toString()
+
+if ("CREATE".equals(changeType)) {
+ executor.subject.getTaskKey("CreateSubscriptionPayloadTask").copyTo(executor.selectedTask);
+}
+else if ("DELETE".equals(changeType)) {
+ executor.subject.getTaskKey("DeleteSubscriptionPayloadTask").copyTo(executor.selectedTask);
+}
+
+true; \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js b/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js
new file mode 100644
index 000000000..48f31847b
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionPayloadTask.js
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. 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.
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+executor.logger.info(executor.subject.id);
+
+var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+
+var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("create_DasH_subscription_DasH_properties_record");
+
+payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName"))
+payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName"))
+payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState"))
+payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString())
+payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation"))
+payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups"))
+
+var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry");
+payloadEntry.put("create_DasH_subscription_DasH_properties", payloadProperties)
+
+var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance();
+payload.put("create_DasH_subscription_DasH_request", payloadEntry);
+
+executor.outFields.put("albumID", executor.inFields.get("albumID"))
+executor.outFields.put("payload", payload);
+
+executor.logger.info("Sending Create Subscription Event to CDS")
+
+true;
diff --git a/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionRequestTask.js b/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionRequestTask.js
new file mode 100644
index 000000000..638429817
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/logic/CreateSubscriptionRequestTask.js
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. 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.
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+executor.logger.info(executor.subject.id);
+
+var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+var payload = executor.inFields.get("payload")
+var actionName = "create-subscription"
+
+var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance();
+commonHeader.put("originatorId", "sdnc");
+commonHeader.put("requestId", "123456-1000");
+commonHeader.put("subRequestId", "sub-123456-1000");
+
+var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance();
+actionIdentifiers.put("actionName", actionName);
+actionIdentifiers.put("blueprintName", "pm_control");
+actionIdentifiers.put("blueprintVersion", "1.0.0");
+actionIdentifiers.put("mode", "sync");
+
+executor.outFields.put("commonHeader", commonHeader);
+executor.outFields.put("actionIdentifiers", actionIdentifiers);
+executor.outFields.put("payload", payload);
+
+executor.logger.info("Sending Activate Subscription Event to CDS")
+
+true; \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionPayloadTask.js b/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionPayloadTask.js
new file mode 100644
index 000000000..180dcba71
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionPayloadTask.js
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. 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.
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+executor.logger.info(executor.subject.id);
+
+var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+
+var payloadProperties = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("delete_DasH_subscription_DasH_properties_record");
+
+payloadProperties.put("nfName", pmSubscriptionInfo.get("nfName"))
+payloadProperties.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName"))
+payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState"))
+payloadProperties.put("fileBasedGP", pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString())
+payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation"))
+payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups"))
+
+var payloadEntry = executor.subject.getOutFieldSchemaHelper("payload").createNewSubInstance("CDSRequestPayloadEntry");
+payloadEntry.put("delete_DasH_subscription_DasH_properties", payloadProperties)
+
+var payload = executor.subject.getOutFieldSchemaHelper("payload").createNewInstance();
+payload.put("delete_DasH_subscription_DasH_request", payloadEntry);
+
+executor.outFields.put("albumID", executor.inFields.get("albumID"))
+executor.outFields.put("payload", payload);
+
+executor.logger.info("Sending delete Subscription Event to CDS")
+
+true;
diff --git a/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionRequestTask.js b/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionRequestTask.js
new file mode 100644
index 000000000..9ec2a119b
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/logic/DeleteSubscriptionRequestTask.js
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. 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.
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+executor.logger.info(executor.subject.id);
+
+var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
+var payload = executor.inFields.get("payload")
+var actionName = "delete-subscription"
+
+var commonHeader = executor.subject.getOutFieldSchemaHelper("commonHeader").createNewInstance();
+commonHeader.put("originatorId", "sdnc");
+commonHeader.put("requestId", "123456-1000");
+commonHeader.put("subRequestId", "sub-123456-1000");
+
+var actionIdentifiers = executor.subject.getOutFieldSchemaHelper("actionIdentifiers").createNewInstance();
+actionIdentifiers.put("actionName", actionName);
+actionIdentifiers.put("blueprintName", "pm_control");
+actionIdentifiers.put("blueprintVersion", "1.0.0");
+actionIdentifiers.put("mode", "sync");
+
+executor.outFields.put("commonHeader", commonHeader);
+executor.outFields.put("actionIdentifiers", actionIdentifiers);
+executor.outFields.put("payload", payload);
+
+executor.logger.info("Sending Deactivate Subscription Event to CDS")
+
+true; \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js b/examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js
new file mode 100644
index 000000000..bc4028a32
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/logic/ReceivePMSubscriptionTask.js
@@ -0,0 +1,48 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. 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.
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+var uuidType = java.util.UUID;
+
+
+//albumID will be used to fetch info from our album later
+var albumID = uuidType.fromString("d0050623-18e5-46c9-9298-9a567990cd7c");
+var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").getSchemaHelper().createNewInstance();
+var returnValue = true;;
+
+if(executor.inFields.get("policyName") != null) {
+ var changeType = executor.inFields.get("changeType")
+ var nfName = executor.inFields.get("nfName")
+ var policyName = executor.inFields.get("policyName")
+ var closedLoopControlName = executor.inFields.get("closedLoopControlName")
+ var subscription = executor.inFields.get("subscription")
+
+ pmSubscriptionInfo.put("nfName", executor.inFields.get("nfName"));
+ pmSubscriptionInfo.put("changeType", executor.inFields.get("changeType"))
+ pmSubscriptionInfo.put("policyName", executor.inFields.get("policyName"))
+ pmSubscriptionInfo.put("closedLoopControlName", executor.inFields.get("closedLoopControlName"))
+ pmSubscriptionInfo.put("subscription", subscription)
+
+ executor.getContextAlbum("PMSubscriptionAlbum").put(albumID.toString(), pmSubscriptionInfo);
+
+ executor.outFields.put("albumID", albumID)
+} else {
+ executor.message = "Received invalid event"
+ returnValue = false;
+}
+returnValue; \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/logic/ResponseTask.js b/examples/examples-grpc/src/main/resources/logic/ResponseTask.js
new file mode 100644
index 000000000..04517763a
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/logic/ResponseTask.js
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix. 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.
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+
+var uuidType = java.util.UUID;
+
+var albumID = uuidType.fromString("d0050623-18e5-46c9-9298-9a567990cd7c");
+
+var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(albumID.toString());
+
+var responseStatus = executor.subject.getOutFieldSchemaHelper("status").createNewInstance();
+
+responseStatus.put("subscriptionName", pmSubscriptionInfo.get("subscription").get("subscriptionName"))
+responseStatus.put("nfName", pmSubscriptionInfo.get("nfName"))
+responseStatus.put("changeType", pmSubscriptionInfo.get("changeType"))
+
+var response = executor.inFields.get("payload")
+
+if ("failure".equals(response.get("create_DasH_subscription_DasH_response").get("odl_DasH_response").get("status"))) {
+ responseStatus.put("message", "failed")
+} else {
+ responseStatus.put("message", "success")
+}
+
+executor.outFields.put("status", responseStatus)
+
+true;
diff --git a/examples/examples-grpc/src/main/resources/policy/APEXgRPCPolicy.apex b/examples/examples-grpc/src/main/resources/policy/APEXgRPCPolicy.apex
new file mode 100644
index 000000000..b0cbcb7c0
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/policy/APEXgRPCPolicy.apex
@@ -0,0 +1,232 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START=======================================================
+# Copyright (C) 2020 Nordix Foundation.
+# ================================================================================
+# 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#-------------------------------------------------------------------------------
+
+model create name=APEXgRPCPolicy
+
+##
+## SCHEMAS
+##
+
+schema create name=SimpleStringType flavour=Java schema=java.lang.String
+schema create name=UUIDType flavour=Java schema=java.util.UUID
+schema create name=SimpleIntType flavour=Java schema=java.lang.Integer
+
+schema create name=CDSRequestCommonHeaderType flavour=Avro schema=LS
+#MACROFILE:"src/main/resources/schemas/CDSRequestCommonHeaderType.avsc"
+LE
+
+schema create name=CDSResponseCommonHeaderType flavour=Avro schema=LS
+#MACROFILE:"src/main/resources/schemas/CDSResponseCommonHeaderType.avsc"
+LE
+
+schema create name=CDSActionIdentifiersType flavour=Avro schema=LS
+#MACROFILE:"src/main/resources/schemas/CDSActionIdentifiersType.avsc"
+LE
+
+schema create name=CDSResponseStatusType flavour=Avro schema=LS
+#MACROFILE:"src/main/resources/schemas/CDSResponseStatusType.avsc"
+LE
+
+schema create name=CDSCreateSubscriptionPayloadType flavour=Avro schema=LS
+#MACROFILE:"src/main/resources/schemas/CDSCreateSubscriptionPayloadType.avsc"
+LE
+
+schema create name=CDSDeleteSubscriptionPayloadType flavour=Avro schema=LS
+#MACROFILE:"src/main/resources/schemas/CDSDeleteSubscriptionPayloadType.avsc"
+LE
+
+schema create name=CDSResponsePayloadType flavour=Avro schema=LS
+#MACROFILE:"src/main/resources/schemas/CDSResponsePayloadType.avsc"
+LE
+
+schema create name=SubscriptionStatusType flavour=Avro schema=LS
+#MACROFILE:"src/main/resources/schemas/SubscriptionStatusType.avsc"
+LE
+
+schema create name=PMSubscriptionType flavour=Avro schema=LS
+#MACROFILE:"src/main/resources/schemas/PMSubscriptionType.avsc"
+LE
+
+schema create name=SubscriptionType flavour=Avro schema=LS
+#MACROFILE:"src/main/resources/schemas/SubscriptionType.avsc"
+LE
+
+##
+## EVENTS
+##
+
+album create name=PMSubscriptionAlbum scope=policy writable=true schemaName=PMSubscriptionType
+
+event create name=testPolicyB version=0.0.1 nameSpace=org.onap.policy.apex.onap.pmcontrol source=DCAE target=APEX
+event parameter create name=testPolicyB parName=nfName schemaName=SimpleStringType
+event parameter create name=testPolicyB parName=policyName schemaName=SimpleStringType
+event parameter create name=testPolicyB parName=changeType schemaName=SimpleStringType
+event parameter create name=testPolicyB parName=closedLoopControlName schemaName=SimpleStringType
+event parameter create name=testPolicyB parName=subscription schemaName=SubscriptionType
+
+event create name=PMSubscriptionOutputEvent nameSpace=org.onap.policy.apex.onap.pmcontrol source=APEX target=APEX
+event parameter create name=PMSubscriptionOutputEvent parName=albumID schemaName=UUIDType
+
+event create name=CreateSubscriptionPayloadEvent nameSpace=org.onap.policy.apex.onap.pmcontrol source=APEX target=APEX
+event parameter create name=CreateSubscriptionPayloadEvent parName=payload schemaName=CDSCreateSubscriptionPayloadType
+event parameter create name=CreateSubscriptionPayloadEvent parName=albumID schemaName=UUIDType
+
+event create name=DeleteSubscriptionPayloadEvent nameSpace=org.onap.policy.apex.onap.pmcontrol source=APEX target=APEX
+event parameter create name=DeleteSubscriptionPayloadEvent parName=payload schemaName=CDSDeleteSubscriptionPayloadType
+event parameter create name=DeleteSubscriptionPayloadEvent parName=albumID schemaName=UUIDType
+
+event create name=CreateSubscriptionRequestEvent nameSpace=org.onap.policy.apex.onap.pmcontrol source=APEX target=APEX
+event parameter create name=CreateSubscriptionRequestEvent parName=commonHeader schemaName=CDSRequestCommonHeaderType
+event parameter create name=CreateSubscriptionRequestEvent parName=actionIdentifiers schemaName=CDSActionIdentifiersType
+event parameter create name=CreateSubscriptionRequestEvent parName=payload schemaName=CDSCreateSubscriptionPayloadType
+
+event create name=DeleteSubscriptionRequestEvent nameSpace=org.onap.policy.apex.onap.pmcontrol source=APEX target=APEX
+event parameter create name=DeleteSubscriptionRequestEvent parName=commonHeader schemaName=CDSRequestCommonHeaderType
+event parameter create name=DeleteSubscriptionRequestEvent parName=actionIdentifiers schemaName=CDSActionIdentifiersType
+event parameter create name=DeleteSubscriptionRequestEvent parName=payload schemaName=CDSDeleteSubscriptionPayloadType
+
+event create name=CDSResponseEvent nameSpace=org.onap.policy.apex.onap.pmcontrol source=CDS target=APEX
+event parameter create name=CDSResponseEvent parName=commonHeader schemaName=CDSResponseCommonHeaderType
+event parameter create name=CDSResponseEvent parName=actionIdentifiers schemaName=CDSActionIdentifiersType
+event parameter create name=CDSResponseEvent parName=status schemaName=CDSResponseStatusType
+event parameter create name=CDSResponseEvent parName=payload schemaName=CDSResponsePayloadType
+
+event create name=CDSResponseStatusEvent nameSpace=org.onap.policy.apex.onap.pmcontrol source=APEX target=DCAE
+event parameter create name=CDSResponseStatusEvent parName=status schemaName=SubscriptionStatusType
+
+##
+## TASKS
+##
+
+
+task create name=ReceivePMSubscriptionTask
+task inputfield create name=ReceivePMSubscriptionTask fieldName=subscription schemaName=SubscriptionType
+task inputfield create name=ReceivePMSubscriptionTask fieldName=nfName schemaName=SimpleStringType
+task inputfield create name=ReceivePMSubscriptionTask fieldName=policyName schemaName=SimpleStringType
+task inputfield create name=ReceivePMSubscriptionTask fieldName=changeType schemaName=SimpleStringType
+task inputfield create name=ReceivePMSubscriptionTask fieldName=closedLoopControlName schemaName=SimpleStringType
+task outputfield create name=ReceivePMSubscriptionTask fieldName=albumID schemaName=UUIDType
+task contextref create name=ReceivePMSubscriptionTask albumName=PMSubscriptionAlbum
+task logic create name=ReceivePMSubscriptionTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/main/resources/logic/ReceivePMSubscriptionTask.js"
+LE
+
+task create name=CreateSubscriptionPayloadTask
+task inputfield create name=CreateSubscriptionPayloadTask fieldName=albumID schemaName=UUIDType
+task outputfield create name=CreateSubscriptionPayloadTask fieldName=payload schemaName=CDSCreateSubscriptionPayloadType
+task outputfield create name=CreateSubscriptionPayloadTask fieldName=albumID schemaName=UUIDType
+task contextref create name=CreateSubscriptionPayloadTask albumName=PMSubscriptionAlbum
+task logic create name=CreateSubscriptionPayloadTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/main/resources/logic/CreateSubscriptionPayloadTask.js"
+LE
+
+task create name=DeleteSubscriptionPayloadTask
+task inputfield create name=DeleteSubscriptionPayloadTask fieldName=albumID schemaName=UUIDType
+task outputfield create name=DeleteSubscriptionPayloadTask fieldName=payload schemaName=CDSDeleteSubscriptionPayloadType
+task outputfield create name=DeleteSubscriptionPayloadTask fieldName=albumID schemaName=UUIDType
+task contextref create name=DeleteSubscriptionPayloadTask albumName=PMSubscriptionAlbum
+task logic create name=DeleteSubscriptionPayloadTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/main/resources/logic/DeleteSubscriptionPayloadTask.js"
+LE
+
+task create name=CreateSubscriptionRequestTask
+task inputfield create name=CreateSubscriptionRequestTask fieldName=albumID schemaName=UUIDType
+task inputfield create name=CreateSubscriptionRequestTask fieldName=payload schemaName=CDSCreateSubscriptionPayloadType
+task outputfield create name=CreateSubscriptionRequestTask fieldName=commonHeader schemaName=CDSRequestCommonHeaderType
+task outputfield create name=CreateSubscriptionRequestTask fieldName=actionIdentifiers schemaName=CDSActionIdentifiersType
+task outputfield create name=CreateSubscriptionRequestTask fieldName=payload schemaName=CDSCreateSubscriptionPayloadType
+task contextref create name=CreateSubscriptionRequestTask albumName=PMSubscriptionAlbum
+task logic create name=CreateSubscriptionRequestTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/main/resources/logic/CreateSubscriptionRequestTask.js"
+LE
+
+task create name=DeleteSubscriptionRequestTask
+task inputfield create name=DeleteSubscriptionRequestTask fieldName=albumID schemaName=UUIDType
+task inputfield create name=DeleteSubscriptionRequestTask fieldName=payload schemaName=CDSDeleteSubscriptionPayloadType
+task outputfield create name=DeleteSubscriptionRequestTask fieldName=commonHeader schemaName=CDSRequestCommonHeaderType
+task outputfield create name=DeleteSubscriptionRequestTask fieldName=actionIdentifiers schemaName=CDSActionIdentifiersType
+task outputfield create name=DeleteSubscriptionRequestTask fieldName=payload schemaName=CDSDeleteSubscriptionPayloadType
+task contextref create name=DeleteSubscriptionRequestTask albumName=PMSubscriptionAlbum
+task logic create name=DeleteSubscriptionRequestTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/main/resources/logic/DeleteSubscriptionRequestTask.js"
+LE
+
+task create name=CDSResponseTask
+task inputfield create name=CDSResponseTask fieldName=commonHeader schemaName=CDSResponseCommonHeaderType
+task inputfield create name=CDSResponseTask fieldName=actionIdentifiers schemaName=CDSActionIdentifiersType
+task inputfield create name=CDSResponseTask fieldName=status schemaName=CDSResponseStatusType
+task inputfield create name=CDSResponseTask fieldName=payload schemaName=CDSResponsePayloadType
+task outputfield create name=CDSResponseTask fieldName=status schemaName=SubscriptionStatusType
+task contextref create name=CDSResponseTask albumName=PMSubscriptionAlbum
+task logic create name=CDSResponseTask logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/main/resources/logic/ResponseTask.js"
+LE
+
+
+##
+## POLICIES
+##
+
+
+# Policy ReceiveEventPolicy
+policy create name=ReceiveEventPolicy template=Freestyle firstState=ReceiveSubscriptionState
+
+# State CreateSubscription
+policy state create name=ReceiveEventPolicy stateName=CreateSubscription triggerName=CreateSubscriptionPayloadEvent defaultTaskName=CreateSubscriptionRequestTask
+policy state output create name=ReceiveEventPolicy stateName=CreateSubscription outputName=IssueCreateSubscriptionRequestOutput eventName=CreateSubscriptionRequestEvent nextState=NULL
+policy state taskref create name=ReceiveEventPolicy stateName=CreateSubscription taskName=CreateSubscriptionRequestTask outputType=DIRECT outputName=IssueCreateSubscriptionRequestOutput
+policy state contextref create name=ReceiveEventPolicy stateName=CreateSubscription albumName=PMSubscriptionAlbum
+
+# State DeleteSubscription
+policy state create name=ReceiveEventPolicy stateName=DeleteSubscription triggerName=DeleteSubscriptionPayloadEvent defaultTaskName=DeleteSubscriptionRequestTask
+policy state output create name=ReceiveEventPolicy stateName=DeleteSubscription outputName=IssueDeleteSubscriptionRequestOutput eventName=DeleteSubscriptionRequestEvent nextState=NULL
+policy state taskref create name=ReceiveEventPolicy stateName=DeleteSubscription taskName=DeleteSubscriptionRequestTask outputType=DIRECT outputName=IssueDeleteSubscriptionRequestOutput
+policy state contextref create name=ReceiveEventPolicy stateName=DeleteSubscription albumName=PMSubscriptionAlbum
+
+# State CreateOrDeleteState
+policy state create name=ReceiveEventPolicy stateName=CreateOrDeleteState triggerName=PMSubscriptionOutputEvent defaultTaskName=CreateSubscriptionPayloadTask
+
+policy state output create name=ReceiveEventPolicy stateName=CreateOrDeleteState outputName=CreateSubscriptionPayload eventName=CreateSubscriptionPayloadEvent nextState=CreateSubscription
+policy state taskref create name=ReceiveEventPolicy stateName=CreateOrDeleteState taskName=CreateSubscriptionPayloadTask outputType=DIRECT outputName=CreateSubscriptionPayload
+
+policy state output create name=ReceiveEventPolicy stateName=CreateOrDeleteState outputName=DeleteSubscriptionPayload eventName=DeleteSubscriptionPayloadEvent nextState=DeleteSubscription
+policy state taskref create name=ReceiveEventPolicy stateName=CreateOrDeleteState taskName=DeleteSubscriptionPayloadTask outputType=DIRECT outputName=DeleteSubscriptionPayload
+
+policy state contextref create name=ReceiveEventPolicy stateName=CreateOrDeleteState albumName=PMSubscriptionAlbum
+policy state selecttasklogic create name=ReceiveEventPolicy stateName=CreateOrDeleteState logicFlavour=JAVASCRIPT logic=LS
+#MACROFILE:"src/main/resources/logic/CreateOrDeleteStateTSL.js"
+LE
+
+# State ReceiveSubscriptionState
+policy state create name=ReceiveEventPolicy stateName=ReceiveSubscriptionState triggerName=testPolicyB defaultTaskName=ReceivePMSubscriptionTask
+policy state output create name=ReceiveEventPolicy stateName=ReceiveSubscriptionState outputName=ReceivePMSubscriptionOutput eventName=PMSubscriptionOutputEvent nextState=CreateOrDeleteState
+policy state taskref create name=ReceiveEventPolicy stateName=ReceiveSubscriptionState taskName=ReceivePMSubscriptionTask outputType=DIRECT outputName=ReceivePMSubscriptionOutput
+policy state contextref create name=ReceiveEventPolicy stateName=ReceiveSubscriptionState albumName=PMSubscriptionAlbum
+
+
+# Policy CDSResponsePolicy
+policy create name=CDSResponsePolicy template=Freestyle firstState=CDSResponseState
+
+# State CDSResponseState
+policy state create name=CDSResponsePolicy stateName=CDSResponseState triggerName=CDSResponseEvent defaultTaskName=CDSResponseTask
+policy state output create name=CDSResponsePolicy stateName=CDSResponseState outputName=ResponseOutput eventName=CDSResponseStatusEvent
+policy state taskref create name=CDSResponsePolicy stateName=CDSResponseState taskName=CDSResponseTask outputType=DIRECT outputName=ResponseOutput
+
+validate \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/schemas/CDSActionIdentifiersType.avsc b/examples/examples-grpc/src/main/resources/schemas/CDSActionIdentifiersType.avsc
new file mode 100644
index 000000000..1d5551704
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/schemas/CDSActionIdentifiersType.avsc
@@ -0,0 +1,23 @@
+{
+ "type": "record",
+ "name": "CDSActionIdentifiers_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "actionName",
+ "type": "string"
+ },
+ {
+ "name": "blueprintName",
+ "type": "string"
+ },
+ {
+ "name": "blueprintVersion",
+ "type": "string"
+ },
+ {
+ "name": "mode",
+ "type": "string"
+ }
+ ]
+}
diff --git a/examples/examples-grpc/src/main/resources/schemas/CDSCreateSubscriptionPayloadType.avsc b/examples/examples-grpc/src/main/resources/schemas/CDSCreateSubscriptionPayloadType.avsc
new file mode 100644
index 000000000..4dc03d300
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/schemas/CDSCreateSubscriptionPayloadType.avsc
@@ -0,0 +1,91 @@
+{
+ "type": "map",
+ "values": {
+ "type": "record",
+ "name": "CDSRequestPayloadEntry",
+ "fields": [
+ {
+ "name": "create_DasH_subscription_DasH_properties",
+ "type": {
+ "name": "create_DasH_subscription_DasH_properties_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "nfName",
+ "type": "string"
+ },
+ {
+ "name": "subscriptionName",
+ "type": "string"
+ },
+ {
+ "name": "administrativeState",
+ "type": "string"
+ },
+ {
+ "name": "fileBasedGP",
+ "type": "string"
+ },
+ {
+ "name": "fileLocation",
+ "type": "string"
+ },
+ {
+ "name": "measurementGroups",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementGroups_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementGroup",
+ "type": {
+ "name": "measurementGroup",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementTypes",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementTypes_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementType",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "managedObjectDNsBasic",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "managedObjectDNsBasic_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "DN",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/schemas/CDSDeleteSubscriptionPayloadType.avsc b/examples/examples-grpc/src/main/resources/schemas/CDSDeleteSubscriptionPayloadType.avsc
new file mode 100644
index 000000000..437c51c70
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/schemas/CDSDeleteSubscriptionPayloadType.avsc
@@ -0,0 +1,91 @@
+{
+ "type": "map",
+ "values": {
+ "type": "record",
+ "name": "CDSRequestPayloadEntry",
+ "fields": [
+ {
+ "name": "delete_DasH_subscription_DasH_properties",
+ "type": {
+ "name": "delete_DasH_subscription_DasH_properties_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "nfName",
+ "type": "string"
+ },
+ {
+ "name": "subscriptionName",
+ "type": "string"
+ },
+ {
+ "name": "administrativeState",
+ "type": "string"
+ },
+ {
+ "name": "fileBasedGP",
+ "type": "string"
+ },
+ {
+ "name": "fileLocation",
+ "type": "string"
+ },
+ {
+ "name": "measurementGroups",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementGroups_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementGroup",
+ "type": {
+ "name": "measurementGroup",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementTypes",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "measurementTypes_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementType",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "managedObjectDNsBasic",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "managedObjectDNsBasic_record",
+ "type": "record",
+ "fields": [
+ {
+ "name": "DN",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/schemas/CDSRequestCommonHeaderType.avsc b/examples/examples-grpc/src/main/resources/schemas/CDSRequestCommonHeaderType.avsc
new file mode 100644
index 000000000..7e7e9256c
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/schemas/CDSRequestCommonHeaderType.avsc
@@ -0,0 +1,19 @@
+{
+ "type": "record",
+ "name": "CDSRequestCommonHeader_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "originatorId",
+ "type": "string"
+ },
+ {
+ "name": "requestId",
+ "type": "string"
+ },
+ {
+ "name": "subRequestId",
+ "type": "string"
+ }
+ ]
+}
diff --git a/examples/examples-grpc/src/main/resources/schemas/CDSResponseCommonHeaderType.avsc b/examples/examples-grpc/src/main/resources/schemas/CDSResponseCommonHeaderType.avsc
new file mode 100644
index 000000000..fe2fae8c7
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/schemas/CDSResponseCommonHeaderType.avsc
@@ -0,0 +1,23 @@
+{
+ "type": "record",
+ "name": "CDSResponseCommonHeader_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "originatorId",
+ "type": "string"
+ },
+ {
+ "name": "requestId",
+ "type": "string"
+ },
+ {
+ "name": "subRequestId",
+ "type": "string"
+ },
+ {
+ "name": "timestamp",
+ "type": "string"
+ }
+ ]
+}
diff --git a/examples/examples-grpc/src/main/resources/schemas/CDSResponsePayloadType.avsc b/examples/examples-grpc/src/main/resources/schemas/CDSResponsePayloadType.avsc
new file mode 100644
index 000000000..e8a958119
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/schemas/CDSResponsePayloadType.avsc
@@ -0,0 +1,29 @@
+{
+ "name": "CDSResponsePayloadEntry",
+ "type": "record",
+ "namespace": "com.acme.avro",
+ "fields": [
+ {
+ "name": "create_DasH_subscription_DasH_response",
+ "type": {
+ "name": "create_DasH_subscription_DasH_response",
+ "type": "record",
+ "fields": [
+ {
+ "name": "odl_DasH_response",
+ "type": {
+ "name": "odl_DasH_response",
+ "type": "record",
+ "fields": [
+ {
+ "name": "status",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/examples/examples-grpc/src/main/resources/schemas/CDSResponseStatusType.avsc b/examples/examples-grpc/src/main/resources/schemas/CDSResponseStatusType.avsc
new file mode 100644
index 000000000..fa2dfa7d6
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/schemas/CDSResponseStatusType.avsc
@@ -0,0 +1,23 @@
+{
+ "type": "record",
+ "name": "CDSResponseStatus_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "code",
+ "type": "int"
+ },
+ {
+ "name": "eventType",
+ "type": "string"
+ },
+ {
+ "name": "timestamp",
+ "type": "string"
+ },
+ {
+ "name": "message",
+ "type": "string"
+ }
+ ]
+}
diff --git a/examples/examples-grpc/src/main/resources/schemas/PMSubscriptionType.avsc b/examples/examples-grpc/src/main/resources/schemas/PMSubscriptionType.avsc
new file mode 100644
index 000000000..1d9c7d4b4
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/schemas/PMSubscriptionType.avsc
@@ -0,0 +1,101 @@
+{
+ "name": "PMSubscription",
+ "type": "record",
+ "namespace": "org.onap.policy.apex.onap.pmcontrol",
+ "fields": [
+ {
+ "name": "nfName",
+ "type": "string"
+ },
+ {
+ "name": "changeType",
+ "type": "string"
+ },
+ {
+ "name": "closedLoopControlName",
+ "type": "string"
+ },
+ {
+ "name": "policyName",
+ "type": "string"
+ },
+ {
+ "name": "subscription",
+ "type": {
+ "name": "subscription",
+ "type": "record",
+ "fields": [
+ {
+ "name": "subscriptionName",
+ "type": "string"
+ },
+ {
+ "name": "administrativeState",
+ "type": "string"
+ },
+ {
+ "name": "fileBasedGP",
+ "type": "int"
+ },
+ {
+ "name": "fileLocation",
+ "type": "string"
+ },
+ {
+ "name": "measurementGroups",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "Measurement_Groups_Type",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementGroup",
+ "type": {
+ "name": "Measurement_Group_Type",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementTypes",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "Measurement_Types_Type",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementType",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "managedObjectDNsBasic",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "Managed_Object_Dns_Basic_Type",
+ "type": "record",
+ "fields": [
+ {
+ "name": "DN",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/schemas/SubscriptionStatusType.avsc b/examples/examples-grpc/src/main/resources/schemas/SubscriptionStatusType.avsc
new file mode 100644
index 000000000..247ba8a8c
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/schemas/SubscriptionStatusType.avsc
@@ -0,0 +1,23 @@
+{
+ "type": "record",
+ "name": "ActivateSubscriptionStatus_Type",
+ "namespace": "org.onap.policy.apex.onap.helloworld",
+ "fields": [
+ {
+ "name": "subscriptionName",
+ "type": "string"
+ },
+ {
+ "name": "nfName",
+ "type": "string"
+ },
+ {
+ "name": "changeType",
+ "type": "string"
+ },
+ {
+ "name": "message",
+ "type": "string"
+ }
+ ]
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/schemas/SubscriptionType.avsc b/examples/examples-grpc/src/main/resources/schemas/SubscriptionType.avsc
new file mode 100644
index 000000000..7172b7aab
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/schemas/SubscriptionType.avsc
@@ -0,0 +1,75 @@
+{
+ "name": "subscription",
+ "type": "record",
+ "fields": [
+ {
+ "name": "subscriptionName",
+ "type": "string"
+ },
+ {
+ "name": "administrativeState",
+ "type": "string"
+ },
+ {
+ "name": "fileBasedGP",
+ "type": "int"
+ },
+ {
+ "name": "fileLocation",
+ "type": "string"
+ },
+ {
+ "name": "measurementGroups",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "Measurement_Groups_Type",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementGroup",
+ "type": {
+ "name": "Measurement_Group_Type",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementTypes",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "Measurement_Types_Type",
+ "type": "record",
+ "fields": [
+ {
+ "name": "measurementType",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ },
+ {
+ "name": "managedObjectDNsBasic",
+ "type": {
+ "type": "array",
+ "items": {
+ "name": "Managed_Object_Dns_Basic_Type",
+ "type": "record",
+ "fields": [
+ {
+ "name": "DN",
+ "type": "string"
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/tosca/ToscaPolicyType.json b/examples/examples-grpc/src/main/resources/tosca/ToscaPolicyType.json
new file mode 100644
index 000000000..33c7337db
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/tosca/ToscaPolicyType.json
@@ -0,0 +1,260 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
+ "policy_types": {
+ "onap.policies.controlloop.operational.Apex": {
+ "version": "1.0.0",
+ "description": "Operational Policy for Control Loops using the APEX PDP",
+ "properties": {
+ "engine_service": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.EngineService",
+ "description": "APEX Engine Service Parameters"
+ },
+ "inputs": {
+ "type": "map",
+ "description": "Inputs for handling events coming into the APEX engine",
+ "entry_schema": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.EventHandler"
+ }
+ },
+ "outputs": {
+ "type": "map",
+ "description": "Outputs for handling events going out of the APEX engine",
+ "entry_schema": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.EventHandler"
+ }
+ },
+ "environment": {
+ "type": "list",
+ "description": "Envioronmental parameters for the APEX engine",
+ "entry_schema": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.Environment"
+ }
+ }
+ }
+ }
+ },
+ "data_types": {
+ "onap.datatypes.policies.controlloop.operational.apex.EngineService": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "Specifies the engine name",
+ "required": false,
+ "default": "ApexEngineService"
+ },
+ "version": {
+ "type": "string",
+ "description": "Specifies the engine version in double dotted format",
+ "required": false,
+ "default": "1.0.0"
+ },
+ "id": {
+ "type": "integer",
+ "description": "Specifies the engine id",
+ "required": true
+ },
+ "instance_count": {
+ "type": "integer",
+ "description": "Specifies the number of engine threads that should be run",
+ "required": true
+ },
+ "deployment_port": {
+ "type": "integer",
+ "description": "Specifies the port to connect to for engine administration",
+ "required": false,
+ "default": 1
+ },
+ "policy_model_file_name": {
+ "type": "string",
+ "description": "The name of the file from which to read the APEX policy model",
+ "required": false
+ },
+ "policy_type_impl": {
+ "type": "string",
+ "description": "The policy type implementation from which to read the APEX policy model",
+ "required": false
+ },
+ "periodic_event_period": {
+ "type": "string",
+ "description": "The time interval in milliseconds for the periodic scanning event, 0 means \"don't scan\"",
+ "required": false,
+ "default": 0
+ },
+ "engine": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.engineservice.Engine",
+ "description": "The parameters for all engines in the APEX engine service",
+ "required": true
+ }
+ }
+ },
+ "onap.datatypes.policies.controlloop.operational.apex.EventHandler": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "Specifies the event handler name, if not specified this is set to the key name",
+ "required": false
+ },
+ "carrier_technology": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.CarrierTechnology",
+ "description": "Specifies the carrier technology of the event handler (such as REST/Web Socket/Kafka)",
+ "required": true
+ },
+ "event_protocol": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.EventProtocol",
+ "description": "Specifies the event protocol of events for the event handler (such as Yaml/JSON/XML/POJO)",
+ "required": true
+ },
+ "event_name": {
+ "type": "string",
+ "description": "Specifies the event name for events on this event handler, if not specified, the event name is read from or written to the event being received or sent",
+ "required": false
+ },
+ "event_name_filter": {
+ "type": "string",
+ "description": "Specifies a filter as a regular expression, events that do not match the filter are dropped, the default is to let all events through",
+ "required": false
+ },
+ "synchronous_mode": {
+ "type": "boolean",
+ "description": "Specifies the event handler is syncronous (receive event and send response)",
+ "required": false,
+ "default": false
+ },
+ "synchronous_peer": {
+ "type": "string",
+ "description": "The peer event handler (output for input or input for output) of this event handler in synchronous mode, this parameter is mandatory if the event handler is in synchronous mode",
+ "required": false
+ },
+ "synchronous_timeout": {
+ "type": "integer",
+ "description": "The timeout in milliseconds for responses to be issued by APEX torequests, this parameter is mandatory if the event handler is in synchronous mode",
+ "required": false
+ },
+ "requestor_mode": {
+ "type": "boolean",
+ "description": "Specifies the event handler is in requestor mode (send event and wait for response mode)",
+ "required": false,
+ "default": false
+ },
+ "requestor_peer": {
+ "type": "string",
+ "description": "The peer event handler (output for input or input for output) of this event handler in requestor mode, this parameter is mandatory if the event handler is in requestor mode",
+ "required": false
+ },
+ "requestor_timeout": {
+ "type": "integer",
+ "description": "The timeout in milliseconds for wait for responses to requests, this parameter is mandatory if the event handler is in requestor mode",
+ "required": false
+ }
+ }
+ },
+ "onap.datatypes.policies.controlloop.operational.apex.CarrierTechnology": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "label": {
+ "type": "string",
+ "description": "The label (name) of the carrier technology (such as REST, Kafka, WebSocket)",
+ "required": true
+ },
+ "plugin_parameter_class_name": {
+ "type": "string",
+ "description": "The class name of the class that overrides default handling of event input or output for this carrier technology, defaults to the supplied input or output class",
+ "required": false
+ }
+ }
+ },
+ "onap.datatypes.policies.controlloop.operational.apex.EventProtocol": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "label": {
+ "type": "string",
+ "description": "The label (name) of the event protocol (such as Yaml, JSON, XML, or POJO)",
+ "required": true
+ },
+ "event_protocol_plugin_class": {
+ "type": "string",
+ "description": "The class name of the class that overrides default handling of the event protocol for this carrier technology, defaults to the supplied event protocol class",
+ "required": false
+ }
+ }
+ },
+ "onap.datatypes.policies.controlloop.operational.apex.Environment": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "The name of the environment variable",
+ "required": true
+ },
+ "value": {
+ "type": "string",
+ "description": "The value of the environment variable",
+ "required": true
+ }
+ }
+ },
+ "onap.datatypes.policies.controlloop.operational.apex.engineservice.Engine": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "context": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.engineservice.engine.Context",
+ "description": "The properties for handling context in APEX engines, defaults to using Java maps for context",
+ "required": false
+ },
+ "executors": {
+ "type": "map",
+ "description": "The plugins for policy executors used in engines such as javascript, MVEL, Jython",
+ "required": true,
+ "entry_schema": {
+ "description": "The plugin class path for this policy executor",
+ "type": "string"
+ }
+ }
+ }
+ },
+ "onap.datatypes.policies.controlloop.operational.apex.engineservice.engine.Context": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "distributor": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.Plugin",
+ "description": "The plugin to be used for distributing context between APEX PDPs at runtime",
+ "required": false
+ },
+ "schemas": {
+ "type": "map",
+ "description": "The plugins for context schemas available in APEX PDPs such as Java and Avro",
+ "required": false,
+ "entry_schema": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.Plugin"
+ }
+ },
+ "locking": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.Plugin",
+ "description": "The plugin to be used for locking context in and between APEX PDPs at runtime",
+ "required": false
+ },
+ "persistence": {
+ "type": "onap.datatypes.policies.controlloop.operational.apex.Plugin",
+ "description": "The plugin to be used for persisting context for APEX PDPs at runtime",
+ "required": false
+ }
+ }
+ },
+ "onap.datatypes.policies.controlloop.operational.apex.Plugin": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "name": {
+ "type": "string",
+ "description": "The name of the executor such as Javascript, Jython or MVEL",
+ "required": true
+ },
+ "plugin_class_name": {
+ "type": "string",
+ "description": "The class path of the plugin class for this executor"
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/examples/examples-grpc/src/main/resources/tosca/ToscaTemplate.json b/examples/examples-grpc/src/main/resources/tosca/ToscaTemplate.json
new file mode 100644
index 000000000..35322a61a
--- /dev/null
+++ b/examples/examples-grpc/src/main/resources/tosca/ToscaTemplate.json
@@ -0,0 +1,16 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
+ "topology_template": {
+ "policies": [
+ {
+ "operational.gRPC": {
+ "type": "onap.policies.controlloop.operational.Apex",
+ "typeVersion": "1.0.0",
+ "version": "1.0.0",
+ "properties": {
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file