Merge "Fix sonar issues in crud/logging/LoggingUtil"
[aai/gizmo.git] / ASYNC.md
1 # ASYNCHRONOUS MODE
2
3 Gizmo has two modes, a Synchoronous (sync) mode and an Asynchronous (async) mode.
4
5 In the Async mode, Gizmo uses the consumer/producer model where when a
6 client makes a request, Gizmo will generate an event payload and
7 publish it  on the async event stream. It will then wait for a
8 response for that particular event on a different event stream. Once it recieves a
9 response, gizmo will send a response back to the client which made the
10 original request.
11
12 Note: In the examples below, there is a database-transaction-id and a
13 transaction-id. A database-transaction-id is only present in the
14 payload when it's part of bulk operation.
15
16 ## Here are a few examples of the events published by Gizmo
17
18 ### Vertex
19
20 #### Adding a Vertex
21
22     {
23         "timestamp": 1514927928167,
24         "operation": "CREATE",
25         "vertex": {
26             "properties": {
27                 "ipv4-oam-address": "1.2.3.4",
28                 "resource-version": "1477013499",
29                 "purpose": "my-purpose",
30                 "fqdn": "myhost.onap.net",
31                 "in-maint": false,
32                 "equip-model": "DL380p-nd",
33                 "equip-vendor": "HP",
34                 "equip-type": "server",
35                 "hostname": "myhost",
36                 "ptnii-equip-name": "e-name"
37             },
38             "key": "",
39             "type": "pserver",
40             "schema-version": "vX"
41         },
42         "transaction-id": "c0a81fa7-5ef4-49cd-ab39-e42c53c9b9a4",
43         "database-transaction-id": "b3e2853e-f643-47a3-a0c3-cb54cc997ad3"
44     }
45
46 #### Updating a Vertex
47
48     {
49         "timestamp": 1514929776429,
50         "operation": "UPDATE",
51         "vertex": {
52             "properties": {
53                 "ipv4-oam-address": "1.2.3.4",
54                 "resource-version": "1477013499",
55                 "purpose": "my-purpose",
56                 "fqdn": "updated.myhost.onap.net",
57                 "in-maint": false,
58                 "equip-model": "DELL380p-nd",
59                 "equip-vendor": "DELL",
60                 "equip-type": "updated-server",
61                 "hostname": "updated-myhost",
62                 "ptnii-equip-name": "name-has-been-updated"
63             },
64             "key": "84bf7b3f-81f5-4c34-ab5c-207281cb71bd",
65             "type": "pserver",
66             "schema-version": "vX"
67         },
68         "transaction-id": "3b8df1d5-4c51-47e3-bbef-c27b47e11149",
69         "database-transaction-id": "b3e2853e-f643-47a3-a0c3-cb54cc997ad3"
70     }
71
72 #### Deleting a Vertex
73
74     {
75         "timestamp": 1514930052327,
76         "operation": "DELETE",
77         "vertex": {
78             "key": "84bf7b3f-81f5-4c34-ab5c-207281cb71bd",
79             "type": "pserver",
80             "schema-version": "vX"
81         },
82         "transaction-id": "6bb7a27b-a942-4cac-9b2b-0fa1f3897b8c",
83         "database-transaction-id": "b3e2853e-f643-47a3-a0c3-cb54cc997ad3"
84     }
85
86
87 #### Adding an Edge
88
89     {
90       "timestamp": 1515005153863,
91       "operation": "CREATE",
92       "edge": {
93         "target": {
94           "key": "febd8996-62ec-4ce6-ba8e-d2fa1609e13b",
95           "type": "pserver"
96         },
97         "properties": {
98           "contains-other-v": "NONE",
99           "delete-other-v": "NONE",
100           "prevent-delete": "IN",
101           "SVC-INFRA": "OUT"
102         },
103         "key": "",
104         "type": "tosca.relationships.HostedOn",
105         "schema-version": "v11",
106         "source": {
107           "key": "7beade35-19f1-4c1d-a1bd-bfba59e0b582",
108           "type": "vserver"
109         }
110       },
111       "transaction-id": "63a8994d-1118-4e65-ab06-fff40f6f48ef",
112       "database-transaction-id": "b3e2853e-f643-47a3-a0c3-cb54cc997ad3"
113     }
114
115 #### Replace an Edge
116
117     {
118       "timestamp": 1515005301622,
119       "operation": "UPDATE",
120       "edge": {
121         "target": {
122           "key": "febd8996-62ec-4ce6-ba8e-d2fa1609e13b",
123           "type": "pserver"
124         },
125         "properties": {
126           "contains-other-v": "NOPE",
127           "delete-other-v": "YES",
128           "prevent-delete": "MAYBE",
129           "SVC-INFRA": "OUT"
130         },
131         "key": "9727a0ea-559e-497c-98e4-0cbdaede0346",
132         "type": "tosca.relationships.HostedOn",
133         "schema-version": "v11",
134         "source": {
135           "key": "7beade35-19f1-4c1d-a1bd-bfba59e0b582",
136           "type": "vserver"
137         }
138       },
139       "transaction-id": "ed284991-6c2f-4c94-a592-76fed17a2f14",
140       "database-transaction-id": "b3e2853e-f643-47a3-a0c3-cb54cc997ad3"
141     }
142
143
144 #### Deleting an Edge
145
146     {
147       "timestamp": 1515005579837,
148       "operation": "DELETE",
149       "edge": {
150         "key": "9727a0ea-559e-497c-98e4-0cbdaede0346",
151         "type": "tosca.relationships.HostedOn",
152         "schema-version": "v11"
153       },
154       "transaction-id": "b4583bc9-dd96-483f-ab2d-20c1c6e5622f",
155       "database-transaction-id": "b3e2853e-f643-47a3-a0c3-cb54cc997ad3"
156     }
157
158
159 ## Gizmo expects a response event in the following formats
160
161 ### Vertex
162
163 #### Adding Vertex Response
164
165     {
166       "timestamp": 1519832579046,
167       "operation": "CREATE",
168       "vertex": {
169         "properties": {
170           "last-mod-source-of-truth": "champ-response",
171           "resource-version": "1477013499",
172           "aai-uuid": "12a0ca27-25b1-41c2-b9ff-4bf54a3caa8a",
173           "in-maint": false,
174           "equip-model": "DELL380p-nd",
175           "hostname": "updated-myhost",
176           "source-of-truth": "champ-response",
177           "ipv4-oam-address": "1.2.3.4",
178           "aai-created-ts": 1519832577709,
179           "purpose": "my-purpose",
180           "fqdn": "updated.myhost.onap.net",
181           "equip-vendor": "DELL",
182           "equip-type": "updated-server",
183           "aai-last-mod-ts": 1519832577709,
184           "ptnii-equip-name": "testing"
185         },
186         "key": "12a0ca27-25b1-41c2-b9ff-4bf54a3caa8a",
187         "type": "pserver",
188         "schema-version": "v11"
189       },
190       "transaction-id": "d5c15dd3-2492-4ab9-86a3-e1cd39221e4a",
191       "result": "SUCCESS"
192     }
193
194 #### Updating Vertex Response
195
196     {
197       "timestamp": 1519833774425,
198       "operation": "UPDATE",
199       "vertex": {
200         "properties": {
201           "last-mod-source-of-truth": "shwetank-updating",
202           "resource-version": "shwetank-resource",
203           "aai-uuid": "12a0ca27-25b1-41c2-b9ff-4bf54a3caa8a",
204           "in-maint": false,
205           "equip-model": "testing-update",
206           "hostname": "sdave",
207           "source-of-truth": "champ-response",
208           "ipv4-oam-address": "1.2.3.4",
209           "aai-created-ts": 1519832577709,
210           "purpose": "my-purpose-testing-update",
211           "fqdn": "created.myhost.onap.net",
212           "equip-vendor": "testing-update",
213           "equip-type": "shwetank",
214           "aai-last-mod-ts": 1519833774407,
215           "ptnii-equip-name": "testing-update"
216         },
217         "key": "12a0ca27-25b1-41c2-b9ff-4bf54a3caa8a",
218         "type": "pserver",
219         "schema-version": "v11"
220       },
221       "transaction-id": "2981a1b0-30d6-4323-8b36-c80636a1639f",
222       "result": "SUCCESS"
223     }
224
225
226 #### Deleting Vertex Response
227
228     {
229       "timestamp": 1519839126416,
230       "operation": "DELETE",
231       "vertex": {
232         "key": "12a0ca27-25b1-41c2-b9ff-4bf54a3caa8a",
233         "type": "pserver",
234         "schema-version": "v11"
235       },
236       "transaction-id": "78650070-a500-47bb-98e5-e46aba77612a",
237       "result": "SUCCESS"
238     }
239
240
241 ### Edge
242
243 #### Adding Edge Response
244
245     {
246       "timestamp": 1519835679492,
247       "operation": "CREATE",
248       "edge": {
249         "target": {
250           "key": "2674b073-2eb5-484b-a21c-7e36983b7cd4",
251           "type": "pserver"
252         },
253         "properties": {
254           "contains-other-v": "NONE",
255           "delete-other-v": "NONE",
256           "aai-created-ts": 1519835679447,
257           "prevent-delete": "IN",
258           "SVC-INFRA": "OUT",
259           "aai-uuid": "149620ae-2382-41a2-b626-1dd321fad4bb",
260           "aai-last-mod-ts": 1519835679447
261         },
262         "key": "149620ae-2382-41a2-b626-1dd321fad4bb",
263         "type": "tosca.relationships.HostedOn",
264         "schema-version": "v11",
265         "source": {
266           "key": "b945d923-b596-4339-a80f-f72ca9a4fe1f",
267           "type": "vserver"
268         }
269       },
270       "transaction-id": "83c7776d-88c9-4fbe-b129-11f40d20348b",
271       "result": "SUCCESS"
272     }
273
274 #### Update Edge Response
275
276     {
277       "timestamp": 1519838804681,
278       "operation": "UPDATE",
279       "edge": {
280         "target": {
281           "key": "2674b073-2eb5-484b-a21c-7e36983b7cd4",
282           "type": "pserver"
283         },
284         "properties": {
285           "contains-other-v": "NONE",
286           "delete-other-v": "NONE",
287           "aai-created-ts": 1519835679447,
288           "SVC-INFRA": "OUT",
289           "prevent-delete": "TRUE",
290           "aai-uuid": "149620ae-2382-41a2-b626-1dd321fad4bb",
291           "aai-last-mod-ts": 1519838804671
292         },
293         "key": "149620ae-2382-41a2-b626-1dd321fad4bb",
294         "type": "tosca.relationships.HostedOn",
295         "schema-version": "v11",
296         "source": {
297           "key": "b945d923-b596-4339-a80f-f72ca9a4fe1f",
298           "type": "vserver"
299         }
300       },
301       "transaction-id": "644839f0-bb6d-490f-8f79-bb8227198ed2",
302       "result": "SUCCESS"
303     }
304
305 #### Delete Edge Response
306
307     {
308       "timestamp": 1519838964576,
309       "operation": "DELETE",
310       "edge": {
311         "key": "149620ae-2382-41a2-b626-1dd321fad4bb",
312         "type": "tosca.relationships.HostedOn",
313         "schema-version": "v11"
314       },
315       "transaction-id": "db3e67ae-28e3-4c1d-bf63-ec398cf28d98",
316       "result": "SUCCESS"
317     }
318
319
320 ### Misc
321
322 #### Failed Operation Response
323
324
325     {
326       "timestamp": 1519843867529,
327       "operation": "UPDATE",
328       "httpErrorStatus": "BAD_REQUEST",
329       "error-message": "aai-created-ts can't be updated",
330       "vertex": {
331         "properties": {
332           "last-mod-source-of-truth": "shwetank-creating-for-update",
333           "ipv4-oam-address": "1.2.3.4",
334           "aai-created-ts": 123456789,
335           "resource-version": "shwetank-resource",
336           "purpose": "my-purpose-creating-for-patching",
337           "fqdn": "created.myhost.onap.net",
338           "in-maint": false,
339           "equip-model": "creating-for-patching",
340           "equip-vendor": "creating-for-patching",
341           "equip-type": "testing-2",
342           "hostname": "sdave",
343           "ptnii-equip-name": "creating-for-patching"
344         },
345         "key": "10572385-3211-4c80-a7c5-cea648513271",
346         "type": "pserver",
347         "schema-version": "v11"
348       },
349       "transaction-id": "25d4c3e9-d4ab-41ec-b2a9-832286a726db",
350       "result": "FAILURE"
351     }