All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.atleon.spring.AtleonManagementController Maven / Gradle / Ivy

There is a newer version: 0.28.3
Show newest version
package io.atleon.spring;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;

@RestController
@RequestMapping(
    path = "/${atleon.management.rest.path:atleonManagement}",
    produces = MediaType.APPLICATION_JSON_VALUE
)
public class AtleonManagementController {

    private final AloStreamStatusService streamStatusService;

    AtleonManagementController(AloStreamStatusService streamStatusService) {
        this.streamStatusService = streamStatusService;
    }

    @Operation(summary = "Get statuses of all Streams")
    @GetMapping("streams")
    public ResponseEntity> getAllStreamStatuses() {
        return ResponseEntity.ok(streamStatusService.getAllStatuses());
    }

    @Operation(summary = "Get status of a single Stream")
    @ApiResponses({
        @ApiResponse(responseCode = "200", description = "Stream found"),
        @ApiResponse(responseCode = "404", description = "Stream not found")
    })
    @GetMapping("streams/{name}")
    public ResponseEntity getStreamStatus(@PathVariable("name") String name) {
        return ResponseEntity.of(streamStatusService.getStatus(name));
    }

    @Operation(summary = "Start a Stream")
    @ApiResponses({
        @ApiResponse(responseCode = "200", description = "Stream found and started"),
        @ApiResponse(responseCode = "404", description = "Stream not found")
    })
    @PutMapping("streams/{name}/start")
    public ResponseEntity startStream(@PathVariable("name") String name) {
        return ResponseEntity.of(streamStatusService.start(name));
    }

    @Operation(summary = "Stop a Stream")
    @ApiResponses({
        @ApiResponse(responseCode = "200", description = "Stream found and stopped"),
        @ApiResponse(responseCode = "404", description = "Stream not found")
    })
    @PutMapping("streams/{name}/stop")
    public ResponseEntity stopStream(@PathVariable("name") String name) {
        return ResponseEntity.of(streamStatusService.stop(name));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy