Fix sonar issues in policy-api
[policy/api.git] / main / src / main / java / org / onap / policy / api / main / rest / LegacyApiRestController.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy API
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.api.main.rest;
24
25 import io.swagger.annotations.Api;
26 import io.swagger.annotations.ApiOperation;
27 import io.swagger.annotations.ApiParam;
28 import io.swagger.annotations.ApiResponse;
29 import io.swagger.annotations.ApiResponses;
30 import io.swagger.annotations.Authorization;
31 import io.swagger.annotations.Extension;
32 import io.swagger.annotations.ExtensionProperty;
33 import io.swagger.annotations.ResponseHeader;
34 import java.util.Map;
35 import java.util.UUID;
36 import javax.ws.rs.Consumes;
37 import javax.ws.rs.DELETE;
38 import javax.ws.rs.GET;
39 import javax.ws.rs.HeaderParam;
40 import javax.ws.rs.POST;
41 import javax.ws.rs.Path;
42 import javax.ws.rs.PathParam;
43 import javax.ws.rs.Produces;
44 import javax.ws.rs.core.Response;
45 import org.onap.policy.api.main.rest.provider.LegacyGuardPolicyProvider;
46 import org.onap.policy.api.main.rest.provider.LegacyOperationalPolicyProvider;
47 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
48 import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
49 import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
50 import org.onap.policy.models.base.PfModelException;
51 import org.onap.policy.models.base.PfModelRuntimeException;
52 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
53 import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
54 import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
55 import org.slf4j.Logger;
56 import org.slf4j.LoggerFactory;
57
58 /**
59  * Class to provide legacy REST API services.
60  *
61  * @author Chenfei Gao (cgao@research.att.com)
62  */
63 @Path("/policy/api/v1")
64 @Api(value = "Legacy Policy Design API")
65 @Produces("application/json")
66 @Consumes("application/json")
67 public class LegacyApiRestController extends CommonRestController {
68
69     private static final Logger LOGGER = LoggerFactory.getLogger(LegacyApiRestController.class);
70
71     /**
72      * Retrieves the latest version of a particular guard policy.
73      *
74      * @param policyId the ID of specified guard policy
75      *
76      * @return the Response object containing the results of the API operation
77      */
78     @GET
79     @Path("/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/{policyId}/versions/latest")
80     @ApiOperation(value = "Retrieve the latest version of a particular guard policy",
81             notes = "Returns the latest version of the specified guard policy",
82             response = LegacyGuardPolicyOutput.class, responseContainer = "Map",
83             responseHeaders = {
84                     @ResponseHeader(name = "X-MinorVersion",
85                                     description = "Used to request or communicate a MINOR version back from the client"
86                                                 + " to the server, and from the server back to the client",
87                                     response = String.class),
88                     @ResponseHeader(name = "X-PatchVersion",
89                                     description = "Used only to communicate a PATCH version in a response for"
90                                                 + " troubleshooting purposes only, and will not be provided by"
91                                                 + " the client on request",
92                                     response = String.class),
93                     @ResponseHeader(name = "X-LatestVersion",
94                                     description = "Used only to communicate an API's latest version",
95                                     response = String.class),
96                     @ResponseHeader(name = "X-ONAP-RequestID",
97                                     description = "Used to track REST transactions for logging purpose",
98                                     response = UUID.class)
99             },
100             authorizations = @Authorization(value = "basicAuth"),
101             tags = { "Legacy Guard Policy", },
102             extensions = {
103                     @Extension(name = "interface info", properties = {
104                             @ExtensionProperty(name = "api-version", value = "1.0.0"),
105                             @ExtensionProperty(name = "last-mod-release", value = "Dublin")
106                     })
107             })
108     @ApiResponses(value = {
109             @ApiResponse(code = 401, message = "Authentication Error"),
110             @ApiResponse(code = 403, message = "Authorization Error"),
111             @ApiResponse(code = 404, message = "Resource Not Found"),
112             @ApiResponse(code = 500, message = "Internal Server Error")
113         })
114     public Response getLatestVersionOfGuardPolicy(
115             @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
116             @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
117
118         try (LegacyGuardPolicyProvider guardPolicyProvider = new LegacyGuardPolicyProvider()) {
119             Map<String, LegacyGuardPolicyOutput> policies = guardPolicyProvider.fetchGuardPolicy(policyId, null);
120             return makeOkResponse(requestId, policies);
121         } catch (PfModelException | PfModelRuntimeException pfme) {
122             LOGGER.error("GET /policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/{}"
123                 + "/versions/latest", policyId, pfme);
124             return makeErrorResponse(requestId, pfme);
125         }
126     }
127
128     /**
129      * Retrieves the specified version of a particular guard policy.
130      *
131      * @param policyId the ID of specified policy
132      * @param policyVersion the version of specified policy
133      *
134      * @return the Response object containing the results of the API operation
135      */
136     @GET
137     @Path("/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/{policyId}/versions/{policyVersion}")
138     @ApiOperation(value = "Retrieve one version of a particular guard policy",
139             notes = "Returns a particular version of a specified guard policy",
140             response = LegacyGuardPolicyOutput.class, responseContainer = "Map",
141             responseHeaders = {
142                     @ResponseHeader(name = "X-MinorVersion",
143                                     description = "Used to request or communicate a MINOR version back from the client"
144                                                 + " to the server, and from the server back to the client",
145                                     response = String.class),
146                     @ResponseHeader(name = "X-PatchVersion",
147                                     description = "Used only to communicate a PATCH version in a response for"
148                                                 + " troubleshooting purposes only, and will not be provided by"
149                                                 + " the client on request",
150                                     response = String.class),
151                     @ResponseHeader(name = "X-LatestVersion",
152                                     description = "Used only to communicate an API's latest version",
153                                     response = String.class),
154                     @ResponseHeader(name = "X-ONAP-RequestID",
155                                     description = "Used to track REST transactions for logging purpose",
156                                     response = UUID.class)
157             },
158             authorizations = @Authorization(value = "basicAuth"),
159             tags = { "Legacy Guard Policy", },
160             extensions = {
161                     @Extension(name = "interface info", properties = {
162                             @ExtensionProperty(name = "api-version", value = "1.0.0"),
163                             @ExtensionProperty(name = "last-mod-release", value = "Dublin")
164                     })
165             })
166     @ApiResponses(value = {
167             @ApiResponse(code = 401, message = "Authentication Error"),
168             @ApiResponse(code = 403, message = "Authorization Error"),
169             @ApiResponse(code = 404, message = "Resource Not Found"),
170             @ApiResponse(code = 500, message = "Internal Server Error")
171         })
172     public Response getSpecificVersionOfGuardPolicy(
173             @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
174             @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
175             @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
176
177         try (LegacyGuardPolicyProvider guardPolicyProvider = new LegacyGuardPolicyProvider()) {
178             Map<String, LegacyGuardPolicyOutput> policies = guardPolicyProvider
179                     .fetchGuardPolicy(policyId, policyVersion);
180             return makeOkResponse(requestId, policies);
181         } catch (PfModelException | PfModelRuntimeException pfme) {
182             LOGGER.error("GET /policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/{}/versions/{}",
183                     policyId, policyVersion, pfme);
184             return makeErrorResponse(requestId, pfme);
185         }
186     }
187
188     /**
189      * Creates a new guard policy.
190      *
191      * @param body the body of policy
192      *
193      * @return the Response object containing the results of the API operation
194      */
195     @POST
196     @Path("/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies")
197     @ApiOperation(value = "Create a new guard policy",
198             notes = "Client should provide entity body of the new guard policy",
199             authorizations = @Authorization(value = "basicAuth"),
200             tags = { "Legacy Guard Policy", },
201             response = LegacyGuardPolicyOutput.class, responseContainer = "Map",
202             responseHeaders = {
203                     @ResponseHeader(name = "X-MinorVersion",
204                                     description = "Used to request or communicate a MINOR version back from the client"
205                                                 + " to the server, and from the server back to the client",
206                                     response = String.class),
207                     @ResponseHeader(name = "X-PatchVersion",
208                                     description = "Used only to communicate a PATCH version in a response for"
209                                                 + " troubleshooting purposes only, and will not be provided by"
210                                                 + " the client on request",
211                                     response = String.class),
212                     @ResponseHeader(name = "X-LatestVersion",
213                                     description = "Used only to communicate an API's latest version",
214                                     response = String.class),
215                     @ResponseHeader(name = "X-ONAP-RequestID",
216                                     description = "Used to track REST transactions for logging purpose",
217                                     response = UUID.class)
218             },
219             extensions = {
220                     @Extension(name = "interface info", properties = {
221                             @ExtensionProperty(name = "api-version", value = "1.0.0"),
222                             @ExtensionProperty(name = "last-mod-release", value = "Dublin")
223                     })
224             })
225     @ApiResponses(value = {
226             @ApiResponse(code = 400, message = "Invalid Body"),
227             @ApiResponse(code = 401, message = "Authentication Error"),
228             @ApiResponse(code = 403, message = "Authorization Error"),
229             @ApiResponse(code = 500, message = "Internal Server Error")
230         })
231     public Response createGuardPolicy(
232             @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,
233             @ApiParam(value = "Entity body of policy", required = true) LegacyGuardPolicyInput body) {
234
235         if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
236             NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST,
237                             "/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies", toJson(body));
238         }
239
240         try (LegacyGuardPolicyProvider guardPolicyProvider = new LegacyGuardPolicyProvider()) {
241             Map<String, LegacyGuardPolicyOutput> policy = guardPolicyProvider.createGuardPolicy(body);
242             return makeOkResponse(requestId, policy);
243         } catch (PfModelException | PfModelRuntimeException pfme) {
244             LOGGER.error("POST /policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies", pfme);
245             return makeErrorResponse(requestId, pfme);
246         }
247     }
248
249     /**
250      * Deletes the specified version of a particular guard policy.
251      *
252      * @param policyId the ID of specified policy
253      * @param policyVersion the version of specified policy
254      *
255      * @return the Response object containing the results of the API operation
256      */
257     @DELETE
258     @Path("/policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/{policyId}/versions/{policyVersion}")
259     @ApiOperation(value = "Delete a particular version of a guard policy",
260             notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",
261             authorizations = @Authorization(value = "basicAuth"),
262             tags = { "Legacy Guard Policy", },
263             response = LegacyGuardPolicyOutput.class, responseContainer = "Map",
264             responseHeaders = {
265                     @ResponseHeader(name = "X-MinorVersion",
266                                     description = "Used to request or communicate a MINOR version back from the client"
267                                                 + " to the server, and from the server back to the client",
268                                     response = String.class),
269                     @ResponseHeader(name = "X-PatchVersion",
270                                     description = "Used only to communicate a PATCH version in a response for"
271                                                 + " troubleshooting purposes only, and will not be provided by"
272                                                 + " the client on request",
273                                     response = String.class),
274                     @ResponseHeader(name = "X-LatestVersion",
275                                     description = "Used only to communicate an API's latest version",
276                                     response = String.class),
277                     @ResponseHeader(name = "X-ONAP-RequestID",
278                                     description = "Used to track REST transactions for logging purpose",
279                                     response = UUID.class)
280             },
281             extensions = {
282                     @Extension(name = "interface info", properties = {
283                             @ExtensionProperty(name = "api-version", value = "1.0.0"),
284                             @ExtensionProperty(name = "last-mod-release", value = "Dublin")
285                     })
286             })
287     @ApiResponses(value = {
288             @ApiResponse(code = 401, message = "Authentication Error"),
289             @ApiResponse(code = 403, message = "Authorization Error"),
290             @ApiResponse(code = 404, message = "Resource Not Found"),
291             @ApiResponse(code = 409, message = "Delete Conflict, Rule Violation"),
292             @ApiResponse(code = 500, message = "Internal Server Error")
293         })
294     public Response deleteSpecificVersionOfGuardPolicy(
295             @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
296             @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
297             @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
298
299         try (LegacyGuardPolicyProvider guardPolicyProvider = new LegacyGuardPolicyProvider()) {
300             Map<String, LegacyGuardPolicyOutput> policies = guardPolicyProvider
301                     .deleteGuardPolicy(policyId, policyVersion);
302             return makeOkResponse(requestId, policies);
303         } catch (PfModelException | PfModelRuntimeException pfme) {
304             LOGGER.error("DELETE /policytypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/{}/versions/{}",
305                     policyId, policyVersion, pfme);
306             return makeErrorResponse(requestId, pfme);
307         }
308     }
309
310     /**
311      * Retrieves the latest version of a particular operational policy.
312      *
313      * @param policyId the ID of specified operational policy
314      *
315      * @return the Response object containing the results of the API operation
316      */
317     @GET
318     @Path("/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/{policyId}/versions/latest")
319     @ApiOperation(value = "Retrieve the latest version of a particular operational policy",
320             notes = "Returns the latest version of the specified operational policy",
321             response = LegacyOperationalPolicy.class,
322             responseHeaders = {
323                     @ResponseHeader(name = "X-MinorVersion",
324                                     description = "Used to request or communicate a MINOR version back from the client"
325                                                 + " to the server, and from the server back to the client",
326                                     response = String.class),
327                     @ResponseHeader(name = "X-PatchVersion",
328                                     description = "Used only to communicate a PATCH version in a response for"
329                                                 + " troubleshooting purposes only, and will not be provided by"
330                                                 + " the client on request",
331                                     response = String.class),
332                     @ResponseHeader(name = "X-LatestVersion",
333                                     description = "Used only to communicate an API's latest version",
334                                     response = String.class),
335                     @ResponseHeader(name = "X-ONAP-RequestID",
336                                     description = "Used to track REST transactions for logging purpose",
337                                     response = UUID.class)
338             },
339             authorizations = @Authorization(value = "basicAuth"),
340             tags = { "Legacy Operational Policy", },
341             extensions = {
342                     @Extension(name = "interface info", properties = {
343                             @ExtensionProperty(name = "api-version", value = "1.0.0"),
344                             @ExtensionProperty(name = "last-mod-release", value = "Dublin")
345                     })
346             })
347     @ApiResponses(value = {
348             @ApiResponse(code = 401, message = "Authentication Error"),
349             @ApiResponse(code = 403, message = "Authorization Error"),
350             @ApiResponse(code = 404, message = "Resource Not Found"),
351             @ApiResponse(code = 500, message = "Internal Server Error")
352         })
353     public Response getLatestVersionOfOperationalPolicy(
354             @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
355             @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
356
357         try (LegacyOperationalPolicyProvider operationalPolicyProvider = new LegacyOperationalPolicyProvider()) {
358             LegacyOperationalPolicy policy = operationalPolicyProvider.fetchOperationalPolicy(policyId, null);
359             return makeOkResponse(requestId, policy);
360         } catch (PfModelException | PfModelRuntimeException pfme) {
361             LOGGER.error("GET /policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/{}"
362                 + "/versions/latest", policyId, pfme);
363             return makeErrorResponse(requestId, pfme);
364         }
365     }
366
367     /**
368      * Retrieves the specified version of a particular operational policy.
369      *
370      * @param policyId the ID of specified policy
371      * @param policyVersion the version of specified policy
372      *
373      * @return the Response object containing the results of the API operation
374      */
375     @GET
376     @Path("/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/"
377          + "policies/{policyId}/versions/{policyVersion}")
378     @ApiOperation(value = "Retrieve one version of a particular operational policy",
379             notes = "Returns a particular version of a specified operational policy",
380             response = LegacyOperationalPolicy.class,
381             responseHeaders = {
382                     @ResponseHeader(name = "X-MinorVersion",
383                                     description = "Used to request or communicate a MINOR version back from the client"
384                                                 + " to the server, and from the server back to the client",
385                                     response = String.class),
386                     @ResponseHeader(name = "X-PatchVersion",
387                                     description = "Used only to communicate a PATCH version in a response for"
388                                                 + " troubleshooting purposes only, and will not be provided by"
389                                                 + " the client on request",
390                                     response = String.class),
391                     @ResponseHeader(name = "X-LatestVersion",
392                                     description = "Used only to communicate an API's latest version",
393                                     response = String.class),
394                     @ResponseHeader(name = "X-ONAP-RequestID",
395                                     description = "Used to track REST transactions for logging purpose",
396                                     response = UUID.class)
397             },
398             authorizations = @Authorization(value = "basicAuth"),
399             tags = { "Legacy Operational Policy", },
400             extensions = {
401                     @Extension(name = "interface info", properties = {
402                             @ExtensionProperty(name = "api-version", value = "1.0.0"),
403                             @ExtensionProperty(name = "last-mod-release", value = "Dublin")
404                     })
405             })
406     @ApiResponses(value = {
407             @ApiResponse(code = 401, message = "Authentication Error"),
408             @ApiResponse(code = 403, message = "Authorization Error"),
409             @ApiResponse(code = 404, message = "Resource Not Found"),
410             @ApiResponse(code = 500, message = "Internal Server Error")
411         })
412     public Response getSpecificVersionOfOperationalPolicy(
413             @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
414             @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
415             @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
416
417         try (LegacyOperationalPolicyProvider operationalPolicyProvider = new LegacyOperationalPolicyProvider()) {
418             LegacyOperationalPolicy policy = operationalPolicyProvider.fetchOperationalPolicy(policyId, policyVersion);
419             return makeOkResponse(requestId, policy);
420         } catch (PfModelException | PfModelRuntimeException pfme) {
421             LOGGER.error("GET /policytypes/onap.policies.controlloop.Operational/versions/1.0.0/"
422                 + "policies/{}/versions/{}", policyId, policyVersion, pfme);
423             return makeErrorResponse(requestId, pfme);
424         }
425     }
426
427     /**
428      * Creates a new operational policy.
429      *
430      * @param body the body of policy
431      *
432      * @return the Response object containing the results of the API operation
433      */
434     @POST
435     @Path("/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies")
436     @ApiOperation(value = "Create a new operational policy",
437             notes = "Client should provide entity body of the new operational policy",
438             authorizations = @Authorization(value = "basicAuth"),
439             tags = { "Legacy Operational Policy", },
440             response = LegacyOperationalPolicy.class,
441             responseHeaders = {
442                     @ResponseHeader(name = "X-MinorVersion",
443                                     description = "Used to request or communicate a MINOR version back from the client"
444                                                 + " to the server, and from the server back to the client",
445                                     response = String.class),
446                     @ResponseHeader(name = "X-PatchVersion",
447                                     description = "Used only to communicate a PATCH version in a response for"
448                                                 + " troubleshooting purposes only, and will not be provided by"
449                                                 + " the client on request",
450                                     response = String.class),
451                     @ResponseHeader(name = "X-LatestVersion",
452                                     description = "Used only to communicate an API's latest version",
453                                     response = String.class),
454                     @ResponseHeader(name = "X-ONAP-RequestID",
455                                     description = "Used to track REST transactions for logging purpose",
456                                     response = UUID.class)
457             },
458             extensions = {
459                     @Extension(name = "interface info", properties = {
460                             @ExtensionProperty(name = "api-version", value = "1.0.0"),
461                             @ExtensionProperty(name = "last-mod-release", value = "Dublin")
462                     })
463             })
464     @ApiResponses(value = {
465             @ApiResponse(code = 400, message = "Invalid Body"),
466             @ApiResponse(code = 401, message = "Authentication Error"),
467             @ApiResponse(code = 403, message = "Authorization Error"),
468             @ApiResponse(code = 500, message = "Internal Server Error")
469         })
470     public Response createOperationalPolicy(
471             @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,
472             @ApiParam(value = "Entity body of policy", required = true) LegacyOperationalPolicy body) {
473
474         if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
475             NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST,
476                             "/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies", toJson(body));
477         }
478
479         try (LegacyOperationalPolicyProvider operationalPolicyProvider = new LegacyOperationalPolicyProvider()) {
480             LegacyOperationalPolicy policy = operationalPolicyProvider.createOperationalPolicy(body);
481             return makeOkResponse(requestId, policy);
482         } catch (PfModelException | PfModelRuntimeException pfme) {
483             LOGGER.error("POST /policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies", pfme);
484             return makeErrorResponse(requestId, pfme);
485         }
486     }
487
488     /**
489      * Deletes the specified version of a particular operational policy.
490      *
491      * @param policyId the ID of specified policy
492      * @param policyVersion the version of specified policy
493      *
494      * @return the Response object containing the results of the API operation
495      */
496     @DELETE
497     @Path("/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/"
498          + "policies/{policyId}/versions/{policyVersion}")
499     @ApiOperation(value = "Delete a particular version of a specified operational policy",
500             notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",
501             authorizations = @Authorization(value = "basicAuth"),
502             tags = { "Legacy Operational Policy", },
503             response = LegacyOperationalPolicy.class,
504             responseHeaders = {
505                     @ResponseHeader(name = "X-MinorVersion",
506                                     description = "Used to request or communicate a MINOR version back from the client"
507                                                 + " to the server, and from the server back to the client",
508                                     response = String.class),
509                     @ResponseHeader(name = "X-PatchVersion",
510                                     description = "Used only to communicate a PATCH version in a response for"
511                                                 + " troubleshooting purposes only, and will not be provided by"
512                                                 + " the client on request",
513                                     response = String.class),
514                     @ResponseHeader(name = "X-LatestVersion",
515                                     description = "Used only to communicate an API's latest version",
516                                     response = String.class),
517                     @ResponseHeader(name = "X-ONAP-RequestID",
518                                     description = "Used to track REST transactions for logging purpose",
519                                     response = UUID.class)
520             },
521             extensions = {
522                     @Extension(name = "interface info", properties = {
523                             @ExtensionProperty(name = "api-version", value = "1.0.0"),
524                             @ExtensionProperty(name = "last-mod-release", value = "Dublin")
525                     })
526             })
527     @ApiResponses(value = {
528             @ApiResponse(code = 401, message = "Authentication Error"),
529             @ApiResponse(code = 403, message = "Authorization Error"),
530             @ApiResponse(code = 404, message = "Resource Not Found"),
531             @ApiResponse(code = 409, message = "Delete Conflict, Rule Violation"),
532             @ApiResponse(code = 500, message = "Internal Server Error")
533         })
534     public Response deleteSpecificVersionOfOperationalPolicy(
535             @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
536             @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
537             @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
538
539         try (LegacyOperationalPolicyProvider operationalPolicyProvider = new LegacyOperationalPolicyProvider()) {
540             LegacyOperationalPolicy policy = operationalPolicyProvider
541                     .deleteOperationalPolicy(policyId, policyVersion);
542             return makeOkResponse(requestId, policy);
543         } catch (PfModelException | PfModelRuntimeException pfme) {
544             LOGGER.error("DELETE /policytypes/onap.policies.controlloop.Operational/versions/1.0.0/"
545                 + "policies/{}/versions/{}", policyId, policyVersion, pfme);
546             return makeErrorResponse(requestId, pfme);
547         }
548     }
549 }