-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Add write_enabled in token resource #309
✨ Add write_enabled in token resource #309
Conversation
Sorry, @fbreckle but this one requires a new release from https://github.com/fbreckle/go-netbox repo. May I please ask for a new release? |
Hey! I do not do releases in the go-netbox library. You can just update the library ref by using |
738dddb
to
5d28339
Compare
Add optional write_enabled in user's token resource. 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: - fbreckle/go-netbox#24 - https://github.com/netbox-community/netbox/blob/21b9732f061b7e91fa77c10da66bd098510354fc/netbox/users/models.py#L216-L219
5d28339
to
8715f4b
Compare
Thank you again, @fbreckle! The changes are now in! 😄 |
Hm, the current master of go-netbox also contains fbreckle/go-netbox#23 which causes these errors. |
Updated go-netbox dependency which included the change for write_enabled. References: - fbreckle/go-netbox#24
5d9886d
to
59fcd2b
Compare
Thank you @fbreckle! Sorry this taking too much work. The branch is now pointed one commit away (7a160aa9dcbb735a69936df9ee7ac45bc18719bd) from the master branch of go-netbox. Thank you again for your kind support |
Add optional write_enabled in user's token resource.
Note that this change is dependent on PR 24 due to an inconsistency issue that currently exists in writable_token model: fbreckle/go-netbox#24
PR #24's description:
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:
https://github.com/netbox-community/netbox/blob/21b9732f061b7e91fa77c10da66bd098510354fc/netbox/users/models.py#L216-L219