summaryrefslogtreecommitdiffstats
path: root/examples/examples-grpc/src/main/resources/logic
diff options
context:
space:
mode:
Diffstat (limited to 'examples/examples-grpc/src/main/resources/logic')
-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
7 files changed, 303 insertions, 0 deletions
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;