use of org.openkilda.messaging.payload.flow.FlowPayload 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.openkilda.messaging.payload.flow.FlowPayload 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.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowControllerTest method deleteFlows.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void deleteFlows() throws Exception {
MvcResult result = mockMvc.perform(delete("/flows").header(CORRELATION_ID, testCorrelationId()).header(EXTRA_AUTH, System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(119)).contentType(APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
FlowPayload[] response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload[].class);
assertEquals(TestMessageMock.flow, response[0]);
}
use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowControllerTest method getFlow.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void getFlow() throws Exception {
MvcResult result = mockMvc.perform(get("/flows/{flow-id}", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
FlowPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload.class);
assertEquals(TestMessageMock.flow, response);
}
use of org.openkilda.messaging.payload.flow.FlowPayload in project open-kilda by telstra.
the class FlowControllerTest method deleteFlow.
@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void deleteFlow() throws Exception {
MvcResult result = mockMvc.perform(delete("/flows/{flow-id}", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
FlowPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowPayload.class);
assertEquals(TestMessageMock.flow, response);
}
Aggregations