re base code
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / vendor-software-products-rest / vendor-software-products-rest-services / src / main / java / org / openecomp / sdcrests / vsp / rest / Components.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdcrests.vsp.rest;
22
23 import io.swagger.annotations.Api;
24 import io.swagger.annotations.ApiOperation;
25 import io.swagger.annotations.ApiParam;
26 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
27 import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto;
28 import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto;
29 import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto;
30 import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson;
31 import org.springframework.validation.annotation.Validated;
32
33 import javax.validation.Valid;
34 import javax.validation.constraints.NotNull;
35 import javax.ws.rs.*;
36 import javax.ws.rs.core.MediaType;
37 import javax.ws.rs.core.Response;
38
39 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
40 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
41
42 @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components")
43 @Produces(MediaType.APPLICATION_JSON)
44 @Consumes(MediaType.APPLICATION_JSON)
45 @Api(value = "Vendor Software Product Components")
46 @Validated
47 public interface Components extends VspEntities {
48   @GET
49   @Path("/")
50   @ApiOperation(value = "List vendor software product components",
51       response = ComponentDto.class,
52       responseContainer = "List")
53   Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
54                 @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
55                 @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
56                     String user);
57
58   @DELETE
59   @Path("/")
60   @ApiOperation(value = "Delete vendor software product components",
61       responseContainer = "List")
62   Response deleteList(
63       @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
64       @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
65       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
66
67   @POST
68   @Path("/")
69   @ApiOperation(value = "Create a vendor software product component")
70   Response create(@Valid ComponentRequestDto request,
71                   @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
72                   @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
73                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
74                       String user);
75
76   @GET
77   @Path("/{componentId}")
78   @ApiOperation(value = "Get vendor software product component",
79       response = ComponentData.class,
80       responseContainer = "CompositionEntityResponse")
81   Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
82                @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
83                @ApiParam(value = "Vendor software product component Id")
84                @PathParam("componentId") String componentId,
85                @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
86                    String user);
87
88   @DELETE
89   @Path("/{componentId}")
90   @ApiOperation(value = "Delete vendor software product component")
91   Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
92                   @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
93                   @ApiParam(value = "Vendor software product component Id")
94                   @PathParam("componentId") String componentId,
95                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
96                       String user);
97
98   @PUT
99   @Path("/{componentId}")
100   @ApiOperation(value = "Update vendor software product component")
101   Response update(@Valid ComponentRequestDto request,
102                   @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
103                   @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
104                   @ApiParam(value = "Vendor software product component Id")
105                   @PathParam("componentId") String componentId,
106                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
107                       String user);
108
109   @GET
110   @Path("/{componentId}/questionnaire")
111   @ApiOperation(value = "Get vendor software product component questionnaire",
112       response = QuestionnaireResponseDto.class)
113   Response getQuestionnaire(
114       @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
115       @ApiParam(value = "Version Id") @PathParam("versionId") String versionId,
116       @ApiParam(value = "Vendor software product component Id")
117       @PathParam("componentId") String componentId,
118       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
119
120   @PUT
121   @Path("/{componentId}/questionnaire")
122   @ApiOperation(value = "Update vendor software product component questionnaire")
123   Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData,
124                                @ApiParam(value = "Vendor software product Id") @PathParam("vspId")
125                                    String vspId,
126                                @ApiParam(value = "Version Id") @PathParam("versionId")
127                                    String versionId,
128                                @ApiParam(value = "Vendor software product component Id")
129                                @PathParam("componentId") String componentId,
130                                @NotNull(message = USER_MISSING_ERROR_MSG)
131                                @HeaderParam(USER_ID_HEADER_PARAM) String user);
132 }