1 package info.mikethomas.fahservices.service;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
44
45
46
47
48 @RestController("pause")
49 @Tag(name = "Pause", description = "Pause all or one slot(s).")
50 public class PauseResource {
51
52 @Autowired
53 private Connection connection;
54
55
56
57
58
59
60
61 @Operation(summary = "pause", description = "Pause all.", responses = {
62 @ApiResponse(responseCode = "200", description = "OK")
63 })
64 @RequestMapping(
65 value = "/pause",
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> getPause() {
74 connection.pause();
75 return new ResponseEntity<>(HttpStatus.OK);
76 }
77
78
79
80
81
82
83
84
85 @Operation(summary = "pause slot {slot}", description = "Pause the specified index.", responses = {
86 @ApiResponse(responseCode = "200", description = "OK")
87 })
88 @RequestMapping(
89 value = "/pause/{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> getPause(
98 @Parameter(description = "slot number", required = true)
99 @PathVariable("slot") final int slot) {
100 connection.pause(slot);
101 return new ResponseEntity<>(HttpStatus.OK);
102 }
103 }