summaryrefslogtreecommitdiffstats
path: root/examples/examples-grpc/src/main/resources/policy/APEXgRPCPolicy.apex
blob: bb08c706310c90d2919ec5d822befed73751253b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#-------------------------------------------------------------------------------
# ============LICENSE_START=======================================================
#  Copyright (C) 2020 Nordix Foundation.
#  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.
# 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=Json schema=LS
#MACROFILE:"src/main/resources/schemas/CDSRequestCommonHeaderType.json"
LE

schema create name=CDSResponseCommonHeaderType flavour=Json schema=LS
#MACROFILE:"src/main/resources/schemas/CDSResponseCommonHeaderType.json"
LE

schema create name=CDSActionIdentifiersType flavour=Json schema=LS
#MACROFILE:"src/main/resources/schemas/CDSActionIdentifiersType.json"
LE

schema create name=CDSResponseStatusType flavour=Json schema=LS
#MACROFILE:"src/main/resources/schemas/CDSResponseStatusType.json"
LE

schema create name=CDSCreateSubscriptionPayloadType flavour=Json schema=LS
#MACROFILE:"src/main/resources/schemas/CDSCreateSubscriptionPayloadType.json"
LE

schema create name=CDSDeleteSubscriptionPayloadType flavour=Avro schema=LS
#MACROFILE:"src/main/resources/schemas/CDSDeleteSubscriptionPayloadType.avsc"
LE

schema create name=CDSResponsePayloadType flavour=Json schema=LS
#MACROFILE:"src/main/resources/schemas/CDSResponsePayloadType.json"
LE

schema create name=SubscriptionStatusType flavour=Json schema=LS
#MACROFILE:"src/main/resources/schemas/SubscriptionStatusType.json"
LE

schema create name=PMSubscriptionType flavour=Json schema=LS
#MACROFILE:"src/main/resources/schemas/PMSubscriptionType.json"
LE

schema create name=SubscriptionType flavour=Json schema=LS
#MACROFILE:"src/main/resources/schemas/SubscriptionType.json"
LE

##
## EVENTS
##

album create name=PMSubscriptionAlbum scope=policy writable=true schemaName=PMSubscriptionType

# Incoming event
event create name=testPolicyB version=0.0.1 nameSpace=org.onap.policy.apex.onap.pmcontrol source=DCAE target=APEX toscaPolicyState=ENTRY
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 toscaPolicyState=EXIT_SUCCESS
event parameter create name=CDSResponseStatusEvent parName=status schemaName=SubscriptionStatusType

event create name=LogEvent nameSpace=org.onap.policy.apex.onap.pmcontrol source=APEX target=DCAE
event parameter create name=LogEvent parName=final_status schemaName=SimpleStringType
event parameter create name=LogEvent parName=message schemaName=SimpleStringType

##
## TASKS
##


task create name=ReceivePMSubscriptionTask
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 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 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 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 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 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 output create name=CDSResponsePolicy stateName=CDSResponseState outputName=ResponseOutput eventName=LogEvent
policy state taskref create name=CDSResponsePolicy stateName=CDSResponseState taskName=CDSResponseTask outputType=DIRECT outputName=ResponseOutput

validate