use of org.wso2.carbon.apimgt.rest.api.store.dto.APIListDTO in project carbon-apimgt by wso2.
the class CompositeAPIMappingUtil method toCompositeAPIListDTO.
/**
* Converts API list to CompositeAPIListDTO list.
*
* @param apisResult List of APIs
* @return CompositeAPIListDTO object
*/
public static CompositeAPIListDTO toCompositeAPIListDTO(List<CompositeAPI> apisResult) {
CompositeAPIListDTO apiListDTO = new CompositeAPIListDTO();
apiListDTO.setCount(apisResult.size());
// apiListDTO.setNext(next);
// apiListDTO.setPrevious(previous);
apiListDTO.setList(toCompositeAPIInfo(apisResult));
return apiListDTO;
}
use of org.wso2.carbon.apimgt.rest.api.store.dto.APIListDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method toAPIListDTO.
/**
* Converts {@code List<API>} to {@link APIListDTO} DTO.
*
* @param apisResult List of APIs
* @return APIListDTO
*/
public static APIListDTO toAPIListDTO(List<API> apisResult) {
APIListDTO apiListDTO = new APIListDTO();
apiListDTO.setCount(apisResult.size());
// apiListDTO.setNext(next);
// apiListDTO.setPrevious(previous);
apiListDTO.setList(toAPIInfo(apisResult));
return apiListDTO;
}
use of org.wso2.carbon.apimgt.rest.api.store.dto.APIListDTO in project carbon-apimgt by wso2.
the class APIMappingUtilTestCase method testAPIListDTO.
@Test
public void testAPIListDTO() throws APIManagementException {
String api1Id = UUID.randomUUID().toString();
Endpoint api1SandBoxEndpointId = new Endpoint.Builder().id(UUID.randomUUID().toString()).applicableLevel(APIMgtConstants.API_SPECIFIC_ENDPOINT).name("abcd").build();
Endpoint api1ProdEndpointId = new Endpoint.Builder().id(UUID.randomUUID().toString()).applicableLevel(APIMgtConstants.API_SPECIFIC_ENDPOINT).name("cdef").build();
API api1 = createApi("provider1", api1Id, "testapi1", "1.0.0", "Test API 1 - version 1.0.0", createEndpointTypeToIdMap(api1SandBoxEndpointId, api1ProdEndpointId)).build();
String api2Id = UUID.randomUUID().toString();
Endpoint api2SandBoxEndpointId = new Endpoint.Builder().id(UUID.randomUUID().toString()).applicableLevel(APIMgtConstants.API_SPECIFIC_ENDPOINT).name("abcd123").build();
Endpoint api2ProdEndpointId = new Endpoint.Builder().id(UUID.randomUUID().toString()).applicableLevel(APIMgtConstants.API_SPECIFIC_ENDPOINT).name("cdef123").build();
API api2 = createApi("provider1", api2Id, "testapi2", "1.0.0", "Test API 2 - version 1.0.0", createEndpointTypeToIdMap(api2SandBoxEndpointId, api2ProdEndpointId)).build();
List<API> apiList = new ArrayList<>();
apiList.add(api1);
apiList.add(api2);
APIMappingUtil apiMappingUtil = new APIMappingUtil();
APIListDTO apiListDTO = apiMappingUtil.toAPIListDTO(apiList);
Assert.assertEquals(apiListDTO.getList().get(0).getName(), "testapi1");
Assert.assertEquals(apiListDTO.getList().get(1).getName(), "testapi2");
}
use of org.wso2.carbon.apimgt.rest.api.store.dto.APIListDTO in project carbon-apimgt by wso2.
the class ApisApiServiceImpl method apisGet.
/**
* Retrieve a list of APIs with given gateway labels and status.
*
* @param labels Gateway labels
* @param status Lifecycle status
* @param request msf4j request object
* @return 200 OK if the opration was successful
* @throws NotFoundException If failed to retrieve APIs
*/
@Override
public Response apisGet(String labels, String status, Request request) throws NotFoundException {
APIListDTO apiListDTO;
try {
APIMgtAdminService adminService = RestApiUtil.getAPIMgtAdminService();
if (labels != null && !labels.isEmpty()) {
String[] gatewayLabels = labels.split(",");
List<String> labelList = new ArrayList<String>(Arrays.asList(gatewayLabels));
if (status != null && !status.isEmpty()) {
apiListDTO = MappingUtil.toAPIListDTO(adminService.getAPIsByStatus(labelList, status));
return Response.ok().entity(apiListDTO).build();
} else {
apiListDTO = MappingUtil.toAPIListDTO(adminService.getAPIsByGatewayLabel(labelList));
return Response.ok().entity(apiListDTO).build();
}
} else {
apiListDTO = new APIListDTO();
return Response.ok().entity(apiListDTO).build();
}
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving APIs";
ErrorDTO errorDTO = RestApiUtil.getErrorDTO(e.getErrorHandler());
log.error(errorMessage, e);
return Response.status(e.getErrorHandler().getHttpStatusCode()).entity(errorDTO).build();
}
}
use of org.wso2.carbon.apimgt.rest.api.store.dto.APIListDTO in project carbon-apimgt by wso2.
the class MappingUtil method toAPIListDTO.
/**
* Converts API list to APIListDTO list.
*
* @param apisList List of APIs
* @return APIListDTO object
*/
public static APIListDTO toAPIListDTO(List<API> apisList) {
APIListDTO apiListDTO = new APIListDTO();
apiListDTO.setCount(apisList.size());
apiListDTO.setList(toAPIInfo(apisList));
return apiListDTO;
}
Aggregations