api: annotating the volume related cmds

Signed-off-by: Prasanna Santhanam <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/71522b88
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/71522b88
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/71522b88

Branch: refs/heads/api_refactoring
Commit: 71522b88dc6a8ef401e4ce05638db6b0a25974ee
Parents: f4a90a1
Author: Prasanna Santhanam <[email protected]>
Authored: Fri Dec 21 15:59:13 2012 -0800
Committer: Prasanna Santhanam <[email protected]>
Committed: Fri Dec 21 15:59:44 2012 -0800

----------------------------------------------------------------------
 .../api/command/user/volume/AttachVolumeCmd.java   |   10 +++---
 .../api/command/user/volume/CreateVolumeCmd.java   |   24 +++++++-------
 .../api/command/user/volume/DeleteVolumeCmd.java   |    6 ++--
 .../api/command/user/volume/DetachVolumeCmd.java   |   10 +++---
 .../api/command/user/volume/ExtractVolumeCmd.java  |   11 ++++---
 .../api/command/user/volume/ListVolumesCmd.java    |   24 +++++++--------
 .../api/command/user/volume/MigrateVolumeCmd.java  |   10 +++---
 .../cloudstack/api/response/SnapshotResponse.java  |    2 +
 .../cloudstack/api/response/VolumeResponse.java    |    3 ++
 9 files changed, 52 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/71522b88/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java 
b/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
index 20a7628..09a2525 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
@@ -16,12 +16,12 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
 import org.apache.cloudstack.api.Implementation;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
@@ -54,12 +54,12 @@ public class AttachVolumeCmd extends BaseAsyncCmd {
                                                                     "* 9 - 
/dev/xvdj")
     private Long deviceId;
 
-    @IdentityMapper(entityTableName="volumes")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, 
description="the ID of the disk volume")
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, 
entityType=VolumeResponse.class,
+            required=true, description="the ID of the disk volume")
     private Long id;
 
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, 
required=true, description="    the ID of the virtual machine")
+    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, 
entityType=UserVmResponse.class,
+            required=true, description="    the ID of the virtual machine")
     private Long virtualMachineId;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/71522b88/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java 
b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
index a82c363..0df4a13 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
@@ -16,16 +16,15 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.cloudstack.api.response.*;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseAsyncCreateCmd;
 import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
 import org.apache.cloudstack.api.Implementation;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.VolumeResponse;
 import com.cloud.async.AsyncJob;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ResourceAllocationException;
@@ -45,16 +44,17 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
     @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, 
description="the account associated with the disk volume. Must be used with the 
domainId parameter.")
     private String accountName;
 
-    @IdentityMapper(entityTableName="projects")
-    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, 
description="the project associated with the volume. Mutually exclusive with 
account parameter")
+    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, 
entityType=ProjectResponse.class,
+            description="the project associated with the volume. Mutually 
exclusive with account parameter")
     private Long projectId;
 
-    @IdentityMapper(entityTableName="domain")
-    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, 
description="the domain ID associated with the disk offering. If used with the 
account parameter returns the disk volume associated with the account for the 
specified domain.")
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, 
entityType=DomainResponse.class,
+            description="the domain ID associated with the disk offering. If 
used with the account parameter" +
+                    " returns the disk volume associated with the account for 
the specified domain.")
     private Long domainId;
 
