|
16 | 16 | // under the License. |
17 | 17 | package org.apache.cloudstack.api.command.user.zone; |
18 | 18 |
|
19 | | -import java.util.ArrayList; |
20 | | -import java.util.List; |
| 19 | +import java.util.Collection; |
| 20 | +import java.util.HashMap; |
| 21 | +import java.util.Iterator; |
| 22 | +import java.util.Map; |
21 | 23 |
|
22 | 24 | import org.apache.cloudstack.api.APICommand; |
23 | 25 | import org.apache.cloudstack.api.ApiConstants; |
24 | 26 | import org.apache.cloudstack.api.BaseListCmd; |
25 | 27 | import org.apache.cloudstack.api.Parameter; |
26 | | -import org.apache.cloudstack.api.BaseCmd.CommandType; |
27 | 28 | import org.apache.cloudstack.api.response.DomainResponse; |
28 | 29 | import org.apache.cloudstack.api.response.ListResponse; |
29 | | -import org.apache.cloudstack.api.response.ServiceOfferingResponse; |
30 | 30 | import org.apache.cloudstack.api.response.ZoneResponse; |
31 | 31 | import org.apache.log4j.Logger; |
32 | 32 |
|
33 | | -import com.cloud.dc.DataCenter; |
| 33 | +import com.cloud.exception.InvalidParameterValueException; |
34 | 34 |
|
35 | 35 | @APICommand(name = "listZones", description="Lists zones", responseObject=ZoneResponse.class) |
36 | 36 | public class ListZonesByCmd extends BaseListCmd { |
@@ -62,6 +62,9 @@ public class ListZonesByCmd extends BaseListCmd { |
62 | 62 |
|
63 | 63 | @Parameter(name=ApiConstants.SHOW_CAPACITIES, type=CommandType.BOOLEAN, description="flag to display the capacity of the zones") |
64 | 64 | private Boolean showCapacities; |
| 65 | + |
| 66 | + @Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, description = "List zones by resource tags (key/value pairs)", since="4.3") |
| 67 | + private Map tags; |
65 | 68 |
|
66 | 69 | ///////////////////////////////////////////////////// |
67 | 70 | /////////////////// Accessors /////////////////////// |
@@ -90,6 +93,25 @@ public String getNetworkType() { |
90 | 93 | public Boolean getShowCapacities() { |
91 | 94 | return showCapacities; |
92 | 95 | } |
| 96 | + |
| 97 | + public Map<String, String> getTags() { |
| 98 | + Map<String, String> tagsMap = null; |
| 99 | + if (tags != null && !tags.isEmpty()) { |
| 100 | + tagsMap = new HashMap<String, String>(); |
| 101 | + Collection<?> servicesCollection = tags.values(); |
| 102 | + Iterator<?> iter = servicesCollection.iterator(); |
| 103 | + while (iter.hasNext()) { |
| 104 | + HashMap<String, String> services = (HashMap<String, String>) iter.next(); |
| 105 | + String key = services.get("key"); |
| 106 | + String value = services.get("value"); |
| 107 | + if (value == null) { |
| 108 | + throw new InvalidParameterValueException("No value is passed in for key " + key); |
| 109 | + } |
| 110 | + tagsMap.put(key, value); |
| 111 | + } |
| 112 | + } |
| 113 | + return tagsMap; |
| 114 | + } |
93 | 115 |
|
94 | 116 | ///////////////////////////////////////////////////// |
95 | 117 | /////////////// API Implementation/////////////////// |
|
0 commit comments