From b34d5dc5d31a9c82cc2a1c5f4c8fcd4104a2eb1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20D=C3=ADaz=20Marco?= Date: Thu, 18 Jan 2024 17:42:31 +0100 Subject: [PATCH] Fix "primary_ip" nullable type. --- api/openapi.yaml | 3 +++ docs/Device.md | 14 ++++++++++++-- docs/DeviceWithConfigContext.md | 14 ++++++++++++-- docs/VirtualMachineWithConfigContext.md | 14 ++++++++++++-- model_device.go | 16 +++++++++------- model_device_with_config_context.go | 16 +++++++++------- model_virtual_machine_with_config_context.go | 16 +++++++++------- scripts/fix-spec.py | 12 +++++++++--- 8 files changed, 75 insertions(+), 30 deletions(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index 0270d9db3..c7bb24cd8 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -98504,6 +98504,7 @@ components: allOf: - $ref: '#/components/schemas/NestedIPAddress' readOnly: true + nullable: true primary_ip4: allOf: - $ref: '#/components/schemas/NestedIPAddress' @@ -99406,6 +99407,7 @@ components: allOf: - $ref: '#/components/schemas/NestedIPAddress' readOnly: true + nullable: true primary_ip4: allOf: - $ref: '#/components/schemas/NestedIPAddress' @@ -131389,6 +131391,7 @@ components: allOf: - $ref: '#/components/schemas/NestedIPAddress' readOnly: true + nullable: true primary_ip4: allOf: - $ref: '#/components/schemas/NestedIPAddress' diff --git a/docs/Device.md b/docs/Device.md index 965769b04..99e440a92 100644 --- a/docs/Device.md +++ b/docs/Device.md @@ -25,7 +25,7 @@ Name | Type | Description | Notes **ParentDevice** | [**NullableNestedDevice**](NestedDevice.md) | | [readonly] **Status** | Pointer to [**DeviceStatus**](DeviceStatus.md) | | [optional] **Airflow** | Pointer to [**DeviceAirflow**](DeviceAirflow.md) | | [optional] -**PrimaryIp** | [**NestedIPAddress**](NestedIPAddress.md) | | [readonly] +**PrimaryIp** | [**NullableNestedIPAddress**](NestedIPAddress.md) | | [readonly] **PrimaryIp4** | Pointer to [**NullableNestedIPAddress**](NestedIPAddress.md) | | [optional] **PrimaryIp6** | Pointer to [**NullableNestedIPAddress**](NestedIPAddress.md) | | [optional] **OobIp** | Pointer to [**NullableNestedIPAddress**](NestedIPAddress.md) | | [optional] @@ -56,7 +56,7 @@ Name | Type | Description | Notes ### NewDevice -`func NewDevice(id int32, url string, display string, deviceType NestedDeviceType, role NestedDeviceRole, deviceRole DeviceDeviceRole, site NestedSite, parentDevice NullableNestedDevice, primaryIp NestedIPAddress, created NullableTime, lastUpdated NullableTime, consolePortCount int32, consoleServerPortCount int32, powerPortCount int32, powerOutletCount int32, interfaceCount int32, frontPortCount int32, rearPortCount int32, deviceBayCount int32, moduleBayCount int32, inventoryItemCount int32, ) *Device` +`func NewDevice(id int32, url string, display string, deviceType NestedDeviceType, role NestedDeviceRole, deviceRole DeviceDeviceRole, site NestedSite, parentDevice NullableNestedDevice, primaryIp NullableNestedIPAddress, created NullableTime, lastUpdated NullableTime, consolePortCount int32, consoleServerPortCount int32, powerPortCount int32, powerOutletCount int32, interfaceCount int32, frontPortCount int32, rearPortCount int32, deviceBayCount int32, moduleBayCount int32, inventoryItemCount int32, ) *Device` NewDevice instantiates a new Device object This constructor will assign default values to properties that have it defined, @@ -676,6 +676,16 @@ and a boolean to check if the value has been set. SetPrimaryIp sets PrimaryIp field to given value. +### SetPrimaryIpNil + +`func (o *Device) SetPrimaryIpNil(b bool)` + + SetPrimaryIpNil sets the value for PrimaryIp to be an explicit nil + +### UnsetPrimaryIp +`func (o *Device) UnsetPrimaryIp()` + +UnsetPrimaryIp ensures that no value is present for PrimaryIp, not even an explicit nil ### GetPrimaryIp4 `func (o *Device) GetPrimaryIp4() NestedIPAddress` diff --git a/docs/DeviceWithConfigContext.md b/docs/DeviceWithConfigContext.md index 07d7d9267..280843b51 100644 --- a/docs/DeviceWithConfigContext.md +++ b/docs/DeviceWithConfigContext.md @@ -25,7 +25,7 @@ Name | Type | Description | Notes **ParentDevice** | [**NullableNestedDevice**](NestedDevice.md) | | [readonly] **Status** | Pointer to [**DeviceStatus**](DeviceStatus.md) | | [optional] **Airflow** | Pointer to [**DeviceAirflow**](DeviceAirflow.md) | | [optional] -**PrimaryIp** | [**NestedIPAddress**](NestedIPAddress.md) | | [readonly] +**PrimaryIp** | [**NullableNestedIPAddress**](NestedIPAddress.md) | | [readonly] **PrimaryIp4** | Pointer to [**NullableNestedIPAddress**](NestedIPAddress.md) | | [optional] **PrimaryIp6** | Pointer to [**NullableNestedIPAddress**](NestedIPAddress.md) | | [optional] **OobIp** | Pointer to [**NullableNestedIPAddress**](NestedIPAddress.md) | | [optional] @@ -57,7 +57,7 @@ Name | Type | Description | Notes ### NewDeviceWithConfigContext -`func NewDeviceWithConfigContext(id int32, url string, display string, deviceType NestedDeviceType, role NestedDeviceRole, deviceRole DeviceDeviceRole, site NestedSite, parentDevice NullableNestedDevice, primaryIp NestedIPAddress, configContext interface{}, created NullableTime, lastUpdated NullableTime, consolePortCount int32, consoleServerPortCount int32, powerPortCount int32, powerOutletCount int32, interfaceCount int32, frontPortCount int32, rearPortCount int32, deviceBayCount int32, moduleBayCount int32, inventoryItemCount int32, ) *DeviceWithConfigContext` +`func NewDeviceWithConfigContext(id int32, url string, display string, deviceType NestedDeviceType, role NestedDeviceRole, deviceRole DeviceDeviceRole, site NestedSite, parentDevice NullableNestedDevice, primaryIp NullableNestedIPAddress, configContext interface{}, created NullableTime, lastUpdated NullableTime, consolePortCount int32, consoleServerPortCount int32, powerPortCount int32, powerOutletCount int32, interfaceCount int32, frontPortCount int32, rearPortCount int32, deviceBayCount int32, moduleBayCount int32, inventoryItemCount int32, ) *DeviceWithConfigContext` NewDeviceWithConfigContext instantiates a new DeviceWithConfigContext object This constructor will assign default values to properties that have it defined, @@ -677,6 +677,16 @@ and a boolean to check if the value has been set. SetPrimaryIp sets PrimaryIp field to given value. +### SetPrimaryIpNil + +`func (o *DeviceWithConfigContext) SetPrimaryIpNil(b bool)` + + SetPrimaryIpNil sets the value for PrimaryIp to be an explicit nil + +### UnsetPrimaryIp +`func (o *DeviceWithConfigContext) UnsetPrimaryIp()` + +UnsetPrimaryIp ensures that no value is present for PrimaryIp, not even an explicit nil ### GetPrimaryIp4 `func (o *DeviceWithConfigContext) GetPrimaryIp4() NestedIPAddress` diff --git a/docs/VirtualMachineWithConfigContext.md b/docs/VirtualMachineWithConfigContext.md index 31a0c58a6..174263aca 100644 --- a/docs/VirtualMachineWithConfigContext.md +++ b/docs/VirtualMachineWithConfigContext.md @@ -15,7 +15,7 @@ Name | Type | Description | Notes **Role** | Pointer to [**NullableNestedDeviceRole**](NestedDeviceRole.md) | | [optional] **Tenant** | Pointer to [**NullableNestedTenant**](NestedTenant.md) | | [optional] **Platform** | Pointer to [**NullableNestedPlatform**](NestedPlatform.md) | | [optional] -**PrimaryIp** | [**NestedIPAddress**](NestedIPAddress.md) | | [readonly] +**PrimaryIp** | [**NullableNestedIPAddress**](NestedIPAddress.md) | | [readonly] **PrimaryIp4** | Pointer to [**NullableNestedIPAddress**](NestedIPAddress.md) | | [optional] **PrimaryIp6** | Pointer to [**NullableNestedIPAddress**](NestedIPAddress.md) | | [optional] **Vcpus** | Pointer to **NullableFloat64** | | [optional] @@ -36,7 +36,7 @@ Name | Type | Description | Notes ### NewVirtualMachineWithConfigContext -`func NewVirtualMachineWithConfigContext(id int32, url string, display string, name string, primaryIp NestedIPAddress, configContext interface{}, created NullableTime, lastUpdated NullableTime, interfaceCount int32, virtualDiskCount int32, ) *VirtualMachineWithConfigContext` +`func NewVirtualMachineWithConfigContext(id int32, url string, display string, name string, primaryIp NullableNestedIPAddress, configContext interface{}, created NullableTime, lastUpdated NullableTime, interfaceCount int32, virtualDiskCount int32, ) *VirtualMachineWithConfigContext` NewVirtualMachineWithConfigContext instantiates a new VirtualMachineWithConfigContext object This constructor will assign default values to properties that have it defined, @@ -386,6 +386,16 @@ and a boolean to check if the value has been set. SetPrimaryIp sets PrimaryIp field to given value. +### SetPrimaryIpNil + +`func (o *VirtualMachineWithConfigContext) SetPrimaryIpNil(b bool)` + + SetPrimaryIpNil sets the value for PrimaryIp to be an explicit nil + +### UnsetPrimaryIp +`func (o *VirtualMachineWithConfigContext) UnsetPrimaryIp()` + +UnsetPrimaryIp ensures that no value is present for PrimaryIp, not even an explicit nil ### GetPrimaryIp4 `func (o *VirtualMachineWithConfigContext) GetPrimaryIp4() NestedIPAddress` diff --git a/model_device.go b/model_device.go index 4286ffe32..f0185c5cc 100644 --- a/model_device.go +++ b/model_device.go @@ -46,7 +46,7 @@ type Device struct { ParentDevice NullableNestedDevice `json:"parent_device"` Status *DeviceStatus `json:"status,omitempty"` Airflow *DeviceAirflow `json:"airflow,omitempty"` - PrimaryIp NestedIPAddress `json:"primary_ip"` + PrimaryIp NullableNestedIPAddress `json:"primary_ip"` PrimaryIp4 NullableNestedIPAddress `json:"primary_ip4,omitempty"` PrimaryIp6 NullableNestedIPAddress `json:"primary_ip6,omitempty"` OobIp NullableNestedIPAddress `json:"oob_ip,omitempty"` @@ -83,7 +83,7 @@ type _Device Device // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewDevice(id int32, url string, display string, deviceType NestedDeviceType, role NestedDeviceRole, deviceRole DeviceDeviceRole, site NestedSite, parentDevice NullableNestedDevice, primaryIp NestedIPAddress, created NullableTime, lastUpdated NullableTime, consolePortCount int32, consoleServerPortCount int32, powerPortCount int32, powerOutletCount int32, interfaceCount int32, frontPortCount int32, rearPortCount int32, deviceBayCount int32, moduleBayCount int32, inventoryItemCount int32) *Device { +func NewDevice(id int32, url string, display string, deviceType NestedDeviceType, role NestedDeviceRole, deviceRole DeviceDeviceRole, site NestedSite, parentDevice NullableNestedDevice, primaryIp NullableNestedIPAddress, created NullableTime, lastUpdated NullableTime, consolePortCount int32, consoleServerPortCount int32, powerPortCount int32, powerOutletCount int32, interfaceCount int32, frontPortCount int32, rearPortCount int32, deviceBayCount int32, moduleBayCount int32, inventoryItemCount int32) *Device { this := Device{} this.Id = id this.Url = url @@ -827,27 +827,29 @@ func (o *Device) SetAirflow(v DeviceAirflow) { } // GetPrimaryIp returns the PrimaryIp field value +// If the value is explicit nil, the zero value for NestedIPAddress will be returned func (o *Device) GetPrimaryIp() NestedIPAddress { - if o == nil { + if o == nil || o.PrimaryIp.Get() == nil { var ret NestedIPAddress return ret } - return o.PrimaryIp + return *o.PrimaryIp.Get() } // GetPrimaryIpOk returns a tuple with the PrimaryIp field value // and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned func (o *Device) GetPrimaryIpOk() (*NestedIPAddress, bool) { if o == nil { return nil, false } - return &o.PrimaryIp, true + return o.PrimaryIp.Get(), o.PrimaryIp.IsSet() } // SetPrimaryIp sets field value func (o *Device) SetPrimaryIp(v NestedIPAddress) { - o.PrimaryIp = v + o.PrimaryIp.Set(&v) } // GetPrimaryIp4 returns the PrimaryIp4 field value if set, zero value otherwise (both if not set or set to explicit null). @@ -1704,7 +1706,7 @@ func (o Device) ToMap() (map[string]interface{}, error) { if !IsNil(o.Airflow) { toSerialize["airflow"] = o.Airflow } - toSerialize["primary_ip"] = o.PrimaryIp + toSerialize["primary_ip"] = o.PrimaryIp.Get() if o.PrimaryIp4.IsSet() { toSerialize["primary_ip4"] = o.PrimaryIp4.Get() } diff --git a/model_device_with_config_context.go b/model_device_with_config_context.go index b9ba4ee9a..6068e551d 100644 --- a/model_device_with_config_context.go +++ b/model_device_with_config_context.go @@ -46,7 +46,7 @@ type DeviceWithConfigContext struct { ParentDevice NullableNestedDevice `json:"parent_device"` Status *DeviceStatus `json:"status,omitempty"` Airflow *DeviceAirflow `json:"airflow,omitempty"` - PrimaryIp NestedIPAddress `json:"primary_ip"` + PrimaryIp NullableNestedIPAddress `json:"primary_ip"` PrimaryIp4 NullableNestedIPAddress `json:"primary_ip4,omitempty"` PrimaryIp6 NullableNestedIPAddress `json:"primary_ip6,omitempty"` OobIp NullableNestedIPAddress `json:"oob_ip,omitempty"` @@ -84,7 +84,7 @@ type _DeviceWithConfigContext DeviceWithConfigContext // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewDeviceWithConfigContext(id int32, url string, display string, deviceType NestedDeviceType, role NestedDeviceRole, deviceRole DeviceDeviceRole, site NestedSite, parentDevice NullableNestedDevice, primaryIp NestedIPAddress, configContext interface{}, created NullableTime, lastUpdated NullableTime, consolePortCount int32, consoleServerPortCount int32, powerPortCount int32, powerOutletCount int32, interfaceCount int32, frontPortCount int32, rearPortCount int32, deviceBayCount int32, moduleBayCount int32, inventoryItemCount int32) *DeviceWithConfigContext { +func NewDeviceWithConfigContext(id int32, url string, display string, deviceType NestedDeviceType, role NestedDeviceRole, deviceRole DeviceDeviceRole, site NestedSite, parentDevice NullableNestedDevice, primaryIp NullableNestedIPAddress, configContext interface{}, created NullableTime, lastUpdated NullableTime, consolePortCount int32, consoleServerPortCount int32, powerPortCount int32, powerOutletCount int32, interfaceCount int32, frontPortCount int32, rearPortCount int32, deviceBayCount int32, moduleBayCount int32, inventoryItemCount int32) *DeviceWithConfigContext { this := DeviceWithConfigContext{} this.Id = id this.Url = url @@ -829,27 +829,29 @@ func (o *DeviceWithConfigContext) SetAirflow(v DeviceAirflow) { } // GetPrimaryIp returns the PrimaryIp field value +// If the value is explicit nil, the zero value for NestedIPAddress will be returned func (o *DeviceWithConfigContext) GetPrimaryIp() NestedIPAddress { - if o == nil { + if o == nil || o.PrimaryIp.Get() == nil { var ret NestedIPAddress return ret } - return o.PrimaryIp + return *o.PrimaryIp.Get() } // GetPrimaryIpOk returns a tuple with the PrimaryIp field value // and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned func (o *DeviceWithConfigContext) GetPrimaryIpOk() (*NestedIPAddress, bool) { if o == nil { return nil, false } - return &o.PrimaryIp, true + return o.PrimaryIp.Get(), o.PrimaryIp.IsSet() } // SetPrimaryIp sets field value func (o *DeviceWithConfigContext) SetPrimaryIp(v NestedIPAddress) { - o.PrimaryIp = v + o.PrimaryIp.Set(&v) } // GetPrimaryIp4 returns the PrimaryIp4 field value if set, zero value otherwise (both if not set or set to explicit null). @@ -1732,7 +1734,7 @@ func (o DeviceWithConfigContext) ToMap() (map[string]interface{}, error) { if !IsNil(o.Airflow) { toSerialize["airflow"] = o.Airflow } - toSerialize["primary_ip"] = o.PrimaryIp + toSerialize["primary_ip"] = o.PrimaryIp.Get() if o.PrimaryIp4.IsSet() { toSerialize["primary_ip4"] = o.PrimaryIp4.Get() } diff --git a/model_virtual_machine_with_config_context.go b/model_virtual_machine_with_config_context.go index 2c016bbbb..2187c8fb7 100644 --- a/model_virtual_machine_with_config_context.go +++ b/model_virtual_machine_with_config_context.go @@ -32,7 +32,7 @@ type VirtualMachineWithConfigContext struct { Role NullableNestedDeviceRole `json:"role,omitempty"` Tenant NullableNestedTenant `json:"tenant,omitempty"` Platform NullableNestedPlatform `json:"platform,omitempty"` - PrimaryIp NestedIPAddress `json:"primary_ip"` + PrimaryIp NullableNestedIPAddress `json:"primary_ip"` PrimaryIp4 NullableNestedIPAddress `json:"primary_ip4,omitempty"` PrimaryIp6 NullableNestedIPAddress `json:"primary_ip6,omitempty"` Vcpus NullableFloat64 `json:"vcpus,omitempty"` @@ -58,7 +58,7 @@ type _VirtualMachineWithConfigContext VirtualMachineWithConfigContext // This constructor will assign default values to properties that have it defined, // and makes sure properties required by API are set, but the set of arguments // will change when the set of required properties is changed -func NewVirtualMachineWithConfigContext(id int32, url string, display string, name string, primaryIp NestedIPAddress, configContext interface{}, created NullableTime, lastUpdated NullableTime, interfaceCount int32, virtualDiskCount int32) *VirtualMachineWithConfigContext { +func NewVirtualMachineWithConfigContext(id int32, url string, display string, name string, primaryIp NullableNestedIPAddress, configContext interface{}, created NullableTime, lastUpdated NullableTime, interfaceCount int32, virtualDiskCount int32) *VirtualMachineWithConfigContext { this := VirtualMachineWithConfigContext{} this.Id = id this.Url = url @@ -468,27 +468,29 @@ func (o *VirtualMachineWithConfigContext) UnsetPlatform() { } // GetPrimaryIp returns the PrimaryIp field value +// If the value is explicit nil, the zero value for NestedIPAddress will be returned func (o *VirtualMachineWithConfigContext) GetPrimaryIp() NestedIPAddress { - if o == nil { + if o == nil || o.PrimaryIp.Get() == nil { var ret NestedIPAddress return ret } - return o.PrimaryIp + return *o.PrimaryIp.Get() } // GetPrimaryIpOk returns a tuple with the PrimaryIp field value // and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned func (o *VirtualMachineWithConfigContext) GetPrimaryIpOk() (*NestedIPAddress, bool) { if o == nil { return nil, false } - return &o.PrimaryIp, true + return o.PrimaryIp.Get(), o.PrimaryIp.IsSet() } // SetPrimaryIp sets field value func (o *VirtualMachineWithConfigContext) SetPrimaryIp(v NestedIPAddress) { - o.PrimaryIp = v + o.PrimaryIp.Set(&v) } // GetPrimaryIp4 returns the PrimaryIp4 field value if set, zero value otherwise (both if not set or set to explicit null). @@ -1028,7 +1030,7 @@ func (o VirtualMachineWithConfigContext) ToMap() (map[string]interface{}, error) if o.Platform.IsSet() { toSerialize["platform"] = o.Platform.Get() } - toSerialize["primary_ip"] = o.PrimaryIp + toSerialize["primary_ip"] = o.PrimaryIp.Get() if o.PrimaryIp4.IsSet() { toSerialize["primary_ip4"] = o.PrimaryIp4.Get() } diff --git a/scripts/fix-spec.py b/scripts/fix-spec.py index e3e3f403b..926763bdb 100755 --- a/scripts/fix-spec.py +++ b/scripts/fix-spec.py @@ -19,9 +19,15 @@ if 'properties' in prop and 'value' in prop['properties'] and 'enum' in prop['properties']['value'] and None in prop['properties']['value']['enum']: prop['properties']['value']['enum'].remove(None) - # Fix "parent_device" nullable type - if 'parent_device' in schema['properties']: - schema['properties']['parent_device']['nullable'] = True + # Fix nullable types + nullable_types = [ + 'parent_device', + 'primary_ip', + ] + + for ntype in nullable_types: + if ntype in schema['properties']: + schema['properties'][ntype]['nullable'] = True # Save the spec file with open(SPEC_PATH, 'w') as file: