From 56fd413d6959ccdd48cbb59c4baa9d5e8c65f203 Mon Sep 17 00:00:00 2001 From: Felix Edelmann Date: Tue, 25 Jun 2024 12:19:14 +0200 Subject: [PATCH 1/4] Quick fix for netbox-community/go-netbox#165: Make some *_count fields non-required --- api/openapi.yaml | 8 ----- docs/Cluster.md | 9 ++++-- docs/DeviceRole.md | 16 ++++++++-- docs/DeviceType.md | 9 ++++-- docs/Manufacturer.md | 9 ++++-- docs/Platform.md | 16 ++++++++-- docs/Rack.md | 9 ++++-- model_cluster.go | 36 +++++++++++++--------- model_device_role.go | 70 ++++++++++++++++++++++++++----------------- model_device_type.go | 36 +++++++++++++--------- model_manufacturer.go | 36 +++++++++++++--------- model_platform.go | 70 ++++++++++++++++++++++++++----------------- model_rack.go | 36 +++++++++++++--------- scripts/fix-spec.py | 11 ++++++- 14 files changed, 238 insertions(+), 133 deletions(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index 75765d6508..a995bf63b9 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -102497,7 +102497,6 @@ components: - id - name - url - - virtualmachine_count ClusterGroup: type: object description: Adds support for custom fields and tags. @@ -105609,13 +105608,11 @@ components: format: int64 readOnly: true required: - - device_count - display - id - name - slug - url - - virtualmachine_count DeviceRoleRequest: type: object description: Adds support for custom fields and tags. @@ -105685,7 +105682,6 @@ components: format: int64 readOnly: true required: - - device_count - display - id - manufacturer @@ -113955,7 +113951,6 @@ components: format: int64 readOnly: true required: - - devicetype_count - display - id - name @@ -126667,13 +126662,11 @@ components: format: int64 readOnly: true required: - - device_count - display - id - name - slug - url - - virtualmachine_count PlatformRequest: type: object description: Adds support for custom fields and tags. @@ -129230,7 +129223,6 @@ components: format: int64 readOnly: true required: - - device_count - display - id - name diff --git a/docs/Cluster.md b/docs/Cluster.md index 53f6ac8f25..00443ca407 100644 --- a/docs/Cluster.md +++ b/docs/Cluster.md @@ -9,13 +9,13 @@ Name | Type | Description | Notes **Display** | **string** | | [readonly] **Name** | **string** | | **Description** | Pointer to **string** | | [optional] -**VirtualmachineCount** | **int64** | | [readonly] +**VirtualmachineCount** | Pointer to **int64** | | [optional] [readonly] ## Methods ### NewCluster -`func NewCluster(id int32, url string, display string, name string, virtualmachineCount int64, ) *Cluster` +`func NewCluster(id int32, url string, display string, name string, ) *Cluster` NewCluster instantiates a new Cluster object This constructor will assign default values to properties that have it defined, @@ -154,6 +154,11 @@ and a boolean to check if the value has been set. SetVirtualmachineCount sets VirtualmachineCount field to given value. +### HasVirtualmachineCount + +`func (o *Cluster) HasVirtualmachineCount() bool` + +HasVirtualmachineCount returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/DeviceRole.md b/docs/DeviceRole.md index 69757a60f2..99ecb82bcc 100644 --- a/docs/DeviceRole.md +++ b/docs/DeviceRole.md @@ -10,14 +10,14 @@ Name | Type | Description | Notes **Name** | **string** | | **Slug** | **string** | | **Description** | Pointer to **string** | | [optional] -**DeviceCount** | **int64** | | [readonly] -**VirtualmachineCount** | **int64** | | [readonly] +**DeviceCount** | Pointer to **int64** | | [optional] [readonly] +**VirtualmachineCount** | Pointer to **int64** | | [optional] [readonly] ## Methods ### NewDeviceRole -`func NewDeviceRole(id int32, url string, display string, name string, slug string, deviceCount int64, virtualmachineCount int64, ) *DeviceRole` +`func NewDeviceRole(id int32, url string, display string, name string, slug string, ) *DeviceRole` NewDeviceRole instantiates a new DeviceRole object This constructor will assign default values to properties that have it defined, @@ -176,6 +176,11 @@ and a boolean to check if the value has been set. SetDeviceCount sets DeviceCount field to given value. +### HasDeviceCount + +`func (o *DeviceRole) HasDeviceCount() bool` + +HasDeviceCount returns a boolean if a field has been set. ### GetVirtualmachineCount @@ -196,6 +201,11 @@ and a boolean to check if the value has been set. SetVirtualmachineCount sets VirtualmachineCount field to given value. +### HasVirtualmachineCount + +`func (o *DeviceRole) HasVirtualmachineCount() bool` + +HasVirtualmachineCount returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/DeviceType.md b/docs/DeviceType.md index 0fd8ee2280..9d02d28e7f 100644 --- a/docs/DeviceType.md +++ b/docs/DeviceType.md @@ -11,13 +11,13 @@ Name | Type | Description | Notes **Model** | **string** | | **Slug** | **string** | | **Description** | Pointer to **string** | | [optional] -**DeviceCount** | **int64** | | [readonly] +**DeviceCount** | Pointer to **int64** | | [optional] [readonly] ## Methods ### NewDeviceType -`func NewDeviceType(id int32, url string, display string, manufacturer Manufacturer, model string, slug string, deviceCount int64, ) *DeviceType` +`func NewDeviceType(id int32, url string, display string, manufacturer Manufacturer, model string, slug string, ) *DeviceType` NewDeviceType instantiates a new DeviceType object This constructor will assign default values to properties that have it defined, @@ -196,6 +196,11 @@ and a boolean to check if the value has been set. SetDeviceCount sets DeviceCount field to given value. +### HasDeviceCount + +`func (o *DeviceType) HasDeviceCount() bool` + +HasDeviceCount returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/Manufacturer.md b/docs/Manufacturer.md index c4c2211adc..753c72fe61 100644 --- a/docs/Manufacturer.md +++ b/docs/Manufacturer.md @@ -10,13 +10,13 @@ Name | Type | Description | Notes **Name** | **string** | | **Slug** | **string** | | **Description** | Pointer to **string** | | [optional] -**DevicetypeCount** | **int64** | | [readonly] +**DevicetypeCount** | Pointer to **int64** | | [optional] [readonly] ## Methods ### NewManufacturer -`func NewManufacturer(id int32, url string, display string, name string, slug string, devicetypeCount int64, ) *Manufacturer` +`func NewManufacturer(id int32, url string, display string, name string, slug string, ) *Manufacturer` NewManufacturer instantiates a new Manufacturer object This constructor will assign default values to properties that have it defined, @@ -175,6 +175,11 @@ and a boolean to check if the value has been set. SetDevicetypeCount sets DevicetypeCount field to given value. +### HasDevicetypeCount + +`func (o *Manufacturer) HasDevicetypeCount() bool` + +HasDevicetypeCount returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/Platform.md b/docs/Platform.md index abceb730ab..d4c3b9c569 100644 --- a/docs/Platform.md +++ b/docs/Platform.md @@ -10,14 +10,14 @@ Name | Type | Description | Notes **Name** | **string** | | **Slug** | **string** | | **Description** | Pointer to **string** | | [optional] -**DeviceCount** | **int64** | | [readonly] -**VirtualmachineCount** | **int64** | | [readonly] +**DeviceCount** | Pointer to **int64** | | [optional] [readonly] +**VirtualmachineCount** | Pointer to **int64** | | [optional] [readonly] ## Methods ### NewPlatform -`func NewPlatform(id int32, url string, display string, name string, slug string, deviceCount int64, virtualmachineCount int64, ) *Platform` +`func NewPlatform(id int32, url string, display string, name string, slug string, ) *Platform` NewPlatform instantiates a new Platform object This constructor will assign default values to properties that have it defined, @@ -176,6 +176,11 @@ and a boolean to check if the value has been set. SetDeviceCount sets DeviceCount field to given value. +### HasDeviceCount + +`func (o *Platform) HasDeviceCount() bool` + +HasDeviceCount returns a boolean if a field has been set. ### GetVirtualmachineCount @@ -196,6 +201,11 @@ and a boolean to check if the value has been set. SetVirtualmachineCount sets VirtualmachineCount field to given value. +### HasVirtualmachineCount + +`func (o *Platform) HasVirtualmachineCount() bool` + +HasVirtualmachineCount returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/Rack.md b/docs/Rack.md index 5628a5efc9..20e4a6cb29 100644 --- a/docs/Rack.md +++ b/docs/Rack.md @@ -9,13 +9,13 @@ Name | Type | Description | Notes **Display** | **string** | | [readonly] **Name** | **string** | | **Description** | Pointer to **string** | | [optional] -**DeviceCount** | **int64** | | [readonly] +**DeviceCount** | Pointer to **int64** | | [optional] [readonly] ## Methods ### NewRack -`func NewRack(id int32, url string, display string, name string, deviceCount int64, ) *Rack` +`func NewRack(id int32, url string, display string, name string, ) *Rack` NewRack instantiates a new Rack object This constructor will assign default values to properties that have it defined, @@ -154,6 +154,11 @@ and a boolean to check if the value has been set. SetDeviceCount sets DeviceCount field to given value. +### HasDeviceCount + +`func (o *Rack) HasDeviceCount() bool` + +HasDeviceCount returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/model_cluster.go b/model_cluster.go index ac931d63f5..64f264c1cd 100644 --- a/model_cluster.go +++ b/model_cluster.go @@ -25,7 +25,7 @@ type Cluster struct { Display string `json:"display"` Name string `json:"name"` Description *string `json:"description,omitempty"` - VirtualmachineCount int64 `json:"virtualmachine_count"` + VirtualmachineCount *int64 `json:"virtualmachine_count,omitempty"` AdditionalProperties map[string]interface{} } @@ -35,13 +35,12 @@ type _Cluster Cluster // 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 NewCluster(id int32, url string, display string, name string, virtualmachineCount int64) *Cluster { +func NewCluster(id int32, url string, display string, name string) *Cluster { this := Cluster{} this.Id = id this.Url = url this.Display = display this.Name = name - this.VirtualmachineCount = virtualmachineCount return &this } @@ -181,28 +180,36 @@ func (o *Cluster) SetDescription(v string) { o.Description = &v } -// GetVirtualmachineCount returns the VirtualmachineCount field value +// GetVirtualmachineCount returns the VirtualmachineCount field value if set, zero value otherwise. func (o *Cluster) GetVirtualmachineCount() int64 { - if o == nil { + if o == nil || IsNil(o.VirtualmachineCount) { var ret int64 return ret } - - return o.VirtualmachineCount + return *o.VirtualmachineCount } -// GetVirtualmachineCountOk returns a tuple with the VirtualmachineCount field value +// GetVirtualmachineCountOk returns a tuple with the VirtualmachineCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Cluster) GetVirtualmachineCountOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.VirtualmachineCount) { return nil, false } - return &o.VirtualmachineCount, true + return o.VirtualmachineCount, true +} + +// HasVirtualmachineCount returns a boolean if a field has been set. +func (o *Cluster) HasVirtualmachineCount() bool { + if o != nil && !IsNil(o.VirtualmachineCount) { + return true + } + + return false } -// SetVirtualmachineCount sets field value +// SetVirtualmachineCount gets a reference to the given int64 and assigns it to the VirtualmachineCount field. func (o *Cluster) SetVirtualmachineCount(v int64) { - o.VirtualmachineCount = v + o.VirtualmachineCount = &v } func (o Cluster) MarshalJSON() ([]byte, error) { @@ -222,7 +229,9 @@ func (o Cluster) ToMap() (map[string]interface{}, error) { if !IsNil(o.Description) { toSerialize["description"] = o.Description } - toSerialize["virtualmachine_count"] = o.VirtualmachineCount + if !IsNil(o.VirtualmachineCount) { + toSerialize["virtualmachine_count"] = o.VirtualmachineCount + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -240,7 +249,6 @@ func (o *Cluster) UnmarshalJSON(data []byte) (err error) { "url", "display", "name", - "virtualmachine_count", } allProperties := make(map[string]interface{}) diff --git a/model_device_role.go b/model_device_role.go index 1c2cf2a0c6..bcd70a8fe3 100644 --- a/model_device_role.go +++ b/model_device_role.go @@ -26,8 +26,8 @@ type DeviceRole struct { Name string `json:"name"` Slug string `json:"slug"` Description *string `json:"description,omitempty"` - DeviceCount int64 `json:"device_count"` - VirtualmachineCount int64 `json:"virtualmachine_count"` + DeviceCount *int64 `json:"device_count,omitempty"` + VirtualmachineCount *int64 `json:"virtualmachine_count,omitempty"` AdditionalProperties map[string]interface{} } @@ -37,15 +37,13 @@ type _DeviceRole DeviceRole // 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 NewDeviceRole(id int32, url string, display string, name string, slug string, deviceCount int64, virtualmachineCount int64) *DeviceRole { +func NewDeviceRole(id int32, url string, display string, name string, slug string) *DeviceRole { this := DeviceRole{} this.Id = id this.Url = url this.Display = display this.Name = name this.Slug = slug - this.DeviceCount = deviceCount - this.VirtualmachineCount = virtualmachineCount return &this } @@ -209,52 +207,68 @@ func (o *DeviceRole) SetDescription(v string) { o.Description = &v } -// GetDeviceCount returns the DeviceCount field value +// GetDeviceCount returns the DeviceCount field value if set, zero value otherwise. func (o *DeviceRole) GetDeviceCount() int64 { - if o == nil { + if o == nil || IsNil(o.DeviceCount) { var ret int64 return ret } - - return o.DeviceCount + return *o.DeviceCount } -// GetDeviceCountOk returns a tuple with the DeviceCount field value +// GetDeviceCountOk returns a tuple with the DeviceCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *DeviceRole) GetDeviceCountOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.DeviceCount) { return nil, false } - return &o.DeviceCount, true + return o.DeviceCount, true +} + +// HasDeviceCount returns a boolean if a field has been set. +func (o *DeviceRole) HasDeviceCount() bool { + if o != nil && !IsNil(o.DeviceCount) { + return true + } + + return false } -// SetDeviceCount sets field value +// SetDeviceCount gets a reference to the given int64 and assigns it to the DeviceCount field. func (o *DeviceRole) SetDeviceCount(v int64) { - o.DeviceCount = v + o.DeviceCount = &v } -// GetVirtualmachineCount returns the VirtualmachineCount field value +// GetVirtualmachineCount returns the VirtualmachineCount field value if set, zero value otherwise. func (o *DeviceRole) GetVirtualmachineCount() int64 { - if o == nil { + if o == nil || IsNil(o.VirtualmachineCount) { var ret int64 return ret } - - return o.VirtualmachineCount + return *o.VirtualmachineCount } -// GetVirtualmachineCountOk returns a tuple with the VirtualmachineCount field value +// GetVirtualmachineCountOk returns a tuple with the VirtualmachineCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *DeviceRole) GetVirtualmachineCountOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.VirtualmachineCount) { return nil, false } - return &o.VirtualmachineCount, true + return o.VirtualmachineCount, true +} + +// HasVirtualmachineCount returns a boolean if a field has been set. +func (o *DeviceRole) HasVirtualmachineCount() bool { + if o != nil && !IsNil(o.VirtualmachineCount) { + return true + } + + return false } -// SetVirtualmachineCount sets field value +// SetVirtualmachineCount gets a reference to the given int64 and assigns it to the VirtualmachineCount field. func (o *DeviceRole) SetVirtualmachineCount(v int64) { - o.VirtualmachineCount = v + o.VirtualmachineCount = &v } func (o DeviceRole) MarshalJSON() ([]byte, error) { @@ -275,8 +289,12 @@ func (o DeviceRole) ToMap() (map[string]interface{}, error) { if !IsNil(o.Description) { toSerialize["description"] = o.Description } - toSerialize["device_count"] = o.DeviceCount - toSerialize["virtualmachine_count"] = o.VirtualmachineCount + if !IsNil(o.DeviceCount) { + toSerialize["device_count"] = o.DeviceCount + } + if !IsNil(o.VirtualmachineCount) { + toSerialize["virtualmachine_count"] = o.VirtualmachineCount + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -295,8 +313,6 @@ func (o *DeviceRole) UnmarshalJSON(data []byte) (err error) { "display", "name", "slug", - "device_count", - "virtualmachine_count", } allProperties := make(map[string]interface{}) diff --git a/model_device_type.go b/model_device_type.go index 6b71ca2b42..491bcc1772 100644 --- a/model_device_type.go +++ b/model_device_type.go @@ -27,7 +27,7 @@ type DeviceType struct { Model string `json:"model"` Slug string `json:"slug"` Description *string `json:"description,omitempty"` - DeviceCount int64 `json:"device_count"` + DeviceCount *int64 `json:"device_count,omitempty"` AdditionalProperties map[string]interface{} } @@ -37,7 +37,7 @@ type _DeviceType DeviceType // 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 NewDeviceType(id int32, url string, display string, manufacturer Manufacturer, model string, slug string, deviceCount int64) *DeviceType { +func NewDeviceType(id int32, url string, display string, manufacturer Manufacturer, model string, slug string) *DeviceType { this := DeviceType{} this.Id = id this.Url = url @@ -45,7 +45,6 @@ func NewDeviceType(id int32, url string, display string, manufacturer Manufactur this.Manufacturer = manufacturer this.Model = model this.Slug = slug - this.DeviceCount = deviceCount return &this } @@ -233,28 +232,36 @@ func (o *DeviceType) SetDescription(v string) { o.Description = &v } -// GetDeviceCount returns the DeviceCount field value +// GetDeviceCount returns the DeviceCount field value if set, zero value otherwise. func (o *DeviceType) GetDeviceCount() int64 { - if o == nil { + if o == nil || IsNil(o.DeviceCount) { var ret int64 return ret } - - return o.DeviceCount + return *o.DeviceCount } -// GetDeviceCountOk returns a tuple with the DeviceCount field value +// GetDeviceCountOk returns a tuple with the DeviceCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *DeviceType) GetDeviceCountOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.DeviceCount) { return nil, false } - return &o.DeviceCount, true + return o.DeviceCount, true +} + +// HasDeviceCount returns a boolean if a field has been set. +func (o *DeviceType) HasDeviceCount() bool { + if o != nil && !IsNil(o.DeviceCount) { + return true + } + + return false } -// SetDeviceCount sets field value +// SetDeviceCount gets a reference to the given int64 and assigns it to the DeviceCount field. func (o *DeviceType) SetDeviceCount(v int64) { - o.DeviceCount = v + o.DeviceCount = &v } func (o DeviceType) MarshalJSON() ([]byte, error) { @@ -276,7 +283,9 @@ func (o DeviceType) ToMap() (map[string]interface{}, error) { if !IsNil(o.Description) { toSerialize["description"] = o.Description } - toSerialize["device_count"] = o.DeviceCount + if !IsNil(o.DeviceCount) { + toSerialize["device_count"] = o.DeviceCount + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -296,7 +305,6 @@ func (o *DeviceType) UnmarshalJSON(data []byte) (err error) { "manufacturer", "model", "slug", - "device_count", } allProperties := make(map[string]interface{}) diff --git a/model_manufacturer.go b/model_manufacturer.go index 6b8dcd9090..5be331410c 100644 --- a/model_manufacturer.go +++ b/model_manufacturer.go @@ -26,7 +26,7 @@ type Manufacturer struct { Name string `json:"name"` Slug string `json:"slug"` Description *string `json:"description,omitempty"` - DevicetypeCount int64 `json:"devicetype_count"` + DevicetypeCount *int64 `json:"devicetype_count,omitempty"` AdditionalProperties map[string]interface{} } @@ -36,14 +36,13 @@ type _Manufacturer Manufacturer // 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 NewManufacturer(id int32, url string, display string, name string, slug string, devicetypeCount int64) *Manufacturer { +func NewManufacturer(id int32, url string, display string, name string, slug string) *Manufacturer { this := Manufacturer{} this.Id = id this.Url = url this.Display = display this.Name = name this.Slug = slug - this.DevicetypeCount = devicetypeCount return &this } @@ -207,28 +206,36 @@ func (o *Manufacturer) SetDescription(v string) { o.Description = &v } -// GetDevicetypeCount returns the DevicetypeCount field value +// GetDevicetypeCount returns the DevicetypeCount field value if set, zero value otherwise. func (o *Manufacturer) GetDevicetypeCount() int64 { - if o == nil { + if o == nil || IsNil(o.DevicetypeCount) { var ret int64 return ret } - - return o.DevicetypeCount + return *o.DevicetypeCount } -// GetDevicetypeCountOk returns a tuple with the DevicetypeCount field value +// GetDevicetypeCountOk returns a tuple with the DevicetypeCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Manufacturer) GetDevicetypeCountOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.DevicetypeCount) { return nil, false } - return &o.DevicetypeCount, true + return o.DevicetypeCount, true +} + +// HasDevicetypeCount returns a boolean if a field has been set. +func (o *Manufacturer) HasDevicetypeCount() bool { + if o != nil && !IsNil(o.DevicetypeCount) { + return true + } + + return false } -// SetDevicetypeCount sets field value +// SetDevicetypeCount gets a reference to the given int64 and assigns it to the DevicetypeCount field. func (o *Manufacturer) SetDevicetypeCount(v int64) { - o.DevicetypeCount = v + o.DevicetypeCount = &v } func (o Manufacturer) MarshalJSON() ([]byte, error) { @@ -249,7 +256,9 @@ func (o Manufacturer) ToMap() (map[string]interface{}, error) { if !IsNil(o.Description) { toSerialize["description"] = o.Description } - toSerialize["devicetype_count"] = o.DevicetypeCount + if !IsNil(o.DevicetypeCount) { + toSerialize["devicetype_count"] = o.DevicetypeCount + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -268,7 +277,6 @@ func (o *Manufacturer) UnmarshalJSON(data []byte) (err error) { "display", "name", "slug", - "devicetype_count", } allProperties := make(map[string]interface{}) diff --git a/model_platform.go b/model_platform.go index 5ab96ce266..95143bd8e3 100644 --- a/model_platform.go +++ b/model_platform.go @@ -26,8 +26,8 @@ type Platform struct { Name string `json:"name"` Slug string `json:"slug"` Description *string `json:"description,omitempty"` - DeviceCount int64 `json:"device_count"` - VirtualmachineCount int64 `json:"virtualmachine_count"` + DeviceCount *int64 `json:"device_count,omitempty"` + VirtualmachineCount *int64 `json:"virtualmachine_count,omitempty"` AdditionalProperties map[string]interface{} } @@ -37,15 +37,13 @@ type _Platform Platform // 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 NewPlatform(id int32, url string, display string, name string, slug string, deviceCount int64, virtualmachineCount int64) *Platform { +func NewPlatform(id int32, url string, display string, name string, slug string) *Platform { this := Platform{} this.Id = id this.Url = url this.Display = display this.Name = name this.Slug = slug - this.DeviceCount = deviceCount - this.VirtualmachineCount = virtualmachineCount return &this } @@ -209,52 +207,68 @@ func (o *Platform) SetDescription(v string) { o.Description = &v } -// GetDeviceCount returns the DeviceCount field value +// GetDeviceCount returns the DeviceCount field value if set, zero value otherwise. func (o *Platform) GetDeviceCount() int64 { - if o == nil { + if o == nil || IsNil(o.DeviceCount) { var ret int64 return ret } - - return o.DeviceCount + return *o.DeviceCount } -// GetDeviceCountOk returns a tuple with the DeviceCount field value +// GetDeviceCountOk returns a tuple with the DeviceCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Platform) GetDeviceCountOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.DeviceCount) { return nil, false } - return &o.DeviceCount, true + return o.DeviceCount, true +} + +// HasDeviceCount returns a boolean if a field has been set. +func (o *Platform) HasDeviceCount() bool { + if o != nil && !IsNil(o.DeviceCount) { + return true + } + + return false } -// SetDeviceCount sets field value +// SetDeviceCount gets a reference to the given int64 and assigns it to the DeviceCount field. func (o *Platform) SetDeviceCount(v int64) { - o.DeviceCount = v + o.DeviceCount = &v } -// GetVirtualmachineCount returns the VirtualmachineCount field value +// GetVirtualmachineCount returns the VirtualmachineCount field value if set, zero value otherwise. func (o *Platform) GetVirtualmachineCount() int64 { - if o == nil { + if o == nil || IsNil(o.VirtualmachineCount) { var ret int64 return ret } - - return o.VirtualmachineCount + return *o.VirtualmachineCount } -// GetVirtualmachineCountOk returns a tuple with the VirtualmachineCount field value +// GetVirtualmachineCountOk returns a tuple with the VirtualmachineCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Platform) GetVirtualmachineCountOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.VirtualmachineCount) { return nil, false } - return &o.VirtualmachineCount, true + return o.VirtualmachineCount, true +} + +// HasVirtualmachineCount returns a boolean if a field has been set. +func (o *Platform) HasVirtualmachineCount() bool { + if o != nil && !IsNil(o.VirtualmachineCount) { + return true + } + + return false } -// SetVirtualmachineCount sets field value +// SetVirtualmachineCount gets a reference to the given int64 and assigns it to the VirtualmachineCount field. func (o *Platform) SetVirtualmachineCount(v int64) { - o.VirtualmachineCount = v + o.VirtualmachineCount = &v } func (o Platform) MarshalJSON() ([]byte, error) { @@ -275,8 +289,12 @@ func (o Platform) ToMap() (map[string]interface{}, error) { if !IsNil(o.Description) { toSerialize["description"] = o.Description } - toSerialize["device_count"] = o.DeviceCount - toSerialize["virtualmachine_count"] = o.VirtualmachineCount + if !IsNil(o.DeviceCount) { + toSerialize["device_count"] = o.DeviceCount + } + if !IsNil(o.VirtualmachineCount) { + toSerialize["virtualmachine_count"] = o.VirtualmachineCount + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -295,8 +313,6 @@ func (o *Platform) UnmarshalJSON(data []byte) (err error) { "display", "name", "slug", - "device_count", - "virtualmachine_count", } allProperties := make(map[string]interface{}) diff --git a/model_rack.go b/model_rack.go index 471e264e13..95c82770b0 100644 --- a/model_rack.go +++ b/model_rack.go @@ -25,7 +25,7 @@ type Rack struct { Display string `json:"display"` Name string `json:"name"` Description *string `json:"description,omitempty"` - DeviceCount int64 `json:"device_count"` + DeviceCount *int64 `json:"device_count,omitempty"` AdditionalProperties map[string]interface{} } @@ -35,13 +35,12 @@ type _Rack Rack // 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 NewRack(id int32, url string, display string, name string, deviceCount int64) *Rack { +func NewRack(id int32, url string, display string, name string) *Rack { this := Rack{} this.Id = id this.Url = url this.Display = display this.Name = name - this.DeviceCount = deviceCount return &this } @@ -181,28 +180,36 @@ func (o *Rack) SetDescription(v string) { o.Description = &v } -// GetDeviceCount returns the DeviceCount field value +// GetDeviceCount returns the DeviceCount field value if set, zero value otherwise. func (o *Rack) GetDeviceCount() int64 { - if o == nil { + if o == nil || IsNil(o.DeviceCount) { var ret int64 return ret } - - return o.DeviceCount + return *o.DeviceCount } -// GetDeviceCountOk returns a tuple with the DeviceCount field value +// GetDeviceCountOk returns a tuple with the DeviceCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Rack) GetDeviceCountOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.DeviceCount) { return nil, false } - return &o.DeviceCount, true + return o.DeviceCount, true +} + +// HasDeviceCount returns a boolean if a field has been set. +func (o *Rack) HasDeviceCount() bool { + if o != nil && !IsNil(o.DeviceCount) { + return true + } + + return false } -// SetDeviceCount sets field value +// SetDeviceCount gets a reference to the given int64 and assigns it to the DeviceCount field. func (o *Rack) SetDeviceCount(v int64) { - o.DeviceCount = v + o.DeviceCount = &v } func (o Rack) MarshalJSON() ([]byte, error) { @@ -222,7 +229,9 @@ func (o Rack) ToMap() (map[string]interface{}, error) { if !IsNil(o.Description) { toSerialize["description"] = o.Description } - toSerialize["device_count"] = o.DeviceCount + if !IsNil(o.DeviceCount) { + toSerialize["device_count"] = o.DeviceCount + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -240,7 +249,6 @@ func (o *Rack) UnmarshalJSON(data []byte) (err error) { "url", "display", "name", - "device_count", } allProperties := make(map[string]interface{}) diff --git a/scripts/fix-spec.py b/scripts/fix-spec.py index fac390124a..e63690bef0 100755 --- a/scripts/fix-spec.py +++ b/scripts/fix-spec.py @@ -39,7 +39,16 @@ for ntype in non_nullable_types: if ntype in schema['properties']: if schema['properties'][ntype]['format'] == 'binary': - schema['properties'][ntype].pop('nullable') + schema['properties'][ntype].pop('nullable', None) + + if 'required' in schema: + non_required_props = [ + 'devicetype_count', + 'device_count', + 'virtualmachine_count', + ] + + schema['required'] = [prop for prop in schema['required'] if prop not in non_required_props] # Save the spec file with open(SPEC_PATH, 'w') as file: From 38594b73abd40cde0585d2750e8507b8e2c95fd9 Mon Sep 17 00:00:00 2001 From: Felix Edelmann Date: Fri, 28 Jun 2024 15:12:42 +0200 Subject: [PATCH 2/4] Fix required props in Device entity --- api/openapi.yaml | 21 +- docs/Device.md | 135 +++++++-- model_device.go | 661 +++++++++++++++++++++++++++----------------- scripts/fix-spec.py | 10 +- 4 files changed, 521 insertions(+), 306 deletions(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index a995bf63b9..24f3a606c0 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -105384,26 +105384,11 @@ components: type: integer readOnly: true required: - - console_port_count - - console_server_port_count - - created - - device_bay_count - - device_type - - display - - front_port_count - id - - interface_count - - inventory_item_count - - last_updated - - module_bay_count - - parent_device - - power_outlet_count - - power_port_count - - primary_ip - - rear_port_count - - role - - site - url + - display + - name + - description DeviceBay: type: object description: Adds support for custom fields and tags. diff --git a/docs/Device.md b/docs/Device.md index ee4593df23..c83083a9c8 100644 --- a/docs/Device.md +++ b/docs/Device.md @@ -7,24 +7,24 @@ Name | Type | Description | Notes **Id** | **int32** | | [readonly] **Url** | **string** | | [readonly] **Display** | **string** | | [readonly] -**Name** | Pointer to **NullableString** | | [optional] -**DeviceType** | [**DeviceType**](DeviceType.md) | | -**Role** | [**DeviceRole**](DeviceRole.md) | | +**Name** | **NullableString** | | +**DeviceType** | Pointer to [**DeviceType**](DeviceType.md) | | [optional] +**Role** | Pointer to [**DeviceRole**](DeviceRole.md) | | [optional] **Tenant** | Pointer to [**NullableTenant**](Tenant.md) | | [optional] **Platform** | Pointer to [**NullablePlatform**](Platform.md) | | [optional] **Serial** | Pointer to **string** | Chassis serial number, assigned by the manufacturer | [optional] **AssetTag** | Pointer to **NullableString** | A unique tag used to identify this device | [optional] -**Site** | [**Site**](Site.md) | | +**Site** | Pointer to [**Site**](Site.md) | | [optional] **Location** | Pointer to [**NullableLocation**](Location.md) | | [optional] **Rack** | Pointer to [**NullableRack**](Rack.md) | | [optional] **Position** | Pointer to **NullableFloat64** | | [optional] **Face** | Pointer to [**DeviceFace**](DeviceFace.md) | | [optional] **Latitude** | Pointer to **NullableFloat64** | GPS coordinate in decimal format (xx.yyyyyy) | [optional] **Longitude** | Pointer to **NullableFloat64** | GPS coordinate in decimal format (xx.yyyyyy) | [optional] -**ParentDevice** | [**NullableNestedDevice**](NestedDevice.md) | | [readonly] +**ParentDevice** | Pointer to [**NullableNestedDevice**](NestedDevice.md) | | [optional] [readonly] **Status** | Pointer to [**DeviceStatus**](DeviceStatus.md) | | [optional] **Airflow** | Pointer to [**DeviceAirflow**](DeviceAirflow.md) | | [optional] -**PrimaryIp** | [**NullableIPAddress**](IPAddress.md) | | [readonly] +**PrimaryIp** | Pointer to [**NullableIPAddress**](IPAddress.md) | | [optional] [readonly] **PrimaryIp4** | Pointer to [**NullableIPAddress**](IPAddress.md) | | [optional] **PrimaryIp6** | Pointer to [**NullableIPAddress**](IPAddress.md) | | [optional] **OobIp** | Pointer to [**NullableIPAddress**](IPAddress.md) | | [optional] @@ -32,30 +32,30 @@ Name | Type | Description | Notes **VirtualChassis** | Pointer to [**NullableVirtualChassis**](VirtualChassis.md) | | [optional] **VcPosition** | Pointer to **NullableInt32** | | [optional] **VcPriority** | Pointer to **NullableInt32** | Virtual chassis master election priority | [optional] -**Description** | Pointer to **string** | | [optional] +**Description** | **string** | | **Comments** | Pointer to **string** | | [optional] **ConfigTemplate** | Pointer to [**NullableConfigTemplate**](ConfigTemplate.md) | | [optional] **LocalContextData** | Pointer to **interface{}** | Local config context data takes precedence over source contexts in the final rendered config context | [optional] **Tags** | Pointer to [**[]NestedTag**](NestedTag.md) | | [optional] **CustomFields** | Pointer to **map[string]interface{}** | | [optional] -**Created** | **NullableTime** | | [readonly] -**LastUpdated** | **NullableTime** | | [readonly] -**ConsolePortCount** | **int32** | | [readonly] -**ConsoleServerPortCount** | **int32** | | [readonly] -**PowerPortCount** | **int32** | | [readonly] -**PowerOutletCount** | **int32** | | [readonly] -**InterfaceCount** | **int32** | | [readonly] -**FrontPortCount** | **int32** | | [readonly] -**RearPortCount** | **int32** | | [readonly] -**DeviceBayCount** | **int32** | | [readonly] -**ModuleBayCount** | **int32** | | [readonly] -**InventoryItemCount** | **int32** | | [readonly] +**Created** | Pointer to **NullableTime** | | [optional] [readonly] +**LastUpdated** | Pointer to **NullableTime** | | [optional] [readonly] +**ConsolePortCount** | Pointer to **int32** | | [optional] [readonly] +**ConsoleServerPortCount** | Pointer to **int32** | | [optional] [readonly] +**PowerPortCount** | Pointer to **int32** | | [optional] [readonly] +**PowerOutletCount** | Pointer to **int32** | | [optional] [readonly] +**InterfaceCount** | Pointer to **int32** | | [optional] [readonly] +**FrontPortCount** | Pointer to **int32** | | [optional] [readonly] +**RearPortCount** | Pointer to **int32** | | [optional] [readonly] +**DeviceBayCount** | Pointer to **int32** | | [optional] [readonly] +**ModuleBayCount** | Pointer to **int32** | | [optional] [readonly] +**InventoryItemCount** | Pointer to **int32** | | [optional] [readonly] ## Methods ### NewDevice -`func NewDevice(id int32, url string, display string, deviceType DeviceType, role DeviceRole, site Site, parentDevice NullableNestedDevice, primaryIp NullableIPAddress, 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, name NullableString, description string, ) *Device` NewDevice instantiates a new Device object This constructor will assign default values to properties that have it defined, @@ -149,11 +149,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *Device) HasName() bool` - -HasName returns a boolean if a field has been set. ### SetNameNil @@ -184,6 +179,11 @@ and a boolean to check if the value has been set. SetDeviceType sets DeviceType field to given value. +### HasDeviceType + +`func (o *Device) HasDeviceType() bool` + +HasDeviceType returns a boolean if a field has been set. ### GetRole @@ -204,6 +204,11 @@ and a boolean to check if the value has been set. SetRole sets Role field to given value. +### HasRole + +`func (o *Device) HasRole() bool` + +HasRole returns a boolean if a field has been set. ### GetTenant @@ -354,6 +359,11 @@ and a boolean to check if the value has been set. SetSite sets Site field to given value. +### HasSite + +`func (o *Device) HasSite() bool` + +HasSite returns a boolean if a field has been set. ### GetLocation @@ -574,6 +584,11 @@ and a boolean to check if the value has been set. SetParentDevice sets ParentDevice field to given value. +### HasParentDevice + +`func (o *Device) HasParentDevice() bool` + +HasParentDevice returns a boolean if a field has been set. ### SetParentDeviceNil @@ -654,6 +669,11 @@ and a boolean to check if the value has been set. SetPrimaryIp sets PrimaryIp field to given value. +### HasPrimaryIp + +`func (o *Device) HasPrimaryIp() bool` + +HasPrimaryIp returns a boolean if a field has been set. ### SetPrimaryIpNil @@ -929,11 +949,6 @@ and a boolean to check if the value has been set. SetDescription sets Description field to given value. -### HasDescription - -`func (o *Device) HasDescription() bool` - -HasDescription returns a boolean if a field has been set. ### GetComments @@ -1099,6 +1114,11 @@ and a boolean to check if the value has been set. SetCreated sets Created field to given value. +### HasCreated + +`func (o *Device) HasCreated() bool` + +HasCreated returns a boolean if a field has been set. ### SetCreatedNil @@ -1129,6 +1149,11 @@ and a boolean to check if the value has been set. SetLastUpdated sets LastUpdated field to given value. +### HasLastUpdated + +`func (o *Device) HasLastUpdated() bool` + +HasLastUpdated returns a boolean if a field has been set. ### SetLastUpdatedNil @@ -1159,6 +1184,11 @@ and a boolean to check if the value has been set. SetConsolePortCount sets ConsolePortCount field to given value. +### HasConsolePortCount + +`func (o *Device) HasConsolePortCount() bool` + +HasConsolePortCount returns a boolean if a field has been set. ### GetConsoleServerPortCount @@ -1179,6 +1209,11 @@ and a boolean to check if the value has been set. SetConsoleServerPortCount sets ConsoleServerPortCount field to given value. +### HasConsoleServerPortCount + +`func (o *Device) HasConsoleServerPortCount() bool` + +HasConsoleServerPortCount returns a boolean if a field has been set. ### GetPowerPortCount @@ -1199,6 +1234,11 @@ and a boolean to check if the value has been set. SetPowerPortCount sets PowerPortCount field to given value. +### HasPowerPortCount + +`func (o *Device) HasPowerPortCount() bool` + +HasPowerPortCount returns a boolean if a field has been set. ### GetPowerOutletCount @@ -1219,6 +1259,11 @@ and a boolean to check if the value has been set. SetPowerOutletCount sets PowerOutletCount field to given value. +### HasPowerOutletCount + +`func (o *Device) HasPowerOutletCount() bool` + +HasPowerOutletCount returns a boolean if a field has been set. ### GetInterfaceCount @@ -1239,6 +1284,11 @@ and a boolean to check if the value has been set. SetInterfaceCount sets InterfaceCount field to given value. +### HasInterfaceCount + +`func (o *Device) HasInterfaceCount() bool` + +HasInterfaceCount returns a boolean if a field has been set. ### GetFrontPortCount @@ -1259,6 +1309,11 @@ and a boolean to check if the value has been set. SetFrontPortCount sets FrontPortCount field to given value. +### HasFrontPortCount + +`func (o *Device) HasFrontPortCount() bool` + +HasFrontPortCount returns a boolean if a field has been set. ### GetRearPortCount @@ -1279,6 +1334,11 @@ and a boolean to check if the value has been set. SetRearPortCount sets RearPortCount field to given value. +### HasRearPortCount + +`func (o *Device) HasRearPortCount() bool` + +HasRearPortCount returns a boolean if a field has been set. ### GetDeviceBayCount @@ -1299,6 +1359,11 @@ and a boolean to check if the value has been set. SetDeviceBayCount sets DeviceBayCount field to given value. +### HasDeviceBayCount + +`func (o *Device) HasDeviceBayCount() bool` + +HasDeviceBayCount returns a boolean if a field has been set. ### GetModuleBayCount @@ -1319,6 +1384,11 @@ and a boolean to check if the value has been set. SetModuleBayCount sets ModuleBayCount field to given value. +### HasModuleBayCount + +`func (o *Device) HasModuleBayCount() bool` + +HasModuleBayCount returns a boolean if a field has been set. ### GetInventoryItemCount @@ -1339,6 +1409,11 @@ and a boolean to check if the value has been set. SetInventoryItemCount sets InventoryItemCount field to given value. +### HasInventoryItemCount + +`func (o *Device) HasInventoryItemCount() bool` + +HasInventoryItemCount returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/model_device.go b/model_device.go index 7585fb9dde..701b56150a 100644 --- a/model_device.go +++ b/model_device.go @@ -24,16 +24,16 @@ type Device struct { Id int32 `json:"id"` Url string `json:"url"` Display string `json:"display"` - Name NullableString `json:"name,omitempty"` - DeviceType DeviceType `json:"device_type"` - Role DeviceRole `json:"role"` + Name NullableString `json:"name"` + DeviceType *DeviceType `json:"device_type,omitempty"` + Role *DeviceRole `json:"role,omitempty"` Tenant NullableTenant `json:"tenant,omitempty"` Platform NullablePlatform `json:"platform,omitempty"` // Chassis serial number, assigned by the manufacturer Serial *string `json:"serial,omitempty"` // A unique tag used to identify this device AssetTag NullableString `json:"asset_tag,omitempty"` - Site Site `json:"site"` + Site *Site `json:"site,omitempty"` Location NullableLocation `json:"location,omitempty"` Rack NullableRack `json:"rack,omitempty"` Position NullableFloat64 `json:"position,omitempty"` @@ -42,10 +42,10 @@ type Device struct { Latitude NullableFloat64 `json:"latitude,omitempty"` // GPS coordinate in decimal format (xx.yyyyyy) Longitude NullableFloat64 `json:"longitude,omitempty"` - ParentDevice NullableNestedDevice `json:"parent_device"` + ParentDevice NullableNestedDevice `json:"parent_device,omitempty"` Status *DeviceStatus `json:"status,omitempty"` Airflow *DeviceAirflow `json:"airflow,omitempty"` - PrimaryIp NullableIPAddress `json:"primary_ip"` + PrimaryIp NullableIPAddress `json:"primary_ip,omitempty"` PrimaryIp4 NullableIPAddress `json:"primary_ip4,omitempty"` PrimaryIp6 NullableIPAddress `json:"primary_ip6,omitempty"` OobIp NullableIPAddress `json:"oob_ip,omitempty"` @@ -54,25 +54,25 @@ type Device struct { VcPosition NullableInt32 `json:"vc_position,omitempty"` // Virtual chassis master election priority VcPriority NullableInt32 `json:"vc_priority,omitempty"` - Description *string `json:"description,omitempty"` + Description string `json:"description"` Comments *string `json:"comments,omitempty"` ConfigTemplate NullableConfigTemplate `json:"config_template,omitempty"` // Local config context data takes precedence over source contexts in the final rendered config context LocalContextData interface{} `json:"local_context_data,omitempty"` Tags []NestedTag `json:"tags,omitempty"` CustomFields map[string]interface{} `json:"custom_fields,omitempty"` - Created NullableTime `json:"created"` - LastUpdated NullableTime `json:"last_updated"` - ConsolePortCount int32 `json:"console_port_count"` - ConsoleServerPortCount int32 `json:"console_server_port_count"` - PowerPortCount int32 `json:"power_port_count"` - PowerOutletCount int32 `json:"power_outlet_count"` - InterfaceCount int32 `json:"interface_count"` - FrontPortCount int32 `json:"front_port_count"` - RearPortCount int32 `json:"rear_port_count"` - DeviceBayCount int32 `json:"device_bay_count"` - ModuleBayCount int32 `json:"module_bay_count"` - InventoryItemCount int32 `json:"inventory_item_count"` + Created NullableTime `json:"created,omitempty"` + LastUpdated NullableTime `json:"last_updated,omitempty"` + ConsolePortCount *int32 `json:"console_port_count,omitempty"` + ConsoleServerPortCount *int32 `json:"console_server_port_count,omitempty"` + PowerPortCount *int32 `json:"power_port_count,omitempty"` + PowerOutletCount *int32 `json:"power_outlet_count,omitempty"` + InterfaceCount *int32 `json:"interface_count,omitempty"` + FrontPortCount *int32 `json:"front_port_count,omitempty"` + RearPortCount *int32 `json:"rear_port_count,omitempty"` + DeviceBayCount *int32 `json:"device_bay_count,omitempty"` + ModuleBayCount *int32 `json:"module_bay_count,omitempty"` + InventoryItemCount *int32 `json:"inventory_item_count,omitempty"` AdditionalProperties map[string]interface{} } @@ -82,28 +82,13 @@ 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 DeviceType, role DeviceRole, site Site, parentDevice NullableNestedDevice, primaryIp NullableIPAddress, 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, name NullableString, description string) *Device { this := Device{} this.Id = id this.Url = url this.Display = display - this.DeviceType = deviceType - this.Role = role - this.Site = site - this.ParentDevice = parentDevice - this.PrimaryIp = primaryIp - this.Created = created - this.LastUpdated = lastUpdated - this.ConsolePortCount = consolePortCount - this.ConsoleServerPortCount = consoleServerPortCount - this.PowerPortCount = powerPortCount - this.PowerOutletCount = powerOutletCount - this.InterfaceCount = interfaceCount - this.FrontPortCount = frontPortCount - this.RearPortCount = rearPortCount - this.DeviceBayCount = deviceBayCount - this.ModuleBayCount = moduleBayCount - this.InventoryItemCount = inventoryItemCount + this.Name = name + this.Description = description return &this } @@ -187,16 +172,18 @@ func (o *Device) SetDisplay(v string) { o.Display = v } -// GetName returns the Name field value if set, zero value otherwise (both if not set or set to explicit null). +// GetName returns the Name field value +// If the value is explicit nil, the zero value for string will be returned func (o *Device) GetName() string { - if o == nil || IsNil(o.Name.Get()) { + if o == nil || o.Name.Get() == nil { var ret string return ret } + return *o.Name.Get() } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name 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) GetNameOk() (*string, bool) { @@ -206,76 +193,73 @@ func (o *Device) GetNameOk() (*string, bool) { return o.Name.Get(), o.Name.IsSet() } -// HasName returns a boolean if a field has been set. -func (o *Device) HasName() bool { - if o != nil && o.Name.IsSet() { - return true - } - - return false -} - -// SetName gets a reference to the given NullableString and assigns it to the Name field. +// SetName sets field value func (o *Device) SetName(v string) { o.Name.Set(&v) } -// SetNameNil sets the value for Name to be an explicit nil -func (o *Device) SetNameNil() { - o.Name.Set(nil) -} - -// UnsetName ensures that no value is present for Name, not even an explicit nil -func (o *Device) UnsetName() { - o.Name.Unset() -} - -// GetDeviceType returns the DeviceType field value +// GetDeviceType returns the DeviceType field value if set, zero value otherwise. func (o *Device) GetDeviceType() DeviceType { - if o == nil { + if o == nil || IsNil(o.DeviceType) { var ret DeviceType return ret } - - return o.DeviceType + return *o.DeviceType } -// GetDeviceTypeOk returns a tuple with the DeviceType field value +// GetDeviceTypeOk returns a tuple with the DeviceType field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetDeviceTypeOk() (*DeviceType, bool) { - if o == nil { + if o == nil || IsNil(o.DeviceType) { return nil, false } - return &o.DeviceType, true + return o.DeviceType, true +} + +// HasDeviceType returns a boolean if a field has been set. +func (o *Device) HasDeviceType() bool { + if o != nil && !IsNil(o.DeviceType) { + return true + } + + return false } -// SetDeviceType sets field value +// SetDeviceType gets a reference to the given DeviceType and assigns it to the DeviceType field. func (o *Device) SetDeviceType(v DeviceType) { - o.DeviceType = v + o.DeviceType = &v } -// GetRole returns the Role field value +// GetRole returns the Role field value if set, zero value otherwise. func (o *Device) GetRole() DeviceRole { - if o == nil { + if o == nil || IsNil(o.Role) { var ret DeviceRole return ret } - - return o.Role + return *o.Role } -// GetRoleOk returns a tuple with the Role field value +// GetRoleOk returns a tuple with the Role field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetRoleOk() (*DeviceRole, bool) { - if o == nil { + if o == nil || IsNil(o.Role) { return nil, false } - return &o.Role, true + return o.Role, true +} + +// HasRole returns a boolean if a field has been set. +func (o *Device) HasRole() bool { + if o != nil && !IsNil(o.Role) { + return true + } + + return false } -// SetRole sets field value +// SetRole gets a reference to the given DeviceRole and assigns it to the Role field. func (o *Device) SetRole(v DeviceRole) { - o.Role = v + o.Role = &v } // GetTenant returns the Tenant field value if set, zero value otherwise (both if not set or set to explicit null). @@ -439,28 +423,36 @@ func (o *Device) UnsetAssetTag() { o.AssetTag.Unset() } -// GetSite returns the Site field value +// GetSite returns the Site field value if set, zero value otherwise. func (o *Device) GetSite() Site { - if o == nil { + if o == nil || IsNil(o.Site) { var ret Site return ret } - - return o.Site + return *o.Site } -// GetSiteOk returns a tuple with the Site field value +// GetSiteOk returns a tuple with the Site field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetSiteOk() (*Site, bool) { - if o == nil { + if o == nil || IsNil(o.Site) { return nil, false } - return &o.Site, true + return o.Site, true +} + +// HasSite returns a boolean if a field has been set. +func (o *Device) HasSite() bool { + if o != nil && !IsNil(o.Site) { + return true + } + + return false } -// SetSite sets field value +// SetSite gets a reference to the given Site and assigns it to the Site field. func (o *Device) SetSite(v Site) { - o.Site = v + o.Site = &v } // GetLocation returns the Location field value if set, zero value otherwise (both if not set or set to explicit null). @@ -710,18 +702,16 @@ func (o *Device) UnsetLongitude() { o.Longitude.Unset() } -// GetParentDevice returns the ParentDevice field value -// If the value is explicit nil, the zero value for NestedDevice will be returned +// GetParentDevice returns the ParentDevice field value if set, zero value otherwise (both if not set or set to explicit null). func (o *Device) GetParentDevice() NestedDevice { - if o == nil || o.ParentDevice.Get() == nil { + if o == nil || IsNil(o.ParentDevice.Get()) { var ret NestedDevice return ret } - return *o.ParentDevice.Get() } -// GetParentDeviceOk returns a tuple with the ParentDevice field value +// GetParentDeviceOk returns a tuple with the ParentDevice field value if set, nil otherwise // 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) GetParentDeviceOk() (*NestedDevice, bool) { @@ -731,11 +721,30 @@ func (o *Device) GetParentDeviceOk() (*NestedDevice, bool) { return o.ParentDevice.Get(), o.ParentDevice.IsSet() } -// SetParentDevice sets field value +// HasParentDevice returns a boolean if a field has been set. +func (o *Device) HasParentDevice() bool { + if o != nil && o.ParentDevice.IsSet() { + return true + } + + return false +} + +// SetParentDevice gets a reference to the given NullableNestedDevice and assigns it to the ParentDevice field. func (o *Device) SetParentDevice(v NestedDevice) { o.ParentDevice.Set(&v) } +// SetParentDeviceNil sets the value for ParentDevice to be an explicit nil +func (o *Device) SetParentDeviceNil() { + o.ParentDevice.Set(nil) +} + +// UnsetParentDevice ensures that no value is present for ParentDevice, not even an explicit nil +func (o *Device) UnsetParentDevice() { + o.ParentDevice.Unset() +} + // GetStatus returns the Status field value if set, zero value otherwise. func (o *Device) GetStatus() DeviceStatus { if o == nil || IsNil(o.Status) { @@ -800,18 +809,16 @@ func (o *Device) SetAirflow(v DeviceAirflow) { o.Airflow = &v } -// GetPrimaryIp returns the PrimaryIp field value -// If the value is explicit nil, the zero value for IPAddress will be returned +// GetPrimaryIp returns the PrimaryIp field value if set, zero value otherwise (both if not set or set to explicit null). func (o *Device) GetPrimaryIp() IPAddress { - if o == nil || o.PrimaryIp.Get() == nil { + if o == nil || IsNil(o.PrimaryIp.Get()) { var ret IPAddress return ret } - return *o.PrimaryIp.Get() } -// GetPrimaryIpOk returns a tuple with the PrimaryIp field value +// GetPrimaryIpOk returns a tuple with the PrimaryIp field value if set, nil otherwise // 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() (*IPAddress, bool) { @@ -821,11 +828,30 @@ func (o *Device) GetPrimaryIpOk() (*IPAddress, bool) { return o.PrimaryIp.Get(), o.PrimaryIp.IsSet() } -// SetPrimaryIp sets field value +// HasPrimaryIp returns a boolean if a field has been set. +func (o *Device) HasPrimaryIp() bool { + if o != nil && o.PrimaryIp.IsSet() { + return true + } + + return false +} + +// SetPrimaryIp gets a reference to the given NullableIPAddress and assigns it to the PrimaryIp field. func (o *Device) SetPrimaryIp(v IPAddress) { o.PrimaryIp.Set(&v) } +// SetPrimaryIpNil sets the value for PrimaryIp to be an explicit nil +func (o *Device) SetPrimaryIpNil() { + o.PrimaryIp.Set(nil) +} + +// UnsetPrimaryIp ensures that no value is present for PrimaryIp, not even an explicit nil +func (o *Device) UnsetPrimaryIp() { + o.PrimaryIp.Unset() +} + // GetPrimaryIp4 returns the PrimaryIp4 field value if set, zero value otherwise (both if not set or set to explicit null). func (o *Device) GetPrimaryIp4() IPAddress { if o == nil || IsNil(o.PrimaryIp4.Get()) { @@ -1127,36 +1153,28 @@ func (o *Device) UnsetVcPriority() { o.VcPriority.Unset() } -// GetDescription returns the Description field value if set, zero value otherwise. +// GetDescription returns the Description field value func (o *Device) GetDescription() string { - if o == nil || IsNil(o.Description) { + if o == nil { var ret string return ret } - return *o.Description + + return o.Description } -// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// GetDescriptionOk returns a tuple with the Description field value // and a boolean to check if the value has been set. func (o *Device) GetDescriptionOk() (*string, bool) { - if o == nil || IsNil(o.Description) { + if o == nil { return nil, false } - return o.Description, true + return &o.Description, true } -// HasDescription returns a boolean if a field has been set. -func (o *Device) HasDescription() bool { - if o != nil && !IsNil(o.Description) { - return true - } - - return false -} - -// SetDescription gets a reference to the given string and assigns it to the Description field. +// SetDescription sets field value func (o *Device) SetDescription(v string) { - o.Description = &v + o.Description = v } // GetComments returns the Comments field value if set, zero value otherwise. @@ -1331,18 +1349,16 @@ func (o *Device) SetCustomFields(v map[string]interface{}) { o.CustomFields = v } -// GetCreated returns the Created field value -// If the value is explicit nil, the zero value for time.Time will be returned +// GetCreated returns the Created field value if set, zero value otherwise (both if not set or set to explicit null). func (o *Device) GetCreated() time.Time { - if o == nil || o.Created.Get() == nil { + if o == nil || IsNil(o.Created.Get()) { var ret time.Time return ret } - return *o.Created.Get() } -// GetCreatedOk returns a tuple with the Created field value +// GetCreatedOk returns a tuple with the Created field value if set, nil otherwise // 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) GetCreatedOk() (*time.Time, bool) { @@ -1352,23 +1368,40 @@ func (o *Device) GetCreatedOk() (*time.Time, bool) { return o.Created.Get(), o.Created.IsSet() } -// SetCreated sets field value +// HasCreated returns a boolean if a field has been set. +func (o *Device) HasCreated() bool { + if o != nil && o.Created.IsSet() { + return true + } + + return false +} + +// SetCreated gets a reference to the given NullableTime and assigns it to the Created field. func (o *Device) SetCreated(v time.Time) { o.Created.Set(&v) } -// GetLastUpdated returns the LastUpdated field value -// If the value is explicit nil, the zero value for time.Time will be returned +// SetCreatedNil sets the value for Created to be an explicit nil +func (o *Device) SetCreatedNil() { + o.Created.Set(nil) +} + +// UnsetCreated ensures that no value is present for Created, not even an explicit nil +func (o *Device) UnsetCreated() { + o.Created.Unset() +} + +// GetLastUpdated returns the LastUpdated field value if set, zero value otherwise (both if not set or set to explicit null). func (o *Device) GetLastUpdated() time.Time { - if o == nil || o.LastUpdated.Get() == nil { + if o == nil || IsNil(o.LastUpdated.Get()) { var ret time.Time return ret } - return *o.LastUpdated.Get() } -// GetLastUpdatedOk returns a tuple with the LastUpdated field value +// GetLastUpdatedOk returns a tuple with the LastUpdated field value if set, nil otherwise // 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) GetLastUpdatedOk() (*time.Time, bool) { @@ -1378,249 +1411,348 @@ func (o *Device) GetLastUpdatedOk() (*time.Time, bool) { return o.LastUpdated.Get(), o.LastUpdated.IsSet() } -// SetLastUpdated sets field value +// HasLastUpdated returns a boolean if a field has been set. +func (o *Device) HasLastUpdated() bool { + if o != nil && o.LastUpdated.IsSet() { + return true + } + + return false +} + +// SetLastUpdated gets a reference to the given NullableTime and assigns it to the LastUpdated field. func (o *Device) SetLastUpdated(v time.Time) { o.LastUpdated.Set(&v) } -// GetConsolePortCount returns the ConsolePortCount field value +// SetLastUpdatedNil sets the value for LastUpdated to be an explicit nil +func (o *Device) SetLastUpdatedNil() { + o.LastUpdated.Set(nil) +} + +// UnsetLastUpdated ensures that no value is present for LastUpdated, not even an explicit nil +func (o *Device) UnsetLastUpdated() { + o.LastUpdated.Unset() +} + +// GetConsolePortCount returns the ConsolePortCount field value if set, zero value otherwise. func (o *Device) GetConsolePortCount() int32 { - if o == nil { + if o == nil || IsNil(o.ConsolePortCount) { var ret int32 return ret } - - return o.ConsolePortCount + return *o.ConsolePortCount } -// GetConsolePortCountOk returns a tuple with the ConsolePortCount field value +// GetConsolePortCountOk returns a tuple with the ConsolePortCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetConsolePortCountOk() (*int32, bool) { - if o == nil { + if o == nil || IsNil(o.ConsolePortCount) { return nil, false } - return &o.ConsolePortCount, true + return o.ConsolePortCount, true +} + +// HasConsolePortCount returns a boolean if a field has been set. +func (o *Device) HasConsolePortCount() bool { + if o != nil && !IsNil(o.ConsolePortCount) { + return true + } + + return false } -// SetConsolePortCount sets field value +// SetConsolePortCount gets a reference to the given int32 and assigns it to the ConsolePortCount field. func (o *Device) SetConsolePortCount(v int32) { - o.ConsolePortCount = v + o.ConsolePortCount = &v } -// GetConsoleServerPortCount returns the ConsoleServerPortCount field value +// GetConsoleServerPortCount returns the ConsoleServerPortCount field value if set, zero value otherwise. func (o *Device) GetConsoleServerPortCount() int32 { - if o == nil { + if o == nil || IsNil(o.ConsoleServerPortCount) { var ret int32 return ret } - - return o.ConsoleServerPortCount + return *o.ConsoleServerPortCount } -// GetConsoleServerPortCountOk returns a tuple with the ConsoleServerPortCount field value +// GetConsoleServerPortCountOk returns a tuple with the ConsoleServerPortCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetConsoleServerPortCountOk() (*int32, bool) { - if o == nil { + if o == nil || IsNil(o.ConsoleServerPortCount) { return nil, false } - return &o.ConsoleServerPortCount, true + return o.ConsoleServerPortCount, true } -// SetConsoleServerPortCount sets field value +// HasConsoleServerPortCount returns a boolean if a field has been set. +func (o *Device) HasConsoleServerPortCount() bool { + if o != nil && !IsNil(o.ConsoleServerPortCount) { + return true + } + + return false +} + +// SetConsoleServerPortCount gets a reference to the given int32 and assigns it to the ConsoleServerPortCount field. func (o *Device) SetConsoleServerPortCount(v int32) { - o.ConsoleServerPortCount = v + o.ConsoleServerPortCount = &v } -// GetPowerPortCount returns the PowerPortCount field value +// GetPowerPortCount returns the PowerPortCount field value if set, zero value otherwise. func (o *Device) GetPowerPortCount() int32 { - if o == nil { + if o == nil || IsNil(o.PowerPortCount) { var ret int32 return ret } - - return o.PowerPortCount + return *o.PowerPortCount } -// GetPowerPortCountOk returns a tuple with the PowerPortCount field value +// GetPowerPortCountOk returns a tuple with the PowerPortCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetPowerPortCountOk() (*int32, bool) { - if o == nil { + if o == nil || IsNil(o.PowerPortCount) { return nil, false } - return &o.PowerPortCount, true + return o.PowerPortCount, true } -// SetPowerPortCount sets field value +// HasPowerPortCount returns a boolean if a field has been set. +func (o *Device) HasPowerPortCount() bool { + if o != nil && !IsNil(o.PowerPortCount) { + return true + } + + return false +} + +// SetPowerPortCount gets a reference to the given int32 and assigns it to the PowerPortCount field. func (o *Device) SetPowerPortCount(v int32) { - o.PowerPortCount = v + o.PowerPortCount = &v } -// GetPowerOutletCount returns the PowerOutletCount field value +// GetPowerOutletCount returns the PowerOutletCount field value if set, zero value otherwise. func (o *Device) GetPowerOutletCount() int32 { - if o == nil { + if o == nil || IsNil(o.PowerOutletCount) { var ret int32 return ret } - - return o.PowerOutletCount + return *o.PowerOutletCount } -// GetPowerOutletCountOk returns a tuple with the PowerOutletCount field value +// GetPowerOutletCountOk returns a tuple with the PowerOutletCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetPowerOutletCountOk() (*int32, bool) { - if o == nil { + if o == nil || IsNil(o.PowerOutletCount) { return nil, false } - return &o.PowerOutletCount, true + return o.PowerOutletCount, true +} + +// HasPowerOutletCount returns a boolean if a field has been set. +func (o *Device) HasPowerOutletCount() bool { + if o != nil && !IsNil(o.PowerOutletCount) { + return true + } + + return false } -// SetPowerOutletCount sets field value +// SetPowerOutletCount gets a reference to the given int32 and assigns it to the PowerOutletCount field. func (o *Device) SetPowerOutletCount(v int32) { - o.PowerOutletCount = v + o.PowerOutletCount = &v } -// GetInterfaceCount returns the InterfaceCount field value +// GetInterfaceCount returns the InterfaceCount field value if set, zero value otherwise. func (o *Device) GetInterfaceCount() int32 { - if o == nil { + if o == nil || IsNil(o.InterfaceCount) { var ret int32 return ret } - - return o.InterfaceCount + return *o.InterfaceCount } -// GetInterfaceCountOk returns a tuple with the InterfaceCount field value +// GetInterfaceCountOk returns a tuple with the InterfaceCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetInterfaceCountOk() (*int32, bool) { - if o == nil { + if o == nil || IsNil(o.InterfaceCount) { return nil, false } - return &o.InterfaceCount, true + return o.InterfaceCount, true } -// SetInterfaceCount sets field value +// HasInterfaceCount returns a boolean if a field has been set. +func (o *Device) HasInterfaceCount() bool { + if o != nil && !IsNil(o.InterfaceCount) { + return true + } + + return false +} + +// SetInterfaceCount gets a reference to the given int32 and assigns it to the InterfaceCount field. func (o *Device) SetInterfaceCount(v int32) { - o.InterfaceCount = v + o.InterfaceCount = &v } -// GetFrontPortCount returns the FrontPortCount field value +// GetFrontPortCount returns the FrontPortCount field value if set, zero value otherwise. func (o *Device) GetFrontPortCount() int32 { - if o == nil { + if o == nil || IsNil(o.FrontPortCount) { var ret int32 return ret } - - return o.FrontPortCount + return *o.FrontPortCount } -// GetFrontPortCountOk returns a tuple with the FrontPortCount field value +// GetFrontPortCountOk returns a tuple with the FrontPortCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetFrontPortCountOk() (*int32, bool) { - if o == nil { + if o == nil || IsNil(o.FrontPortCount) { return nil, false } - return &o.FrontPortCount, true + return o.FrontPortCount, true +} + +// HasFrontPortCount returns a boolean if a field has been set. +func (o *Device) HasFrontPortCount() bool { + if o != nil && !IsNil(o.FrontPortCount) { + return true + } + + return false } -// SetFrontPortCount sets field value +// SetFrontPortCount gets a reference to the given int32 and assigns it to the FrontPortCount field. func (o *Device) SetFrontPortCount(v int32) { - o.FrontPortCount = v + o.FrontPortCount = &v } -// GetRearPortCount returns the RearPortCount field value +// GetRearPortCount returns the RearPortCount field value if set, zero value otherwise. func (o *Device) GetRearPortCount() int32 { - if o == nil { + if o == nil || IsNil(o.RearPortCount) { var ret int32 return ret } - - return o.RearPortCount + return *o.RearPortCount } -// GetRearPortCountOk returns a tuple with the RearPortCount field value +// GetRearPortCountOk returns a tuple with the RearPortCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetRearPortCountOk() (*int32, bool) { - if o == nil { + if o == nil || IsNil(o.RearPortCount) { return nil, false } - return &o.RearPortCount, true + return o.RearPortCount, true } -// SetRearPortCount sets field value +// HasRearPortCount returns a boolean if a field has been set. +func (o *Device) HasRearPortCount() bool { + if o != nil && !IsNil(o.RearPortCount) { + return true + } + + return false +} + +// SetRearPortCount gets a reference to the given int32 and assigns it to the RearPortCount field. func (o *Device) SetRearPortCount(v int32) { - o.RearPortCount = v + o.RearPortCount = &v } -// GetDeviceBayCount returns the DeviceBayCount field value +// GetDeviceBayCount returns the DeviceBayCount field value if set, zero value otherwise. func (o *Device) GetDeviceBayCount() int32 { - if o == nil { + if o == nil || IsNil(o.DeviceBayCount) { var ret int32 return ret } - - return o.DeviceBayCount + return *o.DeviceBayCount } -// GetDeviceBayCountOk returns a tuple with the DeviceBayCount field value +// GetDeviceBayCountOk returns a tuple with the DeviceBayCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetDeviceBayCountOk() (*int32, bool) { - if o == nil { + if o == nil || IsNil(o.DeviceBayCount) { return nil, false } - return &o.DeviceBayCount, true + return o.DeviceBayCount, true } -// SetDeviceBayCount sets field value +// HasDeviceBayCount returns a boolean if a field has been set. +func (o *Device) HasDeviceBayCount() bool { + if o != nil && !IsNil(o.DeviceBayCount) { + return true + } + + return false +} + +// SetDeviceBayCount gets a reference to the given int32 and assigns it to the DeviceBayCount field. func (o *Device) SetDeviceBayCount(v int32) { - o.DeviceBayCount = v + o.DeviceBayCount = &v } -// GetModuleBayCount returns the ModuleBayCount field value +// GetModuleBayCount returns the ModuleBayCount field value if set, zero value otherwise. func (o *Device) GetModuleBayCount() int32 { - if o == nil { + if o == nil || IsNil(o.ModuleBayCount) { var ret int32 return ret } - - return o.ModuleBayCount + return *o.ModuleBayCount } -// GetModuleBayCountOk returns a tuple with the ModuleBayCount field value +// GetModuleBayCountOk returns a tuple with the ModuleBayCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetModuleBayCountOk() (*int32, bool) { - if o == nil { + if o == nil || IsNil(o.ModuleBayCount) { return nil, false } - return &o.ModuleBayCount, true + return o.ModuleBayCount, true +} + +// HasModuleBayCount returns a boolean if a field has been set. +func (o *Device) HasModuleBayCount() bool { + if o != nil && !IsNil(o.ModuleBayCount) { + return true + } + + return false } -// SetModuleBayCount sets field value +// SetModuleBayCount gets a reference to the given int32 and assigns it to the ModuleBayCount field. func (o *Device) SetModuleBayCount(v int32) { - o.ModuleBayCount = v + o.ModuleBayCount = &v } -// GetInventoryItemCount returns the InventoryItemCount field value +// GetInventoryItemCount returns the InventoryItemCount field value if set, zero value otherwise. func (o *Device) GetInventoryItemCount() int32 { - if o == nil { + if o == nil || IsNil(o.InventoryItemCount) { var ret int32 return ret } - - return o.InventoryItemCount + return *o.InventoryItemCount } -// GetInventoryItemCountOk returns a tuple with the InventoryItemCount field value +// GetInventoryItemCountOk returns a tuple with the InventoryItemCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Device) GetInventoryItemCountOk() (*int32, bool) { - if o == nil { + if o == nil || IsNil(o.InventoryItemCount) { return nil, false } - return &o.InventoryItemCount, true + return o.InventoryItemCount, true +} + +// HasInventoryItemCount returns a boolean if a field has been set. +func (o *Device) HasInventoryItemCount() bool { + if o != nil && !IsNil(o.InventoryItemCount) { + return true + } + + return false } -// SetInventoryItemCount sets field value +// SetInventoryItemCount gets a reference to the given int32 and assigns it to the InventoryItemCount field. func (o *Device) SetInventoryItemCount(v int32) { - o.InventoryItemCount = v + o.InventoryItemCount = &v } func (o Device) MarshalJSON() ([]byte, error) { @@ -1636,11 +1768,13 @@ func (o Device) ToMap() (map[string]interface{}, error) { toSerialize["id"] = o.Id toSerialize["url"] = o.Url toSerialize["display"] = o.Display - if o.Name.IsSet() { - toSerialize["name"] = o.Name.Get() + toSerialize["name"] = o.Name.Get() + if !IsNil(o.DeviceType) { + toSerialize["device_type"] = o.DeviceType + } + if !IsNil(o.Role) { + toSerialize["role"] = o.Role } - toSerialize["device_type"] = o.DeviceType - toSerialize["role"] = o.Role if o.Tenant.IsSet() { toSerialize["tenant"] = o.Tenant.Get() } @@ -1653,7 +1787,9 @@ func (o Device) ToMap() (map[string]interface{}, error) { if o.AssetTag.IsSet() { toSerialize["asset_tag"] = o.AssetTag.Get() } - toSerialize["site"] = o.Site + if !IsNil(o.Site) { + toSerialize["site"] = o.Site + } if o.Location.IsSet() { toSerialize["location"] = o.Location.Get() } @@ -1672,14 +1808,18 @@ func (o Device) ToMap() (map[string]interface{}, error) { if o.Longitude.IsSet() { toSerialize["longitude"] = o.Longitude.Get() } - toSerialize["parent_device"] = o.ParentDevice.Get() + if o.ParentDevice.IsSet() { + toSerialize["parent_device"] = o.ParentDevice.Get() + } if !IsNil(o.Status) { toSerialize["status"] = o.Status } if !IsNil(o.Airflow) { toSerialize["airflow"] = o.Airflow } - toSerialize["primary_ip"] = o.PrimaryIp.Get() + if o.PrimaryIp.IsSet() { + toSerialize["primary_ip"] = o.PrimaryIp.Get() + } if o.PrimaryIp4.IsSet() { toSerialize["primary_ip4"] = o.PrimaryIp4.Get() } @@ -1701,9 +1841,7 @@ func (o Device) ToMap() (map[string]interface{}, error) { if o.VcPriority.IsSet() { toSerialize["vc_priority"] = o.VcPriority.Get() } - if !IsNil(o.Description) { - toSerialize["description"] = o.Description - } + toSerialize["description"] = o.Description if !IsNil(o.Comments) { toSerialize["comments"] = o.Comments } @@ -1719,18 +1857,42 @@ func (o Device) ToMap() (map[string]interface{}, error) { if !IsNil(o.CustomFields) { toSerialize["custom_fields"] = o.CustomFields } - toSerialize["created"] = o.Created.Get() - toSerialize["last_updated"] = o.LastUpdated.Get() - toSerialize["console_port_count"] = o.ConsolePortCount - toSerialize["console_server_port_count"] = o.ConsoleServerPortCount - toSerialize["power_port_count"] = o.PowerPortCount - toSerialize["power_outlet_count"] = o.PowerOutletCount - toSerialize["interface_count"] = o.InterfaceCount - toSerialize["front_port_count"] = o.FrontPortCount - toSerialize["rear_port_count"] = o.RearPortCount - toSerialize["device_bay_count"] = o.DeviceBayCount - toSerialize["module_bay_count"] = o.ModuleBayCount - toSerialize["inventory_item_count"] = o.InventoryItemCount + if o.Created.IsSet() { + toSerialize["created"] = o.Created.Get() + } + if o.LastUpdated.IsSet() { + toSerialize["last_updated"] = o.LastUpdated.Get() + } + if !IsNil(o.ConsolePortCount) { + toSerialize["console_port_count"] = o.ConsolePortCount + } + if !IsNil(o.ConsoleServerPortCount) { + toSerialize["console_server_port_count"] = o.ConsoleServerPortCount + } + if !IsNil(o.PowerPortCount) { + toSerialize["power_port_count"] = o.PowerPortCount + } + if !IsNil(o.PowerOutletCount) { + toSerialize["power_outlet_count"] = o.PowerOutletCount + } + if !IsNil(o.InterfaceCount) { + toSerialize["interface_count"] = o.InterfaceCount + } + if !IsNil(o.FrontPortCount) { + toSerialize["front_port_count"] = o.FrontPortCount + } + if !IsNil(o.RearPortCount) { + toSerialize["rear_port_count"] = o.RearPortCount + } + if !IsNil(o.DeviceBayCount) { + toSerialize["device_bay_count"] = o.DeviceBayCount + } + if !IsNil(o.ModuleBayCount) { + toSerialize["module_bay_count"] = o.ModuleBayCount + } + if !IsNil(o.InventoryItemCount) { + toSerialize["inventory_item_count"] = o.InventoryItemCount + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -1747,23 +1909,8 @@ func (o *Device) UnmarshalJSON(data []byte) (err error) { "id", "url", "display", - "device_type", - "role", - "site", - "parent_device", - "primary_ip", - "created", - "last_updated", - "console_port_count", - "console_server_port_count", - "power_port_count", - "power_outlet_count", - "interface_count", - "front_port_count", - "rear_port_count", - "device_bay_count", - "module_bay_count", - "inventory_item_count", + "name", + "description", } allProperties := make(map[string]interface{}) diff --git a/scripts/fix-spec.py b/scripts/fix-spec.py index e63690bef0..32e1f0493d 100755 --- a/scripts/fix-spec.py +++ b/scripts/fix-spec.py @@ -13,7 +13,7 @@ for name, schema in data['components']['schemas'].items(): if 'properties' in schema: # Remove "null" item from nullable enums - for name, prop in schema['properties'].items(): + for propName, prop in schema['properties'].items(): if 'enum' in prop and None in prop['enum']: prop['enum'].remove(None) if 'properties' in prop and 'value' in prop['properties'] and 'enum' in prop['properties']['value'] and None in prop['properties']['value']['enum']: @@ -50,6 +50,14 @@ schema['required'] = [prop for prop in schema['required'] if prop not in non_required_props] +data['components']['schemas']['Device']['required'] = [ + 'id', + 'url', + 'display', + 'name', + 'description', +] + # Save the spec file with open(SPEC_PATH, 'w') as file: yaml.dump(data, file, Dumper=yaml.CDumper, sort_keys=False) From d378dd2caafdbac456a5204a237339ca2f72c41b Mon Sep 17 00:00:00 2001 From: Felix Edelmann Date: Wed, 3 Jul 2024 16:06:58 +0200 Subject: [PATCH 3/4] Format files --- main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 52d78bdce8..e255ab53a3 100644 --- a/main.go +++ b/main.go @@ -4,8 +4,10 @@ import ( "fmt" ) -const authHeaderName = "Authorization" -const authHeaderFormat = "Token %v" +const ( + authHeaderName = "Authorization" + authHeaderFormat = "Token %v" +) func NewAPIClientFor(host string, token string) *APIClient { cfg := NewConfiguration() From 2e8c70d65b1f407c33db4ad2310571a7ab3862a9 Mon Sep 17 00:00:00 2001 From: Felix Edelmann Date: Wed, 3 Jul 2024 19:36:43 +0200 Subject: [PATCH 4/4] Ignore prefix_count --- api/openapi.yaml | 2 -- docs/Role.md | 9 +++++++-- docs/VRF.md | 9 +++++++-- model_role.go | 36 ++++++++++++++++++++++-------------- model_vrf.go | 36 ++++++++++++++++++++++-------------- scripts/fix-spec.py | 1 + 6 files changed, 59 insertions(+), 34 deletions(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index 24f3a606c0..4474f7dddb 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -130116,7 +130116,6 @@ components: - display - id - name - - prefix_count - slug - url - vlan_count @@ -131827,7 +131826,6 @@ components: - display - id - name - - prefix_count - url VRFRequest: type: object diff --git a/docs/Role.md b/docs/Role.md index 5054c3ea7e..2129bc8e43 100644 --- a/docs/Role.md +++ b/docs/Role.md @@ -10,14 +10,14 @@ Name | Type | Description | Notes **Name** | **string** | | **Slug** | **string** | | **Description** | Pointer to **string** | | [optional] -**PrefixCount** | **int64** | | [readonly] +**PrefixCount** | Pointer to **int64** | | [optional] [readonly] **VlanCount** | **int64** | | [readonly] ## Methods ### NewRole -`func NewRole(id int32, url string, display string, name string, slug string, prefixCount int64, vlanCount int64, ) *Role` +`func NewRole(id int32, url string, display string, name string, slug string, vlanCount int64, ) *Role` NewRole instantiates a new Role object This constructor will assign default values to properties that have it defined, @@ -176,6 +176,11 @@ and a boolean to check if the value has been set. SetPrefixCount sets PrefixCount field to given value. +### HasPrefixCount + +`func (o *Role) HasPrefixCount() bool` + +HasPrefixCount returns a boolean if a field has been set. ### GetVlanCount diff --git a/docs/VRF.md b/docs/VRF.md index e30a5c20ec..efb68c0067 100644 --- a/docs/VRF.md +++ b/docs/VRF.md @@ -10,13 +10,13 @@ Name | Type | Description | Notes **Name** | **string** | | **Rd** | Pointer to **NullableString** | Unique route distinguisher (as defined in RFC 4364) | [optional] **Description** | Pointer to **string** | | [optional] -**PrefixCount** | **int64** | | [readonly] +**PrefixCount** | Pointer to **int64** | | [optional] [readonly] ## Methods ### NewVRF -`func NewVRF(id int32, url string, display string, name string, prefixCount int64, ) *VRF` +`func NewVRF(id int32, url string, display string, name string, ) *VRF` NewVRF instantiates a new VRF object This constructor will assign default values to properties that have it defined, @@ -190,6 +190,11 @@ and a boolean to check if the value has been set. SetPrefixCount sets PrefixCount field to given value. +### HasPrefixCount + +`func (o *VRF) HasPrefixCount() bool` + +HasPrefixCount returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/model_role.go b/model_role.go index 41ad3c7c58..7e651644c8 100644 --- a/model_role.go +++ b/model_role.go @@ -26,7 +26,7 @@ type Role struct { Name string `json:"name"` Slug string `json:"slug"` Description *string `json:"description,omitempty"` - PrefixCount int64 `json:"prefix_count"` + PrefixCount *int64 `json:"prefix_count,omitempty"` VlanCount int64 `json:"vlan_count"` AdditionalProperties map[string]interface{} } @@ -37,14 +37,13 @@ type _Role Role // 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 NewRole(id int32, url string, display string, name string, slug string, prefixCount int64, vlanCount int64) *Role { +func NewRole(id int32, url string, display string, name string, slug string, vlanCount int64) *Role { this := Role{} this.Id = id this.Url = url this.Display = display this.Name = name this.Slug = slug - this.PrefixCount = prefixCount this.VlanCount = vlanCount return &this } @@ -209,28 +208,36 @@ func (o *Role) SetDescription(v string) { o.Description = &v } -// GetPrefixCount returns the PrefixCount field value +// GetPrefixCount returns the PrefixCount field value if set, zero value otherwise. func (o *Role) GetPrefixCount() int64 { - if o == nil { + if o == nil || IsNil(o.PrefixCount) { var ret int64 return ret } - - return o.PrefixCount + return *o.PrefixCount } -// GetPrefixCountOk returns a tuple with the PrefixCount field value +// GetPrefixCountOk returns a tuple with the PrefixCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *Role) GetPrefixCountOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.PrefixCount) { return nil, false } - return &o.PrefixCount, true + return o.PrefixCount, true +} + +// HasPrefixCount returns a boolean if a field has been set. +func (o *Role) HasPrefixCount() bool { + if o != nil && !IsNil(o.PrefixCount) { + return true + } + + return false } -// SetPrefixCount sets field value +// SetPrefixCount gets a reference to the given int64 and assigns it to the PrefixCount field. func (o *Role) SetPrefixCount(v int64) { - o.PrefixCount = v + o.PrefixCount = &v } // GetVlanCount returns the VlanCount field value @@ -275,7 +282,9 @@ func (o Role) ToMap() (map[string]interface{}, error) { if !IsNil(o.Description) { toSerialize["description"] = o.Description } - toSerialize["prefix_count"] = o.PrefixCount + if !IsNil(o.PrefixCount) { + toSerialize["prefix_count"] = o.PrefixCount + } toSerialize["vlan_count"] = o.VlanCount for key, value := range o.AdditionalProperties { @@ -295,7 +304,6 @@ func (o *Role) UnmarshalJSON(data []byte) (err error) { "display", "name", "slug", - "prefix_count", "vlan_count", } diff --git a/model_vrf.go b/model_vrf.go index 6f16484c97..e060fd1535 100644 --- a/model_vrf.go +++ b/model_vrf.go @@ -27,7 +27,7 @@ type VRF struct { // Unique route distinguisher (as defined in RFC 4364) Rd NullableString `json:"rd,omitempty"` Description *string `json:"description,omitempty"` - PrefixCount int64 `json:"prefix_count"` + PrefixCount *int64 `json:"prefix_count,omitempty"` AdditionalProperties map[string]interface{} } @@ -37,13 +37,12 @@ type _VRF VRF // 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 NewVRF(id int32, url string, display string, name string, prefixCount int64) *VRF { +func NewVRF(id int32, url string, display string, name string) *VRF { this := VRF{} this.Id = id this.Url = url this.Display = display this.Name = name - this.PrefixCount = prefixCount return &this } @@ -226,28 +225,36 @@ func (o *VRF) SetDescription(v string) { o.Description = &v } -// GetPrefixCount returns the PrefixCount field value +// GetPrefixCount returns the PrefixCount field value if set, zero value otherwise. func (o *VRF) GetPrefixCount() int64 { - if o == nil { + if o == nil || IsNil(o.PrefixCount) { var ret int64 return ret } - - return o.PrefixCount + return *o.PrefixCount } -// GetPrefixCountOk returns a tuple with the PrefixCount field value +// GetPrefixCountOk returns a tuple with the PrefixCount field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *VRF) GetPrefixCountOk() (*int64, bool) { - if o == nil { + if o == nil || IsNil(o.PrefixCount) { return nil, false } - return &o.PrefixCount, true + return o.PrefixCount, true +} + +// HasPrefixCount returns a boolean if a field has been set. +func (o *VRF) HasPrefixCount() bool { + if o != nil && !IsNil(o.PrefixCount) { + return true + } + + return false } -// SetPrefixCount sets field value +// SetPrefixCount gets a reference to the given int64 and assigns it to the PrefixCount field. func (o *VRF) SetPrefixCount(v int64) { - o.PrefixCount = v + o.PrefixCount = &v } func (o VRF) MarshalJSON() ([]byte, error) { @@ -270,7 +277,9 @@ func (o VRF) ToMap() (map[string]interface{}, error) { if !IsNil(o.Description) { toSerialize["description"] = o.Description } - toSerialize["prefix_count"] = o.PrefixCount + if !IsNil(o.PrefixCount) { + toSerialize["prefix_count"] = o.PrefixCount + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -288,7 +297,6 @@ func (o *VRF) UnmarshalJSON(data []byte) (err error) { "url", "display", "name", - "prefix_count", } allProperties := make(map[string]interface{}) diff --git a/scripts/fix-spec.py b/scripts/fix-spec.py index 32e1f0493d..d2dabc4e55 100755 --- a/scripts/fix-spec.py +++ b/scripts/fix-spec.py @@ -46,6 +46,7 @@ 'devicetype_count', 'device_count', 'virtualmachine_count', + 'prefix_count', ] schema['required'] = [prop for prop in schema['required'] if prop not in non_required_props]