-    @IdentityMapper(entityTableName="disk_offering")
-    @Parameter(name=ApiConstants.DISK_OFFERING_ID,required = false, 
type=CommandType.LONG, description="the ID of the disk offering. Either 
diskOfferingId or snapshotId must be passed in.")
+    @Parameter(name=ApiConstants.DISK_OFFERING_ID,required = false, 
type=CommandType.UUID, entityType=DiskOfferingResponse.class,
+            description="the ID of the disk offering. Either diskOfferingId or 
snapshotId must be passed in.")
     private Long diskOfferingId;
 
     @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, 
description="the name of the disk volume")
@@ -63,12 +63,12 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
     @Parameter(name=ApiConstants.SIZE, type=CommandType.LONG, 
description="Arbitrary volume size")
     private Long size;
 
-    @IdentityMapper(entityTableName="snapshots")
-    @Parameter(name=ApiConstants.SNAPSHOT_ID, type=CommandType.LONG, 
description="the snapshot ID for the disk volume. Either diskOfferingId or 
snapshotId must be passed in.")
+    @Parameter(name=ApiConstants.SNAPSHOT_ID, type=CommandType.UUID, 
entityType=SnapshotResponse.class,
+            description="the snapshot ID for the disk volume. Either 
diskOfferingId or snapshotId must be passed in.")
     private Long snapshotId;
 
-    @IdentityMapper(entityTableName="data_center")
-    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, 
description="the ID of the availability zone")
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, 
entityType=ZoneResponse.class,
+            description="the ID of the availability zone")
     private Long zoneId;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/71522b88/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java 
b/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
index 4d6b606..a03be71 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/DeleteVolumeCmd.java
@@ -16,11 +16,11 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
 import org.apache.cloudstack.api.Implementation;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
@@ -39,8 +39,8 @@ public class DeleteVolumeCmd extends BaseCmd {
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
 
-    @IdentityMapper(entityTableName="volumes")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, 
description="The ID of the disk volume")
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, 
entityType=VolumeResponse.class,
+            required=true, description="The ID of the disk volume")
     private Long id;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/71522b88/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java 
b/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
index d4df445..4c85e0a 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
@@ -16,12 +16,12 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
 import org.apache.cloudstack.api.Implementation;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
@@ -42,15 +42,15 @@ public class DetachVolumeCmd extends BaseAsyncCmd {
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
 
-    @IdentityMapper(entityTableName="volumes")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the 
ID of the disk volume")
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, 
entityType=VolumeResponse.class,
+            description="the ID of the disk volume")
     private Long id;
 
     @Parameter(name=ApiConstants.DEVICE_ID, type=CommandType.LONG, 
description="the device ID on the virtual machine where volume is detached 
from")
     private Long deviceId;
 
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, 
description="the ID of the virtual machine where the volume is detached from")
+    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, 
entityType=UserVmResponse.class,
+            description="the ID of the virtual machine where the volume is 
detached from")
     private Long virtualMachineId;
 
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/71522b88/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java 
b/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java
index 39dcfe6..a268373 100644
--- 
a/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/user/volume/ExtractVolumeCmd.java
@@ -18,12 +18,13 @@ package org.apache.cloudstack.api.command.user.volume;
 
 import java.net.URISyntaxException;
 
+import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
 import org.apache.cloudstack.api.Implementation;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
@@ -46,16 +47,16 @@ public class ExtractVolumeCmd extends BaseAsyncCmd {
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
 
-    @IdentityMapper(entityTableName="volumes")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, 
description="the ID of the volume")
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, 
entityType=VolumeResponse.class,
+            required=true, description="the ID of the volume")
     private Long id;
 
 
     @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=false, 
description="the url to which the volume would be extracted")
     private String url;
 
-    @IdentityMapper(entityTableName="data_center")
-    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, 
required=true, description="the ID of the zone where the volume is located")
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, 
entityType=ZoneResponse.class,
+            required=true, description="the ID of the zone where the volume is 
located")
     private Long zoneId;
 
     @Parameter(name=ApiConstants.MODE, type=CommandType.STRING, required=true, 
description="the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD")

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/71522b88/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java 
b/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java
index 14d664e..c47e73d 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java
@@ -19,15 +19,13 @@ package org.apache.cloudstack.api.command.user.volume;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.cloudstack.api.response.*;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
-import org.apache.cloudstack.api.IdentityMapper;
 import org.apache.cloudstack.api.Implementation;
 import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.response.ListResponse;
-import org.apache.cloudstack.api.response.VolumeResponse;
 import com.cloud.async.AsyncJob;
 import com.cloud.storage.Volume;
 import com.cloud.utils.Pair;
