Search in sources :

Example 1 with Payload

use of org.onap.appc.client.lcm.model.Payload in project so by onap.

the class ApplicationControllerClient method createRequest.

public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId, String requestorId) {
    Object requestObject = appCSupport.getInput(action.name());
    try {
        CommonHeader commonHeader = buildCommonHeader(requestId, requestorId);
        requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, commonHeader);
        requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action);
        requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class).invoke(requestObject, identifier);
        if (payload != null) {
            logger.info("payload in RunCommand: " + payload.getValue());
            requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload);
        }
    } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
        logger.error("Error building Appc request", e);
    }
    return requestObject;
}
Also used : CommonHeader(org.onap.appc.client.lcm.model.CommonHeader) Action(org.onap.appc.client.lcm.model.Action) Payload(org.onap.appc.client.lcm.model.Payload) ActionIdentifiers(org.onap.appc.client.lcm.model.ActionIdentifiers) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with Payload

use of org.onap.appc.client.lcm.model.Payload in project so by onap.

the class ApplicationControllerClient method createRequest.

public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) {
    Object requestObject = appCSupport.getInput(action.name());
    try {
        CommonHeader commonHeader = buildCommonHeader(requestId);
        requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, commonHeader);
        requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action);
        requestObject.getClass().getDeclaredMethod("setActionIdentifiers", ActionIdentifiers.class).invoke(requestObject, identifier);
        if (payload != null) {
            requestObject.getClass().getDeclaredMethod("setPayload", Payload.class).invoke(requestObject, payload);
        }
    } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
        logger.error("Error building Appc request", e);
    }
    return requestObject;
}
Also used : CommonHeader(org.onap.appc.client.lcm.model.CommonHeader) Action(org.onap.appc.client.lcm.model.Action) Payload(org.onap.appc.client.lcm.model.Payload) ActionIdentifiers(org.onap.appc.client.lcm.model.ActionIdentifiers) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with Payload

use of org.onap.appc.client.lcm.model.Payload in project so by onap.

the class ApplicationControllerOrchestrator method vnfCommand.

public Status vnfCommand(Action action, String requestId, String vnfId, Optional<String> vserverId, Optional<String> request, String controllerType) throws ApplicationControllerOrchestratorException {
    ApplicationControllerClient client = new ApplicationControllerClient(controllerType);
    Status status;
    ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
    actionIdentifiers.setVnfId(vnfId);
    if (vserverId.isPresent()) {
        actionIdentifiers.setVserverId(vserverId.get());
    }
    Payload payload = null;
    if (request.isPresent()) {
        payload = new Payload(request.get());
    }
    status = client.runCommand(action, actionIdentifiers, payload, requestId);
    if (ApplicationControllerSupport.getCategoryOf(status).equals(StatusCategory.ERROR)) {
        throw new ApplicationControllerOrchestratorException(status.getMessage(), status.getCode());
    } else {
        return status;
    }
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Payload(org.onap.appc.client.lcm.model.Payload) ActionIdentifiers(org.onap.appc.client.lcm.model.ActionIdentifiers)

Example 4 with Payload

use of org.onap.appc.client.lcm.model.Payload in project so by onap.

the class ApplicationControllerClient method vnfCommand.

public Status vnfCommand(Action action, String requestId, String vnfId, Optional<String> vserverId, Optional<String> request, String controllerType, ApplicationControllerCallback listener, String requestorId) throws ApplicationControllerOrchestratorException {
    this.setControllerType(controllerType);
    Status status;
    ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
    actionIdentifiers.setVnfId(vnfId);
    if (vserverId.isPresent()) {
        actionIdentifiers.setVserverId(vserverId.get());
    }
    Payload payload = null;
    if (request.isPresent()) {
        payload = new Payload(request.get());
    }
    status = runCommand(action, actionIdentifiers, payload, requestId, listener, requestorId);
    if (appCSupport.getCategoryOf(status).equals(StatusCategory.ERROR)) {
        throw new ApplicationControllerOrchestratorException(status.getMessage(), status.getCode());
    } else {
        return status;
    }
}
Also used : Status(org.onap.appc.client.lcm.model.Status) Payload(org.onap.appc.client.lcm.model.Payload) ActionIdentifiers(org.onap.appc.client.lcm.model.ActionIdentifiers) ApplicationControllerOrchestratorException(org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException)

Aggregations

ActionIdentifiers (org.onap.appc.client.lcm.model.ActionIdentifiers)4 Payload (org.onap.appc.client.lcm.model.Payload)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Action (org.onap.appc.client.lcm.model.Action)2 CommonHeader (org.onap.appc.client.lcm.model.CommonHeader)2 Status (org.onap.appc.client.lcm.model.Status)2 ApplicationControllerOrchestratorException (org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerOrchestratorException)1