Search in sources :

Example 1 with TaskAttributesDeleteRequest

use of com.netflix.titus.grpc.protogen.TaskAttributesDeleteRequest in project titus-control-plane by Netflix.

the class JobManagementResource method deleteTaskAttributes.

@DELETE
@ApiOperation("Delete attributes of a task with the specified key names")
@Path("/tasks/{taskId}/attributes")
public Response deleteTaskAttributes(@PathParam("taskId") String taskId, @QueryParam("keys") String delimitedKeys) {
    if (Strings.isNullOrEmpty(delimitedKeys)) {
        throw TitusServiceException.invalidArgument("Path parameter 'keys' cannot be empty");
    }
    Set<String> keys = StringExt.splitByCommaIntoSet(delimitedKeys);
    if (keys.isEmpty()) {
        throw TitusServiceException.invalidArgument("Parsed path parameter 'keys' cannot be empty");
    }
    TaskAttributesDeleteRequest request = TaskAttributesDeleteRequest.newBuilder().setTaskId(taskId).addAllKeys(keys).build();
    return Responses.fromCompletable(jobServiceGateway.deleteTaskAttributes(request, resolveCallMetadata()));
}
Also used : TaskAttributesDeleteRequest(com.netflix.titus.grpc.protogen.TaskAttributesDeleteRequest) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with TaskAttributesDeleteRequest

use of com.netflix.titus.grpc.protogen.TaskAttributesDeleteRequest in project titus-control-plane by Netflix.

the class JobManagementSpringResource method deleteTaskAttributes.

@ApiOperation("Delete attributes of a task with the specified key names")
@DeleteMapping(path = "/tasks/{taskId}/attributes")
public ResponseEntity<Void> deleteTaskAttributes(@PathVariable("taskId") String taskId, @RequestParam("keys") String delimitedKeys, CallMetadataAuthentication authentication) {
    if (Strings.isNullOrEmpty(delimitedKeys)) {
        throw TitusServiceException.invalidArgument("Path parameter 'keys' cannot be empty");
    }
    Set<String> keys = StringExt.splitByCommaIntoSet(delimitedKeys);
    if (keys.isEmpty()) {
        throw TitusServiceException.invalidArgument("Parsed path parameter 'keys' cannot be empty");
    }
    TaskAttributesDeleteRequest request = TaskAttributesDeleteRequest.newBuilder().setTaskId(taskId).addAllKeys(keys).build();
    return Responses.fromCompletable(jobServiceGateway.deleteTaskAttributes(request, authentication.getCallMetadata()), HttpStatus.OK);
}
Also used : TaskAttributesDeleteRequest(com.netflix.titus.grpc.protogen.TaskAttributesDeleteRequest) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with TaskAttributesDeleteRequest

use of com.netflix.titus.grpc.protogen.TaskAttributesDeleteRequest in project titus-control-plane by Netflix.

the class JobManagementSpringResourceTest method testDeleteTaskAttributes.

@Test
public void testDeleteTaskAttributes() throws Exception {
    TaskAttributesDeleteRequest forwardedRequest = TaskAttributesDeleteRequest.newBuilder().setTaskId(TASK_ID_1).addKeys("keyA").build();
    when(jobServiceGatewayMock.deleteTaskAttributes(forwardedRequest, JUNIT_REST_CALL_METADATA)).thenReturn(Completable.complete());
    SpringMockMvcUtil.doDelete(mockMvc, String.format("/api/v3/tasks/%s/attributes", TASK_ID_1), "keys", "keyA");
    verify(jobServiceGatewayMock, times(1)).deleteTaskAttributes(forwardedRequest, JUNIT_REST_CALL_METADATA);
}
Also used : TaskAttributesDeleteRequest(com.netflix.titus.grpc.protogen.TaskAttributesDeleteRequest) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest) Test(org.junit.Test)

Aggregations

TaskAttributesDeleteRequest (com.netflix.titus.grpc.protogen.TaskAttributesDeleteRequest)3 ApiOperation (io.swagger.annotations.ApiOperation)2 DELETE (javax.ws.rs.DELETE)1 Path (javax.ws.rs.Path)1 Test (org.junit.Test)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)1