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:56 UTC
[2/2] ambari git commit: AMBARI-21063. Integrate RequestService with
Swagger (Balazs Bence Sari via adoroszlai)
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}));