feat: add IPAddress attribute kind support [INFP-551]

Merged
PH
4mo ago
+84-2

Summary

Adds SDK support for the new IPAddress attribute kind (bare IP address, no netmask/prefix), alongside the existing IPHost and IPNetwork kinds. Part of the cross-stack work for Infrahub INFP-551 (targets the Infrahub 1.11 cycle).

KindPython mappingValue typeStores
IPAddress (new)ipaddress.ip_addressIPv4Address | IPv6Addressbare 192.0.2.1
IPHostipaddress.ip_interfaceIPv4Interface | IPv6Interface192.0.2.1/24
IPNetworkipaddress.ip_networkIPv4Network | IPv6Network192.0.2.0/24

Changes

  • protocols_base.py: new IPAddress / IPAddressOptional attribute types.
  • protocols_generator/constants.py: ATTRIBUTE_KIND_MAP entry.
  • schema/main.py: AttributeKind.IPADDRESS.
  • node/attribute.py + node/constants.py: parse via ipaddress.ip_address; serialize bare addresses with str() (no with_prefixlen).
  • protocols_generator/template.j2: import the new types so generated protocols reference them.
  • Unit tests for input-data serialization and deserialization (async + sync).

Testing

  • uv run pytest tests/unit/sdk/test_node.py โ€” 228 passed.
  • ruff + mypy clean on changed files.
  • Verified end-to-end against a live Infrahub instance built from the matching backend branch: client.get(...) returns a bare IPv4Address/IPv6Address for an IPAddress attribute, while IPHost/IPNetwork still return prefixed interface/network objects.

Notes

Base branch is infrahub-develop (the branch the Infrahub develop submodule tracks). The Infrahub-side PR bumps the python_sdk submodule pointer only after this merges.

๐Ÿค– Generated with Claude Code


Summary by cubic

Adds SDK support for a new IPAddress attribute kind to store and return bare IPv4/IPv6 addresses without a prefix. This fulfills INFP-551 by enabling schemas to validate and serialize plain IPs without the implicit /32 or /128.

  • New Features
    • Added AttributeKind.IPADDRESS and mapping in protocol generator.
    • Introduced IPAddress and IPAddressOptional protocol types (ipaddress.IPv4Address | IPv6Address).
    • Parse with ipaddress.ip_address; serialize as a bare string (no prefix). IPHost/IPNetwork behavior unchanged.
    • Updated node attribute parsing and GraphQL payload generation to handle bare IPs.
    • Added unit tests for sync/async serialization and deserialization.