From 32ca9e2aa4e2265a483911ef91208d0be84f3269 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 18 Dec 2012 17:42:11 -0800 Subject: [PATCH] api: Annotate ListRoutersCmd, fix @Entity for Network,User,VPC Response Signed-off-by: Rohit Yadav --- .../command/admin/router/ListRoutersCmd.java | 33 ++++++++++--------- .../api/response/NetworkResponse.java | 3 +- .../api/response/UserVmResponse.java | 4 ++- .../cloudstack/api/response/VpcResponse.java | 3 ++ 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java index 1995384593d..334c85cfce0 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java @@ -20,13 +20,16 @@ import org.apache.log4j.Logger; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd; -import org.apache.cloudstack.api.IdentityMapper; import org.apache.cloudstack.api.Implementation; import org.apache.cloudstack.api.Parameter; - - import org.apache.cloudstack.api.response.DomainRouterResponse; +import org.apache.cloudstack.api.response.HostResponse; import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.PodResponse; +import org.apache.cloudstack.api.response.NetworkResponse; +import org.apache.cloudstack.api.response.UserVmResponse; +import org.apache.cloudstack.api.response.VpcResponse; +import org.apache.cloudstack.api.response.ZoneResponse; import com.cloud.async.AsyncJob; @@ -40,34 +43,34 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @IdentityMapper(entityTableName="host") - @Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, description="the host ID of the router") + @Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, entityType=HostResponse.class, + description="the host ID of the router") private Long hostId; - @IdentityMapper(entityTableName="vm_instance") - @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the disk router") + @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class, + description="the ID of the disk router") private Long id; @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the router") private String routerName; - @IdentityMapper(entityTableName="host_pod_ref") - @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="the Pod ID of the router") + @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class, + description="the Pod ID of the router") private Long podId; @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="the state of the router") private String state; - @IdentityMapper(entityTableName="data_center") - @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID of the router") + @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class, + description="the Zone ID of the router") private Long zoneId; - @IdentityMapper(entityTableName="networks") - @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="list by network id") + @Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.UUID, entityType=NetworkResponse.class, + description="list by network id") private Long networkId; - @IdentityMapper(entityTableName="vpc") - @Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="List networks by VPC") + @Parameter(name=ApiConstants.VPC_ID, type=CommandType.UUID, entityType=VpcResponse.class, + description="List networks by VPC") private Long vpcId; @Parameter(name=ApiConstants.FOR_VPC, type=CommandType.BOOLEAN, description="if true is passed for this parameter, list only VPC routers") diff --git a/api/src/org/apache/cloudstack/api/response/NetworkResponse.java b/api/src/org/apache/cloudstack/api/response/NetworkResponse.java index fe71371e81d..f5110c73ff6 100644 --- a/api/src/org/apache/cloudstack/api/response/NetworkResponse.java +++ b/api/src/org/apache/cloudstack/api/response/NetworkResponse.java @@ -18,6 +18,7 @@ package org.apache.cloudstack.api.response; import java.util.List; +import com.cloud.network.Network; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.Entity; @@ -26,7 +27,7 @@ import com.cloud.serializer.Param; import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") -@Entity(value = ProjectAccount.class) +@Entity(value = {Network.class, ProjectAccount.class}) public class NetworkResponse extends BaseResponse implements ControlledEntityResponse{ @SerializedName(ApiConstants.ID) @Param(description="the id of the network") diff --git a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java index bea841f5e09..767ee0f4a7e 100644 --- a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java +++ b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java @@ -20,6 +20,8 @@ import java.util.Date; import java.util.HashSet; import java.util.Set; +import com.cloud.network.router.VirtualRouter; +import com.cloud.uservm.UserVm; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseResponse; import org.apache.cloudstack.api.Entity; @@ -28,7 +30,7 @@ import com.cloud.serializer.Param; import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") -@Entity(value = VirtualMachine.class) +@Entity(value={VirtualMachine.class, UserVm.class, VirtualRouter.class}) public class UserVmResponse extends BaseResponse implements ControlledEntityResponse { @SerializedName(ApiConstants.ID) @Param(description="the ID of the virtual machine") private String id; diff --git a/api/src/org/apache/cloudstack/api/response/VpcResponse.java b/api/src/org/apache/cloudstack/api/response/VpcResponse.java index d23337f34c6..d0666f4c6cd 100644 --- a/api/src/org/apache/cloudstack/api/response/VpcResponse.java +++ b/api/src/org/apache/cloudstack/api/response/VpcResponse.java @@ -19,12 +19,15 @@ package org.apache.cloudstack.api.response; import java.util.Date; import java.util.List; +import com.cloud.network.vpc.Vpc; import org.apache.cloudstack.api.ApiConstants; import com.cloud.serializer.Param; import com.cloud.utils.IdentityProxy; import com.google.gson.annotations.SerializedName; import org.apache.cloudstack.api.BaseResponse; +import org.apache.cloudstack.api.Entity; +@Entity(value=Vpc.class) @SuppressWarnings("unused") public class VpcResponse extends BaseResponse implements ControlledEntityResponse{ @SerializedName("id") @Param(description="the id of the VPC")