diff options
author | MichaelMorris <michael.morris@est.tech> | 2019-03-25 10:51:21 +0000 |
---|---|---|
committer | MichaelMorris <michael.morris@est.tech> | 2019-03-25 10:51:21 +0000 |
commit | 0d97f87b6381ea06350933b375c4e821b5e10568 (patch) | |
tree | fd5865146427119400dceae65dad58175df374be /adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter | |
parent | 7815bcec2a85b023f3004e698712cea7fed2f94e (diff) |
Create empty implementation of delete VNF request
The implementation provides no functionality (just logs the call and returns 202 with a job id) but enables invocation of the adapter from a flow
Issue-ID: SO-1632
Change-Id: Ie71699e917173c77b217e8a9f5eb9e5b794155a7
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Diffstat (limited to 'adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter')
2 files changed, 44 insertions, 3 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java index 77a3f21dca..b14ead0c4f 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java @@ -27,12 +27,14 @@ import javax.ws.rs.core.MediaType; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.vnfmadapter.v1.model.CreateVnfRequest; import org.onap.vnfmadapter.v1.model.CreateVnfResponse; +import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -58,15 +60,15 @@ public class VnfmAdapterController { required = true) @Valid @RequestBody final CreateVnfRequest createVnfRequest, @ApiParam( value = "Used to track REST requests for logging purposes. Identifies a single top level invocation of ONAP", - required = true) @RequestHeader(value = ONAPLogConstants.Headers.REQUEST_ID, + required = false) @RequestHeader(value = ONAPLogConstants.Headers.REQUEST_ID, required = false) final String requestId, @ApiParam( value = "Used to track REST requests for logging purposes. Identifies the client application user agent or user invoking the API", - required = true) @RequestHeader(value = ONAPLogConstants.Headers.PARTNER_NAME, + required = false) @RequestHeader(value = ONAPLogConstants.Headers.PARTNER_NAME, required = false) final String partnerName, @ApiParam( value = "Used to track REST requests for logging purposes. Identifies a single invocation of a single component", - required = true) @RequestHeader(value = ONAPLogConstants.Headers.INVOCATION_ID, + required = false) @RequestHeader(value = ONAPLogConstants.Headers.INVOCATION_ID, required = false) final String invocationId) { setLoggingMDCs(requestId, partnerName, invocationId); @@ -79,6 +81,33 @@ public class VnfmAdapterController { return new ResponseEntity<>(response, HttpStatus.ACCEPTED); } + @DeleteMapping(value = "/vnfs/{vnfId}") + public ResponseEntity<DeleteVnfResponse> vnfDelete( + @ApiParam(value = "The identifier of the VNF. This must be the vnf-id of an existing generic-vnf in AAI.", + required = true) @PathVariable("vnfId") final String vnfId, + @ApiParam( + value = "Used to track REST requests for logging purposes. Identifies a single top level invocation of ONAP", + required = false) @RequestHeader(value = ONAPLogConstants.Headers.REQUEST_ID, + required = false) final String requestId, + @ApiParam( + value = "Used to track REST requests for logging purposes. Identifies the client application user agent or user invoking the API", + required = false) @RequestHeader(value = ONAPLogConstants.Headers.PARTNER_NAME, + required = false) final String partnerName, + @ApiParam( + value = "Used to track REST requests for logging purposes. Identifies a single invocation of a single component", + required = false) @RequestHeader(value = ONAPLogConstants.Headers.INVOCATION_ID, + required = false) final String invocationId) { + + setLoggingMDCs(requestId, partnerName, invocationId); + + logger.info("REST request vnfDelete for VNF: {}", vnfId); + + final DeleteVnfResponse response = new DeleteVnfResponse(); + response.setJobId(UUID.randomUUID().toString()); + clearLoggingMDCs(); + return new ResponseEntity<>(response, HttpStatus.ACCEPTED); + } + private void setLoggingMDCs(final String requestId, final String partnerName, final String invocationId) { MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId); MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java index 842b3b56be..071a330e8b 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java @@ -28,6 +28,7 @@ import org.junit.runner.RunWith; import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; import org.onap.vnfmadapter.v1.model.CreateVnfRequest; import org.onap.vnfmadapter.v1.model.CreateVnfResponse; +import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; @@ -75,4 +76,15 @@ public class VnfmAdapterControllerTest { assertEquals(401, response.getStatusCode().value()); } + @Test + public void deleteVnf_ValidRequest_Returns202AndJobId() throws Exception { + final RequestEntity<Void> request = RequestEntity + .delete(new URI("http://localhost:" + port + "/so/vnfm-adapter/v1/vnfs/myVnfId")) + .accept(MediaType.APPLICATION_JSON).header("X-ONAP-RequestId", "myRequestId") + .header("X-ONAP-InvocationID", "myInvocationId").header("Content-Type", "application/json").build(); + final ResponseEntity<DeleteVnfResponse> response = restTemplate.exchange(request, DeleteVnfResponse.class); + assertEquals(202, response.getStatusCode().value()); + assertNotNull(response.getBody().getJobId()); + } + } |