feat: add owners and owner-groups client bindings#69
Open
fabiomatavelli wants to merge 2 commits into
Open
Conversation
NetBox added an Owner/OwnerGroup model to the users app (netbox-community/netbox users/models/owners.py) that isn't covered by the upstream swagger-generated client yet. Add hand-written models and client operations for /users/owners/ and /users/owner-groups/ following the same structural conventions as the existing generated code (see users_groups_*.go), so terraform-provider-netbox can manage these resources.
Verified against a live NetBox 4.6.4 instance:
- NetBox's OwnerSerializer declares group as a nested field without
required=False, so the key must always be present in the request body
(as null or an id); omitempty was dropping it and the API rejected the
request with {"group":["This field is required."]}.
- The create/update/partial_update responses always return the nested
Owner representation for group/user_groups/users, never the flat-int
WritableOwner shape, so decoding into WritableOwner failed. Use Owner
as the response payload type for those operations instead.
fabiomatavelli
marked this pull request as ready for review
July 13, 2026 16:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NetBox added an
Owner/OwnerGroupmodel to theusersapp in NetBox 4.5.0 (netbox-community/netbox#20304) for indicating administrative responsibility for objects (distinct from tenancy). This client doesn't have bindings for it yet, so this adds:Owner,OwnerGroup,NestedOwnerGroup,WritableOwner/users/owners/and/users/owner-groups/(create/read/update/partial_update/delete/list), following the same conventions as the existing generated code (seeusers_groups_*.go)These files are hand-written rather than generated by the swagger tool, since I don't have the updated swagger/OpenAPI spec this repo generates from. Happy to adjust to match however you regenerate this client if that differs from what's here.
Verified against a live dockerized NetBox v4.6.4 instance while building e-breuninger/terraform-provider-netbox#932 (draft), which depends on this branch via a
replacedirective in the meantime. Two bugs were caught and fixed that way:groupmust always be present in the request body (even asnull) since NetBox'sOwnerSerializerdoesn't mark itrequired=False.Ownerrepresentation forgroup/user_groups/users, never a flat-int shape.Opening as a draft since I'm not sure this matches your preferred process for adding new endpoints (e.g. regenerating from an updated spec instead). Let me know if you'd like this done differently.
Test plan
go build ./...go vet ./...gofmt -l(clean)netbox_ownerandnetbox_owner_group)