api_refactoring: add parameter annotation for user 'security-group'

- Add the entityType to the parameter annotation
- Annotate SecurityGroupRules response

Signed-off-by: Rohit Yadav <[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/cba97b17
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/cba97b17
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/cba97b17

Branch: refs/heads/api_refactoring
Commit: cba97b17423a8dda4e8d8b170088fe014754d283
Parents: f8a483f
Author: Likitha Shetty <[email protected]>
Authored: Mon Dec 17 09:55:52 2012 -0800
Committer: Rohit Yadav <[email protected]>
Committed: Mon Dec 17 09:57:04 2012 -0800

----------------------------------------------------------------------
 .../AuthorizeSecurityGroupEgressCmd.java           |   12 +++++-------
 .../AuthorizeSecurityGroupIngressCmd.java          |   12 +++++-------
 .../user/securitygroup/CreateSecurityGroupCmd.java |    9 ++++-----
 .../user/securitygroup/DeleteSecurityGroupCmd.java |   13 ++++++-------
 .../user/securitygroup/ListSecurityGroupsCmd.java  |    8 +++-----
 .../RevokeSecurityGroupEgressCmd.java              |    5 ++---
 .../RevokeSecurityGroupIngressCmd.java             |    5 ++---
 .../api/response/SecurityGroupRuleResponse.java    |    3 +++
 8 files changed, 30 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cba97b17/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
index 566e5c0..e5c7802 100644
--- 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupEgressCmd.java
@@ -25,10 +25,11 @@ 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;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ProjectAccountResponse;
 import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
 import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import com.cloud.async.AsyncJob;
@@ -70,19 +71,16 @@ public class AuthorizeSecurityGroupEgressCmd extends 
BaseAsyncCmd {
     @Parameter(name = ApiConstants.USER_SECURITY_GROUP_LIST, type = 
CommandType.MAP, description = "user to security group mapping")
     private Map userSecurityGroupList;
 
-    @IdentityMapper(entityTableName="domain")
-    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, 
description="an optional domainId for the security group. If the account 
parameter is used, domainId must also be used.")
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, 
description="an optional domainId for the security group. If the account 
parameter is used, domainId must also be used.", entityType = 
DomainResponse.class)
     private Long domainId;
 
     @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, 
description="an optional account for the security group. Must be used with 
domainId.")
     private String accountName;
 
-    @IdentityMapper(entityTableName="projects")
-    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, 
description="an optional project of the security group")
+    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, 
description="an optional project of the security group", 
entityType=ProjectAccountResponse.class)
     private Long projectId;
 
-    @IdentityMapper(entityTableName="security_group")
-    @Parameter(name=ApiConstants.SECURITY_GROUP_ID, type=CommandType.LONG, 
description="The ID of the security group. Mutually exclusive with 
securityGroupName parameter")
+    @Parameter(name=ApiConstants.SECURITY_GROUP_ID, type=CommandType.UUID, 
description="The ID of the security group. Mutually exclusive with 
securityGroupName parameter", entityType=SecurityGroupResponse.class)
     private Long securityGroupId;
 
     @Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, 
description="The name of the security group. Mutually exclusive with 
securityGroupName parameter")

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cba97b17/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
index b5e6aa2..ac6b6af 100644
--- 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/AuthorizeSecurityGroupIngressCmd.java
@@ -27,10 +27,11 @@ 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;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ProjectAccountResponse;
 import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
 import com.cloud.async.AsyncJob;
@@ -73,19 +74,16 @@ public class AuthorizeSecurityGroupIngressCmd extends 
BaseAsyncCmd {
     @Parameter(name = ApiConstants.USER_SECURITY_GROUP_LIST, type = 
CommandType.MAP, description = "user to security group mapping")
     private Map userSecurityGroupList;
 
-    @IdentityMapper(entityTableName="domain")
-    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, 
description="an optional domainId for the security group. If the account 
parameter is used, domainId must also be used.")
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, 
description="an optional domainId for the security group. If the account 
parameter is used, domainId must also be used.", entityType = 
DomainResponse.class)
     private Long domainId;
 
     @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, 
description="an optional account for the security group. Must be used with 
domainId.")
     private String accountName;
 
-    @IdentityMapper(entityTableName="projects")
-    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, 
description="an optional project of the security group")
+    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, 
description="an optional project of the security group", 
entityType=ProjectAccountResponse.class)
     private Long projectId;
 
