use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APIInfoListDTO in project carbon-apimgt by wso2.
the class ApiApiServiceImpl method apiListGet.
/**
* Get list of API Info
*
* @param startTime Filter for start time stamp
* @param endTime Filter for end time stamp
* @param createdBy Filter for created user
* @param request MSF4J request
* @return API List
* @throws NotFoundException When the particular resource does not exist in the system
*/
@Override
public Response apiListGet(String startTime, String endTime, String createdBy, Request request) throws NotFoundException {
String username = RestApiUtil.getLoggedInUsername(request);
try {
log.debug("Retrieving API information. [From: {} To: {} Created By:{} ]", startTime, endTime, createdBy);
Analyzer analyzer = RestApiUtil.getAnalyzer(username);
ZoneId requestTimezone = RestApiUtil.getRequestTimeZone(startTime);
List<APIInfo> apiInfoList = analyzer.getAPIInfo(fromISO8601ToInstant(startTime), fromISO8601ToInstant(endTime), createdBy);
APIInfoListDTO apiInfoListDTO = AnalyticsMappingUtil.fromAPIInfoListToDTO(apiInfoList, requestTimezone);
return Response.ok().entity(apiInfoListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving API information";
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.admin.v1.dto.APIInfoListDTO in project carbon-apimgt by wso2.
the class AnalyticsMappingUtil method fromSubscriptionCountListToDTO.
/**
* Converts and SubscriptionInfoList to SubscriptionInfoListDTO.
*
* @param subscriptionCountList list of SubscriptionCount objects
* @return corresponding APIInfoListDTO object
*/
public static SubscriptionCountListDTO fromSubscriptionCountListToDTO(List<SubscriptionCount> subscriptionCountList, ZoneId zoneId) {
SubscriptionCountListDTO subscriptionCountListDTO = new SubscriptionCountListDTO();
List<SubscriptionCountDTO> subscriptionCountDTOList = new ArrayList<>();
subscriptionCountListDTO.setCount(subscriptionCountList.size());
for (SubscriptionCount subscriptionCount : subscriptionCountList) {
SubscriptionCountDTO subscriptionCountDTO = new SubscriptionCountDTO();
subscriptionCountDTO.setTime(epochToISO8601DateTime(subscriptionCount.getTimestamp(), zoneId));
subscriptionCountDTO.setCount(subscriptionCount.getCount());
subscriptionCountDTOList.add(subscriptionCountDTO);
}
subscriptionCountListDTO.setList(subscriptionCountDTOList);
return subscriptionCountListDTO;
}
Aggregations