Search in sources :

Example 6 with Ack

use of org.wso2.ei.dashboard.core.rest.model.Ack 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)

Example 7 with Ack

use of org.wso2.ei.dashboard.core.rest.model.Ack in project product-mi-tooling by wso2.

the class GroupsApi method updateLogLevelByNodeId.

@PATCH
@Path("/{group-id}/log-configs/nodes/{node-id}")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@Operation(summary = "Update log level by nodeId", description = "", tags = { "logConfigs" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Logger update status", content = @Content(schema = @Schema(implementation = SuccessStatus.class))), @ApiResponse(responseCode = "200", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) })
public Response updateLogLevelByNodeId(@PathParam("group-id") @Parameter(description = "Group ID of the node") String groupId, @PathParam("node-id") @Parameter(description = "NodeId") String nodeId, @Valid LogConfigUpdateRequest request) throws ManagementApiException {
    LogConfigDelegate logConfigDelegate = new LogConfigDelegate();
    Ack ack = logConfigDelegate.updateLogLevelByNodeId(groupId, nodeId, request);
    return Response.ok().entity(ack).build();
}
Also used : LogConfigDelegate(org.wso2.ei.dashboard.micro.integrator.delegates.LogConfigDelegate) Ack(org.wso2.ei.dashboard.core.rest.model.Ack) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 8 with Ack

use of org.wso2.ei.dashboard.core.rest.model.Ack in project product-mi-tooling by wso2.

the class MessageProcessorsDelegate method updateArtifact.

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

Example 9 with Ack

use of org.wso2.ei.dashboard.core.rest.model.Ack in project product-mi-tooling by wso2.

the class UsersDelegate method addUser.

public Ack addUser(String groupId, AddUserRequest request) throws ManagementApiException {
    log.debug("Adding user " + request.getUserId() + " in group " + groupId);
    Ack ack = new Ack(Constants.FAIL_STATUS);
    JsonObject payload = createAddUserPayload(request);
    NodeList nodeList = databaseManager.fetchNodes(groupId);
    // assumption - In a group, all nodes use a shared user-store
    String nodeId = nodeList.get(0).getNodeId();
    String mgtApiUrl = ManagementApiUtils.getMgtApiUrl(groupId, nodeId);
    String accessToken = databaseManager.getAccessToken(groupId, nodeId);
    String url = mgtApiUrl.concat("users");
    Utils.doPost(groupId, nodeId, accessToken, url, payload);
    ack.setStatus(Constants.SUCCESS_STATUS);
    return ack;
}
Also used : NodeList(org.wso2.ei.dashboard.core.rest.model.NodeList) Ack(org.wso2.ei.dashboard.core.rest.model.Ack) JsonObject(com.google.gson.JsonObject)

Example 10 with Ack

use of org.wso2.ei.dashboard.core.rest.model.Ack in project product-mi-tooling by wso2.

the class GroupsApi method addLogger.

@POST
@Path("/{group-id}/log-configs")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@Operation(summary = "Add logger", description = "", tags = { "logConfigs" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Logger insert status", content = @Content(schema = @Schema(implementation = SuccessStatus.class))), @ApiResponse(responseCode = "200", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) })
public Response addLogger(@PathParam("group-id") @Parameter(description = "Group ID of the node") String groupId, @Valid LogConfigAddRequest request) throws ManagementApiException {
    LogConfigDelegate logConfigDelegate = new LogConfigDelegate();
    Ack ack = logConfigDelegate.addLogger(groupId, request);
    Response.ResponseBuilder responseBuilder = Response.ok().entity(ack);
    HttpUtils.setHeaders(responseBuilder);
    return responseBuilder.build();
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse) LogConfigDelegate(org.wso2.ei.dashboard.micro.integrator.delegates.LogConfigDelegate) Ack(org.wso2.ei.dashboard.core.rest.model.Ack) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

Ack (org.wso2.ei.dashboard.core.rest.model.Ack)17 JsonObject (com.google.gson.JsonObject)5 Operation (io.swagger.v3.oas.annotations.Operation)5 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)5 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)4 Response (javax.ws.rs.core.Response)4 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)4 NodeList (org.wso2.ei.dashboard.core.rest.model.NodeList)4 LogConfigDelegate (org.wso2.ei.dashboard.micro.integrator.delegates.LogConfigDelegate)3 NodeListInner (org.wso2.ei.dashboard.core.rest.model.NodeListInner)2 UsersDelegate (org.wso2.ei.dashboard.micro.integrator.delegates.UsersDelegate)2 HL7Exception (ca.uhn.hl7v2.HL7Exception)1 Message (ca.uhn.hl7v2.model.Message)1 DefaultHttpResponse (io.netty.handler.codec.http.DefaultHttpResponse)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 AxisFault (org.apache.axis2.AxisFault)1 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)1 MessageContext (org.apache.axis2.context.MessageContext)1 Parameter (org.apache.axis2.description.Parameter)1