Extend user guide with southbound API details
[ric-plt/a1.git] / docs / user-guide-api.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. SPDX-License-Identifier: CC-BY-4.0
3
4 User Guide and APIs
5 ===================
6
7 This document explains how to communicate with the A1 Mediator.
8 Information for maintainers of this platform component is in the Developer Guide.
9
10 Example Messages
11 ----------------
12
13 Send the following JSON to create policy type 20008, which supports instances with
14 a single integer value:
15
16 .. code-block:: yaml
17
18     {
19       "name": "tsapolicy",
20       "description": "tsa parameters",
21       "policy_type_id": 20008,
22       "create_schema": {
23         "$schema": "http://json-schema.org/draft-07/schema#",
24         "type": "object",
25         "properties": {
26           "threshold": {
27             "type": "integer",
28             "default": 0
29           }
30         },
31         "additionalProperties": false
32       }
33     }
34
35
36 Send the following JSON to create an instance of policy type 20008:
37
38 .. code-block:: yaml
39
40     {
41       "threshold" : 5
42     }
43
44
45 Integrating Xapps with A1
46 -------------------------
47
48 The schema for messages sent by A1 to Xapps is labeled ``downstream_message_schema``
49 in the Southbound API Specification section below. A1 sends policy instance requests
50 using message type 20010.
51
52 The schemas for messages sent by Xapps to A1 appear in the Southbound API
53 Specification section below. Xapps must use a message type and content appropriate
54 for the scenario:
55
56 #. When an Xapp receives a CREATE message for a policy instance, the Xapp
57    must respond by sending a message of type 20011 to A1. The content is
58    defined by schema ``downstream_notification_schema``.  The most convenient
59    way is to use RMR's return-to-sender (RTS) feature after setting the
60    message type appropriately.
61 #. Since policy instances can "deprecate" other instances, there are
62    times when Xapps need to asynchronously tell A1 that a policy is no
63    longer active. Use the same message type and schema as above.
64 #. Xapps can request A1 to re-send all instances of policy type T using a
65    query, message type 20012.  The schema for that message is defined by
66    ``policy_query_schema`` (just a body with ``{policy_type_id: ... }``).
67    When A1 receives this, A1 will send the Xapp a CREATE message N times,
68    where N is the number of policy instances for type T. The Xapp should reply
69    normally to each of those as the first item above. That is, after the Xapp
70    performs the query, the N CREATE messages sent and the N replies
71    are "as normal".  The query just kicks off this process rather than
72    an external caller to A1.
73
74
75 Northbound API Specification
76 ----------------------------
77
78 This section shows the Open API specification for the A1 Mediator's
79 northbound interface, which accepts policy type and policy instance requests.
80 Alternately, if you have checked out the code and are running the server,
81 you can see a formatted version at this URL: ``http://localhost:10000/ui/``.
82
83
84 .. literalinclude:: ../a1/openapi.yaml
85    :language: yaml
86    :linenos:
87
88
89 Southbound API Specification
90 ----------------------------
91
92 This section shows Open API schemas for the A1 Mediator's southbound interface,
93 which communicates with Xapps via RMR. A1 sends policy instance requests using
94 message type 20010. Xapps may send requests to A1 using message types 20011 and
95 20012.
96
97
98 .. literalinclude:: a1_xapp_contract_openapi.yaml
99    :language: yaml
100    :linenos: