bf72b872190c45d17b0379d862608668b8fcf7ab
[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 / Compute.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.ComputeDetailsDto;
32 import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDto;
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" +
47     "}/compute-flavors")
48 @Produces(MediaType.APPLICATION_JSON)
49 @Consumes(MediaType.APPLICATION_JSON)
50 @OpenAPIDefinition(info = @Info(title= "Vendor Software Product Component Compute-flavors"))
51 @Validated
52 public interface Compute extends VspEntities {
53
54   @GET
55   @Path("/")
56   @Operation(description = "Get list of vendor software product component compute-flavors", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation =ComputeDto.class)))))
57   Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
58                 @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
59                 @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
60                     String componentId,
61                 @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
62                     String user);
63
64   @GET
65   @Path("/{computeFlavorId}")
66   @Operation(description = "Get vendor software product component compute-flavor", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation =ComputeDetailsDto.class)))))
67   Response get(@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") @PathParam("componentId")
70                    String componentId,
71                @Parameter(description = "Vendor software product compute-flavor Id") @PathParam
72                    ("computeFlavorId")
73                    String computeId,
74                @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
75                    String user);
76
77   @POST
78   @Path("/")
79   @Operation(description = "Create a vendor software product component compute-flavor")
80   Response create(@Valid ComputeDetailsDto request,
81                   @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
82                   @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
83                   @Parameter(description = "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   @PUT
89   @Path("/{computeFlavorId}")
90   @Operation(description = "Update vendor software product component compute-flavor")
91   Response update(@Valid ComputeDetailsDto request,
92                   @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
93                   @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
94                   @Parameter(description = "Vendor software product component Id")
95                   @PathParam("componentId") String componentId,
96                   @Parameter(description = "Vendor software product compute-flavor Id") @PathParam
97                       ("computeFlavorId")
98                       String computeFlavorId,
99                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
100                       String user);
101
102   @PUT
103   @Path("/{computeFlavorId}/questionnaire")
104   @Operation(description = "Update vendor software product component compute-flavor questionnaire")
105   Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData,
106                   @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
107                   @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
108                   @Parameter(description = "Vendor software product component Id")
109                   @PathParam("componentId") String componentId,
110                   @Parameter(description = "Vendor software product compute-flavor Id") @PathParam
111                       ("computeFlavorId")
112                       String computeFlavorId,
113                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
114                       String user);
115
116   @DELETE
117   @Path("/{computeFlavorId}")
118   @Operation(description = "Delete vendor software product component compute-flavor")
119   Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
120                   @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
121                   @Parameter(description = "Vendor software product component Id")
122                   @PathParam("componentId") String componentId,
123                   @Parameter(description = "Vendor software product compute-flavor Id") @PathParam
124                       ("computeFlavorId")
125                       String computeFlavorId,
126                   @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM)
127                       String user);
128
129   @GET
130   @Path("/{computeFlavorId}/questionnaire")
131   @Operation(description = "Get vendor software product component compute-flavor questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =QuestionnaireResponseDto.class))))
132   Response getQuestionnaire(
133       @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId,
134       @Parameter(description = "Version Id") @PathParam("versionId") String versionId,
135       @Parameter(description = "Vendor software product component Id") @PathParam("componentId")
136           String componentId,
137       @Parameter(description = "Vendor software product compute-flavor Id") @PathParam
138           ("computeFlavorId") String computeId,
139       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
140 }