4f7e1843e176a83d62405246ad746c89967621d4
[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 / Images.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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.v3.oas.annotations.OpenAPIDefinition;
24 import io.swagger.v3.oas.annotations.Operation;
25 import io.swagger.v3.oas.annotations.Parameter;
26 import io.swagger.v3.oas.annotations.info.Info;
27 import io.swagger.v3.oas.annotations.media.ArraySchema;
28 import io.swagger.v3.oas.annotations.media.Content;
29 import io.swagger.v3.oas.annotations.media.Schema;
30 import io.swagger.v3.oas.annotations.responses.ApiResponse;
31 import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto;
32 import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageRequestDto;
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.ws.rs.*;
40 import javax.ws.rs.core.MediaType;
41 import javax.ws.rs.core.Response;
42
43 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
44 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
45
46 @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/images")
47 @Produces(MediaType.APPLICATION_JSON)
48 @Consumes(MediaType.APPLICATION_JSON)
49 @OpenAPIDefinition(info = @Info(title =  "Vendor Software Product Images"))
50 @Validated
51 public interface Images extends VspEntities {
52
53   @GET
54   @Path("/")
55   @Operation(description = "List vendor software product component images",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ImageDto.class)))))
56   Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
57                 @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
58                 @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
59                     String componentId,
60                 @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
61                     String user);
62
63   @POST
64   @Path("/")
65   @Operation(description = "Create a vendor software product component image")
66   Response create(@Valid ImageRequestDto request,
67                   @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
68                   @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
69                   @Parameter(description = "Vendor software product component Id")
70                   @PathParam("componentId") String componentId,
71                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
72                       String user);
73
74   @GET
75   @Path("/schema")
76   //@Operation(description = "Get schema for vendor software product component Image" ,
77   // response = QuestionnaireResponseDto.class)
78   Response getImageSchema(@Parameter(description = "Vendor software product Id") @PathParam("vspId")
79                               String vspId,
80                           @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
81                           @Parameter(description = "Vendor software product component Id")
82                           @PathParam("componentId") String componentId,@NotNull
83                               (message = USER_MISSING_ERROR_MSG) @HeaderParam
84                               (USER_ID_HEADER_PARAM) String user);
85
86   /*@GET
87   @Path("/{imageId}")
88   @Operation(description = "Get vendor software product component Image",
89       response = ImageDto.class,
90       responseContainer = "ImageEntityResponse")
91   Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
92                @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
93                    String componentId,
94                @Parameter(description = "Vendor software product image Id") @PathParam("imageId")
95                    String imageId,
96                @Pattern(regexp = Version.VERSION_REGEX,
97                    message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version")
98                    String version,
99                @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
100                    String user);*/
101
102   @GET
103   @Path("/{imageId}")
104   @Operation(description = "Get vendor software product component Image",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ImageDto.class))))
105   Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
106                @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
107                @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
108                    String componentId,
109                @Parameter(description = "Vendor software product Image Id") @PathParam
110                    ("imageId")
111                    String imageId,
112                @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
113                    String user);
114
115   @DELETE
116   @Path("/{imageId}")
117   @Operation(description = "Delete vendor software product Image")
118   Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
119                   @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
120                   @Parameter(description = "Vendor software product component Id")
121                   @PathParam("componentId") String componentId,
122                   @Parameter(description = "Vendor software product Image Id") @PathParam("imageId")
123                       String imageId,
124                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
125                       String user);
126
127   @PUT
128   @Path("/{imageId}")
129   @Operation(description = "Update vendor software product Image")
130   Response update(@Valid ImageRequestDto request,
131                   @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
132                   @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
133                   @Parameter(description = "Vendor software product component Id")
134                   @PathParam("componentId") String componentId,
135                   @Parameter(description = "Vendor software product Image Id") @PathParam("imageId")
136                       String imageId,
137                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
138                       String user);
139
140   @PUT
141   @Path("/{imageId}/questionnaire")
142   @Operation(description = "Update vendor software product component image questionnaire")
143   Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData,
144                                @Parameter(description = "Vendor software product Id")
145                                @PathParam("vspId") String vspId,
146                                @Parameter(description = "Version Id")
147                                @PathParam("versionId") String versionId,
148                                @Parameter(description = "Vendor software product component Id")
149                                @PathParam("componentId") String componentId,
150                                @Parameter(description = "Vendor software product image Id")
151                                @PathParam ("imageId") String imageId,
152                                @NotNull(message = USER_MISSING_ERROR_MSG)
153                                @HeaderParam(USER_ID_HEADER_PARAM) String user);
154
155   @GET
156   @Path("/{imageId}/questionnaire")
157   @Operation(description = "Get vendor software product component image questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class))))
158   Response getQuestionnaire(
159       @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
160       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
161       @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
162           String componentId,
163       @Parameter(description = "Vendor software product image Id") @PathParam
164           ("imageId") String imageId,
165       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
166 }