e-breuninger / terraform-provider-netbox

Terraform provider to interact with Netbox
https://registry.terraform.io/providers/e-breuninger/netbox/latest/docs
Mozilla Public License 2.0
173 stars 117 forks source link

Filters for netbox_devices are undocumented. #570

Open the-maldridge opened 4 months ago

the-maldridge commented 4 months ago

Terraform Version

N/A

Affected Resource(s)

Please list the resources as a list, for example:

Expected Behavior

I would have expected the filter syntax to be the same as that shown in the netbox API playground, but it doesn't seem to be.

Actual Behavior

Some other filter syntax appears to be in use. There should be documentation or examples as to what kind of filters these data sources take.

Steps to Reproduce

I tried with the following filter block:

filter {
  name = "has_primary_ip"
  value = "true"
}

Important Factoids

N/A

References

N/A

fbreckle commented 4 months ago

Hi,

generally, what you say is true.

You can look up the supported filters here: https://github.com/e-breuninger/terraform-provider-netbox/blob/master/netbox/data_source_netbox_devices.go#L161-L195

Currently, filters have to be implemented manually and implementing ALL supported filters is very chore-y. We have a very nice contribution in https://github.com/e-breuninger/terraform-provider-netbox/pull/428 to generate support for all filters supported by go-netbox via reflection. I did not yet get around to implementing it everywhere, though.

the-maldridge commented 4 months ago

Wow, that i impressively labor intensive. I'll work around this for the moment by using an already implemented filter.

fbreckle commented 4 months ago

Adding a filter is actually quite trivial, but the api exposes SO many possible filters that it really is quite annoying to do :D

peterbaumert commented 1 month ago

I think going with #428 for all datasources would be a major improvement to this provider.

fbreckle commented 1 month ago

Absolutely! I just can barely keep up with new merge requests and upstream changes (netbox 4.0 comes to mind...)