-    @IdentityMapper(entityTableName="security_group")
-    @Parameter(name=ApiConstants.SECURITY_GROUP_ID, type=CommandType.LONG, 
description="The ID of the security group. Mutually exclusive with 
securityGroupName parameter")
+    @Parameter(name=ApiConstants.SECURITY_GROUP_ID, type=CommandType.UUID, 
description="The ID of the security group. Mutually exclusive with 
securityGroupName parameter", entityType=SecurityGroupResponse.class)
     private Long securityGroupId;
 
     @Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, 
description="The name of the security group. Mutually exclusive with 
securityGroupName parameter")

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cba97b17/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
index b83a972..9ea7951 100644
--- 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/CreateSecurityGroupCmd.java
@@ -20,10 +20,11 @@ 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;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ProjectAccountResponse;
 import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import com.cloud.network.security.SecurityGroup;
 import com.cloud.user.Account;
@@ -42,8 +43,7 @@ public class CreateSecurityGroupCmd extends BaseCmd {
     @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, 
description = "an optional account for the security group. Must be used with 
domainId.")
     private String accountName;
 
-    @IdentityMapper(entityTableName = "domain")
-    @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.LONG, 
description = "an optional domainId for the security group. If the account 
parameter is used, domainId must also be used.")
+    @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, 
description = "an optional domainId for the security group. If the account 
parameter is used, domainId must also be used.", entityType = 
DomainResponse.class)
     private Long domainId;
 
     @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, 
description = "the description of the security group")
@@ -52,8 +52,7 @@ public class CreateSecurityGroupCmd extends BaseCmd {
     @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = 
true, description = "name of the security group")
     private String securityGroupName;
 
-    @IdentityMapper(entityTableName = "projects")
-    @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.LONG, 
description = "Deploy vm for the project")
+    @Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, 
description = "Deploy vm for the project", 
entityType=ProjectAccountResponse.class)
     private Long projectId;
 
     // ///////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cba97b17/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
index 5ca76ef..38429ad 100644
--- 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/DeleteSecurityGroupCmd.java
@@ -20,10 +20,12 @@ 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;
+import org.apache.cloudstack.api.response.DomainResponse;
+import org.apache.cloudstack.api.response.ProjectAccountResponse;
+import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceInUseException;
@@ -41,16 +43,13 @@ public class DeleteSecurityGroupCmd extends BaseCmd {
     @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, 
description="the account of the security group. Must be specified with domain 
ID")
     private String accountName;
 
-    @IdentityMapper(entityTableName="domain")
-    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, 
description="the domain ID of account owning the security group")
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, 
description="the domain ID of account owning the security group", 
entityType=DomainResponse.class)
     private Long domainId;
 
-    @IdentityMapper(entityTableName="projects")
-    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, 
description="the project of the security group")
+    @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, 
description="the project of the security group", 
entityType=ProjectAccountResponse.class)
     private Long projectId;
 
-    @IdentityMapper(entityTableName="security_group")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="The 
ID of the security group. Mutually exclusive with name parameter")
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, description="The 
ID of the security group. Mutually exclusive with name parameter", 
entityType=SecurityGroupResponse.class)
     private Long id;
 
     @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, 
description="The ID of the security group. Mutually exclusive with id 
parameter")

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cba97b17/api/src/org/apache/cloudstack/api/command/user/securitygroup/ListSecurityGroupsCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/ListSecurityGroupsCmd.java
 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/ListSecurityGroupsCmd.java
