Search in sources :

Example 1 with ManagementApiException

use of org.wso2.ei.dashboard.core.exception.ManagementApiException in project product-mi-tooling by wso2.

the class EndpointsDelegate method updateArtifact.

@Override
public Ack updateArtifact(String groupId, ArtifactUpdateRequest request) throws ManagementApiException {
    logger.debug("Updating Endpoint " + request.getArtifactName() + " in node " + request.getNodeId() + " in group " + groupId);
    Ack ack = new Ack(Constants.FAIL_STATUS);
    boolean isSuccess = updateEndpoint(groupId, request);
    if (isSuccess) {
        ack.setStatus(Constants.SUCCESS_STATUS);
    }
    return ack;
}
Also used : Ack(org.wso2.ei.dashboard.core.rest.model.Ack)

Example 2 with ManagementApiException

use of org.wso2.ei.dashboard.core.exception.ManagementApiException in project product-mi-tooling by wso2.

the class InboundEndpointDelegate method updateArtifact.

@Override
public Ack updateArtifact(String groupId, ArtifactUpdateRequest request) throws ManagementApiException {
    logger.debug("Updating inbound endpoint " + request.getArtifactName() + " in node " + request.getNodeId() + " in group " + groupId);
    Ack ack = new Ack(Constants.FAIL_STATUS);
    boolean isSuccess = updateInboundEndpoint(groupId, request);
    if (isSuccess) {
        ack.setStatus(Constants.SUCCESS_STATUS);
    }
    return ack;
}
Also used : Ack(org.wso2.ei.dashboard.core.rest.model.Ack)

Example 3 with ManagementApiException

use of org.wso2.ei.dashboard.core.exception.ManagementApiException in project product-mi-tooling by wso2.

the class LogConfigDelegate method addLogger.

public Ack addLogger(String groupId, LogConfigAddRequest request) throws ManagementApiException {
    logger.debug("Adding new Logger " + request.getName() + " for all nodes in group " + groupId);
    Ack ack = new Ack(Constants.FAIL_STATUS);
    JsonObject payload = createAddLoggerPayload(request);
    NodeList nodeList = databaseManager.fetchNodes(groupId);
    for (NodeListInner node : nodeList) {
        String nodeId = node.getNodeId();
        String mgtApiUrl = ManagementApiUtils.getMgtApiUrl(groupId, nodeId);
        String accessToken = databaseManager.getAccessToken(groupId, nodeId);
        String addLoggerUrl = mgtApiUrl.concat("logging");
        logger.debug("Adding new logger on node " + nodeId);
        CloseableHttpResponse httpResponse = Utils.doPatch(groupId, nodeId, accessToken, addLoggerUrl, payload);
        if (httpResponse.getStatusLine().getStatusCode() != 200) {
            logger.error("Error occurred while adding logger on node " + nodeId + " in group " + groupId);
            String message = HttpUtils.getJsonResponse(httpResponse).get("Error").getAsString();
            ack.setMessage(message);
            return ack;
        }
    }
    ack.setStatus(Constants.SUCCESS_STATUS);
    return ack;
}
Also used : NodeListInner(org.wso2.ei.dashboard.core.rest.model.NodeListInner) NodeList(org.wso2.ei.dashboard.core.rest.model.NodeList) Ack(org.wso2.ei.dashboard.core.rest.model.Ack) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) JsonObject(com.google.gson.JsonObject)

Example 4 with ManagementApiException

use of org.wso2.ei.dashboard.core.exception.ManagementApiException in project product-mi-tooling by wso2.

the class LogConfigDelegate method updateLogLevel.

public Ack updateLogLevel(String groupId, LogConfigUpdateRequest request) throws ManagementApiException {
    logger.debug("Updating logger " + request.getName() + " for all nodes in group " + groupId);
    Ack ack = new Ack(Constants.FAIL_STATUS);
    JsonObject payload = createUpdateLoggerPayload(request);
    NodeList nodeList = databaseManager.fetchNodes(groupId);
    for (NodeListInner node : nodeList) {
        String nodeId = node.getNodeId();
        CloseableHttpResponse httpResponse = updateLogLevelByNodeId(groupId, nodeId, payload);
        if (httpResponse.getStatusLine().getStatusCode() != 200) {
            logger.error("Error occurred while updating logger on node " + nodeId + " in group " + groupId);
            String message = HttpUtils.getJsonResponse(httpResponse).get("Error").getAsString();
            ack.setMessage(message);
            return ack;
        }
    }
    ack.setStatus(Constants.SUCCESS_STATUS);
    return ack;
}
Also used : NodeListInner(org.wso2.ei.dashboard.core.rest.model.NodeListInner) NodeList(org.wso2.ei.dashboard.core.rest.model.NodeList) Ack(org.wso2.ei.dashboard.core.rest.model.Ack) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) JsonObject(com.google.gson.JsonObject)

Example 5 with ManagementApiException

use of org.wso2.ei.dashboard.core.exception.ManagementApiException in project product-mi-tooling by wso2.

the class LogConfigDelegate method updateLogLevelByNodeId.

public Ack updateLogLevelByNodeId(String groupId, String nodeId, LogConfigUpdateRequest request) throws ManagementApiException {
    logger.debug("Updating logger " + request.getName() + " in node " + nodeId + " in group " + groupId);
    Ack ack = new Ack(Constants.FAIL_STATUS);
    JsonObject payload = createUpdateLoggerPayload(request);
    CloseableHttpResponse httpResponse = updateLogLevelByNodeId(groupId, nodeId, payload);
    if (httpResponse.getStatusLine().getStatusCode() != 200) {
        logger.error("Error occurred while updating logger on node " + nodeId + " in group " + groupId);
        String message = HttpUtils.getJsonResponse(httpResponse).get("Error").getAsString();
        ack.setMessage(message);
    } else {
        ack.setStatus(Constants.SUCCESS_STATUS);
    }
    return ack;
}
Also used : Ack(org.wso2.ei.dashboard.core.rest.model.Ack) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) JsonObject(com.google.gson.JsonObject)

Aggregations

Ack (org.wso2.ei.dashboard.core.rest.model.Ack)17 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)15 Operation (io.swagger.v3.oas.annotations.Operation)12 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)12 JsonObject (com.google.gson.JsonObject)11 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)11 Response (javax.ws.rs.core.Response)11 NodeList (org.wso2.ei.dashboard.core.rest.model.NodeList)7 ManagementApiException (org.wso2.ei.dashboard.core.exception.ManagementApiException)6 JsonElement (com.google.gson.JsonElement)5 LogConfigDelegate (org.wso2.ei.dashboard.micro.integrator.delegates.LogConfigDelegate)5 JsonArray (com.google.gson.JsonArray)3 UsersDelegate (org.wso2.ei.dashboard.micro.integrator.delegates.UsersDelegate)3 CAppArtifacts (org.wso2.ei.dashboard.core.rest.model.CAppArtifacts)2 LocalEntryValue (org.wso2.ei.dashboard.core.rest.model.LocalEntryValue)2 LogConfigs (org.wso2.ei.dashboard.core.rest.model.LogConfigs)2 LogList (org.wso2.ei.dashboard.core.rest.model.LogList)2 NodeListInner (org.wso2.ei.dashboard.core.rest.model.NodeListInner)2 Users (org.wso2.ei.dashboard.core.rest.model.Users)2 UsersInner (org.wso2.ei.dashboard.core.rest.model.UsersInner)2