572017e2a8b203fffc38f842ade10dd3e7835e2e
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / vendor-license-rest / vendor-license-rest-services / src / main / java / org / openecomp / sdcrests / vendorlicense / rest / LicenseKeyGroupLimits.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.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.LimitEntityDto;
32 import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto;
33 import org.springframework.validation.annotation.Validated;
34
35 import javax.validation.Valid;
36 import javax.validation.constraints.NotNull;
37 import javax.ws.rs.*;
38 import javax.ws.rs.core.MediaType;
39 import javax.ws.rs.core.Response;
40
41 import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM;
42 import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG;
43
44 @Path(
45     "/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-key-groups/{licenseKeyGroupId}/limits")
46 @Produces(MediaType.APPLICATION_JSON)
47 @Consumes(MediaType.APPLICATION_JSON)
48 @OpenAPIDefinition(info = @Info(title = "Vendor License Model - License Key Group Limits"))
49 @Validated
50 public interface LicenseKeyGroupLimits {
51
52   @POST
53   @Path("/")
54   @Operation(description = "Create vendor license key group limit")
55   Response createLimit(@Valid LimitRequestDto request,
56                        @Parameter(description = "Vendor license model Id") @PathParam("vlmId")
57                            String vlmId,
58                        @Parameter(description = "Vendor license model version Id") @PathParam
59                            ("versionId")
60                            String versionId,
61                        @Parameter(description = "Vendor license model License Key Group Id")
62                        @PathParam("licenseKeyGroupId")
63                            String licenseKeyGroupId,
64                        @NotNull(message = USER_MISSING_ERROR_MSG)
65                        @HeaderParam(USER_ID_HEADER_PARAM) String user);
66
67   @GET
68   @Path("/")
69   @Operation(description = "List vendor license key group limits", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = LimitEntityDto.class)))))
70   Response listLimits(
71       @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId,
72       @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId,
73       @Parameter(description = "Vendor license model License Key Group Id") @PathParam("licenseKeyGroupId")
74           String licenseKeyGroupId,
75       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
76
77   @PUT
78   @Path("/{limitId}")
79   @Operation(description = "Update vendor license key group limit")
80   Response updateLimit(@Valid LimitRequestDto request,
81                        @Parameter(description = "Vendor license model Id") @PathParam("vlmId")
82                            String vlmId,
83                        @Parameter(description = "Vendor license model version Id") @PathParam
84                            ("versionId")
85                            String versionId,
86                        @Parameter(description = "Vendor license model License Key Group Id")
87                        @PathParam("licenseKeyGroupId")
88                            String licenseKeyGroupId,
89                        @NotNull(message = USER_MISSING_ERROR_MSG)
90                        @PathParam("limitId") String limitId,
91                        @HeaderParam(USER_ID_HEADER_PARAM) String user);
92
93   @GET
94   @Path("/{limitId}")
95   @Operation(description = "Get vendor entitlement pool limit", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LimitEntityDto.class))))
96   Response getLimit(
97       @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId,
98       @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId,
99       @Parameter(description = "Vendor license model License Key Group") @PathParam
100           ("licenseKeyGroupId") String entitlementPoolId,
101       @Parameter(description = "Vendor license model License Key Group Limit Id") @PathParam("limitId")
102           String limitId,
103       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
104
105   @DELETE
106   @Path("/{limitId}")
107   @Operation(description = "Delete vendor license key group limit")
108   Response deleteLimit(
109       @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId,
110       @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId,
111       @Parameter(description = "Vendor license model license key group Id") @PathParam("licenseKeyGroupId")
112           String licenseKeyGroupId,
113       @PathParam("limitId") String limitId,
114       @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user);
115 }