use of io.gravitee.management.model.analytics.Analytics in project gravitee-management-rest-api by gravitee-io.
the class ApiAnalyticsResource method hits.
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Get API analytics")
@Permissions({ @Permission(value = RolePermission.API_ANALYTICS, acls = RolePermissionAction.READ) })
public Response hits(@PathParam("api") String api, @BeanParam AnalyticsParam analyticsParam) {
analyticsParam.validate();
Analytics analytics = null;
switch(analyticsParam.getType()) {
case DATE_HISTO:
analytics = executeDateHisto(api, analyticsParam);
break;
case GROUP_BY:
analytics = executeGroupBy(api, analyticsParam);
break;
case COUNT:
analytics = executeCount(api, analyticsParam);
break;
}
return Response.ok(analytics).build();
}
use of io.gravitee.management.model.analytics.Analytics in project gravitee-management-rest-api by gravitee-io.
the class PlatformAnalyticsResource method platformAnalytics.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Permissions({ @Permission(value = MANAGEMENT_PLATFORM, acls = READ) })
public Response platformAnalytics(@BeanParam AnalyticsParam analyticsParam) {
analyticsParam.validate();
Analytics analytics = null;
// add filter by Apis or Applications
String extraFilter = null;
if (!isAdmin()) {
if ("api".equals(analyticsParam.getField())) {
extraFilter = getExtraFilter(analyticsParam.getField(), apiService.findByUser(getAuthenticatedUser()).stream().filter(api -> permissionService.hasPermission(API_ANALYTICS, api.getId(), READ)).map(ApiEntity::getId).collect(Collectors.toList()));
} else if ("application".equals(analyticsParam.getField())) {
extraFilter = getExtraFilter(analyticsParam.getField(), applicationService.findByUser(getAuthenticatedUser()).stream().filter(app -> permissionService.hasPermission(APPLICATION_ANALYTICS, app.getId(), READ)).map(ApplicationEntity::getId).collect(Collectors.toList()));
}
}
switch(analyticsParam.getTypeParam().getValue()) {
case DATE_HISTO:
analytics = executeDateHisto(analyticsParam, extraFilter);
break;
case GROUP_BY:
analytics = executeGroupBy(analyticsParam, extraFilter);
break;
case COUNT:
analytics = executeCount(analyticsParam, extraFilter);
break;
}
return Response.ok(analytics).build();
}
use of io.gravitee.management.model.analytics.Analytics in project gravitee-management-rest-api by gravitee-io.
the class ApplicationAnalyticsResource method hits.
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get Application analytics")
@Permissions({ @Permission(value = RolePermission.APPLICATION_ANALYTICS, acls = RolePermissionAction.READ) })
public Response hits(@PathParam("application") String application, @BeanParam AnalyticsParam analyticsParam) {
analyticsParam.validate();
Analytics analytics = null;
switch(analyticsParam.getTypeParam().getValue()) {
case DATE_HISTO:
analytics = executeDateHisto(application, analyticsParam);
break;
case GROUP_BY:
analytics = executeGroupBy(application, analyticsParam);
break;
case COUNT:
analytics = executeCount(application, analyticsParam);
break;
}
return Response.ok(analytics).build();
}
Aggregations