For IntelliJ IDEA and
Android Studio


private void myMethod () {ApiOperation a =
Method method;ReflectionUtils.getAnnotation(method, ApiOperation.class)
Method method;method.getAnnotation(ApiOperation.class)
- AI code suggestions by Codota
}
@GET @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation("Get the project type by the id") @ApiResponses({ @ApiResponse(code = 200, message = "The response contains requested project type entity"), @ApiResponse(code = 404, message = "The project type with such id doesn't exist") }) public ProjectTypeDto getProjectType(@ApiParam("Project type id") @PathParam("id") String id) throws NotFoundException { return asDto(registry.getProjectType(id)); } }
@GET @Path("/{outputId}") @Timed @ApiOperation(value = "Get specific output") @Produces(MediaType.APPLICATION_JSON) @ApiResponses(value = { @ApiResponse(code = 404, message = "No such output on this node.") }) public OutputSummary get(@ApiParam(name = "outputId", value = "The id of the output we want.", required = true) @PathParam("outputId") String outputId) throws NotFoundException { checkPermission(RestPermissions.OUTPUTS_READ, outputId); final Output output = outputService.load(outputId); return OutputSummary.create(output.getId(), output.getTitle(), output.getType(), output.getCreatorUserId(), new DateTime(output.getCreatedAt()), output.getConfiguration(), output.getContentPack()); }
@DELETE @Path("/{id}") @ApiOperation("Remove organization with given id") @ApiResponses({ @ApiResponse(code = 204, message = "The organization successfully removed"), @ApiResponse(code = 500, message = "Internal server error occurred") }) public void remove(@ApiParam("Organization id") @PathParam("id") String organization) throws ServerException { organizationManager.remove(organization); }
@GET @Path("/settings") @Produces(APPLICATION_JSON) @ApiOperation(value = "Get workspace server configuration values") @ApiResponses({@ApiResponse(code = 200, message = "The response contains server settings")}) public Map<String, String> getSettings() { return ImmutableMap.of( Constants.SUPPORTED_RECIPE_TYPES, Joiner.on(",").join(workspaceManager.getSupportedRecipes())); }
@GET @Timed @Path("/{indexSetId}/reopened") @ApiOperation(value = "Get a list of reopened indices, which will not be cleaned by retention cleaning") @Produces(MediaType.APPLICATION_JSON) public ClosedIndices indexSetReopened(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) { final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId); final Set<String> reopenedIndices = indices.getReopenedIndices(indexSet).stream() .filter(index -> isPermitted(RestPermissions.INDICES_READ, index)) .collect(Collectors.toSet()); return ClosedIndices.create(reopenedIndices, reopenedIndices.size()); }
@GET @Timed @ApiOperation(value = "Get detailed API documentation of a single resource") @Produces(MediaType.APPLICATION_JSON) @Path("/{route: .+}") public Response route(@ApiParam(name = "route", value = "Route to fetch. For example /system", required = true) @PathParam("route") String route, @Context HttpHeaders httpHeaders) { final URI baseUri = RestTools.buildExternalUri(httpHeaders.getRequestHeaders(), httpConfiguration.getHttpExternalUri()).resolve(HttpConfiguration.PATH_API); return buildSuccessfulCORSResponse(generator.generateForRoute(route, baseUri.toString())); }
@PUT @Path("/{inputId}") @Timed @ApiOperation(value = "Start or restart specified input in all nodes") @ApiResponses(value = { @ApiResponse(code = 404, message = "No such input."), }) @AuditEvent(type = AuditEventTypes.MESSAGE_INPUT_START) public Map<String, Optional<InputCreated>> start(@ApiParam(name = "inputId", required = true) @PathParam("inputId") String inputId) { return getForAllNodes(remoteResource -> remoteResource.start(inputId), createRemoteInterfaceProvider(RemoteInputStatesResource.class)); }
@GET @Timed @Path("/{filterId}") @ApiOperation("Get the existing blacklist filter") @Produces(MediaType.APPLICATION_JSON) public FilterDescription get(@ApiParam(name = "filterId", required = true) @PathParam("filterId") @NotEmpty String filterId) throws org.graylog2.database.NotFoundException { return filterService.load(filterId); }
@GET @Path("adapters/{idOrName}") @ApiOperation(value = "List the given data adapter") public DataAdapterApi getAdapter(@ApiParam(name = "idOrName") @PathParam("idOrName") @NotEmpty String idOrName) { Optional<DataAdapterDto> dataAdapterDto = dbDataAdapterService.get(idOrName); if (dataAdapterDto.isPresent()) { checkPermission(RestPermissions.LOOKUP_TABLES_READ, dataAdapterDto.get().id()); return DataAdapterApi.fromDto(dataAdapterDto.get()); } throw new NotFoundException(); }
@GET @Path("/{outputId}") @Timed @ApiOperation(value = "Get specific output of a stream") @Produces(MediaType.APPLICATION_JSON) @ApiResponses(value = { @ApiResponse(code = 404, message = "No such stream/output on this node.") }) public OutputSummary get(@ApiParam(name = "streamid", value = "The id of the stream whose outputs we want.", required = true) @PathParam("streamid") String streamid, @ApiParam(name = "outputId", value = "The id of the output we want.", required = true) @PathParam("outputId") String outputId) throws NotFoundException { checkPermission(RestPermissions.STREAMS_READ, streamid); checkPermission(RestPermissions.STREAM_OUTPUTS_READ, outputId); final Output output = outputService.load(outputId); return OutputSummary.create( output.getId(), output.getTitle(), output.getType(), output.getCreatorUserId(), new DateTime(output.getCreatedAt()), output.getConfiguration(), output.getContentPack() ); }
@GET @Path("/bean/{id}") @ApiOperation(value = "Get test object by ID", notes = "No details provided") @ApiResponses({ @ApiResponse(code = 400, message = "Invalid ID", response = NotFoundModel.class), @ApiResponse(code = 404, message = "object not found")}) public Map<String, Integer> getTestBeanParams(@BeanParam TestBeanParam params, @DefaultValue("bodyParam") String testBody) throws WebApplicationException { return new HashMap<String, Integer>(); } }
@GET @Timed @Path("/name") @RequiresPermissions(RestPermissions.INDEXERCLUSTER_READ) @ApiOperation(value = "Get the cluster name") @Produces(MediaType.APPLICATION_JSON) public ClusterName clusterName() { final JsonNode health = cluster.health() .orElseThrow(() -> new InternalServerErrorException("Couldn't read Elasticsearch cluster health")); final String clusterName = health.path("cluster_name").asText("<unknown>"); return ClusterName.create(clusterName); }
@GET @Path("/{id}") @Produces(APPLICATION_JSON) @GenerateLink(rel = LINK_REL_USER) @ApiOperation("Get user by identifier") @ApiResponses({ @ApiResponse(code = 200, message = "The response contains requested user entity"), @ApiResponse(code = 404, message = "User with requested identifier not found"), @ApiResponse(code = 500, message = "Impossible to get user due to internal server error") }) public UserDto getById(@ApiParam("User identifier") @PathParam("id") String id) throws NotFoundException, ServerException { final User user = userManager.getById(id); return linksInjector.injectLinks(asDto(user), getServiceContext()); }
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("testPostWithBody") @ApiOperation(response = String.class, value = "Returns string with provided parameter") public String testPostWithBody(@ApiParam(name = "body", value = "input parameters in json form") List<ClassWithString> items) { List<String> result = Lists.newArrayList(); return String.format("Given parameters are %s", Arrays.toString(result.toArray(new String[result.size()]))); }
@GET @Path("/{indexSetId}/total") @Timed @RequiresPermissions(RestPermissions.MESSAGECOUNT_READ) @ApiOperation(value = "Total number of messages in all your indices.") @Produces(MediaType.APPLICATION_JSON) public MessageCountResponse total(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) { final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId); return MessageCountResponse.create(counts.total(indexSet)); } }
@GET @Path("/types") @Timed @ApiOperation(value = "Get all available stream types") @Produces(MediaType.APPLICATION_JSON) // TODO: Move this to a better place. This method is not related to a context that is bound to the instance of a stream. public List<StreamRuleTypeResponse> types(@ApiParam(name = "streamid", value = "The stream id this new rule belongs to.", required = true) @PathParam("streamid") String streamid) { final List<StreamRuleTypeResponse> result = new ArrayList<>(StreamRuleType.values().length); for (StreamRuleType type : StreamRuleType.values()) { result.add(StreamRuleTypeResponse.create(type.getValue(), type.name(), type.getShortDesc(), type.getLongDesc())); } return result; }
@GET @Timed @Path("/nodes/{nodeId}") @ApiOperation(value = "Information about a node.", notes = "This is returning information of a node in context to its state in the cluster. " + "Use the system API of the node itself to get system information.") @ApiResponses(value = { @ApiResponse(code = 404, message = "Node not found.") }) public NodeSummary node(@ApiParam(name = "nodeId", required = true) @PathParam("nodeId") @NotEmpty String nodeId) throws NodeNotFoundException { return nodeSummary(nodeService.byNodeId(nodeId)); }
@GET @Path("/{indexSetId}/open") @Timed @ApiOperation(value = "Get information of all open indices managed by Graylog and their shards.") @RequiresPermissions(RestPermissions.INDICES_READ) @Produces(MediaType.APPLICATION_JSON) public OpenIndicesInfo indexSetOpen(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) { final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId); final Set<IndexStatistics> indicesInfos = indices.getIndicesStats(indexSet).stream() .filter(indexStats -> isPermitted(RestPermissions.INDICES_READ, indexStats.index())) .collect(Collectors.toSet()); return getOpenIndicesInfo(indicesInfos); }
@GET @Path("{id}/stats") @Timed @ApiOperation(value = "Get index set statistics") @ApiResponses(value = { @ApiResponse(code = 403, message = "Unauthorized"), @ApiResponse(code = 404, message = "Index set not found"), }) public IndexSetStats indexSetStatistics(@ApiParam(name = "id", required = true) @PathParam("id") String id) { checkPermission(RestPermissions.INDEXSETS_READ, id); return indexSetRegistry.get(id) .map(indexSetStatsCreator::getForIndexSet) .orElseThrow(() -> new NotFoundException("Couldn't load index set with ID <" + id + ">")); }
@POST @Timed @Path("/multiple") @ApiOperation(value = "Get all metrics of all nodes in the cluster") @ApiResponses(value = { @ApiResponse(code = 400, message = "Malformed body") }) @NoAuditEvent("only used to retrieve metrics of all nodes") public Map<String, Optional<MetricsSummaryResponse>> multipleMetricsAllNodes(@ApiParam(name = "Requested metrics", required = true) @Valid @NotNull MetricsReadRequest request) throws IOException, NodeNotFoundException { return getForAllNodes(remoteMetricsResource -> remoteMetricsResource.multipleMetrics(request), createRemoteInterfaceProvider(RemoteMetricsResource.class)); } }