SO-3720 BuildingBlockRollback lookup table
[so.git] / adapters / mso-catalog-db-adapter / src / main / java / org / onap / so / adapters / catalogdb / rest / BuildingBlockRollbackRestImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 Bell Canada
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.adapters.catalogdb.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.info.Info;
26 import io.swagger.v3.oas.annotations.media.ArraySchema;
27 import io.swagger.v3.oas.annotations.media.Content;
28 import io.swagger.v3.oas.annotations.media.Schema;
29 import io.swagger.v3.oas.annotations.responses.ApiResponse;
30 import java.util.List;
31 import javax.ws.rs.GET;
32 import javax.ws.rs.Path;
33 import javax.ws.rs.PathParam;
34 import javax.ws.rs.Produces;
35 import javax.ws.rs.core.MediaType;
36 import org.onap.so.db.catalog.beans.BuildingBlockRollback;
37 import org.onap.so.db.catalog.data.repository.BuildingBlockRollbackRepository;
38 import org.springframework.beans.factory.annotation.Autowired;
39 import org.springframework.stereotype.Component;
40 import org.springframework.transaction.annotation.Transactional;
41
42
43 @OpenAPIDefinition(info = @Info(title = "/v1", description = "model"))
44 @Path("/v1/buildingBlockRollback")
45 @Component
46 public class BuildingBlockRollbackRestImpl {
47
48     @Autowired
49     private BuildingBlockRollbackRepository bbRollbackRepo;
50
51     @GET
52     @Path("/{id}")
53     @Produces({MediaType.APPLICATION_JSON})
54     @Transactional(readOnly = true)
55     public BuildingBlockRollback findService(@PathParam("id") Integer id) {
56         return bbRollbackRepo.findOneById(id);
57     }
58
59     @GET
60     @Operation(description = "Look up BuildingBlock Rollback List", responses = @ApiResponse(
61             content = @Content(array = @ArraySchema(schema = @Schema(implementation = BuildingBlockRollback.class)))))
62     @Produces({MediaType.APPLICATION_JSON})
63     @Transactional(readOnly = true)
64     public List<BuildingBlockRollback> getBBRollbackList() {
65         return bbRollbackRepo.findAll();
66     }
67 }