aboutsummaryrefslogtreecommitdiffstats
path: root/docs/AAI REST API Documentation/bulkApi.rst
blob: c292deab803a1d7a65b7b62b2ea033ca508cfee8 (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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
.. contents::
   :depth: 3
..
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

=============
 AAI Bulk API
=============

This page will serve as a reference for how to use the A&AI bulk API's available in 1810+.

Bulk Overview
=============

To execute any of the bulk api's, a client will perform a POST on the specific bulk api and include a payload indicating the nodes to be added/updated/deleted.The version (v$ ie. v14) dictates which release's REST API version the output will be based on.
 
Single transaction API
======================

API takes in transaction object which consists of an array of operations, the operations are executed against A&AI in a single transaction. All operations must succeed for the actions to be committed. If any of the operations fail these changes will be rolled back.

API URI
=======

.. code::

   URI
   POST /aai/v$/bulk/single-transaction
   Payload
   Skeleton 
   {
     "operations": [ //array of operations for this transaction
       {
         "action": "", //aai action to be taken, i.e put, patch, delete
         "uri": "", //aai uri to execute action against
         "body": {} //json object which is the body of the equivalent REST request
       }
     ]
   }

Response

.. code::

   Skeleton 
   {
     "operation-responses": [ //result of each of the request operations
       {
         "action": "", //aai action that was taken
         "uri": "", //aai uri that was executed against
         "response-status-code": , //http status code
         "response-body": null // response body of the of the equivalent REST request
       }
     ]
   }

Request-Response Examples
=========================

Example - 1 (Success)
+++++++++++++++++++++

.. code::

   Request  
   {
       "operations": [
           {
               "action": "put",
               "body": {
                   "fqdn": "pserver-key-fqdn",
                   "hostname": "pserver-1-key"
               },
               "uri": "/cloud-infrastructure/pservers/pserver/pserver-1-key"
           },
           {
               "action": "patch",
               "body": {
                   "fqdn": "patched-fqdn"
               },
               "uri": "/cloud-infrastructure/pservers/pserver/pserver-1-key"
           },
           {
               "action": "put",
               "body": {
                   "fqdn": "pserver-key-fqdn",
                   "hostname": "pserver-2-key"
               },
               "uri": "/cloud-infrastructure/pservers/pserver/pserver-2-key"
           }
       ]
   }

Response
++++++++
.. code:: 

   {
       "operation-responses": [
           {
               "action": "put",
               "response-body": null,
               "response-status-code": 201,
               "uri": "/cloud-infrastructure/pservers/pserver/pserver-1-key"
           },
           {
               "action": "patch",
               "response-body": null,
               "response-status-code": 200,
               "uri": "/cloud-infrastructure/pservers/pserver/pserver-1-key"
           },
           {
               "action": "put",
               "response-body": null,
               "response-status-code": 201,
               "uri": "/cloud-infrastructure/pservers/pserver/pserver-2-key"
           }
       ]
   }

Example - 2 (Success)
=====================
Request
+++++++

.. code::

   {
       "operations": [
           {
               "action": "put",
               "body": {
                   "fqdn": "pserver-key-fqdn",
                   "hostname": "pserver-key"
               },
               "uri": "/cloud-infrastructure/pservers/pserver/pserver-key"
           },
           {
               "action": "put",
               "body": {
                   "city": "city",
                   "country": "NONE",
                   "data-center-code": "code",
                   "identity-url": "N/A",
                   "physical-location-id": "complex-key",
                   "physical-location-type": "type",
                   "postal-code": "12345",
                   "region": "Earth",
                   "state": "state",
                   "street1": "street"
               },
               "uri": "/cloud-infrastructure/complexes/complex/complex-key"
           },
           {
               "action": "put",
               "body": {
                   "related-link": "/aai/v13/cloud-infrastructure/pservers/pserver/pserver-key",
                   "related-to": "pserver"
               },
               "uri": "/cloud-infrastructure/complexes/complex/complex-key/relationship-list/relationship"
           },
           {
               "action": "delete",
               "body": {},
               "uri": "/network/generic-vnfs/generic-vnf/gvnf-key?resource-version=0"
           }
       ]
   }

Response
++++++++

.. code::

   {
       "operation-responses": [
           {
               "action": "put",
               "response-body": null,
               "response-status-code": 201,
               "uri": "/cloud-infrastructure/pservers/pserver/pserver-key"
           },
           {
               "action": "put",
               "response-body": null,
               "response-status-code": 201,
               "uri": "/cloud-infrastructure/complexes/complex/complex-key"
           },
           {
               "action": "put",
               "response-body": null,
               "response-status-code": 200,
               "uri": "/cloud-infrastructure/complexes/complex/complex-key/relationship-list/relationship"
           },
           {
               "action": "delete",
               "response-body": null,
               "response-status-code": 204,
               "uri": "/network/generic-vnfs/generic-vnf/gvnf-key?resource-version=0"
           }
       ]
   }

Example - 3 (Failure on mismatched resource version on delete)
==============================================================
Request
+++++++

.. code::

   {
       "operations": [
           {
               "action": "put",
               "body": {
                   "fqdn": "pserver-key-fqdn",
                   "hostname": "pserver-key"
               },
               "uri": "/cloud-infrastructure/pservers/pserver/pserver-key"
           },
           {
               "action": "put",
               "body": {
                   "city": "city",
                   "country": "NONE",
                   "data-center-code": "code",
                   "identity-url": "N/A",
                   "physical-location-id": "complex-key",
                   "physical-location-type": "type",
                   "postal-code": "12345",
                   "region": "Earth",
                   "state": "state",
                   "street1": "street"
               },
               "uri": "/cloud-infrastructure/complexes/complex/complex-key"
           },
           {
               "action": "put",
               "body": {
                   "related-link": "/aai/v13/cloud-infrastructure/pservers/pserver/pserver-key",
                   "related-to": "pserver"
               },
               "uri": "/cloud-infrastructure/complexes/complex/complex-key/relationship-list/relationship"
           },
           {
               "action": "delete",
               "body": {},
               "uri": "/network/generic-vnfs/generic-vnf/gvnf-key?resource-version=1"
           }
       ]
   }

Response
++++++++

.. code:: 

   {
       "requestError": {
           "serviceException": {
               "messageId": "SVC3000",
               "text": "Invalid input performing %1 on %2 (msg=%3) (ec=%4)",
               "variables": [
                   "POST",
                   "/aai/v14/bulk-single-transaction-multi-operation",
                   "Invalid input performing %1 on %2:Operation 3 failed with status code (412) and msg ({\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3000\",\"text\":\"Invalid input performing %1 on %2 (msg=%3) (ec=%4)\",\"variables\":[\"DELETE\",\"/network/generic-vnfs/generic-vnf/gvnf-key\",\"Precondition Failed:resource-version MISMATCH for delete of generic-vnf\",\"ERR.5.4.6131\"]}}})",
                   "ERR.5.2.3000"
               ]
           }
       }
   }