Skip to content

Commit ee65ee9

Browse files
committed
techdebt: parameterise map typed API parameters
1 parent f00e0c7 commit ee65ee9

61 files changed

Lines changed: 115 additions & 131 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎api/src/main/java/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
7676
protected Boolean isRoutingType;
7777

7878
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "Details in key/value pairs using format details[i].keyname=keyvalue. Example: details[0].hypervisortoolsversion=xenserver61")
79-
protected Map details;
79+
protected Map<Integer, Map<String, String>> details;
8080

8181
@Parameter(name = ApiConstants.CLEAN_UP_DETAILS,
8282
type = CommandType.BOOLEAN,
@@ -144,13 +144,11 @@ public Boolean isRoutingType() {
144144
return isRoutingType;
145145
}
146146

147-
public Map getDetails() {
147+
public Map<String, String> getDetails() {
148148
if (this.details == null || this.details.isEmpty()) {
149149
return null;
150150
}
151-
152-
Collection paramsCollection = this.details.values();
153-
return (Map) (paramsCollection.toArray())[0];
151+
return this.details.values().iterator().next();
154152
}
155153

156154
public boolean isCleanupDetails() {

‎api/src/main/java/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class UpdateAccountCmd extends BaseCmd implements UserCmd {
7070
private String networkDomain;
7171

7272
@Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "Details for the Account used to store specific parameters")
73-
private Map details;
73+
private Map<Integer, Map<String, String>> details;
7474

7575
@Parameter(name = ApiConstants.API_KEY_ACCESS, type = CommandType.STRING, description = "Determines if Api key access for this user is enabled, disabled or inherits the value from its parent, the domain level setting api.key.access", since = "4.20.1.0", authorized = {RoleType.Admin})
7676
private String apiKeyAccess;
@@ -104,14 +104,11 @@ public String getNetworkDomain() {
104104
return networkDomain;
105105
}
106106

107-
public Map getDetails() {
107+
public Map<String, String> getDetails() {
108108
if (details == null || details.isEmpty()) {
109109
return null;
110110
}
111-
112-
Collection paramsCollection = details.values();
113-
Map params = (Map)(paramsCollection.toArray())[0];
114-
return params;
111+
return details.values().iterator().next();
115112
}
116113

117114
public String getApiKeyAccess() {

‎api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public class AddClusterCmd extends BaseCmd {
136136
type = CommandType.MAP,
137137
description = "Details in key/value pairs to be added to the extension-resource mapping. Use the format externaldetails[i].<key>=<value>. Example: externaldetails[0].endpoint.url=https://example.com",
138138
since = "4.21.0")
139-
protected Map externalDetails;
139+
protected Map<Integer, Map<String, String>> externalDetails;
140140

141141
public String getOvm3Pool() {
142142
return ovm3pool;

‎api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class UpdateClusterCmd extends BaseCmd {
6666
type = CommandType.MAP,
6767
description = "Details in key/value pairs to be added to the extension-resource mapping. Use the format externaldetails[i].<key>=<value>. Example: externaldetails[0].endpoint.url=https://example.com",
6868
since = "4.21.0")
69-
protected Map externalDetails;
69+
protected Map<Integer, Map<String, String>> externalDetails;
7070

7171
public String getClusterName() {
7272
return clusterName;

‎api/src/main/java/org/apache/cloudstack/api/command/admin/guest/AddGuestOsCmd.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class AddGuestOsCmd extends BaseAsyncCreateCmd {
5858
private String osName;
5959

6060
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, required = false, description = "Map of (key/value pairs)")
61-
private Map details;
61+
private Map<Integer, Map<String, String>> details;
6262

6363
@Parameter(name="forDisplay", type=CommandType.BOOLEAN, description="whether this guest OS is available for end users", authorized = {RoleType.Admin})
6464
private Boolean display;
@@ -79,7 +79,7 @@ public String getOsName() {
7979
return osName;
8080
}
8181

82-
public Map getDetails() {
82+
public Map<String, String> getDetails() {
8383
Map<String, String> detailsMap = new HashMap<>();
8484
if (!MapUtils.isEmpty(details)) {
8585
Collection<?> servicesCollection = details.values();

‎api/src/main/java/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class UpdateGuestOsCmd extends BaseAsyncCmd {
5454
private String osDisplayName;
5555

5656
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, required = false, description = "Map of (key/value pairs)")
57-
private Map details;
57+
private Map<Integer, Map<String, String>> details;
5858

5959
@Parameter(name="forDisplay", type=CommandType.BOOLEAN, description="whether this guest OS is available for end users", authorized = {RoleType.Admin})
6060
private Boolean display;

‎api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class AddHostCmd extends BaseCmd {
8686
type = CommandType.MAP,
8787
description = "Details in key/value pairs using format externaldetails[i].keyname=keyvalue. Example: externaldetails[0].endpoint.url=urlvalue",
8888
since = "4.21.0")
89-
protected Map externalDetails;
89+
protected Map<Integer, Map<String, String>> externalDetails;
9090

9191
/////////////////////////////////////////////////////
9292
/////////////////// Accessors ///////////////////////

‎api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class AddSecondaryStorageCmd extends BaseCmd {
5050
protected Long zoneId;
5151

5252
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, description = "Details in key/value pairs using format details[i].keyname=keyvalue. Example: details[0].copytemplatesfromothersecondarystorages=true")
53-
protected Map details;
53+
protected Map<Integer, Map<String, String>> details;
5454

5555
/////////////////////////////////////////////////////
5656
/////////////////// Accessors ///////////////////////

‎api/src/main/java/org/apache/cloudstack/api/command/admin/host/UpdateHostCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class UpdateHostCmd extends BaseCmd {
7575
private String annotation;
7676

7777
@Parameter(name = ApiConstants.EXTERNAL_DETAILS, type = CommandType.MAP, description = "Details in key/value pairs using format externaldetails[i].keyname=keyvalue. Example: externaldetails[0].endpoint.url=urlvalue", since = "4.21.0")
78-
protected Map externalDetails;
78+
protected Map<Integer, Map<String, String>> externalDetails;
7979

8080
@Parameter(name = ApiConstants.CLEAN_UP_EXTERNAL_DETAILS,
8181
type = CommandType.BOOLEAN,

‎api/src/main/java/org/apache/cloudstack/api/command/admin/network/NetworkOfferingBaseCmd.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public abstract class NetworkOfferingBaseCmd extends BaseCmd {
168168
@Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, since = "4.2.0", description = "Network offering details in key/value pairs."
169169
+ " Supported keys are internallbprovider/publiclbprovider with service provider as a value, and"
170170
+ " promiscuousmode/macaddresschanges/forgedtransmits with true/false as value to accept/reject the security settings if available for a nic/portgroup")
171-
protected Map details;
171+
protected Map<Integer, Map<String, String>> details;
172172

173173
@Parameter(name = ApiConstants.EGRESS_DEFAULT_POLICY,
174174
type = CommandType.BOOLEAN,

0 commit comments

Comments
 (0)