2  * ============LICENSE_START=======================================================
 
   3  *  Copyright (C) 2019 Nordix Foundation.
 
   4  * ================================================================================
 
   5  * Licensed under the Apache License, Version 2.0 (the "License");
 
   6  * you may not use this file except in compliance with the License.
 
   7  * You may obtain a copy of the License at
 
   9  *      http://www.apache.org/licenses/LICENSE-2.0
 
  11  * Unless required by applicable law or agreed to in writing, software
 
  12  * distributed under the License is distributed on an "AS IS" BASIS,
 
  13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  14  * See the License for the specific language governing permissions and
 
  15  * limitations under the License.
 
  17  * SPDX-License-Identifier: Apache-2.0
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.policy.distribution.forwarding.xacml.pdp.testclasses;
 
  23 import io.swagger.annotations.ApiParam;
 
  25 import javax.ws.rs.Consumes;
 
  26 import javax.ws.rs.POST;
 
  27 import javax.ws.rs.Path;
 
  28 import javax.ws.rs.PathParam;
 
  29 import javax.ws.rs.Produces;
 
  30 import javax.ws.rs.core.MediaType;
 
  31 import javax.ws.rs.core.Response;
 
  33 import org.onap.policy.models.pap.concepts.PdpDeployPolicies;
 
  34 import org.onap.policy.models.pap.concepts.PdpGroupDeployResponse;
 
  35 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 
  38  * Class to provide rest end points for LifecycycleApiSimulator.
 
  40  * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
 
  43 @Produces(MediaType.APPLICATION_JSON)
 
  44 public class LifecycycleApiSimulatorEndpoint {
 
  47      * Create policy type endpoint.
 
  49      * @param body the post body
 
  50      * @return the response object
 
  53     @Path("/api/v1/policytypes")
 
  54     @Consumes(MediaType.APPLICATION_JSON)
 
  55     @Produces(MediaType.APPLICATION_JSON)
 
  56     public Response createPolicyTypes(final ToscaServiceTemplate body) {
 
  57         return Response.status(Response.Status.OK).entity(body).build();
 
  61      * Create policy endpoint.
 
  63      * @param policyTypeId the policy type id
 
  64      * @param policyTypeVersion the policy type version
 
  65      * @param body the post body
 
  66      * @return the response object
 
  69     @Path("/api/v1/policytypes/{policyTypeId}/versions/{policyTypeVersion}/policies")
 
  70     @Consumes(MediaType.APPLICATION_JSON)
 
  71     @Produces(MediaType.APPLICATION_JSON)
 
  72     public Response createPolicies(@PathParam("policyTypeId") final String policyTypeId,
 
  73             @PathParam("policyTypeVersion") final String policyTypeVersion,
 
  74             @ApiParam(value = "Entity body of policy", required = true) final ToscaServiceTemplate body) {
 
  75         if ("onap.policies.controlloop.operational.ApexFailure".equals(policyTypeId)) {
 
  76             return Response.status(Response.Status.NOT_FOUND).build();
 
  78             return Response.status(Response.Status.OK).entity(body).build();
 
  83      * Deploy policy endpoint.
 
  85      * @param policies the post body
 
  86      * @return the response object
 
  89     @Path("/pap/v1/pdps/policies")
 
  90     @Consumes(MediaType.APPLICATION_JSON)
 
  91     @Produces(MediaType.APPLICATION_JSON)
 
  92     public Response deployPolicies(final PdpDeployPolicies policies) {
 
  93         return Response.status(Response.Status.OK).entity(new PdpGroupDeployResponse()).build();