mirror of https://github.com/apache/cloudstack.git
Merge branch 'api_refactoring' of https://git-wip-us.apache.org/repos/asf/incubator-cloudstack into api_refactoring
This commit is contained in:
commit
f4a90a151f
|
|
@ -16,12 +16,12 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.vpc;
|
||||
|
||||
import org.apache.cloudstack.api.response.PrivateGatewayResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
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;
|
||||
|
|
@ -41,9 +41,8 @@ public class CreateStaticRouteCmd extends BaseAsyncCreateCmd{
|
|||
private static final String s_name = "createstaticrouteresponse";
|
||||
public static final Logger s_logger = Logger.getLogger(CreateStaticRouteCmd.class.getName());
|
||||
|
||||
@IdentityMapper(entityTableName="vpc_gateways")
|
||||
@Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.LONG, required=true,
|
||||
description="the gateway id we are creating static route for")
|
||||
@Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.UUID, entityType=PrivateGatewayResponse.class,
|
||||
required=true, description="the gateway id we are creating static route for")
|
||||
private Long gatewayId;
|
||||
|
||||
@Parameter(name = ApiConstants.CIDR, required = true, type = CommandType.STRING, description = "static route cidr")
|
||||
|
|
|
|||
|
|
@ -16,16 +16,19 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.vpc;
|
||||
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.api.response.VpcOfferingResponse;
|
||||
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.VpcResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
|
|
@ -47,17 +50,17 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{
|
|||
"Must be used with the domainId parameter.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the VPC. " +
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
|
||||
description="the domain ID associated with the VPC. " +
|
||||
"If used with the account parameter returns the VPC associated with the account for the specified domain.")
|
||||
private Long domainId;
|
||||
|
||||
@IdentityMapper(entityTableName="projects")
|
||||
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="create VPC for the project")
|
||||
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType=ProjectResponse.class,
|
||||
description="create VPC for the project")
|
||||
private Long projectId;
|
||||
|
||||
@IdentityMapper(entityTableName="data_center")
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the availability zone")
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
|
||||
required=true, description="the ID of the availability zone")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the VPC")
|
||||
|
|
@ -71,9 +74,8 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd{
|
|||
"guest networks' cidrs should be within this CIDR")
|
||||
private String cidr;
|
||||
|
||||
|
||||
@IdentityMapper(entityTableName="vpc_offerings")
|
||||
@Parameter(name=ApiConstants.VPC_OFF_ID, type=CommandType.LONG, required=true, description="the ID of the VPC offering")
|
||||
@Parameter(name=ApiConstants.VPC_OFF_ID, type=CommandType.UUID, entityType=VpcOfferingResponse.class,
|
||||
required=true, description="the ID of the VPC offering")
|
||||
private Long vpcOffering;
|
||||
|
||||
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING,
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ package org.apache.cloudstack.api.command.user.vpc;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
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.ListResponse;
|
||||
|
|
@ -40,8 +40,8 @@ public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCm
|
|||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="vpc_gateways")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list private gateway by id")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=PrivateGatewayResponse.class,
|
||||
description="list private gateway by id")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="list gateways by ip address")
|
||||
|
|
@ -50,8 +50,8 @@ public class ListPrivateGatewaysCmd extends BaseListProjectAndAccountResourcesCm
|
|||
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="list gateways by vlan")
|
||||
private String vlan;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="list gateways by vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.UUID, entityType=VpcResponse.class,
|
||||
description="list gateways by vpc")
|
||||
private Long vpcId;
|
||||
|
||||
@Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="list gateways by state")
|
||||
|
|
|
|||
|
|
@ -20,13 +20,14 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
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.PrivateGatewayResponse;
|
||||
import org.apache.cloudstack.api.response.StaticRouteResponse;
|
||||
import com.cloud.network.vpc.StaticRoute;
|
||||
import com.cloud.utils.Pair;
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
|
||||
@Implementation(description="Lists all static routes", responseObject=StaticRouteResponse.class)
|
||||
public class ListStaticRoutesCmd extends BaseListTaggedResourcesCmd {
|
||||
|
|
@ -35,16 +36,16 @@ public class ListStaticRoutesCmd extends BaseListTaggedResourcesCmd {
|
|||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="static_routes")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list static route by id")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=StaticRouteResponse.class,
|
||||
description="list static route by id")
|
||||
private Long id;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="list static routes by vpc id")
|
||||
@Parameter(name=ApiConstants.VPC_ID, type=CommandType.UUID, entityType=VpcResponse.class,
|
||||
description="list static routes by vpc id")
|
||||
private Long vpcId;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc_gateways")
|
||||
@Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.LONG, description="list static routes by gateway id")
|
||||
@Parameter(name=ApiConstants.GATEWAY_ID, type=CommandType.UUID, entityType=PrivateGatewayResponse.class,
|
||||
description="list static routes by gateway id")
|
||||
private Long gatewayId;
|
||||
|
||||
public Long getId() {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
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;
|
||||
|
|
@ -38,8 +37,8 @@ public class ListVPCOfferingsCmd extends BaseListCmd{
|
|||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="vpc_offerings")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list VPC offerings by id")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VpcOfferingResponse.class,
|
||||
description="list VPC offerings by id")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list VPC offerings by name")
|
||||
|
|
|
|||
|
|
@ -19,15 +19,17 @@ package org.apache.cloudstack.api.command.user.vpc;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.api.response.VpcOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
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.VpcResponse;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
|
||||
|
||||
|
|
@ -38,13 +40,13 @@ public class ListVPCsCmd extends BaseListTaggedResourcesCmd{
|
|||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list VPC by id")
|
||||
////////////////////////////////////////////////////
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VpcResponse.class,
|
||||
description="list VPC by id")
|
||||
private Long id;
|
||||
|
||||
@IdentityMapper(entityTableName="data_center")
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="list by zone")
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class,
|
||||
description="list by zone")
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list by name of the VPC")
|
||||
|
|
@ -58,16 +60,16 @@ public class ListVPCsCmd extends BaseListTaggedResourcesCmd{
|
|||
"guest networks' cidrs should be within this CIDR")
|
||||
private String cidr;
|
||||
|
||||
@IdentityMapper(entityTableName="vpc_offerings")
|
||||
@Parameter(name=ApiConstants.VPC_OFF_ID, type=CommandType.LONG, description="list by ID of the VPC offering")
|
||||
@Parameter(name=ApiConstants.VPC_OFF_ID, type=CommandType.UUID, entityType=VpcOfferingResponse.class
|
||||
, description="list by ID of the VPC offering")
|
||||
private Long VpcOffId;
|
||||
|
||||
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="list by account associated with the VPC. " +
|
||||
"Must be used with the domainId parameter.")
|
||||
private String accountName;
|
||||
|
||||
@IdentityMapper(entityTableName="domain")
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="list by domain ID associated with the VPC. " +
|
||||
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class,
|
||||
description="list by domain ID associated with the VPC. " +
|
||||
"If used with the account parameter returns the VPC associated with the account for the specified domain.")
|
||||
private Long domainId;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ 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;
|
||||
|
|
@ -43,8 +42,8 @@ public class RestartVPCCmd extends BaseAsyncCmd{
|
|||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id of the VPC")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VpcResponse.class,
|
||||
description="the id of the VPC")
|
||||
private Long id;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ 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;
|
||||
|
|
@ -39,8 +38,8 @@ public class UpdateVPCCmd extends BaseAsyncCmd{
|
|||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@IdentityMapper(entityTableName="vpc")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id of the VPC")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VpcResponse.class,
|
||||
description="the id of the VPC")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the VPC")
|
||||
|
|
|
|||
|
|
@ -18,11 +18,14 @@ package org.apache.cloudstack.api.response;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.vpc.StaticRoute;
|
||||
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=StaticRoute.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class StaticRouteResponse extends BaseResponse implements ControlledEntityResponse{
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the ID of static route")
|
||||
|
|
|
|||
|
|
@ -19,11 +19,14 @@ package org.apache.cloudstack.api.response;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.vpc.VpcOffering;
|
||||
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=VpcOffering.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class VpcOfferingResponse extends BaseResponse {
|
||||
@SerializedName("id") @Param(description="the id of the vpc offering")
|
||||
|
|
|
|||
|
|
@ -617,6 +617,12 @@ public class ApiDispatcher {
|
|||
case UUID:
|
||||
if (paramObj.toString().isEmpty())
|
||||
break;
|
||||
if (paramObj.toString().equals("-1")) {
|
||||
// FIXME: This is to handle a lot of hardcoded special cases where -1 is sent
|
||||
// APITODO: Find and get rid of all hardcoded params in API Cmds and service layer
|
||||
field.set(cmdObj, -1L);
|
||||
break;
|
||||
}
|
||||
// There may be multiple entities defined on the @Entity of a Response.class
|
||||
// UUID CommandType would expect only one entityType, so use the first entityType
|
||||
Class<?>[] entities = annotation.entityType()[0].getAnnotation(Entity.class).value();
|
||||
|
|
|
|||
Loading…
Reference in New Issue