Exposing the entity that an API acts upon from API discovery
eg: dedicatePublicIpRange acts on VlanIpRange entities. So does
listVlanIpRanges,
listapisresponse: {
count: 1,
api: [
{
name: "dedicatePublicIpRange",
description: "Dedicates a Public IP range to an account",
isasync: false,
related: "listVlanIpRanges",
params: [],
response: [],
entity: "VlanIpRange"
}
]
}
}
Signed-off-by: Prasanna Santhanam <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6c60f77c
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6c60f77c
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6c60f77c
Branch: refs/heads/marvin_refactor
Commit: 6c60f77c7c61821deae65bbf31db3c66b32ab977
Parents: ac8eb3c
Author: Prasanna Santhanam <[email protected]>
Authored: Wed May 8 16:39:24 2013 +0530
Committer: Prasanna Santhanam <[email protected]>
Committed: Wed May 8 16:39:24 2013 +0530
----------------------------------------------------------------------
.../org/apache/cloudstack/api/ApiConstants.java | 1 +
.../api/response/ApiDiscoveryResponse.java | 12 +++++++++++-
.../discovery/ApiDiscoveryServiceImpl.java | 3 ++-
3 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6c60f77c/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java
b/api/src/org/apache/cloudstack/api/ApiConstants.java
index 1165c7b..99afcae 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -69,6 +69,7 @@ public class ApiConstants {
public static final String END_IP = "endip";
public static final String END_IPV6 = "endipv6";
public static final String END_PORT = "endport";
+ public static final String ENTITY = "entity";
public static final String ENTRY_TIME = "entrytime";
public static final String FETCH_LATEST = "fetchlatest";
public static final String FIRSTNAME = "firstname";
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6c60f77c/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java
----------------------------------------------------------------------
diff --git
a/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java
b/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java
index ce7eb49..42615fb 100644
---
a/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java
+++
b/plugins/api/discovery/src/org/apache/cloudstack/api/response/ApiDiscoveryResponse.java
@@ -50,6 +50,9 @@ public class ApiDiscoveryResponse extends BaseResponse {
@SerializedName(ApiConstants.TYPE) @Param(description="response field
type")
private String type;
+ @SerializedName(ApiConstants.ENTITY) @Param(description="the
entity/resource the API operates on")
+ private String entity;
+
public ApiDiscoveryResponse(){
params = new HashSet<ApiParameterResponse>();
apiResponse = new HashSet<ApiResponseResponse>();
@@ -84,7 +87,6 @@ public class ApiDiscoveryResponse extends BaseResponse {
this.isAsync = isAsync;
}
-
public boolean getAsync() {
return isAsync;
}
@@ -112,4 +114,12 @@ public class ApiDiscoveryResponse extends BaseResponse {
public void addApiResponse(ApiResponseResponse apiResponse) {
this.apiResponse.add(apiResponse);
}
+
+ public String getEntity() {
+ return entity;
+ }
+
+ public void setEntity(String entity) {
+ this.entity = entity;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6c60f77c/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
----------------------------------------------------------------------
diff --git
a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
index 2d7dbd1..3c529ae 100755
---
a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
+++
b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java
@@ -93,7 +93,8 @@ public class ApiDiscoveryServiceImpl implements
ApiDiscoveryService {
responseApiNameListMap.get(responseName).add(apiName);
}
response.setRelated(responseName);
-
+ String entity = apiCmdAnnotation.responseObject().getSimpleName();
+ response.setEntity(entity.replaceAll("Response", ""));
Field[] responseFields =
apiCmdAnnotation.responseObject().getDeclaredFields();
for(Field responseField: responseFields) {