From 536187bf0fa4087704e41899339d91557a443abb Mon Sep 17 00:00:00 2001 From: Fabian Breckle Date: Fri, 4 Aug 2023 10:26:30 +0200 Subject: [PATCH] feat: Allow setting interface.enabled to false --- netbox/models/writable_interface.go | 2 +- netbox/models/writable_vm_interface.go | 2 +- preprocess.py | 12 ++++++++++++ swagger.processed.json | 6 ++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/netbox/models/writable_interface.go b/netbox/models/writable_interface.go index 635d9346af..1628b14d8c 100644 --- a/netbox/models/writable_interface.go +++ b/netbox/models/writable_interface.go @@ -98,7 +98,7 @@ type WritableInterface struct { Duplex *string `json:"duplex,omitempty"` // Enabled - Enabled bool `json:"enabled,omitempty"` + Enabled bool `json:"enabled"` // ID // Read Only: true diff --git a/netbox/models/writable_vm_interface.go b/netbox/models/writable_vm_interface.go index 3dcbdeb722..f4904480c2 100644 --- a/netbox/models/writable_vm_interface.go +++ b/netbox/models/writable_vm_interface.go @@ -64,7 +64,7 @@ type WritableVMInterface struct { Display string `json:"display,omitempty"` // Enabled - Enabled bool `json:"enabled,omitempty"` + Enabled bool `json:"enabled"` // ID // Read Only: true diff --git a/preprocess.py b/preprocess.py index ebd3ebc659..db571f8f27 100755 --- a/preprocess.py +++ b/preprocess.py @@ -174,6 +174,18 @@ prop_spec["x-omitempty"] = False logging.info(f"set x-omitempty = false on WritableIPAddress.{prop}") +# Add omitempty = false for interface enabled +for prop, prop_spec in data["definitions"]["WritableInterface"]["properties"].items(): + if prop == "enabled": + prop_spec["x-omitempty"] = False + logging.info(f"set x-omitempty = false on WritableInterface.{prop}") + +# Add omitempty = false for vminterface enabled +for prop, prop_spec in data["definitions"]["WritableVMInterface"]["properties"].items(): + if prop == "enabled": + prop_spec["x-omitempty"] = False + logging.info(f"set x-omitempty = false on WritableVMInterface.{prop}") + # Delete problematic maximums (might have to be replaced with a proper value) for definition, definition_spec in data["definitions"].items(): for prop, prop_spec in definition_spec["properties"].items(): diff --git a/swagger.processed.json b/swagger.processed.json index 583ddac83d..50ff3e550f 100644 --- a/swagger.processed.json +++ b/swagger.processed.json @@ -80198,7 +80198,8 @@ }, "enabled": { "title": "Enabled", - "type": "boolean" + "type": "boolean", + "x-omitempty": false }, "parent": { "title": "Parent interface", @@ -95699,7 +95700,8 @@ }, "enabled": { "title": "Enabled", - "type": "boolean" + "type": "boolean", + "x-omitempty": false }, "parent": { "title": "Parent interface",