use of org.springframework.http.ResponseEntity in project open-kilda by telstra.
the class FlowController method deleteFlows.
/**
* Delete all flows.
*
* @param correlationId correlation ID header value
* @return list of flows that have been deleted
*/
@ApiOperation(value = "Delete all flows. Requires special authorization", response = FlowPayload.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = FlowPayload.class, message = "Operation is successful"), @ApiResponse(code = 400, response = MessageError.class, message = "Invalid input data"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 500, response = MessageError.class, message = "General error"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable") })
@RequestMapping(value = "/flows", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@ExtraAuthRequired
// the error is unchecked
@SuppressWarnings("unchecked")
public ResponseEntity<List<FlowPayload>> deleteFlows(@RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
logger.debug("Delete flows: {}={}", CORRELATION_ID);
List<FlowPayload> response = flowService.deleteFlows(correlationId);
return new ResponseEntity<>(response, new HttpHeaders(), HttpStatus.OK);
}
use of org.springframework.http.ResponseEntity in project open-kilda by telstra.
the class FlowController method getFlows.
/**
* Dumps all flows. Dumps all flows with specific status if specified.
*
* @param correlationId correlation ID header value
* @return list of flow
*/
@ApiOperation(value = "Dumps all flows", response = FlowPayload.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = FlowPayload.class, message = "Operation is successful"), @ApiResponse(code = 400, response = MessageError.class, message = "Invalid input data"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 500, response = MessageError.class, message = "General error"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable") })
@RequestMapping(value = "/flows", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<List<FlowPayload>> getFlows(@RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
logger.debug("Get flows: {}={}", CORRELATION_ID, correlationId);
List<FlowPayload> response = flowService.getFlows(correlationId);
return new ResponseEntity<>(response, new HttpHeaders(), HttpStatus.OK);
}
use of org.springframework.http.ResponseEntity in project open-kilda by telstra.
the class FlowController method statusFlow.
/**
* Gets flow status.
*
* @param flowId flow id
* @param correlationId correlation ID header value
* @return list of flow
*/
@ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = FlowIdStatusPayload.class, message = "Operation is successful"), @ApiResponse(code = 400, response = MessageError.class, message = "Invalid input data"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 500, response = MessageError.class, message = "General error"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable") })
@RequestMapping(value = "/flows/status/{flow-id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId, @RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
logger.debug("Flow status: {}={}", CORRELATION_ID, correlationId);
FlowIdStatusPayload response = flowService.statusFlow(flowId, correlationId);
return new ResponseEntity<>(response, new HttpHeaders(), HttpStatus.OK);
}
use of org.springframework.http.ResponseEntity in project open-kilda by telstra.
the class HealthCheckController method getHealthCheck.
/**
* Gets the health-check status.
*
* @param correlationId request correlation id
* @return health-check model entity
*/
@ApiOperation(value = "Gets health-check status", response = HealthCheck.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = HealthCheck.class, message = "Operation is successful"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable") })
@RequestMapping(value = "/health-check", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<HealthCheck> getHealthCheck(@RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
logger.debug("getHealthCheck");
HealthCheck healthCheck = healthCheckService.getHealthCheck(correlationId);
HttpStatus status = healthCheck.hasNonOperational() ? HttpStatus.GATEWAY_TIMEOUT : HttpStatus.OK;
return new ResponseEntity<>(healthCheck, new HttpHeaders(), status);
}
use of org.springframework.http.ResponseEntity in project entando-core by entando.
the class CategoryController method getCategories.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<RestResponse> getCategories(@RequestParam(value = "parentCode", required = false, defaultValue = "home") String parentCode) {
logger.debug("getting category tree for parent {}", parentCode);
List<CategoryDto> result = this.getCategoryService().getTree(parentCode);
Map<String, String> metadata = new HashMap<>();
metadata.put("parentCode", parentCode);
return new ResponseEntity<>(new RestResponse(result, new ArrayList<>(), metadata), HttpStatus.OK);
}
Aggregations