netbox-community / go-netbox

The official Go API client for Netbox IPAM and DCIM service.
Other
197 stars 150 forks source link

Allow User Token's WriteEnabled Field #139

Closed keshy7 closed 1 year ago

keshy7 commented 1 year ago

By default, Netbox's REST API sets User Token's write_enabled field to true. This means that if the field is not set explicitly in the request, Netbox would automatically set it to true.

This behavior results to an inconsistency if the value is set to false and omitempty is configured in the JSON tag. This is because by default, JSON Marshaller omits false booleans. Since the field is omitted, Netbox REST API would default it to true. Hence, an inconsistency would occur.

To fix this, simply remove the omitempty tag from the writable token.

References: