Skip to content

Commit edb42d2

Browse files
committed
api: Annotate templates apis
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
1 parent a5dddb4 commit edb42d2

8 files changed

Lines changed: 47 additions & 37 deletions

File tree

api/src/com/cloud/api/commands/ListTemplateOrIsoPermissionsCmd.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
import org.apache.cloudstack.api.ApiConstants;
2424
import org.apache.cloudstack.api.BaseCmd;
25-
import org.apache.cloudstack.api.IdentityMapper;
2625
import org.apache.cloudstack.api.Implementation;
2726
import org.apache.cloudstack.api.Parameter;
2827
import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
@@ -39,7 +38,6 @@ public class ListTemplateOrIsoPermissionsCmd extends BaseCmd {
3938
//////////////// API parameters /////////////////////
4039
/////////////////////////////////////////////////////
4140

42-
@IdentityMapper(entityTableName="vm_template")
4341
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = TemplatePermissionsResponse.class,
4442
required=true, description="the template ID")
4543
private Long id;

api/src/com/cloud/projects/Project.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020

2121
import org.apache.cloudstack.api.Identity;
2222
import com.cloud.domain.PartOf;
23+
import org.apache.cloudstack.api.InternalIdentity;
2324

24-
public interface Project extends PartOf, Identity {
25+
public interface Project extends PartOf, Identity, InternalIdentity {
2526
public enum State {
2627
Active, Disabled, Suspended
2728
}

api/src/com/cloud/storage/GuestOS.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
// under the License.
1717
package com.cloud.storage;
1818

19-
public interface GuestOS {
19+
import org.apache.cloudstack.api.InternalIdentity;
20+
21+
public interface GuestOS extends InternalIdentity {
2022

2123
long getId();
2224

api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@
2525
import org.apache.cloudstack.api.ApiConstants;
2626
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
2727
import org.apache.cloudstack.api.BaseCmd;
28-
import org.apache.cloudstack.api.IdentityMapper;
2928
import org.apache.cloudstack.api.Implementation;
3029
import org.apache.cloudstack.api.Parameter;
3130
import org.apache.cloudstack.api.ServerApiException;
31+
import org.apache.cloudstack.api.response.GuestOSResponse;
32+
import org.apache.cloudstack.api.response.SnapshotResponse;
3233
import org.apache.cloudstack.api.response.StoragePoolResponse;
3334
import org.apache.cloudstack.api.response.TemplateResponse;
35+
import org.apache.cloudstack.api.response.UserVmResponse;
36+
import org.apache.cloudstack.api.response.VolumeResponse;
3437
import com.cloud.async.AsyncJob;
3538
import com.cloud.event.EventTypes;
3639
import com.cloud.exception.InvalidParameterValueException;
@@ -68,8 +71,8 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd {
6871
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the template")
6972
private String templateName;
7073

71-
@IdentityMapper(entityTableName="guest_os")
72-
@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.")
74+
@Parameter(name = ApiConstants.OS_TYPE_ID, type = CommandType.UUID, entityType = GuestOSResponse.class,
75+
required = true, description = "the ID of the OS Type that best represents the OS of this template.")
7376
private Long osTypeId;
7477

7578
@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 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd {
7881
@Parameter(name = ApiConstants.REQUIRES_HVM, type = CommandType.BOOLEAN, description = "true if the template requres HVM, false otherwise")
7982
private Boolean requiresHvm;
8083

81-
@IdentityMapper(entityTableName="snapshots")
82-
@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")
84+
@Parameter(name = ApiConstants.SNAPSHOT_ID, type = CommandType.UUID, entityType = SnapshotResponse.class,
85+
description = "the ID of the snapshot the template is being created from. Either this parameter, or volumeId has to be passed in")
8386
private Long snapshotId;
8487

85-
@IdentityMapper(entityTableName="volumes")
86-
@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")
88+
@Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.UUID, entityType = VolumeResponse.class,
89+
description = "the ID of the disk volume the template is being created from. Either this parameter, or snapshotId has to be passed in")
8790
private Long volumeId;
8891

89-
@IdentityMapper(entityTableName="vm_instance")
90-
@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")
92+
@Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType = UserVmResponse.class,
93+
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")
9194
private Long vmId;
9295

9396
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="Optional, only for baremetal hypervisor. The directory name where template stored on CIFS server")

api/src/org/apache/cloudstack/api/command/user/template/DeleteTemplateCmd.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.template;
1818

19+
import org.apache.cloudstack.api.response.UserVmResponse;
20+
import org.apache.cloudstack.api.response.ZoneResponse;
1921
import org.apache.log4j.Logger;
2022

2123
import org.apache.cloudstack.api.ApiConstants;
2224
import org.apache.cloudstack.api.BaseAsyncCmd;
2325
import org.apache.cloudstack.api.BaseCmd;
24-
import org.apache.cloudstack.api.IdentityMapper;
2526
import org.apache.cloudstack.api.Implementation;
2627
import org.apache.cloudstack.api.Parameter;
2728
import org.apache.cloudstack.api.ServerApiException;
@@ -41,12 +42,12 @@ public class DeleteTemplateCmd extends BaseAsyncCmd {
4142
//////////////// API parameters /////////////////////
4243
/////////////////////////////////////////////////////
4344

44-
@IdentityMapper(entityTableName="vm_template")
45-
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the template")
45+
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = UserVmResponse.class,
46+
required=true, description="the ID of the template")
4647
private Long id;
4748

48-
@IdentityMapper(entityTableName="data_center")
49-
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the ID of zone of the template")
49+
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
50+
description="the ID of zone of the template")
5051
private Long zoneId;
5152

5253

api/src/org/apache/cloudstack/api/command/user/template/ExtractTemplateCmd.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.user.template;
1818

19+
import org.apache.cloudstack.api.response.UserVmResponse;
20+
import org.apache.cloudstack.api.response.ZoneResponse;
1921
import org.apache.log4j.Logger;
2022

2123
import org.apache.cloudstack.api.ApiConstants;
2224
import org.apache.cloudstack.api.BaseAsyncCmd;
2325
import org.apache.cloudstack.api.BaseCmd;
24-
import org.apache.cloudstack.api.IdentityMapper;
2526
import org.apache.cloudstack.api.Implementation;
2627
import org.apache.cloudstack.api.Parameter;
2728
import org.apache.cloudstack.api.ServerApiException;
@@ -43,15 +44,15 @@ public class ExtractTemplateCmd extends BaseAsyncCmd {
4344
//////////////// API parameters /////////////////////
4445
/////////////////////////////////////////////////////
4546

46-
@IdentityMapper(entityTableName="vm_template")
47-
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the template")
47+
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = UserVmResponse.class,
48+
required=true, description="the ID of the template")
4849
private Long id;
4950

5051
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=false, description="the url to which the ISO would be extracted")
5152
private String url;
5253

53-
@IdentityMapper(entityTableName="data_center")
54-
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=false, description="the ID of the zone where the ISO is originally located" )
54+
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
55+
required=false, description="the ID of the zone where the ISO is originally located" )
5556
private Long zoneId;
5657

