You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2018/05/03 12:37:30 UTC

[ambari] branch trunk updated: AMBARI-23749. Support POST on all service / audit logs endpoint. (#1166)

This is an automated email from the ASF dual-hosted git repository.

oleewere pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 2ed2417  AMBARI-23749. Support POST on all service / audit logs endpoint. (#1166)
2ed2417 is described below

commit 2ed2417a5fd800e6e3ddd3e1f98d804c9732b5c7
Author: Olivér Szabó <ol...@gmail.com>
AuthorDate: Thu May 3 14:37:28 2018 +0200

    AMBARI-23749. Support POST on all service / audit logs endpoint. (#1166)
---
 .../request/impl/body/ClusterBodyRequest.java      | 42 ++++++++++++
 .../ambari/logsearch/rest/AuditLogsResource.java   | 34 +++++++++-
 .../ambari/logsearch/rest/ServiceLogsResource.java | 77 ++++++++++++++++++++--
 3 files changed, 144 insertions(+), 9 deletions(-)

diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/body/ClusterBodyRequest.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/body/ClusterBodyRequest.java
new file mode 100644
index 0000000..313d7e2
--- /dev/null
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/model/request/impl/body/ClusterBodyRequest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.model.request.impl.body;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.ambari.logsearch.common.LogSearchConstants;
+import org.apache.ambari.logsearch.model.request.ClustersParamDefinition;
+
+import javax.annotation.Nullable;
+
+public class ClusterBodyRequest implements ClustersParamDefinition {
+
+  @JsonProperty(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES)
+  @Nullable
+  private String clusters;
+
+  @Override
+  public String getClusters() {
+    return clusters;
+  }
+
+  @Override
+  public void setClusters(String clusters) {
+    this.clusters = clusters;
+  }
+}
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
index 7deb24f..c43f5bd 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/AuditLogsResource.java
@@ -43,6 +43,7 @@ import org.apache.ambari.logsearch.model.metadata.AuditFieldMetadataResponse;
 import org.apache.ambari.logsearch.model.request.impl.body.AuditBarGraphBodyRequest;
 import org.apache.ambari.logsearch.model.request.impl.body.AuditLogBodyRequest;
 import org.apache.ambari.logsearch.model.request.impl.body.AuditServiceLoadBodyRequest;
+import org.apache.ambari.logsearch.model.request.impl.body.ClusterBodyRequest;
 import org.apache.ambari.logsearch.model.request.impl.body.TopFieldAuditLogBodyRequest;
 import org.apache.ambari.logsearch.model.request.impl.body.UserExportBodyRequest;
 import org.apache.ambari.logsearch.model.request.impl.query.AuditBarGraphQueryRequest;
@@ -73,7 +74,17 @@ public class AuditLogsResource {
   @Path("/schema/fields")
   @Produces({MediaType.APPLICATION_JSON})
   @ApiOperation(GET_AUDIT_SCHEMA_FIELD_LIST_OD)
-  public AuditFieldMetadataResponse getSolrFieldList() {
+  public AuditFieldMetadataResponse getSolrFieldListGet() {
+    return auditLogsManager.getAuditLogSchemaMetadata();
+  }
+
+
+  @POST
+  @Path("/schema/fields")
+  @Consumes({MediaType.APPLICATION_JSON})
+  @Produces({MediaType.APPLICATION_JSON})
+  @ApiOperation(GET_AUDIT_SCHEMA_FIELD_LIST_OD)
+  public AuditFieldMetadataResponse getSolrFieldListPost() {
     return auditLogsManager.getAuditLogSchemaMetadata();
   }
 
@@ -104,10 +115,18 @@ public class AuditLogsResource {
   @Path("/components")
   @Produces({MediaType.APPLICATION_JSON})
   @ApiOperation(GET_AUDIT_COMPONENTS_OD)
-  public Map<String, String> getAuditComponents(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) {
+  public Map<String, String> getAuditComponentsGet(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) {
     return auditLogsManager.getAuditComponents(clusters);
   }
 
+  @POST
+  @Path("/components")
+  @Produces({MediaType.APPLICATION_JSON})
+  @ApiOperation(GET_AUDIT_COMPONENTS_OD)
+  public Map<String, String> getAuditComponentsPost(@Nullable ClusterBodyRequest clusterBodyRequest) {
+    return auditLogsManager.getAuditComponents(clusterBodyRequest != null ? clusterBodyRequest.getClusters() : null);
+  }
+
   @GET
   @Path("/bargraph")
   @Produces({MediaType.APPLICATION_JSON})
@@ -180,7 +199,16 @@ public class AuditLogsResource {
   @Path("/clusters")
   @Produces({MediaType.APPLICATION_JSON})
   @ApiOperation(GET_AUDIT_CLUSTERS_OD)
-  public List<String> getClustersForAuditLog() {
+  public List<String> getClustersForAuditLogGet() {
+    return auditLogsManager.getClusters();
+  }
+
+  @POST
+  @Path("/clusters")
+  @Produces({MediaType.APPLICATION_JSON})
+  @Consumes({MediaType.APPLICATION_JSON})
+  @ApiOperation(GET_AUDIT_CLUSTERS_OD)
+  public List<String> getClustersForAuditLogPost() {
     return auditLogsManager.getClusters();
   }
 
diff --git a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
index 8196c93..0deffa8 100644
--- a/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
+++ b/ambari-logsearch/ambari-logsearch-server/src/main/java/org/apache/ambari/logsearch/rest/ServiceLogsResource.java
@@ -41,6 +41,7 @@ import org.apache.ambari.logsearch.common.LogSearchConstants;
 import org.apache.ambari.logsearch.common.StatusMessage;
 import org.apache.ambari.logsearch.model.metadata.FieldMetadata;
 import org.apache.ambari.logsearch.model.metadata.ServiceComponentMetadataWrapper;
+import org.apache.ambari.logsearch.model.request.impl.body.ClusterBodyRequest;
 import org.apache.ambari.logsearch.model.request.impl.body.HostLogFilesBodyRequest;
 import org.apache.ambari.logsearch.model.request.impl.body.ServiceAnyGraphBodyRequest;
 import org.apache.ambari.logsearch.model.request.impl.body.ServiceGraphBodyRequest;
@@ -114,10 +115,19 @@ public class ServiceLogsResource {
   @Path("/hosts")
   @Produces({MediaType.APPLICATION_JSON})
   @ApiOperation(GET_HOSTS_OD)
-  public GroupListResponse getHosts(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) {
+  public GroupListResponse getHostsGet(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) {
     return serviceLogsManager.getHosts(clusters);
   }
 
+  @POST
+  @Path("/hosts")
+  @Consumes({MediaType.APPLICATION_JSON})
+  @Produces({MediaType.APPLICATION_JSON})
+  @ApiOperation(GET_HOSTS_OD)
+  public GroupListResponse getHostsPost(@Nullable ClusterBodyRequest clusterBodyRequest) {
+    return serviceLogsManager.getHosts(clusterBodyRequest != null ? clusterBodyRequest.getClusters() : null);
+  }
+
   @GET
   @Path("/components")
   @Produces({MediaType.APPLICATION_JSON})
@@ -126,6 +136,15 @@ public class ServiceLogsResource {
     return serviceLogsManager.getComponentMetadata(clusters);
   }
 
+  @POST
+  @Path("/components")
+  @Consumes({MediaType.APPLICATION_JSON})
+  @Produces({MediaType.APPLICATION_JSON})
+  @ApiOperation(GET_COMPONENTS_OD)
+  public ServiceComponentMetadataWrapper getComponents(@Nullable ClusterBodyRequest clusterBodyRequest) {
+    return serviceLogsManager.getComponentMetadata(clusterBodyRequest != null ? clusterBodyRequest.getClusters() : null);
+  }
+
   @GET
   @Path("/aggregated")
   @Produces({MediaType.APPLICATION_JSON})
@@ -147,18 +166,36 @@ public class ServiceLogsResource {
   @Path("/components/count")
   @Produces({MediaType.APPLICATION_JSON})
   @ApiOperation(GET_COMPONENTS_COUNT_OD)
-  public CountDataListResponse getComponentsCount(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) {
+  public CountDataListResponse getComponentsCountGet(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) {
     return serviceLogsManager.getComponentsCount(clusters);
   }
 
+  @POST
+  @Path("/components/count")
+  @Consumes({MediaType.APPLICATION_JSON})
+  @Produces({MediaType.APPLICATION_JSON})
+  @ApiOperation(GET_COMPONENTS_COUNT_OD)
+  public CountDataListResponse getComponentsCountPost(@Nullable ClusterBodyRequest clusterBodyRequest) {
+    return serviceLogsManager.getComponentsCount(clusterBodyRequest != null ? clusterBodyRequest.getClusters() : null);
+  }
+
   @GET
   @Path("/hosts/count")
   @Produces({MediaType.APPLICATION_JSON})
   @ApiOperation(GET_HOSTS_COUNT_OD)
-  public CountDataListResponse getHostsCount(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) {
+  public CountDataListResponse getHostsCountGet(@QueryParam(LogSearchConstants.REQUEST_PARAM_CLUSTER_NAMES) @Nullable String clusters) {
     return serviceLogsManager.getHostsCount(clusters);
   }
 
+  @POST
+  @Path("/hosts/count")
+  @Consumes({MediaType.APPLICATION_JSON})
+  @Produces({MediaType.APPLICATION_JSON})
+  @ApiOperation(GET_HOSTS_COUNT_OD)
+  public CountDataListResponse getHostsCountPost(@Nullable ClusterBodyRequest clusterBodyRequest) {
+    return serviceLogsManager.getHostsCount(clusterBodyRequest != null ? clusterBodyRequest.getClusters() : null);
+  }
+
   @GET
   @Path("/tree")
   @Produces({MediaType.APPLICATION_JSON})
@@ -266,7 +303,16 @@ public class ServiceLogsResource {
   @Path("/schema/fields")
   @Produces({MediaType.APPLICATION_JSON})
   @ApiOperation(GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD)
-  public List<FieldMetadata> getServiceLogsSchemaFieldsName() {
+  public List<FieldMetadata> getServiceLogsSchemaFieldsNameGet() {
+    return serviceLogsManager.getServiceLogsSchemaFieldsName();
+  }
+
+  @POST
+  @Path("/schema/fields")
+  @Consumes({MediaType.APPLICATION_JSON})
+  @Produces({MediaType.APPLICATION_JSON})
+  @ApiOperation(GET_SERVICE_LOGS_SCHEMA_FIELD_NAME_OD)
+  public List<FieldMetadata> getServiceLogsSchemaFieldsNamePost() {
     return serviceLogsManager.getServiceLogsSchemaFieldsName();
   }
 
@@ -308,7 +354,17 @@ public class ServiceLogsResource {
   @Path("/request/cancel")
   @Produces({MediaType.APPLICATION_JSON})
   @ApiOperation(REQUEST_CANCEL)
-  public String cancelRequest() {
+  public String cancelRequestGet() {
+    // TODO: create function that cancels an ongoing solr request
+    return "{\"endpoint status\": \"not supported yet\"}";
+  }
+
+  @POST
+  @Path("/request/cancel")
+  @Consumes({MediaType.APPLICATION_JSON})
+  @Produces({MediaType.APPLICATION_JSON})
+  @ApiOperation(REQUEST_CANCEL)
+  public String cancelRequestPost() {
     // TODO: create function that cancels an ongoing solr request
     return "{\"endpoint status\": \"not supported yet\"}";
   }
@@ -336,7 +392,16 @@ public class ServiceLogsResource {
   @Path("/clusters")
   @Produces({MediaType.APPLICATION_JSON})
   @ApiOperation(GET_SERVICE_CLUSTERS_OD)
-  public List<String> getClustersForServiceLog() {
+  public List<String> getClustersForServiceLogGet() {
+    return serviceLogsManager.getClusters();
+  }
+
+  @POST
+  @Path("/clusters")
+  @Consumes({MediaType.APPLICATION_JSON})
+  @Produces({MediaType.APPLICATION_JSON})
+  @ApiOperation(GET_SERVICE_CLUSTERS_OD)
+  public List<String> getClustersForServiceLogPost() {
     return serviceLogsManager.getClusters();
   }
 

-- 
To stop receiving notification emails like this one, please contact
oleewere@apache.org.