pynetbox
pynetbox copied to clipboard
Fix updating custom filed of type JSON
Close #457
Since there is no existing PR, I've created one which is based on @markkuleinio solution
+1 I installed pynetbox from this branch and it resolved my inability to update JSON custom properties with the error cited in #457
@zachmoody can you review this? It would be great to have this fix come in upstream to fix our automation and let us avoid having to create an internal fork
@Kani999 This change does not seem to be the right way to handle this scenario. IMO, you should update the flatten_custom
to something like
def flatten_custom(custom_dict):
return {
k: v if not isinstance(v, dict) else v["id"] for k, v in custom_dict.items()
}
custom_dict
always contains the id
field which I believe used to be referred to as value
in the older versions.
@abhi1693 I've changed the flatten_custom
method, which basically does nothing at the moment. So it works like a previous change.
custom_dict
always contains theid
field which I believe used to be referred to asvalue
in the older versions.
That's not true. Item contains just a key and value, there is no id or anything else.
Example of custom_dict
parameter:
type(custom_dict) <class 'dict'>
{'TEST': 'blah blah blah',
'json_data': {'a': 1,
'b': 2}}
Any news on merging this? The issue this PR addresses also affects the ansible modules.