Skip to content
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

Tags missing from Object model via API #239

Open
mroe1234 opened this issue Apr 26, 2024 · 1 comment
Open

Tags missing from Object model via API #239

mroe1234 opened this issue Apr 26, 2024 · 1 comment

Comments

@mroe1234
Copy link

Environment

  • Python version: 3.11.2
  • Nautobot version: 2.2.2
  • nautobot-firewall-models version: 2.0.3

Expected Behavior

When querying an object using pynautobot or the API, I expect to be able to retrieve and set tags of an object

Observed Behavior

No tags are available

Steps to Reproduce

This is visible via the demo instance

  1. https://demo.nautobot.com/api/plugins/firewall/address-object/
    This is just the address object, but all objects that support tags via the GUI should also support tags via the API.
@ccc2lu
Copy link

ccc2lu commented May 10, 2024

I took a crack at fixing this, and I think I've got it working.

Basically I just added the TaggedModelSerializerMixin to all the classes that inherit from NautobotModelSerializer in nautobot_firewall_models/api/serializers.py, except for the M2M ones at the bottom of the file.

Then I added '.prefetch_related("tags")' to the end of the "objects.all()" line in each of the corresponding ViewSet classes in nautobot_firewall_models/api/views.py. Now I see tags are returned for these objects in our local instance, and I'm able to add new tags to the objects through the API using pynautobot.

Is a pull request a good way to submit this for review, to see if it's good to add to the plugin?

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

No branches or pull requests

2 participants