Update pap documents
[policy/parent.git] / docs / pap / pap.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3
4 .. _pap-label:
5
6 Policy Administration Point (PAP) Architecture
7 ##############################################
8
9 .. contents::
10     :depth: 3
11
12 The Policy Administration Point (PAP) keeps track of PDPs, supporting the deployment of PDP groups and the deployment
13 of policies across those PDP groups. Policies are created using the Policy API, but are deployed via the PAP.
14
15 The PAP is stateless in a RESTful sense, using the database (persistent storage) to track PDPs and the deployment of
16 policies to those PDPs. In short, policy management on PDPs is the responsibility of PAP; management of policies by
17 any other manner is not permitted.
18
19 Because the PDP is the main unit of scalability in the Policy Framework, the framework is designed to allow PDPs in a
20 PDP group to arbitrarily appear and disappear and for policy consistency across all PDPs in a PDP group to be easily
21 maintained. The PAP is responsible for controlling the state across the PDPs in a PDP group. The PAP interacts with the
22 policy database and transfers policies to PDPs.
23
24
25 1 APIs
26 ======
27 The APIs in the subchapters below are supported by the PAP.
28
29 1.1 REST API
30 ------------
31
32 The purpose of this API is to support CRUD of PDP groups and subgroups and to support the deployment and life cycles of
33 policies on PDP sub groups and PDPs. This API is provided by the *PolicyAdministration* component (PAP) of the Policy
34 Framework, see the :ref:`ONAP Policy Framework Architecture <architecture-label>` page.
35
36 PDP groups and subgroups may be prefedined in the system. Predefined groups and subgroups may be modified or deleted
37 over this API. The policies running on predefined groups or subgroups as well as the instance counts and properties may
38 also be modified.
39
40 A PDP may be preconfigured with its PDP group, PDP subgroup, and policies. The PDP sends this information to the PAP
41 when it starts. If the PDP group, subgroup, or any policy is unknown to the PAP, the PAP locks the PDP in state PASSIVE.
42
43 PAP supports the operations listed in the following table, via its REST API:
44
45 .. csv-table::
46    :header: "Operation", "Description"
47    :widths: 25,70
48
49    "Health check", "Queries the health of the PAP"
50    "Consolidated healthcheck", "Queries the health of all policy components"
51    "Statistics", "Queries various statistics"
52    "PDP state change", "Changes the state of all PDPs in a PDP Group"
53    "PDP Group create/update", "Creates/updates PDP Groups"
54    "PDP Group delete", "Deletes a PDP Group"
55    "PDP Group query", "Queries all PDP Groups"
56    "Deployment update", "Deploy/undeploy one or more policies in specified PdpGroups"
57    "Deploy policy", "Deploys one or more policies to the PDPs"
58    "Undeploy policy", "Undeploys a policy from the PDPs"
59    "Policy deployment status", "Queries the status of all deployed policies"
60    "PDP statistics", "Queries the statistics of PDPs"
61
62 1.2 DMaaP API
63 -------------
64
65 PAP interacts with the PDPs via the DMaaP Message Router.  The messages listed
66 in the following table are transmitted via DMaaP:
67
68 .. csv-table::
69    :header: "Message", "Direction", "Description"
70    :widths: 25,10,70
71
72    "PDP status", "Incoming", "Registers a PDP with PAP; also sent as a periodic heart beat; also sent in response to requests from the PAP"
73    "PDP update", "Outgoing", "Assigns a PDP to a PDP Group and Subgroup; also deploys or undeploys policies from the PDP"
74    "PDP state change", "Outgoing", "Changes the state of a PDP or all PDPs within a PDP Group or Subgroup"
75
76 In addition, PAP generates notifications via the DMaaP Message Router when policies are successfully or unsuccessfully
77 deployed (or undeployed) from all relevant PDPs.
78
79 Here is a sample notification:
80
81 .. literalinclude:: notification/dmaap-pap-notif.json
82     :language: json
83
84
85 2 PAP REST API Swagger
86 ======================
87
88 It is worth noting that we use basic authorization for access with user name and password set to *healthcheck* and
89 *zb!XztG34*, respectively.
90
91 For every call, the client is encouraged to insert a uuid-type *requestID* as parameter. It is helpful for tracking each
92 http transaction and facilitates debugging. More importantly, it complies with Logging requirements v1.2. If the client
93 does not provide the requestID in a call, one will be randomly generated and attached to the response header,
94 *x-onap-requestid*.
95
96 In accordance with `ONAP API Common Versioning Strategy Guidelines
97 <https://wiki.onap.org/display/DW/ONAP+API+Common+Versioning+Strategy+%28CVS%29+Guidelines>`_, several custom headers
98 are added in the response to each call:
99
100 .. csv-table::
101    :header: "Header", "Example value", "Description"
102    :widths: 25,10,70
103
104    "x-latestversion", "1.0.0", "latest version of the API"
105    "x-minorversion", "0", "MINOR version of the API"
106    "x-patchversion", "0", "PATCH version of the API"
107    "x-onap-requestid", "e1763e61-9eef-4911-b952-1be1edd9812b", "described above; used for logging purposes"
108     
109
110 .. swaggerv2doc:: swagger/health-check-pap.json
111
112 This operation performs a health check on the PAP.
113
114 Here is a sample response:
115
116 .. literalinclude:: response/health-check-pap-resp.json
117     :language: json
118
119 .. swaggerv2doc:: swagger/consolidated-healthcheck-pap.json
120
121 This operation performs a health check of all policy components. The response
122 contains the health check result of each component. The consolidated health check
123 is reported as healthy only if all the components are healthy, otherwise the
124 "healthy" flag is marked as false.
125
126 Here is a sample response:
127
128 .. literalinclude:: response/consolidated-healthcheck-pap-resp.json
129     :language: json
130
131 .. swaggerv2doc:: swagger/statistics-pap.json
132
133 This operation allows statistics for PDP groups, PDP subgroups, and individual PDPs to be retrieved.
134
135 .. note::
136   While this API is supported, most of the statistics are not currently updated; that work has been deferred to a later
137   release.
138
139 Here is a sample response:
140
141 .. literalinclude:: response/statistics-pap-resp.json
142     :language: json
143
144 .. swaggerv2doc:: swagger/state-change-pap.json
145
146 The state of PDP groups is managed by this operation. PDP groups can be in states PASSIVE, TEST, SAFE, or ACTIVE. For a full
147 description of PDP group states, see the :ref:`ONAP Policy Framework Architecture <architecture-label>` page.
148
149 .. swaggerv2doc:: swagger/groups-batch-pap.json
150
151 This operation allows the PDP groups and subgroups to be created and updated. Many PDP groups can be created or updated
152 in a single POST operation by specifying more than one PDP group in the POST operation body.
153 This can be used to create the PDP group by providing all the details including the supported policy types for each subgroup.
154 However, it cannot be used to update policies; that is done using one of
155 the deployment requests.  Consequently, the "policies" property of this
156 request will be ignored.
157 This can also be used to update a PDP Group, but supported policy types cannot be updated during the update operation.
158 So, "policies" and "supportedPolicyTypes" properties in the request will be ignored if provided during the PDP Group update operation.
159
160 .. note::
161   If a subgroup is to be deleted from a PDP Group, then the policies must be removed from
162   the subgroup first.
163
164 .. note::
165   Policies cannot be added/updated during PDP Group create/update operations. So, if provided, they are ignored.
166   Supported policy types are defined during PDP Group creation. They cannot be updated once they are created.
167   So, supportedPolicyTypes are expected during PDP Group create, but ignored if provided during PDP Group update.
168
169 Here is a sample request:
170
171 .. literalinclude:: request/groups-batch-pap-req.json
172     :language: json
173
174 .. swaggerv2doc:: swagger/group-delete-pap.json
175
176 The API also allows PDP groups to be deleted. DELETE operations are only permitted on PDP groups in PASSIVE state.
177
178 .. swaggerv2doc:: swagger/group-query-pap.json
179
180 This operation allows the PDP groups and subgroups to be listed as well as the policies that are deployed on each PDP
181 group and subgroup.
182
183 Here is a sample response:
184
185 .. literalinclude:: response/group-query-pap-resp.json
186     :language: json
187
188 .. swaggerv2doc:: swagger/deployments-batch-pap.json
189
190 This operation allows policies to be deployed on specific PDP groups.
191 Each subgroup includes an "action" property, which is used to indicate
192 that the policies are being added (POST) to the subgroup, deleted (DELETE)
193 from the subgroup, or that the subgroup's entire set of policies is being
194 replaced (PATCH) by a new set of policies.  As such, a subgroup may appear
195 more than once in a single request, one time to delete some policies and
196 another time to add new policies to the same subgroup.
197
198 Here is a sample request:
199
200 .. literalinclude:: request/deployment-batch-pap-req.json
201     :language: json
202
203 .. swaggerv2doc:: swagger/policy-deploy-pap.json
204
205 This operation allows policies to be deployed across all relevant PDP groups.
206 PAP will deploy the specified policies to all relevant subgroups.  Only the
207 policies supported by a given subgroup will be deployed to that subgroup.
208
209 .. note::
210   The policy version is optional.  If left unspecified, then the latest version of the policy is deployed. On the other
211   hand, if it is specified, it may be an integer, or it may be a fully qualified version (e.g., "3.0.2").
212   In addition, a subgroup to which a policy is being deployed must have at
213   least one PDP instance, otherwise the request will be rejected.
214
215 Here is a sample request:
216
217 .. literalinclude:: request/policy-deploy-pap-req.json
218     :language: json
219
220 .. swaggerv2doc:: swagger/policy-undeploy-pap.json
221
222 This operation allows policies to be undeployed from PDP groups.
223
224 .. note::
225   If the policy version is specified, then it may be an integer, or it may be a fully qualified version (e.g., "3.0.2").
226   On the other hand, if left unspecified, then the latest deployed version will be undeployed.
227
228 .. note::
229   Due to current limitations, a fully qualified policy version must always be specified.
230
231 .. swaggerv2doc:: swagger/deployed-policy-pap.json
232
233 This operation allows the deployed policies to be listed together with their respective deployment status.
234 The result can be filtered based on policy name & version.
235
236 Here is a sample response:
237
238 .. literalinclude:: response/deployed-policy-pap-resp.json
239     :language: json
240
241 .. swaggerv2doc:: swagger/pdp-statistics-pap.json
242
243 This operation allows the PDP statistics to be retrieved for all registered PDPs.
244 The result can be filtered based on PDP group, PDP subgroup & PDP instance.
245
246 Here is a sample response:
247
248 .. literalinclude:: response/pdp-statistics-pap-resp.json
249     :language: json
250
251
252 3 Future Features
253 =================
254
255 3.1 Disable policies in PDP
256 ===========================
257
258 This operation will allow disabling individual policies running in PDP engine. It is mainly beneficial
259 in scenarios where network operators/administrators want to disable a particular policy in PDP engine
260 for a period of time due to a failure in the system or for scheduled maintenance.
261
262 End of Document