AMBARI-18196. Generate REST API docs with Swagger for Log Search (oleewere)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/363545f5 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/363545f5 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/363545f5 Branch: refs/heads/branch-dev-logsearch Commit: 363545f5afe66f1d8f7c2d24699efb360a78edb2 Parents: 6727f22 Author: oleewere <oleew...@gmail.com> Authored: Thu Aug 18 12:15:52 2016 +0200 Committer: oleewere <oleew...@gmail.com> Committed: Thu Aug 18 12:17:22 2016 +0200 ---------------------------------------------------------------------- ambari-logsearch/ambari-logsearch-it/pom.xml | 1 + .../ambari-logsearch-portal/pom.xml | 32 +++ .../org/apache/ambari/logsearch/LogSearch.java | 39 ++- .../ambari/logsearch/doc/DocConstants.java | 135 +++++++++ .../apache/ambari/logsearch/rest/AuditREST.java | 145 ++++++++++ .../ambari/logsearch/rest/DashboardREST.java | 285 +++++++++++++++++++ .../ambari/logsearch/rest/LogFileREST.java | 20 ++ .../ambari/logsearch/rest/PublicREST.java | 6 + .../ambari/logsearch/rest/UserConfigREST.java | 21 ++ .../main/webapp/META-INF/applicationContext.xml | 16 ++ .../META-INF/security-applicationContext.xml | 3 +- .../src/main/webapp/WEB-INF/web.xml | 5 +- .../src/main/webapp/login.html | 2 +- .../src/main/webapp/scripts/App.js | 4 +- .../src/main/webapp/scripts/utils/Globals.js | 4 +- .../scripts/views/audit/AuditAggregatedView.js | 2 +- .../webapp/scripts/views/tabs/LogFileView.js | 2 +- .../main/webapp/templates/helpers/Helpers.js | 4 +- 18 files changed, 705 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-it/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-it/pom.xml b/ambari-logsearch/ambari-logsearch-it/pom.xml index 075a22a..d918c8a 100644 --- a/ambari-logsearch/ambari-logsearch-it/pom.xml +++ b/ambari-logsearch/ambari-logsearch-it/pom.xml @@ -113,6 +113,7 @@ <include>**/*Stories.java</include> <include>**/*Story.java</include> </includes> + <skip>${it.skip}</skip> </configuration> </execution> <execution> http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/pom.xml b/ambari-logsearch/ambari-logsearch-portal/pom.xml index 7a46fe5..349531e 100755 --- a/ambari-logsearch/ambari-logsearch-portal/pom.xml +++ b/ambari-logsearch/ambari-logsearch-portal/pom.xml @@ -35,6 +35,7 @@ <spring.ldap.version>2.0.4.RELEASE</spring.ldap.version> <jersey.version>1.19</jersey.version> <jetty-version>9.2.11.v20150529</jetty-version> + <swagger.version>1.5.8</swagger.version> </properties> <profiles> <!-- Dev Profile Start --> @@ -646,5 +647,36 @@ <artifactId>cglib</artifactId> <version>3.2.4</version> </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>${swagger.version}</version> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-core</artifactId> + <version>${swagger.version}</version> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-jaxrs</artifactId> + <version>${swagger.version}</version> + <exclusions> + <exclusion> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-models</artifactId> + <version>${swagger.version}</version> + </dependency> + <dependency> + <groupId>org.webjars</groupId> + <artifactId>swagger-ui</artifactId> + <version>2.1.0</version> + </dependency> </dependencies> </project> http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java index 819d3b9..d1fbcde 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/LogSearch.java @@ -19,6 +19,7 @@ package org.apache.ambari.logsearch; import java.io.IOException; +import java.net.MalformedURLException; import java.net.ServerSocket; import java.net.URI; import java.net.URISyntaxException; @@ -38,6 +39,9 @@ import org.eclipse.jetty.server.SecureRequestCustomizer; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.SslConnectionFactory; +import org.eclipse.jetty.server.handler.HandlerList; +import org.eclipse.jetty.server.handler.ResourceHandler; +import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.webapp.WebAppContext; @@ -79,14 +83,13 @@ public class LogSearch { public void run(String[] argv) throws Exception { Server server = buildSever(argv); - URI webResourceBase = findWebResourceBase(server.getClass() - .getClassLoader()); - WebAppContext context = new WebAppContext(); - context.setBaseResource(Resource.newResource(webResourceBase)); - context.setContextPath(ROOT_CONTEXT); - context.setParentLoaderPriority(true); - server.setHandler(context); + HandlerList handlers = new HandlerList(); + handlers.addHandler(createSwaggerContext()); + handlers.addHandler(createBaseWebappContext()); + + server.setHandler(handlers); server.start(); + logger .debug("============================Server Dump======================================="); logger.debug(server.dump()); @@ -95,7 +98,7 @@ public class LogSearch { ConfigUtil.initializeApplicationConfig(); server.join(); } - + public Server buildSever(String argv[]) { Server server = new Server(); ServerConnector connector = new ServerConnector(server); @@ -145,6 +148,26 @@ public class LogSearch { return server; } + private WebAppContext createBaseWebappContext() throws MalformedURLException { + URI webResourceBase = findWebResourceBase(LogSearch.class.getClassLoader()); + WebAppContext context = new WebAppContext(); + context.setBaseResource(Resource.newResource(webResourceBase)); + context.setContextPath(ROOT_CONTEXT); + context.setParentLoaderPriority(true); + return context; + } + + private ServletContextHandler createSwaggerContext() throws URISyntaxException { + ResourceHandler resourceHandler = new ResourceHandler(); + resourceHandler.setResourceBase(LogSearch.class.getClassLoader() + .getResource("META-INF/resources/webjars/swagger-ui/2.1.0") + .toURI().toString()); + ServletContextHandler context = new ServletContextHandler(); + context.setContextPath("/docs/"); + context.setHandler(resourceHandler); + return context; + } + private URI findWebResourceBase(ClassLoader classLoader) { URL fileCompleteUrl = Thread.currentThread().getContextClassLoader() .getResource(WEB_RESOURCE_FOLDER); http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java new file mode 100644 index 0000000..c1572b7 --- /dev/null +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/doc/DocConstants.java @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ambari.logsearch.doc; + +public class DocConstants { + + public class CommonDescriptions { + public static final String X_AXIS_D = ""; + public static final String Y_AXIS_D = ""; + public static final String STACK_BY_D = ""; + public static final String EXCLUDE_QUERY_D = ""; + public static final String INCLUDE_QUERY_D = ""; + public static final String MUST_BE_D = ""; + public static final String MUST_NOT_D = ""; + public static final String FROM_D = ""; + public static final String TO_D = ""; + public static final String UNIT_D = ""; + public static final String QUERY_D = ""; + public static final String COLUMN_QUERY_D = ""; + public static final String I_MESSAGE_D = ""; + public static final String G_E_MESSAGE_D = ""; + public static final String E_MESSAGE_D = ""; + public static final String IS_LAST_PAGE_D = ""; + public static final String FIELD_D = ""; + public static final String FORMAT_D = ""; + } + + public class AuditOperationDescriptions { + public static final String GET_AUDIT_SCHEMA_FIELD_LIST_OD = ""; + public static final String GET_AUDIT_LOGS_OD = ""; + public static final String GET_AUDIT_COMPONENTS_OD = ""; + public static final String GET_AUDIT_LINE_GRAPH_DATA_OD = ""; + public static final String GET_TOP_AUDIT_USERS_OD = ""; + public static final String GET_TOP_AUDIT_RESOURCES_OD = ""; + public static final String GET_TOP_AUDIT_COMPONENTS_OD = ""; + public static final String GET_LIVE_LOGS_COUNT_OD = ""; + public static final String GET_REQUEST_USER_LINE_GRAPH_OD = ""; + public static final String GET_ANY_GRAPH_DATA_OD = ""; + public static final String EXPORT_USER_TALBE_TO_TEXT_FILE_OD = ""; + public static final String GET_SERVICE_LOAD_OD = ""; + } + + public class ServiceDescriptions { + public static final String LEVEL_D = ""; + public static final String ADVANCED_SEARCH_D = ""; + public static final String TREE_PARAMS_D = ""; + public static final String START_TIME_D = ""; + public static final String END_TIME_D = ""; + public static final String FILE_NAME_D = ""; + public static final String HOST_NAME_D = ""; + public static final String COMPONENT_NAME_D = ""; + public static final String FIND_D = ""; + public static final String ID_D = ""; + public static final String HOST_D = ""; + public static final String COMPONENT_D = ""; + public static final String KEYWORD_TYPE_D = ""; + public static final String TOKEN_D = ""; + public static final String SOURCE_LOG_ID_D = ""; + public static final String G_MUST_NOT_D = ""; + public static final String NUMBER_ROWS_D = ""; + public static final String SCROLL_TYPE_D = ""; + public static final String UTC_OFFSET_D = ""; + } + + public class ServiceOperationDescriptions { + public static final String SEARCH_LOGS_OD = ""; + public static final String GET_HOSTS_OD = ""; + public static final String GET_COMPONENTS_OD = ""; + public static final String GET_AGGREGATED_INFO_OD = ""; + public static final String GET_LOG_LEVELS_COUNT_OD = ""; + public static final String GET_COMPONENTS_COUNT_OD = ""; + public static final String GET_HOSTS_COUNT_OD = ""; + public static final String GET_TREE_EXTENSION_OD = ""; + public static final String GET_HISTOGRAM_DATA_OD = ""; + public static final String CANCEL_FIND_REQUEST_OD = ""; + public static final String EXPORT_TO_TEXT_FILE_OD = ""; + public static final String GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD = ""; + public static final String GET_EXTREME_DATES_FOR_BUNDLE_ID_OD = ""; + public static final String GET_SERVICE_LOGS_FIELD_NAME_OD = ""; + public static final String GET_ANY_GRAPH_DATA_OD = ""; + public static final String GET_AFTER_BEFORE_LOGS_OD = ""; + public static final String GET_HOST_LIST_BY_COMPONENT_OD = ""; + public static final String GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD = ""; + public static final String GET_HADOOP_SERVICE_CONFIG_JSON_OD = ""; + } + + + public class LogFileDescriptions { + public static final String HOST_D = ""; + public static final String COMPONENT_D = ""; + public static final String LOG_TYPE_D = ""; + } + + public class LogFileOperationDescriptions { + public static final String SEARCH_LOG_FILES_OD = ""; + public static final String GET_LOG_FILE_TAIL_OD = ""; + } + + public class PublicOperationDescriptions { + public static final String OBTAIN_GENERAL_CONFIG_OD = "Obtain general config"; + } + + public class UserConfigDescriptions { + public static final String USER_ID_D = ""; + public static final String FILTER_NAME_D = ""; + public static final String ROW_TYPE_D = ""; + } + + public class UserConfigOperationDescriptions { + public static final String SAVE_USER_CONFIG_OD = "Save user config"; + public static final String UPDATE_USER_CONFIG_OD = "Update user config"; + public static final String DELETE_USER_CONFIG_OD = "Delete user config"; + public static final String GET_USER_CONFIG_OD = "Get user config"; + public static final String GET_USER_FILTER_OD = "Get user filter"; + public static final String UPDATE_USER_FILTER_OD = "Update user filter"; + public static final String GET_USER_FILTER_BY_ID_OD = "Get user filter by id"; + public static final String GET_ALL_USER_NAMES_OD = "Get all user names"; + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditREST.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditREST.java index 6d18b4a..5ed49fd 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditREST.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/AuditREST.java @@ -26,12 +26,20 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.apache.ambari.logsearch.common.SearchCriteria; import org.apache.ambari.logsearch.manager.AuditMgr; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.*; +import static org.apache.ambari.logsearch.doc.DocConstants.AuditOperationDescriptions.*; + +@Api(value = "audit", description = "Audit operations") @Path("audit") @Component @Scope("request") @@ -43,6 +51,7 @@ public class AuditREST { @GET @Path("/getAuditSchemaFieldsName") @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_SCHEMA_FIELD_LIST_OD) public String getSolrFieldList(@Context HttpServletRequest request) { return auditMgr.getAuditLogsSchemaFieldsName(); } @@ -50,6 +59,21 @@ public class AuditREST { @GET @Path("/getAuditLogs") @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_LOGS_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = IS_LAST_PAGE_D, name = "isLastPage", dataType = "boolean", paramType = "query") + }) public String getAuditLogs(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredAuditLogsParams(request); @@ -60,6 +84,10 @@ public class AuditREST { @GET @Path("/getAuditComponents") @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_COMPONENTS_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + }) public String getAuditComponents(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); @@ -70,6 +98,21 @@ public class AuditREST { @GET @Path("/getAuditLineGraphData") @Produces({"application/json"}) + @ApiOperation(GET_AUDIT_LINE_GRAPH_DATA_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query") + }) public String getAuditLineGraphData(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredAuditLogsParams(request); @@ -80,6 +123,21 @@ public class AuditREST { @GET @Path("/getTopAuditUsers") @Produces({"application/json"}) + @ApiOperation(GET_TOP_AUDIT_USERS_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query") + }) public String getTopAuditUsers(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredAuditLogsParams(request); @@ -90,6 +148,21 @@ public class AuditREST { @GET @Path("/getTopAuditResources") @Produces({"application/json"}) + @ApiOperation(GET_TOP_AUDIT_RESOURCES_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query") + }) public String getTopAuditResources(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredAuditLogsParams(request); @@ -103,6 +176,22 @@ public class AuditREST { @GET @Path("/getTopAuditComponents") @Produces({"application/json"}) + @ApiOperation(GET_TOP_AUDIT_COMPONENTS_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query") + }) public String getTopAuditComponents(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredAuditLogsParams(request); @@ -114,6 +203,7 @@ public class AuditREST { @GET @Path("/getLiveLogsCount") @Produces({"application/json"}) + @ApiOperation(GET_LIVE_LOGS_COUNT_OD) public String getLiveLogsCount() { return auditMgr.getLiveLogCounts(); } @@ -121,6 +211,22 @@ public class AuditREST { @GET @Path("/getRequestUserLineGraph") @Produces({"application/json"}) + @ApiOperation(GET_REQUEST_USER_LINE_GRAPH_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query") + }) public String getRequestUserLineGraph(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredAuditLogsParams(request); @@ -132,6 +238,15 @@ public class AuditREST { @GET @Path("/getAnyGraphData") @Produces({"application/json"}) + @ApiOperation(GET_ANY_GRAPH_DATA_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = X_AXIS_D, name = "xAxis", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = Y_AXIS_D, name = "yAxis", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = STACK_BY_D, name = "stackBy", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query") + }) public String getAnyGraphData(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addParam("xAxis", request.getParameter("xAxis")); @@ -146,6 +261,22 @@ public class AuditREST { @GET @Path("/exportUserTableToTextFile") @Produces({"application/json"}) + @ApiOperation(EXPORT_USER_TALBE_TO_TEXT_FILE_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FIELD_D, name = "field", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FORMAT_D, name = "format", dataType = "string", paramType = "query") + }) public Response exportUserTableToTextFile(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredAuditLogsParams(request); @@ -157,6 +288,20 @@ public class AuditREST { @GET @Path("/getServiceLoad") @Produces({"application/json"}) + @ApiOperation(GET_SERVICE_LOAD_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), + }) public String getServiceLoad(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredAuditLogsParams(request); http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/DashboardREST.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/DashboardREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/DashboardREST.java index cb87f6f..0144edc 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/DashboardREST.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/DashboardREST.java @@ -25,6 +25,10 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.apache.ambari.logsearch.common.LogSearchConstants; import org.apache.ambari.logsearch.common.SearchCriteria; import org.apache.ambari.logsearch.manager.LogsMgr; @@ -37,6 +41,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import static org.apache.ambari.logsearch.doc.DocConstants.CommonDescriptions.*; +import static org.apache.ambari.logsearch.doc.DocConstants.ServiceDescriptions.*; +import static org.apache.ambari.logsearch.doc.DocConstants.ServiceOperationDescriptions.*; + +@Api(value = "dashboard", description = "Dashboard operations") @Path("dashboard") @Component @Scope("request") @@ -51,6 +60,34 @@ public class DashboardREST { @GET @Path("/solr/logs_search") @Produces({"application/json"}) + @ApiOperation(SEARCH_LOGS_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FIND_D, name = "find", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = SOURCE_LOG_ID_D, name = "sourceLogId", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = KEYWORD_TYPE_D, name = "keywordType", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TOKEN_D, name = "token", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = IS_LAST_PAGE_D, name = "isLastPage", dataType = "boolean", paramType = "query"), + @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public String searchSolrData(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredServiceLogsParams(request); @@ -70,6 +107,10 @@ public class DashboardREST { @GET @Path("/hosts") @Produces({"application/json"}) + @ApiOperation(GET_HOSTS_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query") + }) public String getHosts(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addParam("q", request.getParameter("q")); @@ -79,6 +120,10 @@ public class DashboardREST { @GET @Path("/components") @Produces({"application/json"}) + @ApiOperation(GET_COMPONENTS_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query") + }) public String getComponents(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addParam("q", request.getParameter("q")); @@ -88,6 +133,27 @@ public class DashboardREST { @GET @Path("/aggregatedData") @Produces({"application/json"}) + @ApiOperation(GET_AGGREGATED_INFO_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public String getAggregatedInfo(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(); searchCriteria.addRequiredServiceLogsParams(request); @@ -97,6 +163,12 @@ public class DashboardREST { @GET @Path("/levels_count") @Produces({"application/json"}) + @ApiOperation(GET_LOG_LEVELS_COUNT_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public VCountList getLogLevelsCount(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(); searchCriteria.addParam("q", request.getParameter("q")); @@ -109,6 +181,12 @@ public class DashboardREST { @GET @Path("/components_count") @Produces({"application/json"}) + @ApiOperation(GET_COMPONENTS_COUNT_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public VCountList getComponentsCount(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(); searchCriteria.addParam("q", request.getParameter("q")); @@ -121,6 +199,14 @@ public class DashboardREST { @GET @Path("/hosts_count") @Produces({"application/json"}) + @ApiOperation(GET_HOSTS_COUNT_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = QUERY_D, name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query") + }) public VCountList getHostsCount(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(); searchCriteria.addParam("q", request.getParameter("q")); @@ -137,6 +223,29 @@ public class DashboardREST { @GET @Path("/getTreeExtension") @Produces({"application/json"}) + @ApiOperation(GET_TREE_EXTENSION_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public VNodeList getTreeExtension(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredServiceLogsParams(request); @@ -150,6 +259,29 @@ public class DashboardREST { @GET @Path("/getLogLevelCounts") @Produces({"application/json"}) + @ApiOperation(GET_LOG_LEVELS_COUNT_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public VNameValueList getLogsLevelCount(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredServiceLogsParams(request); @@ -162,6 +294,30 @@ public class DashboardREST { @GET @Path("/getHistogramData") @Produces({"application/json"}) + @ApiOperation(GET_HISTOGRAM_DATA_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public String getHistogramData(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredServiceLogsParams(request); @@ -175,6 +331,7 @@ public class DashboardREST { @GET @Path("/cancelFindRequest") @Produces({"application/json"}) + @ApiOperation(CANCEL_FIND_REQUEST_OD) public String cancelFindRequest(@Context HttpServletRequest request) { return logMgr.cancelFindRequestByDate(request); } @@ -182,6 +339,31 @@ public class DashboardREST { @GET @Path("/exportToTextFile") @Produces({"application/json"}) + @ApiOperation(EXPORT_TO_TEXT_FILE_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FORMAT_D, name = "format", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = UTC_OFFSET_D, name = "utcOffset", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public Response exportToTextFile(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); @@ -198,6 +380,29 @@ public class DashboardREST { @GET @Path("/getHostListByComponent") @Produces({"application/json"}) + @ApiOperation(GET_HOST_LIST_BY_COMPONENT_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public String getHostListByComponent(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredServiceLogsParams(request); @@ -212,6 +417,29 @@ public class DashboardREST { @GET @Path("/getComponentListWithLevelCounts") @Produces({"application/json"}) + @ApiOperation(GET_COMPONENT_LIST_WITH_LEVEL_COUNT_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public String getComponentListWithLevelCounts( @Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); @@ -225,6 +453,7 @@ public class DashboardREST { @GET @Path("/solr/getBundleIdBoundaryDates") @Produces({"application/json"}) + @ApiOperation(GET_EXTREME_DATES_FOR_BUNDLE_ID_OD) public String getExtremeDatesForBundelId(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); @@ -238,6 +467,7 @@ public class DashboardREST { @GET @Path("/getServiceLogsFieldsName") @Produces({"application/json"}) + @ApiOperation(GET_SERVICE_LOGS_FIELD_NAME_OD) public String getServiceLogsFieldsName() { return logMgr.getServiceLogsFieldsName(); } @@ -245,6 +475,7 @@ public class DashboardREST { @GET @Path("/getServiceLogsSchemaFieldsName") @Produces({"application/json"}) + @ApiOperation(GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD) public String getServiceLogsSchemaFieldsName() { return logMgr.getServiceLogsSchemaFieldsName(); } @@ -252,6 +483,33 @@ public class DashboardREST { @GET @Path("/getAnyGraphData") @Produces({"application/json"}) + @ApiOperation(GET_ANY_GRAPH_DATA_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = X_AXIS_D, name = "xAxis", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = Y_AXIS_D, name = "yAxis", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = STACK_BY_D, name = "stackBy", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FROM_D, name = "from", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TO_D, name = "to", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = UNIT_D, name = "unit", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public String getAnyGraphData(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredServiceLogsParams(request); @@ -267,6 +525,32 @@ public class DashboardREST { @GET @Path("/getAfterBeforeLogs") @Produces({"application/json"}) + @ApiOperation(GET_AFTER_BEFORE_LOGS_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_D,name = "component", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = ID_D, name = "id", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = SCROLL_TYPE_D, name = "scrollType", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = NUMBER_ROWS_D, name = "numberRows", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = ADVANCED_SEARCH_D, name = "advancedSearch", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = QUERY_D,name = "q", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LEVEL_D, name = "level", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = TREE_PARAMS_D, name = "treeParams", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COLUMN_QUERY_D, name = "columnQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = I_MESSAGE_D, name = "iMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_E_MESSAGE_D, name = "gEMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = E_MESSAGE_D, name = "eMessage", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = G_MUST_NOT_D, name = "gMustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_BE_D, name = "mustBe", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = MUST_NOT_D, name = "mustNot", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_NAME_D, name = "host_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = COMPONENT_NAME_D, name = "component_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = FILE_NAME_D, name = "file_name", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = EXCLUDE_QUERY_D, name = "excludeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = INCLUDE_QUERY_D, name = "includeQuery", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = START_TIME_D, name = "start_time", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = END_TIME_D, name = "end_time", dataType = "string", paramType = "query") + }) public String getAfterBeforeLogs(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addRequiredServiceLogsParams(request); @@ -284,6 +568,7 @@ public class DashboardREST { @GET @Path("/getHadoopServiceConfigJSON") @Produces({"application/json"}) + @ApiOperation(GET_HADOOP_SERVICE_CONFIG_JSON_OD) public String getHadoopServiceConfigJSON() { return logMgr.getHadoopServiceConfigJSON(); } http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java index ef1bb8f..d53cff9 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/LogFileREST.java @@ -24,12 +24,20 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.apache.ambari.logsearch.common.SearchCriteria; import org.apache.ambari.logsearch.manager.LogFileMgr; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import static org.apache.ambari.logsearch.doc.DocConstants.LogFileDescriptions.*; +import static org.apache.ambari.logsearch.doc.DocConstants.LogFileOperationDescriptions.*; + +@Api(value = "logfile", description = "Logfile operations") @Path("logfile") @Component @Scope("request") @@ -40,6 +48,12 @@ public class LogFileREST { @GET @Produces({"application/json"}) + @ApiOperation(SEARCH_LOG_FILES_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LOG_TYPE_D, name = "logType", dataType = "string", paramType = "query") + }) public String searchLogFiles(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addParam("component", request.getParameter("component")); @@ -51,6 +65,12 @@ public class LogFileREST { @GET @Path("/getLogFileTail") @Produces({"application/json"}) + @ApiOperation(GET_LOG_FILE_TAIL_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = COMPONENT_D, name = "component", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = HOST_D, name = "host", dataType = "string", paramType = "query"), + @ApiImplicitParam(value = LOG_TYPE_D, name = "logType", dataType = "string", paramType = "query") + }) public String getLogFileTail(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(); searchCriteria.addParam("host", request.getParameter("host")); http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java index 7977703..af48acd 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/PublicREST.java @@ -21,11 +21,16 @@ package org.apache.ambari.logsearch.rest; import javax.ws.rs.GET; import javax.ws.rs.Path; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.apache.ambari.logsearch.manager.PublicMgr; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import static org.apache.ambari.logsearch.doc.DocConstants.PublicOperationDescriptions.OBTAIN_GENERAL_CONFIG_OD; + +@Api(value = "public", description = "Public operations") @Path("public") @Component @Scope("request") @@ -36,6 +41,7 @@ public class PublicREST { @GET @Path("/getGeneralConfig") + @ApiOperation(OBTAIN_GENERAL_CONFIG_OD) public String getGeneralConfig() { return generalMgr.getGeneralConfig(); } http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigREST.java ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigREST.java b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigREST.java index 40b215c..4b1675f 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigREST.java +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/rest/UserConfigREST.java @@ -29,6 +29,10 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; import org.apache.ambari.logsearch.common.LogSearchConstants; import org.apache.ambari.logsearch.common.SearchCriteria; import org.apache.ambari.logsearch.manager.UserConfigMgr; @@ -38,6 +42,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigDescriptions.*; +import static org.apache.ambari.logsearch.doc.DocConstants.UserConfigOperationDescriptions.*; + +@Api(value = "userconfig", description = "User config operations") @Path("userconfig") @Component @Scope("request") @@ -52,6 +60,7 @@ public class UserConfigREST { @POST @Path("/saveUserConfig") @Produces({"application/json"}) + @ApiOperation(SAVE_USER_CONFIG_OD) public String saveUserConfig(VUserConfig vhist) { return userConfigMgr.saveUserConfig(vhist); } @@ -59,12 +68,14 @@ public class UserConfigREST { @PUT @Path("/updateUserConfig") @Produces({"application/json"}) + @ApiOperation(UPDATE_USER_CONFIG_OD) public String updateUserConfig(VUserConfig vhist) { return userConfigMgr.updateUserConfig(vhist); } @DELETE @Path("/deleteUserConfig/{id}") + @ApiOperation(DELETE_USER_CONFIG_OD) public void deleteUserConfig(@PathParam("id") String id) { userConfigMgr.deleteUserConfig(id); } @@ -72,6 +83,12 @@ public class UserConfigREST { @GET @Path("/getUserConfig") @Produces({"application/json"}) + @ApiOperation(GET_USER_CONFIG_OD) + @ApiImplicitParams(value = { + @ApiImplicitParam(value = USER_ID_D, name = "userId", paramType = "query", dataType = "string"), + @ApiImplicitParam(value = FILTER_NAME_D, name = "filterName", paramType = "query", dataType = "string"), + @ApiImplicitParam(value = ROW_TYPE_D, name = "rowType", paramType = "query", dataType = "string") + }) public String getUserConfig(@Context HttpServletRequest request) { SearchCriteria searchCriteria = new SearchCriteria(request); searchCriteria.addParam(LogSearchConstants.USER_NAME, @@ -86,6 +103,7 @@ public class UserConfigREST { @GET @Path("/user_filter") @Produces({"application/json"}) + @ApiOperation(GET_USER_FILTER_OD) public String getUserFilter(@Context HttpServletRequest request) { return userConfigMgr.getUserFilter(); } @@ -93,6 +111,7 @@ public class UserConfigREST { @POST @Path("/user_filter") @Produces({"application/json"}) + @ApiOperation(UPDATE_USER_FILTER_OD) public String createUserFilter(String json) { return userConfigMgr.saveUserFiter(json); } @@ -100,6 +119,7 @@ public class UserConfigREST { @PUT @Path("/user_filter/{id}") @Produces({"application/json"}) + @ApiOperation(GET_USER_FILTER_BY_ID_OD) public String updateUserFilter(String json) { return userConfigMgr.saveUserFiter(json); } @@ -107,6 +127,7 @@ public class UserConfigREST { @GET @Path("/getAllUserName") @Produces({"application/json"}) + @ApiOperation(GET_ALL_USER_NAMES_OD) public String getAllUserName() { return userConfigMgr.getAllUserName(); } http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml index 5e24d88..f334e67 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/applicationContext.xml @@ -49,5 +49,21 @@ http://www.springframework.org/schema/util/spring-util.xsd"> </property> <property name="propertiesPersister" ref="xmlPropertyConfigurer" /> </bean> + + <bean id="host" class="java.net.InetAddress" factory-method="getLocalHost"/> + <bean id="apiListingResource" class="io.swagger.jaxrs.listing.ApiListingResource"/> + <bean id="swaggerSerializers" class="io.swagger.jaxrs.listing.SwaggerSerializers" scope="singleton"/> + <bean id="beanConfig" class="io.swagger.jaxrs.config.BeanConfig"> + <property name="schemes" value="http" /> <!-- TODO: set this from property --> + <property name="resourcePackage" value="org.apache.ambari.logsearch.rest"/> + <property name="version" value="1.0.0"/> + <property name="host" value="#{host.hostAddress}:61888"/> <!-- TODO: set port from property --> + <property name="basePath" value="/api/v1"/> + <property name="title" value="Log Search REST API"/> + <property name="description" value="Log aggregation, analysis, and visualization."/> + <property name="license" value="Apache 2.0"/> + <property name="licenseUrl" value="http://www.apache.org/licenses/LICENSE-2.0.html"/> + <property name="scan" value="true"/> + </bean> </beans> http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml index 96852b5..233fad4 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/META-INF/security-applicationContext.xml @@ -31,8 +31,9 @@ http://www.springframework.org/schema/security/spring-security-4.0.xsd"> <security:http pattern="/libs/**" security="none" /> <security:http pattern="/images/**" security="none" /> <security:http pattern="/templates/**" security="none" /> - <security:http pattern="/service/public/**" security="none" /> <security:http pattern="/favicon.ico" security="none" /> + <security:http pattern="/api/v1/public/**" security="none" /> + <security:http pattern="/api/v1/swagger.json" security="none"/> <security:http disable-url-rewriting="true" use-expressions="true" create-session="always" entry-point-ref="authenticationProcessingFilterEntryPoint"> <csrf disabled="true"/> http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml index dc8519a..aee16bf 100755 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/WEB-INF/web.xml @@ -65,8 +65,7 @@ </servlet> <servlet-mapping> <servlet-name>REST service</servlet-name> - <url-pattern>/service/*</url-pattern> + <url-pattern>/api/v1/*</url-pattern> </servlet-mapping> - - + </web-app> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/login.html ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/login.html b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/login.html index ff546ef..44f1aeb 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/login.html +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/login.html @@ -35,7 +35,7 @@ var passDiv = $('#passCont'); $.ajax({ - url : "/service/public/getGeneralConfig", + url : "/api/v1/public/getGeneralConfig", type: "GET", async: true, dataType: 'json', http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js index ef9b662..24cbd5a 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/App.js @@ -60,7 +60,7 @@ define(['backbone','utils/LangSupport', 'backbone.marionette'],function(Backbone context: this, url: tempUrl, success: function(response){ - serverUrl += "http://" + response.parameters['logsearch.server.url']+"/service/"; + serverUrl += "http://" + response.parameters['logsearch.server.url']+"/api/v1/"; }, error: function(response){ console.log("Error while getting log search server url"); @@ -70,7 +70,7 @@ define(['backbone','utils/LangSupport', 'backbone.marionette'],function(Backbone App.baseUrl = serverUrl//Utils.getLogSearchHostDetails(); } else { - App.baseUrl = "service/"; + App.baseUrl = "api/v1/"; } // Add initialize hooks http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js index 212846b..b6e8d7d 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/utils/Globals.js @@ -39,8 +39,8 @@ define(['require','App'], function(require, App){ totalCount : 50 }; - //Globals.baseURL = '../'; - Globals.baseURL = App.baseUrl; + Globals.baseURL = '../api/v1/'; + //Globals.baseURL = App.baseUrl; Globals.AppTabs = { DASHBOARD : { value:1, valStr: 'Dashboard'}, http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditAggregatedView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditAggregatedView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditAggregatedView.js index acca51c..c04aaf9 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditAggregatedView.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/audit/AuditAggregatedView.js @@ -408,7 +408,7 @@ define(['require', obj.utcOffset = moment().utcOffset(); obj.startIndex = this.topUsers.state.currentPage * this.topUsers.state.pageSize; var params = $.param(_.extend({},this.topUsers.queryParams,obj)); - var url = "service/audit/exportUserTableToTextFile?"+ params; + var url = "api/v1/audit/exportUserTableToTextFile?"+ params; window.open(url); this.onDialogClosed(); } http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js index 6932355..4af4670 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/scripts/views/tabs/LogFileView.js @@ -203,7 +203,7 @@ define(['require', // {startIndex : this.logFileCollection.state.currentPage * this.logFileCollection.state.pageSize},obj), // 'component','from','to','host','level','unit','startIndex','pageSize','format','utcOffset')); var params = $.param(_.extend({}, this.logFileCollection.queryParams, obj)); - var url = "service/dashboard/exportToTextFile?" + params; + var url = "api/v1/dashboard/exportToTextFile?" + params; window.open(url); this.onDialogClosed(); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/363545f5/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/helpers/Helpers.js ---------------------------------------------------------------------- diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/helpers/Helpers.js b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/helpers/Helpers.js index 2117aa3..f4f1d32 100644 --- a/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/helpers/Helpers.js +++ b/ambari-logsearch/ambari-logsearch-portal/src/main/webapp/templates/helpers/Helpers.js @@ -292,9 +292,9 @@ var path; if(_.has(options,'profileImageGId')){ if(_.isUndefined(size)) - path = "service/content/multimedia/image/"+options.profileImageGId; + path = "api/v1/content/multimedia/image/"+options.profileImageGId; else - path = "service/content/multimedia/image/"+options.profileImageGId+"/small"; + path = "api/v1/content/multimedia/image/"+options.profileImageGId+"/small"; }else{ path = "styles/images/s-avatar.png"; }