1414 UninitializedError ,
1515)
1616from .graphql import Mutation , Query
17- from .schema import GenericSchema , RelationshipCardinality , RelationshipKind
17+ from .schema import GenericSchemaAPI , RelationshipCardinality , RelationshipKind
1818from .utils import compare_lists , get_flat_value
1919from .uuidt import UUIDT
2020
2121if TYPE_CHECKING :
2222 from typing_extensions import Self
2323
2424 from .client import InfrahubClient , InfrahubClientSync
25- from .schema import AttributeSchema , MainSchemaTypes , RelationshipSchema
25+ from .schema import AttributeSchemaAPI , MainSchemaTypesAPI , RelationshipSchemaAPI
2626
2727# pylint: disable=too-many-lines
2828
4646class Attribute :
4747 """Represents an attribute of a Node, including its schema, value, and properties."""
4848
49- def __init__ (self , name : str , schema : AttributeSchema , data : Union [Any , dict ]):
49+ def __init__ (self , name : str , schema : AttributeSchemaAPI , data : Union [Any , dict ]):
5050 """
5151 Args:
5252 name (str): The name of the attribute.
@@ -143,7 +143,7 @@ def _generate_mutation_query(self) -> dict[str, Any]:
143143class RelatedNodeBase :
144144 """Base class for representing a related node in a relationship."""
145145
146- def __init__ (self , branch : str , schema : RelationshipSchema , data : Union [Any , dict ], name : Optional [str ] = None ):
146+ def __init__ (self , branch : str , schema : RelationshipSchemaAPI , data : Union [Any , dict ], name : Optional [str ] = None ):
147147 """
148148 Args:
149149 branch (str): The branch where the related node resides.
@@ -300,7 +300,7 @@ def __init__(
300300 self ,
301301 client : InfrahubClient ,
302302 branch : str ,
303- schema : RelationshipSchema ,
303+ schema : RelationshipSchemaAPI ,
304304 data : Union [Any , dict ],
305305 name : Optional [str ] = None ,
306306 ):
@@ -347,7 +347,7 @@ def __init__(
347347 self ,
348348 client : InfrahubClientSync ,
349349 branch : str ,
350- schema : RelationshipSchema ,
350+ schema : RelationshipSchemaAPI ,
351351 data : Union [Any , dict ],
352352 name : Optional [str ] = None ,
353353 ):
@@ -390,7 +390,7 @@ def get(self) -> InfrahubNodeSync:
390390class RelationshipManagerBase :
391391 """Base class for RelationshipManager and RelationshipManagerSync"""
392392
393- def __init__ (self , name : str , branch : str , schema : RelationshipSchema ):
393+ def __init__ (self , name : str , branch : str , schema : RelationshipSchemaAPI ):
394394 """
395395 Args:
396396 name (str): The name of the relationship.
@@ -473,7 +473,7 @@ def __init__(
473473 client : InfrahubClient ,
474474 node : InfrahubNode ,
475475 branch : str ,
476- schema : RelationshipSchema ,
476+ schema : RelationshipSchemaAPI ,
477477 data : Union [Any , dict ],
478478 ):
479479 """
@@ -568,7 +568,7 @@ def __init__(
568568 client : InfrahubClientSync ,
569569 node : InfrahubNodeSync ,
570570 branch : str ,
571- schema : RelationshipSchema ,
571+ schema : RelationshipSchemaAPI ,
572572 data : Union [Any , dict ],
573573 ):
574574 """
@@ -657,12 +657,12 @@ def remove(self, data: Union[str, RelatedNodeSync, dict]) -> None:
657657class InfrahubNodeBase :
658658 """Base class for InfrahubNode and InfrahubNodeSync"""
659659
660- def __init__ (self , schema : MainSchemaTypes , branch : str , data : Optional [dict ] = None ) -> None :
660+ def __init__ (self , schema : MainSchemaTypesAPI , branch : str , data : Optional [dict ] = None ) -> None :
661661 """
662662 Args:
663- schema (MainSchemaTypes) : The schema of the node.
664- branch (str) : The branch where the node resides.
665- data (Optional[dict]) : Optional data to initialize the node.
663+ schema: The schema of the node.
664+ branch: The branch where the node resides.
665+ data: Optional data to initialize the node.
666666 """
667667 self ._schema = schema
668668 self ._data = data
@@ -1035,16 +1035,16 @@ class InfrahubNode(InfrahubNodeBase):
10351035 def __init__ (
10361036 self ,
10371037 client : InfrahubClient ,
1038- schema : MainSchemaTypes ,
1038+ schema : MainSchemaTypesAPI ,
10391039 branch : Optional [str ] = None ,
10401040 data : Optional [dict ] = None ,
10411041 ) -> None :
10421042 """
10431043 Args:
1044- client (InfrahubClient) : The client used to interact with the backend.
1045- schema (MainSchemaTypes) : The schema of the node.
1046- branch (Optional[str]) : The branch where the node resides.
1047- data (Optional[dict]) : Optional data to initialize the node.
1044+ client: The client used to interact with the backend.
1045+ schema: The schema of the node.
1046+ branch: The branch where the node resides.
1047+ data: Optional data to initialize the node.
10481048 """
10491049 self ._client = client
10501050 self .__class__ = type (f"{ schema .kind } InfrahubNode" , (self .__class__ ,), {})
@@ -1060,7 +1060,7 @@ async def from_graphql(
10601060 client : InfrahubClient ,
10611061 branch : str ,
10621062 data : dict ,
1063- schema : Optional [MainSchemaTypes ] = None ,
1063+ schema : Optional [MainSchemaTypesAPI ] = None ,
10641064 timeout : Optional [int ] = None ,
10651065 ) -> Self :
10661066 if not schema :
@@ -1146,7 +1146,7 @@ async def save(
11461146 if update_group_context is None and self ._client .mode == InfrahubClientMode .TRACKING :
11471147 update_group_context = True
11481148
1149- if not isinstance (self ._schema , GenericSchema ):
1149+ if not isinstance (self ._schema , GenericSchemaAPI ):
11501150 if "CoreGroup" in self ._schema .inherit_from :
11511151 await self ._client .group_context .add_related_groups (
11521152 ids = [self .id ], update_group_context = update_group_context
@@ -1183,7 +1183,7 @@ async def generate_query_data(
11831183 )
11841184 )
11851185
1186- if isinstance (self ._schema , GenericSchema ) and fragment :
1186+ if isinstance (self ._schema , GenericSchemaAPI ) and fragment :
11871187 for child in self ._schema .used_by :
11881188 child_schema = await self ._client .schema .get (kind = child )
11891189 child_node = InfrahubNode (client = self ._client , schema = child_schema )
@@ -1540,7 +1540,7 @@ class InfrahubNodeSync(InfrahubNodeBase):
15401540 def __init__ (
15411541 self ,
15421542 client : InfrahubClientSync ,
1543- schema : MainSchemaTypes ,
1543+ schema : MainSchemaTypesAPI ,
15441544 branch : Optional [str ] = None ,
15451545 data : Optional [dict ] = None ,
15461546 ) -> None :
@@ -1565,7 +1565,7 @@ def from_graphql(
15651565 client : InfrahubClientSync ,
15661566 branch : str ,
15671567 data : dict ,
1568- schema : Optional [MainSchemaTypes ] = None ,
1568+ schema : Optional [MainSchemaTypesAPI ] = None ,
15691569 timeout : Optional [int ] = None ,
15701570 ) -> Self :
15711571 if not schema :
@@ -1648,7 +1648,7 @@ def save(
16481648 if update_group_context is None and self ._client .mode == InfrahubClientMode .TRACKING :
16491649 update_group_context = True
16501650
1651- if not isinstance (self ._schema , GenericSchema ):
1651+ if not isinstance (self ._schema , GenericSchemaAPI ):
16521652 if "CoreGroup" in self ._schema .inherit_from :
16531653 self ._client .group_context .add_related_groups (ids = [self .id ], update_group_context = update_group_context )
16541654 else :
@@ -1681,7 +1681,7 @@ def generate_query_data(
16811681 )
16821682 )
16831683
1684- if isinstance (self ._schema , GenericSchema ) and fragment :
1684+ if isinstance (self ._schema , GenericSchemaAPI ) and fragment :
16851685 for child in self ._schema .used_by :
16861686 child_schema = self ._client .schema .get (kind = child )
16871687 child_node = InfrahubNodeSync (client = self ._client , schema = child_schema )
0 commit comments