Search in sources :

Example 1 with CAppArtifacts

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

the class GroupsApi method getCarbonApplicationArtifactsByNodeIds.

@GET
@Path("/{group-id}/nodes/{node-id}/capps/{capp-name}/artifacts")
@Produces({ "application/json" })
@Operation(summary = "Get artifact list of carbon application by node id", description = "", tags = { "carbonApplications" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "List of artifacts in carbon applications deployed in provided nodes", content = @Content(schema = @Schema(implementation = CAppArtifacts.class))), @ApiResponse(responseCode = "200", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) })
public Response getCarbonApplicationArtifactsByNodeIds(@PathParam("group-id") @Parameter(description = "Group ID of the node") String groupId, @PathParam("node-id") @Parameter(description = "Node ID") String nodeId, @PathParam("capp-name") @Parameter(description = "Carbon application name") String cappName) throws ManagementApiException {
    CarbonAppsDelegate cappsDelegate = new CarbonAppsDelegate();
    CAppArtifacts cAppArtifactList = cappsDelegate.getCAppArtifactList(groupId, nodeId, cappName);
    Response.ResponseBuilder responseBuilder = Response.ok().entity(cAppArtifactList);
    HttpUtils.setHeaders(responseBuilder);
    return responseBuilder.build();
}
Also used : Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse) CAppArtifacts(org.wso2.ei.dashboard.core.rest.model.CAppArtifacts) CarbonAppsDelegate(org.wso2.ei.dashboard.micro.integrator.delegates.CarbonAppsDelegate) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 2 with CAppArtifacts

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

the class CarbonAppsDelegate method getCAppArtifactList.

public CAppArtifacts getCAppArtifactList(String groupId, String nodeId, String cAppName) throws ManagementApiException {
    log.debug("Fetching artifacts in carbon applications from management console");
    String mgtApiUrl = ManagementApiUtils.getMgtApiUrl(groupId, nodeId);
    String url = mgtApiUrl.concat("applications").concat("?").concat("carbonAppName").concat("=").concat(cAppName);
    String accessToken = databaseManager.getAccessToken(groupId, nodeId);
    CloseableHttpResponse httpResponse = Utils.doGet(groupId, nodeId, accessToken, url);
    JsonObject jsonResponse = HttpUtils.getJsonResponse(httpResponse);
    JsonArray artifacts = jsonResponse.getAsJsonArray("artifacts");
    CAppArtifacts cAppArtifacts = new CAppArtifacts();
    for (JsonElement artifact : artifacts) {
        JsonObject jsonObject = artifact.getAsJsonObject();
        CAppArtifactsInner cAppArtifact = new CAppArtifactsInner();
        cAppArtifact.setName(jsonObject.get("name").getAsString());
        cAppArtifact.setType(jsonObject.get("type").getAsString());
        cAppArtifacts.add(cAppArtifact);
    }
    return cAppArtifacts;
}
Also used : JsonArray(com.google.gson.JsonArray) CAppArtifactsInner(org.wso2.ei.dashboard.core.rest.model.CAppArtifactsInner) CAppArtifacts(org.wso2.ei.dashboard.core.rest.model.CAppArtifacts) JsonElement(com.google.gson.JsonElement) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) JsonObject(com.google.gson.JsonObject)

Aggregations

CAppArtifacts (org.wso2.ei.dashboard.core.rest.model.CAppArtifacts)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 Response (javax.ws.rs.core.Response)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 CAppArtifactsInner (org.wso2.ei.dashboard.core.rest.model.CAppArtifactsInner)1 CarbonAppsDelegate (org.wso2.ei.dashboard.micro.integrator.delegates.CarbonAppsDelegate)1