View Javadoc
1   package info.mikethomas.fahservices.service;
2   
3   /*
4    * #%L
5    * This file is part of FAHServices.
6    * %%
7    * Copyright (C) 2014 - 2024 Mike Thomas <mikepthomas@outlook.com>
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU General Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/gpl-3.0.html>.
22   * #L%
23   */
24  
25  import info.mikethomas.jfold.Connection;
26  
27  import io.swagger.v3.oas.annotations.Operation;
28  import io.swagger.v3.oas.annotations.Parameter;
29  import io.swagger.v3.oas.annotations.responses.ApiResponse;
30  import io.swagger.v3.oas.annotations.tags.Tag;
31  
32  import org.springframework.beans.factory.annotation.Autowired;
33  import org.springframework.http.HttpStatus;
34  import org.springframework.http.MediaType;
35  import org.springframework.http.ResponseEntity;
36  import org.springframework.web.bind.annotation.PathVariable;
37  import org.springframework.web.bind.annotation.RequestMapping;
38  import org.springframework.web.bind.annotation.RequestMethod;
39  import org.springframework.web.bind.annotation.ResponseBody;
40  import org.springframework.web.bind.annotation.RestController;
41  
42  /**
43   * REST Web Service.
44   *
45   * @author Michael Thomas (mikepthomas@outlook.com)
46   * @version $Id: $Id
47   */
48  @RestController("unpause")
49  @Tag(name = "Unpause", description = "Unpause all or one slot(s).")
50  public class UnpauseResource {
51  
52      @Autowired
53      private Connection connection;
54  
55      /**
56       * Retrieves representation of an instance of
57       * info.mikethomas.fahservices.service.UnpauseResource.
58       *
59       * @return an instance of java.lang.String
60       */
61      @Operation(summary = "unpause", description = "Unpause all.", responses = {
62              @ApiResponse(responseCode = "200", description = "OK")
63      })
64      @RequestMapping(
65              value = "/unpause",
66              method = RequestMethod.GET,
67              produces = {
68                  MediaType.APPLICATION_JSON_VALUE,
69                  MediaType.APPLICATION_XML_VALUE,
70                  MediaType.TEXT_XML_VALUE
71              })
72      @ResponseBody
73      public ResponseEntity<String> getUnpause() {
74          connection.unpause();
75          return new ResponseEntity<>(HttpStatus.OK);
76      }
77  
78      /**
79       * Retrieves representation of an instance of
80       * info.mikethomas.fahservices.service.UnpauseResource.
81       *
82       * @param slot Slot number
83       * @return an instance of java.lang.String
84       */
85      @Operation(summary = "unpause {slot}", description = "Unpause the specified index.", responses = {
86              @ApiResponse(responseCode = "200", description = "OK")
87      })
88      @RequestMapping(
89              value = "/unpause/{slot}",
90              method = RequestMethod.GET,
91              produces = {
92                  MediaType.APPLICATION_JSON_VALUE,
93                  MediaType.APPLICATION_XML_VALUE,
94                  MediaType.TEXT_XML_VALUE
95              })
96      @ResponseBody
97      public ResponseEntity<String> getUnpause(
98              @Parameter(description = "slot number", required = true)
99              @PathVariable("slot") final int slot) {
100         connection.unpause(slot);
101         return new ResponseEntity<>(HttpStatus.OK);
102     }
103 }