Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Oct 10, 2024
1 parent 1851017 commit 5839737
Show file tree
Hide file tree
Showing 48 changed files with 92 additions and 81 deletions.
4 changes: 2 additions & 2 deletions catalystwan/models/configuration/feature_profile/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def set_to_dhcp(


class NextHopContainer(BaseModel):
next_hop: List[NextHop] = Field(default=[], serialization_alias="nextHop", validation_alias="nextHop")
next_hop: List[NextHop] = Field(default_factory=list, serialization_alias="nextHop", validation_alias="nextHop")


class Ipv6StaticRouteNull0(BaseModel):
Expand Down Expand Up @@ -687,7 +687,7 @@ class MultilinkControllerTxExList(BaseModel):
)

channel_group: List[ChannelGroup] = Field(
default=[],
default_factory=list,
validation_alias="channelGroup",
serialization_alias="channelGroup",
description="Channel Group List",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class Ipv6AclParcel(_ParcelBase):
default=Default[Literal["drop"]](value="drop"), validation_alias=AliasPath("data", "defaultAction")
)
sequences: List[Sequence] = Field(
default=[], validation_alias=AliasPath("data", "sequences"), description="Access Control List"
default_factory=list, validation_alias=AliasPath("data", "sequences"), description="Access Control List"
)

def set_default_action(self, action: AcceptDropActionType):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,13 @@ def from_params(
) -> "SlaClassAction":
action = SlaClassAction()
action.sla_class = []
if sla_name is not None:
if sla_name:
action.sla_class.append(SlaClass(sla_name=RefIdItem.from_uuid(sla_name)))
if preferred_color:
action.sla_class.append(SlaClass(preferred_color=Global[List[TLOCColor]](value=preferred_color)))
if preferred_color_group is not None:
if preferred_color_group:
action.sla_class.append(SlaClass(preferred_color_group=RefIdItem.from_uuid(preferred_color_group)))
if preferred_remote_color is not None:
if preferred_remote_color:
action.sla_class.append(
SlaClass(preferred_remote_color=Global[List[TLOCColor]](value=preferred_remote_color))
)
Expand Down Expand Up @@ -1069,7 +1069,7 @@ class TrafficPolicyParcel(_ParcelBase):
default=None, validation_alias=AliasPath("data", "dataDefaultAction")
)
has_cor_via_sig: Optional[Global[bool]] = Field(default=None, validation_alias=AliasPath("data", "hasCorViaSig"))
sequences: List[Sequence] = Field(default=[], validation_alias=AliasPath("data", "sequences"))
sequences: List[Sequence] = Field(default_factory=list, validation_alias=AliasPath("data", "sequences"))
simple_flow: Optional[Global[bool]] = Field(default=None, validation_alias=AliasPath("data", "simpleFlow"))
target: TrafficPolicyTarget = Field(validation_alias=AliasPath("data", "target"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ class NgFirewallSequence(BaseModel):
)
match: Match
actions: List[Union[LogAction, AipAction]] = Field(
default=[], validation_alias="actions", min_length=0, max_length=2, serialization_alias="actions"
default_factory=list, validation_alias="actions", min_length=0, max_length=2, serialization_alias="actions"
)
disable_sequence: Global[bool] = Field(
default=Global[bool](value=False),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class PolicyParcel(_ParcelBase):
description="Set the parcel description",
)
assembly: List[Union[NgFirewallContainer, SslDecryption, AdvancedInspectionProfile]] = Field(
default=[], validation_alias=AliasPath("data", "assembly")
default_factory=list, validation_alias=AliasPath("data", "assembly")
)

settings: Optional[PolicySettings] = Field(default=None, validation_alias=AliasPath("data", "settings"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AppProbeMapItem(BaseModel):

class AppProbeEntry(BaseModel):
model_config = ConfigDict(populate_by_name=True)
map: List[AppProbeMapItem] = Field(default=[])
map: List[AppProbeMapItem] = Field(default_factory=list)
forwarding_class: Union[Global[str], RefIdItem] = Field(
validation_alias="forwardingClass",
serialization_alias="forwardingClass",
Expand All @@ -28,7 +28,7 @@ class AppProbeEntry(BaseModel):
class AppProbeParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["app-probe"] = Field(default="app-probe", exclude=True)
entries: List[AppProbeEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[AppProbeEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def _insert_entry(self, entry: AppProbeEntry) -> None:
if self.entries:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ApplicationListParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["app-list"] = Field(default="app-list", exclude=True)
entries: List[Union[ApplicationListEntry, ApplicationFamilyListEntry]] = Field(
default=[], validation_alias=AliasPath("data", "entries")
default_factory=list, validation_alias=AliasPath("data", "entries")
)

def add_application(self, application: str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AsPathParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["as-path"] = Field(default="as-path", exclude=True)
as_path_list_num: Global[int] = Field(validation_alias=AliasPath("data", "asPathListNum"))
entries: List[AsPathEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[AsPathEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_as_path(self, as_path: str):
self.entries.append(AsPathEntry(as_path=as_global(as_path)))
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ColorEntry(BaseModel):
class ColorParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["color"] = Field(default="color", exclude=True)
entries: List[ColorEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[ColorEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_color(self, color: TLOCColor):
self.entries.append(ColorEntry(color=as_global(color, TLOCColor)))
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def from_string(cls, entry: str):
class ExtendedCommunityParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["ext-community"] = Field(default="ext-community", exclude=True)
entries: List[ExtendedCommunityEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[ExtendedCommunityEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_site_of_origin_community(self, ip_address: IPv4Address, port: int):
entry = f"soo {ip_address}:{port}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def check_burst(cls, queue: Global):
class FowardingClassParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["class"] = Field(default="class", exclude=True)
entries: List[FowardingClassQueueEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[FowardingClassQueueEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_queue(self, queue: int):
self.entries.append(FowardingClassQueueEntry(queue=as_global(str(queue))))
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IPv6DataPrefixEntry(BaseModel):
class IPv6DataPrefixParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["data-ipv6-prefix"] = Field(default="data-ipv6-prefix", exclude=True)
entries: List[IPv6DataPrefixEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[IPv6DataPrefixEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_prefix(self, ipv6_network: IPv6Interface):
self.entries.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IPv6PrefixListEntry(BaseModel):
class IPv6PrefixListParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["ipv6-prefix"] = Field(default="ipv6-prefix", exclude=True)
entries: List[IPv6PrefixListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[IPv6PrefixListEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_prefix(self, ipv6_network: IPv6Interface, ge: Optional[int] = None, le: Optional[int] = None):
self.entries.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MirrorParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["mirror"] = Field(default="mirror", exclude=True)
entries: List[MirrorEntry] = Field(
default=[], validation_alias=AliasPath("data", "entries"), min_length=1, max_length=1
default_factory=list, validation_alias=AliasPath("data", "entries"), min_length=1, max_length=1
)

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def check_rate(cls, rate_str: Global):
class PolicerParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["policer"] = Field(default="policer", exclude=True)
entries: List[PolicerEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[PolicerEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_entry(self, burst: int, exceed: PolicerExceedAction, rate: int):
self.entries.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def remove_empty_preferences(cls, value):
class PreferredColorGroupParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["preferred-color-group"] = Field(default="preferred-color-group", exclude=True)
entries: List[PreferredColorGroupEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[PreferredColorGroupEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_primary(self, color_preference: List[TLOCColor], path_preference: PathPreference):
self.entries.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class SLAClassListEntry(BaseModel):
class SLAClassParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["sla-class"] = Field(default="sla-class", exclude=True)
entries: List[SLAClassListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[SLAClassListEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_entry(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class StandardCommunityEntry(BaseModel):
class StandardCommunityParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["standard-community"] = Field(default="standard-community", exclude=True)
entries: List[StandardCommunityEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[StandardCommunityEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def _add_community(self, standard_community: str):
self.entries.append(StandardCommunityEntry(standard_community=as_global(standard_community)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def ensure_correct_preference_value(cls, v: Global):
class TlocParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["tloc"] = Field(default="tloc", exclude=True)
entries: List[TlocEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[TlocEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_entry(
self, tloc: IPv4Address, color: TLOCColor, encapsulation: EncapType, preference: Optional[str] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SecurityApplicationListParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["security-localapp"] = Field(default="security-localapp", exclude=True)
entries: List[Union[SecurityApplicationFamilyListEntry, SecurityApplicationListEntry]] = Field(
default=[], validation_alias=AliasPath("data", "entries")
default_factory=list, validation_alias=AliasPath("data", "entries")
)

def add_application(self, application: str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SecurityDataPrefixEntry(BaseModel):
class SecurityDataPrefixParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["security-data-ip-prefix"] = Field(default="security-data-ip-prefix", exclude=True)
entries: List[SecurityDataPrefixEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[SecurityDataPrefixEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_prefix(self, ip_prefix: IPv4Network):
self.entries.append(SecurityDataPrefixEntry(ip_prefix=as_global(ip_prefix)))
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FQDNListEntry(BaseModel):
class FQDNDomainParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["security-fqdn"] = Field(default="security-fqdn", exclude=True)
entries: List[FQDNListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[FQDNListEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def from_fqdns(self, fqdns: List[str]):
for fqdn in fqdns:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def check_country_xor_continent(self):
class GeoLocationListParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["security-geolocation"] = Field(default="security-geolocation", exclude=True)
entries: List[GeoLocationListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[GeoLocationListEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_country(self, country: str):
self.entries.append(GeoLocationListEntry(country=as_global(country)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def check_signature_id(cls, signature_id: Global):
class IPSSignatureParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["security-ipssignature"] = Field(default="security-ipssignature", exclude=True)
entries: List[IPSSignatureListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[IPSSignatureListEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_signature(self, signature: str):
generator_id, signature_id = signature.split(":")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LocalDomainListEntry(BaseModel):
class LocalDomainParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["security-localdomain"] = Field(default="security-localdomain", exclude=True)
entries: List[LocalDomainListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[LocalDomainListEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def from_local_domains(self, domains: List[str]):
for domain in domains:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ProtocolListEntry(BaseModel):
class ProtocolListParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["security-protocolname"] = Field(default="security-protocolname", exclude=True)
entries: List[ProtocolListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[ProtocolListEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_protocol(self, protocol: str):
self.entries.append(ProtocolListEntry(protocol=as_global(protocol)))
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def check_port(cls, port: Global[str]):
class SecurityPortParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["security-port"] = Field(default="security-port", exclude=True)
entries: List[SecurityPortListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[SecurityPortListEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def _add_port(self, port: str):
self.entries.append(SecurityPortListEntry(port=as_global(port)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class URLParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["security-urllist"] = Field(default="security-urllist", exclude=True)
type: Literal["urlallowed", "urlblocked"]
entries: List[BaseURLListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[BaseURLListEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_url(self, pattern: str):
self.entries.append(BaseURLListEntry(pattern=as_global(pattern)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def check_vpn_xor_interface(self):
class SecurityZoneListParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True)
type_: Literal["security-zone"] = Field(default="security-zone", exclude=True)
entries: List[SecurityZoneListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))
entries: List[SecurityZoneListEntry] = Field(default_factory=list, validation_alias=AliasPath("data", "entries"))

def add_interface(self, interface: InterfaceStr):
self.entries.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ class RoutePolicyParcel(_ParcelBase):
description="Default Action",
)
sequences: List[RoutePolicySequence] = Field(
default=[], validation_alias=AliasPath("data", "sequences"), description="Route Policy List"
default_factory=list, validation_alias=AliasPath("data", "sequences"), description="Route Policy List"
)

def set_default_action(self, default_action: AcceptRejectActionType):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class DeviceAccessIPv4Parcel(_ParcelBase):
default=Default[AcceptDropActionType](value="drop"), validation_alias=AliasPath("data", "defaultAction")
)
sequences: List[Sequence] = Field(
default=[], validation_alias=AliasPath("data", "sequences"), description="Device Access Control List"
default_factory=list, validation_alias=AliasPath("data", "sequences"), description="Device Access Control List"
)

def set_default_action(self, default_action: AcceptDropActionType) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class DeviceAccessIPv6Parcel(_ParcelBase):
default=Default[AcceptDropActionType](value="drop"), validation_alias=AliasPath("data", "defaultAction")
)
sequences: List[Sequence] = Field(
default=[], validation_alias=AliasPath("data", "sequences"), description="Device Access Control List"
default_factory=list, validation_alias=AliasPath("data", "sequences"), description="Device Access Control List"
)

def set_default_action(self, default_action: AcceptDropActionType) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ class LoggingParcel(_ParcelBase):
populate_by_name=True,
)
disk: Disk = Field(default_factory=Disk, validation_alias=AliasPath("data", "disk"))
tls_profile: Optional[List[TlsProfile]] = Field(default=[], validation_alias=AliasPath("data", "tlsProfile"))
server: Optional[List[Server]] = Field(default=[], validation_alias=AliasPath("data", "server"))
ipv6_server: Optional[List[Server]] = Field(default=[], validation_alias=AliasPath("data", "ipv6Server"))
tls_profile: Optional[List[TlsProfile]] = Field(
default_factory=list, validation_alias=AliasPath("data", "tlsProfile")
)
server: Optional[List[Server]] = Field(default_factory=list, validation_alias=AliasPath("data", "server"))
ipv6_server: Optional[List[Server]] = Field(default_factory=list, validation_alias=AliasPath("data", "ipv6Server"))

def set_disk(self, enable: bool, disk_file_size: int = 10, disk_file_rotate: int = 10):
self.disk.disk_enable = as_global(enable)
Expand Down
Loading

0 comments on commit 5839737

Please sign in to comment.