class VfcManager {

    public RestfulResponse terminateNs(NsOperationKey nsOperationKey, String nsInstanceId) throws ApplicationException {
        // Step1: save segment operation info for delete process
        LOGGER.info("save segment operation for delete process");
        ResourceOperationStatus status = new ResourceOperationStatus(nsOperationKey.getServiceId(),
                nsOperationKey.getOperationId(), nsOperationKey.getNodeTemplateUUID());
        status.setStatus(RequestsDbConstant.Status.PROCESSING);
        resourceOperationStatusRepository.save(status);

        LOGGER.info("terminate ns -> begin");
        // Step2: prepare url and method type
        String url = getUrl(nsInstanceId, CommonConstant.Step.TERMINATE);
        String methodType = CommonConstant.MethodType.POST;

        // Step3: prepare restful parameters and options
        Map<String, String> reqBody = new HashMap<>();
        reqBody.put("nsInstanceId", nsInstanceId);
        reqBody.put("terminationType", "graceful");
        reqBody.put("gracefulTerminationTimeout", "60");

        // Step4: Call the NFVO or SDNO service to terminate service
        RestfulResponse terminateRsp = restfulUtil.send(url, methodType, JsonUtil.marshal(reqBody));
        ValidateUtil.assertObjectNotNull(terminateRsp);
        LOGGER.info("terminate ns response status is : {}", terminateRsp.getStatus());
        LOGGER.info("terminate ns response content is : {}", terminateRsp.getResponseContent());
        // Step 3: update segment operation
        if (!HttpCode.isSucess(terminateRsp.getStatus())) {
            LOGGER.error("fail to instantiate ns");
            status.setStatus(RequestsDbConstant.Status.ERROR);
            status.setErrorCode(String.valueOf(terminateRsp.getStatus()));
            status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
            resourceOperationStatusRepository.save(status);

            throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_TERMINATE_NS);
        }
        @SuppressWarnings("unchecked")
        Map<String, String> rsp = JsonUtil.unMarshal(terminateRsp.getResponseContent(), Map.class);
        String jobId = rsp.get(CommonConstant.JOB_ID);
        if (ValidateUtil.isStrEmpty(jobId)) {
            LOGGER.error("Invalid jobId from terminate operation");
            status.setStatus(RequestsDbConstant.Status.ERROR);
            status.setErrorCode(String.valueOf(terminateRsp.getStatus()));
            status.setStatusDescription(CommonConstant.StatusDesc.TERMINATE_NS_FAILED);
            resourceOperationStatusRepository.save(status);
            throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
                    DriverExceptionID.INVALID_RESPONSE_FROM_TERMINATE_OPERATION);
        }
        LOGGER.info("terminate ns -> end");

        LOGGER.info("update segment job id -> begin");
        status.setProgress("60");
        status.setStatusDescription("NS is termination completed");
        status.setJobId(jobId);
        resourceOperationStatusRepository.save(status);
        LOGGER.info("update segment job id -> end");

        return terminateRsp;
    }

    public  VfcManager();

}