From baa7c8cdd49bd6321d747e0424b0d04ceceb2d42 Mon Sep 17 00:00:00 2001 From: Aaron McCarty Date: Thu, 30 Jul 2026 15:46:28 -0700 Subject: [PATCH] feat(schema): add IPAddress to the generated attribute-kind models The IPAddress attribute kind now exists in the backend, so the generated schema models gain the enum member and the two attribute-kind unions accept it. That unblocks the node tests covering a bare address, which were skipped because the schema fixture could not be built without the enum member. Also re-export IP_ADDRESS_TYPES alongside IP_TYPES, and mention IPAddress in the attribute docstring listing the IP-typed kinds. Co-Authored-By: Claude Opus 5 (1M context) --- .vale/styles/Infrahub/sentence-case.yml | 1 + infrahub_sdk/node/__init__.py | 2 ++ infrahub_sdk/node/attribute.py | 4 ++-- infrahub_sdk/schema/generated/enums.py | 1 + infrahub_sdk/schema/generated/read.py | 1 + infrahub_sdk/schema/generated/write.py | 1 + tests/unit/sdk/test_node.py | 10 ---------- 7 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.vale/styles/Infrahub/sentence-case.yml b/.vale/styles/Infrahub/sentence-case.yml index c27cf7a1e..5ea115fc9 100644 --- a/.vale/styles/Infrahub/sentence-case.yml +++ b/.vale/styles/Infrahub/sentence-case.yml @@ -45,6 +45,7 @@ exceptions: - IP - IP Fabric - IPAM + - IPAddress - IPHost - IPNetwork - JavaScript diff --git a/infrahub_sdk/node/__init__.py b/infrahub_sdk/node/__init__.py index 6bbde8540..eb55bfe36 100644 --- a/infrahub_sdk/node/__init__.py +++ b/infrahub_sdk/node/__init__.py @@ -6,6 +6,7 @@ ARTIFACT_FETCH_FEATURE_NOT_SUPPORTED_MESSAGE, ARTIFACT_GENERATE_FEATURE_NOT_SUPPORTED_MESSAGE, HFID_STR_SEPARATOR, + IP_ADDRESS_TYPES, IP_TYPES, MATCHES_LOCAL_CHECKSUM_FEATURE_NOT_SUPPORTED_MESSAGE, PROPERTIES_FLAG, @@ -30,6 +31,7 @@ "ARTIFACT_FETCH_FEATURE_NOT_SUPPORTED_MESSAGE", "ARTIFACT_GENERATE_FEATURE_NOT_SUPPORTED_MESSAGE", "HFID_STR_SEPARATOR", + "IP_ADDRESS_TYPES", "IP_TYPES", "MATCHES_LOCAL_CHECKSUM_FEATURE_NOT_SUPPORTED_MESSAGE", "PROPERTIES_FLAG", diff --git a/infrahub_sdk/node/attribute.py b/infrahub_sdk/node/attribute.py index 5dbb82085..4ada6b9de 100644 --- a/infrahub_sdk/node/attribute.py +++ b/infrahub_sdk/node/attribute.py @@ -74,8 +74,8 @@ class Attribute: def __init__(self, name: str, schema: AttributeSchemaAPI, data: Any | dict) -> None: """Build an ``Attribute`` from raw GraphQL data. - IP-typed attributes (``IPHost``, ``IPNetwork``) are parsed via the standard - ``ipaddress`` module so the in-memory value is a network/interface object. + IP-typed attributes (``IPHost``, ``IPNetwork``, ``IPAddress``) are parsed via the standard + ``ipaddress`` module so the in-memory value is an interface, network or address object. Args: name (str): The name of the attribute. diff --git a/infrahub_sdk/schema/generated/enums.py b/infrahub_sdk/schema/generated/enums.py index 24d3ae5b5..69c6ea2da 100644 --- a/infrahub_sdk/schema/generated/enums.py +++ b/infrahub_sdk/schema/generated/enums.py @@ -77,6 +77,7 @@ class AttributeKind(str, Enum): BANDWIDTH = "Bandwidth" IPHOST = "IPHost" IPNETWORK = "IPNetwork" + IPADDRESS = "IPAddress" BOOLEAN = "Boolean" CHECKBOX = "Checkbox" LIST = "List" diff --git a/infrahub_sdk/schema/generated/read.py b/infrahub_sdk/schema/generated/read.py index 1b0eee5c8..ecc931430 100644 --- a/infrahub_sdk/schema/generated/read.py +++ b/infrahub_sdk/schema/generated/read.py @@ -300,6 +300,7 @@ class GenericAttributeRead(AttributeSchemaBaseRead): AttributeKind.BANDWIDTH, AttributeKind.IPHOST, AttributeKind.IPNETWORK, + AttributeKind.IPADDRESS, AttributeKind.BOOLEAN, AttributeKind.CHECKBOX, AttributeKind.JSON, diff --git a/infrahub_sdk/schema/generated/write.py b/infrahub_sdk/schema/generated/write.py index 8d10710ab..a834ea442 100644 --- a/infrahub_sdk/schema/generated/write.py +++ b/infrahub_sdk/schema/generated/write.py @@ -296,6 +296,7 @@ class GenericAttributeWrite(AttributeSchemaBaseWrite): AttributeKind.BANDWIDTH, AttributeKind.IPHOST, AttributeKind.IPNETWORK, + AttributeKind.IPADDRESS, AttributeKind.BOOLEAN, AttributeKind.CHECKBOX, AttributeKind.JSON, diff --git a/tests/unit/sdk/test_node.py b/tests/unit/sdk/test_node.py index f6b0ec67b..d8c735637 100644 --- a/tests/unit/sdk/test_node.py +++ b/tests/unit/sdk/test_node.py @@ -1787,11 +1787,6 @@ async def test_create_input_data_with_IPHost_attribute( } -@pytest.mark.skip( - reason="The IPAddress attribute kind is not yet defined in the Infrahub backend, so the generated " - "AttributeKind enum omits it and the schema fixture cannot be built. Re-enable once the backend " - "adds the IPAddress attribute type." -) @pytest.mark.parametrize("client_type", client_types) async def test_create_input_data_with_IPAddress_attribute( client: InfrahubClient, bare_ipaddress_schema: NodeSchemaAPI, client_type: str @@ -2202,11 +2197,6 @@ async def test_node_IPHost_deserialization( assert ip_address.address.value == ipaddress.ip_interface("1.1.1.1/24") -@pytest.mark.skip( - reason="The IPAddress attribute kind is not yet defined in the Infrahub backend, so the generated " - "AttributeKind enum omits it and the schema fixture cannot be built. Re-enable once the backend " - "adds the IPAddress attribute type." -) @pytest.mark.parametrize("client_type", client_types) async def test_node_IPAddress_deserialization( client: InfrahubClient, bare_ipaddress_schema: NodeSchemaAPI, client_type: str