use of org.wso2.carbon.apimgt.core.models.analytics.APISubscriptionCount in project carbon-apimgt by wso2.
the class ApiApiServiceImpl method apiSubscriberCountByApiGet.
/**
* Get list of subscriptions for an API
*
* @param startTime Filter for start time stamp
* @param endTime Filter for end time stamp
* @param apiId Filter for apiId
* @param request MSF4J request
* @return API subscriptions count
* @throws NotFoundException When the particular resource does not exist in the system
*/
@Override
public Response apiSubscriberCountByApiGet(String startTime, String endTime, String apiId, Request request) throws NotFoundException {
String username = RestApiUtil.getLoggedInUsername(request);
try {
log.debug("Retrieving APIs created over time. [From: {} To: {} API Id: {}]");
Analyzer analyzer = RestApiUtil.getAnalyzer(username);
List<APISubscriptionCount> apiSubscriptionCountList = analyzer.getAPISubscriptionCount(fromISO8601ToInstant(startTime), fromISO8601ToInstant(endTime), apiId);
APISubscriptionCountListDTO apiSubscriptionListDTO = AnalyticsMappingUtil.fromAPISubscriptionCountListToDTO(apiSubscriptionCountList);
return Response.ok().entity(apiSubscriptionListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving API subscription info";
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.core.models.analytics.APISubscriptionCount in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method createRandomAPISubscriptionCountObject.
/**
* Create Random APISubscriptionCount Object.
*
* @return Random APISubscriptionCount Object
*/
public static APISubscriptionCount createRandomAPISubscriptionCountObject() {
APISubscriptionCount apiSubscriptionCount = new APISubscriptionCount();
apiSubscriptionCount.setId(UUID.randomUUID().toString());
apiSubscriptionCount.setName(UUID.randomUUID().toString());
apiSubscriptionCount.setVersion(UUID.randomUUID().toString());
apiSubscriptionCount.setProvider(UUID.randomUUID().toString());
apiSubscriptionCount.setCount(new Random().nextInt());
return apiSubscriptionCount;
}
Aggregations