Update APEX example to use JSON Schema plugin
[policy/apex-pdp.git] / examples / examples-grpc / src / main / resources / logic / DeleteSubscriptionPayloadTask.js
1 /*
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2020 Nordix. All rights reserved.
4  *  Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 executor.logger.info(executor.subject.id);
23
24 var pmSubscriptionInfo = executor.getContextAlbum("PMSubscriptionAlbum").get(executor.inFields.get("albumID").toString())
25
26 var payloadProperties = new java.util.HashMap();
27
28 payloadProperties.put("nfName",  pmSubscriptionInfo.get("nfName"))
29 payloadProperties.put("subscriptionName",  pmSubscriptionInfo.get("subscription").get("subscriptionName"))
30 payloadProperties.put("administrativeState", pmSubscriptionInfo.get("subscription").get("administrativeState"))
31 payloadProperties.put("fileBasedGP",  pmSubscriptionInfo.get("subscription").get("fileBasedGP").toString())
32 payloadProperties.put("fileLocation", pmSubscriptionInfo.get("subscription").get("fileLocation"))
33 payloadProperties.put("measurementGroups", pmSubscriptionInfo.get("subscription").get("measurementGroups"))
34
35 var payloadEntry = new java.util.HashMap();
36 payloadEntry.put("delete-subscription-properties", payloadProperties)
37
38 var payload = new java.util.HashMap();
39 payload.put("delete-subscription-request", payloadEntry);
40
41 executor.outFields.put("albumID", executor.inFields.get("albumID"))
42 executor.outFields.put("payload", payload);
43
44 executor.logger.info("Sending delete Subscription Event to CDS")
45
46 true;