push addional 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 static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM;
24 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
25
26 import io.swagger.annotations.Api;
27 import io.swagger.annotations.ApiOperation;
28 import io.swagger.annotations.ApiParam;
29 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
30 import org.openecomp.sdc.versioning.dao.types.Version;
31 import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto;
32 import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto;
33 import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto;
34 import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson;
35 import org.springframework.validation.annotation.Validated;
36
37 import javax.validation.Valid;
38 import javax.validation.constraints.NotNull;
39 import javax.validation.constraints.Pattern;
40 import javax.ws.rs.Consumes;
41 import javax.ws.rs.DELETE;
42 import javax.ws.rs.GET;
43 import javax.ws.rs.HeaderParam;
44 import javax.ws.rs.POST;
45 import javax.ws.rs.PUT;
46 import javax.ws.rs.Path;
47 import javax.ws.rs.PathParam;
48 import javax.ws.rs.Produces;
49 import javax.ws.rs.QueryParam;
50 import javax.ws.rs.core.MediaType;
51 import javax.ws.rs.core.Response;
52
53 @Path("/v1.0/vendor-software-products/{vspId}/components")
54 @Produces(MediaType.APPLICATION_JSON)
55 @Consumes(MediaType.APPLICATION_JSON)
56 @Api(value = "Vendor Software Product Components")
57 @Validated
58 public interface Components {
59   @GET
60   @Path("/")
61   @ApiOperation(value = "List vendor software product components",
62       response = ComponentDto.class,
63       responseContainer = "List")
64   Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
65                 @Pattern(regexp = Version.VERSION_REGEX,
66                     message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version")
67                     String version,
68                 @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
69                     String user);
70
71   @DELETE
72   @Path("/")
73   @ApiOperation(value = "Delete vendor software product components",
74       responseContainer = "List")
75   Response deleteList(
76       @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
77       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user);
78
79   @POST
80   @Path("/")
81   @ApiOperation(value = "Create a vendor software product component")
82   Response create(@Valid ComponentRequestDto request,
83                   @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
84                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
85                       String user);
86
87   @GET
88   @Path("/{componentId}")
89   @ApiOperation(value = "Get vendor software product component",
90       response = ComponentData.class,
91       responseContainer = "CompositionEntityResponse")
92   Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
93                @ApiParam(value = "Vendor software product component Id") @PathParam("componentId")
94                    String componentId,
95                @Pattern(regexp = Version.VERSION_REGEX,
96                    message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version")
97                    String version,
98                @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
99                    String user);
100
101   @DELETE
102   @Path("/{componentId}")
103   @ApiOperation(value = "Delete vendor software product component")
104   Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
105                   @ApiParam(value = "Vendor software product component Id")
106                   @PathParam("componentId") String componentId,
107                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
108                       String user);
109
110   @PUT
111   @Path("/{componentId}")
112   @ApiOperation(value = "Update vendor software product component")
113   Response update(@Valid ComponentRequestDto request,
114                   @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
115                   @ApiParam(value = "Vendor software product component Id")
116                   @PathParam("componentId") String componentId,
117                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM)
118                       String user);
119
120   @GET
121   @Path("/{componentId}/questionnaire")
122   @ApiOperation(value = "Get vendor software product component questionnaire",
123       response = QuestionnaireResponseDto.class)
124   Response getQuestionnaire(
125       @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId,
126       @ApiParam(value = "Vendor software product component Id") @PathParam("componentId")
127           String componentId,
128       @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG)
129       @QueryParam("version") String version,
130       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user);
131
132   @PUT
133   @Path("/{componentId}/questionnaire")
134   @ApiOperation(value = "Update vendor software product component questionnaire")
135   Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData,
136                                @ApiParam(value = "Vendor software product Id") @PathParam("vspId")
137                                    String vspId,
138                                @ApiParam(value = "Vendor software product component Id")
139                                @PathParam("componentId") String componentId,
140                                @NotNull(message = USER_MISSING_ERROR_MSG)
141                                @HeaderParam(USER_HEADER_PARAM) String user);
142 }