diff --git a/infrahub_sdk/schema/__init__.py b/infrahub_sdk/schema/__init__.py index 790b5873..9b23fe49 100644 --- a/infrahub_sdk/schema/__init__.py +++ b/infrahub_sdk/schema/__init__.py @@ -34,6 +34,7 @@ RelationshipSchemaAPI, SchemaRoot, SchemaRootAPI, + TemplateSchemaAPI, ) if TYPE_CHECKING: @@ -58,6 +59,7 @@ "RelationshipSchemaAPI", "SchemaRoot", "SchemaRootAPI", + "TemplateSchemaAPI", ] @@ -78,8 +80,10 @@ class EnumMutation(str, Enum): MainSchemaTypes: TypeAlias = Union[NodeSchema, GenericSchema] -MainSchemaTypesAPI: TypeAlias = Union[NodeSchemaAPI, GenericSchemaAPI, ProfileSchemaAPI] -MainSchemaTypesAll: TypeAlias = Union[NodeSchema, GenericSchema, NodeSchemaAPI, GenericSchemaAPI, ProfileSchemaAPI] +MainSchemaTypesAPI: TypeAlias = Union[NodeSchemaAPI, GenericSchemaAPI, ProfileSchemaAPI, TemplateSchemaAPI] +MainSchemaTypesAll: TypeAlias = Union[ + NodeSchema, GenericSchema, NodeSchemaAPI, GenericSchemaAPI, ProfileSchemaAPI, TemplateSchemaAPI +] class InfrahubSchemaBase: @@ -417,6 +421,10 @@ async def fetch( profile = ProfileSchemaAPI(**profile_schema) nodes[profile.kind] = profile + for template_schema in data.get("templates", []): + template = TemplateSchemaAPI(**template_schema) + nodes[template.kind] = template + return nodes @@ -621,6 +629,10 @@ def fetch( profile = ProfileSchemaAPI(**profile_schema) nodes[profile.kind] = profile + for template_schema in data.get("templates", []): + template = TemplateSchemaAPI(**template_schema) + nodes[template.kind] = template + return nodes def load( diff --git a/infrahub_sdk/schema/main.py b/infrahub_sdk/schema/main.py index 760d7430..57aaa890 100644 --- a/infrahub_sdk/schema/main.py +++ b/infrahub_sdk/schema/main.py @@ -31,6 +31,7 @@ class RelationshipKind(str, Enum): GROUP = "Group" HIERARCHY = "Hierarchy" PROFILE = "Profile" + TEMPLATE = "Template" class RelationshipDirection(str, Enum): @@ -290,6 +291,7 @@ class BaseNodeSchema(BaseSchema): branch: BranchSupportType | None = None default_filter: str | None = None generate_profile: bool | None = None + generate_template: bool | None = None parent: str | None = None children: str | None = None @@ -308,6 +310,10 @@ class ProfileSchemaAPI(BaseSchema, BaseSchemaAttrRelAPI): inherit_from: list[str] = Field(default_factory=list) +class TemplateSchemaAPI(BaseSchema, BaseSchemaAttrRelAPI): + inherit_from: list[str] = Field(default_factory=list) + + class NodeExtensionSchema(BaseModel): model_config = ConfigDict(use_enum_values=True) @@ -341,3 +347,4 @@ class SchemaRootAPI(BaseModel): generics: list[GenericSchemaAPI] = Field(default_factory=list) nodes: list[NodeSchemaAPI] = Field(default_factory=list) profiles: list[ProfileSchemaAPI] = Field(default_factory=list) + templates: list[TemplateSchemaAPI] = Field(default_factory=list)