866fa885ccfc985fcafb2fc0313596336a5798d0
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / item-permissions-rest / item-permissions-rest-services / src / main / java / org / openecomp / sdcrests / itempermissions / rest / ItemPermissions.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.itempermissions.rest;
22
23
24 import io.swagger.v3.oas.annotations.OpenAPIDefinition;
25 import io.swagger.v3.oas.annotations.Operation;
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.itempermissions.types.ItemPermissionsDto;
32 import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsRequestDto;
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 /**
45  * Created by ayalaben on 6/18/2017.
46  */
47 @Path("/v1.0/items/{itemId}/permissions")
48 @Produces(MediaType.APPLICATION_JSON)
49 @Consumes(MediaType.APPLICATION_JSON)
50 @OpenAPIDefinition(info = @Info(title = "Item Permissions"))
51 @Validated
52 public interface ItemPermissions {
53
54   @GET
55   @Path("/")
56   @Operation(description = "List users permissions assigned on item",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ItemPermissionsDto.class)))))
57   Response list(@PathParam("itemId") String itemId,
58                 @HeaderParam(USER_ID_HEADER_PARAM) String user);
59
60   @PUT
61   @Path("/{permission}")
62   @Operation(description = "Update useres permission on item")
63   Response updatePermissions(@Valid ItemPermissionsRequestDto request,
64                              @PathParam("itemId") String itemId,
65                              @PathParam("permission") String permission,
66                              @NotNull(message = USER_MISSING_ERROR_MSG)
67                              @HeaderParam(USER_ID_HEADER_PARAM) String user);
68
69 }