506058d2af54a59f46085be9866a9ef0c40e227b
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / vendor-license-rest / vendor-license-rest-services / src / main / java / org / openecomp / sdcrests / vendorlicense / rest / LicenseAgreements.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.vendorlicense.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.vendorlicense.types.LicenseAgreementEntityDto;
32 import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementModelDto;
33 import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementRequestDto;
34 import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementUpdateRequestDto;
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
47 @Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-agreements")
48 @Produces(MediaType.APPLICATION_JSON)
49 @Consumes(MediaType.APPLICATION_JSON)
50 @OpenAPIDefinition(info = @Info(title = "Vendor License Model - License Agreements"))
51 @Validated
52
53 public interface LicenseAgreements {
54
55   @GET
56   @Path("/")
57   @Operation(description = "List vendor license agreements", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation =LicenseAgreementEntityDto.class)))))
58   Response listLicenseAgreements(
59       @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId,
60       @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId,
61       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
62
63   @POST
64   @Path("/")
65   @Operation(description = "Create vendor license agreement")
66   Response createLicenseAgreement(@Valid LicenseAgreementRequestDto request,
67                                   @Parameter(description = "Vendor license model Id") @PathParam("vlmId")
68                                       String vlmId,
69                                   @Parameter(description = "Vendor license model version Id")
70                                   @PathParam("versionId") String versionId,
71                                   @NotNull(message = USER_MISSING_ERROR_MSG)
72                                   @HeaderParam(USER_ID_HEADER_PARAM) String user);
73
74   @PUT
75   @Path("/{licenseAgreementId}")
76   @Operation(description = "Update vendor license agreement")
77   Response updateLicenseAgreement(@Valid LicenseAgreementUpdateRequestDto request,
78                                   @Parameter(description = "Vendor license model Id") @PathParam("vlmId")
79                                       String vlmId,
80                                   @Parameter(description = "Vendor license model version Id")
81                                   @PathParam("versionId") String versionId,
82                                   @PathParam("licenseAgreementId") String licenseAgreementId,
83                                   @NotNull(message = USER_MISSING_ERROR_MSG)
84                                   @HeaderParam(USER_ID_HEADER_PARAM) String user);
85
86   @GET
87   @Path("/{licenseAgreementId}")
88   @Operation(description = "Get vendor license agreement", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LicenseAgreementModelDto.class))))
89   Response getLicenseAgreement(
90       @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId,
91       @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId,
92       @PathParam("licenseAgreementId") String licenseAgreementId,
93       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
94
95   @DELETE
96   @Path("/{licenseAgreementId}")
97   @Operation(description = "Delete vendor license agreement")
98   Response deleteLicenseAgreement(
99       @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId,
100       @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId,
101       @PathParam("licenseAgreementId") String licenseAgreementId,
102       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
103
104 }