api: Annotate templates apis

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
This commit is contained in:
Rohit Yadav 2012-12-23 17:17:59 -08:00
parent a5dddb4a83
commit edb42d2cbb
8 changed files with 47 additions and 37 deletions

View File

@ -22,7 +22,6 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.IdentityMapper;
import org.apache.cloudstack.api.Implementation; import org.apache.cloudstack.api.Implementation;
import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.TemplatePermissionsResponse; import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
@ -39,7 +38,6 @@ public class ListTemplateOrIsoPermissionsCmd extends BaseCmd {
//////////////// API parameters ///////////////////// //////////////// API parameters /////////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@IdentityMapper(entityTableName="vm_template")
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = TemplatePermissionsResponse.class, @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = TemplatePermissionsResponse.class,
required=true, description="the template ID") required=true, description="the template ID")
private Long id; private Long id;

View File

@ -20,8 +20,9 @@ import java.util.Date;
import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.Identity;
import com.cloud.domain.PartOf; import com.cloud.domain.PartOf;
import org.apache.cloudstack.api.InternalIdentity;
public interface Project extends PartOf, Identity { public interface Project extends PartOf, Identity, InternalIdentity {
public enum State { public enum State {
Active, Disabled, Suspended Active, Disabled, Suspended
} }

View File

@ -16,7 +16,9 @@
// under the License. // under the License.
package com.cloud.storage; package com.cloud.storage;
public interface GuestOS { import org.apache.cloudstack.api.InternalIdentity;
public interface GuestOS extends InternalIdentity {
long getId(); long getId();

View File

@ -25,12 +25,15 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseAsyncCreateCmd; import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.IdentityMapper;
import org.apache.cloudstack.api.Implementation; import org.apache.cloudstack.api.Implementation;
import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.GuestOSResponse;
import org.apache.cloudstack.api.response.SnapshotResponse;
import org.apache.cloudstack.api.response.StoragePoolResponse; import org.apache.cloudstack.api.response.StoragePoolResponse;
import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.TemplateResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.VolumeResponse;
import com.cloud.async.AsyncJob; import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes; import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.InvalidParameterValueException;
@ -68,8 +71,8 @@ import com.cloud.user.UserContext;
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the template") @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the template")
private String templateName; private String templateName;
@IdentityMapper(entityTableName="guest_os") @Parameter(name = ApiConstants.OS_TYPE_ID, type = CommandType.UUID, entityType = GuestOSResponse.class,
@Parameter(name = ApiConstants.OS_TYPE_ID, type = CommandType.LONG, required = true, description = "the ID of the OS Type that best represents the OS of this template.") required = true, description = "the ID of the OS Type that best represents the OS of this template.")
private Long osTypeId; private Long osTypeId;
@Parameter(name = ApiConstants.PASSWORD_ENABLED, type = CommandType.BOOLEAN, description = "true if the template supports the password reset feature; default is false") @Parameter(name = ApiConstants.PASSWORD_ENABLED, type = CommandType.BOOLEAN, description = "true if the template supports the password reset feature; default is false")
@ -78,16 +81,16 @@ import com.cloud.user.UserContext;
@Parameter(name = ApiConstants.REQUIRES_HVM, type = CommandType.BOOLEAN, description = "true if the template requres HVM, false otherwise") @Parameter(name = ApiConstants.REQUIRES_HVM, type = CommandType.BOOLEAN, description = "true if the template requres HVM, false otherwise")
private Boolean requiresHvm; private Boolean requiresHvm;
@IdentityMapper(entityTableName="snapshots") @Parameter(name = ApiConstants.SNAPSHOT_ID, type = CommandType.UUID, entityType = SnapshotResponse.class,
@Parameter(name = ApiConstants.SNAPSHOT_ID, type = CommandType.LONG, description = "the ID of the snapshot the template is being created from. Either this parameter, or volumeId has to be passed in") description = "the ID of the snapshot the template is being created from. Either this parameter, or volumeId has to be passed in")
private Long snapshotId; private Long snapshotId;
@IdentityMapper(entityTableName="volumes") @Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.UUID, entityType = VolumeResponse.class,
@Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.LONG, description = "the ID of the disk volume the template is being created from. Either this parameter, or snapshotId has to be passed in") description = "the ID of the disk volume the template is being created from. Either this parameter, or snapshotId has to be passed in")
private Long volumeId; private Long volumeId;
@IdentityMapper(entityTableName="vm_instance") @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType = UserVmResponse.class,
@Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, description="Optional, VM ID. If this presents, it is going to create a baremetal template for VM this ID refers to. This is only for VM whose hypervisor type is BareMetal") description="Optional, VM ID. If this presents, it is going to create a baremetal template for VM this ID refers to. This is only for VM whose hypervisor type is BareMetal")
private Long vmId; private Long vmId;
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="Optional, only for baremetal hypervisor. The directory name where template stored on CIFS server") @Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="Optional, only for baremetal hypervisor. The directory name where template stored on CIFS server")

View File

