aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>2020-07-17 11:13:49 +0100
committerputhuparambil.aditya <aditya.puthuparambil@bell.ca>2020-07-24 11:14:52 +0100
commit478ac7c72dba1c26e7a79a08d50b6fd14441bf2a (patch)
tree5ab59a46fd8eba49a6641cd7ade8ab95cb95c9f0
parentf655bbd5cf8c28fda08ea6a130ec314b21725cb6 (diff)
Fetch and Delete policy API with PolicyName and PolicyVersion
Issue-ID: POLICY-2585 Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca> Change-Id: Icabde6463105ed382c1e32b6f7c1319490a385b2
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java892
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java81
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java92
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java19
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java110
-rw-r--r--postman/lifecycle-api-collection.json1488
6 files changed, 1664 insertions, 1018 deletions
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
index 79d8a64a..e23604b0 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
@@ -5,6 +5,7 @@
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,6 +38,8 @@ import io.swagger.annotations.Info;
import io.swagger.annotations.ResponseHeader;
import io.swagger.annotations.SecurityDefinition;
import io.swagger.annotations.SwaggerDefinition;
+import java.net.HttpURLConnection;
+import java.util.List;
import java.util.UUID;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -49,6 +52,7 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
import org.onap.policy.api.main.rest.provider.HealthCheckProvider;
import org.onap.policy.api.main.rest.provider.PolicyProvider;
import org.onap.policy.api.main.rest.provider.PolicyTypeProvider;
@@ -90,6 +94,42 @@ public class ApiRestController extends CommonRestController {
private static final Logger LOGGER = LoggerFactory.getLogger(ApiRestController.class);
+ private static final String ERROR_MESSAGE_NO_POLICIES_FOUND = "No policies found";
+
+ private static final String EXTENSION_NAME = "interface info";
+
+ private static final String API_VERSION_NAME = "api-version";
+ private static final String API_VERSION = "1.0.0";
+
+ private static final String LAST_MOD_NAME = "last-mod-release";
+
+ private static final String AUTHORIZATION_TYPE = "basicAuth";
+
+ private static final String VERSION_MINOR_NAME = "X-MinorVersion";
+ private static final String VERSION_MINOR_DESCRIPTION =
+ "Used to request or communicate a MINOR version back from the client"
+ + " to the server, and from the server back to the client";
+
+ private static final String VERSION_PATCH_NAME = "X-PatchVersion";
+ private static final String VERSION_PATCH_DESCRIPTION = "Used only to communicate a PATCH version in a response for"
+ + " troubleshooting purposes only, and will not be provided by" + " the client on request";
+
+ private static final String VERSION_LATEST_NAME = "X-LatestVersion";
+ private static final String VERSION_LATEST_DESCRIPTION = "Used only to communicate an API's latest version";
+
+ private static final String REQUEST_ID_NAME = "X-ONAP-RequestID";
+ private static final String REQUEST_ID_HDR_DESCRIPTION = "Used to track REST transactions for logging purpose";
+ private static final String REQUEST_ID_PARAM_DESCRIPTION = "RequestID for http transaction";
+
+ private static final String AUTHENTICATION_ERROR_MESSAGE = "Authentication Error";
+ private static final String AUTHORIZATION_ERROR_MESSAGE = "Authorization Error";
+ private static final String SERVER_ERROR_MESSAGE = "Internal Server Error";
+ private static final String NOT_FOUND_MESSAGE = "Resource Not Found";
+ private static final String INVALID_BODY_MESSAGE = "Invalid Body";
+ private static final String INVALID_PAYLOAD_MESSAGE = "Not Acceptable Payload";
+ private static final String HTTP_CONFLICT_MESSAGE = "Delete Conflict, Rule Violation";
+
+
/**
* Retrieves the healthcheck status of the API component.
*
@@ -100,27 +140,27 @@ public class ApiRestController extends CommonRestController {
@ApiOperation(value = "Perform a system healthcheck", notes = "Returns healthy status of the Policy API component",
response = HealthCheckReport.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"HealthCheck", },
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"HealthCheck", },
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
public Response
- getHealthCheck(@HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
+ getHealthCheck(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
updateApiStatisticsCounter(Target.OTHER, Result.SUCCESS, HttpMethod.GET);
return makeOkResponse(requestId, new HealthCheckProvider().performHealthCheck());
@@ -137,27 +177,27 @@ public class ApiRestController extends CommonRestController {
notes = "Returns current statistics including the counters of API invocation",
response = StatisticsReport.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"Statistics", },
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Statistics", },
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
public Response
- getStatistics(@HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
+ getStatistics(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
updateApiStatisticsCounter(Target.OTHER, Result.SUCCESS, HttpMethod.GET);
@@ -175,34 +215,34 @@ public class ApiRestController extends CommonRestController {
notes = "Returns a list of existing policy types stored in Policy Framework",
response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType", },
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
public Response
- getAllPolicyTypes(@HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
+ getAllPolicyTypes(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
try (PolicyTypeProvider policyTypeProvider = new PolicyTypeProvider()) {
ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(null, null);
updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("GET /policytypes", pfme);
+ LOGGER.warn("GET /policytypes", pfme);
updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET);
return makeErrorResponse(requestId, pfme);
}
@@ -221,36 +261,36 @@ public class ApiRestController extends CommonRestController {
notes = "Returns a list of all available versions for the specified policy type",
response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType", },
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
public Response getAllVersionsOfPolicyType(
@PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
try (PolicyTypeProvider policyTypeProvider = new PolicyTypeProvider()) {
ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(policyTypeId, null);
updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("GET /policytypes/{}", policyTypeId, pfme);
+ LOGGER.warn("GET /policytypes/{}", policyTypeId, pfme);
updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET);
return makeErrorResponse(requestId, pfme);
}
@@ -269,37 +309,37 @@ public class ApiRestController extends CommonRestController {
@ApiOperation(value = "Retrieve one particular version of a policy type",
notes = "Returns a particular version for the specified policy type", response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType", },
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
public Response getSpecificVersionOfPolicyType(
@PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
@PathParam("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
try (PolicyTypeProvider policyTypeProvider = new PolicyTypeProvider()) {
ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(policyTypeId, versionId);
updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("GET /policytypes/{}/versions/{}", policyTypeId, versionId, pfme);
+ LOGGER.warn("GET /policytypes/{}/versions/{}", policyTypeId, versionId, pfme);
updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET);
return makeErrorResponse(requestId, pfme);
}
@@ -317,36 +357,36 @@ public class ApiRestController extends CommonRestController {
@ApiOperation(value = "Retrieve latest version of a policy type",
notes = "Returns latest version for the specified policy type", response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType", },
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
public Response getLatestVersionOfPolicyType(
@PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
try (PolicyTypeProvider policyTypeProvider = new PolicyTypeProvider()) {
ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchLatestPolicyTypes(policyTypeId);
updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("GET /policytypes/{}/versions/latest", policyTypeId, pfme);
+ LOGGER.warn("GET /policytypes/{}/versions/latest", policyTypeId, pfme);
updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.GET);
return makeErrorResponse(requestId, pfme);
}
@@ -362,32 +402,32 @@ public class ApiRestController extends CommonRestController {
@POST
@Path("/policytypes")
@ApiOperation(value = "Create a new policy type", notes = "Client should provide TOSCA body of the new policy type",
- authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType", },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid Body"),
- @ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 406, message = "Not Acceptable Payload"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
public Response createPolicyType(
@ApiParam(value = "Entity body of policy type", required = true) ToscaServiceTemplate body,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, "/policytypes", toJson(body));
@@ -398,7 +438,7 @@ public class ApiRestController extends CommonRestController {
updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.POST);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("POST /policytypes", pfme);
+ LOGGER.warn("POST /policytypes", pfme);
updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.POST);
return makeErrorResponse(requestId, pfme);
}
@@ -418,39 +458,41 @@ public class ApiRestController extends CommonRestController {
notes = "Rule 1: pre-defined policy types cannot be deleted;"
+ "Rule 2: policy types that are in use (parameterized by a TOSCA policy) cannot be deleted."
+ "The parameterizing TOSCA policies must be deleted first;",
- authorizations = @Authorization(value = "basicAuth"), tags = {"PolicyType", },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"PolicyType", },
response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 409, message = "Delete Conflict, Rule Violation"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
public Response deleteSpecificVersionOfPolicyType(
@PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
@PathParam("versionId") @ApiParam(value = "Version of policy type", required = true) String versionId,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
try (PolicyTypeProvider policyTypeProvider = new PolicyTypeProvider()) {
ToscaServiceTemplate serviceTemplate = policyTypeProvider.deletePolicyType(policyTypeId, versionId);
+ updateApiStatisticsCounter(Target.POLICY_TYPE, Result.SUCCESS, HttpMethod.DELETE);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("DELETE /policytypes/{}/versions/{}", policyTypeId, versionId, pfme);
+ LOGGER.warn("DELETE /policytypes/{}/versions/{}", policyTypeId, versionId, pfme);
+ updateApiStatisticsCounter(Target.POLICY_TYPE, Result.FAILURE, HttpMethod.DELETE);
return makeErrorResponse(requestId, pfme);
}
}
@@ -463,7 +505,6 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- // @formatter:off
@GET
@Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies")
@ApiOperation(
@@ -471,37 +512,35 @@ public class ApiRestController extends CommonRestController {
notes = "Returns a list of all versions of specified policy created for the specified policy type version",
response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"Policy,"},
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy,"},
extensions = {
- @Extension(name = "interface info", properties = {
- @ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")
})
}
)
@ApiResponses(value = {
- @ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 500, message = "Internal Server Error")
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
})
public Response getAllPolicies(
@PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
@PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",
required = true) String policyTypeVersion,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
@QueryParam("mode") @DefaultValue("bare") @ApiParam("Fetch mode for policies, BARE for bare policies (default),"
+ " REFERENCED for fully referenced policies") PolicyFetchMode mode
) {
@@ -512,12 +551,11 @@ public class ApiRestController extends CommonRestController {
updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("GET /policytypes/{}/versions/{}/policies", policyTypeId, policyTypeVersion, pfme);
+ LOGGER.warn("GET /policytypes/{}/versions/{}/policies", policyTypeId, policyTypeVersion, pfme);
updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);
return makeErrorResponse(requestId, pfme);
}
}
- // @formatter:on
/**
* Retrieves all versions of a particular policy.
@@ -528,44 +566,41 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- // @formatter:off
@GET
@Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}")
@ApiOperation(value = "Retrieve all version details of a policy created for a particular policy type version",
notes = "Returns a list of all version details of the specified policy", response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"Policy", },
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
extensions = {
- @Extension(name = "interface info", properties = {
- @ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")
})
}
)
@ApiResponses(value = {
- @ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 500, message = "Internal Server Error")
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
})
public Response getAllVersionsOfPolicy(
@PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
@PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",
required = true) String policyTypeVersion,
@PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
@QueryParam("mode") @DefaultValue("bare") @ApiParam("Fetch mode for policies, BARE for bare policies (default),"
+ " REFERENCED for fully referenced policies") PolicyFetchMode mode
) {
@@ -575,12 +610,11 @@ public class ApiRestController extends CommonRestController {
updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("/policytypes/{}/versions/{}/policies/{}", policyTypeId, policyTypeVersion, policyId, pfme);
+ LOGGER.warn("/policytypes/{}/versions/{}/policies/{}", policyTypeId, policyTypeVersion, policyId, pfme);
updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);
return makeErrorResponse(requestId, pfme);
}
}
- // @formatter:on
/**
* Retrieves the specified version of a particular policy.
@@ -592,38 +626,35 @@ public class ApiRestController extends CommonRestController {
*
* @return the Response object containing the results of the API operation
*/
- // @formatter:off
@GET
@Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}")
@ApiOperation(value = "Retrieve one version of a policy created for a particular policy type version",
notes = "Returns a particular version of specified policy created for the specified policy type version",
response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"Policy", },
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
extensions = {
- @Extension(name = "interface info", properties = {
- @ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")
})
}
)
@ApiResponses(value = {
- @ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 500, message = "Internal Server Error")
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
})
public Response getSpecificVersionOfPolicy(
@PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
@@ -631,7 +662,7 @@ public class ApiRestController extends CommonRestController {
required = true) String policyTypeVersion,
@PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
@PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
@QueryParam("mode") @DefaultValue("bare") @ApiParam("Fetch mode for policies, BARE for bare policies (default),"
+ " REFERENCED for fully referenced policies") PolicyFetchMode mode
) {
@@ -641,13 +672,12 @@ public class ApiRestController extends CommonRestController {
updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("GET /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, policyTypeVersion,
+ LOGGER.warn("GET /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, policyTypeVersion,
policyId, policyVersion, pfme);
updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);
return makeErrorResponse(requestId, pfme);
}
}
- // @formatter:on
/**
* Retrieves the latest version of a particular policy.
@@ -663,32 +693,32 @@ public class ApiRestController extends CommonRestController {
@ApiOperation(value = "Retrieve the latest version of a particular policy",
notes = "Returns the latest version of specified policy", response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
- authorizations = @Authorization(value = "basicAuth"), tags = {"Policy", },
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
public Response getLatestVersionOfPolicy(
@PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
@PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",
required = true) String policyTypeVersion,
@PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
@QueryParam("mode") @ApiParam("Fetch mode for policies, TERSE for bare policies (default), "
+ "REFERENCED for fully referenced policies") PolicyFetchMode mode) {
@@ -698,7 +728,7 @@ public class ApiRestController extends CommonRestController {
updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("GET /policytypes/{}/versions/{}/policies/{}/versions/latest", policyTypeId, policyTypeVersion,
+ LOGGER.warn("GET /policytypes/{}/versions/{}/policies/{}/versions/latest", policyTypeId, policyTypeVersion,
policyId, pfme);
updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);
return makeErrorResponse(requestId, pfme);
@@ -718,35 +748,35 @@ public class ApiRestController extends CommonRestController {
@Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies")
@ApiOperation(value = "Create a new policy for a policy type version",
notes = "Client should provide TOSCA body of the new policy",
- authorizations = @Authorization(value = "basicAuth"), tags = {"Policy", },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid Body"),
- @ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 406, message = "Not Acceptable Payload"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
public Response createPolicy(
@PathParam("policyTypeId") @ApiParam(value = "ID of policy type", required = true) String policyTypeId,
@PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",
required = true) String policyTypeVersion,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
@ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) {
if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
@@ -759,13 +789,184 @@ public class ApiRestController extends CommonRestController {
updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.POST);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("POST /policytypes/{}/versions/{}/policies", policyTypeId, policyTypeVersion, pfme);
+ LOGGER.warn("POST /policytypes/{}/versions/{}/policies", policyTypeId, policyTypeVersion, pfme);
updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.POST);
return makeErrorResponse(requestId, pfme);
}
}
/**
+ * Deletes the specified version of a particular policy.
+ *
+ * @param policyTypeId the ID of specified policy type
+ * @param policyTypeVersion the version of specified policy type
+ * @param policyId the ID of specified policy
+ * @param policyVersion the version of specified policy
+ *
+ * @return the Response object containing the results of the API operation
+ */
+ @DELETE
+ @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}")
+ @ApiOperation(value = "Delete a particular version of a policy",
+ notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
+ response = ToscaServiceTemplate.class,
+ responseHeaders = {
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ extensions = {
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Dublin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ public Response deleteSpecificVersionOfPolicy(
+ @PathParam("policyTypeId") @ApiParam(value = "PolicyType ID", required = true) String policyTypeId,
+ @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",
+ required = true) String policyTypeVersion,
+ @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
+ @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
+
+ try (PolicyProvider policyProvider = new PolicyProvider()) {
+ ToscaServiceTemplate serviceTemplate =
+ policyProvider.deletePolicy(policyTypeId, policyTypeVersion, policyId, policyVersion);
+ updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.DELETE);
+ return makeOkResponse(requestId, serviceTemplate);
+ } catch (PfModelException | PfModelRuntimeException pfme) {
+ LOGGER.warn("DELETE /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, policyTypeVersion,
+ policyId, policyVersion, pfme);
+ updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.DELETE);
+ return makeErrorResponse(requestId, pfme);
+ }
+ }
+
+ /**
+ * Retrieves all the available policies.
+ *
+ * @return the Response object containing the results of the API operation
+ */
+ @GET
+ @Path("/policies")
+ @ApiOperation(value = "Retrieve all versions of available policies",
+ notes = "Returns all version of available policies",
+ response = ToscaServiceTemplate.class,
+ responseHeaders = {
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
+ extensions = {
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")
+ })
+ }
+ )
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
+ })
+ public Response getPolicies(
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @QueryParam("mode") @DefaultValue("bare") @ApiParam("Fetch mode for policies, BARE for bare policies (default),"
+ + " REFERENCED for fully referenced policies") PolicyFetchMode mode
+ ) {
+ try (PolicyProvider policyProvider = new PolicyProvider()) {
+ ToscaServiceTemplate serviceTemplate =
+ policyProvider.fetchPolicies(null, null, null, null, mode);
+ updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);
+ return makeOkResponse(requestId, serviceTemplate);
+ } catch (PfModelException | PfModelRuntimeException pfme) {
+ LOGGER.warn("GET /policies/ --", pfme);
+ updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);
+ if (pfme.getErrorResponse().getResponseCode().equals(Status.NOT_FOUND)) {
+ pfme.getErrorResponse().setErrorMessage(ERROR_MESSAGE_NO_POLICIES_FOUND);
+ pfme.getErrorResponse().setErrorDetails(List.of(ERROR_MESSAGE_NO_POLICIES_FOUND));
+ }
+ return makeErrorResponse(requestId, pfme);
+ }
+ }
+
+ /**
+ * Retrieves the specified version of a particular policy.
+ *
+ * @param policyId the Name of specified policy
+ * @param policyVersion the version of specified policy
+ *
+ * @return the Response object containing the results of the API operation
+ */
+ @GET
+ @Path("/policies/{policyId}/versions/{policyVersion}")
+ @ApiOperation(value = "Retrieve specific version of a specified policy",
+ notes = "Returns a particular version of specified policy",
+ response = ToscaServiceTemplate.class,
+ responseHeaders = {
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
+ extensions = {
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")
+ })
+ }
+ )
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)
+ })
+ public Response getSpecificPolicy(
+ @PathParam("policyId") @ApiParam(value = "Name of policy", required = true) String policyId,
+ @PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @QueryParam("mode") @DefaultValue("bare") @ApiParam("Fetch mode for policies, BARE for bare policies (default),"
+ + " REFERENCED for fully referenced policies") PolicyFetchMode mode
+ ) {
+ try (PolicyProvider policyProvider = new PolicyProvider()) {
+ ToscaServiceTemplate serviceTemplate =
+ policyProvider.fetchPolicies(null, null, policyId, policyVersion, mode);
+ updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.GET);
+ return makeOkResponse(requestId, serviceTemplate);
+ } catch (PfModelException | PfModelRuntimeException pfme) {
+ LOGGER.warn("GET /policies/{}/versions/{}", policyId, policyVersion, pfme);
+ updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.GET);
+ return makeErrorResponse(requestId, pfme);
+ }
+ }
+
+ /**
* Creates one or more new policies in one call.
*
* @param body the body of policy following TOSCA definition
@@ -776,32 +977,32 @@ public class ApiRestController extends CommonRestController {
@Path("/policies")
@ApiOperation(value = "Create one or more new policies",
notes = "Client should provide TOSCA body of the new polic(ies)",
- authorizations = @Authorization(value = "basicAuth"), tags = {"Policy", },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "El Alto")})})
- @ApiResponses(value = {@ApiResponse(code = 400, message = "Invalid Body"),
- @ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 406, message = "Not Acceptable Payload"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "El Alto")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_BAD_REQUEST, message = INVALID_BODY_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_ACCEPTABLE, message = INVALID_PAYLOAD_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
public Response createPolicies(
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
@ApiParam(value = "Entity body of policy", required = true) ToscaServiceTemplate body) {
if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
@@ -813,7 +1014,7 @@ public class ApiRestController extends CommonRestController {
updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.POST);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("POST /policies", pfme);
+ LOGGER.warn("POST /policies", pfme);
updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.POST);
return makeErrorResponse(requestId, pfme);
}
@@ -822,59 +1023,57 @@ public class ApiRestController extends CommonRestController {
/**
* Deletes the specified version of a particular policy.
*
- * @param policyTypeId the ID of specified policy type
- * @param policyTypeVersion the version of specified policy type
* @param policyId the ID of specified policy
* @param policyVersion the version of specified policy
*
* @return the Response object containing the results of the API operation
*/
@DELETE
- @Path("/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies/{policyId}/versions/{policyVersion}")
+ @Path("/policies/{policyId}/versions/{policyVersion}")
@ApiOperation(value = "Delete a particular version of a policy",
notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",
- authorizations = @Authorization(value = "basicAuth"), tags = {"Policy", },
- response = ToscaServiceTemplate.class,
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE), tags = {"Policy", },
+ response = ToscaServiceTemplate.class,
responseHeaders = {
- @ResponseHeader(name = "X-MinorVersion",
- description = "Used to request or communicate a MINOR version back from the client"
- + " to the server, and from the server back to the client",
+ @ResponseHeader(name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-PatchVersion",
- description = "Used only to communicate a PATCH version in a response for"
- + " troubleshooting purposes only, and will not be provided by" + " the client on request",
+ @ResponseHeader(name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-LatestVersion", description = "Used only to communicate an API's latest version",
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", response = UUID.class)},
+ @ResponseHeader(name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION, response = UUID.class)},
extensions = {
- @Extension(name = "interface info", properties = {@ExtensionProperty(name = "api-version", value = "1.0.0"),
- @ExtensionProperty(name = "last-mod-release", value = "Dublin")})})
- @ApiResponses(value = {@ApiResponse(code = 401, message = "Authentication Error"),
- @ApiResponse(code = 403, message = "Authorization Error"),
- @ApiResponse(code = 404, message = "Resource Not Found"),
- @ApiResponse(code = 409, message = "Delete Conflict, Rule Violation"),
- @ApiResponse(code = 500, message = "Internal Server Error")})
- public Response deleteSpecificVersionOfPolicy(
- @PathParam("policyTypeId") @ApiParam(value = "PolicyType ID", required = true) String policyTypeId,
- @PathParam("policyTypeVersion") @ApiParam(value = "Version of policy type",
- required = true) String policyTypeVersion,
+ @Extension(name = EXTENSION_NAME, properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = "Guilin")})})
+ @ApiResponses(value = {
+ @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = NOT_FOUND_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_CONFLICT, message = HTTP_CONFLICT_MESSAGE),
+ @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = SERVER_ERROR_MESSAGE)})
+ public Response deleteSpecificPolicy(
@PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
@PathParam("policyVersion") @ApiParam(value = "Version of policy", required = true) String policyVersion,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId) {
try (PolicyProvider policyProvider = new PolicyProvider()) {
ToscaServiceTemplate serviceTemplate =
- policyProvider.deletePolicy(policyTypeId, policyTypeVersion, policyId, policyVersion);
+ policyProvider.deletePolicy(null, null, policyId, policyVersion);
+ updateApiStatisticsCounter(Target.POLICY, Result.SUCCESS, HttpMethod.DELETE);
return makeOkResponse(requestId, serviceTemplate);
} catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("DELETE /policytypes/{}/versions/{}/policies/{}/versions/{}", policyTypeId, policyTypeVersion,
- policyId, policyVersion, pfme);
+ LOGGER.warn("DELETE /policies/{}/versions/{}", policyId, policyVersion, pfme);
+ updateApiStatisticsCounter(Target.POLICY, Result.FAILURE, HttpMethod.DELETE);
return makeErrorResponse(requestId, pfme);
}
}
+
+
private enum Target {
POLICY,
POLICY_TYPE,
@@ -888,7 +1087,8 @@ public class ApiRestController extends CommonRestController {
private enum HttpMethod {
POST,
- GET
+ GET,
+ DELETE
}
private void updateApiStatisticsCounter(Target target, Result result, HttpMethod http) {
@@ -910,48 +1110,92 @@ public class ApiRestController extends CommonRestController {
private void updatePolicyStats(Result result, HttpMethod http) {
if (result == Result.SUCCESS) {
- if (http == HttpMethod.GET) {
- ApiStatisticsManager.updateApiCallSuccessCount();
- ApiStatisticsManager.updateTotalPolicyGetCount();
- ApiStatisticsManager.updatePolicyGetSuccessCount();
- } else if (http == HttpMethod.POST) {
- ApiStatisticsManager.updateApiCallSuccessCount();
- ApiStatisticsManager.updateTotalPolicyPostCount();
- ApiStatisticsManager.updatePolicyPostSuccessCount();
+ switch (http) {
+ case GET:
+ ApiStatisticsManager.updateApiCallSuccessCount();
+ ApiStatisticsManager.updateTotalPolicyGetCount();
+ ApiStatisticsManager.updatePolicyGetSuccessCount();
+ break;
+ case POST:
+ ApiStatisticsManager.updateApiCallSuccessCount();
+ ApiStatisticsManager.updateTotalPolicyPostCount();
+ ApiStatisticsManager.updatePolicyPostSuccessCount();
+ break;
+ case DELETE:
+ ApiStatisticsManager.updateApiCallSuccessCount();
+ ApiStatisticsManager.updateTotalPolicyDeleteCount();
+ ApiStatisticsManager.updatePolicyDeleteSuccessCount();
+ break;
+ default:
+ ApiStatisticsManager.updateApiCallSuccessCount();
+ break;
}
} else {
- if (http == HttpMethod.GET) {
- ApiStatisticsManager.updateApiCallFailureCount();
- ApiStatisticsManager.updateTotalPolicyGetCount();
- ApiStatisticsManager.updatePolicyGetFailureCount();
- } else {
- ApiStatisticsManager.updateApiCallFailureCount();
- ApiStatisticsManager.updateTotalPolicyPostCount();
- ApiStatisticsManager.updatePolicyPostFailureCount();
+ switch (http) {
+ case GET:
+ ApiStatisticsManager.updateApiCallFailureCount();
+ ApiStatisticsManager.updateTotalPolicyGetCount();
+ ApiStatisticsManager.updatePolicyGetFailureCount();
+ break;
+ case POST:
+ ApiStatisticsManager.updateApiCallFailureCount();
+ ApiStatisticsManager.updateTotalPolicyPostCount();
+ ApiStatisticsManager.updatePolicyPostFailureCount();
+ break;
+ case DELETE:
+ ApiStatisticsManager.updateApiCallFailureCount();
+ ApiStatisticsManager.updateTotalPolicyDeleteCount();
+ ApiStatisticsManager.updatePolicyDeleteFailureCount();
+ break;
+ default:
+ ApiStatisticsManager.updateApiCallFailureCount();
+ break;
}
}
}
private void updatePolicyTypeStats(Result result, HttpMethod http) {
if (result == Result.SUCCESS) {
- if (http == HttpMethod.GET) {
- ApiStatisticsManager.updateApiCallSuccessCount();
- ApiStatisticsManager.updateTotalPolicyTypeGetCount();
- ApiStatisticsManager.updatePolicyTypeGetSuccessCount();
- } else if (http == HttpMethod.POST) {
- ApiStatisticsManager.updateApiCallSuccessCount();
- ApiStatisticsManager.updatePolicyTypePostSuccessCount();
- ApiStatisticsManager.updatePolicyTypePostSuccessCount();
+ switch (http) {
+ case GET:
+ ApiStatisticsManager.updateApiCallSuccessCount();
+ ApiStatisticsManager.updateTotalPolicyTypeGetCount();
+ ApiStatisticsManager.updatePolicyTypeGetSuccessCount();
+ break;
+ case POST:
+ ApiStatisticsManager.updateApiCallSuccessCount();
+ ApiStatisticsManager.updateTotalPolicyTypePostCount();
+ ApiStatisticsManager.updatePolicyTypePostSuccessCount();
+ break;
+ case DELETE:
+ ApiStatisticsManager.updateApiCallSuccessCount();
+ ApiStatisticsManager.updateTotalPolicyTypeDeleteCount();
+ ApiStatisticsManager.updatePolicyTypeDeleteSuccessCount();
+ break;
+ default:
+ ApiStatisticsManager.updateApiCallSuccessCount();
+ break;
}
} else {
- if (http == HttpMethod.GET) {
- ApiStatisticsManager.updateApiCallFailureCount();
- ApiStatisticsManager.updateTotalPolicyTypeGetCount();
- ApiStatisticsManager.updatePolicyTypeGetFailureCount();
- } else {
- ApiStatisticsManager.updateApiCallFailureCount();
- ApiStatisticsManager.updateTotalPolicyTypePostCount();
- ApiStatisticsManager.updatePolicyTypePostFailureCount();
+ switch (http) {
+ case GET:
+ ApiStatisticsManager.updateApiCallFailureCount();
+ ApiStatisticsManager.updateTotalPolicyTypeGetCount();
+ ApiStatisticsManager.updatePolicyTypeGetFailureCount();
+ break;
+ case POST:
+ ApiStatisticsManager.updateApiCallFailureCount();
+ ApiStatisticsManager.updateTotalPolicyTypePostCount();
+ ApiStatisticsManager.updatePolicyTypePostFailureCount();
+ break;
+ case DELETE:
+ ApiStatisticsManager.updateApiCallFailureCount();
+ ApiStatisticsManager.updateTotalPolicyTypeDeleteCount();
+ ApiStatisticsManager.updatePolicyTypeDeleteFailureCount();
+ break;
+ default:
+ ApiStatisticsManager.updateApiCallFailureCount();
+ break;
}
}
}
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java b/main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java
index 6f8fb103..c40a38c4 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java
@@ -3,6 +3,7 @@
* ONAP Policy API
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,12 +48,18 @@ public class ApiStatisticsManager {
private static long totalPolicyPostCount;
@Getter
+ private static long totalPolicyDeleteCount;
+
+ @Getter
private static long totalPolicyTypeGetCount;
@Getter
private static long totalPolicyTypePostCount;
@Getter
+ private static long totalPolicyTypeDeleteCount;
+
+ @Getter
private static long policyGetSuccessCount;
@Getter
@@ -65,6 +72,12 @@ public class ApiStatisticsManager {
private static long policyPostFailureCount;
@Getter
+ private static long policyDeleteSuccessCount;
+
+ @Getter
+ private static long policyDeleteFailureCount;
+
+ @Getter
private static long policyTypeGetSuccessCount;
@Getter
@@ -76,6 +89,12 @@ public class ApiStatisticsManager {
@Getter
private static long policyTypePostFailureCount;
+ @Getter
+ private static long policyTypeDeleteSuccessCount;
+
+ @Getter
+ private static long policyTypeDeleteFailureCount;
+
private ApiStatisticsManager() {
throw new IllegalStateException("Instantiation of the class is not allowed");
}
@@ -126,6 +145,15 @@ public class ApiStatisticsManager {
}
/**
+ * Method to update the total policy DELETE count.
+ *
+ * @return the updated value of totalPolicyDeleteCount
+ */
+ public static long updateTotalPolicyDeleteCount() {
+ return ++totalPolicyDeleteCount;
+ }
+
+ /**
* Method to update the total policyType GET count.
*
* @return the updated value of totalPolicyTypeGetCount
@@ -144,6 +172,15 @@ public class ApiStatisticsManager {
}
/**
+ * Method to update the total policyType DELETE count.
+ *
+ * @return the updated value of totalPolicyTypeDeleteCount
+ */
+ public static long updateTotalPolicyTypeDeleteCount() {
+ return ++totalPolicyTypeDeleteCount;
+ }
+
+ /**
* Method to update successful policy GET count.
*
* @return the updated value of policyGetSuccessCount
@@ -180,6 +217,24 @@ public class ApiStatisticsManager {
}
/**
+ * Method to update successful policy DELETE count.
+ *
+ * @return the updated value of policyDeleteSuccessCount
+ */
+ public static long updatePolicyDeleteSuccessCount() {
+ return ++policyDeleteSuccessCount;
+ }
+
+ /**
+ * Method to update failed policy DELETE count.
+ *
+ * @return the updated value of policyDeleteFailureCount
+ */
+ public static long updatePolicyDeleteFailureCount() {
+ return ++policyDeleteFailureCount;
+ }
+
+ /**
* Method to update successful policyType GET count.
*
* @return the updated value of policyTypeGetSuccessCount
@@ -216,6 +271,24 @@ public class ApiStatisticsManager {
}
/**
+ * Method to update successful policyType DELETE count.
+ *
+ * @return the updated value of policyTypeDeleteSuccessCount
+ */
+ public static long updatePolicyTypeDeleteSuccessCount() {
+ return ++policyTypeDeleteSuccessCount;
+ }
+
+ /**
+ * Method to update failed policyType DELETE count.
+ *
+ * @return the updated value of policyTypePostFailureCount
+ */
+ public static long updatePolicyTypeDeleteFailureCount() {
+ return ++policyTypeDeleteFailureCount;
+ }
+
+ /**
* Reset all the statistics counts to 0.
*/
public static void resetAllStatistics() {
@@ -224,15 +297,23 @@ public class ApiStatisticsManager {
apiCallFailureCount = 0L;
totalPolicyGetCount = 0L;
totalPolicyPostCount = 0L;
+ totalPolicyDeleteCount = 0L;
totalPolicyTypeGetCount = 0L;
totalPolicyTypePostCount = 0L;
+ totalPolicyTypeDeleteCount = 0L;
policyGetSuccessCount = 0L;
policyGetFailureCount = 0L;
policyPostSuccessCount = 0L;
policyPostFailureCount = 0L;
+ policyDeleteSuccessCount = 0L;
+ policyDeleteFailureCount = 0L;
policyTypeGetSuccessCount = 0L;
policyTypeGetFailureCount = 0L;
policyTypePostSuccessCount = 0L;
policyTypePostFailureCount = 0L;
+ policyTypeDeleteSuccessCount = 0L;
+ policyTypeDeleteFailureCount = 0L;
+
}
+
}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
index 2f794fd7..01892be1 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
@@ -3,6 +3,7 @@
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,6 +48,7 @@ import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.AfterClass;
@@ -197,6 +199,8 @@ public class TestApiRestServer {
"policies/vCPE.policy.operational.legacy.input.json", "policies/vDNS.policy.operational.legacy.input.json",
"policies/vFirewall.policy.operational.legacy.input.json"};
+ private static final String POLICIES_VCPE_VERSION1 = "policies/onap.restart.tca/versions/1.0.0";
+
private static PolicyModelsProviderParameters providerParams;
private static ApiParameterGroup apiParamGroup;
private static PolicyProvider policyProvider;
@@ -335,6 +339,7 @@ public class TestApiRestServer {
.getResourceAsString(TOSCA_POLICY_RESOURCE_NAMES[TOSCA_POLICIES_RESOURCE_NAMES.length - 1]);
toscaPolicy = toscaPolicy.replaceAll("onap.policies.monitoring.cdap.tca.hi.lo.app", "IDontExist");
+ toscaPolicy = toscaPolicy.replaceAll("onap.restart.tca", "onap.restart.tca.IDontExist");
TextFileUtils.putStringAsTextFile(toscaPolicy, "src/test/resources/policies/BadTestPolicy.yaml");
Response rawResponse2 = createResource(POLICIES, "src/test/resources/policies/BadTestPolicy.yaml");
@@ -836,6 +841,93 @@ public class TestApiRestServer {
assertEquals("policy operational.scaleout:1.0.0 not found", errorResponse.getErrorMessage());
}
+ @Test
+ public void testGetPoliciesJson() throws Exception {
+ getPolicies(APP_JSON);
+ }
+
+ @Test
+ public void testGetPoliciesYaml() throws Exception {
+ getPolicies(APP_YAML);
+ }
+
+ private void getPolicies(String mediaType) throws Exception {
+ for (String resrcName : TOSCA_POLICYTYPE_RESOURCE_NAMES) {
+ Response rawResponse = createResource(POLICYTYPES, resrcName);
+ assertThat(rawResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
+ ToscaServiceTemplate response = rawResponse.readEntity(ToscaServiceTemplate.class);
+ assertThat(response).isNotNull();
+ assertThat(response.getPolicyTypes()).isNotEmpty();
+ }
+ for (String resrcName : TOSCA_POLICY_RESOURCE_NAMES) {
+ Response rawResponse = createResource(POLICYTYPES_TCA_POLICIES, resrcName);
+ assertThat(rawResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
+ }
+ Response rawResponse = readResource(POLICIES, mediaType);
+ assertThat(rawResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
+ ToscaServiceTemplate response = rawResponse.readEntity(ToscaServiceTemplate.class);
+ assertThat(response.getToscaTopologyTemplate().getPolicies()).isNotEmpty();
+ }
+
+ @Test
+ public void testGetSpecificPolicyJson() throws Exception {
+ getSpecificPolicy(APP_JSON);
+ }
+
+ @Test
+ public void testGetSpecificPolicyYaml() throws Exception {
+ getSpecificPolicy(APP_YAML);
+ }
+
+ private void getSpecificPolicy(String mediaType) throws Exception {
+ for (String resrcName : TOSCA_POLICYTYPE_RESOURCE_NAMES) {
+ Response rawResponse = createResource(POLICYTYPES, resrcName);
+ assertThat(rawResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
+ ToscaServiceTemplate response = rawResponse.readEntity(ToscaServiceTemplate.class);
+ assertThat(response).isNotNull();
+ assertThat(response.getPolicyTypes()).isNotEmpty();
+ }
+ for (String resrcName : TOSCA_POLICY_RESOURCE_NAMES) {
+ Response rawResponse = createResource(POLICYTYPES_TCA_POLICIES, resrcName);
+ assertThat(rawResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
+ }
+ Response rawResponse = readResource(POLICIES_VCPE_VERSION1, mediaType);
+ assertThat(rawResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
+ ToscaServiceTemplate response = rawResponse.readEntity(ToscaServiceTemplate.class);
+ assertThat(response.getToscaTopologyTemplate().getPolicies()).hasSize(1);
+ }
+
+ @Test
+ public void testDeleteSpecificPolicy() throws Exception {
+ Response rawResponse;
+ for (String resrcName : TOSCA_POLICYTYPE_RESOURCE_NAMES) {
+ rawResponse = createResource(POLICYTYPES, resrcName);
+ assertThat(rawResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
+ ToscaServiceTemplate response = rawResponse.readEntity(ToscaServiceTemplate.class);
+ assertThat(response).isNotNull();
+ assertThat(response.getPolicyTypes()).isNotEmpty();
+ }
+ for (String resrcName : TOSCA_POLICY_RESOURCE_NAMES) {
+ rawResponse = createResource(POLICYTYPES_TCA_POLICIES, resrcName);
+ assertThat(rawResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
+ }
+
+ rawResponse = readResource(POLICIES_VCPE_VERSION1, APP_JSON);
+ assertThat(rawResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
+
+ // delete a particular policy
+ rawResponse = deleteResource(POLICIES_VCPE_VERSION1, APP_JSON);
+ assertThat(rawResponse.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
+
+ rawResponse = readResource(POLICIES_VCPE_VERSION1, APP_JSON);
+ assertThat(rawResponse.getStatus()).isEqualTo(Status.NOT_FOUND.getStatusCode());
+
+ rawResponse = deleteResource(POLICIES_VCPE_VERSION1, APP_JSON);
+ assertThat(rawResponse.getStatus()).isEqualTo(Status.NOT_FOUND.getStatusCode());
+
+ }
+
+
private Response createResource(String endpoint, String resourceName) throws Exception {
String mediaType = APP_JSON; // default media type
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java
index b72ad23c..148ec1b8 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatisticsManager.java
@@ -3,6 +3,7 @@
* ONAP Policy API
* ================================================================================
* Copyright (C) 2019 IBM.
+ * Modifications Copyright (C) 2020 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,10 +37,26 @@ public class TestApiStatisticsManager {
@Test
public void testUpdateMethods() {
+ assertEquals(1, ApiStatisticsManager.updateTotalApiCallCount());
+ assertEquals(1, ApiStatisticsManager.updateApiCallSuccessCount());
+ assertEquals(1, ApiStatisticsManager.updateApiCallFailureCount());
+ assertEquals(1, ApiStatisticsManager.updateTotalPolicyGetCount());
+ assertEquals(1, ApiStatisticsManager.updateTotalPolicyPostCount());
+ assertEquals(1, ApiStatisticsManager.updateTotalPolicyDeleteCount());
+ assertEquals(1, ApiStatisticsManager.updateTotalPolicyTypeGetCount());
assertEquals(1, ApiStatisticsManager.updateTotalPolicyTypePostCount());
+ assertEquals(1, ApiStatisticsManager.updateTotalPolicyTypeDeleteCount());
assertEquals(1, ApiStatisticsManager.updatePolicyGetSuccessCount());
+ assertEquals(1, ApiStatisticsManager.updatePolicyGetFailureCount());
assertEquals(1, ApiStatisticsManager.updatePolicyPostSuccessCount());
+ assertEquals(1, ApiStatisticsManager.updatePolicyPostFailureCount());
+ assertEquals(1, ApiStatisticsManager.updatePolicyDeleteSuccessCount());
+ assertEquals(1, ApiStatisticsManager.updatePolicyDeleteFailureCount());
+ assertEquals(1, ApiStatisticsManager.updatePolicyTypeGetSuccessCount());
+ assertEquals(1, ApiStatisticsManager.updatePolicyTypeGetFailureCount());
+ assertEquals(1, ApiStatisticsManager.updatePolicyTypePostSuccessCount());
assertEquals(1, ApiStatisticsManager.updatePolicyTypePostFailureCount());
+ assertEquals(1, ApiStatisticsManager.updatePolicyTypeDeleteSuccessCount());
+ assertEquals(1, ApiStatisticsManager.updatePolicyTypeDeleteFailureCount());
}
-
}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
index 23257e34..a86f969a 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +24,7 @@
package org.onap.policy.api.main.rest.provider;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
@@ -140,6 +142,10 @@ public class TestPolicyProvider {
assertThatThrownBy(() -> {
policyProvider.fetchPolicies("dummy", "1.0.0", "dummy", "1.0.0", null);
}).hasMessage("service template not found in database");
+
+ assertThatThrownBy(() -> {
+ policyProvider.fetchPolicies(null, null, "dummy", "1.0.0", null);
+ }).hasMessage("service template not found in database");
}
@Test
@@ -413,4 +419,108 @@ public class TestPolicyProvider {
"1.0.0");
}).hasMessageContaining("no policies found");
}
+
+ @Test
+ public void testFetchAllPolicies() throws Exception {
+ // Create Policy Type
+ ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
+ .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
+ policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+
+ // Create Policy
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ ToscaServiceTemplate policyServiceTemplate =
+ standardCoder.decode(policyString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = policyProvider.createPolicy(
+ "onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
+
+ assertThat(serviceTemplate.getToscaTopologyTemplate().getPolicies()).hasSize(1);
+
+ // Test fetch all policies
+ policyTypeServiceTemplate = policyProvider
+ .fetchPolicies(null, null, null, null, null);
+
+ assertThat(policyTypeServiceTemplate.getToscaTopologyTemplate().getPolicies()).hasSize(1);
+ }
+
+ @Test
+ public void testFetchSpecificPolicy_availablePolicy() throws Exception {
+ // Create Policy Type
+ ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
+ .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
+ policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+
+ // Create Policy
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ ToscaServiceTemplate policyServiceTemplate =
+ standardCoder.decode(policyString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = policyProvider.createPolicy(
+ "onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
+
+ assertThat(serviceTemplate.getToscaTopologyTemplate().getPolicies()).hasSize(1);
+
+ // Test fetch specific policy
+ assertThat(policyProvider.fetchPolicies(null, null, "onap.restart.tca",
+ "1.0.0", null).getToscaTopologyTemplate().getPolicies()).hasSize(1);
+ }
+
+ @Test
+ public void testFetchSpecificPolicy_unavailablePolicy() throws Exception {
+ // Create Policy Type
+ ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
+ .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
+ policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+
+ // Create Policy
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ ToscaServiceTemplate policyServiceTemplate =
+ standardCoder.decode(policyString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = policyProvider.createPolicy(
+ "onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
+ assertNotNull(serviceTemplate.getToscaTopologyTemplate().getPolicies());
+ assertThat(serviceTemplate.getToscaTopologyTemplate().getPolicies()).hasSize(1);
+
+ // Test fetch specific policy
+ assertThatThrownBy(() -> policyProvider.fetchPolicies(
+ null, null, "onap.restart.tca", "2.0.0", null))
+ .hasMessageContaining("policies for onap.restart.tca:2.0.0 do not exist");
+ }
+
+ @Test
+ public void testDeleteSpecificPolicy_availablePolicy() throws Exception {
+ ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
+ .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
+ policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ ToscaServiceTemplate policyServiceTemplate = standardCoder.decode(policyString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = policyProvider.createPolicy(
+ "onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
+ assertThat(serviceTemplate.getToscaTopologyTemplate().getPolicies()).hasSize(1);
+
+ ToscaServiceTemplate svcTemplate = policyProvider
+ .deletePolicy(null, null, "onap.restart.tca", "1.0.0");
+ assertThat(svcTemplate.getToscaTopologyTemplate().getPolicies()).hasSize(1);
+ }
+
+ @Test
+ public void testDeleteSpecificPolicy_unavailablePolicy() throws Exception {
+ ToscaServiceTemplate policyTypeServiceTemplate = standardYamlCoder
+ .decode(ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE), ToscaServiceTemplate.class);
+ policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ ToscaServiceTemplate policyServiceTemplate = standardCoder.decode(policyString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = policyProvider.createPolicy(
+ "onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
+ assertThat(serviceTemplate.getToscaTopologyTemplate().getPolicies()).hasSize(1);
+
+ assertThatThrownBy(() -> policyProvider
+ .deletePolicy(null, null, "onap.restart.tca", "2.0.0"))
+ .hasMessageContaining("not found");
+
+ assertThatThrownBy(() -> policyProvider.deletePolicy(
+ null, null, "onap.restart.tca.unavailable", "1.0.0"))
+ .hasMessageContaining("not found");
+ }
}
diff --git a/postman/lifecycle-api-collection.json b/postman/lifecycle-api-collection.json
index 3b496626..4f240885 100644
--- a/postman/lifecycle-api-collection.json
+++ b/postman/lifecycle-api-collection.json
@@ -1,716 +1,818 @@
{
- "info": {
- "_postman_id": "1592e803-60f3-4f7e-a1e1-4ad01c72d960",
- "name": "Policy Framework Lifecycle API",
- "description": "This collection lists all the Lifecycle API's supported by ONAP Policy Framework. These API's are used to perform CRUD operations for Policy, Policy Type & Data Type for all supported PDP engines.",
- "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
+ "info": {
+ "_postman_id": "50c9900b-7fbc-42f6-8d84-f3761824b96b",
+ "name": "Policy Framework Lifecycle API",
+ "description": "This collection lists all the Lifecycle API's supported by ONAP Policy Framework. These API's are used to perform CRUD operations for Policy, Policy Type & Data Type for all supported PDP engines.",
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
+ },
+ "item": [
+ {
+ "name": "Lifecycle Api Healthcheck",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/healthcheck",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "healthcheck"
+ ]
+ },
+ "description": "This is an API to fetch current healthcheck information for the policy-api component."
+ },
+ "response": []
},
- "item": [
- {
- "name": "Lifecycle Api Healthcheck",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/healthcheck",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "healthcheck"
- ]
- },
- "description": "This is an API to fetch current healthcheck information for the policy-api component."
- },
- "response": []
+ {
+ "name": "Lifecycle Api Statistics",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/statistics",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "statistics"
+ ]
},
- {
- "name": "Lifecycle Api Statistics",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/statistics",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "statistics"
- ]
- },
- "description": "This is an API to fetch current statistics information for the policy-api component."
- },
- "response": []
+ "description": "This is an API to fetch current statistics information for the policy-api component."
+ },
+ "response": []
+ },
+ {
+ "name": "Create Policy Type",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/yaml"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/yaml"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.operational.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant\n Policy Types. This does NOT support the legacy Policy YAML policy type.\n properties:\n id:\n type: string\n description: The unique control loop id.\n required: true\n timeout:\n type: integer\n description: |\n Overall timeout for executing all the operations. This timeout should equal or exceed the total\n timeout for each operation listed.\n required: true\n abatement:\n type: boolean\n description: Whether an abatement event message will be expected for the control loop from DCAE.\n required: true\n default: false\n trigger:\n type: string\n description: Initial operation to execute upon receiving an Onset event message for the Control Loop.\n required: true\n operations:\n type: list\n description: List of operations to be performed when Control Loop is triggered.\n required: true\n entry_schema:\n type: onap.datatype.controlloop.Operation\n\n onap.policies.controlloop.operational.common.Drools:\n derived_from: onap.policies.controlloop.operational.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Operational policies for Drools PDP\n properties:\n controllerName:\n type: string\n description: Drools controller properties\n required: false\n\ndata_types:\n onap.datatype.controlloop.Target:\n derived_from: tosca.datatypes.Root\n description: Definition for a entity in A&AI to perform a control loop operation on\n properties:\n targetType:\n type: string\n description: Category for the target type\n required: true\n constraints:\n - valid_values: [VNF, VM, VFMODULE, PNF]\n entityIds:\n type: map\n description: |\n Map of values that identify the resource. If none are provided, it is assumed that the\n entity that generated the ONSET event will be the target.\n required: false\n metadata:\n clamp_possible_values: ClampExecution:CSAR_RESOURCES\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Actor:\n derived_from: tosca.datatypes.Root\n description: An actor/operation/target definition\n properties:\n actor:\n type: string\n description: The actor performing the operation.\n required: true\n metadata:\n clamp_possible_values: Dictionary:DefaultActors,ClampExecution:CDS/actor\n operation:\n type: string\n description: The operation the actor is performing.\n metadata:\n clamp_possible_values: Dictionary:DefaultOperations,ClampExecution:CDS/operation\n required: true\n target:\n type: onap.datatype.controlloop.Target\n description: The resource the operation should be performed on.\n required: true\n payload:\n type: map\n description: Name/value pairs of payload information passed by Policy to the actor\n required: false\n metadata:\n clamp_possible_values: ClampExecution:CDS/payload\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Operation:\n derived_from: tosca.datatypes.Root\n description: An operation supported by an actor\n properties:\n id:\n type: string\n description: Unique identifier for the operation\n required: true\n description:\n type: string\n description: A user-friendly description of the intent for the operation\n required: false\n operation:\n type: onap.datatype.controlloop.Actor\n description: The definition of the operation to be performed.\n required: true\n timeout:\n type: integer\n description: The amount of time for the actor to perform the operation.\n required: true\n retries:\n type: integer\n description: The number of retries the actor should attempt to perform the operation.\n required: true\n default: 0\n success:\n type: string\n description: Points to the operation to invoke on success. A value of \"final_success\" indicates and end to the operation.\n required: false\n default: final_success\n failure:\n type: string\n description: Points to the operation to invoke on Actor operation failure.\n required: false\n default: final_failure\n failure_timeout:\n type: string\n description: Points to the operation to invoke when the time out for the operation occurs.\n required: false\n default: final_failure_timeout\n failure_retries:\n type: string\n description: Points to the operation to invoke when the current operation has exceeded its max retries.\n required: false\n default: final_failure_retries\n failure_exception:\n type: string\n description: Points to the operation to invoke when the current operation causes an exception.\n required: false\n default: final_failure_exception\n failure_guard:\n type: string\n description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.\n required: false\n default: final_failure_guard"
},
- {
- "name": "Create Policy Type",
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/yaml"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/yaml"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.operational.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant\n Policy Types. This does NOT support the legacy Policy YAML policy type.\n properties:\n id:\n type: string\n description: The unique control loop id.\n required: true\n timeout:\n type: integer\n description: |\n Overall timeout for executing all the operations. This timeout should equal or exceed the total\n timeout for each operation listed.\n required: true\n abatement:\n type: boolean\n description: Whether an abatement event message will be expected for the control loop from DCAE.\n required: true\n default: false\n trigger:\n type: string\n description: Initial operation to execute upon receiving an Onset event message for the Control Loop.\n required: true\n operations:\n type: list\n description: List of operations to be performed when Control Loop is triggered.\n required: true\n entry_schema:\n type: onap.datatype.controlloop.Operation\n\n onap.policies.controlloop.operational.common.Drools:\n derived_from: onap.policies.controlloop.operational.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Operational policies for Drools PDP\n properties:\n controllerName:\n type: string\n description: Drools controller properties\n required: false\n\ndata_types:\n onap.datatype.controlloop.Target:\n derived_from: tosca.datatypes.Root\n description: Definition for a entity in A&AI to perform a control loop operation on\n properties:\n targetType:\n type: string\n description: Category for the target type\n required: true\n constraints:\n - valid_values: [VNF, VM, VFMODULE, PNF]\n entityIds:\n type: map\n description: |\n Map of values that identify the resource. If none are provided, it is assumed that the\n entity that generated the ONSET event will be the target.\n required: false\n metadata:\n clamp_possible_values: ClampExecution:CSAR_RESOURCES\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Actor:\n derived_from: tosca.datatypes.Root\n description: An actor/operation/target definition\n properties:\n actor:\n type: string\n description: The actor performing the operation.\n required: true\n metadata:\n clamp_possible_values: Dictionary:DefaultActors,ClampExecution:CDS/actor\n operation:\n type: string\n description: The operation the actor is performing.\n metadata:\n clamp_possible_values: Dictionary:DefaultOperations,ClampExecution:CDS/operation\n required: true\n target:\n type: onap.datatype.controlloop.Target\n description: The resource the operation should be performed on.\n required: true\n payload:\n type: map\n description: Name/value pairs of payload information passed by Policy to the actor\n required: false\n metadata:\n clamp_possible_values: ClampExecution:CDS/payload\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Operation:\n derived_from: tosca.datatypes.Root\n description: An operation supported by an actor\n properties:\n id:\n type: string\n description: Unique identifier for the operation\n required: true\n description:\n type: string\n description: A user-friendly description of the intent for the operation\n required: false\n operation:\n type: onap.datatype.controlloop.Actor\n description: The definition of the operation to be performed.\n required: true\n timeout:\n type: integer\n description: The amount of time for the actor to perform the operation.\n required: true\n retries:\n type: integer\n description: The number of retries the actor should attempt to perform the operation.\n required: true\n default: 0\n success:\n type: string\n description: Points to the operation to invoke on success. A value of \"final_success\" indicates and end to the operation.\n required: false\n default: final_success\n failure:\n type: string\n description: Points to the operation to invoke on Actor operation failure.\n required: false\n default: final_failure\n failure_timeout:\n type: string\n description: Points to the operation to invoke when the time out for the operation occurs.\n required: false\n default: final_failure_timeout\n failure_retries:\n type: string\n description: Points to the operation to invoke when the current operation has exceeded its max retries.\n required: false\n default: final_failure_retries\n failure_exception:\n type: string\n description: Points to the operation to invoke when the current operation causes an exception.\n required: false\n default: final_failure_exception\n failure_guard:\n type: string\n description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.\n required: false\n default: final_failure_guard"
- },
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes"
- ]
- },
- "description": "This is a generic API to create one or more policy types together in a single API call."
- },
- "response": []
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes"
+ ]
},
- {
- "name": "Fetch Policy Type",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.operational.common.Drools",
- "versions",
- "1.0.0"
- ]
- },
- "description": "This is an API to fetch a specific policy type (example - \"onap.policies.controlloop.operational.common.Drools\") currently available in Policy DB."
- },
- "response": []
+ "description": "This is a generic API to create one or more policy types together in a single API call."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch Policy Type",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.operational.common.Drools",
+ "versions",
+ "1.0.0"
+ ]
},
- {
- "name": "Fetch All Policy Types",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes"
- ]
- },
- "description": "This is a generic API to fetch all policy types currently available in Policy DB."
- },
- "response": []
+ "description": "This is an API to fetch a specific policy type (example - \"onap.policies.controlloop.operational.common.Drools\") currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch All Policy Types",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes"
+ ]
},
- {
- "name": "Fetch All Versions of Policy Type",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.operational.common.Drools"
- ]
- },
- "description": "This is an API to fetch all versions of a specific policy type (example - \"onap.policies.controlloop.operational.common.Drools\") currently available in Policy DB."
- },
- "response": []
+ "description": "This is a generic API to fetch all policy types currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch All Versions of Policy Type",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.operational.common.Drools"
+ ]
},
- {
- "name": "Fetch Latest Version of Policy Type",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/latest",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.operational.common.Drools",
- "versions",
- "latest"
- ]
- },
- "description": "This is an API to fetch latest versions of a specific policy type (example - \"onap.policies.controlloop.operational.common.Drools\") currently available in Policy DB."
- },
- "response": []
+ "description": "This is an API to fetch all versions of a specific policy type (example - \"onap.policies.controlloop.operational.common.Drools\") currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch Latest Version of Policy Type",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/latest",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.operational.common.Drools",
+ "versions",
+ "latest"
+ ]
},
- {
- "name": "Delete Policy Type",
- "request": {
- "method": "DELETE",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.operational.common.Drools",
- "versions",
- "1.0.0"
- ]
- },
- "description": "This is an API to delete a specific policy type (example - \"onap.policies.controlloop.operational.common.Drools\") currently available in Policy DB."
- },
- "response": []
+ "description": "This is an API to fetch latest versions of a specific policy type (example - \"onap.policies.controlloop.operational.common.Drools\") currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Delete Policy Type",
+ "request": {
+ "method": "DELETE",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.operational.common.Drools",
+ "versions",
+ "1.0.0"
+ ]
},
- {
- "name": "Create Policy (Generic)",
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\",\n \"topology_template\": {\n \"policies\": [\n {\n \"operational.modifyconfig\": {\n \"type\": \"onap.policies.controlloop.operational.common.Drools\",\n \"type_version\": \"1.0.0\",\n \"version\": \"1.0.0\",\n \"metadata\": {\n \"policy-id\": \"operational.modifyconfig\"\n },\n \"properties\": {\n \"id\": \"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\n \"timeout\": 1200,\n \"abatement\": false,\n \"trigger\": \"unique-policy-id-1-modifyConfig\",\n \"operations\": [\n {\n \"id\": \"unique-policy-id-1-modifyConfig\",\n \"description\": \"Modify the packet generator\",\n \"operation\": {\n \"actor\": \"CDS\",\n \"operation\": \"modify-config\",\n \"target\": {\n \"targetType\": \"VNF\",\n \"entityIds\": {\n \"resourceID\": \"37b008b9-b367-4359-93fd-74d3ce0ee1a0\"\n }\n },\n \"payload\":{\n \"artifact_name\": \"vFW-CDS\",\n \"artifact_version\": \"1.0.0\",\n \"data\": \"{\\\"active-streams\\\": \\\"7\\\"}\"\n }\n },\n \"timeout\": 300,\n \"retries\": 0,\n \"success\": \"final_success\",\n \"failure\": \"final_failure\",\n \"failure_timeout\": \"final_failure_timeout\",\n \"failure_retries\": \"final_failure_retries\",\n \"failure_exception\": \"final_failure_exception\",\n \"failure_guard\": \"final_failure_guard\"\n }\n ],\n \"controllerName\": \"frankfurt\"\n }\n }\n }\n ]\n }\n}"
- },
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policies",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policies"
- ]
- },
- "description": "This is a generic API to create multiple policies together in a single API call. The individual policies can refer to same policy type or different policy types."
- },
- "response": []
+ "description": "This is an API to delete a specific policy type (example - \"onap.policies.controlloop.operational.common.Drools\") currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Create Policy (Generic)",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\",\n \"topology_template\": {\n \"policies\": [\n {\n \"operational.modifyconfig\": {\n \"type\": \"onap.policies.controlloop.operational.common.Drools\",\n \"type_version\": \"1.0.0\",\n \"version\": \"1.0.0\",\n \"metadata\": {\n \"policy-id\": \"operational.modifyconfig\"\n },\n \"properties\": {\n \"id\": \"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\n \"timeout\": 1200,\n \"abatement\": false,\n \"trigger\": \"unique-policy-id-1-modifyConfig\",\n \"operations\": [\n {\n \"id\": \"unique-policy-id-1-modifyConfig\",\n \"description\": \"Modify the packet generator\",\n \"operation\": {\n \"actor\": \"CDS\",\n \"operation\": \"modify-config\",\n \"target\": {\n \"targetType\": \"VNF\",\n \"entityIds\": {\n \"resourceID\": \"37b008b9-b367-4359-93fd-74d3ce0ee1a0\"\n }\n },\n \"payload\":{\n \"artifact_name\": \"vFW-CDS\",\n \"artifact_version\": \"1.0.0\",\n \"data\": \"{\\\"active-streams\\\": \\\"7\\\"}\"\n }\n },\n \"timeout\": 300,\n \"retries\": 0,\n \"success\": \"final_success\",\n \"failure\": \"final_failure\",\n \"failure_timeout\": \"final_failure_timeout\",\n \"failure_retries\": \"final_failure_retries\",\n \"failure_exception\": \"final_failure_exception\",\n \"failure_guard\": \"final_failure_guard\"\n }\n ],\n \"controllerName\": \"frankfurt\"\n }\n }\n }\n ]\n }\n}"
},
- {
- "name": "Create Policy (Specific)",
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\",\n \"topology_template\": {\n \"policies\": [\n {\n \"operational.modifyconfig\": {\n \"type\": \"onap.policies.controlloop.operational.common.Drools\",\n \"type_version\": \"1.0.0\",\n \"version\": \"1.0.0\",\n \"metadata\": {\n \"policy-id\": \"operational.modifyconfig\"\n },\n \"properties\": {\n \"id\": \"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\n \"timeout\": 1200,\n \"abatement\": false,\n \"trigger\": \"unique-policy-id-1-modifyConfig\",\n \"operations\": [\n {\n \"id\": \"unique-policy-id-1-modifyConfig\",\n \"description\": \"Modify the packet generator\",\n \"operation\": {\n \"actor\": \"CDS\",\n \"operation\": \"modify-config\",\n \"target\": {\n \"targetType\": \"VNF\",\n \"entityIds\": {\n \"resourceID\": \"37b008b9-b367-4359-93fd-74d3ce0ee1a0\"\n }\n },\n \"payload\":{\n \"artifact_name\": \"vFW-CDS\",\n \"artifact_version\": \"1.0.0\",\n \"data\": \"{\\\"active-streams\\\": \\\"7\\\"}\"\n }\n },\n \"timeout\": 300,\n \"retries\": 0,\n \"success\": \"final_success\",\n \"failure\": \"final_failure\",\n \"failure_timeout\": \"final_failure_timeout\",\n \"failure_retries\": \"final_failure_retries\",\n \"failure_exception\": \"final_failure_exception\",\n \"failure_guard\": \"final_failure_guard\"\n }\n ],\n \"controllerName\": \"frankfurt\"\n }\n }\n }\n ]\n }\n}"
- },
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.operational.common.Drools",
- "versions",
- "1.0.0",
- "policies"
- ]
- },
- "description": "This is a specific API to create a policy referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to create policy for any policy type to be deployed in any supported PDP engine."
- },
- "response": []
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policies",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policies"
+ ]
},
- {
- "name": "Create Policy (Legacy)",
- "request": {
- "method": "POST",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/yaml"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/yaml"
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{\n \"policy-id\" : \"operational.modifyconfiglegacy\",\n \"content\" : \"controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vFirewall-7e4fbe9c-d612-4ec5-bbf8-605aeabdb677%0A%20%20trigger_policy%3A%20unique-policy-id-1-modifyConfig%0A%20%20timeout%3A%2060%0A%20%20abatement%3A%20false%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-modifyConfig%0A%20%20%20%20name%3A%20modifyconfig-cds-actor%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20CDS%0A%20%20%20%20recipe%3A%20modify-config%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20resourceID%3A%2037b008b9-b367-4359-93fd-74d3ce0ee1a0%0A%20%20%20%20%20%20type%3A%20VNF%0A%20%20%20%20payload%3A%0A%20%20%20%20%20%20artifact_name%3A%20vFW-CDS%0A%20%20%20%20%20%20artifact_version%3A%201.0.0%0A%20%20%20%20%20%20data%3A%20%27%7B%22active-streams%22%3A%227%22%7D%27%0A%20%20%20%20retry%3A%200%0A%20%20%20%20timeout%3A%2030%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard\"\n}"
- },
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.Operational",
- "versions",
- "1.0.0",
- "policies"
- ]
- },
- "description": "This is a specific API to create a policy of type \"onap.policies.controlloop.Operational\", used to create legacy control loop operational policy aimed to be deployed in drools-pdp engine."
- },
- "response": []
+ "description": "This is a generic API to create multiple policies together in a single API call. The individual policies can refer to same policy type or different policy types."
+ },
+ "response": []
+ },
+ {
+ "name": "Create Policy (Specific)",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"tosca_definitions_version\": \"tosca_simple_yaml_1_1_0\",\n \"topology_template\": {\n \"policies\": [\n {\n \"operational.modifyconfig\": {\n \"type\": \"onap.policies.controlloop.operational.common.Drools\",\n \"type_version\": \"1.0.0\",\n \"version\": \"1.0.0\",\n \"metadata\": {\n \"policy-id\": \"operational.modifyconfig\"\n },\n \"properties\": {\n \"id\": \"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\n \"timeout\": 1200,\n \"abatement\": false,\n \"trigger\": \"unique-policy-id-1-modifyConfig\",\n \"operations\": [\n {\n \"id\": \"unique-policy-id-1-modifyConfig\",\n \"description\": \"Modify the packet generator\",\n \"operation\": {\n \"actor\": \"CDS\",\n \"operation\": \"modify-config\",\n \"target\": {\n \"targetType\": \"VNF\",\n \"entityIds\": {\n \"resourceID\": \"37b008b9-b367-4359-93fd-74d3ce0ee1a0\"\n }\n },\n \"payload\":{\n \"artifact_name\": \"vFW-CDS\",\n \"artifact_version\": \"1.0.0\",\n \"data\": \"{\\\"active-streams\\\": \\\"7\\\"}\"\n }\n },\n \"timeout\": 300,\n \"retries\": 0,\n \"success\": \"final_success\",\n \"failure\": \"final_failure\",\n \"failure_timeout\": \"final_failure_timeout\",\n \"failure_retries\": \"final_failure_retries\",\n \"failure_exception\": \"final_failure_exception\",\n \"failure_guard\": \"final_failure_guard\"\n }\n ],\n \"controllerName\": \"frankfurt\"\n }\n }\n }\n ]\n }\n}"
},
- {
- "name": "Fetch Policy (Specific)",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies/operational.modifyconfig/versions/1.0.0",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.operational.common.Drools",
- "versions",
- "1.0.0",
- "policies",
- "operational.modifyconfig",
- "versions",
- "1.0.0"
- ]
- },
- "description": "This is a specific API to fetch a policy (example - operational.modifyconfig) referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to fetch a policy referring to any policy type currently available in Policy DB."
- },
- "response": []
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.operational.common.Drools",
+ "versions",
+ "1.0.0",
+ "policies"
+ ]
},
- {
- "name": "Fetch Policy (Legacy)",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/operational.modifyconfiglegacy/versions/1",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.Operational",
- "versions",
- "1.0.0",
- "policies",
- "operational.modifyconfiglegacy",
- "versions",
- "1"
- ]
- },
- "description": "This is a specific API to fetch a policy (example - operational.modifyconfig) referring to the specific policy type \"onap.policies.controlloop.Operational\" currently available in Policy DB."
- },
- "response": []
+ "description": "This is a specific API to create a policy referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to create policy for any policy type to be deployed in any supported PDP engine."
+ },
+ "response": []
+ },
+ {
+ "name": "Create Policy (Legacy)",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/yaml"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/yaml"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"policy-id\" : \"operational.modifyconfiglegacy\",\n \"content\" : \"controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vFirewall-7e4fbe9c-d612-4ec5-bbf8-605aeabdb677%0A%20%20trigger_policy%3A%20unique-policy-id-1-modifyConfig%0A%20%20timeout%3A%2060%0A%20%20abatement%3A%20false%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-modifyConfig%0A%20%20%20%20name%3A%20modifyconfig-cds-actor%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20CDS%0A%20%20%20%20recipe%3A%20modify-config%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20resourceID%3A%2037b008b9-b367-4359-93fd-74d3ce0ee1a0%0A%20%20%20%20%20%20type%3A%20VNF%0A%20%20%20%20payload%3A%0A%20%20%20%20%20%20artifact_name%3A%20vFW-CDS%0A%20%20%20%20%20%20artifact_version%3A%201.0.0%0A%20%20%20%20%20%20data%3A%20%27%7B%22active-streams%22%3A%227%22%7D%27%0A%20%20%20%20retry%3A%200%0A%20%20%20%20timeout%3A%2030%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard\"\n}"
},
- {
- "name": "Fetch All Policies (Specific)",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.operational.common.Drools",
- "versions",
- "1.0.0",
- "policies"
- ]
- },
- "description": "This is a specific API to fetch all policies referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to fetch policies for any policy type currently available in Policy DB."
- },
- "response": []
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.Operational",
+ "versions",
+ "1.0.0",
+ "policies"
+ ]
},
- {
- "name": "Fetch All Version of a Policy (Specific)",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies/operational.modifyconfig",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.operational.common.Drools",
- "versions",
- "1.0.0",
- "policies",
- "operational.modifyconfig"
- ]
- },
- "description": "This is a specific API to fetch all versions of a policy (example - operational.modifyconfig) referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to fetch all versions of a policy referring to any policy type currently available in Policy DB."
- },
- "response": []
+ "description": "This is a specific API to create a policy of type \"onap.policies.controlloop.Operational\", used to create legacy control loop operational policy aimed to be deployed in drools-pdp engine."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch Policy (Specific)",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies/operational.modifyconfig/versions/1.0.0",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.operational.common.Drools",
+ "versions",
+ "1.0.0",
+ "policies",
+ "operational.modifyconfig",
+ "versions",
+ "1.0.0"
+ ]
},
- {
- "name": "Fetch Latest Version of a Policy (Specific)",
- "request": {
- "method": "GET",
- "header": [
- {
- "key": "Accept",
- "type": "text",
- "value": "application/json"
- },
- {
- "key": "Content-Type",
- "type": "text",
- "value": "application/json"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies/operational.modifyconfig/versions/latest",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.operational.common.Drools",
- "versions",
- "1.0.0",
- "policies",
- "operational.modifyconfig",
- "versions",
- "latest"
- ]
- },
- "description": "This is a specific API to fetch latest version of a policy (example - operational.modifyconfig) referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to fetch latest version of a policy referring to any policy type currently available in Policy DB."
- },
- "response": []
+ "description": "This is a specific API to fetch a policy (example - operational.modifyconfig) referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to fetch a policy referring to any policy type currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch All Policies without specifying policyType",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policies",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policies"
+ ]
},
- {
- "name": "Delete Policy (Specific)",
- "request": {
- "method": "DELETE",
- "header": [
- {
- "key": "Accept",
- "value": "application/json",
- "type": "text"
- },
- {
- "key": "Content-Type",
- "value": "application/json",
- "type": "text"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies/operational.modifyconfig/versions/1.0.0",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.operational.common.Drools",
- "versions",
- "1.0.0",
- "policies",
- "operational.modifyconfig",
- "versions",
- "1.0.0"
- ]
- },
- "description": "This is a specific API to delete a policy (example - operational.modifyconfig) referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to delete a policy referring to any policy type currently available in Policy DB."
- },
- "response": []
+ "description": "This is a specific API to fetch all policies currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch Policy without specifying policyType (Specific)",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policies/operational.modifyconfig/versions/1.0.0",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policies",
+ "operational.modifyconfig",
+ "versions",
+ "1.0.0"
+ ]
},
- {
- "name": "Delete Policy (Legacy)",
- "request": {
- "method": "DELETE",
- "header": [
- {
- "key": "Accept",
- "value": "application/json",
- "type": "text"
- },
- {
- "key": "Content-Type",
- "value": "application/json",
- "type": "text"
- }
- ],
- "url": {
- "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/operational.modifyconfiglegacy/versions/1",
- "host": [
- "{{POLICY-API-URL}}"
- ],
- "path": [
- "policy",
- "api",
- "v1",
- "policytypes",
- "onap.policies.controlloop.Operational",
- "versions",
- "1.0.0",
- "policies",
- "operational.modifyconfiglegacy",
- "versions",
- "1"
- ]
- },
- "description": "This is a specific API to delete a policy (example - operational.modifyconfiglegacy) referring to the specific policy type \"onap.policies.controlloop.Operational\" currently available in Policy DB."
- },
- "response": []
- }
- ],
- "auth": {
- "type": "basic",
- "basic": [
- {
- "key": "password",
- "value": "{{PASSWORD}}",
- "type": "string"
- },
- {
- "key": "username",
- "value": "{{USER}}",
- "type": "string"
- }
- ]
+ "description": "This is a specific API to fetch a policy (example - operational.modifyconfig). The same API can be used to fetch a policy without referring to any policy type currently available in Policy DB."
+ },
+ "response": []
},
- "event": [
- {
- "listen": "prerequest",
- "script": {
- "id": "c9224b64-293c-4a9c-bd05-ca4b1e1a9dba",
- "type": "text/javascript",
- "exec": [
- ""
- ]
- }
+ {
+ "name": "Fetch Policy (Legacy)",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/operational.modifyconfiglegacy/versions/1",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.Operational",
+ "versions",
+ "1.0.0",
+ "policies",
+ "operational.modifyconfiglegacy",
+ "versions",
+ "1"
+ ]
},
- {
- "listen": "test",
- "script": {
- "id": "efd8a8fe-3e04-4989-9f1c-8874190c49e4",
- "type": "text/javascript",
- "exec": [
- ""
- ]
- }
- }
- ],
- "variable": [
- {
- "id": "99d48afc-d62d-48be-9f89-d7db5acf48dd",
- "key": "USER",
- "value": "healthcheck",
- "type": "string"
+ "description": "This is a specific API to fetch a policy (example - operational.modifyconfig) referring to the specific policy type \"onap.policies.controlloop.Operational\" currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch All Policies (Specific)",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.operational.common.Drools",
+ "versions",
+ "1.0.0",
+ "policies"
+ ]
},
- {
- "id": "a9c660a8-2bd1-4e87-aacd-aa6ff2104a60",
- "key": "PASSWORD",
- "value": "zb!XztG34",
- "type": "string"
- }
- ],
- "protocolProfileBehavior": {}
+ "description": "This is a specific API to fetch all policies referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to fetch policies for any policy type currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch All Version of a Policy (Specific)",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies/operational.modifyconfig",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.operational.common.Drools",
+ "versions",
+ "1.0.0",
+ "policies",
+ "operational.modifyconfig"
+ ]
+ },
+ "description": "This is a specific API to fetch all versions of a policy (example - operational.modifyconfig) referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to fetch all versions of a policy referring to any policy type currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Fetch Latest Version of a Policy (Specific)",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies/operational.modifyconfig/versions/latest",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.operational.common.Drools",
+ "versions",
+ "1.0.0",
+ "policies",
+ "operational.modifyconfig",
+ "versions",
+ "latest"
+ ]
+ },
+ "description": "This is a specific API to fetch latest version of a policy (example - operational.modifyconfig) referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to fetch latest version of a policy referring to any policy type currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Delete Policy (Specific)",
+ "request": {
+ "method": "DELETE",
+ "header": [
+ {
+ "key": "Accept",
+ "value": "application/json",
+ "type": "text"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "type": "text"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.operational.common.Drools/versions/1.0.0/policies/operational.modifyconfig/versions/1.0.0",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.operational.common.Drools",
+ "versions",
+ "1.0.0",
+ "policies",
+ "operational.modifyconfig",
+ "versions",
+ "1.0.0"
+ ]
+ },
+ "description": "This is a specific API to delete a policy (example - operational.modifyconfig) referring to the given policy type (example - \"onap.policies.controlloop.operational.common.Drools\"). The same API can be used to delete a policy referring to any policy type currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Delete Policy without specifying policyType (Specific)",
+ "request": {
+ "method": "DELETE",
+ "header": [
+ {
+ "key": "Accept",
+ "type": "text",
+ "value": "application/json"
+ },
+ {
+ "key": "Content-Type",
+ "type": "text",
+ "value": "application/json"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policies/operational.modifyconfig/versions/1.0.0",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policies",
+ "operational.modifyconfig",
+ "versions",
+ "1.0.0"
+ ]
+ },
+ "description": "This is a specific API to delete a policy (example - operational.modifyconfig). The same API can be used to delete a policy without referring to any policy type currently available in Policy DB."
+ },
+ "response": []
+ },
+ {
+ "name": "Delete Policy (Legacy)",
+ "request": {
+ "method": "DELETE",
+ "header": [
+ {
+ "key": "Accept",
+ "value": "application/json",
+ "type": "text"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "type": "text"
+ }
+ ],
+ "url": {
+ "raw": "{{POLICY-API-URL}}/policy/api/v1/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/operational.modifyconfiglegacy/versions/1",
+ "host": [
+ "{{POLICY-API-URL}}"
+ ],
+ "path": [
+ "policy",
+ "api",
+ "v1",
+ "policytypes",
+ "onap.policies.controlloop.Operational",
+ "versions",
+ "1.0.0",
+ "policies",
+ "operational.modifyconfiglegacy",
+ "versions",
+ "1"
+ ]
+ },
+ "description": "This is a specific API to delete a policy (example - operational.modifyconfiglegacy) referring to the specific policy type \"onap.policies.controlloop.Operational\" currently available in Policy DB."
+ },
+ "response": []
+ }
+ ],
+ "auth": {
+ "type": "basic",
+ "basic": [
+ {
+ "key": "password",
+ "value": "{{PASSWORD}}",
+ "type": "string"
+ },
+ {
+ "key": "username",
+ "value": "{{USER}}",
+ "type": "string"
+ }
+ ]
+ },
+ "event": [
+ {
+ "listen": "prerequest",
+ "script": {
+ "id": "baf39e37-fd26-4171-82eb-f05352acc45e",
+ "type": "text/javascript",
+ "exec": [
+ ""
+ ]
+ }
+ },
+ {
+ "listen": "test",
+ "script": {
+ "id": "5ba39dc8-fe5c-48fb-a157-c7bb26641a75",
+ "type": "text/javascript",
+ "exec": [
+ ""
+ ]
+ }
+ }
+ ],
+ "variable": [
+ {
+ "id": "99d48afc-d62d-48be-9f89-d7db5acf48dd",
+ "key": "USER",
+ "value": "healthcheck",
+ "type": "string"
+ },
+ {
+ "id": "a9c660a8-2bd1-4e87-aacd-aa6ff2104a60",
+ "key": "PASSWORD",
+ "value": "zb!XztG34",
+ "type": "string"
+ }
+ ],
+ "protocolProfileBehavior": {}
} \ No newline at end of file