You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ad...@apache.org on 2017/05/23 08:54:55 UTC

[1/2] ambari git commit: AMBARI-21035. Integrate ClusterService with Swagger, addendum (adoroszlai)

Repository: ambari
Updated Branches:
  refs/heads/ambari-rest-api-explorer f67879461 -> 017726319


AMBARI-21035. Integrate ClusterService with Swagger, addendum (adoroszlai)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f2cad775
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f2cad775
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f2cad775

Branch: refs/heads/ambari-rest-api-explorer
Commit: f2cad775e98e6478fcc4282a8eff1014cc00414d
Parents: f678794
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Tue May 23 10:55:13 2017 +0200
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Tue May 23 10:55:13 2017 +0200

----------------------------------------------------------------------
 .../api/services/ClusterRequestSwagger.java     | 30 ++++++++++++++
 .../server/api/services/ClusterService.java     |  2 +-
 .../server/state/ClusterHealthReport.java       | 43 +++++++++++++++-----
 3 files changed, 64 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f2cad775/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterRequestSwagger.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterRequestSwagger.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterRequestSwagger.java
new file mode 100644
index 0000000..693a462
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterRequestSwagger.java
@@ -0,0 +1,30 @@
+/*
+ * 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.server.api.services;
+
+import org.apache.ambari.server.controller.ApiModel;
+import org.apache.ambari.server.controller.ClusterRequest;
+import org.apache.ambari.server.controller.internal.ClusterResourceProvider;
+
+import io.swagger.annotations.ApiModelProperty;
+
+@SuppressWarnings("unused") // for Swagger
+public interface ClusterRequestSwagger extends ApiModel {
+  @ApiModelProperty(name = ClusterResourceProvider.RESPONSE_KEY)
+  ClusterRequest getClusterRequest();
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f2cad775/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
index 80fcd2e..f61fb2a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
@@ -59,7 +59,7 @@ import io.swagger.annotations.ApiResponses;
 @Api(value = "/clusters", description = "Endpoint for cluster-specific operations")
 public class ClusterService extends BaseService {
 
-  private static final String CLUSTER_REQUEST_TYPE = "org.apache.ambari.server.controller.ClusterRequest";
+  private static final String CLUSTER_REQUEST_TYPE = "org.apache.ambari.server.api.services.ClusterRequestSwagger";
   private static final String ARTIFACT_REQUEST_TYPE = "org.apache.ambari.server.controller.ClusterArtifactRequest";
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/f2cad775/ambari-server/src/main/java/org/apache/ambari/server/state/ClusterHealthReport.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ClusterHealthReport.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ClusterHealthReport.java
index 4be44c6..90dac00 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ClusterHealthReport.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ClusterHealthReport.java
@@ -20,11 +20,24 @@ package org.apache.ambari.server.state;
 
 import org.codehaus.jackson.annotate.JsonProperty;
 
+import io.swagger.annotations.ApiModelProperty;
+
 /**
  * Cluster Health Report (part of Clusters API response)
  */
 public class ClusterHealthReport {
 
+  private static final String HOST_STALE_CONFIG = "Host/stale_config";
+  private static final String HOST_MAINTENANCE_STATE = "Host/maintenance_state";
+  private static final String HOST_HOST_STATE_HEALTHY = "Host/host_state/HEALTHY";
+  private static final String HOST_HOST_STATE_UNHEALTHY = "Host/host_state/UNHEALTHY";
+  private static final String HOST_HOST_STATE_INIT = "Host/host_state/INIT";
+  private static final String HOST_HOST_STATUS_HEALTHY = "Host/host_status/HEALTHY";
+  private static final String HOST_HOST_STATUS_UNHEALTHY = "Host/host_status/UNHEALTHY";
+  private static final String HOST_HOST_STATUS_UNKNOWN = "Host/host_status/UNKNOWN";
+  private static final String HOST_HOST_STATUS_ALERT = "Host/host_status/ALERT";
+  private static final String HOST_HOST_STATE_HEARTBEAT_LOST = "Host/host_state/HEARTBEAT_LOST";
+
   private int staleConfigsHosts;
   private int maintenanceStateHosts;
 
@@ -41,7 +54,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having stale_config set to true
    */
-  @JsonProperty("Host/stale_config")
+  @JsonProperty(HOST_STALE_CONFIG)
+  @ApiModelProperty(name = HOST_STALE_CONFIG)
   public int getStaleConfigsHosts() {
     return staleConfigsHosts;
   }
@@ -56,7 +70,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having maintenance state on
    */
-  @JsonProperty("Host/maintenance_state")
+  @JsonProperty(HOST_MAINTENANCE_STATE)
+  @ApiModelProperty(name = HOST_MAINTENANCE_STATE)
   public int getMaintenanceStateHosts() {
     return maintenanceStateHosts;
   }
@@ -71,7 +86,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host state HEALTHY
    */
-  @JsonProperty("Host/host_state/HEALTHY")
+  @JsonProperty(HOST_HOST_STATE_HEALTHY)
+  @ApiModelProperty(name = HOST_HOST_STATE_HEALTHY)
   public int getHealthyStateHosts() {
     return healthyStateHosts;
   }
@@ -86,7 +102,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host state UNHEALTHY
    */
-  @JsonProperty("Host/host_state/UNHEALTHY")
+  @JsonProperty(HOST_HOST_STATE_UNHEALTHY)
+  @ApiModelProperty(name = HOST_HOST_STATE_UNHEALTHY)
   public int getUnhealthyStateHosts() {
     return unhealthyStateHosts;
   }
@@ -101,7 +118,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host state INIT
    */
-  @JsonProperty("Host/host_state/INIT")
+  @JsonProperty(HOST_HOST_STATE_INIT)
+  @ApiModelProperty(name = HOST_HOST_STATE_INIT)
   public int getInitStateHosts() {
     return initStateHosts;
   }
@@ -116,7 +134,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host status HEALTHY
    */
-  @JsonProperty("Host/host_status/HEALTHY")
+  @JsonProperty(HOST_HOST_STATUS_HEALTHY)
+  @ApiModelProperty(name = HOST_HOST_STATUS_HEALTHY)
   public int getHealthyStatusHosts() {
     return healthyStatusHosts;
   }
@@ -131,7 +150,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host status UNHEALTHY
    */
-  @JsonProperty("Host/host_status/UNHEALTHY")
+  @JsonProperty(HOST_HOST_STATUS_UNHEALTHY)
+  @ApiModelProperty(name = HOST_HOST_STATUS_UNHEALTHY)
   public int getUnhealthyStatusHosts() {
     return unhealthyStatusHosts;
   }
@@ -146,7 +166,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host status UNKNOWN
    */
-  @JsonProperty("Host/host_status/UNKNOWN")
+  @JsonProperty(HOST_HOST_STATUS_UNKNOWN)
+  @ApiModelProperty(name = HOST_HOST_STATUS_UNKNOWN)
   public int getUnknownStatusHosts() {
     return unknownStatusHosts;
   }
@@ -161,7 +182,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host status ALERT
    */
-  @JsonProperty("Host/host_status/ALERT")
+  @JsonProperty(HOST_HOST_STATUS_ALERT)
+  @ApiModelProperty(name = HOST_HOST_STATUS_ALERT)
   public int getAlertStatusHosts() {
     return alertStatusHosts;
   }
@@ -176,7 +198,8 @@ public class ClusterHealthReport {
   /**
    * @return number of hosts having host status HEARTBEAT_LOST
    */
-  @JsonProperty("Host/host_state/HEARTBEAT_LOST")
+  @JsonProperty(HOST_HOST_STATE_HEARTBEAT_LOST)
+  @ApiModelProperty(name = HOST_HOST_STATE_HEARTBEAT_LOST)
   public int getHeartbeatLostStateHosts() {
     return heartbeatLostStateHosts;
   }


[2/2] ambari git commit: AMBARI-21063. Integrate RequestService with Swagger (Balazs Bence Sari via adoroszlai)

Posted by ad...@apache.org.
AMBARI-21063. Integrate RequestService with Swagger (Balazs Bence Sari via adoroszlai)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/01772631
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/01772631
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/01772631

Branch: refs/heads/ambari-rest-api-explorer
Commit: 017726319c77c4bc6cae86f1f1e42b1b6d4f1ce0
Parents: f2cad77
Author: Balazs Bence Sari <bs...@hortonworks.com>
Authored: Tue May 23 10:58:03 2017 +0200
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Tue May 23 10:58:03 2017 +0200

----------------------------------------------------------------------
 .../server/api/services/RequestService.java     | 105 +++++++++++++++++--
 .../server/controller/RequestPostRequest.java   |  96 +++++++++++++++++
 .../server/controller/RequestPostResponse.java  |  43 ++++++++
 .../server/controller/RequestPutRequest.java    |  33 ++++++
 .../server/controller/RequestRequest.java       |   6 ++
 .../server/controller/RequestResponse.java      | 100 ++++++++++++++++++
 .../internal/RequestResourceFilter.java         |   3 +-
 .../internal/RequestResourceProvider.java       |  66 ++++++------
 8 files changed, 409 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/01772631/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java
index 936b857..3532695 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RequestService.java
@@ -30,18 +30,35 @@ import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.controller.RequestPostResponse;
+import org.apache.ambari.server.controller.RequestResponse;
 import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.http.HttpStatus;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
 
 
 /**
  * Service responsible for request resource requests.
  */
 @Path("/requests/")
+@Api(value = "Requests", description = "Endpoint for request specific operations")
 public class RequestService extends BaseService {
+
+  private static final String REQUEST_POST_REQUEST_TYPE = "org.apache.ambari.server.controller.RequestPostRequest";
+  private static final String REQUEST_PUT_REQUEST_TYPE = "org.apache.ambari.server.controller.RequestPutRequest";
+
   /**
    * Parent cluster name.
    */
@@ -73,9 +90,23 @@ public class RequestService extends BaseService {
    */
   @GET
   @Path("{requestId}")
-  @Produces("text/plain")
+  @Produces(MediaType.TEXT_PLAIN)
+  @ApiOperation(value = "Get the details of a request",
+      nickname = "RequestService#getRequest",
+      response = RequestResponse.class)
+  @ApiImplicitParams({
+      @ApiImplicitParam(name = QUERY_FIELDS, value = QUERY_FILTER_DESCRIPTION,
+          defaultValue = "Requests/*",
+          dataType = DATA_TYPE_STRING, paramType = PARAM_TYPE_QUERY)
+  })
+  @ApiResponses(value = {
+      @ApiResponse(code = HttpStatus.SC_OK, message = MSG_SUCCESSFUL_OPERATION),
+      @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = MSG_NOT_AUTHENTICATED),
+      @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = MSG_RESOURCE_NOT_FOUND),
+      @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR)
+  })
   public Response getRequest(String body, @Context HttpHeaders headers, @Context UriInfo ui,
-                             @PathParam("requestId") String requestId) {
+                             @ApiParam @PathParam("requestId") String requestId) {
 
     return handleRequest(headers, body, ui, Request.Type.GET,
         createRequestResource(m_clusterName, requestId));
@@ -91,7 +122,27 @@ public class RequestService extends BaseService {
    * @return request collection resource representation
    */
   @GET
-  @Produces("text/plain")
+  @Produces(MediaType.TEXT_PLAIN)
+  @ApiOperation(value = "Get all requests. A predicate can be given to filter results.",
+      nickname = "RequestService#getRequests",
+      response = RequestResponse.class,
+      responseContainer = RESPONSE_CONTAINER_LIST)
+  @ApiImplicitParams({
+      @ApiImplicitParam(name = QUERY_FIELDS, value = QUERY_FILTER_DESCRIPTION,
+          defaultValue = "Requests/id",
+          dataType = DATA_TYPE_STRING, paramType = PARAM_TYPE_QUERY),
+      @ApiImplicitParam(name = QUERY_SORT, value = QUERY_SORT_DESCRIPTION,
+          defaultValue = "Requests/id.asc",
+          dataType = DATA_TYPE_STRING, paramType = PARAM_TYPE_QUERY),
+      @ApiImplicitParam(name = QUERY_PAGE_SIZE, value = QUERY_PAGE_SIZE_DESCRIPTION, defaultValue = DEFAULT_PAGE_SIZE, dataType = DATA_TYPE_INT, paramType = PARAM_TYPE_QUERY),
+      @ApiImplicitParam(name = QUERY_FROM, value = QUERY_FROM_DESCRIPTION, defaultValue = DEFAULT_FROM, dataType = DATA_TYPE_STRING, paramType = PARAM_TYPE_QUERY),
+      @ApiImplicitParam(name = QUERY_TO, value = QUERY_TO_DESCRIPTION, dataType = DATA_TYPE_STRING, paramType = PARAM_TYPE_QUERY)
+  })
+  @ApiResponses(value = {
+      @ApiResponse(code = HttpStatus.SC_OK, message = MSG_SUCCESSFUL_OPERATION),
+      @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = MSG_NOT_AUTHENTICATED),
+      @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR)
+  })
   public Response getRequests(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
     return handleRequest(headers, body, ui, Request.Type.GET,
         createRequestResource(m_clusterName, null));
@@ -101,7 +152,8 @@ public class RequestService extends BaseService {
    * Gets the stage sub-resource.
    */
   @Path("{requestId}/stages")
-  public StageService getStageHandler(@PathParam("requestId") String requestId) {
+  // TODO: find a way to handle this with Swagger (refactor or custom annotation?)
+  public StageService getStageHandler(@ApiParam @PathParam("requestId") String requestId) {
     return new StageService(m_clusterName, requestId);
   }
 
@@ -109,7 +161,8 @@ public class RequestService extends BaseService {
    * Gets the tasks sub-resource.
    */
   @Path("{requestId}/tasks")
-  public TaskService getTaskHandler(@PathParam("requestId") String requestId) {
+  // TODO: find a way to handle this with Swagger (refactor or custom annotation?)
+  public TaskService getTaskHandler(@ApiParam @PathParam("requestId") String requestId) {
     return new TaskService(m_clusterName, requestId, null);
   }
 
@@ -124,15 +177,31 @@ public class RequestService extends BaseService {
    */
   @PUT
   @Path("{requestId}")
-  @Produces("text/plain")
+  @Produces(MediaType.TEXT_PLAIN)
+  @ApiOperation(value = "Updates a request, usually used to cancel running requests.",
+      notes = "Changes the state of an existing request. Usually used to cancel running requests.",
+      nickname = "RequestService#updateRequests"
+  )
+  @ApiImplicitParams({
+      @ApiImplicitParam(dataType = REQUEST_PUT_REQUEST_TYPE, paramType = PARAM_TYPE_BODY)
+  })
+  @ApiResponses({
+      @ApiResponse(code = HttpStatus.SC_OK, message = MSG_SUCCESSFUL_OPERATION),
+      @ApiResponse(code = HttpStatus.SC_ACCEPTED, message = MSG_REQUEST_ACCEPTED),
+      @ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = MSG_INVALID_ARGUMENTS),
+      @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = MSG_RESOURCE_NOT_FOUND),
+      @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = MSG_NOT_AUTHENTICATED),
+      @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = MSG_PERMISSION_DENIED),
+      @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR),
+  })
   public Response updateRequests(String body, @Context HttpHeaders headers, @Context UriInfo ui,
-                                 @PathParam("requestId") String requestId) {
+                                 @ApiParam @PathParam("requestId") String requestId) {
     return handleRequest(headers, body, ui, Request.Type.PUT, createRequestResource(m_clusterName, requestId));
   }
 
   /**
    * Handles: POST /clusters/{clusterId}/requests or /requests
-   * Create multiple services.
+   * Create multiple requests.
    *
    * @param body        http body
    * @param headers     http headers
@@ -140,9 +209,25 @@ public class RequestService extends BaseService {
    * @return information regarding the created requests
    */
   @POST
-  @Produces("text/plain")
+  @Produces(MediaType.TEXT_PLAIN)
+  @ApiOperation(value = "Creates one or more Requests",
+      nickname = "RequestService#createRequests"
+  )
+  @ApiImplicitParams({
+      @ApiImplicitParam(dataType = REQUEST_POST_REQUEST_TYPE, paramType = PARAM_TYPE_BODY, allowMultiple = true)
+  })
+  @ApiResponses({
+      @ApiResponse(code = HttpStatus.SC_CREATED, message = MSG_SUCCESSFUL_OPERATION),
+      @ApiResponse(code = HttpStatus.SC_ACCEPTED, message = MSG_REQUEST_ACCEPTED,
+          response = RequestPostResponse.class),
+      @ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = MSG_INVALID_ARGUMENTS),
+      @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = MSG_RESOURCE_NOT_FOUND),
+      @ApiResponse(code = HttpStatus.SC_CONFLICT, message = MSG_RESOURCE_ALREADY_EXISTS),
+      @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = MSG_NOT_AUTHENTICATED),
+      @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = MSG_PERMISSION_DENIED),
+      @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR),
+  })
   public Response createRequests(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
-
     return handleRequest(headers, body, ui, Request.Type.POST, createRequestResource(m_clusterName, null));
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/01772631/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPostRequest.java
new file mode 100644
index 0000000..fa7799e
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPostRequest.java
@@ -0,0 +1,96 @@
+/**
+ * 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.server.controller;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ambari.server.controller.internal.RequestResourceProvider;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * Request schema for endpoint {@link org.apache.ambari.server.api.services.RequestService#createRequests(String,
+ *    javax.ws.rs.core.HttpHeaders, javax.ws.rs.core.UriInfo)}
+ *
+ * The interface is not actually implemented, it only carries swagger annotations.
+ */
+public interface RequestPostRequest extends ApiModel {
+
+  String NOTES_ACTION_OR_COMMAND = "Either action or command must be specified, but not both";
+
+  @ApiModelProperty(name = RequestResourceProvider.REQUEST_INFO)
+  RequestInfo getRequestInfo();
+
+  @ApiModelProperty(name = "Body")
+  Body getBody();
+
+  interface RequestInfo {
+    @ApiModelProperty(name = RequestResourceProvider.ACTION_ID, notes = NOTES_ACTION_OR_COMMAND)
+    String getAction();
+
+    @ApiModelProperty(name = RequestResourceProvider.COMMAND_ID, notes = NOTES_ACTION_OR_COMMAND)
+    String getCommand();
+
+    @ApiModelProperty(name = "operation_level",
+        notes = "Must be specified along with command.")
+    OperationLevel getOperationLevel();
+
+    @ApiModelProperty(name = "parameters")
+    Map<String, Object> getParameters();
+  }
+
+  interface RequestResourceFilter {
+    @ApiModelProperty(name = "service_name")
+    String getServiceName();
+
+    @ApiModelProperty(name = "component_name")
+    String getComponentName();
+
+    @ApiModelProperty(name = "hosts")
+    String getHosts();
+
+    @ApiModelProperty(name = "hosts_predicate")
+    String getHostsPredicate();
+  }
+
+  interface OperationLevel {
+    @ApiModelProperty(name = "level")
+    String getLevel();
+
+    @ApiModelProperty(name = "cluster_name")
+    String getClusterName();
+  }
+
+  interface Body {
+    @ApiModelProperty(name = RequestResourceProvider.REQUESTS)
+    Request getRequest();
+  }
+
+  interface Request {
+    @ApiModelProperty(name = "resource_filters")
+    List<RequestResourceFilter> getResourceFilters();
+
+    @ApiModelProperty(name = "cluster_name")
+    String getClusterName();
+
+    @ApiModelProperty(name = "exclusive")
+    boolean isExclusive();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/01772631/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPostResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPostResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPostResponse.java
new file mode 100644
index 0000000..da2731a
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPostResponse.java
@@ -0,0 +1,43 @@
+/**
+ * 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.server.controller;
+
+import org.apache.ambari.server.controller.internal.RequestResourceProvider;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * Response schema for endpoint {@link org.apache.ambari.server.api.services.RequestService#createRequests(String,
+ *    javax.ws.rs.core.HttpHeaders, javax.ws.rs.core.UriInfo)}
+ *
+ * The interface is not actually implemented, it only carries swagger annotations.
+ */
+public interface RequestPostResponse extends ApiModel {
+
+  @ApiModelProperty(name = RequestResourceProvider.REQUESTS)
+  ShortRequestInfo getShortRequestInfo();
+
+  interface ShortRequestInfo {
+    @ApiModelProperty(name = "id")
+    long getId();
+
+    @ApiModelProperty(name = "status")
+    String getStatus();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/01772631/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPutRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPutRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPutRequest.java
new file mode 100644
index 0000000..232b233
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestPutRequest.java
@@ -0,0 +1,33 @@
+/**
+ * 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.server.controller;
+
+import org.apache.ambari.server.controller.internal.RequestResourceProvider;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * Request schema for endpoint {@link org.apache.ambari.server.api.services.RequestService#updateRequests(String,
+ *    javax.ws.rs.core.HttpHeaders, javax.ws.rs.core.UriInfo, String)}
+ *
+ * The interface is not actually implemented, it only carries swagger annotations.
+ */
+public interface RequestPutRequest extends ApiModel {
+  @ApiModelProperty(name = RequestResourceProvider.REQUESTS)
+  RequestRequest getRequestRequest();
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/01772631/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestRequest.java
index db9268b..5dfc148 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestRequest.java
@@ -19,6 +19,8 @@ package org.apache.ambari.server.controller;
 
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
 
+import io.swagger.annotations.ApiModelProperty;
+
 /**
  * Encapsulates all data about update request that came to RequestResourceProvider
  */
@@ -38,10 +40,12 @@ public class RequestRequest {
   private String abortReason;
 
 
+  @ApiModelProperty(name = "request_status", notes = "Only valid value is ABORTED.")
   public HostRoleStatus getStatus() {
     return status;
   }
 
+  @ApiModelProperty(name = "cluster_name")
   public String getClusterName() {
     return clusterName;
   }
@@ -50,6 +54,7 @@ public class RequestRequest {
     this.clusterName = clusterName;
   }
 
+  @ApiModelProperty(name = "id")
   public long getRequestId() {
     return requestId;
   }
@@ -62,6 +67,7 @@ public class RequestRequest {
     this.status = status;
   }
 
+  @ApiModelProperty(name = "abort_reason")
   public String getAbortReason() {
     return abortReason;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/01772631/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestResponse.java
new file mode 100644
index 0000000..a6db34f
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestResponse.java
@@ -0,0 +1,100 @@
+/**
+ * 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.server.controller;
+
+
+import java.util.List;
+
+import org.apache.ambari.server.controller.internal.RequestResourceProvider;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * Response schema for endpoint {@link org.apache.ambari.server.api.services.RequestService#getRequest(String,
+ *    javax.ws.rs.core.HttpHeaders, javax.ws.rs.core.UriInfo, String)}
+ *
+ * The interface is not actually implemented, it only carries swagger annotations.
+ */
+public interface RequestResponse extends ApiModel {
+
+  @ApiModelProperty(name = RequestResourceProvider.REQUESTS)
+  RequestStatusInfo getRequestStatusInfo();
+
+  interface RequestStatusInfo {
+    @ApiModelProperty(name = "id")
+    String getRequestId();
+
+    @ApiModelProperty(name = "request_status")
+    String getStatus();
+
+    @ApiModelProperty(name = "aborted_task_count")
+    int getAbortedTaskCount();
+
+    @ApiModelProperty(name = "cluster_name")
+    String getClusterName();
+
+    @ApiModelProperty(name = "completed_task_count")
+    String getCompletedTaskCount();
+
+    @ApiModelProperty(name = "create_time")
+    long getCreateTime();
+
+    @ApiModelProperty(name = "start_time")
+    String getStartTime();
+
+    @ApiModelProperty(name = "end_time")
+    String getEndTime();
+
+    @ApiModelProperty(name = "exclusive")
+    boolean isExclusive();
+
+    @ApiModelProperty(name = "failed_task_count")
+    int getFailedTaskCount();
+
+    @ApiModelProperty(name = "inputs")
+    String getInputs();
+
+    @ApiModelProperty(name = "operation_level")
+    String getOperationLevel();
+
+    @ApiModelProperty(name = "progress_percent")
+    double getProgressPercent();
+
+    @ApiModelProperty(name = "queued_task_count")
+    int getQueuedTaskCount();
+
+    @ApiModelProperty(name = "request_context")
+    String getRequestContext();
+
+    @ApiModelProperty(name = "request_schedule")
+    String getRequestSchedule();
+
+    @ApiModelProperty(name = "request_schedule_id")
+    long getRequestScheduleId();
+
+    @ApiModelProperty(name = "resource_filters")
+    List<RequestPostRequest.RequestResourceFilter> getResourceFilters();
+
+    @ApiModelProperty(name = "task_count")
+    int getTaskCount();
+
+    @ApiModelProperty(name = "type")
+    String getType();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/01772631/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceFilter.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceFilter.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceFilter.java
index 4028e35..2c68a6c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceFilter.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceFilter.java
@@ -20,10 +20,11 @@ package org.apache.ambari.server.controller.internal;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.ambari.server.controller.ApiModel;
 import org.codehaus.jackson.annotate.JsonProperty;
 import org.codehaus.jackson.map.annotate.JsonSerialize;
 
-public class RequestResourceFilter {
+public class RequestResourceFilter implements ApiModel {
   private String serviceName;
   private String componentName;
   private final List<String> hostNames = new ArrayList<>();

http://git-wip-us.apache.org/repos/asf/ambari/blob/01772631/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
index 9704b33..1fc4bd5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
@@ -91,38 +91,40 @@ public class RequestResourceProvider extends AbstractControllerResourceProvider
 
   // ----- Property ID constants ---------------------------------------------
   // Requests
-  public static final String REQUEST_CLUSTER_NAME_PROPERTY_ID = "Requests/cluster_name";
-  public static final String REQUEST_CLUSTER_ID_PROPERTY_ID = "Requests/cluster_id";
-  public static final String REQUEST_ID_PROPERTY_ID = "Requests/id";
-  protected static final String REQUEST_STATUS_PROPERTY_ID = "Requests/request_status";
-  protected static final String REQUEST_ABORT_REASON_PROPERTY_ID = "Requests/abort_reason";
-  protected static final String REQUEST_CONTEXT_ID = "Requests/request_context";
-  public static final String REQUEST_SOURCE_SCHEDULE = "Requests/request_schedule";
-  public static final String REQUEST_SOURCE_SCHEDULE_ID = "Requests/request_schedule/schedule_id";
-  public static final String REQUEST_SOURCE_SCHEDULE_HREF = "Requests/request_schedule/href";
-  protected static final String REQUEST_TYPE_ID = "Requests/type";
-  protected static final String REQUEST_INPUTS_ID = "Requests/inputs";
-  protected static final String REQUEST_RESOURCE_FILTER_ID = "Requests/resource_filters";
-  protected static final String REQUEST_OPERATION_LEVEL_ID = "Requests/operation_level";
-  protected static final String REQUEST_CREATE_TIME_ID = "Requests/create_time";
-  protected static final String REQUEST_START_TIME_ID = "Requests/start_time";
-  protected static final String REQUEST_END_TIME_ID = "Requests/end_time";
-  protected static final String REQUEST_EXCLUSIVE_ID = "Requests/exclusive";
-  protected static final String REQUEST_TASK_CNT_ID = "Requests/task_count";
-  protected static final String REQUEST_FAILED_TASK_CNT_ID = "Requests/failed_task_count";
-  protected static final String REQUEST_ABORTED_TASK_CNT_ID = "Requests/aborted_task_count";
-  protected static final String REQUEST_TIMED_OUT_TASK_CNT_ID = "Requests/timed_out_task_count";
-  protected static final String REQUEST_COMPLETED_TASK_CNT_ID = "Requests/completed_task_count";
-  protected static final String REQUEST_QUEUED_TASK_CNT_ID = "Requests/queued_task_count";
-  protected static final String REQUEST_PROGRESS_PERCENT_ID = "Requests/progress_percent";
-  protected static final String COMMAND_ID = "command";
-  protected static final String SERVICE_ID = "service_name";
-  protected static final String COMPONENT_ID = "component_name";
-  protected static final String HOSTS_ID = "hosts"; // This is actually a list of hosts
-  protected static final String HOSTS_PREDICATE = "hosts_predicate";
-  protected static final String ACTION_ID = "action";
-  protected static final String INPUTS_ID = "parameters";
-  protected static final String EXLUSIVE_ID = "exclusive";
+  public static final String REQUESTS = "Requests";
+  public static final String REQUEST_INFO = "RequestInfo";
+  public static final String REQUEST_CLUSTER_NAME_PROPERTY_ID = REQUESTS + "/cluster_name";
+  public static final String REQUEST_CLUSTER_ID_PROPERTY_ID = REQUESTS + "/cluster_id";
+  public static final String REQUEST_ID_PROPERTY_ID = REQUESTS + "/id";
+  public static final String REQUEST_STATUS_PROPERTY_ID = REQUESTS + "/request_status";
+  public static final String REQUEST_ABORT_REASON_PROPERTY_ID = REQUESTS + "/abort_reason";
+  public static final String REQUEST_CONTEXT_ID = REQUESTS + "/request_context";
+  public static final String REQUEST_SOURCE_SCHEDULE = REQUESTS + "/request_schedule";
+  public static final String REQUEST_SOURCE_SCHEDULE_ID = REQUESTS + "/request_schedule/schedule_id";
+  public static final String REQUEST_SOURCE_SCHEDULE_HREF = REQUESTS + "/request_schedule/href";
+  public static final String REQUEST_TYPE_ID = REQUESTS + "/type";
+  public static final String REQUEST_INPUTS_ID = REQUESTS + "/inputs";
+  public static final String REQUEST_RESOURCE_FILTER_ID = REQUESTS + "/resource_filters";
+  public static final String REQUEST_OPERATION_LEVEL_ID = REQUESTS + "/operation_level";
+  public static final String REQUEST_CREATE_TIME_ID = REQUESTS + "/create_time";
+  public static final String REQUEST_START_TIME_ID = REQUESTS + "/start_time";
+  public static final String REQUEST_END_TIME_ID = REQUESTS + "/end_time";
+  public static final String REQUEST_EXCLUSIVE_ID = REQUESTS + "/exclusive";
+  public static final String REQUEST_TASK_CNT_ID = REQUESTS + "/task_count";
+  public static final String REQUEST_FAILED_TASK_CNT_ID = REQUESTS + "/failed_task_count";
+  public static final String REQUEST_ABORTED_TASK_CNT_ID = REQUESTS + "/aborted_task_count";
+  public static final String REQUEST_TIMED_OUT_TASK_CNT_ID = REQUESTS + "/timed_out_task_count";
+  public static final String REQUEST_COMPLETED_TASK_CNT_ID = REQUESTS + "/completed_task_count";
+  public static final String REQUEST_QUEUED_TASK_CNT_ID = REQUESTS + "/queued_task_count";
+  public static final String REQUEST_PROGRESS_PERCENT_ID = REQUESTS + "/progress_percent";
+  public static final String COMMAND_ID = "command";
+  public static final String SERVICE_ID = "service_name";
+  public static final String COMPONENT_ID = "component_name";
+  public static final String HOSTS_ID = "hosts"; // This is actually a list of hosts
+  public static final String HOSTS_PREDICATE = "hosts_predicate";
+  public static final String ACTION_ID = "action";
+  public static final String INPUTS_ID = "parameters";
+  public static final String EXLUSIVE_ID = "exclusive";
   private static Set<String> pkPropertyIds =
     new HashSet<>(Arrays.asList(new String[]{
       REQUEST_ID_PROPERTY_ID}));