From 00db80d5a20ebd088e8c35e662da12a1f6d43fa5 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Sun, 26 May 2019 11:54:01 +0200 Subject: [PATCH] Fix the type check to test for float64 --- cloudstack/AffinityGroupService.go | 4 +- cloudstack/AlertService.go | 8 ++-- cloudstack/ClusterService.go | 4 +- cloudstack/DiskOfferingService.go | 4 +- cloudstack/EventService.go | 8 ++-- cloudstack/GuestOSService.go | 12 ++--- cloudstack/HostService.go | 8 ++-- cloudstack/ISOService.go | 28 ++++++------ cloudstack/ImageStoreService.go | 8 ++-- cloudstack/LoadBalancerService.go | 4 +- cloudstack/NATService.go | 4 +- cloudstack/NetworkDeviceService.go | 4 +- cloudstack/NetworkOfferingService.go | 4 +- cloudstack/NetworkService.go | 4 +- cloudstack/NicService.go | 4 +- cloudstack/PodService.go | 4 +- cloudstack/PoolService.go | 4 +- cloudstack/RegionService.go | 4 +- cloudstack/RoleService.go | 12 ++--- cloudstack/SSHService.go | 8 ++-- cloudstack/SecurityGroupService.go | 4 +- cloudstack/ServiceOfferingService.go | 4 +- cloudstack/SnapshotService.go | 20 ++++---- cloudstack/StratosphereSSPService.go | 4 +- cloudstack/TemplateService.go | 28 ++++++------ cloudstack/UCSService.go | 4 +- cloudstack/UsageService.go | 12 ++--- cloudstack/UserService.go | 4 +- cloudstack/VLANService.go | 4 +- cloudstack/VMGroupService.go | 4 +- cloudstack/VirtualMachineService.go | 68 ++++++++++++++-------------- cloudstack/VolumeService.go | 4 +- cloudstack/ZoneService.go | 4 +- generate/generate.go | 7 +-- 34 files changed, 156 insertions(+), 155 deletions(-) diff --git a/cloudstack/AffinityGroupService.go b/cloudstack/AffinityGroupService.go index 04681c4..87d28d8 100644 --- a/cloudstack/AffinityGroupService.go +++ b/cloudstack/AffinityGroupService.go @@ -853,8 +853,8 @@ func (r *UpdateVMAffinityGroupResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/AlertService.go b/cloudstack/AlertService.go index 2ccc13b..8202e96 100644 --- a/cloudstack/AlertService.go +++ b/cloudstack/AlertService.go @@ -126,8 +126,8 @@ func (r *ArchiveAlertsResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -240,8 +240,8 @@ func (r *DeleteAlertsResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/ClusterService.go b/cloudstack/ClusterService.go index f6d79b5..9a3c15d 100644 --- a/cloudstack/ClusterService.go +++ b/cloudstack/ClusterService.go @@ -478,8 +478,8 @@ func (r *DeleteClusterResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/DiskOfferingService.go b/cloudstack/DiskOfferingService.go index 04817dc..f71d646 100644 --- a/cloudstack/DiskOfferingService.go +++ b/cloudstack/DiskOfferingService.go @@ -458,8 +458,8 @@ func (r *DeleteDiskOfferingResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/EventService.go b/cloudstack/EventService.go index e644399..243ada4 100644 --- a/cloudstack/EventService.go +++ b/cloudstack/EventService.go @@ -126,8 +126,8 @@ func (r *ArchiveEventsResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -240,8 +240,8 @@ func (r *DeleteEventsResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/GuestOSService.go b/cloudstack/GuestOSService.go index d665914..b2cacbc 100644 --- a/cloudstack/GuestOSService.go +++ b/cloudstack/GuestOSService.go @@ -279,8 +279,8 @@ func (r *AddGuestOsMappingResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -470,8 +470,8 @@ func (r *GuestOsMapping) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1167,8 +1167,8 @@ func (r *UpdateGuestOsMappingResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/HostService.go b/cloudstack/HostService.go index 4a54768..7ce06f5 100644 --- a/cloudstack/HostService.go +++ b/cloudstack/HostService.go @@ -995,8 +995,8 @@ func (r *DeleteHostResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -2651,8 +2651,8 @@ func (r *UpdateHostPasswordResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/ISOService.go b/cloudstack/ISOService.go index 08b32e0..9c1c4f8 100644 --- a/cloudstack/ISOService.go +++ b/cloudstack/ISOService.go @@ -228,8 +228,8 @@ func (r *AttachIsoResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -403,8 +403,8 @@ func (r *CopyIsoResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -687,8 +687,8 @@ func (r *DetachIsoResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1312,8 +1312,8 @@ func (r *Iso) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1619,8 +1619,8 @@ func (r *RegisterIsoResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1895,8 +1895,8 @@ func (r *UpdateIsoResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -2047,8 +2047,8 @@ func (r *UpdateIsoPermissionsResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/ImageStoreService.go b/cloudstack/ImageStoreService.go index 0dbbe90..62faac1 100644 --- a/cloudstack/ImageStoreService.go +++ b/cloudstack/ImageStoreService.go @@ -488,8 +488,8 @@ func (r *DeleteImageStoreResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -569,8 +569,8 @@ func (r *DeleteSecondaryStagingStoreResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/LoadBalancerService.go b/cloudstack/LoadBalancerService.go index 73c3c15..08cf53b 100644 --- a/cloudstack/LoadBalancerService.go +++ b/cloudstack/LoadBalancerService.go @@ -2080,8 +2080,8 @@ func (r *DeleteSslCertResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/NATService.go b/cloudstack/NATService.go index 94ce318..f8c56c6 100644 --- a/cloudstack/NATService.go +++ b/cloudstack/NATService.go @@ -415,8 +415,8 @@ func (r *EnableStaticNatResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/NetworkDeviceService.go b/cloudstack/NetworkDeviceService.go index b8996f4..edb6adf 100644 --- a/cloudstack/NetworkDeviceService.go +++ b/cloudstack/NetworkDeviceService.go @@ -160,8 +160,8 @@ func (r *DeleteNetworkDeviceResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/NetworkOfferingService.go b/cloudstack/NetworkOfferingService.go index 8eebe9b..e4f7404 100644 --- a/cloudstack/NetworkOfferingService.go +++ b/cloudstack/NetworkOfferingService.go @@ -431,8 +431,8 @@ func (r *DeleteNetworkOfferingResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/NetworkService.go b/cloudstack/NetworkService.go index 0dc57c3..628aa1f 100644 --- a/cloudstack/NetworkService.go +++ b/cloudstack/NetworkService.go @@ -3574,8 +3574,8 @@ func (r *ReleasePublicIpRangeResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/NicService.go b/cloudstack/NicService.go index 983d6fb..722278a 100644 --- a/cloudstack/NicService.go +++ b/cloudstack/NicService.go @@ -536,8 +536,8 @@ func (r *UpdateVmNicIpResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/PodService.go b/cloudstack/PodService.go index 603cb9a..c51139a 100644 --- a/cloudstack/PodService.go +++ b/cloudstack/PodService.go @@ -343,8 +343,8 @@ func (r *DeletePodResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/PoolService.go b/cloudstack/PoolService.go index fdc19e6..047f766 100644 --- a/cloudstack/PoolService.go +++ b/cloudstack/PoolService.go @@ -323,8 +323,8 @@ func (r *DeleteStoragePoolResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/RegionService.go b/cloudstack/RegionService.go index 81285c0..92d8338 100644 --- a/cloudstack/RegionService.go +++ b/cloudstack/RegionService.go @@ -282,8 +282,8 @@ func (r *RemoveRegionResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/RoleService.go b/cloudstack/RoleService.go index 0be4e47..f40354d 100644 --- a/cloudstack/RoleService.go +++ b/cloudstack/RoleService.go @@ -265,8 +265,8 @@ func (r *DeleteRoleResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -346,8 +346,8 @@ func (r *DeleteRolePermissionResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -777,8 +777,8 @@ func (r *UpdateRolePermissionResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/SSHService.go b/cloudstack/SSHService.go index 8f49ec0..a69f7f2 100644 --- a/cloudstack/SSHService.go +++ b/cloudstack/SSHService.go @@ -219,8 +219,8 @@ func (r *DeleteSSHKeyPairResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -738,8 +738,8 @@ func (r *ResetSSHKeyForVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/SecurityGroupService.go b/cloudstack/SecurityGroupService.go index 14b8e13..245f263 100644 --- a/cloudstack/SecurityGroupService.go +++ b/cloudstack/SecurityGroupService.go @@ -728,8 +728,8 @@ func (r *DeleteSecurityGroupResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/ServiceOfferingService.go b/cloudstack/ServiceOfferingService.go index 220171d..ea9b4d9 100644 --- a/cloudstack/ServiceOfferingService.go +++ b/cloudstack/ServiceOfferingService.go @@ -581,8 +581,8 @@ func (r *DeleteServiceOfferingResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/SnapshotService.go b/cloudstack/SnapshotService.go index 1efeeb0..7733d82 100644 --- a/cloudstack/SnapshotService.go +++ b/cloudstack/SnapshotService.go @@ -212,8 +212,8 @@ func (r *CreateSnapshotResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -628,8 +628,8 @@ func (r *DeleteSnapshotPoliciesResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1214,8 +1214,8 @@ func (r *Snapshot) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1597,8 +1597,8 @@ func (r *RevertSnapshotResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1801,8 +1801,8 @@ func (r *RevertToVMSnapshotResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/StratosphereSSPService.go b/cloudstack/StratosphereSSPService.go index 74a039e..81d1059 100644 --- a/cloudstack/StratosphereSSPService.go +++ b/cloudstack/StratosphereSSPService.go @@ -204,8 +204,8 @@ func (r *DeleteStratosphereSspResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/TemplateService.go b/cloudstack/TemplateService.go index 0f0b483..2b8d764 100644 --- a/cloudstack/TemplateService.go +++ b/cloudstack/TemplateService.go @@ -187,8 +187,8 @@ func (r *CopyTemplateResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -517,8 +517,8 @@ func (r *CreateTemplateResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1518,8 +1518,8 @@ func (r *Template) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1662,8 +1662,8 @@ func (r *PrepareTemplateResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -2061,8 +2061,8 @@ func (r *RegisterTemplate) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -2337,8 +2337,8 @@ func (r *UpdateTemplateResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -2489,8 +2489,8 @@ func (r *UpdateTemplatePermissionsResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/UCSService.go b/cloudstack/UCSService.go index e52b57b..bf109f0 100644 --- a/cloudstack/UCSService.go +++ b/cloudstack/UCSService.go @@ -297,8 +297,8 @@ func (r *DeleteUcsManagerResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/UsageService.go b/cloudstack/UsageService.go index bcfc99c..e6632e7 100644 --- a/cloudstack/UsageService.go +++ b/cloudstack/UsageService.go @@ -352,8 +352,8 @@ func (r *DeleteTrafficMonitorResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -525,8 +525,8 @@ func (r *GenerateUsageRecordsResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1192,8 +1192,8 @@ func (r *RemoveRawUsageRecordsResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/UserService.go b/cloudstack/UserService.go index 4e888ce..cf121e6 100644 --- a/cloudstack/UserService.go +++ b/cloudstack/UserService.go @@ -263,8 +263,8 @@ func (r *DeleteUserResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/VLANService.go b/cloudstack/VLANService.go index d6a4b98..15555c4 100644 --- a/cloudstack/VLANService.go +++ b/cloudstack/VLANService.go @@ -462,8 +462,8 @@ func (r *DeleteVlanIpRangeResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/VMGroupService.go b/cloudstack/VMGroupService.go index fe453dc..450010a 100644 --- a/cloudstack/VMGroupService.go +++ b/cloudstack/VMGroupService.go @@ -186,8 +186,8 @@ func (r *DeleteInstanceGroupResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/VirtualMachineService.go b/cloudstack/VirtualMachineService.go index 4349b0c..431de3a 100644 --- a/cloudstack/VirtualMachineService.go +++ b/cloudstack/VirtualMachineService.go @@ -266,8 +266,8 @@ func (r *AddNicToVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -507,8 +507,8 @@ func (r *AssignVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -718,8 +718,8 @@ func (r *ChangeServiceForVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1372,8 +1372,8 @@ func (r *DeployVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -1600,8 +1600,8 @@ func (r *DestroyVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -2325,8 +2325,8 @@ func (r *VirtualMachine) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -2551,8 +2551,8 @@ func (r *MigrateVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -2783,8 +2783,8 @@ func (r *MigrateVirtualMachineWithVolumeResponse) UnmarshalJSON(b []byte) error } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -2987,8 +2987,8 @@ func (r *RebootVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -3171,8 +3171,8 @@ func (r *RecoverVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -3387,8 +3387,8 @@ func (r *RemoveNicFromVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -3591,8 +3591,8 @@ func (r *ResetPasswordForVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -3806,8 +3806,8 @@ func (r *RestoreVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -4128,8 +4128,8 @@ func (r *StartVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -4344,8 +4344,8 @@ func (r *StopVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -4560,8 +4560,8 @@ func (r *UpdateDefaultNicForVirtualMachineResponse) UnmarshalJSON(b []byte) erro } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err @@ -4935,8 +4935,8 @@ func (r *UpdateVirtualMachineResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/VolumeService.go b/cloudstack/VolumeService.go index ed4dbde..e95c5e0 100644 --- a/cloudstack/VolumeService.go +++ b/cloudstack/VolumeService.go @@ -512,8 +512,8 @@ func (r *DeleteVolumeResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/cloudstack/ZoneService.go b/cloudstack/ZoneService.go index 0a10a24..fff7f40 100644 --- a/cloudstack/ZoneService.go +++ b/cloudstack/ZoneService.go @@ -432,8 +432,8 @@ func (r *DeleteZoneResponse) UnmarshalJSON(b []byte) error { } } - if ostypeid, ok := m["ostypeid"].(int); ok { - m["ostypeid"] = strconv.Itoa(ostypeid) + if ostypeid, ok := m["ostypeid"].(float64); ok { + m["ostypeid"] = strconv.Itoa(int(ostypeid)) b, err = json.Marshal(m) if err != nil { return err diff --git a/generate/generate.go b/generate/generate.go index edab1ba..36894d3 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -1306,8 +1306,8 @@ func (s *service) generateResponseType(a *API) { pn(" }") pn(" }") pn("") - pn(" if ostypeid, ok := m[\"ostypeid\"].(int); ok {") - pn(" m[\"ostypeid\"] = strconv.Itoa(ostypeid)") + pn(" if ostypeid, ok := m[\"ostypeid\"].(float64); ok {") + pn(" m[\"ostypeid\"] = strconv.Itoa(int(ostypeid))") pn(" b, err = json.Marshal(m)") pn(" if err != nil {") pn(" return err") @@ -1358,14 +1358,15 @@ func (s *service) recusiveGenerateResponseType(tn string, resp APIResponses, asy } } else { if !found[r.Name] { - // This code is needed because the response field is different for sync and async calls :( switch r.Name { case "success": + // This case is because the response field is different for sync and async calls :( pn("%s bool `json:\"%s\"`", capitalize(r.Name), r.Name) if !async { customMarshal = true } case "ostypeid": + // This case is needed for backwards compatibility. pn("%s string `json:\"%s\"`", capitalize(r.Name), r.Name) customMarshal = true default: