Package org.powertac.visualizer.web.rest
Class GameResource
- java.lang.Object
-
- org.powertac.visualizer.web.rest.GameResource
-
@RestController @RequestMapping("/api") public class GameResource extends Object
REST controller for managing Game.
-
-
Constructor Summary
Constructors Constructor Description GameResource(GameService gameService, UserRepository userRepository)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.http.ResponseEntity<Game>
bootGame(@Valid Game game, @Valid @NotNull Boolean overwrite)
org.springframework.http.ResponseEntity<Void>
closeGame()
org.springframework.http.ResponseEntity<Game>
createGame(@Valid Game game)
POST /games : Create a new game.org.springframework.http.ResponseEntity<Void>
deleteGame(Long id)
DELETE /games/:id : delete the "id" game.org.springframework.http.ResponseEntity<List<Game>>
getAllGames(org.springframework.data.domain.Pageable pageable)
GET /games : get all the games.org.springframework.http.ResponseEntity<Game>
getGame(Long id)
GET /games/:id : get the "id" game.org.springframework.http.ResponseEntity<List<Game>>
getMyGames()
Get all games owned by logged in user, plus all shared files.org.springframework.http.ResponseEntity<Void>
replayGameExternal(@Valid String url)
org.springframework.http.ResponseEntity<Void>
replayGameInternal(@Valid File file)
org.springframework.http.ResponseEntity<Game>
simGame(@Valid Game game, @Valid @NotNull Boolean overwrite)
org.springframework.http.ResponseEntity<Game>
updateGame(@Valid Game game)
PUT /games : Updates an existing game.
-
-
-
Constructor Detail
-
GameResource
public GameResource(GameService gameService, UserRepository userRepository)
-
-
Method Detail
-
createGame
@PostMapping("/games") @Timed public org.springframework.http.ResponseEntity<Game> createGame(@Valid @RequestBody @Valid Game game) throws URISyntaxException
POST /games : Create a new game.- Parameters:
game
- the game to create- Returns:
- the ResponseEntity with status 201 (Created) and with body the new game, or with status 400 (Bad Request) if the game has already an ID
- Throws:
URISyntaxException
- if the Location URI syntax is incorrect
-
updateGame
@PutMapping("/games") @Timed public org.springframework.http.ResponseEntity<Game> updateGame(@Valid @RequestBody @Valid Game game) throws URISyntaxException
PUT /games : Updates an existing game.- Parameters:
game
- the game to update- Returns:
- the ResponseEntity with status 200 (OK) and with body the updated game, or with status 400 (Bad Request) if the game is not valid, or with status 500 (Internal Server Error) if the game couldnt be updated
- Throws:
URISyntaxException
- if the Location URI syntax is incorrect
-
getAllGames
@GetMapping("/games") @Timed public org.springframework.http.ResponseEntity<List<Game>> getAllGames(org.springframework.data.domain.Pageable pageable) throws URISyntaxException
GET /games : get all the games.- Parameters:
pageable
- the pagination information- Returns:
- the ResponseEntity with status 200 (OK) and the list of games in body
- Throws:
URISyntaxException
- if there is an error to generate the pagination HTTP headers
-
getGame
@GetMapping("/games/{id}") @Timed public org.springframework.http.ResponseEntity<Game> getGame(@PathVariable Long id)
GET /games/:id : get the "id" game.- Parameters:
id
- the id of the game to retrieve- Returns:
- the ResponseEntity with status 200 (OK) and with body the game, or with status 404 (Not Found)
-
deleteGame
@DeleteMapping("/games/{id}") @Timed public org.springframework.http.ResponseEntity<Void> deleteGame(@PathVariable Long id)
DELETE /games/:id : delete the "id" game.- Parameters:
id
- the id of the game to delete- Returns:
- the ResponseEntity with status 200 (OK)
-
getMyGames
@GetMapping("/mygames") @Timed public org.springframework.http.ResponseEntity<List<Game>> getMyGames() throws URISyntaxException
Get all games owned by logged in user, plus all shared files.- Throws:
URISyntaxException
-
bootGame
@PostMapping("/bootgame") @Timed public org.springframework.http.ResponseEntity<Game> bootGame(@Valid @RequestBody @Valid Game game, @RequestParam("overwrite") @Valid @NotNull @Valid @NotNull Boolean overwrite) throws URISyntaxException, org.apache.commons.io.FileExistsException
- Throws:
URISyntaxException
org.apache.commons.io.FileExistsException
-
simGame
@PostMapping("/simgame") @Timed public org.springframework.http.ResponseEntity<Game> simGame(@Valid @RequestBody @Valid Game game, @RequestParam("overwrite") @Valid @NotNull @Valid @NotNull Boolean overwrite) throws URISyntaxException
- Throws:
URISyntaxException
-
replayGameInternal
@PostMapping("/replaygame_internal") @Timed public org.springframework.http.ResponseEntity<Void> replayGameInternal(@Valid @RequestBody @Valid File file) throws URISyntaxException, IOException
- Throws:
URISyntaxException
IOException
-
replayGameExternal
@PostMapping("/replaygame_external") @Timed public org.springframework.http.ResponseEntity<Void> replayGameExternal(@Valid @RequestBody @Valid String url) throws URISyntaxException, MalformedURLException, IOException
-
closeGame
@PostMapping("/closegame") @Timed public org.springframework.http.ResponseEntity<Void> closeGame() throws IllegalStateException
- Throws:
IllegalStateException
-
-