netbox-community / pynetbox

Python API client library for Netbox.
Apache License 2.0
567 stars 168 forks source link

.updates() returns true if customfields are of the type 'object/multiobject' #501

Closed PieterL75 closed 1 year ago

PieterL75 commented 1 year ago

A customfield is provided as 'array of dicts' by the API, But when returning, it has to be an array of integers. There is a bug report for that on NetBox git https://github.com/netbox-community/netbox/issues/10241 and https://github.com/netbox-community/netbox/pull/10479 It is however not clear on how this will be fixed.

Will the API send ID's only, or will it accept dicts.

I'm creating this bugreport, as pynetbox might need to be adjusted, depending on the decision made in the NetBox API

moonrail commented 1 year ago

This was no pynetbox issue. Was fixed partially in https://github.com/netbox-community/netbox/issues/10241. Not yet fixed on NetBox side: https://github.com/netbox-community/netbox/issues/11326

So this issue can be closed.

jeremystretch commented 1 year ago

@PieterL75 is correct: The NetBox REST API requires related objects to be identified either by their numeric primary keys or by some set of attributes sufficient to uniquely identify each object.

moonrail commented 1 year ago

@jeremystretch How would you propose pynetbox as a generic library shall jiggle CF DataTypes efficiently? This comes at extra cost with expensive API calls.

As I see it, it either

  1. would have to GET all CustomFields using the specific ContentType to then evaluate and modify the data before sending it
  2. or would have to guess, if a CF may be a DataType XYZ by data received from NetBox/given by User (which would be unstable at best and already in conflict with CF DataType JSON, as this is ambigious)
  3. pynetbox does nothing and every sole user of NetBox has to hardcode specific handling for these CF values, even if they are modifying other values of other CustomFields of an instance
PieterL75 commented 1 year ago

This issue was solved in https://github.com/netbox-community/netbox/pull/10479

NetBox allows dicts in a customerfield POST