pa_api.xmlapi.types.config.interface

  1from ipaddress import ip_network
  2from typing import ClassVar, Iterable, Optional
  3
  4from pydantic import AliasPath, ConfigDict, Field
  5
  6from pa_api.xmlapi.types.utils import Ip, List, String, XMLBaseModel
  7
  8
  9def get_ip_network(ip_netmask):
 10    try:
 11        if ip_netmask:
 12            return ip_network(ip_netmask, strict=False)
 13    except Exception:
 14        return None
 15
 16
 17class GenericInterface(XMLBaseModel):
 18    model_config = ConfigDict(extra="ignore")
 19    inttype: str
 20    parent: Optional[str] = None
 21    name: str
 22    description: String = ""
 23    comment: String = ""
 24    ip: List[str] = Field(default_factory=list)
 25    untagged_sub_interface: Optional[String] = None
 26    tags: List[String] = Field(default_factory=list)
 27    link_state: Optional[str] = None
 28    link_speed: Optional[str] = None
 29    link_duplex: Optional[str] = None
 30    aggregate_group: Optional[String] = None
 31
 32
 33class Layer2(XMLBaseModel):
 34    model_config = ConfigDict(extra="allow")
 35    inttype: ClassVar[str] = "layer2"
 36
 37    name: String = Field(validation_alias="@name", default="")
 38    units: List["Layer2"] = Field(
 39        alias="units",
 40        validation_alias=AliasPath("units", "entry"),
 41        default_factory=list,
 42    )
 43    comment: String = ""
 44    tags: List[String] = Field(
 45        validation_alias=AliasPath("tag", "member"),
 46        default_factory=list,
 47    )
 48
 49    def flatten(self, parent=None) -> Iterable[GenericInterface]:
 50        if self.name:
 51            dump = self.model_dump()
 52            dump.update(
 53                {
 54                    "inttype": self.inttype,
 55                    "parent": parent,
 56                }
 57            )
 58            generic = GenericInterface.model_validate(dump)
 59            yield generic
 60            parent = self.name
 61        for u in self.units:
 62            yield from u.flatten(parent)
 63
 64
 65class Layer3(XMLBaseModel):
 66    model_config = ConfigDict(extra="allow")
 67    inttype: ClassVar[str] = "layer3"
 68
 69    name: Optional[String] = Field(validation_alias="@name", default=None)
 70    description: String = Field(validation_alias="#text", default="")
 71    ip: List[Ip] = Field(
 72        validation_alias=AliasPath("ip", "entry"), default_factory=list
 73    )
 74    untagged_sub_interface: Optional[String] = Field(
 75        alias="untagged-sub-interface",
 76        default=None,
 77    )
 78    units: List["Layer3"] = Field(
 79        alias="units",
 80        validation_alias=AliasPath("units", "entry"),
 81        default_factory=list,
 82    )
 83    comment: String = ""
 84    tags: List[String] = Field(
 85        validation_alias=AliasPath("tag", "member"),
 86        default_factory=list,
 87    )
 88
 89    def flatten(self, parent=None) -> Iterable[GenericInterface]:
 90        if self.name:
 91            dump = self.model_dump()
 92            dump.update(
 93                {
 94                    "inttype": self.inttype,
 95                    "parent": parent,
 96                }
 97            )
 98            generic = GenericInterface.model_validate(dump)
 99            yield generic
100            parent = self.name
101        for u in self.units:
102            yield from u.flatten(parent)
103
104
105class Vlan(XMLBaseModel):
106    model_config = ConfigDict(extra="allow")
107    inttype: ClassVar[str] = "vlan"
108
109    name: Optional[String] = Field(validation_alias="@name", default=None)
110    description: String = Field(validation_alias="#text", default="")
111    ip: List[Ip] = Field(
112        validation_alias=AliasPath("ip", "entry"), default_factory=list
113    )
114    # untagged_sub_interface: Optional[String] = Field(
115    #     alias="untagged-sub-interface",
116    #     default=None,
117    # )
118    units: List["Vlan"] = Field(
119        alias="units",
120        validation_alias=AliasPath("units", "entry"),
121        default_factory=list,
122    )
123    comment: String = ""
124    tags: List[String] = Field(
125        validation_alias=AliasPath("tag", "member"),
126        default_factory=list,
127    )
128
129    def flatten(self, parent=None) -> Iterable[GenericInterface]:
130        if self.name:
131            dump = self.model_dump()
132            dump.update(
133                {
134                    "inttype": self.inttype,
135                    "parent": parent,
136                }
137            )
138            generic = GenericInterface.model_validate(dump)
139            yield generic
140            parent = self.name
141        for u in self.units:
142            yield from u.flatten(parent)
143
144
145class Ethernet(XMLBaseModel):
146    model_config = ConfigDict(extra="allow")
147    inttype: ClassVar[str] = "ethernet"
148
149    name: str = Field(validation_alias="@name")
150    ip: List[str] = Field(
151        validation_alias=AliasPath("layer3", "ip", "entry", "@name"),
152        default_factory=list,
153    )
154    description: String = Field(validation_alias="#text", default="")
155    link_state: Optional[str] = Field(
156        alias="link-state",
157        validation_alias=AliasPath("link-state", "#text"),
158        default=None,
159    )
160    link_speed: Optional[str] = Field(
161        alias="link-speed",
162        validation_alias=AliasPath("link-speed", "#text"),
163        default=None,
164    )
165    link_duplex: Optional[str] = Field(
166        alias="link-duplex",
167        validation_alias=AliasPath("link-duplex", "#text"),
168        default=None,
169    )
170    aggregate_group: Optional[String] = Field(
171        alias="aggregate-group",
172        default=None,
173    )
174    layer2: Optional[Layer2] = Field(alias="layer2", default=None)
175    layer3: Optional[Layer3] = Field(alias="layer3", default=None)
176    tags: List[String] = Field(
177        validation_alias=AliasPath("tag", "member"),
178        default_factory=list,
179    )
180
181    def flatten(self, parent=None) -> Iterable[GenericInterface]:
182        if self.name:
183            dump = self.model_dump()
184            dump.update(
185                {
186                    "inttype": self.inttype,
187                    "parent": parent,
188                }
189            )
190            generic = GenericInterface.model_validate(dump)
191            yield generic
192            parent = self.name
193        if self.layer2:
194            yield from self.layer2.flatten(parent)
195        if self.layer3:
196            yield from self.layer3.flatten(parent)
197
198
199class AggregateEthernet(XMLBaseModel):
200    model_config = ConfigDict(extra="allow")
201    inttype: ClassVar[str] = "aggregate"
202
203    name: str = Field(validation_alias="@name")
204    ip: List[str] = Field(
205        validation_alias=AliasPath("layer3", "ip", "entry", "@name"),
206        default_factory=list,
207    )
208    description: String = Field(validation_alias="#text", default="")
209    comment: String = ""
210    units: List["AggregateEthernet"] = Field(
211        alias="units",
212        validation_alias=AliasPath("units", "entry"),
213        default_factory=list,
214    )
215    layer2: Optional[Layer2] = Field(alias="layer2", default=None)
216    layer3: Optional[Layer3] = Field(alias="layer3", default=None)
217    untagged_sub_interface: Optional[String] = Field(
218        alias="untagged-sub-interface",
219        default=None,
220    )
221    tags: List[String] = Field(
222        validation_alias=AliasPath("tag", "member"),
223        default_factory=list,
224    )
225
226    def flatten(self, parent=None) -> Iterable[GenericInterface]:
227        if self.name:
228            dump = self.model_dump()
229            dump.update(
230                {
231                    "inttype": self.inttype,
232                    "parent": parent,
233                }
234            )
235            generic = GenericInterface.model_validate(dump)
236            yield generic
237            parent = self.name
238        if self.layer2:
239            yield from self.layer2.flatten(parent)
240        if self.layer3:
241            yield from self.layer3.flatten(parent)
242
243
244class Tunnel(XMLBaseModel):
245    model_config = ConfigDict(extra="allow")
246    inttype: ClassVar[str] = "tunnel"
247
248    name: str = Field(validation_alias="@name")
249    units: List["Tunnel"] = Field(
250        alias="units",
251        validation_alias=AliasPath("units", "entry"),
252        default_factory=list,
253    )
254    ip: List[str] = Field(
255        validation_alias=AliasPath("ip", "entry", "@name"),
256        default_factory=list,
257    )
258    interface_management_profile: Optional[String] = Field(
259        validation_alias="interface-management-profile", default=None
260    )
261
262    comment: Optional[str] = Field(
263        alias="comment", validation_alias=AliasPath("comment", "#text"), default=None
264    )
265    mtu: Optional[str] = Field(
266        alias="comment", validation_alias=AliasPath("mtu", "#text"), default=None
267    )
268
269    def flatten(self, parent=None) -> Iterable[GenericInterface]:
270        dump = self.model_dump()
271        dump.update(
272            {
273                "inttype": self.inttype,
274                "parent": parent,
275            }
276        )
277        generic = GenericInterface.model_validate(dump)
278        yield generic
279
280
281class Loopback(XMLBaseModel):
282    model_config = ConfigDict(extra="allow")
283    inttype: ClassVar[str] = "loopback"
284
285    name: str = Field(validation_alias="@name")
286    description: Optional[String] = Field(validation_alias="#text", default=None)
287    ip: List[Ip] = Field(
288        validation_alias=AliasPath("ip", "entry"), default_factory=list
289    )
290    comment: Optional[str] = Field(
291        alias="comment", validation_alias=AliasPath("comment", "#text"), default=None
292    )
293    tags: List[String] = Field(
294        validation_alias=AliasPath("tag", "member"),
295        default_factory=list,
296    )
297
298    def flatten(self, parent=None) -> Iterable[GenericInterface]:
299        dump = self.model_dump()
300        dump.update(
301            {
302                "inttype": self.inttype,
303                "parent": parent,
304            }
305        )
306        generic = GenericInterface.model_validate(dump)
307        yield generic
308
309
310# https://docs.pydantic.dev/latest/concepts/alias/#aliaspath-and-aliaschoices
311class Interface(XMLBaseModel):
312    model_config = ConfigDict(extra="allow")
313
314    aggregate_ethernet: List[AggregateEthernet] = Field(
315        alias="aggregate-ethernet",
316        validation_alias=AliasPath("aggregate-ethernet", "entry"),
317        default_factory=list,
318    )
319    # entry = Field(alias="entry")
320    ethernet: List[Ethernet] = Field(
321        alias="ethernet",
322        validation_alias=AliasPath("ethernet", "entry"),
323        default_factory=list,
324    )
325    loopback: List[Loopback] = Field(
326        alias="loopback",
327        validation_alias=AliasPath("loopback", "units", "entry"),
328        default_factory=list,
329    )
330    vlan: List[Vlan] = Field(
331        alias="vlan",
332        validation_alias=AliasPath("vlan", "units", "entry"),
333        default_factory=list,
334    )
335    tunnel: List[Tunnel] = Field(
336        alias="tunnel",
337        validation_alias=AliasPath("tunnel", "units", "entry"),
338        default_factory=list,
339    )
340
341    # ha1 = Field(alias='ha1')
342    # ha1_backup = Field(alias='ha1-backup')
343    # ha2 = Field(alias='ha2')
344    # ha2_backup = Field(alias='ha2-backup')
345    # ha3 = Field(alias='ha3')
346    # member = Field(alias='member')
347    # tunnel = Field(alias='tunnel')
348
349    def _flatten(self) -> Iterable[GenericInterface]:
350        for eth in self.ethernet:
351            yield from eth.flatten()
352        for agg in self.aggregate_ethernet:
353            yield from agg.flatten()
354        for v in self.vlan:
355            yield from v.flatten()
356        for lb in self.loopback:
357            yield from lb.flatten()
358
359    def flatten(self) -> List[GenericInterface]:
360        return list(self._flatten())
def get_ip_network(ip_netmask):
10def get_ip_network(ip_netmask):
11    try:
12        if ip_netmask:
13            return ip_network(ip_netmask, strict=False)
14    except Exception:
15        return None
class GenericInterface(pa_api.xmlapi.types.utils.XMLBaseModel):
18class GenericInterface(XMLBaseModel):
19    model_config = ConfigDict(extra="ignore")
20    inttype: str
21    parent: Optional[str] = None
22    name: str
23    description: String = ""
24    comment: String = ""
25    ip: List[str] = Field(default_factory=list)
26    untagged_sub_interface: Optional[String] = None
27    tags: List[String] = Field(default_factory=list)
28    link_state: Optional[str] = None
29    link_speed: Optional[str] = None
30    link_duplex: Optional[str] = None
31    aggregate_group: Optional[String] = None

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

