Skip to content

Commit 32cb095

Browse files
committed
techdebt: parameterise map typed API parameters
1 parent 2f34b0c commit 32cb095

67 files changed

Lines changed: 286 additions & 141 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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.apache.cloudstack.api.response.TemplateResponse;
2222
import org.apache.commons.lang3.StringUtils;
2323

24-
import java.util.Collection;
2524
import java.util.Map;
2625

2726
public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
@@ -76,7 +75,7 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
7675
protected Boolean isRoutingType;
7776

7877
@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;
78+
protected Map<Integer, Map<String, String>> details;
8079

8180
@Parameter(name = ApiConstants.CLEAN_UP_DETAILS,
8281
type = CommandType.BOOLEAN,
@@ -144,13 +143,11 @@ public Boolean isRoutingType() {
144143
return isRoutingType;
145144
}
146145

147-
public Map getDetails() {
146+
public Map<String, String> getDetails() {
148147
if (this.details == null || this.details.isEmpty()) {
149148
return null;
150149
}
151-
152-
Collection paramsCollection = this.details.values();
153-
return (Map) (paramsCollection.toArray())[0];
150+
return this.details.values().iterator().next();
154151
}
155152

156153
public boolean isCleanupDetails() {

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.admin.account;
1818

19-
import java.util.Collection;
2019
import java.util.Map;
2120

2221
import javax.inject.Inject;
@@ -70,7 +69,7 @@ public class UpdateAccountCmd extends BaseCmd implements UserCmd {
7069
private String networkDomain;
7170

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

7574
@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})
7675
private String apiKeyAccess;
@@ -104,14 +103,11 @@ public String getNetworkDomain() {
104103
return networkDomain;
105104
}
106105

107-
public Map getDetails() {
106+
public Map<String, String> getDetails() {
108107
if (details == null || details.isEmpty()) {
109108
return null;
110109
}
111-
112-
Collection paramsCollection = details.values();
113-
Map params = (Map)(paramsCollection.toArray())[0];
114-
return params;
110+
return details.values().iterator().next();
115111
}
116112

117113
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)