5758
@Parameter(name=ApiConstants.MODE, type=CommandType.STRING, required=true, description="the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD")

api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
import java.util.List;
2121
import java.util.Set;
2222

23+
import org.apache.cloudstack.api.response.UserVmResponse;
24+
import org.apache.cloudstack.api.response.ZoneResponse;
2325
import org.apache.log4j.Logger;
2426

2527
import org.apache.cloudstack.api.ApiConstants;
2628
import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
27-
import org.apache.cloudstack.api.IdentityMapper;
2829
import org.apache.cloudstack.api.Implementation;
2930
import org.apache.cloudstack.api.Parameter;
3031
import org.apache.cloudstack.api.response.ListResponse;
@@ -48,8 +49,8 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
4849
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, description="the hypervisor for which to restrict the search")
4950
private String hypervisor;
5051

51-
@IdentityMapper(entityTableName="vm_template")
52-
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the template ID")
52+
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = UserVmResponse.class,
53+
description="the template ID")
5354
private Long id;
5455

5556
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the template name")
@@ -62,8 +63,8 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
6263
"* executable-all templates that can be used to deploy a new VM* community-templates that are public.")
6364
private String templateFilter;
6465

65-
@IdentityMapper(entityTableName="data_center")
66-
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="list templates by zoneId")
66+
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
67+
description="list templates by zoneId")
6768
private Long zoneId;
6869
/////////////////////////////////////////////////////
6970
/////////////////// Accessors ///////////////////////

api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@
2525

2626
import org.apache.cloudstack.api.ApiConstants;
2727
import org.apache.cloudstack.api.BaseCmd;
28-
import org.apache.cloudstack.api.IdentityMapper;
2928
import org.apache.cloudstack.api.Implementation;
3029
import org.apache.cloudstack.api.Parameter;
3130
import org.apache.cloudstack.api.ServerApiException;
31+
import org.apache.cloudstack.api.response.DomainResponse;
3232
import org.apache.cloudstack.api.response.ListResponse;
33+
import org.apache.cloudstack.api.response.GuestOSResponse;
34+
import org.apache.cloudstack.api.response.ProjectResponse;
3335
import org.apache.cloudstack.api.response.TemplateResponse;
36+
import org.apache.cloudstack.api.response.ZoneResponse;
3437
import com.cloud.async.AsyncJob;
3538
import com.cloud.exception.ResourceAllocationException;
3639
import com.cloud.template.VirtualMachineTemplate;
@@ -67,8 +70,8 @@ public class RegisterTemplateCmd extends BaseCmd {
6770
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the template")
6871
private String templateName;
6972

70-
@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.")
71-
@IdentityMapper(entityTableName="guest_os")
73+
@Parameter(name=ApiConstants.OS_TYPE_ID, type=CommandType.UUID, entityType = GuestOSResponse.class,
74+
required=true, description="the ID of the OS Type that best represents the OS of this template.")
7275
private Long osTypeId;
7376

7477
@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 {
8689
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL of where the template is hosted. Possible URL include http:// and https://")
8790
private String url;
8891

89-
@IdentityMapper(entityTableName="data_center")
90-
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the ID of the zone the template is to be hosted on")
92+
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
93+
required=true, description="the ID of the zone the template is to be hosted on")
9194
private Long zoneId;
9295

93-
@IdentityMapper(entityTableName="domain")
94-
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId. If the account parameter is used, domainId must also be used.")
96+
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class,
97+
description="an optional domainId. If the account parameter is used, domainId must also be used.")
9598
private Long domainId;
9699

97100
@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 {
103106
@Parameter(name=ApiConstants.TEMPLATE_TAG, type=CommandType.STRING, description="the tag for this template.")
104107
private String templateTag;
105108

106-
@IdentityMapper(entityTableName="projects")
107-
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Register template for the project")
109+
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
110+
description="Register template for the project")
108111
private Long projectId;
109112

110113
@Parameter(name=ApiConstants.DETAILS, type=CommandType.MAP, description="Template details in key/value pairs.")

0 commit comments

Comments
 (0)