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