summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2020-08-06 16:10:01 -0400
committerRam Krishna Verma <ram_krishna.verma@bell.ca>2020-08-06 16:10:08 -0400
commit3181973bf8ef4c2295dbff95b276f82157396515 (patch)
tree573fa4de7580dea4544a72675bed782f95472ed4
parente2d247088c6d675ebfa53689016053fc17918c81 (diff)
Remove legacy operational policy from api
Issue-ID: POLICY-2762 Change-Id: I8e4b3cb5968a691dd9ac3ad9a42ccd7d9fc7b963 Signed-off-by: Ram Krishna Verma <ram_krishna.verma@bell.ca>
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/LegacyApiRestController.java331
-rw-r--r--main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java3
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java201
-rw-r--r--postman/lifecycle-api-collection.json118
4 files changed, 1 insertions, 652 deletions
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/LegacyApiRestController.java b/main/src/main/java/org/onap/policy/api/main/rest/LegacyApiRestController.java
deleted file mode 100644
index ccbe3b47..00000000
--- a/main/src/main/java/org/onap/policy/api/main/rest/LegacyApiRestController.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP Policy API
- * ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.api.main.rest;
-
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import io.swagger.annotations.Authorization;
-import io.swagger.annotations.Extension;
-import io.swagger.annotations.ExtensionProperty;
-import io.swagger.annotations.ResponseHeader;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Response;
-import org.apache.commons.lang3.tuple.Pair;
-import org.onap.policy.api.main.rest.provider.LegacyOperationalPolicyProvider;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
-import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
-import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Class to provide legacy REST API services.
- *
- * @author Chenfei Gao (cgao@research.att.com)
- */
-@Path("/policy/api/v1")
-@Api(value = "Legacy Policy Design API")
-@Produces({"application/json", "application/yaml"})
-@Consumes({"application/json", "application/yaml"})
-public class LegacyApiRestController extends CommonRestController {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(LegacyApiRestController.class);
-
- /**
- * Retrieves the latest version of a particular operational policy.
- *
- * @param policyId the ID of specified operational policy
- *
- * @return the Response object containing the results of the API operation
- */
- @GET
- @Path("/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/{policyId}/versions/latest")
- @ApiOperation(value = "Retrieve the latest version of a particular operational policy",
- notes = "Returns the latest version of the specified operational policy",
- response = LegacyOperationalPolicy.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",
- 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",
- response = String.class),
- @ResponseHeader(name = "X-LatestVersion",
- description = "Used only to communicate an API's latest version", 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 = {"Legacy Operational 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")})
- public Response getLatestVersionOfOperationalPolicy(
- @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
-
- try (LegacyOperationalPolicyProvider operationalPolicyProvider = new LegacyOperationalPolicyProvider()) {
- LegacyOperationalPolicy policy = operationalPolicyProvider.fetchOperationalPolicy(policyId, null);
- return makeOkResponse(requestId, policy);
- } catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("GET /policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/{}"
- + "/versions/latest", policyId, pfme);
- return makeErrorResponse(requestId, pfme);
- }
- }
-
- /**
- * Retrieves the specified version of a particular operational policy.
- *
- * @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
- */
- @GET
- @Path("/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/"
- + "policies/{policyId}/versions/{policyVersion}")
- @ApiOperation(value = "Retrieve one version of a particular operational policy",
- notes = "Returns a particular version of a specified operational policy",
- response = LegacyOperationalPolicy.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",
- 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",
- response = String.class),
- @ResponseHeader(name = "X-LatestVersion",
- description = "Used only to communicate an API's latest version", 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 = {"Legacy Operational 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")})
- public Response getSpecificVersionOfOperationalPolicy(
- @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) {
-
- try (LegacyOperationalPolicyProvider operationalPolicyProvider = new LegacyOperationalPolicyProvider()) {
- LegacyOperationalPolicy policy = operationalPolicyProvider.fetchOperationalPolicy(policyId, policyVersion);
- return makeOkResponse(requestId, policy);
- } catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("GET /policytypes/onap.policies.controlloop.Operational/versions/1.0.0/"
- + "policies/{}/versions/{}", policyId, policyVersion, pfme);
- return makeErrorResponse(requestId, pfme);
- }
- }
-
- /**
- * Retrieves deployed versions of a particular operational policy in PDP groups.
- *
- * @param policyId the ID of specified policy
- *
- * @return the Response object containing the results of the API operation
- */
- @GET
- @Path("/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/"
- + "policies/{policyId}/versions/deployed")
- @ApiOperation(value = "Retrieve deployed versions of a particular operational policy in pdp groups",
- notes = "Returns deployed versions of a specified operational policy in pdp groups",
- response = LegacyOperationalPolicy.class, responseContainer = "List",
- 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",
- 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",
- response = String.class),
- @ResponseHeader(name = "X-LatestVersion",
- description = "Used only to communicate an API's latest version", 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 = {"Legacy Operational 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")})
- public Response getDeployedVersionsOfOperationalPolicy(
- @PathParam("policyId") @ApiParam(value = "ID of policy", required = true) String policyId,
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId) {
-
- try (LegacyOperationalPolicyProvider operationalPolicyProvider = new LegacyOperationalPolicyProvider()) {
- Map<Pair<String, String>, List<LegacyOperationalPolicy>> deployedOperationalPolicies =
- operationalPolicyProvider.fetchDeployedOperationalPolicies(policyId);
- return makeOkResponse(requestId, deployedOperationalPolicies);
- } catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("GET /policytypes/onap.policies.controlloop.Operational/versions/1.0.0/"
- + "policies/{}/versions/deployed", policyId, pfme);
- return makeErrorResponse(requestId, pfme);
- }
- }
-
- /**
- * Creates a new operational policy.
- *
- * @param body the body of policy
- *
- * @return the Response object containing the results of the API operation
- */
- @POST
- @Path("/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies")
- @ApiOperation(value = "Create a new operational policy",
- notes = "Client should provide entity body of the new operational policy",
- authorizations = @Authorization(value = "basicAuth"), tags = {"Legacy Operational Policy", },
- response = LegacyOperationalPolicy.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",
- 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",
- response = String.class),
- @ResponseHeader(name = "X-LatestVersion",
- description = "Used only to communicate an API's latest version",
- response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose",
- 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")
- })
- public Response createOperationalPolicy(
- @HeaderParam("X-ONAP-RequestID") @ApiParam("RequestID for http transaction") UUID requestId,
- @ApiParam(value = "Entity body of policy", required = true) LegacyOperationalPolicy body) {
-
- if (NetLoggerUtil.getNetworkLogger().isInfoEnabled()) {
- NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST,
- "/policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies", toJson(body));
- }
-
- try (LegacyOperationalPolicyProvider operationalPolicyProvider = new LegacyOperationalPolicyProvider()) {
- LegacyOperationalPolicy policy = operationalPolicyProvider.createOperationalPolicy(body);
- return makeOkResponse(requestId, policy);
- } catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("POST /policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies", pfme);
- return makeErrorResponse(requestId, pfme);
- }
- }
-
- /**
- * Deletes the specified version of a particular operational policy.
- *
- * @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/onap.policies.controlloop.Operational/versions/1.0.0/"
- + "policies/{policyId}/versions/{policyVersion}")
- @ApiOperation(value = "Delete a particular version of a specified operational policy",
- notes = "Rule: the version that has been deployed in PDP group(s) cannot be deleted",
- authorizations = @Authorization(value = "basicAuth"), tags = {"Legacy Operational Policy", },
- response = LegacyOperationalPolicy.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",
- 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",
- response = String.class),
- @ResponseHeader(name = "X-LatestVersion",
- description = "Used only to communicate an API's latest version", response = String.class),
- @ResponseHeader(name = "X-ONAP-RequestID",
- description = "Used to track REST transactions for logging purpose", 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 deleteSpecificVersionOfOperationalPolicy(
- @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) {
-
- try (LegacyOperationalPolicyProvider operationalPolicyProvider = new LegacyOperationalPolicyProvider()) {
- LegacyOperationalPolicy policy = operationalPolicyProvider.deleteOperationalPolicy(policyId, policyVersion);
- return makeOkResponse(requestId, policy);
- } catch (PfModelException | PfModelRuntimeException pfme) {
- LOGGER.debug("DELETE /policytypes/onap.policies.controlloop.Operational/versions/1.0.0/"
- + "policies/{}/versions/{}", policyId, policyVersion, pfme);
- return makeErrorResponse(requestId, pfme);
- }
- }
-} \ No newline at end of file
diff --git a/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java b/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java
index d50ff40b..e52bc9a2 100644
--- a/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java
+++ b/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java
@@ -26,7 +26,6 @@ package org.onap.policy.api.main.startstop;
import org.onap.policy.api.main.exception.PolicyApiException;
import org.onap.policy.api.main.parameters.ApiParameterGroup;
import org.onap.policy.api.main.rest.ApiRestController;
-import org.onap.policy.api.main.rest.LegacyApiRestController;
import org.onap.policy.api.main.rest.aaf.AafApiFilter;
import org.onap.policy.common.endpoints.http.server.RestServer;
import org.onap.policy.common.parameters.ParameterService;
@@ -77,7 +76,7 @@ public class ApiActivator {
private void startApiRestServer() throws PolicyApiException {
apiParameterGroup.getRestServerParameters().setName(apiParameterGroup.getName());
restServer = new RestServer(apiParameterGroup.getRestServerParameters(), AafApiFilter.class,
- LegacyApiRestController.class, ApiRestController.class);
+ ApiRestController.class);
if (!restServer.start()) {
throw new PolicyApiException("Failed to start api rest server. Check log for more details...");
}
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 01892be1..351f2eb2 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
@@ -72,7 +72,6 @@ import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.errors.concepts.ErrorResponse;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
/**
* Class to perform unit test of {@link ApiRestController}.
@@ -91,8 +90,6 @@ public class TestApiRestServer {
private static final String STATISTICS_ENDPOINT = "statistics";
private static final String OP_POLICY_NAME_VCPE = "operational.restart";
- private static final String OP_POLICY_NAME_VDNS = "operational.scaleout";
- private static final String OP_POLICY_NAME_VFW = "operational.modifyconfig";
private static final String POLICYTYPES = "policytypes";
private static final String POLICYTYPES_TCA = "policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app";
@@ -125,32 +122,6 @@ public class TestApiRestServer {
private static final String POLICYTYPES_DROOLS_POLICIES_VCPE_VERSION =
POLICYTYPES_DROOLS_VERSION + "/policies/" + OP_POLICY_NAME_VCPE + "/versions/1.0.0";
- private static final String OPS_POLICIES =
- "policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies";
- private static final String OPS_POLICIES_VCPE_LATEST =
- "policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/" + OP_POLICY_NAME_VCPE
- + "/versions/latest";
- private static final String OPS_POLICIES_VCPE_DEPLOYED =
- "policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/" + OP_POLICY_NAME_VCPE
- + "/versions/deployed";
- private static final String OPS_POLICIES_VDNS_LATEST =
- "policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/" + OP_POLICY_NAME_VDNS
- + "/versions/latest";
- private static final String OPS_POLICIES_VFIREWALL_LATEST =
- "policytypes/onap.policies.controlloop.Operational/versions/1.0.0/policies/" + OP_POLICY_NAME_VFW
- + "/versions/latest";
- private static final String OPS_POLICIES_VCPE_VERSION =
- "policytypes/" + "onap.policies.controlloop.Operational/versions/1.0.0/policies/" + OP_POLICY_NAME_VCPE
- + "/versions/1";
- private static final String OPS_POLICIES_VDNS_VERSION =
- "policytypes/" + "onap.policies.controlloop.Operational/versions/1.0.0/policies/" + OP_POLICY_NAME_VDNS
- + "/versions/1";
- private static final String OPS_POLICIES_VFIREWALL_VERSION =
- "policytypes/" + "onap.policies.controlloop.Operational/versions/1.0.0/policies/" + OP_POLICY_NAME_VFW
- + "/versions/1";
- private static final String OPS_POLICIES_VCPE_VERSION_NOEX =
- "policytypes/" + "onap.policies.controlloop.Operational/versions/1.0.0/policies/" + OP_POLICY_NAME_VCPE
- + "/versions/99";
private static final String POLICIES = "policies";
private static final String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
@@ -166,13 +137,9 @@ public class TestApiRestServer {
private static final String TOSCA_POLICYTYPE_OP_RESOURCE =
"policytypes/onap.policies.controlloop.operational.Common.yaml";
- private static final String LEGACY_POLICYTYPE_OP_RESOURCE =
- "policytypes/onap.policies.controlloop.Operational.yaml";
-
private static final String[] TOSCA_POLICYTYPE_RESOURCE_NAMES = {
"policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml",
"policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml",
- "policytypes/onap.policies.Optimization.yaml", LEGACY_POLICYTYPE_OP_RESOURCE, TOSCA_POLICYTYPE_OP_RESOURCE,
"policytypes/onap.policies.controlloop.operational.common.Drools.yaml",
"policytypes/onap.policies.controlloop.guard.Common.yaml",
"policytypes/onap.policies.controlloop.guard.common.Blacklist.yaml",
@@ -195,10 +162,6 @@ public class TestApiRestServer {
private static final String TOSCA_POLICY_OP_DROOLS_VCPE_RESOURSE_YAML =
"policies/vCPE.policy.operational.input.tosca.yaml";
- private static final String[] LEGACY_OPERATIONAL_POLICY_RESOURCE_NAMES = {
- "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;
@@ -349,25 +312,6 @@ public class TestApiRestServer {
.contains("policy type IDontExist:1.0.0 referenced in policy not found");
}
- @Test
- public void testCreateOperationalPolicies() throws Exception {
- for (String resrcName : LEGACY_OPERATIONAL_POLICY_RESOURCE_NAMES) {
- Response rawResponse = createOperationalPolicy(OPS_POLICIES, resrcName);
- ErrorResponse errorResponse = rawResponse.readEntity(ErrorResponse.class);
- assertEquals(null, errorResponse.getErrorDetails());
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
- }
-
- Response rawResponse = deleteResource(OPS_POLICIES + "/operational.restart/versions/1", APP_JSON);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
-
- rawResponse = deleteResource(OPS_POLICIES + "/operational.scaleout/versions/1", APP_JSON);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
-
- rawResponse = deleteResource(OPS_POLICIES + "/operational.modifyconfig/versions/1", APP_JSON);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
- }
-
@SuppressWarnings("unchecked")
@Test
public void testToscaCompliantOpDroolsPolicies() throws Exception {
@@ -718,130 +662,6 @@ public class TestApiRestServer {
}
@Test
- public void testReadOperationalPoliciesJson() throws Exception {
- testReadOperationalPolicies(APP_JSON);
- }
-
- @Test
- public void testReadOperationalPoliciesYaml() throws Exception {
- testReadOperationalPolicies(APP_YAML);
- }
-
- private void testReadOperationalPolicies(String mediaType) throws Exception {
- for (String resrcName : LEGACY_OPERATIONAL_POLICY_RESOURCE_NAMES) {
- Response rawResponse = createOperationalPolicy(OPS_POLICIES, resrcName);
- ErrorResponse error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals(null, error.getErrorDetails());
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
- }
-
- Response rawResponse = readResource(OPS_POLICIES_VCPE_LATEST, mediaType);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
-
- rawResponse = readResource(OPS_POLICIES_VCPE_VERSION, mediaType);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
-
- rawResponse = readResource(OPS_POLICIES_VDNS_LATEST, mediaType);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
-
- rawResponse = readResource(OPS_POLICIES_VDNS_VERSION, mediaType);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
-
- rawResponse = readResource(OPS_POLICIES_VFIREWALL_LATEST, mediaType);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
-
- rawResponse = readResource(OPS_POLICIES_VFIREWALL_VERSION, mediaType);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
-
- rawResponse = deleteResource(OPS_POLICIES + "/operational.restart/versions/1", APP_JSON);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
-
- rawResponse = deleteResource(OPS_POLICIES + "/operational.scaleout/versions/1", APP_JSON);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
-
- rawResponse = deleteResource(OPS_POLICIES + "/operational.modifyconfig/versions/1", APP_JSON);
- assertEquals(Response.Status.OK.getStatusCode(), rawResponse.getStatus());
-
- }
-
- @Test
- public void testDeleteOperationalPolicyJson() throws Exception {
- testDeleteOperationalPolicy(APP_JSON);
- }
-
- @Test
- public void testDeleteOperationalPolicyYaml() throws Exception {
- testDeleteOperationalPolicy(APP_YAML);
- }
-
- private void testDeleteOperationalPolicy(String mediaType) throws Exception {
- Response rawResponse = deleteResource(OPS_POLICIES_VCPE_VERSION_NOEX, mediaType);
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawResponse.getStatus());
- ErrorResponse error = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("policy operational.restart:99.0.0 not found", error.getErrorMessage());
- }
-
- @Test
- public void testGetLatestVersionOfOperationalPolicyJson() throws Exception {
- testGetLatestVersionOfOperationalPolicy(APP_JSON);
- }
-
- @Test
- public void testGetLatestVersionOfOperationalPolicyYaml() throws Exception {
- testGetLatestVersionOfOperationalPolicy(APP_YAML);
- }
-
- private void testGetLatestVersionOfOperationalPolicy(String mediaType) throws Exception {
- Response rawResponse = readResource(OPS_POLICIES_VDNS_LATEST, mediaType);
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawResponse.getStatus());
- ErrorResponse errorResponse = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("policies for operational.scaleout:null do not exist", errorResponse.getErrorMessage());
- }
-
- @Test
- public void testGetSpecificVersionOfOperationalPolicyJson() throws Exception {
- testGetSpecificVersionOfOperationalPolicy(APP_JSON);
- }
-
- @Test
- public void testGetSpecificVersionOfOperationalPolicyYaml() throws Exception {
- testGetSpecificVersionOfOperationalPolicy(APP_YAML);
- }
-
- private void testGetSpecificVersionOfOperationalPolicy(String mediaType) throws Exception {
- Response rawResponse = readResource(OPS_POLICIES_VDNS_VERSION, mediaType);
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawResponse.getStatus());
- ErrorResponse errorResponse = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("policies for operational.scaleout:1.0.0 do not exist", errorResponse.getErrorMessage());
- }
-
- @Test
- public void testGetDeployedVersionsOfOperationalPolicyJson() throws Exception {
- testGetDeployedVersionsOfOperationalPolicy(APP_JSON);
- }
-
- @Test
- public void testGetDeployedVersionsOfOperationalPolicyYaml() throws Exception {
- testGetDeployedVersionsOfOperationalPolicy(APP_YAML);
- }
-
- private void testGetDeployedVersionsOfOperationalPolicy(String mediaType) throws Exception {
- Response rawResponse = readResource(OPS_POLICIES_VCPE_DEPLOYED, mediaType);
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawResponse.getStatus());
- ErrorResponse errorResponse = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("could not find policy with ID " + OP_POLICY_NAME_VCPE + " and type "
- + "onap.policies.controlloop.Operational:1.0.0 deployed in any pdp group", errorResponse.getErrorMessage());
- }
-
- @Test
- public void testDeleteSpecificVersionOfOperationalPolicy() throws Exception {
- Response rawResponse = deleteResource(OPS_POLICIES_VDNS_VERSION, APP_YAML);
- assertEquals(Response.Status.NOT_FOUND.getStatusCode(), rawResponse.getStatus());
- ErrorResponse errorResponse = rawResponse.readEntity(ErrorResponse.class);
- assertEquals("policy operational.scaleout:1.0.0 not found", errorResponse.getErrorMessage());
- }
-
- @Test
public void testGetPoliciesJson() throws Exception {
getPolicies(APP_JSON);
}
@@ -949,27 +769,6 @@ public class TestApiRestServer {
return invocationBuilder.post(entity);
}
- private Response createOperationalPolicy(String endpoint, String resourceName) throws Exception {
-
- String mediaType = APP_JSON; // default media type
- LegacyOperationalPolicy rawOpsPolicy = new LegacyOperationalPolicy();
- if (resourceName.endsWith(".json")) {
- rawOpsPolicy = standardCoder
- .decode(ResourceUtils.getResourceAsString(resourceName), LegacyOperationalPolicy.class);
- } else if (resourceName.endsWith(".yaml") || resourceName.endsWith(".yml")) {
- mediaType = APP_YAML;
- rawOpsPolicy = standardYamlCoder
- .decode(ResourceUtils.getResourceAsString(resourceName), LegacyOperationalPolicy.class);
- }
-
- final Invocation.Builder invocationBuilder;
-
- invocationBuilder = sendHttpsRequest(endpoint, mediaType);
-
- Entity<LegacyOperationalPolicy> entity = Entity.entity(rawOpsPolicy, mediaType);
- return invocationBuilder.post(entity);
- }
-
private Response readResource(String endpoint, String mediaType) throws Exception {
final Invocation.Builder invocationBuilder;
diff --git a/postman/lifecycle-api-collection.json b/postman/lifecycle-api-collection.json
index d2772227..5643d4da 100644
--- a/postman/lifecycle-api-collection.json
+++ b/postman/lifecycle-api-collection.json
@@ -353,46 +353,6 @@
"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}"
- },
- "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": []
- },
- {
"name": "Fetch Policy (Specific)",
"request": {
"method": "GET",
@@ -467,45 +427,6 @@
"response": []
},
{
- "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": []
- },
- {
"name": "Fetch All Policies (Specific)",
"request": {
"method": "GET",
@@ -722,45 +643,6 @@
"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": {