Skip to content

feat: add owners and owner-groups client bindings#69

Open
fabiomatavelli wants to merge 2 commits into
fbreckle:masterfrom
fabiomatavelli:add-owner-owner-group
Open

feat: add owners and owner-groups client bindings#69
fabiomatavelli wants to merge 2 commits into
fbreckle:masterfrom
fabiomatavelli:add-owner-owner-group

Conversation

@fabiomatavelli

Copy link
Copy Markdown

Summary

NetBox added an Owner/OwnerGroup model to the users app 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:

  • Models: Owner, OwnerGroup, NestedOwnerGroup, WritableOwner
  • Client operations for /users/owners/ and /users/owner-groups/ (create/read/update/partial_update/delete/list), following the same conventions as the existing generated code (see users_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 replace directive in the meantime. Two bugs were caught and fixed that way:

  • group must always be present in the request body (even as null) since NetBox's OwnerSerializer doesn't mark it required=False.
  • The create/update/partial_update responses always return the nested Owner representation for group/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)
  • Exercised via terraform-provider-netbox acceptance tests against live NetBox v4.6.4 (create/read/update/delete for both netbox_owner and netbox_owner_group)

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
fabiomatavelli marked this pull request as ready for review July 13, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant