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;
}
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;
}
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();
}
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();
}
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;
}
Aggregations