class GenericVnfHealthCheck {

    public void callAppcClient(BuildingBlockExecution execution) {
        logger.trace("Start runAppcCommand ");
        String appcCode = "1002";
        String appcMessage = "";
        try {
            Action action = null;
            action = Action.valueOf(execution.getVariable("action"));
            String msoRequestId = execution.getVariable("msoRequestId");
            String vnfId = execution.getVariable("vnfId");
            Optional<String> payload = null;
            if (execution.getVariable("payload") != null) {
                String pay = execution.getVariable("payload");
                payload = Optional.of(pay);
            }
            String controllerType = execution.getVariable("controllerType");
            HashMap<String, String> payloadInfo = new HashMap<>();
            payloadInfo.put(VNF_NAME, execution.getVariable(VNF_NAME));
            payloadInfo.put("vfModuleId", execution.getVariable("vfModuleId"));
            payloadInfo.put(OAM_IP_ADDRESS, execution.getVariable(OAM_IP_ADDRESS));
            payloadInfo.put(VNF_HOST_IP_ADDRESS, execution.getVariable(VNF_HOST_IP_ADDRESS));

            logger.debug("Running APP-C action: {}", action.toString());
            logger.debug("VNFID: {}", vnfId);
            // PayloadInfo contains extra information that adds on to payload before making request to appc
            appCClient.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
            appcCode = appCClient.getErrorCode();
            appcMessage = appCClient.getErrorMessage();
        } catch (BpmnError ex) {
            logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
                    "Caught exception in GenericVnfHealthCheck", "BPMN", ErrorCode.UnknownError.getValue(), ex);
            appcMessage = ex.getMessage();
            exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
        } catch (Exception e) {
            if (e instanceof java.util.concurrent.TimeoutException) {
                appcMessage = "Request to APPC timed out. ";
                logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONNECTION_EXCEPTION.toString(),
                        "Caught timedOut exception in runAppcCommand in GenericVnfHealthCheck", "BPMN",
                        ErrorCode.UnknownError.getValue(), "APPC Error", e);
                throw e;
            } else {
                logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION.toString(),
                        "Caught exception in runAppcCommand in GenericVnfHealthCheck", "BPMN",
                        ErrorCode.UnknownError.getValue(), "APPC Error", e);
                appcMessage = e.getMessage();
                exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
            }
        }
        logger.error("Error Message: " + appcMessage);
        logger.error("ERROR CODE: " + appcCode);
        logger.trace("End of runAppCommand ");
        if (appcCode != null && !("0").equals(appcCode)) {
            exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage);
        }
    }

}