Commit 79f09fb
authored
Add support for excluding a list of parameters from an API response (apache#163)
This PR address #apache#149, it adds an exclude parameter to remove fields from the response
For example, without the exclude parameter, the listAccounts response looks like:
```
$ ./cmk -p pd-env list accounts name=admin
{
"account": [
{
"accounttype": 1,
"apikeyaccess": "INHERIT",
"backupavailable": "Unlimited",
"backuplimit": "Unlimited",
"backupstorageavailable": "Unlimited",
"backupstoragelimit": "Unlimited",
"backupstoragetotal": 0,
"backuptotal": 0,
"bucketavailable": "Unlimited",
"bucketlimit": "Unlimited",
"buckettotal": 0,
"cpuavailable": "Unlimited",
"cpulimit": "Unlimited",
"cputotal": 4,
"domain": "ROOT",
"domainid": "db0704ab-5827-11f0-804a-1e0052000469",
"domainpath": "ROOT",
"groups": [],
"id": "24e85a59-5828-11f0-804a-1e0052000469",
"ipavailable": "Unlimited",
"iplimit": "Unlimited",
"iptotal": 1,
"isdefault": true,
"memoryavailable": "Unlimited",
"memorylimit": "Unlimited",
"memorytotal": 4096,
"name": "admin",
"networkavailable": "Unlimited",
"networklimit": "Unlimited",
"networktotal": 1,
"objectstorageavailable": "Unlimited",
"objectstoragelimit": "Unlimited",
"objectstoragetotal": 0,
"primarystorageavailable": "Unlimited",
"primarystoragelimit": "Unlimited",
"primarystoragetotal": 16,
"projectavailable": "Unlimited",
"projectlimit": "Unlimited",
"projecttotal": 0,
"receivedbytes": 1346690740,
"roleid": "fff4ee8f-5827-11f0-804a-1e0052000469",
"rolename": "Root Admin",
"roletype": "Admin",
"secondarystorageavailable": "Unlimited",
"secondarystoragelimit": "Unlimited",
"secondarystoragetotal": 0,
"sentbytes": 35867842,
"snapshotavailable": "Unlimited",
"snapshotlimit": "Unlimited",
"snapshottotal": 0,
"state": "enabled",
"templateavailable": "Unlimited",
"templatelimit": "Unlimited",
"templatetotal": 0,
"user": [
{
"account": "admin",
"accountid": "24e85a59-5828-11f0-804a-1e0052000469",
"accounttype": 1,
"apikey": "LIN6rqXuaJwMPfGYFh13qDwYz5VNNz1J2J6qIOWcd3oLQOq0WtD4CwRundBL6rzXToa3lQOC_vKjI3nkHtiD8Q",
"created": "2025-07-03T16:09:48+0000",
"domain": "ROOT",
"domainid": "db0704ab-5827-11f0-804a-1e0052000469",
"firstname": "admin",
"id": "24e902f0-5828-11f0-804a-1e0052000469",
"is2faenabled": false,
"is2famandated": false,
"iscallerchilddomain": false,
"isdefault": true,
"lastname": "cloud",
"roleid": "fff4ee8f-5827-11f0-804a-1e0052000469",
"rolename": "Root Admin",
"roletype": "Admin",
"state": "enabled",
"username": "admin",
"usersource": "native"
},
{
"account": "admin",
"accountid": "24e85a59-5828-11f0-804a-1e0052000469",
"accounttype": 1,
"apikey": "U7qz8y6CjK1ECQsOuRLT7XaIfaWF3QuB4VJBHvDOBfQjyzsVvhWgDhMkHveJzu1Bb7oFnYKG4CZAfdHLpnim6w",
"created": "2025-07-09T17:26:05+0000",
"domain": "ROOT",
"domainid": "db0704ab-5827-11f0-804a-1e0052000469",
"email": "kubeadmin",
"firstname": "admin",
"id": "8ea65043-7df2-4906-8953-641a7e25a5cf",
"is2faenabled": false,
"is2famandated": false,
"iscallerchilddomain": false,
"isdefault": false,
"lastname": "kubeadmin",
"roleid": "fff4ee8f-5827-11f0-804a-1e0052000469",
"rolename": "Root Admin",
"roletype": "Admin",
"state": "enabled",
"username": "admin-kubeadmin",
"usersource": "native"
}
],
"vmavailable": "Unlimited",
"vmlimit": "Unlimited",
"vmrunning": 2,
"vmstopped": 0,
"vmtotal": 2,
"volumeavailable": "Unlimited",
"volumelimit": "Unlimited",
"volumetotal": 2,
"vpcavailable": "Unlimited",
"vpclimit": "Unlimited",
"vpctotal": 0
}
],
"count": 1
}
```
With this patch, if user wants to remove `user` field from the response, they could do so using the exclude param:
```
$ ./cmk -p pd-env list accounts name=admin exclude=user
{
"account": [
{
"accounttype": 1,
"apikeyaccess": "INHERIT",
"backupavailable": "Unlimited",
"backuplimit": "Unlimited",
"backupstorageavailable": "Unlimited",
"backupstoragelimit": "Unlimited",
"backupstoragetotal": 0,
"backuptotal": 0,
"bucketavailable": "Unlimited",
"bucketlimit": "Unlimited",
"buckettotal": 0,
"cpuavailable": "Unlimited",
"cpulimit": "Unlimited",
"cputotal": 4,
"domain": "ROOT",
"domainid": "db0704ab-5827-11f0-804a-1e0052000469",
"domainpath": "ROOT",
"groups": [],
"id": "24e85a59-5828-11f0-804a-1e0052000469",
"ipavailable": "Unlimited",
"iplimit": "Unlimited",
"iptotal": 1,
"isdefault": true,
"memoryavailable": "Unlimited",
"memorylimit": "Unlimited",
"memorytotal": 4096,
"name": "admin",
"networkavailable": "Unlimited",
"networklimit": "Unlimited",
"networktotal": 1,
"objectstorageavailable": "Unlimited",
"objectstoragelimit": "Unlimited",
"objectstoragetotal": 0,
"primarystorageavailable": "Unlimited",
"primarystoragelimit": "Unlimited",
"primarystoragetotal": 16,
"projectavailable": "Unlimited",
"projectlimit": "Unlimited",
"projecttotal": 0,
"receivedbytes": 1346706148,
"roleid": "fff4ee8f-5827-11f0-804a-1e0052000469",
"rolename": "Root Admin",
"roletype": "Admin",
"secondarystorageavailable": "Unlimited",
"secondarystoragelimit": "Unlimited",
"secondarystoragetotal": 0,
"sentbytes": 35872906,
"snapshotavailable": "Unlimited",
"snapshotlimit": "Unlimited",
"snapshottotal": 0,
"state": "enabled",
"templateavailable": "Unlimited",
"templatelimit": "Unlimited",
"templatetotal": 0,
"vmavailable": "Unlimited",
"vmlimit": "Unlimited",
"vmrunning": 2,
"vmstopped": 0,
"vmtotal": 2,
"volumeavailable": "Unlimited",
"volumelimit": "Unlimited",
"volumetotal": 2,
"vpcavailable": "Unlimited",
"vpclimit": "Unlimited",
"vpctotal": 0
}
],
"count": 1
}
```1 parent ee1a001 commit 79f09fb
4 files changed
+77
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
| 360 | + | |
360 | 361 | | |
361 | 362 | | |
362 | 363 | | |
| |||
373 | 374 | | |
374 | 375 | | |
375 | 376 | | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
376 | 393 | | |
377 | 394 | | |
378 | 395 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
101 | 112 | | |
102 | | - | |
| 113 | + | |
103 | 114 | | |
104 | 115 | | |
105 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
210 | | - | |
| 209 | + | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
213 | 224 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
221 | 229 | | |
222 | 230 | | |
223 | 231 | | |
224 | | - | |
| 232 | + | |
225 | 233 | | |
226 | 234 | | |
| 235 | + | |
227 | 236 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
232 | 245 | | |
233 | 246 | | |
234 | | - | |
235 | | - | |
236 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
237 | 252 | | |
238 | 253 | | |
239 | 254 | | |
| 255 | + | |
240 | 256 | | |
241 | 257 | | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
| 258 | + | |
247 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
248 | 263 | | |
| 264 | + | |
249 | 265 | | |
250 | 266 | | |
251 | 267 | | |
252 | | - | |
253 | | - | |
| 268 | + | |
| 269 | + | |
254 | 270 | | |
255 | 271 | | |
256 | 272 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
154 | 161 | | |
155 | 162 | | |
156 | 163 | | |
| |||
0 commit comments