[PR #20015] [MERGED] Implement contains filter for IPAM prefixes and IP ranges #15792

Closed
opened 2025-12-30 00:24:06 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/20015
Author: @mraerino
Created: 8/3/2025
Status: Merged
Merged: 8/5/2025
Merged by: @bctiemann

Base: mainHead: graphql-contains-prefix


📝 Commits (3)

  • 0827198 Implement contains filter for IPAM prefixes
  • 5d19421 Implement contains filter for IPAM IP ranges
  • 4506c80 Fix formatting

📊 Changes

1 file changed (+23 additions, -0 deletions)

View changed files

📝 netbox/ipam/graphql/filters.py (+23 -0)

📄 Description

Fixes: #19812

This adds a contains filter on both Prefixes and IP Ranges.

Example queries:

query prefixes {
  prefix_list(filters: {contains: ["10.1.0.0"]}) {
    prefix
  }
}

query ipranges {
  ip_range_list(filters: {contains: ["10.2.1.0/24"]}) {
    start_address
    end_address
  }
}

The query will throw an error if the given subnet cannot be parsed. A missing prefixlength on the filter argument is interpreted as /128//32 (depending on the family)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/20015 **Author:** [@mraerino](https://github.com/mraerino) **Created:** 8/3/2025 **Status:** ✅ Merged **Merged:** 8/5/2025 **Merged by:** [@bctiemann](https://github.com/bctiemann) **Base:** `main` ← **Head:** `graphql-contains-prefix` --- ### 📝 Commits (3) - [`0827198`](https://github.com/netbox-community/netbox/commit/0827198cad4c358e3b32b463df72f660df459cea) Implement contains filter for IPAM prefixes - [`5d19421`](https://github.com/netbox-community/netbox/commit/5d194214aa29fdf569e3920603fd23fa2ae1c28c) Implement contains filter for IPAM IP ranges - [`4506c80`](https://github.com/netbox-community/netbox/commit/4506c809d8c06e5b13d2e3fee74e3828a78a394b) Fix formatting ### 📊 Changes **1 file changed** (+23 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `netbox/ipam/graphql/filters.py` (+23 -0) </details> ### 📄 Description ### Fixes: #19812 This adds a `contains` filter on both Prefixes and IP Ranges. Example queries: ```gql query prefixes { prefix_list(filters: {contains: ["10.1.0.0"]}) { prefix } } query ipranges { ip_range_list(filters: {contains: ["10.2.1.0/24"]}) { start_address end_address } } ``` The query will throw an error if the given subnet cannot be parsed. A missing prefixlength on the filter argument is interpreted as `/128`/`/32` (depending on the family) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:24:06 +01:00
adam closed this issue 2025-12-30 00:24:06 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15792