Search in sources :

Example 16 with Ack

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

the class UsersDelegate method deleteUser.

public Ack deleteUser(String groupId, String userId) throws ManagementApiException {
    log.debug("Deleting user " + userId + " in group " + groupId);
    Ack ack = new Ack(Constants.FAIL_STATUS);
    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/").concat(userId);
    CloseableHttpResponse httpResponse = Utils.doDelete(groupId, nodeId, accessToken, url);
    if (httpResponse.getStatusLine().getStatusCode() != 200) {
        log.error("Error occurred while deleting user " + userId + " 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 : 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)

Example 17 with Ack

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

the class ApisDelegate method updateArtifact.

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

Example 18 with Ack

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

the class GroupsApi method deleteUser.

@DELETE
@Path("/{group-id}/users/{user-id}")
@Produces({ "application/json" })
@Operation(summary = "Delete user", description = "", tags = { "Users" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "User deletion status", content = @Content(schema = @Schema(implementation = SuccessStatus.class))), @ApiResponse(responseCode = "200", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) })
public Response deleteUser(@PathParam("group-id") @Parameter(description = "Group ID") String groupId, @PathParam("user-id") @Parameter(description = "User ID") String userId) throws ManagementApiException {
    UsersDelegate usersDelegate = new UsersDelegate();
    Ack ack = usersDelegate.deleteUser(groupId, userId);
    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) UsersDelegate(org.wso2.ei.dashboard.micro.integrator.delegates.UsersDelegate) 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 19 with Ack

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

the class GroupsApi method updateLogLevel.

@PATCH
@Path("/{group-id}/log-configs")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@Operation(summary = "Update log level", 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 updateLogLevel(@PathParam("group-id") @Parameter(description = "Group ID of the node") String groupId, @Valid LogConfigUpdateRequest request) throws ManagementApiException {
    LogConfigDelegate logConfigDelegate = new LogConfigDelegate();
    Ack ack = logConfigDelegate.updateLogLevel(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)

Example 20 with Ack

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

the class HeartBeatDelegate method processHeartbeat.

public Ack processHeartbeat(HeartbeatRequest heartbeatRequest) throws ManagementApiException {
    long currentTimestamp = System.currentTimeMillis();
    Ack ack = new Ack(Constants.FAIL_STATUS);
    HeartbeatObject heartbeat = new HeartbeatObject(heartbeatRequest.getProduct(), heartbeatRequest.getGroupId(), heartbeatRequest.getNodeId(), heartbeatRequest.getInterval(), heartbeatRequest.getMgtApiUrl(), currentTimestamp, heartbeatRequest.getChangeNotification().getDeployedArtifacts(), heartbeatRequest.getChangeNotification().getUndeployedArtifacts());
    boolean isSuccess;
    String productName = heartbeat.getProduct();
    ArtifactsManager artifactsManager = getArtifactManager(productName, heartbeat);
    if (isNodeRegistered(heartbeat)) {
        isSuccess = updateHeartbeat(heartbeat);
        artifactsManager.runUpdateExecutorService();
    } else {
        isSuccess = registerNode(heartbeat);
        if (isSuccess) {
            artifactsManager.runFetchAllExecutorService();
        }
    }
    runHeartbeatExecutorService(productName, heartbeat);
    if (isSuccess) {
        ack.setStatus(Constants.SUCCESS_STATUS);
    }
    return ack;
}
Also used : ArtifactsManager(org.wso2.ei.dashboard.core.rest.delegates.ArtifactsManager) MiArtifactsManager(org.wso2.ei.dashboard.micro.integrator.MiArtifactsManager) Ack(org.wso2.ei.dashboard.core.rest.model.Ack)

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