@ -16,12 +16,13 @@
// under the License. // under the License.
package org.apache.cloudstack.api.command.user.template; package org.apache.cloudstack.api.command.user.template;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.IdentityMapper;
import org.apache.cloudstack.api.Implementation; import org.apache.cloudstack.api.Implementation;
import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.ServerApiException;
@ -41,12 +42,12 @@ public class DeleteTemplateCmd extends BaseAsyncCmd {
//////////////// API parameters ///////////////////// //////////////// API parameters /////////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@IdentityMapper(entityTableName="vm_template") @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = UserVmResponse.class,
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the template") required=true, description="the ID of the template")
private Long id; private Long id;
@IdentityMapper(entityTableName="data_center") @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the ID of zone of the template") description="the ID of zone of the template")
private Long zoneId; private Long zoneId;

View File

@ -16,12 +16,13 @@
// under the License. // under the License.
package org.apache.cloudstack.api.command.user.template; package org.apache.cloudstack.api.command.user.template;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.IdentityMapper;
import org.apache.cloudstack.api.Implementation; import org.apache.cloudstack.api.Implementation;
import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.ServerApiException;
@ -43,15 +44,15 @@ public class ExtractTemplateCmd extends BaseAsyncCmd {
//////////////// API parameters ///////////////////// //////////////// API parameters /////////////////////
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@IdentityMapper(entityTableName="vm_template") @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = UserVmResponse.class,
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the template") required=true, description="the ID of the template")
private Long id; private Long id;
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=false, description="the url to which the ISO would be extracted") @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=false, description="the url to which the ISO would be extracted")
private String url; private String url;
@IdentityMapper(entityTableName="data_center") @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=false, description="the ID of the zone where the ISO is originally located" ) required=false, description="the ID of the zone where the ISO is originally located" )
private Long zoneId; private Long zoneId;
@Parameter(name=ApiConstants.MODE, type=CommandType.STRING, required=true, description="the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD") @Parameter(name=ApiConstants.MODE, type=CommandType.STRING, required=true, description="the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD")

View File

@ -20,11 +20,12 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListTaggedResourcesCmd; import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
import org.apache.cloudstack.api.IdentityMapper;
import org.apache.cloudstack.api.Implementation; import org.apache.cloudstack.api.Implementation;
import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ListResponse;
@ -48,8 +49,8 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, description="the hypervisor for which to restrict the search") @Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, description="the hypervisor for which to restrict the search")
private String hypervisor; private String hypervisor;
@IdentityMapper(entityTableName="vm_template") @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = UserVmResponse.class,
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the template ID") description="the template ID")
private Long id; private Long id;
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the template name") @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the template name")
@ -62,8 +63,8 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
"* executable-all templates that can be used to deploy a new VM* community-templates that are public.") "* executable-all templates that can be used to deploy a new VM* community-templates that are public.")
private String templateFilter; private String templateFilter;
@IdentityMapper(entityTableName="data_center") @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="list templates by zoneId") description="list templates by zoneId")
private Long zoneId; private Long zoneId;
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
/////////////////// Accessors /////////////////////// /////////////////// Accessors ///////////////////////

View File

@ -25,12 +25,15 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.IdentityMapper;
import org.apache.cloudstack.api.Implementation; import org.apache.cloudstack.api.Implementation;
import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.GuestOSResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.TemplateResponse; import org.apache.cloudstack.api.response.TemplateResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import com.cloud.async.AsyncJob; import com.cloud.async.AsyncJob;
import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceAllocationException;
import com.cloud.template.VirtualMachineTemplate; import com.cloud.template.VirtualMachineTemplate;
@ -67,8 +70,8 @@ public class RegisterTemplateCmd extends BaseCmd {
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the template") @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the template")
private String templateName; private String templateName;
@Parameter(name=ApiConstants.OS_TYPE_ID, type=CommandType.LONG, required=true, description="the ID of the OS Type that best represents the OS of this template.") @Parameter(name=ApiConstants.OS_TYPE_ID, type=CommandType.UUID, entityType = GuestOSResponse.class,
@IdentityMapper(entityTableName="guest_os") required=true, description="the ID of the OS Type that best represents the OS of this template.")
private Long osTypeId; private Long osTypeId;
@Parameter(name=ApiConstants.PASSWORD_ENABLED, type=CommandType.BOOLEAN, description="true if the template supports the password reset feature; default is false") @Parameter(name=ApiConstants.PASSWORD_ENABLED, type=CommandType.BOOLEAN, description="true if the template supports the password reset feature; default is false")
@ -86,12 +89,12 @@ public class RegisterTemplateCmd extends BaseCmd {
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL of where the template is hosted. Possible URL include http:// and https://") @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL of where the template is hosted. Possible URL include http:// and https://")
private String url; private String url;
@IdentityMapper(entityTableName="data_center") @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the zone the template is to be hosted on") required=true, description="the ID of the zone the template is to be hosted on")
private Long zoneId; private Long zoneId;
@IdentityMapper(entityTableName="domain") @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class,
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId. If the account parameter is used, domainId must also be used.") description="an optional domainId. If the account parameter is used, domainId must also be used.")
private Long domainId; private Long domainId;
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional accountName. Must be used with domainId.") @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional accountName. Must be used with domainId.")
@ -103,8 +106,8 @@ public class RegisterTemplateCmd extends BaseCmd {
@Parameter(name=ApiConstants.TEMPLATE_TAG, type=CommandType.STRING, description="the tag for this template.") @Parameter(name=ApiConstants.TEMPLATE_TAG, type=CommandType.STRING, description="the tag for this template.")
private String templateTag; private String templateTag;
@IdentityMapper(entityTableName="projects") @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Register template for the project") description="Register template for the project")
private Long projectId; private Long projectId;
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.") @Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.")