@@ -43,30 +41,30 @@ public class ListVolumesCmd extends 
BaseListTaggedResourcesCmd {
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
 
-    @IdentityMapper(entityTableName="host")
-    @Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, 
description="list volumes on specified host")
+    @Parameter(name=ApiConstants.HOST_ID, type=CommandType.UUID, 
entityType=HostResponse.class,
+            description="list volumes on specified host")
     private Long hostId;
 
-    @IdentityMapper(entityTableName="volumes")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the 
ID of the disk volume")
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, 
entityType=VolumeResponse.class,
+            description="the ID of the disk volume")
     private Long id;
 
     @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, 
description="the name of the disk volume")
     private String volumeName;
 
-    @IdentityMapper(entityTableName="host_pod_ref")
-    @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, 
description="the pod id the disk volume belongs to")
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, 
entityType=PodResponse.class,
+            description="the pod id the disk volume belongs to")
     private Long podId;
 
     @Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, 
description="the type of disk volume")
     private String type;
 
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, 
description="the ID of the virtual machine")
+    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, 
entityType=UserVmResponse.class,
+            description="the ID of the virtual machine")
     private Long virtualMachineId;
 
-    @IdentityMapper(entityTableName="data_center")
-    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, 
description="the ID of the availability zone")
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, 
entityType=ZoneResponse.class,
+            description="the ID of the availability zone")
     private Long zoneId;
 
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/71522b88/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java 
b/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
index a1e8f35..d15379b 100644
--- 
a/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
@@ -19,10 +19,10 @@ package org.apache.cloudstack.api.command.user.volume;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
 import org.apache.cloudstack.api.Implementation;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.StoragePoolResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
@@ -38,12 +38,12 @@ public class MigrateVolumeCmd extends BaseAsyncCmd {
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
 
-    @IdentityMapper(entityTableName="volumes")
-    @Parameter(name=ApiConstants.VOLUME_ID, type=CommandType.LONG, 
required=true, description="the ID of the volume")
+    @Parameter(name=ApiConstants.VOLUME_ID, type=CommandType.UUID, 
entityType=VolumeResponse.class,
+            required=true, description="the ID of the volume")
     private Long volumeId;
 
-    @IdentityMapper(entityTableName="storage_pool")
-    @Parameter(name=ApiConstants.STORAGE_ID, type=CommandType.LONG, 
required=true, description="destination storage pool ID to migrate the volume 
to")
+    @Parameter(name=ApiConstants.STORAGE_ID, type=CommandType.UUID, 
entityType=StoragePoolResponse.class,
+            required=true, description="destination storage pool ID to migrate 
the volume to")
     private Long storageId;
 
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/71522b88/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java 
b/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java
index 1c06b0a..8f5dc20 100644
--- a/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/SnapshotResponse.java
@@ -24,7 +24,9 @@ import com.cloud.serializer.Param;
 import com.cloud.storage.Snapshot;
 import com.google.gson.annotations.SerializedName;
 import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.Entity;
 
+@Entity(value=Snapshot.class)
 @SuppressWarnings("unused")
 public class SnapshotResponse extends BaseResponse implements 
ControlledEntityResponse {
     @SerializedName(ApiConstants.ID)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/71522b88/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java 
b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
index 1c6f4f3..1b1ff14 100644
--- a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java
@@ -19,11 +19,14 @@ package org.apache.cloudstack.api.response;
 import java.util.Date;
 import java.util.List;
 
+import com.cloud.storage.Volume;
 import org.apache.cloudstack.api.ApiConstants;
 import com.cloud.serializer.Param;
 import com.google.gson.annotations.SerializedName;
 import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.Entity;
 
+@Entity(value=Volume.class)
 @SuppressWarnings("unused")
 public class VolumeResponse extends BaseResponse implements 
ControlledEntityResponse{
     @SerializedName(ApiConstants.ID)

Reply via email to