@Path("/check") @ApiOperation(value = "Check feature exists", authorizations = @Authorization(value = "read_key")) @GET public boolean check() { return !database.isPresent(); }
public ProjectPermissionIRequestParameter(ApiKeyService apiKeyService, Method method) { final ApiOperation annotation = method.getAnnotation(ApiOperation.class); Authorization[] authorizations = annotation == null ? new Authorization[0] : Arrays.stream(annotation.authorizations()).filter(auth -> !auth.value().equals("")).toArray(value -> new Authorization[value]); if (authorizations.length == 0) { throw new IllegalStateException(method.toGenericString() + ": The permission check component requires endpoints to have authorizations definition in @ApiOperation. " + "Use @IgnorePermissionCheck to bypass security check in method " + method.toString()); } if (annotation != null && !annotation.consumes().isEmpty() && !annotation.consumes().equals("application/json")) { throw new IllegalStateException("The permission check component requires endpoint to consume application/json. " + "Use @IgnorePermissionCheck to bypass security check in method " + method.toString()); } Api clazzOperation = method.getDeclaringClass().getAnnotation(Api.class); if (authorizations.length == 0 && (clazzOperation == null || clazzOperation.authorizations().length == 0)) { throw new IllegalArgumentException(String.format("Authorization for method %s is not defined. " + "You must use @IgnorePermissionCheck if the endpoint doesn't need permission check", method.toString())); } if (authorizations.length != 1) { throw new IllegalArgumentException(); } type = ApiKeyService.AccessKeyType.fromKey(authorizations[0].value()); this.apiKeyService = apiKeyService; }
String nickname = !apiOperation.nickname().isEmpty() ? apiOperation.nickname() : parentApi.nickname(); if (nickname.isEmpty()) { nickname = method.getDeclaringClass().getName().replace(".", "_"); if (apiOperation.hidden()) { return null; defaultResponseHeaders = parseResponseHeaders(apiOperation.responseHeaders()); .summary(apiOperation.value()) .description(apiOperation.notes()); if (apiOperation.response() != null && !Void.class.equals(apiOperation.response())) { responseClass = apiOperation.response(); if (!"".equals(apiOperation.responseContainer())) { responseContainer = apiOperation.responseContainer(); if (apiOperation.authorizations() != null) { List<SecurityRequirement> securities = new ArrayList<>(); for (Authorization auth : apiOperation.authorizations()) { if (auth.value() != null && !"".equals(auth.value())) { SecurityRequirement security = new SecurityRequirement(); if (!apiOperation.request().equals(Void.class)) { Class<?> clazz = apiOperation.request(); if (clazz.getSuperclass() != null && clazz.getSuperclass().equals(TypeToken.class)) { explicitType = ((ParameterizedType) clazz.getGenericSuperclass()).getActualTypeArguments()[0];
}); String protocols = apiOperation.protocols(); if (!"".equals(protocols)) { String[] parts = protocols.split(","); ApiOperation op = method.getAnnotation(ApiOperation.class); if (op != null) { for (String tag : op.tags()) { if (!"".equals(tag)) { operation.tag(tag); continue; if (!apiOperation.consumes().isEmpty() && !apiOperation.consumes().startsWith("application/json")) { continue; operation.produces(Arrays.asList(produces.value())); else if (!apiOperation.produces().isEmpty()) { operation.produces(apiOperation.produces());
.setSwaggerOperationProcessor((method, operation) -> { ApiOperation annotation = method.getAnnotation(ApiOperation.class); if (annotation != null && annotation.authorizations() != null && annotation.authorizations().length > 0) { String value = annotation.authorizations()[0].value(); if (value != null && !value.isEmpty()) { operation.response(FORBIDDEN.code(), new Response()
public String extractOperationMethod(ApiOperation apiOperation, Method method) { if (apiOperation.httpMethod() != null && !"".equals(apiOperation.httpMethod())) { return apiOperation.httpMethod().toLowerCase(); } else if (method.getAnnotation(javax.ws.rs.GET.class) != null) { return "get"; } else if (method.getAnnotation(javax.ws.rs.PUT.class) != null) { return "put"; } else if (method.getAnnotation(javax.ws.rs.POST.class) != null) { return "post"; } else if (method.getAnnotation(javax.ws.rs.DELETE.class) != null) { return "delete"; } else if (method.getAnnotation(javax.ws.rs.OPTIONS.class) != null) { return "options"; } else if (method.getAnnotation(javax.ws.rs.HEAD.class) != null) { return "patch"; } else if (method.getAnnotation(HttpMethod.class) != null) { HttpMethod httpMethod = method.getAnnotation(HttpMethod.class); return httpMethod.value().toLowerCase(); } return "post"; }
@GET @ApiOperation(value = "List users who can access to the project") @Path("/user-access") public List<UserAccess> getUserAccess(@Named("user_id") Project project) { return service.getUserAccessForProject(project.userId, project.project); }
@GET @ApiOperation(value = "Get project configurations") @Path("/project-configuration") public ProjectConfiguration getProjectPreferences(@Named("user_id") Project project) { return service.getProjectConfigurations(project.project); }
@POST @ApiOperation(value = "Collect Bulk events", request = EventList.class, response = SuccessMessage.class, notes = "Bulk API requires master_key as api key and built for importing the data without any rate limiting unlike event/batch" + "This endpoint accepts application/json and the data format is same as event/batch. Additionally it supports application/x-rawjson for JSON dump data, application/x-ndjson for newline delimited JSON, application/avro for AVRO and text/csv for CSV formats. You need need to set 'collection' and 'master_key' query parameters if the content-type is not application/json.") @Path("/bulk") public void bulkEvents(RakamHttpRequest request) { bulkEvents(request, true); }
@ApiOperation(value = "Schema of data-sources", authorizations = @Authorization(value = "read_key")) @Path("/schema/tables") @GET public CompletableFuture<Map<String, List<String>>> schemaDatabases(@Named("project") RequestContext context) { return service.schemaDatabases(context.project); }
@ApiOperation(value = "List scenarios", authorizations = @Authorization(value = "read_key") ) @GET @Path("/list") public List<AutomationRule> listRules(@Named("project") RequestContext context) { return service.list(context.project); } }
@Path("/modules") @GET @IgnoreApi @ApiOperation(value = "List installed modules for Rakam UI", authorizations = @Authorization(value = "master_key") ) public ActiveModuleList modules() { return activeModules; }
@POST @ApiOperation(value = "Copy events directly to database", request = EventList.class, response = Integer.class) @Path("/copy") public void copyEvents(RakamHttpRequest request) { bulkEvents(request, false); }
@GET @ApiOperation(value = "List reports", authorizations = @Authorization(value = "read_key")) @Path("/list") public List<ABTestingReport> list(@Named("project") RequestContext context) { return metadata.getReports(context.project); }
@ApiOperation(value = "Get types", authorizations = @Authorization(value = "master_key") ) @GET @JsonRequest @Path("/types") public Map<String, String> getTypes() { return Arrays.stream(FieldType.values()).collect(Collectors.toMap(FieldType::name, FieldType::getPrettyName)); }
@Path("/get_online_users") @POST @JsonRequest @ApiOperation(value = "Get connected users", authorizations = @Authorization(value = "read_key") ) public CompletableFuture<Collection<Map<String, Object>>> getConnectedUsers(@Named("project") RequestContext context) { Collection<Object> connectedUsers = webSocketService.getConnectedUsers(context.project); return CompletableFuture.completedFuture(connectedUsers.stream() .map(id -> ImmutableMap.of(config.getIdentifierColumn(), id)) .collect(Collectors.toList())); }
@ApiOperation(value = "Create pre-calculate rule", authorizations = @Authorization(value = "master_key") ) @Consumes("text/event-stream") @IgnoreApi @GET @Path("/pre_calculate") public void precalculateUsers(RakamHttpRequest request) { queryService.handleServerSentQueryExecution(request, PreCalculateQuery.class, service::preCalculate, MASTER_KEY, false, Optional.empty()); }
@Path("/list") @ApiOperation(value = "Get Report", authorizations = @Authorization(value = "read_key")) @JsonRequest public List<CustomPageDatabase.Page> list(@Named("user_id") UIPermissionParameterProvider.Project project) { if (!database.isPresent()) { return null; } return database.get().list(project.project); } }
@ApiOperation(value = "List data-sources", authorizations = @Authorization(value = "master_key")) @Path("/list") @GET public CustomDataSourceService.CustomDataSourceList listDatabases(@Named("project") RequestContext context) { CustomDataSourceService.CustomDataSourceList customDataSourceList = service.listDatabases(context.project); for (CustomDataSource customDataSource : customDataSourceList.customDataSources) { customDataSource.options.setPassword(null); } return customDataSourceList; }
@ApiOperation(value = "List custom event mappers", authorizations = @Authorization(value = "master_key") ) @GET @Path("/list") @JsonRequest public List<JSEventMapperCode> list(@Named("project") RequestContext context) { return list(context.project); }