Merge "Fix sonar issues in crud/logging/LoggingUtil"
[aai/gizmo.git] / EDGE.md
1 ## Edge APIs
2
3 ### Create Edge
4
5 When creating an edge, the CRUD service will validate:
6 * properties match the defined schema
7 * relationship is valid between the source and target
8
9         URL: https://<host>:9520/services/inventory/relationships/v11/tosca.relationships.HostedOn/
10         Method: POST
11         Body:
12                 {     
13                         "source":"services/inventory/v11/vserver/0",
14                         "target":"services/inventory/v11/pserver/7",
15                         "properties":{   
16                                 "SVC-INFRA": "OUT",
17                 "prevent-delete": "IN",
18                 "delete-other-v": "NONE",
19                 "contains-other-v": "NONE"
20                         }
21                 }
22         Success Response:
23                 Code: 201
24                 Content:
25                         {   
26                                 "id":"215x5m-6hc-d6vp-oe08g",
27                                 "type":"tosca.relationships.HostedOn",
28                                 "url":"services/inventory/relationships/v11/has/215x5m-6hc-d6vp-oe08g",
29                                 "source":"services/inventory/v11/vserver/0",
30                                 "target":"services/inventory/v11/pserver/7",
31                                 "properties":{   
32                                         "SVC-INFRA": "OUT",
33                     "prevent-delete": "IN",
34                     "delete-other-v": "NONE",
35                     "contains-other-v": "NONE"
36                                 }
37                         }
38         Error Response:
39                 Code: 400 (BAD REQUEST)
40                 Content: Error message describing the bad request failure.
41                 Situation: Invalid Payload or schema error.
42
43                 Code: 403 (FORBIDDEN)
44                 Content: Error message describing the Authorization failure.
45                 Situation: Authorization failure.
46
47                 Code: 415 (UNSUPPORTED MEDIA TYPE)
48                 Situation: Unsupported content type .
49                 
50                 Code: 500 (Internal Server Error)
51                 Content: Error message describing the failure.
52                 Situation: Any scenario not covered by the above error codes.
53
54 Optionally, an edge can be created by posting to an endpoint which doesn't include the edge type.
55
56         URL: https://<host>:9520/services/inventory/relationships/v11/
57         Method: POST
58         Body:
59                 {    
60                         "type":"tosca.relationships.HostedOn",
61                         "source":"services/inventory/v11/vserver/0",
62                         "target":"services/inventory/v11/pserver/7",
63                         "properties":{   
64                                 "SVC-INFRA": "OUT",
65                 "prevent-delete": "IN",
66                 "delete-other-v": "NONE",
67                 "contains-other-v": "NONE"
68                         }
69                 }
70         Success Response:
71                 Code: 201
72                 Content: Same as above  
73         Error Response:
74                 Code: 400 (BAD REQUEST)
75                 Content: Error message describing the bad request failure.
76                 Situation: Invalid Payload or schema error.
77
78                 Code: 403 (FORBIDDEN)
79                 Content: Error message describing the Authorization failure.
80                 Situation: Authorization failure.
81
82                 Code: 415 (UNSUPPORTED MEDIA TYPE)
83                 Situation: Unsupported content type .
84                 
85                 Code: 500 (Internal Server Error)
86                 Content: Error message describing the failure.
87                 Situation: Any scenario not covered by the above error codes.
88  
89 ### Create Edge With Auto-Population Of Edge Properties
90 An alternate endpoint exists for creating edges which follows all of the conventions of the above endpoints, with the  addition that properties defined in the db edge rules produced by the A&AI will be automatically populated for the edge.
91
92         URL: https://<host>:9520/services/resources/relationships/tosca.relationships.HostedOn/
93         Method: POST
94         Body:
95                 {     
96                         "source":"services/inventory/v11/vserver/0",
97                         "target":"services/inventory/v11/pserver/7",
98                         "properties":{   
99
100                         }
101                 }
102         Success Response:
103                 Code: 201
104                 Content:
105                         {   
106                                 "id":"215x5m-6hc-d6vp-oe08g",
107                                 "type":"tosca.relationships.HostedOn",
108                                 "url":"services/inventory/relationships/v11/has/215x5m-6hc-d6vp-oe08g",
109                                 "source":"services/inventory/v11/vserver/0",
110                                 "target":"services/inventory/v11/pserver/7",
111                                 "properties":{   
112                     "SVC-INFRA": "OUT",
113                     "prevent-delete": "IN",
114                     "delete-other-v": "NONE",
115                     "contains-other-v": "NONE"
116                                 }
117                         }
118         Error Response:
119                 Code: 400 (BAD REQUEST)
120                 Content: Error message describing the bad request failure.
121                 Situation: Invalid Payload or schema error.
122
123                 Code: 403 (FORBIDDEN)
124                 Content: Error message describing the Authorization failure.
125                 Situation: Authorization failure.
126
127                 Code: 415 (UNSUPPORTED MEDIA TYPE)
128                 Situation: Unsupported content type .
129                 
130                 Code: 500 (Internal Server Error)
131                 Content: Error message describing the failure.
132                 Situation: Any scenario not covered by the above error codes.
133  
134 The same option to POST to an endpoint without specifying a type in the URL exists for this endpoint as well:
135
136         URL: https://<host>:9520/services/resources/relationships/
137         Method: POST
138         Body:
139                 {    
140                         "type":"tosca.relationships.HostedOn",
141                         "source":"services/inventory/v11/vserver/0",
142                         "target":"services/inventory/v11/pserver/7",
143                         "properties":{   
144                                 "SVC-INFRA": "OUT",
145                 "prevent-delete": "IN",
146                 "delete-other-v": "NONE",
147                 "contains-other-v": "NONE"
148                         }
149                 }
150         Success Response:
151                 Code: 201
152                 Content: Same as above  
153         Error Response:
154                 Code: 400 (BAD REQUEST)
155                 Content: Error message describing the bad request failure.
156                 Situation: Invalid Payload or schema error.
157
158                 Code: 403 (FORBIDDEN)
159                 Content: Error message describing the Authorization failure.
160                 Situation: Authorization failure.
161
162                 Code: 415 (UNSUPPORTED MEDIA TYPE)
163                 Situation: Unsupported content type .
164                 
165                 Code: 500 (Internal Server Error)
166                 Content: Error message describing the failure.
167                 Situation: Any scenario not covered by the above error codes.
168                 
169 ### Get Edge
170
171         URL: https://<host>:9520/services/inventory/relationships/v11/tosca.relationships.HostedOn/<id>
172         Method: GET
173         Success Response:
174                 Code: 200
175                 Content:
176                         {   
177                                 "id":"215x5m-6hc-d6vp-oe08g",
178                                 "type":"tosca.relationships.HostedOn",
179                                 "url":"services/inventory/relationships/tosca.relationships.HostedOn/has/215x5m-6hc-d6vp-oe08g",
180                                 "source":"services/inventory/v11/vserver/8400",
181                                 "target":"services/inventory/v11/pserver/40964272",
182                                 "properties":{   
183                     "SVC-INFRA": "OUT",
184                     "prevent-delete": "IN",
185                     "delete-other-v": "NONE",
186                     "contains-other-v": "NONE"
187                                 }
188                         }       
189         Error Response:
190                 Code: 404 (NOT FOUND)
191                 Situation: Resource Not found
192
193                 Code: 403 (FORBIDDEN)
194                 Content: Error message describing the Authorization failure.
195                 Situation: Authorization failure.
196
197                 Code: 415 (UNSUPPORTED MEDIA TYPE)
198                 Situation: Unsupported content type .
199                 
200                 Code: 500 (Internal Server Error)
201                 Content: Error message describing the failure.
202                 Situation: Any scenario not covered by the above error codes.
203
204 ### Get Edges
205
206         URL: https://<host>:9520/services/inventory/relationships/v11/tosca.relationships.HostedOn
207         Optional Query Param: ?multiplicity=many
208         Method: GET
209         Success Response:
210                 Code: 200
211                 Content:
212                         [   
213                                 {   
214                                         "id":"1crwnu-6hc-d6vp-oe08g",
215                                         "type":"tosca.relationships.HostedOn",
216                                         "url":"services/inventory/relationships/v11/tosca.relationships.HostedOn/1crwnu-6hc-d6vp-oe08g",
217                                         "source":"services/inventory/v11/vserver/8400",
218                                         "target":"services/inventory/v11/pserver/40964272"
219                                 },
220                                 {   
221                                         "id":"215x5m-6hc-d6vp-oe08g",
222                                         "type":"tosca.relationships.HostedOn",
223                                         "url":"services/inventory/relationships/v11/tosca.relationships.HostedOn/215x5m-6hc-d6vp-oe08g",
224                                         "source":"services/inventory/v11/vserver/8400",
225                                         "target":"services/inventory/v11/pserver/40964272"
226                                 }
227                         ]
228         Error Response:
229                 Code: 404 (NOT FOUND)
230                 Situation: Resource Not found
231
232                 Code: 403 (FORBIDDEN)
233                 Content: Error message describing the Authorization failure.
234                 Situation: Authorization failure.
235
236                 Code: 415 (UNSUPPORTED MEDIA TYPE)
237                 Situation: Unsupported content type .
238                 
239                 Code: 500 (Internal Server Error)
240                 Content: Error message describing the failure.
241                 Situation: Any scenario not covered by the above error codes.           
242
243 ### Update Edge
244
245 The PUT command is used to modify an existing edge.  By default, the edge data is replaced by the content of the payload.  However, the following parameter can be added to the header to perform a PATCH instead of a replace:
246 **X-HTTP-Method-Override=Patch**
247
248         URL: https://<host>:9520/services/inventory/relationships/v11/tosca.relationships.HostedOn/<id>
249         Method: PUT
250         Body: (**Note that the source and target can not be modified)
251                 {     
252                         "properties":{   
253                 "SVC-INFRA": "OUT",
254                 "prevent-delete": "IN",
255                 "delete-other-v": "NONE",
256                 "contains-other-v": "NONE"
257                         }
258                 }
259         Success Response:
260                 Code: 200
261                 Content: Same as POST   
262         Error Response:
263                 Code: 400 (BAD REQUEST)
264                 Content: Error message describing the bad request failure.
265                 Situation: Invalid Payload or schema error.
266
267                 Code: 403 (FORBIDDEN)
268                 Content: Error message describing the Authorization failure.
269                 Situation: Authorization failure.
270
271                 Code: 415 (UNSUPPORTED MEDIA TYPE)
272                 Situation: Unsupported content type .
273                 
274                 Code: 500 (Internal Server Error)
275                 Content: Error message describing the failure.
276                 Situation: Any scenario not covered by the above error codes.
277
278 ### Patch Edge
279
280         URL: https://<host>:9520/services/inventory/relationships/v11/tosca.relationships.HostedOn/<id>
281         Method: PATCH (Content-Type header set to application/merge-patch+json)
282         Body:
283                 {        
284                         "properties":{   
285                                 "prevent-delete":"OUT"
286                         }
287                 }
288         Success Response:
289                 Code: 200
290                 Content: Same as POST           
291         Error Response:
292                 Code: 400 (BAD REQUEST)
293                 Content: Error message describing the bad request failure.
294                 Situation: Invalid Payload or schema error.
295
296                 Code: 403 (FORBIDDEN)
297                 Content: Error message describing the Authorization failure.
298                 Situation: Authorization failure.
299
300                 Code: 415 (UNSUPPORTED MEDIA TYPE)
301                 Situation: Unsupported content type .
302                 
303                 Code: 500 (Internal Server Error)
304                 Content: Error message describing the failure.
305                 Situation: Any scenario not covered by the above error codes.
306  
307 ### Delete Edge
308
309         URL: https://<host>:9520/services/inventory/relationships/v11/tosca.relationships.HostedOn/<id>
310         Method: DELETE
311         Success Response:
312                 Code: 200               
313         Error Response:
314                 Code: 404 (NOT FOUND)
315                 Situation: Resource not found
316
317                 Code: 403 (FORBIDDEN)
318                 Content: Error message describing the Authorization failure.
319                 Situation: Authorization failure.
320
321                 Code: 415 (UNSUPPORTED MEDIA TYPE)
322                 Situation: Unsupported content type .
323                 
324                 Code: 500 (Internal Server Error)
325                 Content: Error message describing the failure.
326                 Situation: Any scenario not covered by the above error codes.
327