Attributes: __class_vars__: The names of the class variables defined on the model. __private_attributes__: Metadata about the private attributes of the model. __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__: The core schema of the model.
__pydantic_custom_init__: Whether the model has a custom `__init__` function.
__pydantic_decorators__: Metadata containing the decorators defined on the model.
    This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
__pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
    __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__: The name of the post-init method for the model, if defined.
__pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
__pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
__pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

__pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
    is set to `'allow'`.
__pydantic_fields_set__: The names of fields explicitly set during instantiation.
__pydantic_private__: Values of private attributes set on the model instance.
model_config = {'extra': 'ignore'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

inttype: str
parent: Optional[str]
name: str
description: typing.Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]
comment: typing.Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]
ip: Annotated[List[str], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
untagged_sub_interface: Optional[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]]
tags: Annotated[List[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
aggregate_group: Optional[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]]
model_fields: ClassVar[Dict[str, pydantic.fields.FieldInfo]] = {'inttype': FieldInfo(annotation=str, required=True), 'parent': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'name': FieldInfo(annotation=str, required=True), 'description': FieldInfo(annotation=str, required=False, default='', metadata=[BeforeValidator(func=<function ensure_str>, json_schema_input_type=PydanticUndefined)]), 'comment': FieldInfo(annotation=str, required=False, default='', metadata=[BeforeValidator(func=<function ensure_str>, json_schema_input_type=PydanticUndefined)]), 'ip': FieldInfo(annotation=List[str], required=False, default_factory=list, metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'untagged_sub_interface': FieldInfo(annotation=Union[Annotated[str, BeforeValidator], NoneType], required=False, default=None), 'tags': FieldInfo(annotation=List[Annotated[str, BeforeValidator]], required=False, default_factory=list, metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'link_state': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'link_speed': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'link_duplex': FieldInfo(annotation=Union[str, NoneType], required=False, default=None), 'aggregate_group': FieldInfo(annotation=Union[Annotated[str, BeforeValidator], NoneType], required=False, default=None)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

model_computed_fields: ClassVar[Dict[str, pydantic.fields.ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
pa_api.xmlapi.types.utils.XMLBaseModel
from_xml
class Layer2(pa_api.xmlapi.types.utils.XMLBaseModel):
34class Layer2(XMLBaseModel):
35    model_config = ConfigDict(extra="allow")
36    inttype: ClassVar[str] = "layer2"
37
38    name: String = Field(validation_alias="@name", default="")
39    units: List["Layer2"] = Field(
40        alias="units",
41        validation_alias=AliasPath("units", "entry"),
42        default_factory=list,
43    )
44    comment: String = ""
45    tags: List[String] = Field(
46        validation_alias=AliasPath("tag", "member"),
47        default_factory=list,
48    )
49
50    def flatten(self, parent=None) -> Iterable[GenericInterface]:
51        if self.name:
52            dump = self.model_dump()
53            dump.update(
54                {
55                    "inttype": self.inttype,
56                    "parent": parent,
57                }
58            )
59            generic = GenericInterface.model_validate(dump)
60            yield generic
61            parent = self.name
62        for u in self.units:
63            yield from u.flatten(parent)

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

Attributes: __class_vars__: The names of the class variables defined on the model. __private_attributes__: Metadata about the private attributes of the model. __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__: The core schema of the model.
__pydantic_custom_init__: Whether the model has a custom `__init__` function.
__pydantic_decorators__: Metadata containing the decorators defined on the model.
    This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
__pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
    __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__: The name of the post-init method for the model, if defined.
__pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
__pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
__pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

__pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
    is set to `'allow'`.
__pydantic_fields_set__: The names of fields explicitly set during instantiation.
__pydantic_private__: Values of private attributes set on the model instance.
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

inttype: ClassVar[str] = 'layer2'
name: typing.Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]
units: Annotated[List[Layer2], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
comment: typing.Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]
tags: Annotated[List[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
def flatten( self, parent=None) -> Iterable[GenericInterface]:
50    def flatten(self, parent=None) -> Iterable[GenericInterface]:
51        if self.name:
52            dump = self.model_dump()
53            dump.update(
54                {
55                    "inttype": self.inttype,
56                    "parent": parent,
57                }
58            )
59            generic = GenericInterface.model_validate(dump)
60            yield generic
61            parent = self.name
62        for u in self.units:
63            yield from u.flatten(parent)
model_fields: ClassVar[Dict[str, pydantic.fields.FieldInfo]] = {'name': FieldInfo(annotation=str, required=False, default='', alias_priority=2, validation_alias='@name', metadata=[BeforeValidator(func=<function ensure_str>, json_schema_input_type=PydanticUndefined)]), 'units': FieldInfo(annotation=List[Layer2], required=False, default_factory=list, alias='units', alias_priority=2, validation_alias=AliasPath(path=['units', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'comment': FieldInfo(annotation=str, required=False, default='', metadata=[BeforeValidator(func=<function ensure_str>, json_schema_input_type=PydanticUndefined)]), 'tags': FieldInfo(annotation=List[Annotated[str, BeforeValidator]], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['tag', 'member']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

model_computed_fields: ClassVar[Dict[str, pydantic.fields.ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
pa_api.xmlapi.types.utils.XMLBaseModel
from_xml
class Layer3(pa_api.xmlapi.types.utils.XMLBaseModel):
 66class Layer3(XMLBaseModel):
 67    model_config = ConfigDict(extra="allow")
 68    inttype: ClassVar[str] = "layer3"
 69
 70    name: Optional[String] = Field(validation_alias="@name", default=None)
 71    description: String = Field(validation_alias="#text", default="")
 72    ip: List[Ip] = Field(
 73        validation_alias=AliasPath("ip", "entry"), default_factory=list
 74    )
 75    untagged_sub_interface: Optional[String] = Field(
 76        alias="untagged-sub-interface",
 77        default=None,
 78    )
 79    units: List["Layer3"] = Field(
 80        alias="units",
 81        validation_alias=AliasPath("units", "entry"),
 82        default_factory=list,
 83    )
 84    comment: String = ""
 85    tags: List[String] = Field(
 86        validation_alias=AliasPath("tag", "member"),
 87        default_factory=list,
 88    )
 89
 90    def flatten(self, parent=None) -> Iterable[GenericInterface]:
 91        if self.name:
 92            dump = self.model_dump()
 93            dump.update(
 94                {
 95                    "inttype": self.inttype,
 96                    "parent": parent,
 97                }
 98            )
 99            generic = GenericInterface.model_validate(dump)
100            yield generic
101            parent = self.name
102        for u in self.units:
103            yield from u.flatten(parent)

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

Attributes: __class_vars__: The names of the class variables defined on the model. __private_attributes__: Metadata about the private attributes of the model. __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__: The core schema of the model.
__pydantic_custom_init__: Whether the model has a custom `__init__` function.
__pydantic_decorators__: Metadata containing the decorators defined on the model.
    This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
__pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
    __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__: The name of the post-init method for the model, if defined.
__pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
__pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
__pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

__pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
    is set to `'allow'`.
__pydantic_fields_set__: The names of fields explicitly set during instantiation.
__pydantic_private__: Values of private attributes set on the model instance.
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

inttype: ClassVar[str] = 'layer3'
name: Optional[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]]
description: typing.Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]
ip: Annotated[List[Annotated[str, BeforeValidator(func=<function validate_ip at 0x7f0db0c89c60>, json_schema_input_type=PydanticUndefined)]], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
untagged_sub_interface: Optional[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]]
units: Annotated[List[Layer3], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
comment: typing.Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]
tags: Annotated[List[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
def flatten( self, parent=None) -> Iterable[GenericInterface]:
 90    def flatten(self, parent=None) -> Iterable[GenericInterface]:
 91        if self.name:
 92            dump = self.model_dump()
 93            dump.update(
 94                {
 95                    "inttype": self.inttype,
 96                    "parent": parent,
 97                }
 98            )
 99            generic = GenericInterface.model_validate(dump)
100            yield generic
101            parent = self.name
102        for u in self.units:
103            yield from u.flatten(parent)
model_fields: ClassVar[Dict[str, pydantic.fields.FieldInfo]] = {'name': FieldInfo(annotation=Union[Annotated[str, BeforeValidator], NoneType], required=False, default=None, alias_priority=2, validation_alias='@name'), 'description': FieldInfo(annotation=str, required=False, default='', alias_priority=2, validation_alias='#text', metadata=[BeforeValidator(func=<function ensure_str>, json_schema_input_type=PydanticUndefined)]), 'ip': FieldInfo(annotation=List[Annotated[str, BeforeValidator]], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['ip', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'untagged_sub_interface': FieldInfo(annotation=Union[Annotated[str, BeforeValidator], NoneType], required=False, default=None, alias='untagged-sub-interface', alias_priority=2), 'units': FieldInfo(annotation=List[Layer3], required=False, default_factory=list, alias='units', alias_priority=2, validation_alias=AliasPath(path=['units', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'comment': FieldInfo(annotation=str, required=False, default='', metadata=[BeforeValidator(func=<function ensure_str>, json_schema_input_type=PydanticUndefined)]), 'tags': FieldInfo(annotation=List[Annotated[str, BeforeValidator]], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['tag', 'member']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

model_computed_fields: ClassVar[Dict[str, pydantic.fields.ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
pa_api.xmlapi.types.utils.XMLBaseModel
from_xml
class Vlan(pa_api.xmlapi.types.utils.XMLBaseModel):
106class Vlan(XMLBaseModel):
107    model_config = ConfigDict(extra="allow")
108    inttype: ClassVar[str] = "vlan"
109
110    name: Optional[String] = Field(validation_alias="@name", default=None)
111    description: String = Field(validation_alias="#text", default="")
112    ip: List[Ip] = Field(
113        validation_alias=AliasPath("ip", "entry"), default_factory=list
114    )
115    # untagged_sub_interface: Optional[String] = Field(
116    #     alias="untagged-sub-interface",
117    #     default=None,
118    # )
119    units: List["Vlan"] = Field(
120        alias="units",
121        validation_alias=AliasPath("units", "entry"),
122        default_factory=list,
123    )
124    comment: String = ""
125    tags: List[String] = Field(
126        validation_alias=AliasPath("tag", "member"),
127        default_factory=list,
128    )
129
130    def flatten(self, parent=None) -> Iterable[GenericInterface]:
131        if self.name:
132            dump = self.model_dump()
133            dump.update(
134                {
135                    "inttype": self.inttype,
136                    "parent": parent,
137                }
138            )
139            generic = GenericInterface.model_validate(dump)
140            yield generic
141            parent = self.name
142        for u in self.units:
143            yield from u.flatten(parent)

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

Attributes: __class_vars__: The names of the class variables defined on the model. __private_attributes__: Metadata about the private attributes of the model. __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__: The core schema of the model.
__pydantic_custom_init__: Whether the model has a custom `__init__` function.
__pydantic_decorators__: Metadata containing the decorators defined on the model.
    This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
__pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
    __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__: The name of the post-init method for the model, if defined.
__pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
__pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
__pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

__pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
    is set to `'allow'`.
__pydantic_fields_set__: The names of fields explicitly set during instantiation.
__pydantic_private__: Values of private attributes set on the model instance.
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

inttype: ClassVar[str] = 'vlan'
name: Optional[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]]
description: typing.Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]
ip: Annotated[List[Annotated[str, BeforeValidator(func=<function validate_ip at 0x7f0db0c89c60>, json_schema_input_type=PydanticUndefined)]], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
units: Annotated[List[Vlan], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
comment: typing.Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]
tags: Annotated[List[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
def flatten( self, parent=None) -> Iterable[GenericInterface]:
130    def flatten(self, parent=None) -> Iterable[GenericInterface]:
131        if self.name:
132            dump = self.model_dump()
133            dump.update(
134                {
135                    "inttype": self.inttype,
136                    "parent": parent,
137                }
138            )
139            generic = GenericInterface.model_validate(dump)
140            yield generic
141            parent = self.name
142        for u in self.units:
143            yield from u.flatten(parent)
model_fields: ClassVar[Dict[str, pydantic.fields.FieldInfo]] = {'name': FieldInfo(annotation=Union[Annotated[str, BeforeValidator], NoneType], required=False, default=None, alias_priority=2, validation_alias='@name'), 'description': FieldInfo(annotation=str, required=False, default='', alias_priority=2, validation_alias='#text', metadata=[BeforeValidator(func=<function ensure_str>, json_schema_input_type=PydanticUndefined)]), 'ip': FieldInfo(annotation=List[Annotated[str, BeforeValidator]], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['ip', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'units': FieldInfo(annotation=List[Vlan], required=False, default_factory=list, alias='units', alias_priority=2, validation_alias=AliasPath(path=['units', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'comment': FieldInfo(annotation=str, required=False, default='', metadata=[BeforeValidator(func=<function ensure_str>, json_schema_input_type=PydanticUndefined)]), 'tags': FieldInfo(annotation=List[Annotated[str, BeforeValidator]], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['tag', 'member']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

model_computed_fields: ClassVar[Dict[str, pydantic.fields.ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
pa_api.xmlapi.types.utils.XMLBaseModel
from_xml
class Ethernet(pa_api.xmlapi.types.utils.XMLBaseModel):
146class Ethernet(XMLBaseModel):
147    model_config = ConfigDict(extra="allow")
148    inttype: ClassVar[str] = "ethernet"
149
150    name: str = Field(validation_alias="@name")
151    ip: List[str] = Field(
152        validation_alias=AliasPath("layer3", "ip", "entry", "@name"),
153        default_factory=list,
154    )
155    description: String = Field(validation_alias="#text", default="")
156    link_state: Optional[str] = Field(
157        alias="link-state",
158        validation_alias=AliasPath("link-state", "#text"),
159        default=None,
160    )
161    link_speed: Optional[str] = Field(
162        alias="link-speed",
163        validation_alias=AliasPath("link-speed", "#text"),
164        default=None,
165    )
166    link_duplex: Optional[str] = Field(
167        alias="link-duplex",
168        validation_alias=AliasPath("link-duplex", "#text"),
169        default=None,
170    )
171    aggregate_group: Optional[String] = Field(
172        alias="aggregate-group",
173        default=None,
174    )
175    layer2: Optional[Layer2] = Field(alias="layer2", default=None)
176    layer3: Optional[Layer3] = Field(alias="layer3", default=None)
177    tags: List[String] = Field(
178        validation_alias=AliasPath("tag", "member"),
179        default_factory=list,
180    )
181
182    def flatten(self, parent=None) -> Iterable[GenericInterface]:
183        if self.name:
184            dump = self.model_dump()
185            dump.update(
186                {
187                    "inttype": self.inttype,
188                    "parent": parent,
189                }
190            )
191            generic = GenericInterface.model_validate(dump)
192            yield generic
193            parent = self.name
194        if self.layer2:
195            yield from self.layer2.flatten(parent)
196        if self.layer3:
197            yield from self.layer3.flatten(parent)

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

Attributes: __class_vars__: The names of the class variables defined on the model. __private_attributes__: Metadata about the private attributes of the model. __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__: The core schema of the model.
__pydantic_custom_init__: Whether the model has a custom `__init__` function.
__pydantic_decorators__: Metadata containing the decorators defined on the model.
    This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
__pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
    __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__: The name of the post-init method for the model, if defined.
__pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
__pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
__pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

__pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
    is set to `'allow'`.
__pydantic_fields_set__: The names of fields explicitly set during instantiation.
__pydantic_private__: Values of private attributes set on the model instance.
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

inttype: ClassVar[str] = 'ethernet'
name: str
ip: Annotated[List[str], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
description: typing.Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]
aggregate_group: Optional[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]]
layer2: Optional[Layer2]
layer3: Optional[Layer3]
tags: Annotated[List[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
def flatten( self, parent=None) -> Iterable[GenericInterface]:
182    def flatten(self, parent=None) -> Iterable[GenericInterface]:
183        if self.name:
184            dump = self.model_dump()
185            dump.update(
186                {
187                    "inttype": self.inttype,
188                    "parent": parent,
189                }
190            )
191            generic = GenericInterface.model_validate(dump)
192            yield generic
193            parent = self.name
194        if self.layer2:
195            yield from self.layer2.flatten(parent)
196        if self.layer3:
197            yield from self.layer3.flatten(parent)
model_fields: ClassVar[Dict[str, pydantic.fields.FieldInfo]] = {'name': FieldInfo(annotation=str, required=True, alias_priority=2, validation_alias='@name'), 'ip': FieldInfo(annotation=List[str], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['layer3', 'ip', 'entry', '@name']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'description': FieldInfo(annotation=str, required=False, default='', alias_priority=2, validation_alias='#text', metadata=[BeforeValidator(func=<function ensure_str>, json_schema_input_type=PydanticUndefined)]), 'link_state': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='link-state', alias_priority=2, validation_alias=AliasPath(path=['link-state', '#text'])), 'link_speed': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='link-speed', alias_priority=2, validation_alias=AliasPath(path=['link-speed', '#text'])), 'link_duplex': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='link-duplex', alias_priority=2, validation_alias=AliasPath(path=['link-duplex', '#text'])), 'aggregate_group': FieldInfo(annotation=Union[Annotated[str, BeforeValidator], NoneType], required=False, default=None, alias='aggregate-group', alias_priority=2), 'layer2': FieldInfo(annotation=Union[Layer2, NoneType], required=False, default=None, alias='layer2', alias_priority=2), 'layer3': FieldInfo(annotation=Union[Layer3, NoneType], required=False, default=None, alias='layer3', alias_priority=2), 'tags': FieldInfo(annotation=List[Annotated[str, BeforeValidator]], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['tag', 'member']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

model_computed_fields: ClassVar[Dict[str, pydantic.fields.ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
pa_api.xmlapi.types.utils.XMLBaseModel
from_xml
class AggregateEthernet(pa_api.xmlapi.types.utils.XMLBaseModel):
200class AggregateEthernet(XMLBaseModel):
201    model_config = ConfigDict(extra="allow")
202    inttype: ClassVar[str] = "aggregate"
203
204    name: str = Field(validation_alias="@name")
205    ip: List[str] = Field(
206        validation_alias=AliasPath("layer3", "ip", "entry", "@name"),
207        default_factory=list,
208    )
209    description: String = Field(validation_alias="#text", default="")
210    comment: String = ""
211    units: List["AggregateEthernet"] = Field(
212        alias="units",
213        validation_alias=AliasPath("units", "entry"),
214        default_factory=list,
215    )
216    layer2: Optional[Layer2] = Field(alias="layer2", default=None)
217    layer3: Optional[Layer3] = Field(alias="layer3", default=None)
218    untagged_sub_interface: Optional[String] = Field(
219        alias="untagged-sub-interface",
220        default=None,
221    )
222    tags: List[String] = Field(
223        validation_alias=AliasPath("tag", "member"),
224        default_factory=list,
225    )
226
227    def flatten(self, parent=None) -> Iterable[GenericInterface]:
228        if self.name:
229            dump = self.model_dump()
230            dump.update(
231                {
232                    "inttype": self.inttype,
233                    "parent": parent,
234                }
235            )
236            generic = GenericInterface.model_validate(dump)
237            yield generic
238            parent = self.name
239        if self.layer2:
240            yield from self.layer2.flatten(parent)
241        if self.layer3:
242            yield from self.layer3.flatten(parent)

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

Attributes: __class_vars__: The names of the class variables defined on the model. __private_attributes__: Metadata about the private attributes of the model. __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__: The core schema of the model.
__pydantic_custom_init__: Whether the model has a custom `__init__` function.
__pydantic_decorators__: Metadata containing the decorators defined on the model.
    This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
__pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
    __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__: The name of the post-init method for the model, if defined.
__pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
__pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
__pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

__pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
    is set to `'allow'`.
__pydantic_fields_set__: The names of fields explicitly set during instantiation.
__pydantic_private__: Values of private attributes set on the model instance.
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

inttype: ClassVar[str] = 'aggregate'
name: str
ip: Annotated[List[str], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
description: typing.Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]
comment: typing.Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]
units: Annotated[List[AggregateEthernet], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
layer2: Optional[Layer2]
layer3: Optional[Layer3]
untagged_sub_interface: Optional[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]]
tags: Annotated[List[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
def flatten( self, parent=None) -> Iterable[GenericInterface]:
227    def flatten(self, parent=None) -> Iterable[GenericInterface]:
228        if self.name:
229            dump = self.model_dump()
230            dump.update(
231                {
232                    "inttype": self.inttype,
233                    "parent": parent,
234                }
235            )
236            generic = GenericInterface.model_validate(dump)
237            yield generic
238            parent = self.name
239        if self.layer2:
240            yield from self.layer2.flatten(parent)
241        if self.layer3:
242            yield from self.layer3.flatten(parent)
model_fields: ClassVar[Dict[str, pydantic.fields.FieldInfo]] = {'name': FieldInfo(annotation=str, required=True, alias_priority=2, validation_alias='@name'), 'ip': FieldInfo(annotation=List[str], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['layer3', 'ip', 'entry', '@name']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'description': FieldInfo(annotation=str, required=False, default='', alias_priority=2, validation_alias='#text', metadata=[BeforeValidator(func=<function ensure_str>, json_schema_input_type=PydanticUndefined)]), 'comment': FieldInfo(annotation=str, required=False, default='', metadata=[BeforeValidator(func=<function ensure_str>, json_schema_input_type=PydanticUndefined)]), 'units': FieldInfo(annotation=List[AggregateEthernet], required=False, default_factory=list, alias='units', alias_priority=2, validation_alias=AliasPath(path=['units', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'layer2': FieldInfo(annotation=Union[Layer2, NoneType], required=False, default=None, alias='layer2', alias_priority=2), 'layer3': FieldInfo(annotation=Union[Layer3, NoneType], required=False, default=None, alias='layer3', alias_priority=2), 'untagged_sub_interface': FieldInfo(annotation=Union[Annotated[str, BeforeValidator], NoneType], required=False, default=None, alias='untagged-sub-interface', alias_priority=2), 'tags': FieldInfo(annotation=List[Annotated[str, BeforeValidator]], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['tag', 'member']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

model_computed_fields: ClassVar[Dict[str, pydantic.fields.ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
pa_api.xmlapi.types.utils.XMLBaseModel
from_xml
class Tunnel(pa_api.xmlapi.types.utils.XMLBaseModel):
245class Tunnel(XMLBaseModel):
246    model_config = ConfigDict(extra="allow")
247    inttype: ClassVar[str] = "tunnel"
248
249    name: str = Field(validation_alias="@name")
250    units: List["Tunnel"] = Field(
251        alias="units",
252        validation_alias=AliasPath("units", "entry"),
253        default_factory=list,
254    )
255    ip: List[str] = Field(
256        validation_alias=AliasPath("ip", "entry", "@name"),
257        default_factory=list,
258    )
259    interface_management_profile: Optional[String] = Field(
260        validation_alias="interface-management-profile", default=None
261    )
262
263    comment: Optional[str] = Field(
264        alias="comment", validation_alias=AliasPath("comment", "#text"), default=None
265    )
266    mtu: Optional[str] = Field(
267        alias="comment", validation_alias=AliasPath("mtu", "#text"), default=None
268    )
269
270    def flatten(self, parent=None) -> Iterable[GenericInterface]:
271        dump = self.model_dump()
272        dump.update(
273            {
274                "inttype": self.inttype,
275                "parent": parent,
276            }
277        )
278        generic = GenericInterface.model_validate(dump)
279        yield generic

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

Attributes: __class_vars__: The names of the class variables defined on the model. __private_attributes__: Metadata about the private attributes of the model. __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__: The core schema of the model.
__pydantic_custom_init__: Whether the model has a custom `__init__` function.
__pydantic_decorators__: Metadata containing the decorators defined on the model.
    This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
__pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
    __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__: The name of the post-init method for the model, if defined.
__pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
__pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
__pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

__pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
    is set to `'allow'`.
__pydantic_fields_set__: The names of fields explicitly set during instantiation.
__pydantic_private__: Values of private attributes set on the model instance.
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

inttype: ClassVar[str] = 'tunnel'
name: str
units: Annotated[List[Tunnel], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
ip: Annotated[List[str], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
interface_management_profile: Optional[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]]
comment: Optional[str]
mtu: Optional[str]
def flatten( self, parent=None) -> Iterable[GenericInterface]:
270    def flatten(self, parent=None) -> Iterable[GenericInterface]:
271        dump = self.model_dump()
272        dump.update(
273            {
274                "inttype": self.inttype,
275                "parent": parent,
276            }
277        )
278        generic = GenericInterface.model_validate(dump)
279        yield generic
model_fields: ClassVar[Dict[str, pydantic.fields.FieldInfo]] = {'name': FieldInfo(annotation=str, required=True, alias_priority=2, validation_alias='@name'), 'units': FieldInfo(annotation=List[Tunnel], required=False, default_factory=list, alias='units', alias_priority=2, validation_alias=AliasPath(path=['units', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'ip': FieldInfo(annotation=List[str], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['ip', 'entry', '@name']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'interface_management_profile': FieldInfo(annotation=Union[Annotated[str, BeforeValidator], NoneType], required=False, default=None, alias_priority=2, validation_alias='interface-management-profile'), 'comment': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='comment', alias_priority=2, validation_alias=AliasPath(path=['comment', '#text'])), 'mtu': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='comment', alias_priority=2, validation_alias=AliasPath(path=['mtu', '#text']))}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

model_computed_fields: ClassVar[Dict[str, pydantic.fields.ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
pa_api.xmlapi.types.utils.XMLBaseModel
from_xml
class Loopback(pa_api.xmlapi.types.utils.XMLBaseModel):
282class Loopback(XMLBaseModel):
283    model_config = ConfigDict(extra="allow")
284    inttype: ClassVar[str] = "loopback"
285
286    name: str = Field(validation_alias="@name")
287    description: Optional[String] = Field(validation_alias="#text", default=None)
288    ip: List[Ip] = Field(
289        validation_alias=AliasPath("ip", "entry"), default_factory=list
290    )
291    comment: Optional[str] = Field(
292        alias="comment", validation_alias=AliasPath("comment", "#text"), default=None
293    )
294    tags: List[String] = Field(
295        validation_alias=AliasPath("tag", "member"),
296        default_factory=list,
297    )
298
299    def flatten(self, parent=None) -> Iterable[GenericInterface]:
300        dump = self.model_dump()
301        dump.update(
302            {
303                "inttype": self.inttype,
304                "parent": parent,
305            }
306        )
307        generic = GenericInterface.model_validate(dump)
308        yield generic

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

Attributes: __class_vars__: The names of the class variables defined on the model. __private_attributes__: Metadata about the private attributes of the model. __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__: The core schema of the model.
__pydantic_custom_init__: Whether the model has a custom `__init__` function.
__pydantic_decorators__: Metadata containing the decorators defined on the model.
    This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
__pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
    __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__: The name of the post-init method for the model, if defined.
__pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
__pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
__pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

__pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
    is set to `'allow'`.
__pydantic_fields_set__: The names of fields explicitly set during instantiation.
__pydantic_private__: Values of private attributes set on the model instance.
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

inttype: ClassVar[str] = 'loopback'
name: str
description: Optional[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]]
ip: Annotated[List[Annotated[str, BeforeValidator(func=<function validate_ip at 0x7f0db0c89c60>, json_schema_input_type=PydanticUndefined)]], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
comment: Optional[str]
tags: Annotated[List[Annotated[str, BeforeValidator(func=<function ensure_str at 0x7f0db0c89bd0>, json_schema_input_type=PydanticUndefined)]], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
def flatten( self, parent=None) -> Iterable[GenericInterface]:
299    def flatten(self, parent=None) -> Iterable[GenericInterface]:
300        dump = self.model_dump()
301        dump.update(
302            {
303                "inttype": self.inttype,
304                "parent": parent,
305            }
306        )
307        generic = GenericInterface.model_validate(dump)
308        yield generic
model_fields: ClassVar[Dict[str, pydantic.fields.FieldInfo]] = {'name': FieldInfo(annotation=str, required=True, alias_priority=2, validation_alias='@name'), 'description': FieldInfo(annotation=Union[Annotated[str, BeforeValidator], NoneType], required=False, default=None, alias_priority=2, validation_alias='#text'), 'ip': FieldInfo(annotation=List[Annotated[str, BeforeValidator]], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['ip', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'comment': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='comment', alias_priority=2, validation_alias=AliasPath(path=['comment', '#text'])), 'tags': FieldInfo(annotation=List[Annotated[str, BeforeValidator]], required=False, default_factory=list, alias_priority=2, validation_alias=AliasPath(path=['tag', 'member']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

model_computed_fields: ClassVar[Dict[str, pydantic.fields.ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
pa_api.xmlapi.types.utils.XMLBaseModel
from_xml
class Interface(pa_api.xmlapi.types.utils.XMLBaseModel):
312class Interface(XMLBaseModel):
313    model_config = ConfigDict(extra="allow")
314
315    aggregate_ethernet: List[AggregateEthernet] = Field(
316        alias="aggregate-ethernet",
317        validation_alias=AliasPath("aggregate-ethernet", "entry"),
318        default_factory=list,
319    )
320    # entry = Field(alias="entry")
321    ethernet: List[Ethernet] = Field(
322        alias="ethernet",
323        validation_alias=AliasPath("ethernet", "entry"),
324        default_factory=list,
325    )
326    loopback: List[Loopback] = Field(
327        alias="loopback",
328        validation_alias=AliasPath("loopback", "units", "entry"),
329        default_factory=list,
330    )
331    vlan: List[Vlan] = Field(
332        alias="vlan",
333        validation_alias=AliasPath("vlan", "units", "entry"),
334        default_factory=list,
335    )
336    tunnel: List[Tunnel] = Field(
337        alias="tunnel",
338        validation_alias=AliasPath("tunnel", "units", "entry"),
339        default_factory=list,
340    )
341
342    # ha1 = Field(alias='ha1')
343    # ha1_backup = Field(alias='ha1-backup')
344    # ha2 = Field(alias='ha2')
345    # ha2_backup = Field(alias='ha2-backup')
346    # ha3 = Field(alias='ha3')
347    # member = Field(alias='member')
348    # tunnel = Field(alias='tunnel')
349
350    def _flatten(self) -> Iterable[GenericInterface]:
351        for eth in self.ethernet:
352            yield from eth.flatten()
353        for agg in self.aggregate_ethernet:
354            yield from agg.flatten()
355        for v in self.vlan:
356            yield from v.flatten()
357        for lb in self.loopback:
358            yield from lb.flatten()
359
360    def flatten(self) -> List[GenericInterface]:
361        return list(self._flatten())

Usage docs: https://docs.pydantic.dev/2.9/concepts/models/

A base class for creating Pydantic models.

Attributes: __class_vars__: The names of the class variables defined on the model. __private_attributes__: Metadata about the private attributes of the model. __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.

__pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
__pydantic_core_schema__: The core schema of the model.
__pydantic_custom_init__: Whether the model has a custom `__init__` function.
__pydantic_decorators__: Metadata containing the decorators defined on the model.
    This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1.
__pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to
    __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
__pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
__pydantic_post_init__: The name of the post-init method for the model, if defined.
__pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel].
__pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model.
__pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model.

__pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra]
    is set to `'allow'`.
__pydantic_fields_set__: The names of fields explicitly set during instantiation.
__pydantic_private__: Values of private attributes set on the model instance.
model_config = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

aggregate_ethernet: Annotated[List[AggregateEthernet], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
ethernet: Annotated[List[Ethernet], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
loopback: Annotated[List[Loopback], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
vlan: Annotated[List[Vlan], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
tunnel: Annotated[List[Tunnel], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]
def flatten( self) -> Annotated[List[GenericInterface], BeforeValidator(func=<function ensure_list at 0x7f0db0c89ab0>, json_schema_input_type=PydanticUndefined)]:
360    def flatten(self) -> List[GenericInterface]:
361        return list(self._flatten())
model_fields: ClassVar[Dict[str, pydantic.fields.FieldInfo]] = {'aggregate_ethernet': FieldInfo(annotation=List[AggregateEthernet], required=False, default_factory=list, alias='aggregate-ethernet', alias_priority=2, validation_alias=AliasPath(path=['aggregate-ethernet', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'ethernet': FieldInfo(annotation=List[Ethernet], required=False, default_factory=list, alias='ethernet', alias_priority=2, validation_alias=AliasPath(path=['ethernet', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'loopback': FieldInfo(annotation=List[Loopback], required=False, default_factory=list, alias='loopback', alias_priority=2, validation_alias=AliasPath(path=['loopback', 'units', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'vlan': FieldInfo(annotation=List[Vlan], required=False, default_factory=list, alias='vlan', alias_priority=2, validation_alias=AliasPath(path=['vlan', 'units', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)]), 'tunnel': FieldInfo(annotation=List[Tunnel], required=False, default_factory=list, alias='tunnel', alias_priority=2, validation_alias=AliasPath(path=['tunnel', 'units', 'entry']), metadata=[BeforeValidator(func=<function ensure_list>, json_schema_input_type=PydanticUndefined)])}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

model_computed_fields: ClassVar[Dict[str, pydantic.fields.ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_post_init
model_rebuild
model_validate
model_validate_json
model_validate_strings
dict
json
parse_obj
parse_raw
parse_file
from_orm
construct
copy
schema
schema_json
validate
update_forward_refs
pa_api.xmlapi.types.utils.XMLBaseModel
from_xml