Skip to content

Commit 1db12bd

Browse files
committed
Fix list response keys derived from the API name
CloudStack keys a list response's items by the response object name, not by the API name the generator derived the tag from, so 16 list APIs decoded as a permanently empty slice while count parsed from the same body and no error was returned. The keys are now data in a documented listResponseKeys map rather than 24 hand-written switch arms, each one observed on a real server and pinned by a test, leaving only genuine shape differences in the switch; listCaCertificate and listUsageServerMetrics also become pointers, since they return a single object with no count. Also moves the getRawValue empty-array guard from #154 into the generator, where it had been edited into the generated file only and so was reverted by every `make code`.
1 parent 6b701ff commit 1db12bd

15 files changed

Lines changed: 273 additions & 96 deletions

cloudstack/ASNumberRangeService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ func (s *ASNumberRangeService) ListASNRanges(p *ListASNRangesParams) (*ListASNRa
385385

386386
type ListASNRangesResponse struct {
387387
Count int `json:"count"`
388-
ASNRanges []*ASNRange `json:"asnrange"`
388+
ASNRanges []*ASNRange `json:"asnumberrange"`
389389
}
390390

391391
type ASNRange struct {

cloudstack/BackupService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3544,7 +3544,7 @@ func (s *BackupService) ListBackupProviders(p *ListBackupProvidersParams) (*List
35443544

35453545
type ListBackupProvidersResponse struct {
35463546
Count int `json:"count"`
3547-
BackupProviders []*BackupProvider `json:"backupprovider"`
3547+
BackupProviders []*BackupProvider `json:"providers"`
35483548
}
35493549

35503550
type BackupProvider struct {

cloudstack/CertificateService.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,7 @@ func (s *CertificateService) ListCaCertificate(p *ListCaCertificateParams) (*Lis
366366
}
367367

368368
type ListCaCertificateResponse struct {
369-
Count int `json:"count"`
370-
CaCertificate []*CaCertificate `json:"cacertificate"`
369+
CaCertificate *CaCertificate `json:"cacertificates"`
371370
}
372371

373372
type CaCertificate struct {

cloudstack/ClusterService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2686,7 +2686,7 @@ func (s *ClusterService) ListClustersMetrics(p *ListClustersMetricsParams) (*Lis
26862686

26872687
type ListClustersMetricsResponse struct {
26882688
Count int `json:"count"`
2689-
ClustersMetrics []*ClustersMetric `json:"clustersmetric"`
2689+
ClustersMetrics []*ClustersMetric `json:"cluster"`
26902690
}
26912691

26922692
type ClustersMetric struct {

cloudstack/ExtensionService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ func (s *ExtensionService) ListCustomActions(p *ListCustomActionsParams) (*ListC
11971197

11981198
type ListCustomActionsResponse struct {
11991199
Count int `json:"count"`
1200-
CustomActions []*CustomAction `json:"customaction"`
1200+
CustomActions []*CustomAction `json:"extensioncustomaction"`
12011201
}
12021202

12031203
type CustomAction struct {

cloudstack/FirewallService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4094,7 +4094,7 @@ func (s *FirewallService) ListRoutingFirewallRules(p *ListRoutingFirewallRulesPa
40944094

40954095
type ListRoutingFirewallRulesResponse struct {
40964096
Count int `json:"count"`
4097-
RoutingFirewallRules []*RoutingFirewallRule `json:"routingfirewallrule"`
4097+
RoutingFirewallRules []*RoutingFirewallRule `json:"firewallrule"`
40984098
}
40994099

41004100
type RoutingFirewallRule struct {

cloudstack/HostService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4193,7 +4193,7 @@ func (s *HostService) ListHostsMetrics(p *ListHostsMetricsParams) (*ListHostsMet
41934193

41944194
type ListHostsMetricsResponse struct {
41954195
Count int `json:"count"`
4196-
HostsMetrics []*HostsMetric `json:"hostsmetric"`
4196+
HostsMetrics []*HostsMetric `json:"host"`
41974197
}
41984198

41994199
type HostsMetric struct {

cloudstack/NetworkService.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3775,7 +3775,7 @@ func (s *NetworkService) ListNetworkIsolationMethods(p *ListNetworkIsolationMeth
37753775

37763776
type ListNetworkIsolationMethodsResponse struct {
37773777
Count int `json:"count"`
3778-
NetworkIsolationMethods []*NetworkIsolationMethod `json:"networkisolationmethod"`
3778+
NetworkIsolationMethods []*NetworkIsolationMethod `json:"isolationmethod"`
37793779
}
37803780

37813781
type NetworkIsolationMethod struct {
@@ -6424,7 +6424,7 @@ func (s *NetworkService) ListSupportedNetworkServices(p *ListSupportedNetworkSer
64246424

64256425
type ListSupportedNetworkServicesResponse struct {
64266426
Count int `json:"count"`
6427-
SupportedNetworkServices []*SupportedNetworkService `json:"supportednetworkservice"`
6427+
SupportedNetworkServices []*SupportedNetworkService `json:"networkservice"`
64286428
}
64296429

64306430
type SupportedNetworkService struct {

cloudstack/SystemVMService.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ func (s *SystemVMService) ListSystemVmsUsageHistory(p *ListSystemVmsUsageHistory
11081108

11091109
type ListSystemVmsUsageHistoryResponse struct {
11101110
Count int `json:"count"`
1111-
SystemVmsUsageHistory []*SystemVmsUsageHistory `json:"systemvmsusagehistory"`
1111+
SystemVmsUsageHistory []*SystemVmsUsageHistory `json:"virtualmachine"`
11121112
}
11131113

11141114
type SystemVmsUsageHistory struct {

cloudstack/UsageService.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ func (s *UsageService) ListTrafficTypeImplementors(p *ListTrafficTypeImplementor
10861086

10871087
type ListTrafficTypeImplementorsResponse struct {
10881088
Count int `json:"count"`
1089-
TrafficTypeImplementors []*TrafficTypeImplementor `json:"traffictypeimplementor"`
1089+
TrafficTypeImplementors []*TrafficTypeImplementor `json:"traffictypeimplementorresponse"`
10901090
}
10911091

10921092
type TrafficTypeImplementor struct {
@@ -2128,8 +2128,7 @@ func (s *UsageService) ListUsageServerMetrics(p *ListUsageServerMetricsParams) (
21282128
}
21292129

21302130
type ListUsageServerMetricsResponse struct {
2131-
Count int `json:"count"`
2132-
UsageServerMetrics []*UsageServerMetric `json:"usageservermetric"`
2131+
UsageServerMetrics *UsageServerMetric `json:"usageMetrics"`
21332132
}
21342133

21352134
type UsageServerMetric struct {

0 commit comments

Comments
 (0)