index 3a49b26..b43dbd7 100644
--- 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/ListSecurityGroupsCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/ListSecurityGroupsCmd.java
@@ -20,11 +20,11 @@ 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.SecurityGroupResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
 
 import com.cloud.async.AsyncJob;
 
@@ -41,12 +41,10 @@ public class ListSecurityGroupsCmd extends 
BaseListTaggedResourcesCmd {
     @Parameter(name=ApiConstants.SECURITY_GROUP_NAME, type=CommandType.STRING, 
description="lists security groups by name")
     private String securityGroupName;
 
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, 
description="lists security groups by virtual machine id")
+    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, 
description="lists security groups by virtual machine id", 
entityType=UserVmResponse.class)
     private Long virtualMachineId;
 
-    @IdentityMapper(entityTableName="security_group")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list 
the security group by the id provided")
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, description="list 
the security group by the id provided", entityType=SecurityGroupResponse.class)
     private Long id;
 
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cba97b17/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupEgressCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupEgressCmd.java
 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupEgressCmd.java
index 9783218..023896b 100644
--- 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupEgressCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupEgressCmd.java
@@ -21,10 +21,10 @@ 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;
+import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import com.cloud.async.AsyncJob;
 import com.cloud.event.EventTypes;
@@ -41,8 +41,7 @@ public class RevokeSecurityGroupEgressCmd extends 
BaseAsyncCmd {
     // ////////////// API parameters /////////////////////
     // ///////////////////////////////////////////////////
 
-    @IdentityMapper(entityTableName="security_group_rule")
-    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = 
true, description = "The ID of the egress rule")
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, required = 
true, description = "The ID of the egress rule", 
entityType=SecurityGroupRuleResponse.class)
     private Long id;
 
     // ///////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cba97b17/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupIngressCmd.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupIngressCmd.java
 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupIngressCmd.java
index 34c0004..7d7d115 100644
--- 
a/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupIngressCmd.java
+++ 
b/api/src/org/apache/cloudstack/api/command/user/securitygroup/RevokeSecurityGroupIngressCmd.java
@@ -21,10 +21,10 @@ 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;
+import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
 import org.apache.cloudstack.api.response.SuccessResponse;
 import com.cloud.async.AsyncJob;
 import com.cloud.event.EventTypes;
@@ -41,8 +41,7 @@ public class RevokeSecurityGroupIngressCmd extends 
BaseAsyncCmd {
     // ////////////// API parameters /////////////////////
     // ///////////////////////////////////////////////////
 
-    @IdentityMapper(entityTableName="security_group_rule")
-    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = 
true, description = "The ID of the ingress rule")
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, required = 
true, description = "The ID of the ingress rule", 
entityType=SecurityGroupRuleResponse.class)
     private Long id;
 
     // ///////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/cba97b17/api/src/org/apache/cloudstack/api/response/SecurityGroupRuleResponse.java
----------------------------------------------------------------------
diff --git 
a/api/src/org/apache/cloudstack/api/response/SecurityGroupRuleResponse.java 
b/api/src/org/apache/cloudstack/api/response/SecurityGroupRuleResponse.java
index 206e5fb..314c2db 100644
--- a/api/src/org/apache/cloudstack/api/response/SecurityGroupRuleResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/SecurityGroupRuleResponse.java
@@ -17,10 +17,13 @@
 package org.apache.cloudstack.api.response;
 
 import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.Entity;
+import com.cloud.network.security.SecurityGroupRules;
 import com.cloud.serializer.Param;
 import com.google.gson.annotations.SerializedName;
 import org.apache.cloudstack.api.BaseResponse;
 
+@Entity(value = SecurityGroupRules.class)
 public class SecurityGroupRuleResponse extends BaseResponse {
     @SerializedName("ruleid") @Param(description="the id of the security group 
rule")
     private String ruleId;

Reply via email to