Skip to content

Allow to use Lookup Expressions #218

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

Closed
eshcheglov opened this issue Jun 3, 2020 · 2 comments
Closed

Allow to use Lookup Expressions #218

eshcheglov opened this issue Jun 3, 2020 · 2 comments

Comments

@eshcheglov
Copy link

eshcheglov commented Jun 3, 2020

ISSUE TYPE
  • Feature Idea
SUMMARY

NetBox support Lookup Expressions filters for almost every field: API Filtering.

From NetBox documentation:

These lookup expressions can be applied by adding a suffix to the desired field's name. E.g. mac_address__n. In this case, the filter expression is for negation and it is separated by two underscores. Below are the lookup expressions that are supported across different field types.

It can't be used in netbox inventory because list of available field names is hardcoded in netbox.py:

ALLOWED_DEVICE_QUERY_PARAMETERS = (
    "asset_tag",
    "cluster_id",
   <...skipped...>
    "tenant_id",
    "virtual_chassis_id",
)

I think possible workaround is to add suffixes to ALLOWED_DEVICE_QUERY_PARAMETERS check, like this:

370c370
<         if not (k in ALLOWED_DEVICE_QUERY_PARAMETERS or k.startswith("cf_")):
---
>         if not (k in ALLOWED_DEVICE_QUERY_PARAMETERS or k.startswith("cf_") or k.endswith("__n", "__lt", "__lte", "__gt", "__gte", "__n", "__ic", "__nic", "__isw", "__nisw", "__iew", "__niew", "__ie", "__nie")):
@FragmentedPacket
Copy link
Contributor

I think I need to cut a new release, but if you look at the nb_inventory.py file, those constants are removed now.

@FragmentedPacket
Copy link
Contributor

Sorry this should have been fixed in v0.2.1 and PR #202

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