9cff428b74feedb36342445972982c3ec0a6486e
[aai/aai-common.git] / docs / AAI REST API Documentation / AAIRESTAPI_AMSTERDAM.rst
1 .. contents::
2    :depth: 3
3 ..
4
5 AAI REST API
6
7 | Copyright © 2017 AT&T Intellectual Property.
8 | All rights reserved.
9 | Licensed under the Creative Commons License, Attribution 4.0 Intl. 
10   (the "License"); you may not use this documentation except in
11   compliance with the License.
12 | You may obtain a copy of the License at
13 |        https://creativecommons.org/licenses/by/4.0/
14 | Unless required by applicable law or agreed to in writing, software
15   distributed under the License is distributed on an "AS IS" BASIS,
16   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17   implied.  See the License for the specific language governing
18   permissions and limitations under the License.
19 | ECOMP and OpenECOMP are trademarks and service marks of AT&T
20   Intellectual Property.
21
22 \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
23
24 Overview
25 ========
26
27 The AAI REST API provides access to the AAI active inventory graph. The
28 API is largely configured off of models and configuration files. Each
29 vertex in the graph has an API that can be called separately or, if part
30 of a tree structure, as a nested element with one or more generations
31 (parent, grandparent, etc.).
32
33 The edges of the graph are provisioned using a relationship list
34 construct. For PUT methods, a relationship contains the vertex type or
35 category (related-to) and a list of relationship data which captures the
36 key pieces of data required to uniquely identify the resource. On a GET
37 method, the above information and a URL are returned. The URL can be
38 used to GET all the details of that object. The URL returned is suitable
39 for retrying failed commands but should not be expected to be cacheable
40 for very long periods (e.g., the version of the URL may get deprecated
41 when the release changes).
42
43 Concurrency control for AAI is in place. The assumptions made for the
44 implementation are as follows:
45
46 -  A client always gets a resource before updating through PUT or
47    deleting it.
48
49 -  All resource updates and deletions are done via the AAI REST APIs
50
51 -  This solution will apply to PUT and DELETE operations.
52
53 -  The resource-version attribute is now in every container
54
55 -  The update API is not subject to concurrency control because it is
56    only intended to be used by clients who are the definitive source of
57    truth for the attributes they are changing. An update through the
58    update API will however reset the resource-version so clients using
59    PUT and DELETE will not risk updating with stale data.
60
61 -  The PATCH REST verb is not subject to concurrency control because it
62    is only intended to be used by clients who are the definitive source
63    of truth for the attributes they are changing. An update through the
64    update API will however reset the resource-version so clients using
65    PUT and DELETE will not risk updating with stale data.
66
67 How to Use this Document
68 ========================
69
70 When you click on the API documentation, you will see the Summary of
71 APIs broken down by namespace (e.g., cloud-infrastructure, business,
72 network, service-design-and-creation). You can search for **Tag:**
73 (matching the explicit case) to move from namespace to namespace through
74 the Summary.
75
76 Search for **Paths** to skip past the Summary section where there will
77 be more detail about each API. Query parameters are provided here, as
78 well as links to our error codes.
79
80 Search for **Schema definitions** to see the definitions of the
81 payloads. In your browser URL, you can type /#/definitions/node-name at
82 the end of the html address to skip directly to a payload definition.
83
84 Note that the schema definitions now contain information about the
85 delete scope of a node (also referenced in this document) and some
86 related node information (also reference in this document as Edges).
87
88 Once AAI has a model and configured it, the AAI development server can
89 be used to generate sample XML and JSON payloads, according to the
90 Accept header passed in the request. This is done by calling the
91 "plural" version of an API followed by the word example (e.g.,
92 /vserver/vservers/example). This returns a GET result array with one
93 entry. That single entry can be sent in a PUT request with actual data
94 (the resource-id does not need to be in the PUT payload as it is on the
95 URL).
96
97 Document Conventions
98 ====================
99
100 Information that is largely guidance or aspirational will be show in
101 gray italicized text. This information should not be relied upon or
102 referenced at this point except with the understanding that it WILL
103 change.
104
105 **Bold blue text** will be used to cover communication to our clients
106 that may not be enforced by AAI. The sources of truth (our clients)
107 populate AAI and are expected to send the correct information, having
108 applied business rules that live in the client systems.
109
110 Deprecation Warnings and History
111 ================================
112
113 V11
114
115 API retirements:
116
117 -  The actions/update API will be retired. Clients must switch to PATCH.
118    There is one grandfathered usage for vpe update flows which will be
119    retired in v11.
120
121 -  The edge tag query will be retired.
122
123 Notable attribute and/or valid value changes (generally also impacts
124 events):
125
126 -  The persona-model-id and persona-version will be replaced with
127    model-invariant-id (same value as persona-model-id) and
128    model-version-id (the UUID of the specific version of a model).
129    Persona-model-customization-id will be replaced by
130    model-customization-id.
131
132 -  The operational-state attribute will be replaced by
133    operational-status and the only valid values will be in-service-path
134    and out-of-service-path
135
136 -  The vpn-binding object will be split in two to reflect more than one
137    route-target per binding. The route-target will be a child of
138    vpn-binding and some attributes will move from vpn-binding to
139    route-target.
140
141 -  The following license related attributes will be removed from
142    generic-vnf: license-key, entitlement-assignment-group-uuid,
143    entitlement-resource-uuid, license-assignment-group-uuid, and
144    license-key-uuid due to the introduction of the entitlement and
145    license children.
146
147 Event Specific:
148
149 -  Normal impacts due to renaming or adding attributes, splitting
150    objects, etc. Please see swagger documentation for objects of
151    interest.
152
153 -  In v11, clients that require lineage, children, or relationship
154    information need to subscribe to a different DMaaP topic than the
155    current one.
156
157 Relationship List
158
159 -  The related-link will be a URI and thus not contain
160    https://{serverroot} (impacts events)
161
162 -  Thhe related-link will be used on a PUT as the "first choice" to
163    identify the related resource. The relationship-data structure, which
164    contains the unordered set of keys, is still an acceptable way to
165    relate two objects but, *if both the relationship-data and the
166    related-link are passed, and they don't agree, the related-link will
167    be used without warning that the data is inconsistent*.
168
169 -  The relationship-data will be ignored on PUT.
170
171 AAI API Definition
172 ==================
173
174 The API structure is composed of:
175
176 -  The HTTP command, which indicates the operation to perform
177
178 -  The HTTP URI, which defines what object this operation is related to
179
180 -  The HTTP version, which MUST be 1.1
181
182 Available HTTP commands are:
183
184 -  PUT: used to create or update an object
185
186 -  DELETE: used to delete an object or a set of objects
187
188 -  GET : used to query an object or set of objects
189
190 -  PATCH : used to update specific fields owned by the client doing the
191    update
192
193 The HTTP URI is built according to this pattern:
194
195 https://{serverRoot}/{namespace}/{resource}
196
197 -  (serverRoot} refers to the server base url: hostname+port+base
198    path+version. Port and base path are OPTIONAL but AAI will use port
199    8443 and base path aai. The Amsterdam release version will be v11.
200
201 -  {namespace} refers to the API namespace. Supported namespaces are
202    cloud-infrastructure, business, service-design-and-creation, and
203    network
204
205 -  {resource} refers to how the object is identified according to the
206    namespace specifications.
207
208 Example
209
210 GET https://{hostname}:8443/aai
211 /v11/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}
212
213 The GET requests support a depth query parameter allowing a query to
214 stop after it has reached a certain point in the graph. This allows
215 clients to minimize the data that is returned to them. A depth=0 returns
216 the resource itself and none of its children.
217
218 Data Assumptions
219 ----------------
220
221 Given AAI is largely a correlation engine among disparate inventory
222 types, AAI will accept values as they are sent, without validating the
223 format or value of the input. It is incumbent upon the source of truth
224 to provide valid information to AAI.
225
226 Clients should do a GET prior to a PUT and change only the data that
227 they mean to affect. The REST APIs expect the payload passed to replace
228 the resource in AAI. **This is vital in our concurrency scheme. The
229 client will be returned an opaque value per entity which needs to be
230 returned back in the PUT. AAI will reject the PUT or DELETE if the
231 opaque value doesn't match what AAI has stored for that entity.**
232
233 If a leaf has been added to a model in vN+1, and a GET/PUT of a vN
234 resource is done, AAI should not affect the new leaf (i.e., it should be
235 left unchanged).
236
237 PUT and Lists
238 -------------
239
240 The PUT verb is used to both create and replace a resource. A given
241 resource may have child resources (e.g., customers have service
242 subscriptions; tenants have vservers and vservers have volumes).
243
244 The following convention will be followed:
245
246 If a resource is replaced and there are no tags for children, the
247 children that exist will be left alone.
248
249 If a resource is replaced and there are tags for children, the children
250 will be replaced by the list passed. If the list is empty, then children
251 will be deleted.
252
253 Note that the relationship list is a type of child resource. The same
254 conventions are followed. It is especially critical to ensure that you
255 do not send an incomplete relationship list and therefore remove edges
256 in the graph. See section 5.10 for more information on relationship
257 lists.
258
259 PATCH
260 -----
261
262 To move towards industry standards and to make our APIs easier to use by
263 clients who own specific attributes and do not require AAI to enforce
264 concurrency control around them, the PATCH verb has been introduced.
265
266 -  RFC Algorithm implemented JSON Merge PATCH
267    `tools.ietf.org/html/rfc7386 <https://tools.ietf.org/html/rfc7386>`__
268
269 -  *HTTP Verb = PATCH*
270
271 -  PATCH requires a Content-Type of "application/merge-patch+json" in
272    your HTTP headers.
273
274 -  PATCH does not support XML
275
276 -  PATCH does not require a resource version to preform these
277    modifications
278
279 -  Clients should only send what they wish to modify and whose value
280    they "own"
281
282 Example:
283
284 PATCH \ `https://<hostname>:8443/aai/v11/network/generic-vnfs/generic-vnf/cscf0001v <https://aai-int1.test.att.com:8443/aai/v7/network/generic-vnfs/generic-vnf/cscf0001v>`__
285
286     {
287
288       "vnf-id": "cscf0001v", This key needs to be here but you cannot
289 modify the key
290
291       "regional-resource-zone": null,
292
293       "ipv4-oam-address": "1.2.3.4"   
294
295 }
296
297 This payload would result in the generic-vnf with the vnf-id = cscf0001v
298 having ipv4-oam-address set to "1.2.3.4" and regional-resource-zone
299 having its value removed from the database.
300
301 Referential Integrity
302 ---------------------
303
304 AAI is primarily a view to the relationships between customers,
305 products, services, physical and virtual components, etc. It stores just
306 the details it needs to be efficient to its tasks and knows how to get
307 more details if needed.
308
309 As such, a transaction sent to AAI may be refused if would break
310 referential integrity. The referential integrity rules of AAI are still
311 evolving as we understand the services and customers that will use us.
312
313 AAI uses a graph database on a NoSQL data store. The following are true
314 for AAI:
315
316 -  Some vertices are exposed to the outside world through APIs, others
317    are internal to how we store the data (i.e., it may look like one
318    resource to our customers but it is expressed as more than one vertex
319    in our graph)
320
321 -  Vertices that are internal to AAI will be deleted when the parent
322    vertex is deleted, if deletion of the parent leaves the child vertex
323    orphaned
324
325 -  Vertices that are exposed need to be managed using specific rules for
326    each vertex.
327
328 -  Vertices may have more than just parent/child relationships. One
329    example is a vserver, which will be owned by a tenant and used by a
330    VNF.
331
332 Delete Rules
333 ------------
334
335 The following options are available as actions to be take upon deletion
336 of a resource:
337
338 -  ERROR\_IF\_ANY\_EDGES – If the resource being deleted has any edges
339    at all, an error should be returned
340
341 -  ERROR\_IF\_ANY\_IN\_EDGES – if the resource being deleted has any
342    edges that point IN towards it, an error should be returned
343
344 -  THIS\_NODE\_ONLY – delete the vertex being requested by first
345    deleting its edge to other vertices, but do not delete the other
346    vertices. Note, the delete will be rejected if the deletion target
347    has DEPENDENT children (e.g., tenants that have vservers)
348
349 -  CASCADE\_TO\_CHILDREN – cascade the delete through vertices who have
350    a parentOf relationship to the vertex being deleted, as long as the
351    vertex is orphaned by the delete of its parent
352
353 -  ERROR\_4\_IN\_EDGES\_OR\_CASCADE – error if there are any in edges
354    and, if not, cascade to children
355
356 Security
357 --------
358
359 All REST APIs must be called using https.
360
361 The current release is configured to support BasicAuth. 2-way SSL using
362 client certificates should be configured for production deployments or
363 as needed.
364
365 Headers
366 -------
367
368 The following will be used for logging and interface diagnostic
369 purposes.
370
371 -  X-FromAppId Unique Application ID assigned to the user of these APIs
372
373 -  X-TransactionId Unique ID that identifies an API request
374
375 The X-FromAppId will be assigned to each application by the AAI team.
376 The X-TransactionId must be unique to each transaction within the
377 context of an X-FromAppId.
378
379 OpenECOMP components that call AAI use the Java UUID class to generate
380 unique ids for X-TransactionId.
381
382 The Accept header should be set to either application/json or
383 application/xml.
384
385 +-------------------------------+---------------+
386 | Client                        | X-FromAppId   |
387 +===============================+===============+
388 | Policy                        | Policy        |
389 +-------------------------------+---------------+
390 | Master Service Orchestrator   | MSO           |
391 +-------------------------------+---------------+
392 | SDN Controller                | SDNC          |
393 +-------------------------------+---------------+
394 | Application Controller        | APPC          |
395 +-------------------------------+---------------+
396
397 Response Codes and Error Handling
398 ---------------------------------
399
400 HTTP response codes and error codes are described in the API
401 documentation.
402
403 URLs Sent To and Retrieved From AAI
404 -----------------------------------
405
406 AAI receives URLs from clients that point back to that client in order
407 to get more details about the data sent to AAI. AAI expects the URLs
408 sent by clients (e.g., self links) to be URL encoded (UTF-8) and AAI
409 will store them unchanged.
410
411 URLs that AAI constructs that point to AAI resources will be returned
412 URLEncoded (UTF-8) to clients. This affects URLs in relationship lists
413 and search results.
414
415 AAI expects space to be %20, and not plus(+).
416
417 The Relationship-List
418 ---------------------
419
420 The REST interface does not lend itself to creating more than
421 parent-child relationships and the backend structure of AAI is a graph.
422 A goal of AAI is to do as little coding as possible to introduce a new
423 service into the service design and creation environment.
424
425 To that end, we've introduced a relationship-list structure. AAI will
426 ask its clients to provide certain data in the relationship-list
427 structure.
428
429 Each relationship has a related-to attribute and a list of key/value
430 pairs. The related-to attribute identifies the node type that the
431 resource being acted on is to be related to using the data in the
432 key/value pairs. AAI will encode a set of rules for each resource type
433 to verify that only valid edges are being made. AAI will keep the name
434 of the edge itself, the directionality and cardinality, and the edge
435 attributes within its own logic.
436
437 If an attempt is made to add a relationship to a node that doesn't exist
438 (e.g., from a vserver to a vnf, and the vnf doesn't exist), a unique
439 message Id (3003) will be returned with a specific error code
440 (ERR.5.4.6129). Arguments will tell the client which node type was
441 missing (e.g., generic-vnf) and the key data for that node type
442 (generic-vnf.vnf-id).
443
444 Single relationships can be PUT to the graph in the following way:
445
446 https://{serverRoot}/{namespace}/{resource}
447 /relationship-list/relationship
448
449 or
450
451 https://{hostname}:8443/aai/v11/cloud-infrastructure/pservers/pserver/pserver-123456789-01/p-interfaces/p-interface/p-interface-name-123456789-01/l-interfaces/l-interface/l-interface-name-123456789-01/relationship-list/relationship
452
453 with a payload containing the relationship information.
454
455 XML:
456
457 <relationship xmlns="http://org.openecomp.aai.inventory/v11">
458
459 <related-to>logical-link</related-to>
460
461 <relationship-data>
462
463     <relationship-key>logical-link.link-name</relationship-key>
464
465     <relationship-value>logical-link-123456789-01</relationship-value>
466
467 </relationship-data>
468
469 </relationship>
470
471 JSON:
472
473 "related-to": "logical-link",
474
475 "relationship-data": [
476
477 {
478
479     "relationship-key": "logical-link.link-name",
480
481     "relationship-value": " logical-link-123456789-01"
482
483 }
484
485 ]
486
487 }
488
489 Edges
490 =====
491
492 The following are the properties used for edge definitions. T is true, F
493 is false
494
495 -  From and To are the node types for the ends of the edges.
496
497 -  EdgeLabel is the name of the label within the graph.
498
499 -  Direction shows the direction of the edge.
500
501 -  Multiplicity shows the multiplicity rule between two nodes. This
502    helps govern what AAI does when modifying relationships between edges
503    using the relationship REST APIs
504
505 -  ParentOf indicates whether From is a parent of To.
506
507 -  UsesResource specifies whether the From node uses resources of the To
508    node, to be able to view the data in the context of "what uses what".
509
510 -  hasDelTarget specifies whether to try to delete the To node when the
511    From node is deleted.
512
513 -  SVC-INFRA (deprecated)
514
515 The configuration for different edges supported by the AAI model are
516 defined in the DbEdgeRules.java class.
517
518 Indexed Attributes 
519 ===================
520
521 AAI supports query parameters on its indexed attributes.
522
523 As an example, if you wanted to GET a tenant by tenant-name, you would
524 do something like
525
526 /aai/vX/cloud-infrastructure/cloud-regions/cloud-region/cloud\_owner\_1/cloud-region\_1/tenants/tenant?tenant-name=value
527
528 The properties that are indexed are defined in the aai-schema.
529
530 Namespaces
531 ==========
532
533 Util Domain
534 -----------
535
536 The util domain is where AAI locates utility functions. There is
537 currently one utility function, echo, which serves as a ping test that
538 authenticated authorized clients can call to ensure there is
539 connectivity with AAI.
540
541 The URL for the echo utility is:
542
543 https://load-balanced-address:8443/aai/util/echo
544
545 If the response is unsuccessful, an error will be returned following the
546 standard format.
547
548 The successful payload returns the X-FromAppId and X-TransactionId sent
549 by the client.
550
551 Successful XML Response Payload
552 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
553
554 <Info>
555
556 <responseMessages>
557
558 <responseMessage>
559
560 <messageId>INF0001</messageId>
561
562 <text>Success X-FromAppId=%1 X-TransactionId=%2 (msg=%3) (rc=%4)</text>
563
564 <variables>
565
566 <variable>XYZ</variable>
567
568 <variable>XYZ123</variable>
569
570 <variable>Successful health check:OK</variable>
571
572 <variable>0.0.0002</variable>
573
574 </variables>
575
576 </responseMessage>
577
578 </responseMessages>
579
580 </Info>
581
582 Successful JSON Response Payload
583 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
584
585 {"responseMessages": {"responseMessage": [{
586
587 "messageId": "INF0001",
588
589 "text": "Success X-FromAppId=%1 X-TransactionId=%2 (msg=%3) (rc=%4)",
590
591 "variables": {"variable": [
592
593 "XYZ",
594
595 "XYZ123",
596
597 "Successful health check:OK",
598
599 "0.0.0002"
600
601 ]}
602
603 }]}}
604
605 Cloud Infrastructure Domain
606 ---------------------------
607
608 The Cloud Infrastructure domain (cloud-infrastructure) represents the
609 assets managed within a cloud infrastructure site. This includes the
610 physical servers, tenants, vservers and cloud-region.
611
612 Network Domain
613 --------------
614
615 The network namespace contains virtual and physical network resources as
616 well as connection resources such as physical links, logical links, etc.
617
618 Business Domain
619 ---------------
620
621 The business namespace captures customers, service subscriptions, and
622 service instances. This domain is immature and will be evolving as
623 service design and creation starts to gel.
624
625 Service Design and Creation
626 ---------------------------
627
628 The service design and creation namespace captures data we invented
629 based on what we thought SDC would eventually provide.
630
631 To date, there are only five containers:
632
633 1. Service-capabilities capture the pairings of service to resources.
634
635 2. Service captures the service model instances and this will be
636    deprecated in the future as things mature
637
638 3. Models captures model definitions (subgraph definitions using the AAI
639    widgets)
640
641 4. named-queries capture subgraph definitions that allow different data
642    to be retrieved for a given type of asset