/* * Copyright 2015-2016 Red Hat, Inc. and/or its affiliates * and other contributors as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.hawkular.inventory.rest; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import java.io.InputStream; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Response; import org.hawkular.inventory.rest.json.ApiError; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; /** * @author Jirka Kremser * @since 0.2.1 */ @Path("/graph") @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) @Api(value = "/graph", description = "Retrieves whole graph in the JSON representation.", tags = "Graph") public class RestGraphSON extends RestBase { public RestGraphSON() { super("/graph".length()); } @GET @Path("/") @ApiOperation("Gets the graph.") @ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 401, message = "Unauthorized access"), @ApiResponse(code = 404, message = "Tenant doesn't exist", response = ApiError.class), @ApiResponse(code = 500, message = "Server error", response = ApiError.class) }) public Response getGraph() { String tenantId = getTenantId(); InputStream jsonStream = inventory.getGraphSON(tenantId); return Response.ok(jsonStream).build(); } }