Search in sources :

Example 1 with JobAttributesDeleteRequest

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

the class JobManagementResource method deleteJobAttributes.

@DELETE
@ApiOperation("Delete attributes of a job with the specified key names")
@Path("/jobs/{jobId}/attributes")
public Response deleteJobAttributes(@PathParam("jobId") String jobId, @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");
    }
    JobAttributesDeleteRequest request = JobAttributesDeleteRequest.newBuilder().setJobId(jobId).addAllKeys(keys).build();
    return Responses.fromVoidMono(jobServiceGateway.deleteJobAttributes(request, resolveCallMetadata()));
}
Also used : JobAttributesDeleteRequest(com.netflix.titus.grpc.protogen.JobAttributesDeleteRequest) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with JobAttributesDeleteRequest

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

the class JobManagementSpringResource method deleteJobAttributes.

@ApiOperation("Delete attributes of a job with the specified key names")
@DeleteMapping(path = "/jobs/{jobId}/attributes")
public ResponseEntity<Void> deleteJobAttributes(@PathVariable("jobId") String jobId, @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");
    }
    JobAttributesDeleteRequest request = JobAttributesDeleteRequest.newBuilder().setJobId(jobId).addAllKeys(keys).build();
    return Responses.fromVoidMono(jobServiceGateway.deleteJobAttributes(request, authentication.getCallMetadata()), HttpStatus.OK);
}
Also used : JobAttributesDeleteRequest(com.netflix.titus.grpc.protogen.JobAttributesDeleteRequest) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with JobAttributesDeleteRequest

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

the class JobManagementSpringResourceTest method testDeleteJobAttributes.

@Test
public void testDeleteJobAttributes() throws Exception {
    JobAttributesDeleteRequest forwardedRequest = JobAttributesDeleteRequest.newBuilder().setJobId(JOB_ID_1).addKeys("keyA").build();
    when(jobServiceGatewayMock.deleteJobAttributes(forwardedRequest, JUNIT_REST_CALL_METADATA)).thenReturn(Mono.empty());
    SpringMockMvcUtil.doDelete(mockMvc, String.format("/api/v3/jobs/%s/attributes", JOB_ID_1), "keys", "keyA");
    verify(jobServiceGatewayMock, times(1)).deleteJobAttributes(forwardedRequest, JUNIT_REST_CALL_METADATA);
}
Also used : JobAttributesDeleteRequest(com.netflix.titus.grpc.protogen.JobAttributesDeleteRequest) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest) Test(org.junit.Test)

Aggregations

JobAttributesDeleteRequest (com.netflix.titus.grpc.protogen.JobAttributesDeleteRequest)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