UpdateSwagger annotations and OpenAPI.yaml
[oom/platform/cert-service.git] / certService / src / main / java / org / onap / aaf / certservice / api / ReloadConfigController.java
1 /*
2  * ============LICENSE_START=======================================================
3  * PROJECT
4  * ================================================================================
5  * Copyright (C) 2020 Nokia. 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.onap.aaf.certservice.api;
22
23 import io.swagger.v3.oas.annotations.Operation;
24 import io.swagger.v3.oas.annotations.media.Content;
25 import io.swagger.v3.oas.annotations.media.Schema;
26 import io.swagger.v3.oas.annotations.responses.ApiResponse;
27 import io.swagger.v3.oas.annotations.responses.ApiResponses;
28 import io.swagger.v3.oas.annotations.tags.Tag;
29 import org.onap.aaf.certservice.certification.configuration.CmpServersConfig;
30 import org.onap.aaf.certservice.certification.configuration.CmpServersConfigLoadingException;
31 import org.onap.aaf.certservice.certification.exception.ErrorResponseModel;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.http.HttpStatus;
34 import org.springframework.http.ResponseEntity;
35 import org.springframework.web.bind.annotation.GetMapping;
36 import org.springframework.web.bind.annotation.RestController;
37
38 @RestController
39 @Tag(name = "CertificationService")
40 public final class ReloadConfigController {
41
42     private final CmpServersConfig cmpServersConfig;
43
44     @Autowired
45     public ReloadConfigController(CmpServersConfig cmpServersConfig) {
46         this.cmpServersConfig = cmpServersConfig;
47     }
48
49     @GetMapping(value = "/reload", produces = "application/json")
50     @ApiResponses(value = {
51             @ApiResponse(responseCode = "200", description = "Configuration has been successfully reloaded"),
52             @ApiResponse(responseCode = "500", description = "Something went wrong during configuration loading",
53                     content = @Content(schema = @Schema(implementation = ErrorResponseModel.class)))
54     })
55     @Operation(
56             summary = "Reload CMPv2 servers configuration from configuration file",
57             description = "Web endpoint for performing configuration reload. Used to reload configuration from file.",
58             tags = {"CertificationService"})
59     public ResponseEntity<String> reloadConfiguration() throws CmpServersConfigLoadingException {
60         cmpServersConfig.reloadConfiguration();
61         return new ResponseEntity<>(HttpStatus.OK);
62     }
63
64 }