From 2a5ce18be7deac23d6f0e502c04b7ddd5a3126be Mon Sep 17 00:00:00 2001 From: sbasan Date: Mon, 19 Feb 2024 17:58:50 +0100 Subject: [PATCH] bulk refactor --- catalystwan/models/common.py | 121 ++- catalystwan/models/configuration/common.py | 28 +- .../configuration/feature_profile/README.md | 8 +- .../configuration/feature_profile/common.py | 119 ++- .../sdwan/policy_object/__init__.py | 148 +-- .../sdwan/policy_object/policy/app_probe.py | 6 +- .../sdwan/policy_object/policy/color_list.py | 6 +- .../sdwan/policy_object/policy/policier.py | 6 +- .../policy/prefered_group_color.py | 16 +- .../sdwan/policy_object/policy/sla_class.py | 41 +- .../policy/standard_community.py | 6 +- .../sdwan/policy_object/policy/tloc_list.py | 10 +- .../sdwan/policy_object/security/zone.py | 6 +- .../feature_profile/sdwan/service/acl.py | 414 ++++---- .../feature_profile/sdwan/service/appqoe.py | 179 ++-- .../feature_profile/sdwan/service/bgp.py | 179 ++-- .../sdwan/service/dhcp_server.py | 38 +- .../feature_profile/sdwan/service/eigrp.py | 68 +- .../sdwan/service/lan/common.py | 145 +-- .../sdwan/service/lan/ethernet.py | 237 +++-- .../feature_profile/sdwan/service/lan/gre.py | 123 ++- .../sdwan/service/lan/ipsec.py | 103 +- .../feature_profile/sdwan/service/lan/svi.py | 102 +- .../feature_profile/sdwan/service/lan/vpn.py | 509 ++++++---- .../sdwan/service/multicast.py | 121 ++- .../sdwan/service/object_tracker.py | 56 +- .../feature_profile/sdwan/service/ospf.py | 142 +-- .../feature_profile/sdwan/service/ospfv3.py | 200 ++-- .../sdwan/service/route_policy.py | 155 +-- .../service/service_insertion_attachment.py | 191 ++-- .../sdwan/service/switchport.py | 104 +- .../feature_profile/sdwan/service/tracker.py | 69 +- .../sdwan/service/wireless_lan.py | 299 +++--- .../sdwan/transport/cellular_controller.py | 9 +- .../models/configuration/profile_type.py | 14 +- catalystwan/models/policy/__init__.py | 55 +- catalystwan/models/policy/centralized.py | 43 +- .../policy/definitions/access_control_list.py | 18 +- .../definitions/access_control_list_ipv6.py | 18 +- .../models/policy/definitions/control.py | 63 +- .../policy/definitions/device_access.py | 19 +- .../policy/definitions/device_access_ipv6.py | 19 +- .../models/policy/definitions/qos_map.py | 29 +- .../models/policy/definitions/rewrite.py | 4 +- .../policy/definitions/security_group.py | 9 +- .../models/policy/definitions/traffic_data.py | 61 +- .../policy/definitions/zone_based_firewall.py | 19 +- catalystwan/models/policy/lists.py | 26 +- catalystwan/models/policy/lists_entries.py | 46 +- .../models/policy/policy_definition.py | 289 +++--- catalystwan/models/policy/security.py | 21 +- .../models/profileparcel/traffic_policy.py | 938 ------------------ examples/parcel_configuration_guide.py | 51 +- examples/policies_configuration_guide.py | 62 +- examples/policy_forwarding_qos.py | 33 +- 55 files changed, 2775 insertions(+), 3026 deletions(-) delete mode 100644 catalystwan/models/profileparcel/traffic_policy.py diff --git a/catalystwan/models/common.py b/catalystwan/models/common.py index 04205578d..af4ca778a 100644 --- a/catalystwan/models/common.py +++ b/catalystwan/models/common.py @@ -1,5 +1,4 @@ -from enum import Enum -from typing import Dict, List, Set, Tuple +from typing import Dict, List, Literal, Set, Tuple def check_fields_exclusive(values: Dict, field_names: Set[str], at_least_one: bool = False) -> bool: @@ -47,53 +46,71 @@ def check_any_of_exclusive_field_sets(values: Dict, field_sets: List[Tuple[Set[s raise ValueError(f"One of {all_sets_field_names} must be assigned") -class InterfaceTypeEnum(str, Enum): - ETHERNET = "Ethernet" - FAST_ETHERNET = "FastEthernet" - FIVE_GIGABIT_ETHERNET = "FiveGigabitEthernet" - FORTY_GIGABIT_ETHERNET = "FortyGigabitEthernet" - GIGABIT_ETHERNET = "GigabitEthernet" - HUNDRED_GIG_ETHERNET = "HundredGigE" - LOOPBACK = "Loopback" - TEN_GIGABIT_ETHERNET = "TenGigabitEthernet" - TUNNEL = "Tunnel" - TWENTY_FIVEGIGABIT_ETHERNET = "TwentyFiveGigabitEthernet" - TWENTY_FIVE_GIG_ETHERNET = "TwentyFiveGigE" - TWO_GIGABIT_ETHERNET = "TwoGigabitEthernet" - VIRTUAL_PORT_GROUP = "VirtualPortGroup" - VLAN = "Vlan" - - -class TLOCColorEnum(str, Enum): - DEFAULT = "default" - MPLS = "mpls" - METRO_ETHERNET = "metro-ethernet" - BIZ_INTERNET = "biz-internet" - PUBLIC_INTERNET = "public-internet" - LTE = "lte" - THREEG = "3g" - RED = "red" - GREEN = "green" - BLUE = "blue" - GOLD = "gold" - SILVER = "silver" - BRONZE = "bronze" - CUSTOM1 = "custom1" - CUSTOM2 = "custom2" - CUSTOM3 = "custom3" - PRIVATE1 = "private1" - PRIVATE2 = "private2" - PRIVATE3 = "private3" - PRIVATE4 = "private4" - PRIVATE5 = "private5" - PRIVATE6 = "private6" - - -class WellKnownBGPCommunitiesEnum(str, Enum): - INTERNET = "internet" - LOCAL_AS = "local-AS" - NO_ADVERTISE = "no-advertise" - NO_EXPORT = "no-export" - - -UUID = str +InterfaceType = Literal[ + "Ethernet", + "FastEthernet", + "FiveGigabitEthernet", + "FortyGigabitEthernet", + "GigabitEthernet", + "HundredGigE", + "Loopback", + "TenGigabitEthernet", + "Tunnel", + "TwentyFiveGigabitEthernet", + "TwentyFiveGigE", + "TwoGigabitEthernet", + "VirtualPortGroup", + "Vlan", +] + +TLOCColor = Literal[ + "default", + "mpls", + "metro-ethernet", + "biz-internet", + "public-internet", + "lte", + "3g", + "red", + "green", + "blue", + "gold", + "silver", + "bronze", + "custom1", + "custom2", + "custom3", + "private1", + "private2", + "private3", + "private4", + "private5", + "private6", +] + + +WellKnownBGPCommunities = Literal[ + "internet", + "local-AS", + "no-advertise", + "no-export", +] + +ServiceChainNumber = Literal[ + "SC1", + "SC2", + "SC3", + "SC4", + "SC5", + "SC6", + "SC7", + "SC8", + "SC9", + "SC10", + "SC11", + "SC12", + "SC13", + "SC14", + "SC15", + "SC16", +] diff --git a/catalystwan/models/configuration/common.py b/catalystwan/models/configuration/common.py index 6d84180a2..3a2bac29e 100644 --- a/catalystwan/models/configuration/common.py +++ b/catalystwan/models/configuration/common.py @@ -1,20 +1,8 @@ -from enum import Enum - -from pydantic import BaseModel, Extra, Field - -from catalystwan.models.profileparcel.traffic_policy import GlobalOptionTypeDef, UuidDef - - -class Solution(str, Enum): - MOBILITY = "mobility" - SDWAN = "sdwan" - NFVIRTUAL = "nfvirtual" - SDROUTING = "sd-routing" - - -class RefId(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: UuidDef +from typing import Literal + +Solution = Literal[ + "mobility", + "sdwan", + "nfvirtual", + "sd-routing", +] diff --git a/catalystwan/models/configuration/feature_profile/README.md b/catalystwan/models/configuration/feature_profile/README.md index 912f3d428..bc0529d05 100644 --- a/catalystwan/models/configuration/feature_profile/README.md +++ b/catalystwan/models/configuration/feature_profile/README.md @@ -310,10 +310,10 @@ auto_sim: Union[Variable, Global[bool], Default[None]] ### 3. Literals vs Enums -Use `Enums` over the `Literals`. Justification: -- `Enum` provides IntelliSense. -- Both provides static typing safety. -- `Enum` can be treated as a `str`. +Use `Literal` over the `Enums`. Justification: +- Both provides static typing safety ant intellisense (type-hints). +- `(str, Enum)` can be problematic as `__str__` != `__format__` for Enum +- When instantiating pydantic Field defined as `Literal` no explicit import of specific `Enum` is needed ### 4. Naming Conventions diff --git a/catalystwan/models/configuration/feature_profile/common.py b/catalystwan/models/configuration/feature_profile/common.py index bcc302aea..11780efd3 100644 --- a/catalystwan/models/configuration/feature_profile/common.py +++ b/catalystwan/models/configuration/feature_profile/common.py @@ -1,5 +1,4 @@ from datetime import datetime -from enum import Enum from typing import Generic, List, Literal, Optional, TypeVar, Union from uuid import UUID @@ -14,15 +13,65 @@ IPV4Address = str IPv6Address = str - -class ProfileType(str, Enum): - TRANSPORT = "transport" - SYSTEM = "system" - CLI = "cli" - SERVICE = "service" - APPLICATION_PRIORITY = "application-priority" - POLICY_OBJECT = "policy-object" - EMBEDDED_SECURITY = "embedded-security" +ParcelType = Literal[ + "appqoe", + "lan/vpn", + "lan/vpn/interface/ethernet", + "lan/vpn/interface/gre", + "lan/vpn/interface/ipsec", + "lan/vpn/interface/svi", + "dhcp-server", + "tracker", + "trackergroup", + "routing/bgp", + "routing/eigrp", + "routing/multicast", + "routing/ospf", + "routing/ospfv3/ipv4", + "routing/ospfv3/ipv6", + "wirelesslan", + "switchport", + "app-probe", + "app-list", + "color", + "data-prefix", + "expanded-community", + "class", + "data-ipv6-prefix", + "ipv6-prefix", + "prefix", + "policer", + "preferred-color-group", + "sla-class", + "tloc", + "standard-community", + "security-localdomain", + "security-fqdn", + "security-ipssignature", + "security-urllist", + "security-urllist", + "security-port", + "security-protocolname", + "security-geolocation", + "security-zone", + "security-localapp", + "security-data-ip-prefix", +] + +ProfileType = Literal[ + "transport", + "system", + "cli", + "service", + "application-priority", + "policy-object", + "embedded-security", +] + +SchemaType = Literal[ + "post", + "put", +] class FeatureProfileInfo(BaseModel): @@ -78,51 +127,6 @@ class ParcelCreationResponse(BaseModel): id: UUID = Field(serialization_alias="parcelId", validation_alias="parcelId") -class ParcelType(str, Enum): - APPQOE = "appqoe" - LAN_VPN = "lan/vpn" - LAN_VPN_INTERFACE_ETHERNET = "lan/vpn/interface/ethernet" - LAN_VPN_INTERFACE_GRE = "lan/vpn/interface/gre" - LAN_VPN_INTERFACE_IPSEC = "lan/vpn/interface/ipsec" - LAN_VPN_INTERFACE_SVI = "lan/vpn/interface/svi" - DHCP_SERVER = "dhcp-server" - TRACKER = "tracker" - TRACKER_GROUP = "trackergroup" - ROUTING_BGP = "routing/bgp" - ROUTING_EIGRP = "routing/eigrp" - ROUTING_MULTICAST = "routing/multicast" - ROUTING_OSPF = "routing/ospf" - ROUTING_OSPFV3_IPV4 = "routing/ospfv3/ipv4" - ROUTING_OSPFV3_IPV6 = "routing/ospfv3/ipv6" - WIRELESSLAN = "wirelesslan" - SWITCHPORT = "switchport" - APP_PROBE = "app-probe" - APPLICATION_LIST = "app-list" - COLOR = "color" - DATA_PREFIX = "data-prefix" - EXPANDED_COMMUNITY = "expanded-community" - FOWARDING_CLASS = "class" - IPV6_DATA_PREFIX = "data-ipv6-prefix" - IPV6_PREFIX_LIST = "ipv6-prefix" - PREFIX_LIST = "prefix" - POLICIER = "policer" - PREFERRED_COLOR_GROUP = "preferred-color-group" - SLA_CLASS = "sla-class" - TLOC = "tloc" - STANDARD_COMMUNITY = "standard-community" - LOCAL_DOMAIN = "security-localdomain" - FQDN_DOMAIN = "security-fqdn" - IPS_SIGNATURE = "security-ipssignature" - URL_ALLOW = "security-urllist" - URL_BLOCK = "security-urllist" - SECURITY_PORT = "security-port" - PROTOCOL_LIST = "security-protocolname" - GEO_LOCATION_LIST = "security-geolocation" - SECURITY_ZONE_LIST = "security-zone" - SECURITY_APPLICATION_LIST = "security-localapp" - SECURITY_DATA_PREFIX = "security-data-ip-prefix" - - class Parcel(BaseModel, Generic[T]): parcel_id: str = Field(alias="parcelId") parcel_type: ParcelType = Field(alias="parcelType") @@ -157,11 +161,6 @@ class Prefix(BaseModel): mask: Union[Variable, Global[str]] -class SchemaType(str, Enum): - POST = "post" - PUT = "put" - - class SchemaTypeQuery(BaseModel): model_config = ConfigDict(populate_by_name=True) diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/__init__.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/__init__.py index a2a32939f..1ac7c2da8 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/__init__.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/__init__.py @@ -1,63 +1,36 @@ -from typing import Dict, Mapping, Union +from typing import List, Mapping, Union from pydantic import Field from typing_extensions import Annotated -from .policy.app_probe import AppProbeEntry as AppProbeEntry -from .policy.app_probe import AppProbeMapItem as AppProbeMapItem -from .policy.app_probe import AppProbeParcel as AppProbeParcel -from .policy.application_list import ApplicationFamilyListEntry as ApplicationFamilyListEntry -from .policy.application_list import ApplicationListEntry as ApplicationListEntry -from .policy.application_list import ApplicationListParcel -from .policy.color_list import ColorEntry as ColorEntry -from .policy.color_list import ColorParcel as ColorParcel -from .policy.data_prefix import DataPrefixEntry as DataPrefixEntry -from .policy.data_prefix import DataPrefixParcel as DataPrefixParcel -from .policy.expanded_community_list import ExpandedCommunityParcel as ExpandedCommunityParcel -from .policy.fowarding_class import FowardingClassParcel as FowardingClassParcel -from .policy.fowarding_class import FowardingClassQueueEntry as FowardingClassQueueEntry -from .policy.ipv6_data_prefix import IPv6DataPrefixEntry as IPv6DataPrefixEntry -from .policy.ipv6_data_prefix import IPv6DataPrefixParcel as IPv6DataPrefixParcel -from .policy.ipv6_prefix_list import IPv6PrefixListEntry as IPv6PrefixListEntry -from .policy.ipv6_prefix_list import IPv6PrefixListParcel as IPv6PrefixListParcel -from .policy.policier import PolicierEntry as PolicierEntry -from .policy.policier import PolicierParcel as PolicierParcel -from .policy.prefered_group_color import Preference as Preference -from .policy.prefered_group_color import PreferredColorGroupEntry as PreferredColorGroupEntry -from .policy.prefered_group_color import PreferredColorGroupParcel as PreferredColorGroupParcel -from .policy.prefix_list import PrefixListEntry as PrefixListEntry -from .policy.prefix_list import PrefixListParcel as PrefixListParcel -from .policy.sla_class import FallbackBestTunnel as FallbackBestTunnel -from .policy.sla_class import SLAAppProbeClass as SLAAppProbeClass -from .policy.sla_class import SLAClassCriteriaEnum as SLAClassCriteriaEnum -from .policy.sla_class import SLAClassListEntry as SLAClassListEntry -from .policy.sla_class import SLAClassParcel as SLAClassParcel -from .policy.standard_community import StandardCommunityEntry as StandardCommunityEntry -from .policy.standard_community import StandardCommunityParcel as StandardCommunityParcel -from .policy.tloc_list import TlocEntry as TlocEntry -from .policy.tloc_list import TlocParcel as TlocParcel -from .security.application_list import SecurityApplicationFamilyListEntry as SecurityApplicationFamilyListEntry -from .security.application_list import SecurityApplicationListEntry as SecurityApplicationListEntry -from .security.application_list import SecurityApplicationListParcel as SecurityApplicationListParcel -from .security.data_prefix import SecurityDataPrefixEntry as SecurityDataPrefixEntry -from .security.data_prefix import SecurityDataPrefixParcel as SecurityDataPrefixParcel -from .security.fqdn import FQDNDomainParcel as FQDNDomainParcel -from .security.fqdn import FQDNListEntry as FQDNListEntry -from .security.geolocation_list import GeoLocationListEntry as GeoLocationListEntry -from .security.geolocation_list import GeoLocationListParcel as GeoLocationListParcel -from .security.ips_signature import IPSSignatureListEntry as IPSSignatureListEntry -from .security.ips_signature import IPSSignatureParcel as IPSSignatureParcel -from .security.local_domain import LocalDomainListEntry as LocalDomainListEntry -from .security.local_domain import LocalDomainParcel as LocalDomainParcel -from .security.protocol_list import ProtocolListEntry as ProtocolListEntry -from .security.protocol_list import ProtocolListParcel as ProtocolListParcel -from .security.security_port import SecurityPortListEntry as SecurityPortListEntry -from .security.security_port import SecurityPortParcel as SecurityPortParcel -from .security.url import BaseURLListEntry as BaseURLListEntry -from .security.url import URLAllowParcel as URLAllowParcel -from .security.url import URLBlockParcel as URLBlockParcel -from .security.zone import SecurityZoneListEntry as SecurityZoneListEntry -from .security.zone import SecurityZoneListParcel as SecurityZoneListParcel +from .policy.app_probe import AppProbeMapItem, AppProbeParcel +from .policy.application_list import ApplicationFamilyListEntry, ApplicationListEntry, ApplicationListParcel +from .policy.color_list import ColorEntry, ColorParcel +from .policy.data_prefix import DataPrefixEntry, DataPrefixParcel +from .policy.expanded_community_list import ExpandedCommunityParcel +from .policy.fowarding_class import FowardingClassParcel, FowardingClassQueueEntry +from .policy.ipv6_data_prefix import IPv6DataPrefixEntry, IPv6DataPrefixParcel +from .policy.ipv6_prefix_list import IPv6PrefixListEntry, IPv6PrefixListParcel +from .policy.policier import PolicierEntry, PolicierParcel +from .policy.prefered_group_color import Preference, PreferredColorGroupEntry, PreferredColorGroupParcel +from .policy.prefix_list import PrefixListEntry, PrefixListParcel +from .policy.sla_class import FallbackBestTunnel, SLAAppProbeClass, SLAClassCriteria, SLAClassListEntry, SLAClassParcel +from .policy.standard_community import StandardCommunityEntry, StandardCommunityParcel +from .policy.tloc_list import TlocEntry, TlocParcel +from .security.application_list import ( + SecurityApplicationFamilyListEntry, + SecurityApplicationListEntry, + SecurityApplicationListParcel, +) +from .security.data_prefix import SecurityDataPrefixEntry, SecurityDataPrefixParcel +from .security.fqdn import FQDNDomainParcel, FQDNListEntry +from .security.geolocation_list import GeoLocationListEntry, GeoLocationListParcel +from .security.ips_signature import IPSSignatureListEntry, IPSSignatureParcel +from .security.local_domain import LocalDomainListEntry, LocalDomainParcel +from .security.protocol_list import ProtocolListEntry, ProtocolListParcel +from .security.security_port import SecurityPortListEntry, SecurityPortParcel +from .security.url import BaseURLListEntry, URLAllowParcel, URLBlockParcel +from .security.zone import SecurityZoneListEntry, SecurityZoneListParcel AnyPolicyObjectParcel = Annotated[ Union[ @@ -117,3 +90,66 @@ SecurityApplicationListParcel: "security-localapp", SecurityDataPrefixParcel: "security-data-ip-prefix", } + +__all__ = ( + "AnyPolicyObjectParcel", + "ApplicationFamilyListEntry", + "ApplicationListEntry", + "ApplicationListParcel", + "AppProbeEntry", + "AppProbeMapItem", + "AppProbeParcel", + "BaseURLListEntry", + "ColorEntry", + "ColorParcel", + "DataPrefixEntry", + "DataPrefixParcel", + "ExpandedCommunityParcel", + "FallbackBestTunnel", + "FowardingClassParcel", + "FowardingClassQueueEntry", + "FQDNDomainParcel", + "FQDNListEntry", + "GeoLocationListEntry", + "GeoLocationListParcel", + "IPSSignatureListEntry", + "IPSSignatureParcel", + "IPv6DataPrefixEntry", + "IPv6DataPrefixParcel", + "IPv6PrefixListEntry", + "IPv6PrefixListParcel", + "LocalDomainListEntry", + "LocalDomainParcel", + "PolicierEntry", + "PolicierParcel", + "Preference", + "PreferredColorGroupEntry", + "PreferredColorGroupParcel", + "PrefixListEntry", + "PrefixListParcel", + "ProtocolListEntry", + "ProtocolListParcel", + "SecurityApplicationFamilyListEntry", + "SecurityApplicationListEntry", + "SecurityApplicationListParcel", + "SecurityDataPrefixEntry", + "SecurityDataPrefixParcel", + "SecurityPortListEntry", + "SecurityPortParcel", + "SecurityZoneListEntry", + "SecurityZoneListParcel", + "SLAAppProbeClass", + "SLAClassCriteria", + "SLAClassListEntry", + "SLAClassParcel", + "StandardCommunityEntry", + "StandardCommunityParcel", + "TlocEntry", + "TlocParcel", + "URLAllowParcel", + "URLBlockParcel", +) + + +def __dir__() -> "List[str]": + return list(__all__) diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/app_probe.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/app_probe.py index 46e723788..7a9c2c5a7 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/app_probe.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/app_probe.py @@ -3,11 +3,11 @@ from pydantic import AliasPath, BaseModel, ConfigDict, Field, field_validator from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase, as_global -from catalystwan.models.common import TLOCColorEnum +from catalystwan.models.common import TLOCColor class AppProbeMapItem(BaseModel): - color: Global[TLOCColorEnum] + color: Global[TLOCColor] dscp: Global[int] @field_validator("dscp") @@ -35,6 +35,6 @@ def add_fowarding_class(self, forwarding_class_name: str): ) ) - def add_map(self, color: TLOCColorEnum, dscp: int): + def add_map(self, color: TLOCColor, dscp: int): entry = self.entries[0] entry.map.append(AppProbeMapItem(color=as_global(color), dscp=as_global(dscp))) diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/color_list.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/color_list.py index bb7541af9..605019046 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/color_list.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/color_list.py @@ -3,15 +3,15 @@ from pydantic import AliasPath, BaseModel, Field from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase, as_global -from catalystwan.models.common import TLOCColorEnum +from catalystwan.models.common import TLOCColor class ColorEntry(BaseModel): - color: Global[TLOCColorEnum] + color: Global[TLOCColor] class ColorParcel(_ParcelBase): entries: List[ColorEntry] = Field(default=[], validation_alias=AliasPath("data", "entries")) - def add_color(self, color: TLOCColorEnum): + def add_color(self, color: TLOCColor): self.entries.append(ColorEntry(color=as_global(color))) diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/policier.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/policier.py index d38e26459..894af438f 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/policier.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/policier.py @@ -3,13 +3,13 @@ from pydantic import AliasPath, BaseModel, ConfigDict, Field, field_validator from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase, as_global -from catalystwan.models.policy.lists_entries import PolicerExceedActionEnum +from catalystwan.models.policy.lists_entries import PolicerExceedAction class PolicierEntry(BaseModel): model_config = ConfigDict(populate_by_name=True) burst: Global[int] - exceed: Global[PolicerExceedActionEnum] + exceed: Global[PolicerExceedAction] rate: Global[int] @field_validator("burst") @@ -28,7 +28,7 @@ def check_rate(cls, rate_str: Global): class PolicierParcel(_ParcelBase): entries: List[PolicierEntry] = Field(default=[], validation_alias=AliasPath("data", "entries")) - def add_entry(self, burst: int, exceed: PolicerExceedActionEnum, rate: int): + def add_entry(self, burst: int, exceed: PolicerExceedAction, rate: int): self.entries.append( PolicierEntry( burst=as_global(burst), diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/prefered_group_color.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/prefered_group_color.py index c05769f22..b0680fc8d 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/prefered_group_color.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/prefered_group_color.py @@ -3,16 +3,14 @@ from pydantic import AliasPath, BaseModel, ConfigDict, Field, model_validator from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase, as_global -from catalystwan.models.common import TLOCColorEnum -from catalystwan.models.policy.lists_entries import PathPreferenceEnum +from catalystwan.models.common import TLOCColor +from catalystwan.models.policy.lists_entries import PathPreference class Preference(BaseModel): model_config = ConfigDict(populate_by_name=True) - color_preference: Global[list] = Field( # [TLOCColorEnum] - serialization_alias="colorPreference", validation_alias="colorPreference" - ) - path_preference: Global[PathPreferenceEnum] = Field( + color_preference: Global[list] = Field(serialization_alias="colorPreference", validation_alias="colorPreference") + path_preference: Global[PathPreference] = Field( serialization_alias="pathPreference", validation_alias="pathPreference" ) @@ -39,7 +37,7 @@ def check_passwords_match(self) -> "PreferredColorGroupEntry": class PreferredColorGroupParcel(_ParcelBase): entries: List[PreferredColorGroupEntry] = Field(default=[], validation_alias=AliasPath("data", "entries")) - def add_primary(self, color_preference: List[TLOCColorEnum], path_preference: PathPreferenceEnum): + def add_primary(self, color_preference: List[TLOCColor], path_preference: PathPreference): self.entries.append( PreferredColorGroupEntry( primary_preference=Preference( @@ -50,13 +48,13 @@ def add_primary(self, color_preference: List[TLOCColorEnum], path_preference: Pa ) ) - def add_secondary(self, color_preference: List[TLOCColorEnum], path_preference: PathPreferenceEnum): + def add_secondary(self, color_preference: List[TLOCColor], path_preference: PathPreference): preferred_color = self.entries[0] preferred_color.secondary_preference = Preference( color_preference=as_global(color_preference), path_preference=as_global(path_preference) ) - def add_tertiary(self, color_preference: List[TLOCColorEnum], path_preference: PathPreferenceEnum): + def add_tertiary(self, color_preference: List[TLOCColor], path_preference: PathPreference): preferred_color = self.entries[0] preferred_color.tertiary_preference = Preference( color_preference=as_global(color_preference), path_preference=as_global(path_preference) diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/sla_class.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/sla_class.py index 2e8af6bfe..7c9242c0c 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/sla_class.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/sla_class.py @@ -1,28 +1,27 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union from uuid import UUID from pydantic import AliasPath, BaseModel, ConfigDict, Field, field_validator from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase, as_global - -class SLAClassCriteriaEnum(str, Enum): - LOSS = "loss" - LATENCY = "latency" - JITTER = "jitter" - LOSS_LATENCY = "loss-latency" - LOSS_JITTER = "loss-jitter" - LATENCY_LOSS = "latency-loss" - LATENCY_JITTER = "latency-jitter" - JITTER_LATENCY = "jitter-latency" - JITTER_LOSS = "jitter-loss" - LOSS_LATENCY_JITTER = "loss-latency-jitter" - LOSS_JITTER_LATENCY = "loss-jitter-latency" - LATENCY_LOSS_JITTER = "latency-loss-jitter" - LATENCY_JITTER_LOSS = "latency-jitter-loss" - JITTER_LATENCY_LOSS = "jitter-latency-loss" - JITTER_LOSS_LATENCY = "jitter-loss-latency" +SLAClassCriteria = Literal[ + "loss", + "latency", + "jitter", + "loss-latency", + "loss-jitter", + "latency-loss", + "latency-jitter", + "jitter-latency", + "jitter-loss", + "loss-latency-jitter", + "loss-jitter-latency", + "latency-loss-jitter", + "latency-jitter-loss", + "jitter-latency-loss", + "jitter-loss-latency", +] class SLAAppProbeClass(BaseModel): @@ -34,7 +33,7 @@ class SLAAppProbeClass(BaseModel): class FallbackBestTunnel(BaseModel): model_config = ConfigDict(populate_by_name=True) - criteria: Global[SLAClassCriteriaEnum] + criteria: Global[SLAClassCriteria] jitter_variance: Optional[Global[int]] = Field( default=None, serialization_alias="jitterVariance", @@ -137,7 +136,7 @@ def add_entry(self, app_probe_class_id: UUID, loss: Optional[int], jitter: Optio def add_fallback( self, - criteria: SLAClassCriteriaEnum, + criteria: SLAClassCriteria, jitter_variance: Optional[int], latency_variance: Optional[int], loss_variance: Optional[int], diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/standard_community.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/standard_community.py index ce87f6de3..af728be38 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/standard_community.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/standard_community.py @@ -3,12 +3,12 @@ from pydantic import AliasPath, BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase, as_global -from catalystwan.models.common import WellKnownBGPCommunitiesEnum +from catalystwan.models.common import WellKnownBGPCommunities class StandardCommunityEntry(BaseModel): model_config = ConfigDict(populate_by_name=True) - standard_community: Global[WellKnownBGPCommunitiesEnum] = Field( + standard_community: Global[WellKnownBGPCommunities] = Field( serialization_alias="standardCommunity", validation_alias="standardCommunity" ) @@ -16,5 +16,5 @@ class StandardCommunityEntry(BaseModel): class StandardCommunityParcel(_ParcelBase): entries: List[StandardCommunityEntry] = Field(default=[], validation_alias=AliasPath("data", "entries")) - def add_community(self, standard_community: WellKnownBGPCommunitiesEnum): + def add_community(self, standard_community: WellKnownBGPCommunities): self.entries.append(StandardCommunityEntry(standard_community=as_global(standard_community))) diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/tloc_list.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/tloc_list.py index 935445e77..f007958ae 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/tloc_list.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/policy/tloc_list.py @@ -4,15 +4,15 @@ from pydantic import AliasPath, BaseModel, ConfigDict, Field, field_validator from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase, as_global -from catalystwan.models.common import TLOCColorEnum -from catalystwan.models.policy.lists_entries import EncapEnum +from catalystwan.models.common import TLOCColor +from catalystwan.models.policy.lists_entries import EncapType class TlocEntry(BaseModel): model_config = ConfigDict(populate_by_name=True) tloc: Global[IPv4Address] - color: Global[TLOCColorEnum] - encapsulation: Global[EncapEnum] = Field(serialization_alias="encap", validation_alias="encap") + color: Global[TLOCColor] + encapsulation: Global[EncapType] = Field(serialization_alias="encap", validation_alias="encap") preference: Optional[Global[str]] = None @field_validator("preference") @@ -29,7 +29,7 @@ class TlocParcel(_ParcelBase): entries: List[TlocEntry] = Field(default=[], validation_alias=AliasPath("data", "entries")) def add_entry( - self, tloc: IPv4Address, color: TLOCColorEnum, encapsulation: EncapEnum, preference: Optional[str] = None + self, tloc: IPv4Address, color: TLOCColor, encapsulation: EncapType, preference: Optional[str] = None ): self.entries.append( TlocEntry( diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/zone.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/zone.py index e9955119d..9a7bfb6c1 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/zone.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/zone.py @@ -3,12 +3,12 @@ from pydantic import AliasPath, BaseModel, Field, field_validator, model_validator from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase, as_global -from catalystwan.models.common import InterfaceTypeEnum, check_fields_exclusive +from catalystwan.models.common import InterfaceType, check_fields_exclusive class SecurityZoneListEntry(BaseModel): vpn: Optional[Global[str]] = Field(default=None, description="0-65530 single number") - interface: Optional[Global[InterfaceTypeEnum]] = None + interface: Optional[Global[InterfaceType]] = None @field_validator("vpn") @classmethod @@ -25,7 +25,7 @@ def check_vpn_xor_interface(self): class SecurityZoneListParcel(_ParcelBase): entries: List[SecurityZoneListEntry] = Field(default=[], validation_alias=AliasPath("data", "entries")) - def add_interface(self, interface: InterfaceTypeEnum): + def add_interface(self, interface: InterfaceType): self.entries.append( SecurityZoneListEntry( interface=as_global(interface), diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/acl.py b/catalystwan/models/configuration/feature_profile/sdwan/service/acl.py index a0e403b74..e602ba77b 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/acl.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/acl.py @@ -1,241 +1,257 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId - - -class Action(str, Enum): - DROP = "drop" - ACCEPT = "accept" - - -class IcmpMessage(str, Enum): - ADMINISTRATIVELY_PROHIBITED = "administratively-prohibited" - DOD_HOST_PROHIBITED = "dod-host-prohibited" - DOD_NET_PROHIBITED = "dod-net-prohibited" - ECHO = "echo" - ECHO_REPLY = "echo-reply" - ECHO_REPLY_NO_ERROR = "echo-reply-no-error" - EXTENDED_ECHO = "extended-echo" - EXTENDED_ECHO_REPLY = "extended-echo-reply" - GENERAL_PARAMETER_PROBLEM = "general-parameter-problem" - HOST_ISOLATED = "host-isolated" - HOST_PRECEDENCE_UNREACHABLE = "host-precedence-unreachable" - HOST_REDIRECT = "host-redirect" - HOST_TOS_REDIRECT = "host-tos-redirect" - HOST_TOS_UNREACHABLE = "host-tos-unreachable" - HOST_UNKNOWN = "host-unknown" - HOST_UNREACHABLE = "host-unreachable" - INTERFACE_ERROR = "interface-error" - MALFORMED_QUERY = "malformed-query" - MULTIPLE_INTERFACE_MATCH = "multiple-interface-match" - NET_REDIRECT = "net-redirect" - NET_TOS_REDIRECT = "net-tos-redirect" - NET_TOS_UNREACHABLE = "net-tos-unreachable" - NET_UNREACHABLE = "net-unreachable" - NETWORK_UNKNOWN = "network-unknown" - NO_ROOM_FOR_OPTION = "no-room-for-option" - OPTION_MISSING = "option-missing" - PACKET_TOO_BIG = "packet-too-big" - PARAMETER_PROBLEM = "parameter-problem" - PHOTURIS = "photuris" - PORT_UNREACHABLE = "port-unreachable" - PRECEDENCE_UNREACHABLE = "precedence-unreachable" - PROTOCOL_UNREACHABLE = "protocol-unreachable" - REASSEMBLY_TIMEOUT = "reassembly-timeout" - REDIRECT = "redirect" - ROUTER_ADVERTISEMENT = "router-advertisement" - ROUTER_SOLICITATION = "router-solicitation" - SOURCE_ROUTE_FAILED = "source-route-failed" - TABLE_ENTRY_ERROR = "table-entry-error" - TIME_EXCEEDED = "time-exceeded" - TIMESTAMP_REPLY = "timestamp-reply" - TIMESTAMP_REQUEST = "timestamp-request" - TTL_EXCEEDED = "ttl-exceeded" - UNREACHABLE = "unreachable" - - -class Icmp6Message(str, Enum): - BEYOND_SCOPE = "beyond-scope" - CP_ADVERTISEMENT = "cp-advertisement" - CP_SOLICITATION = "cp-solicitation" - DESTINATION_UNREACHABLE = "destination-unreachable" - DHAAD_REPLY = "dhaad-reply" - DHAAD_REQUEST = "dhaad-request" - ECHO_REPLY = "echo-reply" - ECHO_REQUEST = "echo-request" - HEADER = "header" - HOP_LIMIT = "hop-limit" - IND_ADVERTISEMENT = "ind-advertisement" - IND_SOLICITATION = "ind-solicitation" - MLD_QUERY = "mld-query" - MLD_REDUCTION = "mld-reduction" - MLD_REPORT = "mld-report" - MLDV2_REPORT = "mldv2-report" - MPD_ADVERTISEMENT = "mpd-advertisement" - MPD_SOLICITATION = "mpd-solicitation" - MR_ADVERTISEMENT = "mr-advertisement" - MR_SOLICITATION = "mr-solicitation" - MR_TERMINATION = "mr-termination" - ND_NA = "nd-na" - ND_NS = "nd-ns" - NEXT_HEADER_TYPE = "next-header-type" - NI_QUERY = "ni-query" - NI_QUERY_NAME = "ni-query-name" - NI_QUERY_V4_ADDRESS = "ni-query-v4-address" - NI_QUERY_V6_ADDRESS = "ni-query-v6-address" - NI_RESPONSE = "ni-response" - NI_RESPONSE_QTYPE_UNKNOWN = "ni-response-qtype-unknown" - NI_RESPONSE_REFUSE = "ni-response-refuse" - NI_RESPONSE_SUCCESS = "ni-response-success" - NO_ADMIN = "no-admin" - NO_ROUTE = "no-route" - PACKET_TOO_BIG = "packet-too-big" - PARAMETER_OPTION = "parameter-option" - PARAMETER_PROBLEM = "parameter-problem" - PORT_UNREACHABLE = "port-unreachable" - REASSEMBLY_TIMEOUT = "reassembly-timeout" - REDIRECT = "redirect" - REJECT_ROUTE = "reject-route" - RENUM_COMMAND = "renum-command" - RENUM_RESULT = "renum-result" - RENUM_SEQ_NUMBER = "renum-seq-number" - ROUTER_ADVERTISEMENT = "router-advertisement" - ROUTER_RENUMBERING = "router-renumbering" - ROUTER_SOLICITATION = "router-solicitation" - RPL_CONTROL = "rpl-control" - SOURCE_POLICY = "source-policy" - SOURCE_ROUTE_HEADER = "source-route-header" - TIME_EXCEEDED = "time-exceeded" - UNREACHABLE = "unreachable" +from catalystwan.models.common import ServiceChainNumber + +Action = Literal[ + "drop", + "accept", +] + +IcmpMessage = Literal[ + "administratively-prohibited", + "dod-host-prohibited", + "dod-net-prohibited", + "echo", + "echo-reply", + "echo-reply-no-error", + "extended-echo", + "extended-echo-reply", + "general-parameter-problem", + "host-isolated", + "host-precedence-unreachable", + "host-redirect", + "host-tos-redirect", + "host-tos-unreachable", + "host-unknown", + "host-unreachable", + "interface-error", + "malformed-query", + "multiple-interface-match", + "net-redirect", + "net-tos-redirect", + "net-tos-unreachable", + "net-unreachable", + "network-unknown", + "no-room-for-option", + "option-missing", + "packet-too-big", + "parameter-problem", + "photuris", + "port-unreachable", + "precedence-unreachable", + "protocol-unreachable", + "reassembly-timeout", + "redirect", + "router-advertisement", + "router-solicitation", + "source-route-failed", + "table-entry-error", + "time-exceeded", + "timestamp-reply", + "timestamp-request", + "ttl-exceeded", + "unreachable", +] + +Icmp6Message = Literal[ + "beyond-scope", + "cp-advertisement", + "cp-solicitation", + "destination-unreachable", + "dhaad-reply", + "dhaad-request", + "echo-reply", + "echo-request", + "header", + "hop-limit", + "ind-advertisement", + "ind-solicitation", + "mld-query", + "mld-reduction", + "mld-report", + "mldv2-report", + "mpd-advertisement", + "mpd-solicitation", + "mr-advertisement", + "mr-solicitation", + "mr-termination", + "nd-na", + "nd-ns", + "next-header-type", + "ni-query", + "ni-query-name", + "ni-query-v4-address", + "ni-query-v6-address", + "ni-response", + "ni-response-qtype-unknown", + "ni-response-refuse", + "ni-response-success", + "no-admin", + "no-route", + "packet-too-big", + "parameter-option", + "parameter-problem", + "port-unreachable", + "reassembly-timeout", + "redirect", + "reject-route", + "renum-command", + "renum-result", + "renum-seq-number", + "router-advertisement", + "router-renumbering", + "router-solicitation", + "rpl-control", + "source-policy", + "source-route-header", + "time-exceeded", + "unreachable", +] class SourceDataIPv4Prefix(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_ip_prefix: Union[Global[str], Variable] = Field(alias="sourceIpPrefix") + source_ip_prefix: Union[Global[str], Variable] = Field( + serialization_alias="sourceIpPrefix", validation_alias="sourceIpPrefix" + ) class SourceDataIPv6Prefix(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_ip_prefix: Union[Global[str], Variable] = Field(alias="sourceIpPrefix") + source_ip_prefix: Union[Global[str], Variable] = Field( + serialization_alias="sourceIpPrefix", validation_alias="sourceIpPrefix" + ) class SourceDataIPv4PrefixParcel(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_data_prefix_list: RefId = Field(alias="sourceDataPrefixList") + source_data_prefix_list: Global[UUID] = Field( + serialization_alias="sourceDataPrefixList", validation_alias="sourceDataPrefixList" + ) class SourceDataIPv6PrefixParcel(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_data_prefix_list: RefId = Field(alias="sourceDataPrefixList") + source_data_prefix_list: Global[UUID] = Field( + serialization_alias="sourceDataPrefixList", validation_alias="sourceDataPrefixList" + ) class SourcePort(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_port: Global[int] = Field(alias="sourcePort") + source_port: Global[int] = Field(serialization_alias="sourcePort", validation_alias="sourcePort") class DestinationDataIPv4Prefix(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - destination_ip_prefix: Union[Global[str], Variable] = Field(alias="destinationIpPrefix") + destination_ip_prefix: Union[Global[str], Variable] = Field( + serialization_alias="destinationIpPrefix", validation_alias="destinationIpPrefix" + ) class DestinationDataIPv6Prefix(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - destination_ip_prefix: Union[Global[str], Variable] = Field(alias="destinationIpPrefix") + destination_ip_prefix: Union[Global[str], Variable] = Field( + serialization_alias="destinationIpPrefix", validation_alias="destinationIpPrefix" + ) class DestinationDataIPv4PrefixParcel(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - destination_data_prefix_list: RefId = Field(alias="destinationDataPrefixList") + destination_data_prefix_list: Global[UUID] = Field( + serialization_alias="destinationDataPrefixList", validation_alias="destinationDataPrefixList" + ) class DestinationDataIPv6PrefixParcel(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - destination_data_prefix_list: RefId = Field(alias="destinationDataPrefixList") + destination_data_prefix_list: Global[UUID] = Field( + serialization_alias="destinationDataPrefixList", validation_alias="destinationDataPrefixList" + ) class DestinationPort(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - destination_port: Global[int] = Field(alias="destinationPort") + destination_port: Global[int] = Field(serialization_alias="destinationPort", validation_alias="destinationPort") -class TcpState(str, Enum): - SYN = "syn" +TcpState = Literal["syn"] class IPv4Match(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) dscp: Optional[Global[List[int]]] = None - packet_length: Optional[Global[int]] = Field(alias="packetLength", default=None) + packet_length: Optional[Global[int]] = Field( + serialization_alias="packetLength", validation_alias="packetLength", default=None + ) protocol: Optional[Global[List[int]]] = None - icmp_message: Optional[Global[List[IcmpMessage]]] = Field(alias="icmpMsg", default=None) + icmp_message: Optional[Global[List[IcmpMessage]]] = Field( + serialization_alias="icmpMsg", validation_alias="icmpMsg", default=None + ) source_data_prefix: Optional[Union[SourceDataIPv4Prefix, SourceDataIPv4PrefixParcel]] = Field( - alias="sourceDataPrefix", default=None + serialization_alias="sourceDataPrefix", validation_alias="sourceDataPrefix", default=None + ) + source_ports: Optional[List[SourcePort]] = Field( + serialization_alias="sourcePorts", validation_alias="sourcePorts", default=None ) - source_ports: Optional[List[SourcePort]] = Field(alias="sourcePorts", default=None) destination_data_prefix: Optional[Union[DestinationDataIPv4Prefix, DestinationDataIPv4PrefixParcel]] = Field( - alias="destinationDataPrefix", default=None + serialization_alias="destinationDataPrefix", validation_alias="destinationDataPrefix", default=None + ) + destination_ports: Optional[List[DestinationPort]] = Field( + serialization_alias="destinationPorts", validation_alias="destinationPorts", default=None ) - destination_ports: Optional[List[DestinationPort]] = Field(alias="destinationPorts", default=None) tcp: Optional[Global[TcpState]] = None class IPv6Match(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - next_header: Optional[Global[int]] = Field(alias="nextHeader", default=None) - packet_length: Optional[Global[int]] = Field(alias="packetLength", default=None) + next_header: Optional[Global[int]] = Field( + serialization_alias="nextHeader", validation_alias="nextHeader", default=None + ) + packet_length: Optional[Global[int]] = Field( + serialization_alias="packetLength", validation_alias="packetLength", default=None + ) source_data_prefix: Optional[Union[SourceDataIPv6Prefix, SourceDataIPv6PrefixParcel]] = Field( - alias="sourceDataPrefix", default=None + serialization_alias="sourceDataPrefix", validation_alias="sourceDataPrefix", default=None + ) + source_ports: Optional[List[SourcePort]] = Field( + serialization_alias="sourcePorts", validation_alias="sourcePorts", default=None ) - source_ports: Optional[List[SourcePort]] = Field(alias="sourcePorts", default=None) destination_data_prefix: Optional[Union[DestinationDataIPv6Prefix, DestinationDataIPv6PrefixParcel]] = Field( - alias="destinationDataPrefix", default=None + serialization_alias="destinationDataPrefix", validation_alias="destinationDataPrefix", default=None + ) + destination_ports: Optional[List[DestinationPort]] = Field( + serialization_alias="destinationPorts", validation_alias="destinationPorts", default=None ) - destination_ports: Optional[List[DestinationPort]] = Field(alias="destinationPorts", default=None) tcp: Optional[Global[TcpState]] = None traffic_class: Optional[Global[int]] = None - icmp6_message: Optional[Global[List[Icmp6Message]]] = Field(alias="icmpMsg", default=None) - - -class ServiceChainNumber(str, Enum): - SC1 = "SC1" - SC2 = "SC2" - SC3 = "SC3" - SC4 = "SC4" - SC5 = "SC5" - SC6 = "SC6" - SC7 = "SC7" - SC8 = "SC8" - SC9 = "SC9" - SC10 = "SC10" - SC11 = "SC11" - SC12 = "SC12" - SC13 = "SC13" - SC14 = "SC14" - SC15 = "SC15" - SC16 = "SC16" + icmp6_message: Optional[Global[List[Icmp6Message]]] = Field( + serialization_alias="icmpMsg", validation_alias="icmpMsg", default=None + ) class ServiceChain(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - service_chain_number: Union[Global[ServiceChainNumber], Variable] = Field(alias="serviceChainNumber") + service_chain_number: Union[Global[ServiceChainNumber], Variable] = Field( + serialization_alias="serviceChainNumber", validation_alias="serviceChainNumber" + ) vpn: Optional[Union[Global[int], Variable]] = None fallback: Optional[Union[Global[bool], Variable, Default[bool]]] = None @@ -243,31 +259,47 @@ class ServiceChain(BaseModel): class AcceptActionIPv4(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - set_dscp: Optional[Global[int]] = Field(alias="setDscp", default=None) - counter_name: Optional[Global[str]] = Field(alias="counterName", default=None) + set_dscp: Optional[Global[int]] = Field(serialization_alias="setDscp", validation_alias="setDscp", default=None) + counter_name: Optional[Global[str]] = Field( + serialization_alias="counterName", validation_alias="counterName", default=None + ) log: Optional[Union[Global[bool], Default[bool]]] = None - set_next_hop: Optional[Global[str]] = Field(alias="setNextHop", default=None) - set_service_chain: Optional[ServiceChain] = Field(alias="setServiceChain", default=None) - mirror: Optional[RefId] = None - policer: Optional[RefId] = None + set_next_hop: Optional[Global[str]] = Field( + serialization_alias="setNextHop", validation_alias="setNextHop", default=None + ) + set_service_chain: Optional[ServiceChain] = Field( + serialization_alias="setServiceChain", validation_alias="setServiceChain", default=None + ) + mirror: Optional[Global[UUID]] = None + policer: Optional[Global[UUID]] = None class AcceptActionIPv6(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - counter_name: Optional[Global[str]] = Field(alias="counterName", default=None) + counter_name: Optional[Global[str]] = Field( + serialization_alias="counterName", validation_alias="counterName", default=None + ) log: Optional[Union[Global[bool], Default[bool]]] = None - set_next_hop: Optional[Global[str]] = Field(alias="setNextHop", default=None) - set_service_chain: Optional[ServiceChain] = Field(alias="setServiceChain", default=None) - set_traffic_class: Optional[Global[int]] = Field(alias="setTrafficClass", default=None) - mirror: Optional[RefId] = None - policer: Optional[RefId] = None + set_next_hop: Optional[Global[str]] = Field( + serialization_alias="setNextHop", validation_alias="setNextHop", default=None + ) + set_service_chain: Optional[ServiceChain] = Field( + serialization_alias="setServiceChain", validation_alias="setServiceChain", default=None + ) + set_traffic_class: Optional[Global[int]] = Field( + serialization_alias="setTrafficClass", validation_alias="setTrafficClass", default=None + ) + mirror: Optional[Global[UUID]] = None + policer: Optional[Global[UUID]] = None class DropAction(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - counter_name: Optional[Global[str]] = Field(alias="counterName", default=None) + counter_name: Optional[Global[str]] = Field( + serialization_alias="counterName", validation_alias="counterName", default=None + ) log: Optional[Union[Global[bool], Default[bool]]] = None @@ -292,48 +324,60 @@ class DropActions(BaseModel): class IPv4SequenceBaseAction(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - sequence_id: Global[int] = Field(alias="sequenceId") - sequence_name: Global[str] = Field(alias="sequenceName") + sequence_id: Global[int] = Field(serialization_alias="sequenceId", validation_alias="sequenceId") + sequence_name: Global[str] = Field(serialization_alias="sequenceName", validation_alias="sequenceName") base_action: Union[Global[Action], Default[Action]] = Field( - alias="baseAction", default=Default[Action](value=Action.ACCEPT) + serialization_alias="baseAction", validation_alias="baseAction", default=Default[Action](value="accept") + ) + match_entries: Optional[List[IPv4Match]] = Field( + serialization_alias="matchEntries", validation_alias="matchEntries", default=None ) - match_entries: Optional[List[IPv4Match]] = Field(alias="matchEntries", default=None) class IPv6SequenceBaseAction(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - sequence_id: Global[int] = Field(alias="sequenceId") - sequence_name: Global[str] = Field(alias="sequenceName") + sequence_id: Global[int] = Field(serialization_alias="sequenceId", validation_alias="sequenceId") + sequence_name: Global[str] = Field(serialization_alias="sequenceName", validation_alias="sequenceName") base_action: Union[Global[Action], Default[Action]] = Field( - alias="baseAction", default=Default[Action](value=Action.ACCEPT) + serialization_alias="baseAction", validation_alias="baseAction", default=Default[Action](value="accept") + ) + match_entries: Optional[List[IPv6Match]] = Field( + serialization_alias="matchEntries", validation_alias="matchEntries", default=None ) - match_entries: Optional[List[IPv6Match]] = Field(alias="matchEntries", default=None) class IPv4SequenceActions(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - sequence_id: Global[int] = Field(alias="sequenceId") - sequence_name: Global[str] = Field(alias="sequenceName") - actions: List[Union[AcceptActionsIPv4, DropActions]] = Field(alias="actions") - match_entries: Optional[List[IPv4Match]] = Field(alias="matchEntries", default=None) + sequence_id: Global[int] = Field(serialization_alias="sequenceId", validation_alias="sequenceId") + sequence_name: Global[str] = Field(serialization_alias="sequenceName", validation_alias="sequenceName") + actions: List[Union[AcceptActionsIPv4, DropActions]] = Field( + serialization_alias="actions", validation_alias="actions" + ) + match_entries: Optional[List[IPv4Match]] = Field( + serialization_alias="matchEntries", validation_alias="matchEntries", default=None + ) class IPv6SequenceActions(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - sequence_id: Global[int] = Field(alias="sequenceId") - sequence_name: Global[str] = Field(alias="sequenceName") - actions: List[Union[AcceptActionsIPv6, DropActions]] = Field(alias="actions") - match_entries: Optional[List[IPv6Match]] = Field(alias="matchEntries", default=None) + sequence_id: Global[int] = Field(serialization_alias="sequenceId", validation_alias="sequenceId") + sequence_name: Global[str] = Field(serialization_alias="sequenceName", validation_alias="sequenceName") + actions: List[Union[AcceptActionsIPv6, DropActions]] = Field( + serialization_alias="actions", validation_alias="actions" + ) + match_entries: Optional[List[IPv6Match]] = Field( + serialization_alias="matchEntries", validation_alias="matchEntries", default=None + ) class IPv4AclData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) defautl_action: Union[Global[Action], Default[Action]] = Field( - alias="defaultAction", default=Default[Action](value=Action.DROP) + serialization_alias="defaultAction", validation_alias="defaultAction", default=Default[Action](value="drop") ) sequences: List[Union[IPv4SequenceBaseAction, IPv4SequenceActions]] @@ -350,7 +394,7 @@ class IPv6AclData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) defautl_action: Union[Global[Action], Default[Action]] = Field( - alias="defaultAction", default=Default[Action](value=Action.DROP) + serialization_alias="defaultAction", validation_alias="defaultAction", default=Default[Action](value="drop") ) sequences: List[Union[IPv6SequenceBaseAction, IPv6SequenceActions]] diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/appqoe.py b/catalystwan/models/configuration/feature_profile/sdwan/service/appqoe.py index 3783f2af3..730e7163a 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/appqoe.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/appqoe.py @@ -1,64 +1,73 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable - -class VirtualApplicationType(str, Enum): - DREOPT = "dreopt" - - -class ResourceProfile(str, Enum): - SMALL = "small" - MEDIUM = "medium" - LARGE = "large" - EXTRA_LARGE = "extra-large" - DEFAULT = "default" +VirtualApplicationType = Literal["dreopt"] + +ResourceProfile = Literal[ + "small", + "medium", + "large", + "extra-large", + "default", +] + +AppqoeDeviceRole = Literal[ + "forwarder", + "forwarderAndServiceNode", + "serviceNode", + "serviceNodeWithDre", + "forwarderAndServiceNodeWithDre", +] + +AppnavControllerGroupName = Literal["ACG-APPQOE"] +ServiceNodeGroupName = Literal["SNG-APPQOE"] +ForwarderAndServiceNodeAddress = Literal["192.168.2.2"] # TODO: 1.Is it really constant? 2.Use ipaddress.IPv4Address? +ForwarderAndServiceNodeControllerAddress = Literal[ + "192.168.2.1" +] # TODO: 1.Is it really constant? 2.Use ipaddress.IPv4Address? +ServiceNodeExternalAddress = Literal["192.168.2.2"] # TODO: 1.Is it really constant? 2.Use ipaddress.IPv4Address? +ServiceNodeExternalVpgIp = Literal["192.168.2.1/24"] # TODO: 1.Is it really constant? 2.Use ipaddress.IPv4Address? class VirtualApplication(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - instance_id: Global[int] = Field(default=Global(value=1), alias="instanceId") + instance_id: Global[int] = Field( + default=Global(value=1), serialization_alias="instanceId", validation_alias="instanceId" + ) application_type: Global[VirtualApplicationType] = Field( - default=Global[VirtualApplicationType](value=VirtualApplicationType.DREOPT), alias="applicationType" + default=Global[VirtualApplicationType](value="dreopt"), + serialization_alias="applicationType", + validation_alias="applicationType", ) resource_profile: Union[Global[ResourceProfile], Default[str]] = Field( - default=Global[ResourceProfile](value=ResourceProfile.DEFAULT), alias="resourceProfile" + default=Global[ResourceProfile](value="default"), + serialization_alias="resourceProfile", + validation_alias="resourceProfile", ) -class AppqoeDeviceRole(str, Enum): - FORWARDER = "forwarder" - FORWARDER_AND_SERVICE_NODE = "forwarderAndServiceNode" - SERVICE_NODE = "serviceNode" - SERVICE_NODE_WITH_DRE = "serviceNodeWithDre" - FORWARDER_AND_SERVICE_NODE_WITH_DRE = "forwarderAndServiceNodeWithDre" - - -class AppnavControllerGroupName(str, Enum): - ACG_APPQOE = "ACG-APPQOE" - - -class ServiceNodeGroupName(str, Enum): - SNG_APPQOE = "SNG-APPQOE" - - class Appqoe(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) name: Default[str] = Default(value="/1") appnav_controller_group: Global[AppnavControllerGroupName] = Field( - default=Global[AppnavControllerGroupName](value=AppnavControllerGroupName.ACG_APPQOE), - alias="appnavControllerGroup", + default=Global[AppnavControllerGroupName](value="ACG-APPQOE"), + serialization_alias="appnavControllerGroup", + validation_alias="appnavControllerGroup", ) service_node_group: Global[ServiceNodeGroupName] = Field( - default=Global[ServiceNodeGroupName](value=ServiceNodeGroupName.SNG_APPQOE), alias="serviceNodeGroup" + default=Global[ServiceNodeGroupName](value="SNG-APPQOE"), + serialization_alias="serviceNodeGroup", + validation_alias="serviceNodeGroup", ) service_node_groups: List[Global[ServiceNodeGroupName]] = Field( - default=[Global[ServiceNodeGroupName](value=ServiceNodeGroupName.SNG_APPQOE)], alias="serviceNodeGroups" + default=[Global[ServiceNodeGroupName](value="SNG-APPQOE")], + serialization_alias="serviceNodeGroups", + validation_alias="serviceNodeGroups", ) enable: Global[bool] = Global[bool](value=True) vpn: Union[Global[int], Default[None], Variable] = Field(default=Global[int](value=0)) @@ -87,9 +96,11 @@ class ForwarderAppnavControllerGroup(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) group_name: Default[AppnavControllerGroupName] = Field( - default=Default(value=AppnavControllerGroupName.ACG_APPQOE), alias="groupName" + default=Default(value="ACG-APPQOE"), serialization_alias="groupName", validation_alias="groupName" + ) + appnav_controllers: List[ForwarderController] = Field( + serialization_alias="appnavControllers", validation_alias="appnavControllers" ) - appnav_controllers: List[ForwarderController] = Field(alias="appnavControllers") class ForwarderNodeGroup(BaseModel): @@ -97,37 +108,33 @@ class ForwarderNodeGroup(BaseModel): name: Union[Global[str], Default[ServiceNodeGroupName]] internal: Default[bool] = Default[bool](value=False) - service_node: List[ServiceNodeInformation] = Field(alias="serviceNode") + service_node: List[ServiceNodeInformation] = Field( + serialization_alias="serviceNode", validation_alias="serviceNode" + ) class ForwarderRole(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - appnav_controller_group: List[ForwarderAppnavControllerGroup] = Field(alias="appnavControllerGroup") - service_node_group: List[ForwarderNodeGroup] = Field(alias="serviceNodeGroup") - service_context: ServiceContext = Field(alias="serviceContext") + appnav_controller_group: List[ForwarderAppnavControllerGroup] = Field( + serialization_alias="appnavControllerGroup", validation_alias="appnavControllerGroup" + ) + service_node_group: List[ForwarderNodeGroup] = Field( + serialization_alias="serviceNodeGroup", validation_alias="serviceNodeGroup" + ) + service_context: ServiceContext = Field(serialization_alias="serviceContext", validation_alias="serviceContext") # Forwarder and Service -class ForwarderAndServiceNodeAddress(str, Enum): - ADDRESS_192_168_2_2 = "192.168.2.2" - - class ServiceNodeInformationDefault(BaseModel): - address: Default[ForwarderAndServiceNodeAddress] = Default[ForwarderAndServiceNodeAddress]( - value=ForwarderAndServiceNodeAddress.ADDRESS_192_168_2_2 - ) - - -class ForwarderAndServiceNodeControllerAddress(str, Enum): - ADDRESS_192_168_2_1 = "192.168.2.1" + address: Default[ForwarderAndServiceNodeAddress] = Default[ForwarderAndServiceNodeAddress](value="192.168.2.2") class ForwarderAndServiceNodeController(BaseModel): address: Default[ForwarderAndServiceNodeControllerAddress] = Default[ForwarderAndServiceNodeControllerAddress]( - value=ForwarderAndServiceNodeControllerAddress.ADDRESS_192_168_2_1 + value="192.168.2.1" ) @@ -135,74 +142,88 @@ class ForwarderAndServiceNodeAppnavControllerGroup(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) group_name: Default[AppnavControllerGroupName] = Field( - default=Default[AppnavControllerGroupName](value=AppnavControllerGroupName.ACG_APPQOE), alias="groupName" + default=Default[AppnavControllerGroupName](value="ACG-APPQOE"), + serialization_alias="groupName", + validation_alias="groupName", + ) + appnav_controllers: List[ForwarderAndServiceNodeController] = Field( + serialization_alias="appnavControllers", validation_alias="appnavControllers" ) - appnav_controllers: List[ForwarderAndServiceNodeController] = Field(alias="appnavControllers") class ForwarderAndServiceNodeGroup(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - name: Default[ServiceNodeGroupName] = Default[ServiceNodeGroupName](value=ServiceNodeGroupName.SNG_APPQOE) + name: Default[ServiceNodeGroupName] = Default[ServiceNodeGroupName](value="SNG-APPQOE") internal: Default[bool] = Default[bool](value=True) - service_node: List[ServiceNodeInformationDefault] = Field(alias="serviceNode") + service_node: List[ServiceNodeInformationDefault] = Field( + serialization_alias="serviceNode", validation_alias="serviceNode" + ) class ForwarderAndServiceNodeRole(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - appnav_controller_group: List[ForwarderAndServiceNodeAppnavControllerGroup] = Field(alias="appnavControllerGroup") - service_node_group: List[ForwarderAndServiceNodeGroup] = Field(alias="serviceNodeGroup") + appnav_controller_group: List[ForwarderAndServiceNodeAppnavControllerGroup] = Field( + serialization_alias="appnavControllerGroup", validation_alias="appnavControllerGroup" + ) + service_node_group: List[ForwarderAndServiceNodeGroup] = Field( + serialization_alias="serviceNodeGroup", validation_alias="serviceNodeGroup" + ) - service_context: ServiceContext = Field(alias="serviceContext") + service_context: ServiceContext = Field(serialization_alias="serviceContext", validation_alias="serviceContext") # Service -class ServiceNodeExternalAddress(str, Enum): - ADDRESS_192_168_2_2 = "192.168.2.2" - - -class ServiceNodeExternalVpgIp(str, Enum): - ADDRESS_192_168_2_1 = "192.168.2.1/24" class ServiceNodeInformationExternal(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - address: Default[ServiceNodeExternalAddress] = Default[ServiceNodeExternalAddress]( - value=ServiceNodeExternalAddress.ADDRESS_192_168_2_2 - ) + address: Default[ServiceNodeExternalAddress] = Default[ServiceNodeExternalAddress](value="192.168.2.2") vpg_ip: Default[ServiceNodeExternalVpgIp] = Field( - default=Default[ServiceNodeExternalVpgIp](value=ServiceNodeExternalVpgIp.ADDRESS_192_168_2_1), alias="vpgIp" + default=Default[ServiceNodeExternalVpgIp](value="192.168.2.1"), + serialization_alias="vpgIp", + validation_alias="vpgIp", ) class ServiceNodeGroup(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - name: Default[ServiceNodeGroupName] = Default[ServiceNodeGroupName](value=ServiceNodeGroupName.SNG_APPQOE) - external_node: Default[bool] = Field(default=Default[bool](value=True), alias="externalNode") + name: Default[ServiceNodeGroupName] = Default[ServiceNodeGroupName](value="SNG-APPQOE") + external_node: Default[bool] = Field( + default=Default[bool](value=True), serialization_alias="externalNode", validation_alias="externalNode" + ) service_node: List[ServiceNodeInformationExternal] = Field( - default=[ServiceNodeInformationExternal()], alias="serviceNode" + default=[ServiceNodeInformationExternal()], serialization_alias="serviceNode", validation_alias="serviceNode" ) class ServiceNodeRole(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - service_node_group: List[ServiceNodeGroup] = Field(default=[ServiceNodeGroup()], alias="serviceNodeGroup") + service_node_group: List[ServiceNodeGroup] = Field( + default=[ServiceNodeGroup()], serialization_alias="serviceNodeGroup", validation_alias="serviceNodeGroup" + ) class AppqoeData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) dreopt: Optional[Union[Global[bool], Default[bool]]] = Default[bool](value=False) - virtual_application: Optional[List[VirtualApplication]] = Field(alias="virtualApplication") - appqoe_device_role: Global[str] = Field(default=Global(value=AppqoeDeviceRole.FORWARDER), alias="appqoeDeviceRole") + virtual_application: Optional[List[VirtualApplication]] = Field( + serialization_alias="virtualApplication", validation_alias="virtualApplication" + ) + appqoe_device_role: Global[str] = Field( + default=Global(value="forwarder"), serialization_alias="appqoeDeviceRole", validation_alias="appqoeDeviceRole" + ) forwarder: Optional[ForwarderRole] - forwarder_and_service_node: Optional[ForwarderAndServiceNodeRole] = Field(alias="forwarderAndServiceNode") - service_node: Optional[ServiceNodeRole] = Field(alias="serviceNode") + forwarder_and_service_node: Optional[ForwarderAndServiceNodeRole] = Field( + serialization_alias="forwarderAndServiceNode", validation_alias="forwarderAndServiceNode" + ) + service_node: Optional[ServiceNodeRole] = Field(serialization_alias="serviceNode", validation_alias="serviceNode") class AppqoeCreationPayload(BaseModel): diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/bgp.py b/catalystwan/models/configuration/feature_profile/sdwan/service/bgp.py index e1d1063a6..bfce3dce0 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/bgp.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/bgp.py @@ -1,10 +1,9 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId from catalystwan.models.configuration.feature_profile.common import Prefix @@ -13,10 +12,10 @@ class AggregatePrefix(BaseModel): prefix: Prefix as_set: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="asSet", default=Default[bool](value=False) + serialization_alias="asSet", validation_alias="asSet", default=Default[bool](value=False) ) summary_only: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="summaryOnly", default=Default[bool](value=False) + serialization_alias="summaryOnly", validation_alias="summaryOnly", default=Default[bool](value=False) ) @@ -25,10 +24,10 @@ class AggregatePrefixIPv6(BaseModel): prefix: Union[Global[str], Variable] as_set: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="asSet", default=Default[bool](value=False) + serialization_alias="asSet", validation_alias="asSet", default=Default[bool](value=False) ) summary_only: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="summaryOnly", default=Default[bool](value=False) + serialization_alias="summaryOnly", validation_alias="summaryOnly", default=Default[bool](value=False) ) @@ -44,45 +43,53 @@ class NetworkPrefixIPv6(BaseModel): prefix: Union[Global[str], Variable] -class RedistributeProtocol(str, Enum): - STATIC = "static" - CONNECTED = "connected" - OMP = "omp" - NAT = "nat" - OSPF = "ospf" - OSPFV3 = "ospfv3" - EIGRP = "eigrp" +RedistributeProtocol = Literal[ + "static", + "connected", + "omp", + "nat", + "ospf", + "ospfv3", + "eigrp", +] -class RedistributeProtocolIPv6(str, Enum): - STATIC = "static" - CONNECTED = "connected" - OMP = "omp" - OSPF = "ospf" +RedistributeProtocolIPv6 = Literal[ + "static", + "connected", + "omp", + "ospf", +] class RedistributedRoute(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) protocol: Union[Global[RedistributeProtocol], Variable] - route_policy: Optional[Union[Default[None], RefId]] = Field(alias="routePolicy") + route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="routePolicy", validation_alias="routePolicy" + ) class RedistributedRouteIPv6(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) protocol: Union[Global[RedistributeProtocolIPv6], Variable] - route_policy: Optional[Union[Default[None], RefId]] = Field(alias="routePolicy") + route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="routePolicy", validation_alias="routePolicy" + ) class AddressFamilyIPv4(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - aggregate_address: Optional[List[AggregatePrefix]] = Field(alias="aggregateAddress") + aggregate_address: Optional[List[AggregatePrefix]] = Field( + serialization_alias="aggregateAddress", validation_alias="aggregateAddress" + ) network: Optional[List[NetworkPrefix]] = None paths: Optional[Union[Global[int], Variable, Default[None]]] = None originate: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=False) - name: Optional[Union[Default[None], RefId]] = None + name: Optional[Union[Default[None], Global[UUID]]] = None filter: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=False) redistribute: Optional[List[RedistributedRoute]] = None @@ -90,22 +97,22 @@ class AddressFamilyIPv4(BaseModel): class PolicyType(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - policy_type: Global[str] = Field(alias="policyType") + policy_type: Global[str] = Field(serialization_alias="policyType", validation_alias="policyType") class PolicyTypeWithThreshold(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - policy_type: Global[str] = Field(alias="policyType") - prefix_number: Union[Global[int], Variable] = Field(alias="prefixNum") + policy_type: Global[str] = Field(serialization_alias="policyType", validation_alias="policyType") + prefix_number: Union[Global[int], Variable] = Field(serialization_alias="prefixNum", validation_alias="prefixNum") threshold: Union[Global[int], Variable, Default[int]] = Default[int](value=75) class PolicyTypeWithRestart(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - policy_type: Global[str] = Field(alias="policyType") - prefix_number: Union[Global[int], Variable] = Field(alias="prefixNum") + policy_type: Global[str] = Field(serialization_alias="policyType", validation_alias="policyType") + prefix_number: Union[Global[int], Variable] = Field(serialization_alias="prefixNum", validation_alias="prefixNum") threshold: Union[Global[int], Variable, Default[int]] = Default[int](value=75) restart_interval: Union[Global[int], Variable] @@ -113,11 +120,15 @@ class PolicyTypeWithRestart(BaseModel): class AddressFamilyIPv6(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - aggregate_address: Optional[List[AggregatePrefixIPv6]] = Field(alias="ipv6AggregateAddress") - network: Optional[List[NetworkPrefixIPv6]] = Field(alias="ipv6Network") + aggregate_address: Optional[List[AggregatePrefixIPv6]] = Field( + serialization_alias="ipv6AggregateAddress", validation_alias="ipv6AggregateAddress" + ) + network: Optional[List[NetworkPrefixIPv6]] = Field( + serialization_alias="ipv6Network", validation_alias="ipv6Network" + ) paths: Optional[Union[Global[int], Variable, Default[None]]] = None originate: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=False) - name: Optional[Union[Default[None], RefId]] = None + name: Optional[Union[Default[None], Global[UUID]]] = None filter: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=False) redistribute: Optional[List[RedistributedRouteIPv6]] = None @@ -125,12 +136,16 @@ class AddressFamilyIPv6(BaseModel): class BgpAddressFamily(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - family_type: Global[str] = Field(alias="familyType") + family_type: Global[str] = Field(serialization_alias="familyType", validation_alias="familyType") max_prefix_config: Optional[Union[PolicyType, PolicyTypeWithRestart, PolicyTypeWithThreshold]] = Field( - alias="maxPrefixConfig" + serialization_alias="maxPrefixConfig", validation_alias="maxPrefixConfig" + ) + in_route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="inRoutePolicy", validation_alias="inRoutePolicy" + ) + out_route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="outRoutePolicy", validation_alias="outRoutePolicy" ) - in_route_policy: Optional[Union[Default[None], RefId]] = Field(alias="inRoutePolicy") - out_route_policy: Optional[Union[Default[None], RefId]] = Field(alias="outRoutePolicy") class BgpIPv4Neighbor(BaseModel): @@ -139,32 +154,40 @@ class BgpIPv4Neighbor(BaseModel): address: Union[Global[str], Variable] description: Optional[Union[Global[str], Variable, Default[None]]] = None shutdown: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=False) - remote_as: Union[Global[int], Variable] = Field(alias="remoteAs") - local_as: Union[Global[int], Variable] = Field(alias="localAs", default=None) + remote_as: Union[Global[int], Variable] = Field(serialization_alias="remoteAs", validation_alias="remoteAs") + local_as: Union[Global[int], Variable] = Field( + serialization_alias="localAs", validation_alias="localAs", default=None + ) keepalive: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=60) holdtime: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=180) - interface_name: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="ifName", default=None) + interface_name: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="ifName", validation_alias="ifName", default=None + ) next_hop_self: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="nextHopSelf", default=Default[bool](value=False) + serialization_alias="nextHopSelf", validation_alias="nextHopSelf", default=Default[bool](value=False) ) send_community: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="sendCommunity", default=Default[bool](value=True) + serialization_alias="sendCommunity", validation_alias="sendCommunity", default=Default[bool](value=True) ) send_ext_community: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="sendExtCommunity", default=Default[bool](value=True) + serialization_alias="sendExtCommunity", validation_alias="sendExtCommunity", default=Default[bool](value=True) ) ebgp_multihop: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="ebgpMultihop", default=Default[int](value=1) + serialization_alias="ebgpMultihop", validation_alias="ebgpMultihop", default=Default[int](value=1) ) password: Optional[Union[Global[str], Variable, Default[None]]] = None send_label: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="sendLabel", default=Default[bool](value=False) + serialization_alias="sendLabel", validation_alias="sendLabel", default=Default[bool](value=False) ) as_override: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="asOverride", default=Default[bool](value=False) + serialization_alias="asOverride", validation_alias="asOverride", default=Default[bool](value=False) + ) + as_number: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="asNumber", validation_alias="asNumber", default=None + ) + address_family: Optional[BgpAddressFamily] = Field( + serialization_alias="addressFamily", validation_alias="addressFamily" ) - as_number: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="asNumber", default=None) - address_family: Optional[BgpAddressFamily] = Field(alias="addressFamily") class BgpIPv6Neighbor(BaseModel): @@ -173,44 +196,56 @@ class BgpIPv6Neighbor(BaseModel): address: Union[Global[str], Variable] description: Optional[Union[Global[str], Variable, Default[None]]] = None shutdown: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=False) - remote_as: Union[Global[int], Variable] = Field(alias="remoteAs") - local_as: Union[Global[int], Variable] = Field(alias="localAs", default=None) + remote_as: Union[Global[int], Variable] = Field(serialization_alias="remoteAs", validation_alias="remoteAs") + local_as: Union[Global[int], Variable] = Field( + serialization_alias="localAs", validation_alias="localAs", default=None + ) keepalive: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=60) holdtime: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=180) - interface_name: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="ifName", default=None) + interface_name: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="ifName", validation_alias="ifName", default=None + ) next_hop_self: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="nextHopSelf", default=Default[bool](value=False) + serialization_alias="nextHopSelf", validation_alias="nextHopSelf", default=Default[bool](value=False) ) send_community: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="sendCommunity", default=Default[bool](value=True) + serialization_alias="sendCommunity", validation_alias="sendCommunity", default=Default[bool](value=True) ) send_ext_community: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="sendExtCommunity", default=Default[bool](value=True) + serialization_alias="sendExtCommunity", validation_alias="sendExtCommunity", default=Default[bool](value=True) ) ebgp_multihop: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="ebgpMultihop", default=Default[int](value=1) + serialization_alias="ebgpMultihop", validation_alias="ebgpMultihop", default=Default[int](value=1) ) password: Optional[Union[Global[str], Variable, Default[None]]] = None send_label: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="sendLabel", default=Default[bool](value=False) + serialization_alias="sendLabel", validation_alias="sendLabel", default=Default[bool](value=False) ) as_override: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="asOverride", default=Default[bool](value=False) + serialization_alias="asOverride", validation_alias="asOverride", default=Default[bool](value=False) + ) + as_number: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="asNumber", validation_alias="asNumber", default=None + ) + address_family: Optional[BgpAddressFamily] = Field( + serialization_alias="addressFamily", validation_alias="addressFamily" ) - as_number: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="asNumber", default=None) - address_family: Optional[BgpAddressFamily] = Field(alias="addressFamily") class BgpData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - as_num: Union[Global[int], Variable] = Field(alias="asNum") - router_id: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="routerId", default=None) + as_num: Union[Global[int], Variable] = Field(serialization_alias="asNum", validation_alias="asNum") + router_id: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="routerId", validation_alias="routerId", default=None + ) propagate_aspath: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="propagateAspath", default=Default[bool](value=False) + serialization_alias="propagateAspath", validation_alias="propagateAspath", default=Default[bool](value=False) ) propagate_community: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="propagateCommunity", default=Default[bool](value=False) + serialization_alias="propagateCommunity", + validation_alias="propagateCommunity", + default=Default[bool](value=False), ) external: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=20) internal: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=200) @@ -218,22 +253,28 @@ class BgpData(BaseModel): keepalive: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=60) holdtime: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=180) always_compare: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="alwaysCompare", default=Default[bool](value=False) + serialization_alias="alwaysCompare", validation_alias="alwaysCompare", default=Default[bool](value=False) ) deterministic: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=False) missing_as_worst: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="missingAsWorst", default=Default[bool](value=False) + serialization_alias="missingAsWorst", validation_alias="missingAsWorst", default=Default[bool](value=False) ) compare_router_id: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="compareRouterId", default=Default[bool](value=False) + serialization_alias="compareRouterId", validation_alias="compareRouterId", default=Default[bool](value=False) ) multipath_relax: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="multipathRelax", default=Default[bool](value=False) + serialization_alias="multipathRelax", validation_alias="multipathRelax", default=Default[bool](value=False) ) neighbor: Optional[List[BgpIPv4Neighbor]] = None - ipv6_neighbor: Optional[List[BgpIPv6Neighbor]] = Field(alias="ipv6Neighbor", default=None) - address_family: Optional[AddressFamilyIPv4] = Field(alias="addressFamily", default=None) - ipv6_address_family: Optional[AddressFamilyIPv6] = Field(alias="ipv6AddressFamily", default=None) + ipv6_neighbor: Optional[List[BgpIPv6Neighbor]] = Field( + serialization_alias="ipv6Neighbor", validation_alias="ipv6Neighbor", default=None + ) + address_family: Optional[AddressFamilyIPv4] = Field( + serialization_alias="addressFamily", validation_alias="addressFamily", default=None + ) + ipv6_address_family: Optional[AddressFamilyIPv6] = Field( + serialization_alias="ipv6AddressFamily", validation_alias="ipv6AddressFamily", default=None + ) class BgpCreationPayload(BaseModel): diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/dhcp_server.py b/catalystwan/models/configuration/feature_profile/sdwan/service/dhcp_server.py index bd72ce165..6e2177c3d 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/dhcp_server.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/dhcp_server.py @@ -29,33 +29,47 @@ class OptionCodeIP(BaseModel): class StaticLease(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - mac_address: Union[Global[str], Variable] = Field(alias="macAddress") + mac_address: Union[Global[str], Variable] = Field(serialization_alias="macAddress", validation_alias="macAddress") ip: Union[Global[str], Variable] class DhcpAddressPool(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - network_address: Union[Global[str], Variable] = Field(alias="networkAddress") - subnet_mask: Union[Global[str], Variable] = Field(alias="subnetMask") + network_address: Union[Global[str], Variable] = Field( + serialization_alias="networkAddress", validation_alias="networkAddress" + ) + subnet_mask: Union[Global[str], Variable] = Field(serialization_alias="subnetMask", validation_alias="subnetMask") class DhcpServerData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - address_pool: DhcpAddressPool = Field(alias="addressPool") + address_pool: DhcpAddressPool = Field(serialization_alias="addressPool", validation_alias="addressPool") exclude: Optional[Union[Global[List[str]], Variable, Default[None]]] = None lease_time: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="leaseTime", default=Default[int](value=86400) + serialization_alias="leaseTime", validation_alias="leaseTime", default=Default[int](value=86400) + ) + interface_mtu: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="interfaceMtu", validation_alias="interfaceMtu", default=None + ) + domain_name: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="domainName", validation_alias="domainName", default=None + ) + default_gateway: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="defaultGateway", validation_alias="defaultGateway", default=None + ) + dns_servers: Optional[Union[Global[List[str]], Variable, Default[None]]] = Field( + serialization_alias="dnsServers", validation_alias="dnsServers", default=None + ) + tftp_servers: Optional[Union[Global[List[str]], Variable, Default[None]]] = Field( + serialization_alias="tftpServers", validation_alias="tftpServers", default=None + ) + static_lease: Optional[List[StaticLease]] = Field( + serialization_alias="staticLease", validation_alias="staticLease", default=None ) - interface_mtu: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="interfaceMtu", default=None) - domain_name: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="domainName", default=None) - default_gateway: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="defaultGateway", default=None) - dns_servers: Optional[Union[Global[List[str]], Variable, Default[None]]] = Field(alias="dnsServers", default=None) - tftp_servers: Optional[Union[Global[List[str]], Variable, Default[None]]] = Field(alias="tftpServers", default=None) - static_lease: Optional[List[StaticLease]] = Field(alias="staticLease", default=None) option_code: Optional[List[Union[OptionCodeAscii, OptionCodeHex, OptionCodeIP]]] = Field( - alias="optionCode", default=None + serialization_alias="optionCode", validation_alias="optionCode", default=None ) diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/eigrp.py b/catalystwan/models/configuration/feature_profile/sdwan/service/eigrp.py index 4ea5264d0..64d46a102 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/eigrp.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/eigrp.py @@ -1,35 +1,49 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId from catalystwan.models.configuration.feature_profile.common import Prefix +EigrpAuthType = Literal[ + "md5", + "hmac-sha-256", +] -class EigrpAuthType(str, Enum): - MD5 = "md5" - HMAC_SHA_256 = "hmac-sha-256" + +RedistributeProtocol = Literal[ + "bgp", + "connected", + "nat-route", + "omp", + "ospf", + "ospfv3", + "static", +] class KeychainDetails(BaseModel): - key_id: Union[Global[int], Variable, Default[None]] = Field(alias="keyId") + key_id: Union[Global[int], Variable, Default[None]] = Field(serialization_alias="keyId", validation_alias="keyId") keystring: Union[Global[str], Variable, Default[None]] class EigrpAuthentication(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - auth_type: Union[Global[EigrpAuthType], Variable, Default[None]] = Field(alias="type") - auth_key: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="authKey") - key: Optional[List[KeychainDetails]] = Field(alias="key") + auth_type: Union[Global[EigrpAuthType], Variable, Default[None]] = Field( + serialization_alias="type", validation_alias="type" + ) + auth_key: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="authKey", validation_alias="authKey" + ) + key: Optional[List[KeychainDetails]] = Field(serialization_alias="key", validation_alias="key") class TableMap(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - name: Optional[Union[Default[None], RefId]] = Default[None](value=None) + name: Optional[Union[Default[None], Global[UUID]]] = Default[None](value=None) filter: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=False) @@ -44,24 +58,16 @@ class IPv4StaticRoute(BaseModel): name: Union[Global[str], Variable] shutdown: Optional[Union[Global[int], Variable, Default[bool]]] = Default[bool](value=False) - summary_address: Optional[List[SummaryAddress]] = Field(alias="summaryAddress") - - -class RedistributeProtocol(str, Enum): - BGP = "bgp" - CONNECTED = "connected" - NAT = "nat-route" - OMP = "omp" - OSPF = "ospf" - OSPFV3 = "ospfv3" - STATIC = "static" + summary_address: Optional[List[SummaryAddress]] = Field( + serialization_alias="summaryAddress", validation_alias="summaryAddress" + ) class RedistributeIntoEigrp(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) protocol: Union[Global[RedistributeProtocol], Variable] - route_policy: Optional[Union[Default[None], RefId]] = Default[None](value=None) + route_policy: Optional[Union[Default[None], Global[UUID]]] = Default[None](value=None) class AddressFamily(BaseModel): @@ -74,15 +80,19 @@ class AddressFamily(BaseModel): class EigrpData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - as_number: Union[Global[int], Variable] = Field(alias="asNum") - address_family: AddressFamily = Field(alias="addressFamily") + as_number: Union[Global[int], Variable] = Field(serialization_alias="asNum", validation_alias="asNum") + address_family: AddressFamily = Field(serialization_alias="addressFamily", validation_alias="addressFamily") hello_interval: Union[Global[int], Variable, Default[int]] = Field( - alias="helloInterval", default=Default[int](value=5) + serialization_alias="helloInterval", validation_alias="helloInterval", default=Default[int](value=5) + ) + hold_time: Union[Global[int], Variable, Default[int]] = Field( + serialization_alias="holdTime", validation_alias="holdTime", default=Default[int](value=15) ) - hold_time: Union[Global[int], Variable, Default[int]] = Field(alias="holdTime", default=Default[int](value=15)) authentication: Optional[EigrpAuthentication] = None - af_interface: Optional[List[IPv4StaticRoute]] = Field(alias="afInterface", default=None) - table_map: TableMap = Field(alias="tableMap", default=TableMap()) + af_interface: Optional[List[IPv4StaticRoute]] = Field( + serialization_alias="afInterface", validation_alias="afInterface", default=None + ) + table_map: TableMap = Field(serialization_alias="tableMap", validation_alias="tableMap", default=TableMap()) class EigrpCreationPayload(BaseModel): diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/common.py b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/common.py index f6b4d7196..42135f83b 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/common.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/common.py @@ -1,64 +1,68 @@ -from enum import Enum -from typing import Optional, Union +from typing import Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId - -class IkeMode(str, Enum): - MAIN = "main" - AGGRESIVE = "aggresive" - - -class IkeCiphersuite(str, Enum): - AES256_CBC_SHA1 = "aes256-cbc-sha1" - AES256_CBC_SHA2 = "aes256-cbc-sha2" - AES128_CBC_SHA1 = "aes128-cbc-sha1" - AES128_CBC_SHA2 = "aes128-cbc-sha2" - - -class IkeGroup(str, Enum): - GROUP_2 = "2" - GROUP_14 = "14" - GROUP_15 = "15" - GROUP_16 = "16" - GROUP_19 = "19" - GROUP_20 = "20" - GROUP_21 = "21" - GROUP_24 = "24" - - -class IpsecCiphersuite(str, Enum): - AES256_CBC_SHA1 = "aes256-cbc-sha1" - AES256_CBC_SHA384 = "aes256-cbc-sha384" - AES256_CBC_SHA256 = "aes256-cbc-sha256" - AES256_CBC_SHA512 = "aes256-cbc-sha512" - AES256_GCM = "aes256-gcm" - NULL_SHA1 = "null-sha1" - NULL_SHA384 = "null-sha384" - NULL_SHA256 = "null-sha256" - NULL_SHA512 = "null-sha512" - - -class PfsGroup(str, Enum): - GROUP_1 = "group-1" - GROUP_2 = "group-2" - GROUP_5 = "group-5" - GROUP_14 = "group-14" - GROUP_15 = "group-15" - GROUP_16 = "group-16" - GROUP_19 = "group-19" - GROUP_20 = "group-20" - GROUP_21 = "group-21" - GROUP_24 = "group-24" - NONE = "none" - - -class TunnelApplication(str, Enum): - NONE = "none" - SIG = "sig" +IkeMode = Literal[ + "main", + "aggresive", +] + +IkeCiphersuite = Literal[ + "aes256-cbc-sha1", + "aes256-cbc-sha2", + "aes128-cbc-sha1", + "aes128-cbc-sha2", +] + +IkeGroup = Literal[ + "2", + "14", + "15", + "16", + "19", + "20", + "21", + "24", +] + +IpsecCiphersuite = Literal[ + "aes256-cbc-sha1", + "aes256-cbc-sha384", + "aes256-cbc-sha256", + "aes256-cbc-sha512", + "aes256-gcm", + "null-sha1", + "null-sha384", + "null-sha256", + "null-sha512", +] + +PfsGroup = Literal[ + "group-1", + "group-2", + "group-5", + "group-14", + "group-15", + "group-16", + "group-19", + "group-20", + "group-21", + "group-24", + "none", +] + +TunnelApplication = Literal[ + "none", + "sig", +] + +VrrpTrackerAction = Literal[ + "Decrement", + "Shutdown", +] class Arp(BaseModel): @@ -68,31 +72,38 @@ class Arp(BaseModel): mac_address: Union[Global[str], Variable] -class VrrpTrackerAction(str, Enum): - DECREMENT = "Decrement" - SHUTDOWN = "Shutdown" - - class VrrpTrackingObject(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - tracker_id: Union[Default[None], RefId] = Field(alias="trackerId") - tracker_action: Union[Global[VrrpTrackerAction], Variable] = Field(alias="trackerAction") - decrement_value: Optional[Union[Variable, Global[int]]] = Field(alias="decrementValue", default=None) + tracker_id: Union[Default[None], Global[UUID]] = Field( + serialization_alias="trackerId", validation_alias="trackerId" + ) + tracker_action: Union[Global[VrrpTrackerAction], Variable] = Field( + serialization_alias="trackerAction", validation_alias="trackerAction" + ) + decrement_value: Optional[Union[Variable, Global[int]]] = Field( + serialization_alias="decrementValue", validation_alias="decrementValue", default=None + ) class VrrpIPv6Address(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - ipv6_link_local: Union[Global[str], Variable] = Field(alias="ipv6LinkLocal") + ipv6_link_local: Union[Global[str], Variable] = Field( + serialization_alias="ipv6LinkLocal", validation_alias="ipv6LinkLocal" + ) prefix: Optional[Union[Global[str], Variable, Default[None]]] = None class StaticIPv4Address(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - ip_address: Union[Variable, Global[str], Default[None]] = Field(alias="ipAddress") - subnet_mask: Union[Variable, Global[str], Default[None]] = Field(alias="subnetMask") + ip_address: Union[Variable, Global[str], Default[None]] = Field( + serialization_alias="ipAddress", validation_alias="ipAddress" + ) + subnet_mask: Union[Variable, Global[str], Default[None]] = Field( + serialization_alias="subnetMask", validation_alias="subnetMask" + ) class StaticIPv6Address(BaseModel): diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/ethernet.py b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/ethernet.py index c5d66d986..9b20fb0c7 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/ethernet.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/ethernet.py @@ -1,10 +1,9 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId from catalystwan.models.configuration.feature_profile.sdwan.service.lan.common import ( Arp, StaticIPv4Address, @@ -14,6 +13,23 @@ ) from catalystwan.models.configuration.feature_profile.sdwan.service.lan.vpn import Direction +NatType = Literal[ + "pool", + "loopback", +] + +DuplexMode = Literal[ + "full", + "half", + "auto", +] + +MediaType = Literal[ + "auto-select", + "rj45", + "sfp", +] + class DynamicDhcpDistance(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) @@ -30,8 +46,12 @@ class InterfaceDynamicIPv4Address(BaseModel): class StaticIPv4AddressConfig(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - primary_ip_address: StaticIPv4Address = Field(alias="staticIpV4AddressPrimary") - secondary_ip_address: Optional[StaticIPv4Address] = Field(alias="staticIpV4AddressSecondary", default=None) + primary_ip_address: StaticIPv4Address = Field( + serialization_alias="staticIpV4AddressPrimary", validation_alias="staticIpV4AddressPrimary" + ) + secondary_ip_address: Optional[StaticIPv4Address] = Field( + serialization_alias="staticIpV4AddressSecondary", validation_alias="staticIpV4AddressSecondary", default=None + ) class InterfaceStaticIPv4Address(BaseModel): @@ -43,8 +63,12 @@ class InterfaceStaticIPv4Address(BaseModel): class DynamicIPv6Dhcp(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - dhcp_client: Global[dict] = Field(alias="dhcpClient", default=Global[dict](value={})) - secondary_ipv6_address: Optional[List[StaticIPv6Address]] = Field(alias="secondaryIpV6Address") + dhcp_client: Global[dict] = Field( + serialization_alias="dhcpClient", validation_alias="dhcpClient", default=Global[dict](value={}) + ) + secondary_ipv6_address: Optional[List[StaticIPv6Address]] = Field( + serialization_alias="secondaryIpV6Address", validation_alias="secondaryIpV6Address" + ) class InterfaceDynamicIPv6Address(BaseModel): @@ -56,16 +80,22 @@ class InterfaceDynamicIPv6Address(BaseModel): class Dhcpv6Helper(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - ip_address: Union[Global[str], Variable] = Field(alias="ipAddress") + ip_address: Union[Global[str], Variable] = Field(serialization_alias="ipAddress", validation_alias="ipAddress") vpn: Optional[Union[Global[int], Variable, Default[None]]] = None class StaticIPv6AddressConfig(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - primary_ip_address: StaticIPv6Address = Field(alias="staticIpV6AddressPrimary") - secondary_ip_address: Optional[List[StaticIPv6Address]] = Field(alias="staticIpV6AddressSecondary", default=None) - dhcp_helper_v6: Optional[List[Dhcpv6Helper]] = Field(alias="dhcpHelperV6", default=None) + primary_ip_address: StaticIPv6Address = Field( + serialization_alias="staticIpV6AddressPrimary", validation_alias="staticIpV6AddressPrimary" + ) + secondary_ip_address: Optional[List[StaticIPv6Address]] = Field( + serialization_alias="staticIpV6AddressSecondary", validation_alias="staticIpV6AddressSecondary", default=None + ) + dhcp_helper_v6: Optional[List[Dhcpv6Helper]] = Field( + serialization_alias="dhcpHelperV6", validation_alias="dhcpHelperV6", default=None + ) class InterfaceStaticIPv6Address(BaseModel): @@ -74,41 +104,56 @@ class InterfaceStaticIPv6Address(BaseModel): static: StaticIPv6AddressConfig -class NatType(str, Enum): - POOL = "pool" - LOOPBACK = "loopback" - - class NatPool(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - range_start: Union[Variable, Global[str], Default[None]] = Field(alias="rangeStart") - range_end: Union[Variable, Global[str], Default[None]] = Field(alias="rangeEnd") - prefix_length: Union[Variable, Global[int], Default[None]] = Field(alias="prefixLength") + range_start: Union[Variable, Global[str], Default[None]] = Field( + serialization_alias="rangeStart", validation_alias="rangeStart" + ) + range_end: Union[Variable, Global[str], Default[None]] = Field( + serialization_alias="rangeEnd", validation_alias="rangeEnd" + ) + prefix_length: Union[Variable, Global[int], Default[None]] = Field( + serialization_alias="prefixLength", validation_alias="prefixLength" + ) overload: Union[Variable, Global[bool], Default[bool]] = Default[bool](value=True) class StaticNat(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_ip: Union[Global[str], Variable] = Field(alias="sourceIp") + source_ip: Union[Global[str], Variable] = Field(serialization_alias="sourceIp", validation_alias="sourceIp") - translate_ip: Union[Global[str], Variable] = Field(alias="translateIp") + translate_ip: Union[Global[str], Variable] = Field( + serialization_alias="translateIp", validation_alias="translateIp" + ) static_nat_direction: Union[Global[Direction], Default[Direction]] = Field( - alias="staticNatDirection", default=Default[Direction](value=Direction.INSIDE) + serialization_alias="staticNatDirection", + validation_alias="staticNatDirection", + default=Default[Direction](value="inside"), + ) + source_vpn: Union[Global[int], Variable, Default[int]] = Field( + serialization_alias="sourceVpn", validation_alias="sourceVpn", default=Default[int](value=0) ) - source_vpn: Union[Global[int], Variable, Default[int]] = Field(alias="sourceVpn", default=Default[int](value=0)) class NatAttributesIPv4(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - nat_type: Union[Global[NatType], Variable] = Field(alias="natType") - nat_pool: Optional[NatPool] = Field(alias="natPool", default=None) - nat_loopback: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="natLoopbakc", default=None) - udp_timeout: Union[Global[int], Variable, Default[int]] = Field(alias="udpTimeout", default=Default[int](value=1)) - tcp_timeout: Union[Global[int], Variable, Default[int]] = Field(alias="tcpTimeout", default=Default[int](value=1)) - new_static_nat: Optional[List[StaticNat]] = Field(alias="newStaticNat", default=None) + nat_type: Union[Global[NatType], Variable] = Field(serialization_alias="natType", validation_alias="natType") + nat_pool: Optional[NatPool] = Field(serialization_alias="natPool", validation_alias="natPool", default=None) + nat_loopback: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="natLoopbakc", validation_alias="natLoopbakc", default=None + ) + udp_timeout: Union[Global[int], Variable, Default[int]] = Field( + serialization_alias="udpTimeout", validation_alias="udpTimeout", default=Default[int](value=1) + ) + tcp_timeout: Union[Global[int], Variable, Default[int]] = Field( + serialization_alias="tcpTimeout", validation_alias="tcpTimeout", default=Default[int](value=1) + ) + new_static_nat: Optional[List[StaticNat]] = Field( + serialization_alias="newStaticNat", validation_alias="newStaticNat", default=None + ) class NatAttributesIPv6(BaseModel): @@ -120,93 +165,117 @@ class NatAttributesIPv6(BaseModel): class AclQos(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - shaping_rate: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="shapingRate", default=None) - ipv4_acl_egress: Optional[RefId] = Field(alias="ipv4AclEgress", default=None) - ipv4_acl_ingress: Optional[RefId] = Field(alias="ipv4AclIngress", default=None) - ipv6_acl_egress: Optional[RefId] = Field(alias="ipv6AclEgress", default=None) - ipv6_acl_ingress: Optional[RefId] = Field(alias="ipv6AclIngress", default=None) + shaping_rate: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="shapingRate", validation_alias="shapingRate", default=None + ) + ipv4_acl_egress: Optional[Global[UUID]] = Field( + serialization_alias="ipv4AclEgress", validation_alias="ipv4AclEgress", default=None + ) + ipv4_acl_ingress: Optional[Global[UUID]] = Field( + serialization_alias="ipv4AclIngress", validation_alias="ipv4AclIngress", default=None + ) + ipv6_acl_egress: Optional[Global[UUID]] = Field( + serialization_alias="ipv6AclEgress", validation_alias="ipv6AclEgress", default=None + ) + ipv6_acl_ingress: Optional[Global[UUID]] = Field( + serialization_alias="ipv6AclIngress", validation_alias="ipv6AclIngress", default=None + ) class VrrpIPv6(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - group_id: Union[Variable, Global[int]] = Field(alias="groupId") + group_id: Union[Variable, Global[int]] = Field(serialization_alias="groupId", validation_alias="groupId") priority: Union[Variable, Global[int], Default[int]] = Default[int](value=100) timer: Union[Variable, Global[int], Default[int]] = Default[int](value=1000) - track_omp: Union[Global[bool], Default[bool]] = Field(alias="trackOmp", default=Default[bool](value=False)) + track_omp: Union[Global[bool], Default[bool]] = Field( + serialization_alias="trackOmp", validation_alias="trackOmp", default=Default[bool](value=False) + ) ipv6: List[VrrpIPv6Address] class VrrpIPv4(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - group_id: Union[Variable, Global[int]] = Field(alias="groupId") + group_id: Union[Variable, Global[int]] = Field(serialization_alias="groupId", validation_alias="groupId") priority: Union[Variable, Global[int], Default[int]] = Default[int](value=100) timer: Union[Variable, Global[int], Default[int]] = Default[int](value=1000) - track_omp: Union[Global[bool], Default[bool]] = Field(alias="trackOmp", default=Default[bool](value=False)) - ip_address: Union[Global[str], Variable] = Field(alias="ipAddress") - ip_address_secondary: Optional[List[StaticIPv4Address]] = Field(alias="ipAddressSecondary") + track_omp: Union[Global[bool], Default[bool]] = Field( + serialization_alias="trackOmp", validation_alias="trackOmp", default=Default[bool](value=False) + ) + ip_address: Union[Global[str], Variable] = Field(serialization_alias="ipAddress", validation_alias="ipAddress") + ip_address_secondary: Optional[List[StaticIPv4Address]] = Field( + serialization_alias="ipAddressSecondary", validation_alias="ipAddressSecondary" + ) tloc_pref_change: Union[Global[bool], Default[bool]] = Field( - alias="tlocPrefChange", default=Default[bool](value=False) + serialization_alias="tlocPrefChange", validation_alias="tlocPrefChange", default=Default[bool](value=False) ) tloc_pref_change_value: Optional[Union[Global[int], Default[None]]] = Field( - alias="tlocPrefChangeValue", default=None + serialization_alias="tlocPrefChangeValue", validation_alias="tlocPrefChangeValue", default=None + ) + tracking_object: Optional[List[VrrpTrackingObject]] = Field( + serialization_alias="trackingObject", validation_alias="trackingObject", default=None ) - tracking_object: Optional[List[VrrpTrackingObject]] = Field(alias="trackingObject", default=None) class Trustsec(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) enable_sgt_propagation: Union[Global[bool], Default[bool]] = Field( - alias="enableSGTPropagation", default=Default[bool](value=False) + serialization_alias="enableSGTPropagation", + validation_alias="enableSGTPropagation", + default=Default[bool](value=False), ) propagate: Optional[Union[Global[bool], Default[bool]]] = Default[bool](value=True) security_group_tag: Optional[Union[Global[int], Variable, Default[None]]] = Field( - alias="securityGroupTag", default=None + serialization_alias="securityGroupTag", validation_alias="securityGroupTag", default=None + ) + enable_enforced_propagation: Union[Global[bool], Default[None]] = Field( + serialization_alias="enableEnforcedPropagation", validation_alias="enableEnforcedPropagation" + ) + enforced_security_group_tag: Union[Global[int], Variable, Default[None]] = Field( + serialization_alias="enforcedSecurityGroupTag", validation_alias="enforcedSecurityGroupTag" ) - enable_enforced_propagation: Union[Global[bool], Default[None]] = Field(alias="enableEnforcedPropagation") - enforced_security_group_tag: Union[Global[int], Variable, Default[None]] = Field(alias="enforcedSecurityGroupTag") - - -class DuplexMode(str, Enum): - FULL = "full" - HALF = "half" - AUTO = "auto" - - -class MediaType(str, Enum): - AUTO = "auto-select" - RJ45 = "rj45" - SFP = "sfp" class AdvancedAttributes(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) duplex: Optional[Union[Global[DuplexMode], Variable, Default[None]]] = None - mac_address: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="macAddress", default=None) - ip_mtu: Union[Global[int], Variable, Default[int]] = Field(alias="ipMtu", default=Default[int](value=1500)) + mac_address: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="macAddress", validation_alias="macAddress", default=None + ) + ip_mtu: Union[Global[int], Variable, Default[int]] = Field( + serialization_alias="ipMtu", validation_alias="ipMtu", default=Default[int](value=1500) + ) interface_mtu: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="intrfMtu", default=Default[int](value=1500) + serialization_alias="intrfMtu", validation_alias="intrfMtu", default=Default[int](value=1500) + ) + tcp_mss: Optional[Union[Global[int], Variable, Default[int]]] = Field( + serialization_alias="tcpMss", validation_alias="tcpMss", default=None ) - tcp_mss: Optional[Union[Global[int], Variable, Default[int]]] = Field(alias="tcpMss", default=None) speed: Optional[Union[Global[str], Variable, Default[None]]] = None arp_timeout: Union[Global[int], Variable, Default[int]] = Field( - alias="arpTimeout", default=Default[int](value=1200) + serialization_alias="arpTimeout", validation_alias="arpTimeout", default=Default[int](value=1200) ) autonegotiate: Optional[Union[Global[bool], Variable, Default[bool]]] = None - media_type: Optional[Union[Global[MediaType], Variable, Default[None]]] = Field(alias="mediaType", default=None) + media_type: Optional[Union[Global[MediaType], Variable, Default[None]]] = Field( + serialization_alias="mediaType", validation_alias="mediaType", default=None + ) load_interval: Union[Global[int], Variable, Default[int]] = Field( - alias="loadInterval", default=Default[int](value=30) + serialization_alias="loadInterval", validation_alias="loadInterval", default=Default[int](value=30) ) tracker: Optional[Union[Global[str], Variable, Default[None]]] = None icmp_redirect_disable: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="icmpRedirectDisable", default=Default[bool](value=True) + serialization_alias="icmpRedirectDisable", + validation_alias="icmpRedirectDisable", + default=Default[bool](value=True), ) xconnect: Optional[Union[Global[str], Variable, Default[None]]] = None ip_directed_broadcast: Union[Global[bool], Variable, Default[bool]] = Field( - alias="ipDirectedBroadcast", default=Default[bool](value=False) + serialization_alias="ipDirectedBroadcast", + validation_alias="ipDirectedBroadcast", + default=Default[bool](value=False), ) @@ -214,19 +283,33 @@ class InterfaceEthernetData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) shutdown: Union[Global[bool], Variable, Default[bool]] = Default[bool](value=True) - interface_name: Union[Global[str], Variable] = Field(alias="interfaceName") + interface_name: Union[Global[str], Variable] = Field( + serialization_alias="interfaceName", validation_alias="interfaceName" + ) description: Optional[Union[Global[str], Variable, Default[None]]] = None - interface_ip_address: Union[InterfaceDynamicIPv4Address, InterfaceStaticIPv4Address] = Field(alias="intfIpAddress") - dhcp_helper: Optional[Union[Variable, Global[List[str]], Default[None]]] = Field(alias="dhcpHelper", default=None) + interface_ip_address: Union[InterfaceDynamicIPv4Address, InterfaceStaticIPv4Address] = Field( + serialization_alias="intfIpAddress", validation_alias="intfIpAddress" + ) + dhcp_helper: Optional[Union[Variable, Global[List[str]], Default[None]]] = Field( + serialization_alias="dhcpHelper", validation_alias="dhcpHelper", default=None + ) interface_ipv6_address: Optional[Union[InterfaceDynamicIPv6Address, InterfaceStaticIPv6Address]] = Field( - alias="intfIpV6Address", default=None + serialization_alias="intfIpV6Address", validation_alias="intfIpV6Address", default=None ) nat: Union[Global[bool], Default[bool]] = Default[bool](value=False) - nat_attributes_ipv4: Optional[NatAttributesIPv4] = Field(alias="natAttributesIpv4", default=None) - nat_ipv6: Optional[Union[Global[bool], Default[bool]]] = Field(alias="natIpv6", default=Default[bool](value=False)) - nat_attributes_ipv6: Optional[NatAttributesIPv6] = Field(alias="natAttributesIpv6", default=None) - acl_qos: Optional[AclQos] = Field(alias="aclQos", default=None) - vrrp_ipv6: Optional[List[VrrpIPv6]] = Field(alias="vrrpIpv6", default=None) + nat_attributes_ipv4: Optional[NatAttributesIPv4] = Field( + serialization_alias="natAttributesIpv4", validation_alias="natAttributesIpv4", default=None + ) + nat_ipv6: Optional[Union[Global[bool], Default[bool]]] = Field( + serialization_alias="natIpv6", validation_alias="natIpv6", default=Default[bool](value=False) + ) + nat_attributes_ipv6: Optional[NatAttributesIPv6] = Field( + serialization_alias="natAttributesIpv6", validation_alias="natAttributesIpv6", default=None + ) + acl_qos: Optional[AclQos] = Field(serialization_alias="aclQos", validation_alias="aclQos", default=None) + vrrp_ipv6: Optional[List[VrrpIPv6]] = Field( + serialization_alias="vrrpIpv6", validation_alias="vrrpIpv6", default=None + ) vrrp: Optional[List[VrrpIPv4]] = None arp: Optional[List[Arp]] = None trustsec: Optional[Trustsec] = None diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/gre.py b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/gre.py index 60e474f65..daa3b67bf 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/gre.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/gre.py @@ -1,5 +1,4 @@ -from enum import Enum -from typing import Optional, Union +from typing import Literal, Optional, Union from pydantic import BaseModel, ConfigDict, Field @@ -13,6 +12,11 @@ TunnelApplication, ) +GreTunnelMode = Literal[ + "ipv4", + "ipv6", +] + class GreAddress(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) @@ -21,125 +25,160 @@ class GreAddress(BaseModel): mask: Union[Variable, Global[str]] -class GreTunnelMode(str, Enum): - IPv4 = "ipv4" - IPv6 = "ipv6" - - class TunnelSourceIP(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - tunnel_source: Union[Global[str], Variable] = Field(alias="tunnelSource") + tunnel_source: Union[Global[str], Variable] = Field( + serialization_alias="tunnelSource", validation_alias="tunnelSource" + ) tunnel_route_via: Optional[Union[Global[str], Variable, Default[None]]] = Field( - alias="tunnelRouteVia", default=None + serialization_alias="tunnelRouteVia", validation_alias="tunnelRouteVia", default=None ) class TunnelSourceIPv6(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - tunnel_source_v6: Union[Global[str], Variable] = Field(alias="tunnelSourceV6") + tunnel_source_v6: Union[Global[str], Variable] = Field( + serialization_alias="tunnelSourceV6", validation_alias="tunnelSourceV6" + ) tunnel_route_via: Optional[Union[Global[str], Variable, Default[None]]] = Field( - alias="tunnelRouteVia", default=None + serialization_alias="tunnelRouteVia", validation_alias="tunnelRouteVia", default=None ) class TunnelSourceInterface(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - tunnel_source_interface: Union[Global[str], Variable] = Field(alias="tunnelSourceInterface") + tunnel_source_interface: Union[Global[str], Variable] = Field( + serialization_alias="tunnelSourceInterface", validation_alias="tunnelSourceInterface" + ) tunnel_route_via: Optional[Union[Global[str], Variable, Default[None]]] = Field( - alias="tunnelRouteVia", default=None + serialization_alias="tunnelRouteVia", validation_alias="tunnelRouteVia", default=None ) class GreSourceIp(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_ip: TunnelSourceIP = Field(alias="sourceIp") + source_ip: TunnelSourceIP = Field(serialization_alias="sourceIp", validation_alias="sourceIp") class GreSourceNotLoopback(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_not_loopback: TunnelSourceInterface = Field(alias="sourceNotLoopback") + source_not_loopback: TunnelSourceInterface = Field( + serialization_alias="sourceNotLoopback", validation_alias="sourceNotLoopback" + ) class GreSourceLoopback(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_loopback: TunnelSourceInterface = Field(alias="sourceLoopback") + source_loopback: TunnelSourceInterface = Field( + serialization_alias="sourceLoopback", validation_alias="sourceLoopback" + ) class GreSourceIPv6(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_ipv6: TunnelSourceIPv6 = Field(alias="sourceIpv6") + source_ipv6: TunnelSourceIPv6 = Field(serialization_alias="sourceIpv6", validation_alias="sourceIpv6") class BasicGre(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Optional[Union[Global[str], Variable]] = Field(alias="ifName", default=None) + interface_name: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="ifName", validation_alias="ifName", default=None + ) description: Optional[Union[Global[str], Variable, Default[None]]] = None address: Optional[GreAddress] = None - ipv6_address: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="ipv6Address", default=None) + ipv6_address: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="ipv6Address", validation_alias="ipv6Address", default=None + ) shutdown: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=False) tunnel_protection: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="tunnelProtection", default=Default[bool](value=False) + serialization_alias="tunnelProtection", validation_alias="tunnelProtection", default=Default[bool](value=False) ) tunnel_mode: Optional[Union[Global[GreTunnelMode], Default[GreTunnelMode]]] = Field( - alias="tunnelMode", default=Default[GreTunnelMode](value=GreTunnelMode.IPv4) + serialization_alias="tunnelMode", + validation_alias="tunnelMode", + default=Default[GreTunnelMode](value="ipv4"), ) tunnel_source_type: Optional[Union[GreSourceIp, GreSourceNotLoopback, GreSourceLoopback, GreSourceIPv6]] = Field( - alias="tunnelSourceType", default=None + serialization_alias="tunnelSourceType", validation_alias="tunnelSourceType", default=None + ) + tunnel_destination: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="tunnelDestination", validation_alias="tunnelDestination", default=None + ) + tunnel_destination_v6: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="tunnelDestinationV6", validation_alias="tunnelDestinationV6", default=None ) - tunnel_destination: Optional[Union[Global[str], Variable]] = Field(alias="tunnelDestination", default=None) - tunnel_destination_v6: Optional[Union[Global[str], Variable]] = Field(alias="tunnelDestinationV6", default=None) mtu: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=1500) - mtu_v6: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="mtuV6", default=None) - tcp_mss_adjust: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="tcpMssAdjust", default=None) + mtu_v6: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="mtuV6", validation_alias="mtuV6", default=None + ) + tcp_mss_adjust: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="tcpMssAdjust", validation_alias="tcpMssAdjust", default=None + ) tcp_mss_adjust_v6: Optional[Union[Global[int], Variable, Default[None]]] = Field( - alias="tcpMssAdjustV6", default=None + serialization_alias="tcpMssAdjustV6", validation_alias="tcpMssAdjustV6", default=None ) clear_dont_fragment: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="clearDontFragment", default=Default[bool](value=False) + serialization_alias="clearDontFragment", + validation_alias="clearDontFragment", + default=Default[bool](value=False), ) dpd_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="dpdInterval", default=Default[int](value=10) + serialization_alias="dpdInterval", validation_alias="dpdInterval", default=Default[int](value=10) ) dpd_retries: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="dpdRetries", default=Default[int](value=3) + serialization_alias="dpdRetries", validation_alias="dpdRetries", default=Default[int](value=3) + ) + ike_version: Optional[Union[Global[int], Default[int]]] = Field( + serialization_alias="ikeVersion", validation_alias="ikeVersion", default=Default[int](value=1) ) - ike_version: Optional[Union[Global[int], Default[int]]] = Field(alias="ikeVersion", default=Default[int](value=1)) ike_mode: Optional[Union[Global[IkeMode], Variable, Default[IkeMode]]] = Field( - alias="ikeMode", default=Default[IkeMode](value=IkeMode.MAIN) + serialization_alias="ikeMode", validation_alias="ikeMode", default=Default[IkeMode](value="main") ) ike_rekey_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="ikeRekeyInterval", default=Default[int](value=14400) + serialization_alias="ikeRekeyInterval", validation_alias="ikeRekeyInterval", default=Default[int](value=14400) ) ike_ciphersuite: Optional[Union[Global[IkeCiphersuite], Variable, Default[IkeCiphersuite]]] = Field( - alias="ikeCiphersuite", default=Default[IkeCiphersuite](value=IkeCiphersuite.AES256_CBC_SHA1) + serialization_alias="ikeCiphersuite", + validation_alias="ikeCiphersuite", + default=Default[IkeCiphersuite](value="aes256-cbc-sha1"), ) ike_group: Optional[Union[Global[IkeGroup], Variable, Default[IkeGroup]]] = Field( - alias="ikeGroup", default=Default[IkeGroup](value=IkeGroup.GROUP_16) + serialization_alias="ikeGroup", validation_alias="ikeGroup", default=Default[IkeGroup](value="16") ) pre_shared_secret: Optional[Union[Global[str], Variable, Default[None]]] = Field( - alias="preSharedSecret", default=None + serialization_alias="preSharedSecret", validation_alias="preSharedSecret", default=None + ) + ike_local_id: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="ikeLocalId", validation_alias="ikeLocalId", default=None + ) + ike_remote_id: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="ikeRemoteId", validation_alias="ikeRemoteId", default=None ) - ike_local_id: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="ikeLocalId", default=None) - ike_remote_id: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="ikeRemoteId", default=None) ipsec_rekey_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="ipsecRekeyInterval", default=Default[int](value=3600) + serialization_alias="ipsecRekeyInterval", + validation_alias="ipsecRekeyInterval", + default=Default[int](value=3600), ) ipsec_replay_window: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="ipsecReplayWindow", default=Default[int](value=512) + serialization_alias="ipsecReplayWindow", validation_alias="ipsecReplayWindow", default=Default[int](value=512) ) ipsec_ciphersuite: Optional[Union[Global[IpsecCiphersuite], Variable, Default[IpsecCiphersuite]]] = Field( - alias="ipsecCiphersuite", default=Default[IpsecCiphersuite](value=IpsecCiphersuite.AES256_GCM) + serialization_alias="ipsecCiphersuite", + validation_alias="ipsecCiphersuite", + default=Default[IpsecCiphersuite](value="aes256-gcm"), ) perfect_forward_secrecy: Optional[Union[Global[PfsGroup], Variable, Default[PfsGroup]]] = Field( - alias="perfectForwardSecrecy", default=Default[PfsGroup](value=PfsGroup.GROUP_16) + serialization_alias="perfectForwardSecrecy", + validation_alias="perfectForwardSecrecy", + default=Default[PfsGroup](value="group-16"), ) diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/ipsec.py b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/ipsec.py index 45a0fdd9f..cc92f569d 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/ipsec.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/ipsec.py @@ -1,5 +1,4 @@ -from enum import Enum -from typing import Optional, Union +from typing import Literal, Optional, Union from pydantic import BaseModel, ConfigDict, Field @@ -13,11 +12,11 @@ TunnelApplication, ) - -class IpsecTunnelMode(str, Enum): - IPv4 = "ipv4" - IPv6 = "ipv6" - IPv4_V6_OVERLAY = "ipv4-v6overlay" +IpsecTunnelMode = Literal[ + "ipv4", + "ipv6", + "ipv4-v6overlay", +] class IpsecAddress(BaseModel): @@ -30,66 +29,102 @@ class IpsecAddress(BaseModel): class InterfaceIpsecData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Union[Global[str], Variable] = Field(alias="ifName") + interface_name: Union[Global[str], Variable] = Field(serialization_alias="ifName", validation_alias="ifName") shutdown: Union[Global[bool], Variable, Default[bool]] = Default[bool](value=True) tunnel_mode: Optional[Union[Global[IpsecTunnelMode], Default[IpsecTunnelMode]]] = Field( - alias="tunnelMode", default=Default[IpsecTunnelMode](value=IpsecTunnelMode.IPv4) + serialization_alias="tunnelMode", + validation_alias="tunnelMode", + default=Default[IpsecTunnelMode](value="ipv4"), ) description: Union[Global[str], Variable, Default[None]] = Default[None](value=None) address: Optional[IpsecAddress] = None - ipv6_address: Optional[Union[Global[str], Variable]] = Field(alias="ipv6Address", default=None) - tunnel_source: Optional[IpsecAddress] = Field(alias="tunnelSource", default=None) - tunnel_source_v6: Optional[Union[Global[str], Variable]] = Field(alias="tunnelSourceV6", default=None) - tunnel_source_interface: Optional[Union[Global[str], Variable]] = Field(alias="tunnelSourceInterface", default=None) - tunnel_destination: Optional[IpsecAddress] = Field(alias="tunnelDestination", default=None) - tunnel_destination_v6: Optional[Union[Global[str], Variable]] = Field(alias="tunnelDestinationV6", default=None) + ipv6_address: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="ipv6Address", validation_alias="ipv6Address", default=None + ) + tunnel_source: Optional[IpsecAddress] = Field( + serialization_alias="tunnelSource", validation_alias="tunnelSource", default=None + ) + tunnel_source_v6: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="tunnelSourceV6", validation_alias="tunnelSourceV6", default=None + ) + tunnel_source_interface: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="tunnelSourceInterface", validation_alias="tunnelSourceInterface", default=None + ) + tunnel_destination: Optional[IpsecAddress] = Field( + serialization_alias="tunnelDestination", validation_alias="tunnelDestination", default=None + ) + tunnel_destination_v6: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="tunnelDestinationV6", validation_alias="tunnelDestinationV6", default=None + ) application: Union[Global[TunnelApplication], Variable] tcp_mss_adjust: Union[Global[int], Variable, Default[None]] = Field( - alias="tcpMssAdjust", default=Default[None](value=None) + serialization_alias="tcpMssAdjust", validation_alias="tcpMssAdjust", default=Default[None](value=None) ) tcp_mss_adjust_v6: Union[Global[int], Variable, Default[None]] = Field( - alias="tcpMssAdjustV6", default=Default[None](value=None) + serialization_alias="tcpMssAdjustV6", validation_alias="tcpMssAdjustV6", default=Default[None](value=None) ) clear_dont_fragment: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="clearDontFragment", default=Default[bool](value=False) + serialization_alias="clearDontFragment", + validation_alias="clearDontFragment", + default=Default[bool](value=False), ) mtu: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=1500) - mtu_v6: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="mtuV6", default=None) + mtu_v6: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="mtuV6", validation_alias="mtuV6", default=None + ) dpd_interval: Union[Global[int], Variable, Default[int]] = Field( - alias="dpdInterval", default=Default[int](value=10) + serialization_alias="dpdInterval", validation_alias="dpdInterval", default=Default[int](value=10) + ) + dpd_retries: Union[Global[int], Variable, Default[int]] = Field( + serialization_alias="dpdRetries", validation_alias="dpdRetries", default=Default[int](value=3) + ) + ike_version: Union[Global[int], Default[int]] = Field( + serialization_alias="ikeVersion", validation_alias="ikeVersion", default=Default[int](value=1) ) - dpd_retries: Union[Global[int], Variable, Default[int]] = Field(alias="dpdRetries", default=Default[int](value=3)) - ike_version: Union[Global[int], Default[int]] = Field(alias="ikeVersion", default=Default[int](value=1)) ike_mode: Optional[Union[Global[IkeMode], Variable, Default[IkeMode]]] = Field( - alias="ikeMode", default=Default[IkeMode](value=IkeMode.MAIN) + serialization_alias="ikeMode", validation_alias="ikeMode", default=Default[IkeMode](value="main") ) ike_rekey_interval: Union[Global[int], Variable, Default[int]] = Field( - alias="ikeRekeyInterval", default=Default[int](value=14400) + serialization_alias="ikeRekeyInterval", validation_alias="ikeRekeyInterval", default=Default[int](value=14400) ) ike_ciphersuite: Union[Global[IkeCiphersuite], Variable, Default[IkeCiphersuite]] = Field( - alias="ikeCiphersuite", default=Default[IkeCiphersuite](value=IkeCiphersuite.AES256_CBC_SHA1) + serialization_alias="ikeCiphersuite", + validation_alias="ikeCiphersuite", + default=Default[IkeCiphersuite](value="aes256-cbc-sha1"), ) ike_group: Union[Global[IkeGroup], Variable, Default[IkeGroup]] = Field( - alias="ikeGroup", default=Default[IkeGroup](value=IkeGroup.GROUP_16) + serialization_alias="ikeGroup", validation_alias="ikeGroup", default=Default[IkeGroup](value="16") + ) + pre_shared_secret: Union[Global[str], Variable] = Field( + serialization_alias="preSharedSecret", validation_alias="preSharedSecret" + ) + ike_local_id: Union[Global[str], Variable, Default[None]] = Field( + serialization_alias="ikeLocalId", validation_alias="ikeLocalId" + ) + ike_remote_id: Union[Global[str], Variable, Default[None]] = Field( + serialization_alias="ikeRemoteId", validation_alias="ikeRemoteId" ) - pre_shared_secret: Union[Global[str], Variable] = Field(alias="preSharedSecret") - ike_local_id: Union[Global[str], Variable, Default[None]] = Field(alias="ikeLocalId") - ike_remote_id: Union[Global[str], Variable, Default[None]] = Field(alias="ikeRemoteId") ipsec_rekey_interval: Union[Global[int], Variable, Default[int]] = Field( - alias="ipsecRekeyInterval", default=Default[int](value=3600) + serialization_alias="ipsecRekeyInterval", + validation_alias="ipsecRekeyInterval", + default=Default[int](value=3600), ) ipsec_replay_window: Union[Global[int], Variable, Default[int]] = Field( - alias="ipsecReplayWindow", default=Default[int](value=512) + serialization_alias="ipsecReplayWindow", validation_alias="ipsecReplayWindow", default=Default[int](value=512) ) ipsec_ciphersuite: Union[Global[IpsecCiphersuite], Variable, Default[IpsecCiphersuite]] = Field( - alias="ipsecCiphersuite", default=Default[IpsecCiphersuite](value=IpsecCiphersuite.AES256_GCM) + serialization_alias="ipsecCiphersuite", + validation_alias="ipsecCiphersuite", + default=Default[IpsecCiphersuite](value="aes256-gcm"), ) perfect_forward_secrecy: Union[Global[PfsGroup], Variable, Default[PfsGroup]] = Field( - alias="perfectForwardSecrecy", default=Default[PfsGroup](value=PfsGroup.GROUP_16) + serialization_alias="perfectForwardSecrecy", + validation_alias="perfectForwardSecrecy", + default=Default[PfsGroup](value="group-16"), ) tracker: Optional[Union[Global[str], Variable, Default[None]]] = None tunnel_route_via: Optional[Union[Global[str], Variable, Default[None]]] = Field( - alias="tunnelRouteVia", default=None + serialization_alias="tunnelRouteVia", validation_alias="tunnelRouteVia", default=None ) diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/svi.py b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/svi.py index d16674a97..b624f2735 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/svi.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/svi.py @@ -1,9 +1,9 @@ from typing import List, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId from catalystwan.models.configuration.feature_profile.sdwan.service.lan.common import ( Arp, StaticIPv4Address, @@ -28,17 +28,25 @@ class VrrpIPv6SecondaryAddress(BaseModel): class VrrpIPv4(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - group_id: Union[Variable, Global[int]] = Field(alias="groupId") + group_id: Union[Variable, Global[int]] = Field(serialization_alias="groupId", validation_alias="groupId") priority: Union[Variable, Global[int], Default[int]] = Default[int](value=100) timer: Union[Variable, Global[int], Default[int]] = Default[int](value=1000) - track_omp: Union[Global[bool], Default[bool]] = Field(alias="trackOmp", default=Default[bool](value=False)) - ip_address: Union[Global[str], Variable] = Field(alias="ipAddress") - ip_address_secondary: Optional[List[VrrpIPv4SecondaryAddress]] = Field(alias="ipAddressSecondary") + track_omp: Union[Global[bool], Default[bool]] = Field( + serialization_alias="trackOmp", validation_alias="trackOmp", default=Default[bool](value=False) + ) + ip_address: Union[Global[str], Variable] = Field(serialization_alias="ipAddress", validation_alias="ipAddress") + ip_address_secondary: Optional[List[VrrpIPv4SecondaryAddress]] = Field( + serialization_alias="ipAddressSecondary", validation_alias="ipAddressSecondary" + ) tloc_pref_change: Union[Global[bool], Default[bool]] = Field( - alias="tlocPrefChange", default=Default[bool](value=False) + serialization_alias="tlocPrefChange", validation_alias="tlocPrefChange", default=Default[bool](value=False) + ) + tloc_pref_change_value: Optional[Union[Global[int], Variable]] = Field( + serialization_alias="tlocPrefChangeValue", validation_alias="tlocPrefChangeValue", default=None + ) + tracking_object: Optional[List[VrrpTrackingObject]] = Field( + serialization_alias="trackingObject", validation_alias="trackingObject", default=None ) - tloc_pref_change_value: Optional[Union[Global[int], Variable]] = Field(alias="tlocPrefChangeValue", default=None) - tracking_object: Optional[List[VrrpTrackingObject]] = Field(alias="trackingObject", default=None) prefix_list: Optional[Union[Global[str], Variable, Default[None]]] = Default[None](value=None) @@ -46,11 +54,15 @@ class VrrpIPv4(BaseModel): class VrrpIPv6(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - group_id: Union[Variable, Global[int]] = Field(alias="groupId") + group_id: Union[Variable, Global[int]] = Field(serialization_alias="groupId", validation_alias="groupId") priority: Union[Variable, Global[int], Default[int]] = Default[int](value=100) timer: Union[Variable, Global[int], Default[int]] = Default[int](value=1000) - track_omp: Union[Global[bool], Default[bool]] = Field(alias="trackOmp", default=Default[bool](value=False)) - track_prefix_list: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="trackPrefixList") + track_omp: Union[Global[bool], Default[bool]] = Field( + serialization_alias="trackOmp", validation_alias="trackOmp", default=Default[bool](value=False) + ) + track_prefix_list: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="trackPrefixList", validation_alias="trackPrefixList" + ) ipv6: List[VrrpIPv6Address] ipv6_secondary: Optional[List[VrrpIPv6SecondaryAddress]] @@ -58,7 +70,7 @@ class VrrpIPv6(BaseModel): class Dhcpv6Helper(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - address: Union[Global[str], Variable] = Field(alias="address") + address: Union[Global[str], Variable] = Field(serialization_alias="address", validation_alias="address") vpn: Optional[Union[Global[int], Variable, Default[None]]] = None @@ -66,64 +78,90 @@ class AdvancedSviAttributes(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) tcp_mss: Optional[Union[Global[int], Variable, Default[None]]] = Field( - alias="tcpMss", default=Default[None](value=None) + serialization_alias="tcpMss", validation_alias="tcpMss", default=Default[None](value=None) ) arp_timeout: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="arpTimeout", default=Default[int](value=1200) + serialization_alias="arpTimeout", validation_alias="arpTimeout", default=Default[int](value=1200) ) ip_directed_broadcast: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="ipDirectedBroadcast", default=Default[bool](value=False) + serialization_alias="ipDirectedBroadcast", + validation_alias="ipDirectedBroadcast", + default=Default[bool](value=False), ) icmp_redirect_disable: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="icmpRedirectDisable", default=Default[bool](value=True) + serialization_alias="icmpRedirectDisable", + validation_alias="icmpRedirectDisable", + default=Default[bool](value=True), ) class IPv4Address(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - address: StaticIPv4Address = Field(alias="addressV4") - secondary_address: Optional[List[StaticIPv4Address]] = Field(alias="secondaryAddressV4", default=None) - dhcp_helper: Optional[Union[Global[List[str]], Variable, Default[None]]] = Field(alias="dhcpHelperV4", default=None) + address: StaticIPv4Address = Field(serialization_alias="addressV4", validation_alias="addressV4") + secondary_address: Optional[List[StaticIPv4Address]] = Field( + serialization_alias="secondaryAddressV4", validation_alias="secondaryAddressV4", default=None + ) + dhcp_helper: Optional[Union[Global[List[str]], Variable, Default[None]]] = Field( + serialization_alias="dhcpHelperV4", validation_alias="dhcpHelperV4", default=None + ) class IPv6Address(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - address: Union[Global[str], Variable, Default[None]] = Field(alias="addressV6") - secondary_address: Optional[List[StaticIPv6Address]] = Field(alias="secondaryAddressV6", default=None) - dhcp_helper: Optional[List[Dhcpv6Helper]] = Field(alias="dhcpHelperV6", default=None) + address: Union[Global[str], Variable, Default[None]] = Field( + serialization_alias="addressV6", validation_alias="addressV6" + ) + secondary_address: Optional[List[StaticIPv6Address]] = Field( + serialization_alias="secondaryAddressV6", validation_alias="secondaryAddressV6", default=None + ) + dhcp_helper: Optional[List[Dhcpv6Helper]] = Field( + serialization_alias="dhcpHelperV6", validation_alias="dhcpHelperV6", default=None + ) class AclQos(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - ipv4_acl_egress: Optional[RefId] = Field(alias="ipv4AclEgress", default=None) - ipv4_acl_ingress: Optional[RefId] = Field(alias="ipv4AclIngress", default=None) - ipv6_acl_egress: Optional[RefId] = Field(alias="ipv6AclEgress", default=None) - ipv6_acl_ingress: Optional[RefId] = Field(alias="ipv6AclIngress", default=None) + ipv4_acl_egress: Optional[Global[UUID]] = Field( + serialization_alias="ipv4AclEgress", validation_alias="ipv4AclEgress", default=None + ) + ipv4_acl_ingress: Optional[Global[UUID]] = Field( + serialization_alias="ipv4AclIngress", validation_alias="ipv4AclIngress", default=None + ) + ipv6_acl_egress: Optional[Global[UUID]] = Field( + serialization_alias="ipv6AclEgress", validation_alias="ipv6AclEgress", default=None + ) + ipv6_acl_ingress: Optional[Global[UUID]] = Field( + serialization_alias="ipv6AclIngress", validation_alias="ipv6AclIngress", default=None + ) class InterfaceSviData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) shutdown: Union[Global[bool], Variable, Default[bool]] = Default[bool](value=True) - interface_name: Optional[Union[Global[str], Variable]] = Field(alias="interfaceName") + interface_name: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="interfaceName", validation_alias="interfaceName" + ) description: Optional[Union[Global[str], Variable, Default[None]]] = Default[None](value=None) interface_mtu: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="ifMtu", default=Default[int](value=1500) + serialization_alias="ifMtu", validation_alias="ifMtu", default=Default[int](value=1500) ) ip_mtu: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="ipMtu", default=Default[int](value=1500) + serialization_alias="ipMtu", validation_alias="ipMtu", default=Default[int](value=1500) ) ipv4: Optional[IPv4Address] = None ipv6: Optional[IPv6Address] = None - acl_qos: Optional[AclQos] = Field(alias="aclQos", default=None) + acl_qos: Optional[AclQos] = Field(serialization_alias="aclQos", validation_alias="aclQos", default=None) arp: Optional[List[Arp]] = None vrrp: Optional[List[VrrpIPv4]] = None - vrrp_ipv6: Optional[List[VrrpIPv6]] = Field(alias="vrrpIpv6", default=None) + vrrp_ipv6: Optional[List[VrrpIPv6]] = Field( + serialization_alias="vrrpIpv6", validation_alias="vrrpIpv6", default=None + ) dhcp_client_v6: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="dhcpClientV6", default=Default[bool](value=False) + serialization_alias="dhcpClientV6", validation_alias="dhcpClientV6", default=Default[bool](value=False) ) advanced: AdvancedSviAttributes = AdvancedSviAttributes() diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/vpn.py b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/vpn.py index a25d09dd4..4b4748a8e 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/vpn.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/vpn.py @@ -1,72 +1,137 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId from catalystwan.models.configuration.feature_profile.common import Prefix +ProtocolIPv4 = Literal[ + "bgp", + "ospf", + "opsfv3", + "connected", + "static", + "network", + "aggregate", + "eigrp", + "lisp", + "isis", +] + +ProtocolIPv6 = Literal[ + "BGP", + "OSPF", + "connected", + "static", + "network", + "aggregate", +] + +Region = Literal[ + "core-and-access", + "core", + "access", +] + +NATRoute = Literal[ + "NAT64", + "NAT66", +] + +ServiceType = Literal[ + "FW", + "IDS", + "IDP", + "netsvc1", + "netsvc2", + "netsvc3", + "netsvc4", + "TE", + "appqoe", +] + +ServiceRouteType = Literal[ + "SIG", + "SSE", +] + +Direction = Literal[ + "inside", + "outside", +] + +NATPortForwardProtocol = Literal[ + "TCP", + "UDP", +] + +RouteLeakFromGlobalProtocol = Literal[ + "static", + "connected", + "bgp", + "ospf", +] + +RedistributeToServiceProtocol = Literal[ + "bgp", + "ospf", +] + +RouteLeakFromServiceProtocol = Literal[ + "static", + "connected", + "bgp", + "ospf", +] + +RedistributeToGlobalProtocol = Literal[ + "bgp", + "ospf", +] + class DnsIPv4(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - primary_dns_address_ipv4: Union[Variable, Global[str], Default[None]] = Field(alias="primaryDnsAddressIpv4") - secondary_dns_address_ipv4: Union[Variable, Global[str], Default[None]] = Field(alias="secondaryDnsAddressIpv4") + primary_dns_address_ipv4: Union[Variable, Global[str], Default[None]] = Field( + serialization_alias="primaryDnsAddressIpv4", validation_alias="primaryDnsAddressIpv4" + ) + secondary_dns_address_ipv4: Union[Variable, Global[str], Default[None]] = Field( + serialization_alias="secondaryDnsAddressIpv4", validation_alias="secondaryDnsAddressIpv4" + ) class DnsIPv6(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - primary_dns_address_ipv6: Union[Variable, Global[str], Default[None]] = Field(alias="primaryDnsAddressIpv6") - secondary_dns_address_ipv6: Union[Variable, Global[str], Default[None]] = Field(alias="secondaryDnsAddressIpv6") + primary_dns_address_ipv6: Union[Variable, Global[str], Default[None]] = Field( + serialization_alias="primaryDnsAddressIpv6", validation_alias="primaryDnsAddressIpv6" + ) + secondary_dns_address_ipv6: Union[Variable, Global[str], Default[None]] = Field( + serialization_alias="secondaryDnsAddressIpv6", validation_alias="secondaryDnsAddressIpv6" + ) class HostMapping(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - host_name: Union[Variable, Global[str]] = Field(alias="hostName") - list_of_ip: Union[Variable, Global[str]] = Field(alias="listOfIp") - - -class ProtocolIPv4(str, Enum): - BGP = "bgp" - OSPF = "ospf" - OSPFv3 = "opsfv3" - CONNECTED = "connected" - STATIC = "static" - NETWORK = "network" - AGGREGATE = "aggregate" - EIGRP = "eigrp" - LISP = "lisp" - ISIS = "isis" - - -class ProtocolIPv6(str, Enum): - BGP = "BGP" - OSPF = "OSPF" - CONNECTED = "connected" - STATIC = "static" - NETWORK = "network" - AGGREGATE = "aggregate" - - -class Region(str, Enum): - CORE_AND_ACCESS = "core-and-access" - CORE = "core" - ACCESS = "access" + host_name: Union[Variable, Global[str]] = Field(serialization_alias="hostName", validation_alias="hostName") + list_of_ip: Union[Variable, Global[str]] = Field(serialization_alias="listOfIp", validation_alias="listOfIp") class RoutePrefix(BaseModel): - ip_address: Union[Variable, Global[str]] = Field(alias="ipAddress") - subnet_mask: Union[Variable, Global[str]] = Field(alias="subnetMask") + ip_address: Union[Variable, Global[str]] = Field(serialization_alias="ipAddress", validation_alias="ipAddress") + subnet_mask: Union[Variable, Global[str]] = Field(serialization_alias="subnetMask", validation_alias="subnetMask") class IPv4Prefix(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) prefix: Prefix - aggregate_only: Optional[Union[Global[bool], Default[bool]]] = Field(alias="aggregateOnly", default=None) + aggregate_only: Optional[Union[Global[bool], Default[bool]]] = Field( + serialization_alias="aggregateOnly", validation_alias="aggregateOnly", default=None + ) region: Optional[Union[Variable, Global[Region], Default[str]]] = None @@ -74,23 +139,33 @@ class IPv6Prefix(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) prefix: Union[Global[str], Variable] - aggregate_only: Optional[Union[Global[bool], Default[bool]]] = Field(alias="aggregateOnly", default=None) + aggregate_only: Optional[Union[Global[bool], Default[bool]]] = Field( + serialization_alias="aggregateOnly", validation_alias="aggregateOnly", default=None + ) region: Optional[Union[Variable, Global[Region], Default[str]]] = None class OmpAdvertiseIPv4(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - omp_protocol: Union[Variable, Global[ProtocolIPv4]] = Field(alias="ompProtocol") - route_policy: Optional[Union[Default[None], RefId]] = Field(alias="routePolicy", default=None) + omp_protocol: Union[Variable, Global[ProtocolIPv4]] = Field( + serialization_alias="ompProtocol", validation_alias="ompProtocol" + ) + route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="routePolicy", validation_alias="routePolicy", default=None + ) prefix_list: Optional[List[IPv4Prefix]] = None class OmpAdvertiseIPv6(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - omp_protocol: Union[Variable, Global[ProtocolIPv6]] = Field(alias="ompProtocol") - route_policy: Optional[Union[Default[None], RefId]] = Field(alias="routePolicy", default=None) + omp_protocol: Union[Variable, Global[ProtocolIPv6]] = Field( + serialization_alias="ompProtocol", validation_alias="ompProtocol" + ) + route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="routePolicy", validation_alias="routePolicy", default=None + ) prefix_list: Optional[List[IPv6Prefix]] = None @@ -106,15 +181,17 @@ class IPv4RouteGatewayNextHopWithTracker(BaseModel): address: Union[Variable, Global[str]] distance: Union[Variable, Global[int], Default[int]] = Default[int](value=1) - tracker: Union[RefId, Default[None]] + tracker: Union[Global[UUID], Default[None]] class NextHopContainer(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - next_hop: Optional[List[IPv4RouteGatewayNextHop]] = Field(alias="nextHop", default=None) + next_hop: Optional[List[IPv4RouteGatewayNextHop]] = Field( + serialization_alias="nextHop", validation_alias="nextHop", default=None + ) next_hop_with_tracker: Optional[List[IPv4RouteGatewayNextHopWithTracker]] = Field( - alias="nextHopWithTracker", default=None + serialization_alias="nextHopWithTracker", validation_alias="nextHopWithTracker", default=None ) @@ -128,19 +205,25 @@ class IPv6RouteGatewayNextHop(BaseModel): class NextHopIPv6Container(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - next_hop: Optional[List[IPv6RouteGatewayNextHop]] = Field(alias="nextHop", default=None) + next_hop: Optional[List[IPv6RouteGatewayNextHop]] = Field( + serialization_alias="nextHop", validation_alias="nextHop", default=None + ) class NextHopRouteContainer(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - next_hop_container: NextHopContainer = Field(alias="nextHopContainer") + next_hop_container: NextHopContainer = Field( + serialization_alias="nextHopContainer", validation_alias="nextHopContainer" + ) class NextHopRouteIPv6Container(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - next_hop_container: NextHopIPv6Container = Field(alias="nextHopContainer") + next_hop_container: NextHopIPv6Container = Field( + serialization_alias="nextHopContainer", validation_alias="nextHopContainer" + ) class Null0(BaseModel): @@ -156,11 +239,6 @@ class Null0IPv6(BaseModel): null0: Union[Global[bool], Default[bool]] = Default[bool](value=True) -class NATRoute(str, Enum): - NAT64 = "NAT64" - NAT66 = "NAT66" - - class NAT(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) @@ -196,39 +274,51 @@ class NextHopInterfaceRouteIPv6(BaseModel): class IPStaticRouteInterface(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Union[Variable, Global[str]] = Field(alias="interfaceName") - next_hop: List[NextHopInterfaceRoute] = Field(alias="nextHop") + interface_name: Union[Variable, Global[str]] = Field( + serialization_alias="interfaceName", validation_alias="interfaceName" + ) + next_hop: List[NextHopInterfaceRoute] = Field(serialization_alias="nextHop", validation_alias="nextHop") class IPv6StaticRouteInterface(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Union[Variable, Global[str]] = Field(alias="interfaceName") - next_hop: List[NextHopInterfaceRouteIPv6] = Field(alias="nextHop") + interface_name: Union[Variable, Global[str]] = Field( + serialization_alias="interfaceName", validation_alias="interfaceName" + ) + next_hop: List[NextHopInterfaceRouteIPv6] = Field(serialization_alias="nextHop", validation_alias="nextHop") class InterfaceContainer(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - ip_static_route_interface: List[IPStaticRouteInterface] = Field(alias="ipStaticRouteInterface") + ip_static_route_interface: List[IPStaticRouteInterface] = Field( + serialization_alias="ipStaticRouteInterface", validation_alias="ipStaticRouteInterface" + ) class InterfaceIPv6Container(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - ipv6_static_route_interface: List[IPv6StaticRouteInterface] = Field(alias="ipv6StaticRouteInterface") + ipv6_static_route_interface: List[IPv6StaticRouteInterface] = Field( + serialization_alias="ipv6StaticRouteInterface", validation_alias="ipv6StaticRouteInterface" + ) class InterfaceRouteContainer(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_container: InterfaceContainer = Field(alias="interfaceContainer") + interface_container: InterfaceContainer = Field( + serialization_alias="interfaceContainer", validation_alias="interfaceContainer" + ) class InterfaceRouteIPv6Container(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_container: InterfaceIPv6Container = Field(alias="interfaceContainer") + interface_container: InterfaceIPv6Container = Field( + serialization_alias="interfaceContainer", validation_alias="interfaceContainer" + ) class StaticRouteIPv4(BaseModel): @@ -236,7 +326,7 @@ class StaticRouteIPv4(BaseModel): prefix: RoutePrefix one_of_ip_route: Union[NextHopRouteContainer, Null0, DHCP, StaticRouteVPN, InterfaceRouteContainer] = Field( - alias="oneOfIpRoute" + serialization_alias="oneOfIpRoute", validation_alias="oneOfIpRoute" ) @@ -245,44 +335,33 @@ class StaticRouteIPv6(BaseModel): prefix: RoutePrefix one_of_ip_route: Union[NextHopRouteIPv6Container, Null0IPv6, NAT, InterfaceRouteIPv6Container] = Field( - alias="oneOfIpRoute" + serialization_alias="oneOfIpRoute", validation_alias="oneOfIpRoute" ) -class ServiceType(str, Enum): - FW = "FW" - IDS = "IDS" - IDP = "IDP" - NETSVC1 = "netsvc1" - NETSVC2 = "netsvc2" - NETSVC3 = "netsvc3" - NETSVC4 = "netsvc4" - TE = "TE" - APPQOE = "appqoe" - - class Service(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - service_type: Union[Variable, Global[ServiceType]] = Field(alias="serviceType") - ipv4_addresses: Union[Variable, Global[List[str]]] = Field(alias="ipv4Addresses") + service_type: Union[Variable, Global[ServiceType]] = Field( + serialization_alias="serviceType", validation_alias="serviceType" + ) + ipv4_addresses: Union[Variable, Global[List[str]]] = Field( + serialization_alias="ipv4Addresses", validation_alias="ipv4Addresses" + ) tracking: Union[Variable, Global[bool], Default[bool]] = Default[bool](value=True) -class ServiceRouteType(str, Enum): - SIG = "SIG" - SSE = "SSE" - - class ServiceRoute(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) prefix: Prefix service: Union[Variable, Global[ServiceRouteType], Default[ServiceRouteType]] = Default[ServiceRouteType]( - value=ServiceRouteType.SIG + value="SIG" ) vpn: Global[int] = Global[int](value=0) - sse_instance: Optional[Union[Variable, Global[str]]] = Field(alias="sseInstance", default=None) + sse_instance: Optional[Union[Variable, Global[str]]] = Field( + serialization_alias="sseInstance", validation_alias="sseInstance", default=None + ) class StaticGreRouteIPv4(BaseModel): @@ -300,136 +379,152 @@ class StaticIpsecRouteIPv4(BaseModel): interface: Union[Variable, Global[List[str]], Default[None]] -class Direction(str, Enum): - INSIDE = "inside" - OUTSIDE = "outside" - - class NatPool(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - nat_pool_name: Union[Variable, Global[int]] = Field(alias="natPoolName") - prefix_length: Union[Variable, Global[int]] = Field(alias="prefixLength") - range_start: Union[Variable, Global[str]] = Field(alias="rangeStart") - range_end: Union[Variable, Global[str]] = Field(alias="rangeEnd") + nat_pool_name: Union[Variable, Global[int]] = Field( + serialization_alias="natPoolName", validation_alias="natPoolName" + ) + prefix_length: Union[Variable, Global[int]] = Field( + serialization_alias="prefixLength", validation_alias="prefixLength" + ) + range_start: Union[Variable, Global[str]] = Field(serialization_alias="rangeStart", validation_alias="rangeStart") + range_end: Union[Variable, Global[str]] = Field(serialization_alias="rangeEnd", validation_alias="rangeEnd") overload: Union[Variable, Global[bool], Default[bool]] = Default[bool](value=True) direction: Union[Variable, Global[Direction]] - tracking_object: Optional[dict] = Field(alias="trackingObject", default=None) - - -class NATPortForwardProtocol(str, Enum): - TCP = "TCP" - UDP = "UDP" + tracking_object: Optional[dict] = Field( + serialization_alias="trackingObject", validation_alias="trackingObject", default=None + ) class NatPortForward(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - nat_pool_name: Union[Variable, Global[int], Default[None]] = Field(alias="natPoolName") - source_port: Union[Variable, Global[int]] = Field(alias="sourcePort") - translate_port: Union[Variable, Global[int]] = Field(alias="translatePort") - source_ip: Union[Variable, Global[str]] = Field(alias="sourceIp") - translated_source_ip: Union[Variable, Global[str]] = Field(alias="TranslatedSourceIp") + nat_pool_name: Union[Variable, Global[int], Default[None]] = Field( + serialization_alias="natPoolName", validation_alias="natPoolName" + ) + source_port: Union[Variable, Global[int]] = Field(serialization_alias="sourcePort", validation_alias="sourcePort") + translate_port: Union[Variable, Global[int]] = Field( + serialization_alias="translatePort", validation_alias="translatePort" + ) + source_ip: Union[Variable, Global[str]] = Field(serialization_alias="sourceIp", validation_alias="sourceIp") + translated_source_ip: Union[Variable, Global[str]] = Field( + serialization_alias="TranslatedSourceIp", validation_alias="TranslatedSourceIp" + ) protocol: Union[Variable, Global[NATPortForwardProtocol]] class StaticNat(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - nat_pool_name: Union[Variable, Global[int], Default[None]] = Field(alias="natPoolName") - source_ip: Union[Variable, Global[str]] = Field(alias="sourceIp") - translated_source_ip: Union[Variable, Global[str]] = Field(alias="TranslatedSourceIP") - static_nat_direction: Union[Variable, Global[Direction]] = Field(alias="staticNatDirection") - tracking_object: Optional[dict] = Field(alias="trackingObject", default=None) + nat_pool_name: Union[Variable, Global[int], Default[None]] = Field( + serialization_alias="natPoolName", validation_alias="natPoolName" + ) + source_ip: Union[Variable, Global[str]] = Field(serialization_alias="sourceIp", validation_alias="sourceIp") + translated_source_ip: Union[Variable, Global[str]] = Field( + serialization_alias="TranslatedSourceIP", validation_alias="TranslatedSourceIP" + ) + static_nat_direction: Union[Variable, Global[Direction]] = Field( + serialization_alias="staticNatDirection", validation_alias="staticNatDirection" + ) + tracking_object: Optional[dict] = Field( + serialization_alias="trackingObject", validation_alias="trackingObject", default=None + ) class StaticNatSubnet(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_ip_subnet: Union[Variable, Global[str]] = Field(alias="sourceIpSubnet") - translated_source_ip_subnet: Union[Variable, Global[str]] = Field(alias="TranslatedSourceIpSubnet") - prefix_length: Union[Variable, Global[int]] = Field(alias="prefixLength") - static_nat_direction: Union[Variable, Global[Direction]] = Field(alias="staticNatDirection") - tracking_object: Optional[dict] = Field(alias="trackingObject", default=None) + source_ip_subnet: Union[Variable, Global[str]] = Field( + serialization_alias="sourceIpSubnet", validation_alias="sourceIpSubnet" + ) + translated_source_ip_subnet: Union[Variable, Global[str]] = Field( + serialization_alias="TranslatedSourceIpSubnet", validation_alias="TranslatedSourceIpSubnet" + ) + prefix_length: Union[Variable, Global[int]] = Field( + serialization_alias="prefixLength", validation_alias="prefixLength" + ) + static_nat_direction: Union[Variable, Global[Direction]] = Field( + serialization_alias="staticNatDirection", validation_alias="staticNatDirection" + ) + tracking_object: Optional[dict] = Field( + serialization_alias="trackingObject", validation_alias="trackingObject", default=None + ) class Nat64v4Pool(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - nat64_v4_pool_name: Union[Variable, Global[str]] = Field(alias="nat64V4PoolName") - nat64_v4_pool_range_start: Union[Variable, Global[str]] = Field(alias="nat64V4PoolRangeStart") - nat64_v4_pool_range_end: Union[Variable, Global[str]] = Field(alias="nat64V4PoolRangeEnd") + nat64_v4_pool_name: Union[Variable, Global[str]] = Field( + serialization_alias="nat64V4PoolName", validation_alias="nat64V4PoolName" + ) + nat64_v4_pool_range_start: Union[Variable, Global[str]] = Field( + serialization_alias="nat64V4PoolRangeStart", validation_alias="nat64V4PoolRangeStart" + ) + nat64_v4_pool_range_end: Union[Variable, Global[str]] = Field( + serialization_alias="nat64V4PoolRangeEnd", validation_alias="nat64V4PoolRangeEnd" + ) nat64_v4_pool_overload: Union[Variable, Global[bool], Default[bool]] = Field( - alias="nat64V4PoolOverload", default=Default[bool](value=False) + serialization_alias="nat64V4PoolOverload", + validation_alias="nat64V4PoolOverload", + default=Default[bool](value=False), ) -class RouteLeakFromGlobalProtocol(str, Enum): - STATIC = "static" - CONNECTED = "connected" - BGP = "bgp" - OSPF = "ospf" - - -class RedistributeToServiceProtocol(str, Enum): - BGP = "bgp" - OSPF = "ospf" - - -class RouteLeakFromServiceProtocol(str, Enum): - STATIC = "static" - CONNECTED = "connected" - BGP = "bgp" - OSPF = "ospf" - - -class RedistributeToGlobalProtocol(str, Enum): - BGP = "bgp" - OSPF = "ospf" - - class RedistributeToService(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) protocol: Union[Variable, Global[RedistributeToServiceProtocol]] - policy: Union[Default[None], RefId] + policy: Union[Default[None], Global[UUID]] class RedistributeToGlobal(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) protocol: Union[Variable, Global[RedistributeToGlobalProtocol]] - policy: Union[Default[None], RefId] + policy: Union[Default[None], Global[UUID]] class RouteLeakFromGlobal(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - route_protocol: Union[Variable, Global[RouteLeakFromGlobalProtocol]] = Field(alias="routeProtocol") - route_policy: Optional[Union[Default[None], RefId]] = Field(alias="routePolicy", default=None) + route_protocol: Union[Variable, Global[RouteLeakFromGlobalProtocol]] = Field( + serialization_alias="routeProtocol", validation_alias="routeProtocol" + ) + route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="routePolicy", validation_alias="routePolicy", default=None + ) redistribute_to_protocol: Optional[List[RedistributeToService]] = Field( - alias="redistributeToProtocol", default=None + serialization_alias="redistributeToProtocol", validation_alias="redistributeToProtocol", default=None ) class RouteLeakFromService(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - route_protocol: Union[Variable, Global[RouteLeakFromServiceProtocol]] = Field(alias="routeProtocol") - route_policy: Optional[Union[Default[None], RefId]] = Field(alias="routePolicy", default=None) + route_protocol: Union[Variable, Global[RouteLeakFromServiceProtocol]] = Field( + serialization_alias="routeProtocol", validation_alias="routeProtocol" + ) + route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="routePolicy", validation_alias="routePolicy", default=None + ) redistribute_to_protocol: Optional[List[RedistributeToService]] = Field( - alias="redistributeToProtocol", default=None + serialization_alias="redistributeToProtocol", validation_alias="redistributeToProtocol", default=None ) class RouteLeakBetweenServices(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - source_vpn: Union[Variable, Global[int]] = Field(alias="soureVpn") - route_protocol: Union[Variable, Global[RouteLeakFromServiceProtocol]] = Field(alias="routeProtocol") - route_policy: Optional[Union[Default[None], RefId]] = Field(alias="routePolicy", default=None) + source_vpn: Union[Variable, Global[int]] = Field(serialization_alias="soureVpn", validation_alias="soureVpn") + route_protocol: Union[Variable, Global[RouteLeakFromServiceProtocol]] = Field( + serialization_alias="routeProtocol", validation_alias="routeProtocol" + ) + route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="routePolicy", validation_alias="routePolicy", default=None + ) redistribute_to_protocol: Optional[List[RedistributeToService]] = Field( - alias="redistributeToProtocol", default=None + serialization_alias="redistributeToProtocol", validation_alias="redistributeToProtocol", default=None ) @@ -442,52 +537,94 @@ class RouteTarget(BaseModel): class MplsVpnIPv4RouteTarget(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - import_rt_list: Optional[List[RouteTarget]] = Field(alias="importRtList", default=None) - export_rt_list: Optional[List[RouteTarget]] = Field(alias="exportRtList", default=None) + import_rt_list: Optional[List[RouteTarget]] = Field( + serialization_alias="importRtList", validation_alias="importRtList", default=None + ) + export_rt_list: Optional[List[RouteTarget]] = Field( + serialization_alias="exportRtList", validation_alias="exportRtList", default=None + ) class MplsVpnIPv6RouteTarget(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - import_rt_list: Optional[List[RouteTarget]] = Field(alias="importRtList", default=None) - export_rt_list: Optional[List[RouteTarget]] = Field(alias="exportRtList", default=None) + import_rt_list: Optional[List[RouteTarget]] = Field( + serialization_alias="importRtList", validation_alias="importRtList", default=None + ) + export_rt_list: Optional[List[RouteTarget]] = Field( + serialization_alias="exportRtList", validation_alias="exportRtList", default=None + ) class LanVpnData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - vpn_id: Union[Variable, Global[int], Default[int]] = Field(alias="vpnId") + vpn_id: Union[Variable, Global[int], Default[int]] = Field(serialization_alias="vpnId", validation_alias="vpnId") name: Union[Variable, Global[str], Default[None]] omp_admin_distance: Optional[Union[Variable, Global[int], Default[None]]] = Field( - alias="ompAdminDistance", default=None + serialization_alias="ompAdminDistance", validation_alias="ompAdminDistance", default=None ) omp_admin_distance_ipv6: Optional[Union[Variable, Global[int], Default[None]]] = Field( - alias="ompAdminDistanceIpv6", default=None - ) - dns_ipv4: Optional[DnsIPv4] = Field(alias="dnsIpv4", default=None) - dns_ipv6: Optional[DnsIPv6] = Field(alias="dnsIpv6", default=None) - new_host_mapping: Optional[List[HostMapping]] = Field(alias="newHostMapping", default=None) - omp_advertise_ipv4: Optional[List[OmpAdvertiseIPv4]] = Field(alias="ompAdvertiseIpv4", default=None) - omp_advertise_ipv6: Optional[List[OmpAdvertiseIPv6]] = Field(alias="ompAdvertiseIpv6", default=None) - ipv4_route: Optional[List[StaticRouteIPv4]] = Field(alias="ipv4Route", default=None) - ipv6_route: Optional[List[StaticRouteIPv6]] = Field(alias="ipv6Route", default=None) + serialization_alias="ompAdminDistanceIpv6", validation_alias="ompAdminDistanceIpv6", default=None + ) + dns_ipv4: Optional[DnsIPv4] = Field(serialization_alias="dnsIpv4", validation_alias="dnsIpv4", default=None) + dns_ipv6: Optional[DnsIPv6] = Field(serialization_alias="dnsIpv6", validation_alias="dnsIpv6", default=None) + new_host_mapping: Optional[List[HostMapping]] = Field( + serialization_alias="newHostMapping", validation_alias="newHostMapping", default=None + ) + omp_advertise_ipv4: Optional[List[OmpAdvertiseIPv4]] = Field( + serialization_alias="ompAdvertiseIpv4", validation_alias="ompAdvertiseIpv4", default=None + ) + omp_advertise_ipv6: Optional[List[OmpAdvertiseIPv6]] = Field( + serialization_alias="ompAdvertiseIpv6", validation_alias="ompAdvertiseIpv6", default=None + ) + ipv4_route: Optional[List[StaticRouteIPv4]] = Field( + serialization_alias="ipv4Route", validation_alias="ipv4Route", default=None + ) + ipv6_route: Optional[List[StaticRouteIPv6]] = Field( + serialization_alias="ipv6Route", validation_alias="ipv6Route", default=None + ) service: Optional[List[Service]] = None - service_route: Optional[List[ServiceRoute]] = Field(alias="serviceRoute", default=None) - gre_route: Optional[List[StaticGreRouteIPv4]] = Field(alias="greRoute", default=None) - ipsec_route: Optional[List[StaticIpsecRouteIPv4]] = Field(alias="ipsecRoute", default=None) - nat_pool: Optional[List[NatPool]] = Field(alias="natPool", default=None) - nat_port_forwarding: Optional[List[NatPortForward]] = Field(alias="natPortForwarding", default=None) - static_nat: Optional[List[StaticNat]] = Field(alias="staticNat", default=None) - static_nat_subnet: Optional[List[StaticNatSubnet]] = Field(alias="staticNatSubnet", default=None) - nat64_v4_pool: Optional[List[Nat64v4Pool]] = Field(alias="nat64V4Pool", default=None) - route_leak_from_global: Optional[List[RouteLeakFromGlobal]] = Field(alias="routeLeakFromGlobal", default=None) - route_leak_from_service: Optional[List[RouteLeakFromService]] = Field(alias="routeLeakFromService", default=None) + service_route: Optional[List[ServiceRoute]] = Field( + serialization_alias="serviceRoute", validation_alias="serviceRoute", default=None + ) + gre_route: Optional[List[StaticGreRouteIPv4]] = Field( + serialization_alias="greRoute", validation_alias="greRoute", default=None + ) + ipsec_route: Optional[List[StaticIpsecRouteIPv4]] = Field( + serialization_alias="ipsecRoute", validation_alias="ipsecRoute", default=None + ) + nat_pool: Optional[List[NatPool]] = Field(serialization_alias="natPool", validation_alias="natPool", default=None) + nat_port_forwarding: Optional[List[NatPortForward]] = Field( + serialization_alias="natPortForwarding", validation_alias="natPortForwarding", default=None + ) + static_nat: Optional[List[StaticNat]] = Field( + serialization_alias="staticNat", validation_alias="staticNat", default=None + ) + static_nat_subnet: Optional[List[StaticNatSubnet]] = Field( + serialization_alias="staticNatSubnet", validation_alias="staticNatSubnet", default=None + ) + nat64_v4_pool: Optional[List[Nat64v4Pool]] = Field( + serialization_alias="nat64V4Pool", validation_alias="nat64V4Pool", default=None + ) + route_leak_from_global: Optional[List[RouteLeakFromGlobal]] = Field( + serialization_alias="routeLeakFromGlobal", validation_alias="routeLeakFromGlobal", default=None + ) + route_leak_from_service: Optional[List[RouteLeakFromService]] = Field( + serialization_alias="routeLeakFromService", validation_alias="routeLeakFromService", default=None + ) route_leak_between_services: Optional[List[RouteLeakBetweenServices]] = Field( - alias="routeLeakBetweenServices", default=None + serialization_alias="routeLeakBetweenServices", validation_alias="routeLeakBetweenServices", default=None + ) + mpls_vpn_ipv4_route_target: Optional[MplsVpnIPv4RouteTarget] = Field( + serialization_alias="mplsVpnIpv4RouteTarget", validation_alias="mplsVpnIpv4RouteTarget", default=None + ) + mpls_vpn_ipv6_route_target: Optional[MplsVpnIPv6RouteTarget] = Field( + serialization_alias="mplsVpnIpv6RouteTarget", validation_alias="mplsVpnIpv6RouteTarget", default=None + ) + enable_sdra: Optional[Union[Global[bool], Default[bool]]] = Field( + serialization_alias="enableSdra", validation_alias="enableSdra", default=None ) - mpls_vpn_ipv4_route_target: Optional[MplsVpnIPv4RouteTarget] = Field(alias="mplsVpnIpv4RouteTarget", default=None) - mpls_vpn_ipv6_route_target: Optional[MplsVpnIPv6RouteTarget] = Field(alias="mplsVpnIpv6RouteTarget", default=None) - enable_sdra: Optional[Union[Global[bool], Default[bool]]] = Field(alias="enableSdra", default=None) class LanVpnCreationPayload(BaseModel): diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/multicast.py b/catalystwan/models/configuration/feature_profile/sdwan/service/multicast.py index 1d0cd1347..89f1c8c8d 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/multicast.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/multicast.py @@ -1,10 +1,9 @@ -from enum import Enum from typing import List, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId class LocalConfig(BaseModel): @@ -17,25 +16,35 @@ class LocalConfig(BaseModel): class MulticastBasicAttributes(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - spt_only: Union[Global[bool], Variable, Default[bool]] = Field(alias="sptOnly", default=Default[bool](value=False)) - local_config: LocalConfig = Field(alias="localConfig", default=LocalConfig()) + spt_only: Union[Global[bool], Variable, Default[bool]] = Field( + serialization_alias="sptOnly", validation_alias="sptOnly", default=Default[bool](value=False) + ) + local_config: LocalConfig = Field( + serialization_alias="localConfig", validation_alias="localConfig", default=LocalConfig() + ) class StaticJoin(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - group_address: Union[Global[str], Variable] = Field(alias="groupAddress") + group_address: Union[Global[str], Variable] = Field( + serialization_alias="groupAddress", validation_alias="groupAddress" + ) source_address: Optional[Union[Global[str], Variable, Default[None]]] = Field( - alias="sourceAddress", default=Default[None](value=None) + serialization_alias="sourceAddress", validation_alias="sourceAddress", default=Default[None](value=None) ) class IgmpInterfaceParameters(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Union[Global[str], Variable] = Field(alias="interfaceName") + interface_name: Union[Global[str], Variable] = Field( + serialization_alias="interfaceName", validation_alias="interfaceName" + ) version: Union[Global[int], Default[int]] = Default[int](value=2) - join_group: Optional[List[StaticJoin]] = Field(alias="joinGroup", default=None) + join_group: Optional[List[StaticJoin]] = Field( + serialization_alias="joinGroup", validation_alias="joinGroup", default=None + ) class IgmpAttributes(BaseModel): @@ -51,7 +60,7 @@ class SmmFlag(BaseModel): range: Optional[Union[Global[str], Variable, Default[None]]] = Default[None](value=None) -class SptThreshold(str, Enum): +class SptThreshold: INFINITY = "infinity" ZERO = "0" @@ -59,21 +68,25 @@ class SptThreshold(str, Enum): class SsmAttrubutes(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - ssm_range_config: SmmFlag = Field(alias="ssmRangeConfig") + ssm_range_config: SmmFlag = Field(serialization_alias="ssmRangeConfig", validation_alias="ssmRangeConfig") spt_threshold: Optional[Union[Global[SptThreshold], Variable, Default[SptThreshold]]] = Field( - alias="sptThreshold", default=Default[SptThreshold](value=SptThreshold.ZERO) + serialization_alias="sptThreshold", + validation_alias="sptThreshold", + default=Default[SptThreshold](value=SptThreshold.ZERO), ) class PimInterfaceParameters(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Union[Global[str], Variable] = Field(alias="interfaceName") + interface_name: Union[Global[str], Variable] = Field( + serialization_alias="interfaceName", validation_alias="interfaceName" + ) query_interval: Union[Global[int], Variable, Default[int]] = Field( - alias="queryInterval", default=Default[int](value=30) + serialization_alias="queryInterval", validation_alias="queryInterval", default=Default[int](value=30) ) join_prune_interval: Union[Global[int], Variable, Default[int]] = Field( - alias="joinPruneInterval", default=Default[int](value=60) + serialization_alias="joinPruneInterval", validation_alias="joinPruneInterval", default=Default[int](value=60) ) @@ -81,14 +94,16 @@ class StaticRpAddress(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) address: Union[Global[str], Variable] - access_list: Union[Global[str], Variable] = Field(alias="accessList") + access_list: Union[Global[str], Variable] = Field(serialization_alias="accessList", validation_alias="accessList") override: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=False) class RPAnnounce(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Union[Global[str], Variable] = Field(alias="interfaceName") + interface_name: Union[Global[str], Variable] = Field( + serialization_alias="interfaceName", validation_alias="interfaceName" + ) scope: Union[Global[int], Variable] @@ -96,17 +111,25 @@ class AutoRpAttributes(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) enable_auto_rp_flag: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="enableAutoRPFlag", default=Default[bool](value=False) + serialization_alias="enableAutoRPFlag", validation_alias="enableAutoRPFlag", default=Default[bool](value=False) + ) + send_rp_announce_list: Optional[List[RPAnnounce]] = Field( + serialization_alias="sendRpAnnounceList", validation_alias="sendRpAnnounceList", default=None + ) + send_rp_discovery: Optional[List[RPAnnounce]] = Field( + serialization_alias="sendRpDiscovery", validation_alias="sendRpDiscovery", default=None ) - send_rp_announce_list: Optional[List[RPAnnounce]] = Field(alias="sendRpAnnounceList", default=None) - send_rp_discovery: Optional[List[RPAnnounce]] = Field(alias="sendRpDiscovery", default=None) class RpDiscoveryScope(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Union[Global[str], Variable] = Field(alias="interfaceName") - group_list: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="groupList", default=None) + interface_name: Union[Global[str], Variable] = Field( + serialization_alias="interfaceName", validation_alias="interfaceName" + ) + group_list: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="groupList", validation_alias="groupList", default=None + ) interval: Optional[Union[Global[int], Variable, Default[None]]] = None priority: Optional[Union[Global[int], Variable, Default[None]]] = None @@ -114,19 +137,25 @@ class RpDiscoveryScope(BaseModel): class BsrCandidateAttributes(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Union[Global[str], Variable] = Field(alias="interfaceName") + interface_name: Union[Global[str], Variable] = Field( + serialization_alias="interfaceName", validation_alias="interfaceName" + ) mask: Optional[Union[Global[int], Variable, Default[None]]] = None priority: Optional[Union[Global[int], Variable, Default[None]]] = None accept_rp_candidate: Optional[Union[Global[str], Variable, Default[None]]] = Field( - alias="acceptRpCandidate", default=None + serialization_alias="acceptRpCandidate", validation_alias="acceptRpCandidate", default=None ) class PimBsrAttributes(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - rp_candidate: Optional[List[RpDiscoveryScope]] = Field(alias="rpCandidate", default=None) - bsr_candidate: Optional[List[BsrCandidateAttributes]] = Field(alias="bsdCandidate", default=None) + rp_candidate: Optional[List[RpDiscoveryScope]] = Field( + serialization_alias="rpCandidate", validation_alias="rpCandidate", default=None + ) + bsr_candidate: Optional[List[BsrCandidateAttributes]] = Field( + serialization_alias="bsdCandidate", validation_alias="bsdCandidate", default=None + ) class PimAttributes(BaseModel): @@ -134,50 +163,64 @@ class PimAttributes(BaseModel): ssm: SsmAttrubutes interface: Optional[List[PimInterfaceParameters]] = None - rp_addres: Optional[List[StaticRpAddress]] = Field(alias="rpAddr", default=None) - auto_rp: Optional[AutoRpAttributes] = Field(alias="autoRp", default=None) - pim_bsr: Optional[PimBsrAttributes] = Field(alias="pimBsr", default=None) + rp_addres: Optional[List[StaticRpAddress]] = Field( + serialization_alias="rpAddr", validation_alias="rpAddr", default=None + ) + auto_rp: Optional[AutoRpAttributes] = Field(serialization_alias="autoRp", validation_alias="autoRp", default=None) + pim_bsr: Optional[PimBsrAttributes] = Field(serialization_alias="pimBsr", validation_alias="pimBsr", default=None) class DefaultMsdpPeer(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) default_peer: Union[Global[bool], Default[bool]] - prefix_list: Optional[RefId] = None + prefix_list: Optional[Global[UUID]] = None class MsdpPeerAttributes(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - peer_ip: Union[Global[str], Variable] = Field(alias="peerIp") + peer_ip: Union[Global[str], Variable] = Field(serialization_alias="peerIp", validation_alias="peerIp") connect_source_intf: Optional[Union[Global[str], Variable, Default[None]]] = Field( - alias="connectSourceIntf", default=None + serialization_alias="connectSourceIntf", validation_alias="connectSourceIntf", default=None + ) + remote_as: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="remoteAs", validation_alias="remoteAs", default=None ) - remote_as: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="remoteAs", default=None) password: Optional[Union[Global[str], Variable, Default[None]]] = None keepalive_interval: Optional[Union[Global[int], Variable, Default[None]]] = Field( - alias="keepaliveInterval", default=None + serialization_alias="keepaliveInterval", validation_alias="keepaliveInterval", default=None ) keepalive_holdtime: Optional[Union[Global[int], Variable, Default[None]]] = Field( - alias="keepaliveHoldTime", default=None + serialization_alias="keepaliveHoldTime", validation_alias="keepaliveHoldTime", default=None + ) + sa_limit: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="saLimit", validation_alias="saLimit", default=None ) - sa_limit: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="saLimit", default=None) default: Optional[DefaultMsdpPeer] = None class MsdpPeer(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - mesh_group: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="meshGroup", default=None) + mesh_group: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="meshGroup", validation_alias="meshGroup", default=None + ) peer: List[MsdpPeerAttributes] class MsdpAttributes(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - msdp_list: Optional[List[MsdpPeer]] = Field(alias="msdpList", default=None) - originator_id: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="originatorId", default=None) - refresh_timer: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="refreshTimer", default=None) + msdp_list: Optional[List[MsdpPeer]] = Field( + serialization_alias="msdpList", validation_alias="msdpList", default=None + ) + originator_id: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="originatorId", validation_alias="originatorId", default=None + ) + refresh_timer: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="refreshTimer", validation_alias="refreshTimer", default=None + ) class MulticastData(BaseModel): diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/object_tracker.py b/catalystwan/models/configuration/feature_profile/sdwan/service/object_tracker.py index 8527e89f3..56a022f77 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/object_tracker.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/object_tracker.py @@ -1,33 +1,42 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId +ObjectTrackerType = Literal[ + "Interface", + "SIG", + "Route", +] -class ObjectTrackerType(str, Enum): - INTERFACE = "Interface" - SIG = "SIG" - ROUTE = "Route" + +Criteria = Literal[ + "and", + "or", +] class SigTracker(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - object_id: Union[Global[int], Variable] = Field(alias="objectId") + object_id: Union[Global[int], Variable] = Field(serialization_alias="objectId", validation_alias="objectId") object_tracker_type: Global[ObjectTrackerType] = Field( - alias="objectTrackerType", default=Global[ObjectTrackerType](value=ObjectTrackerType.SIG) + serialization_alias="objectTrackerType", + validation_alias="objectTrackerType", + default=Global[ObjectTrackerType](value="SIG"), ) class InterfaceTracker(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - object_id: Union[Global[int], Variable] = Field(alias="objectId") + object_id: Union[Global[int], Variable] = Field(serialization_alias="objectId", validation_alias="objectId") object_tracker_type: Global[ObjectTrackerType] = Field( - alias="objectTrackerType", default=Global[ObjectTrackerType](value=ObjectTrackerType.INTERFACE) + serialization_alias="objectTrackerType", + validation_alias="objectTrackerType", + default=Global[ObjectTrackerType](value="Interface"), ) interface: Union[Global[str], Variable] @@ -35,12 +44,16 @@ class InterfaceTracker(BaseModel): class RouteTracker(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - object_id: Union[Global[int], Variable] = Field(alias="objectId") + object_id: Union[Global[int], Variable] = Field(serialization_alias="objectId", validation_alias="objectId") object_tracker_type: Global[ObjectTrackerType] = Field( - alias="objectTrackerType", default=Global[ObjectTrackerType](value=ObjectTrackerType.ROUTE) + serialization_alias="objectTrackerType", + validation_alias="objectTrackerType", + default=Global[ObjectTrackerType](value="Route"), + ) + route_ip: Union[Global[str], Variable] = Field(serialization_alias="routeIp", validation_alias="routeIp") + route_mask: Union[Global[str], Variable, Default[str]] = Field( + serialization_alias="routeMask", validation_alias="routeMask" ) - route_ip: Union[Global[str], Variable] = Field(alias="routeIp") - route_mask: Union[Global[str], Variable, Default[str]] = Field(alias="routeMask") vpn: Union[Global[int], Variable, Default[None]] = Default[None](value=None) @@ -55,20 +68,15 @@ class ObjectTrackerCreationPayload(BaseModel): class ObjectTrackerRef(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - tracker_ref: RefId = Field(alias="trackerRef") - - -class Criteria(str, Enum): - AND = "and" - OR = "or" + tracker_ref: Global[UUID] = Field(serialization_alias="trackerRef", validation_alias="trackerRef") class ObjectTrackerGroupData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - object_id: Union[Global[int], Variable] = Field(alias="objectId") - tracker_refs: List[ObjectTrackerRef] = Field(alias="trackerRefs") - criteria: Union[Global[Criteria], Variable, Default[Criteria]] = Default[Criteria](value=Criteria.OR) + object_id: Union[Global[int], Variable] = Field(serialization_alias="objectId", validation_alias="objectId") + tracker_refs: List[ObjectTrackerRef] = Field(serialization_alias="trackerRefs", validation_alias="trackerRefs") + criteria: Union[Global[Criteria], Variable, Default[Criteria]] = Default[Criteria](value="or") class ObjectTrackerGroupCreationPayload(BaseModel): diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/ospf.py b/catalystwan/models/configuration/feature_profile/sdwan/service/ospf.py index f906bab5c..34e446678 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/ospf.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/ospf.py @@ -1,10 +1,39 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId + +NetworkType = Literal[ + "broadcast", + "point-to-point", + "non-broadcast", + "point-to-multipoint", +] + +AuthenticationType = Literal["message-digest"] + +AreaType = Literal[ + "stub", + "nssa", +] + +AdvertiseType = Literal[ + "administrative", + "on-startup", +] + +RedistributeProtocol = Literal[ + "static", + "connected", + "bgp", + "omp", + "nat", + "eigrp", +] + +MetricType = Literal["type1", "type2"] class SummaryPrefix(BaseModel): @@ -19,47 +48,37 @@ class SummaryRoute(BaseModel): address: Optional[SummaryPrefix] = None cost: Optional[Union[Global[int], Variable, Default[None]]] = None - no_advertise: Optional[Union[Global[bool], Variable, Default[bool]]] = Field(alias="noAdvertise", default=None) - - -class NetworkType(str, Enum): - BROADCAST = "broadcast" - POINT_TO_POINT = "point-to-point" - NON_BROADCAST = "non-broadcast" - PONIT_TO_MULTIPOINT = "point-to-multipoint" - - -class AuthenticationType(str, Enum): - MESSAGE_DIGEST = "message-digest" - - -class AreaType(str, Enum): - STUB = "stub" - NSSA = "nssa" + no_advertise: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( + serialization_alias="noAdvertise", validation_alias="noAdvertise", default=None + ) class OspfInterfaceParametres(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) name: Optional[Union[Global[str], Variable]] - hello_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field(alias="helloInterval", default=None) - dead_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field(alias="deadInterval", default=None) + hello_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field( + serialization_alias="helloInterval", validation_alias="helloInterval", default=None + ) + dead_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field( + serialization_alias="deadInterval", validation_alias="deadInterval", default=None + ) retransmit_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="retransmitInterval", default=None + serialization_alias="retransmitInterval", validation_alias="retransmitInterval", default=None ) cost: Optional[Union[Global[int], Variable, Default[None]]] = None priority: Optional[Union[Global[int], Variable, Default[int]]] = None network: Optional[Union[Global[NetworkType], Variable, Default[NetworkType]]] = Default[NetworkType]( - value=NetworkType.BROADCAST + value="broadcast" ) passive_interface: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="passiveInterface", default=None + serialization_alias="passiveInterface", validation_alias="passiveInterface", default=None ) authentication_type: Optional[Union[Global[AuthenticationType], Variable, Default[None]]] = Field( - alias="type", default=None + serialization_alias="type", validation_alias="type", default=None ) message_digest_key: Optional[Union[Global[int], Variable, Default[None]]] = Field( - alias="messageDigestKey", default=None + serialization_alias="messageDigestKey", validation_alias="messageDigestKey", default=None ) md5: Optional[Union[Global[str], Variable, Default[None]]] = None @@ -67,68 +86,71 @@ class OspfInterfaceParametres(BaseModel): class OspfArea(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - area_number: Union[Global[int], Variable] = Field(alias="aNum") - area_type: Optional[Union[Global[AreaType], Default[None]]] = Field(alias="aType", default=None) - no_summary: Optional[Union[Global[bool], Variable, Default[bool]]] = Field(alias="noSummary", default=None) + area_number: Union[Global[int], Variable] = Field(serialization_alias="aNum", validation_alias="aNum") + area_type: Optional[Union[Global[AreaType], Default[None]]] = Field( + serialization_alias="aType", validation_alias="aType", default=None + ) + no_summary: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( + serialization_alias="noSummary", validation_alias="noSummary", default=None + ) interface: Optional[List[OspfInterfaceParametres]] = None range: Optional[List[SummaryRoute]] -class AdvertiseType(str, Enum): - ADMINISTRATIVE = "administrative" - ON_STARTUP = "on-startup" - - class RouterLsa(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - ad_type: Global[AdvertiseType] = Field(alias="adType") + ad_type: Global[AdvertiseType] = Field(serialization_alias="adType", validation_alias="adType") time: Optional[Union[Global[int], Variable]] = None -class RedistributeProtocol(str, Enum): - STATIC = "static" - CONNECTED = "connected" - BGP = "bgp" - OMP = "omp" - NAT = "nat" - EIGRP = "eigrp" - - class RedistributedRoute(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) protocol: Union[Global[RedistributeProtocol], Variable] dia: Optional[Union[Global[bool], Variable, Default[bool]]] = None - route_policy: Optional[Union[Default[None], RefId]] = Field(alias="routePolicy", default=None) - - -class MetricType(str, Enum): - TYPE1 = "type1" - TYPE2 = "type2" + route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="routePolicy", validation_alias="routePolicy", default=None + ) class OspfData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - router_id: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="routerId", default=None) + router_id: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="routerId", validation_alias="routerId", default=None + ) reference_bandwidth: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="referenceBandwidth", default=None + serialization_alias="referenceBandwidth", validation_alias="referenceBandwidth", default=None ) rfc1583: Optional[Union[Global[bool], Variable, Default[bool]]] = None originate: Optional[Union[Global[bool], Default[bool]]] = None always: Optional[Union[Global[bool], Variable, Default[bool]]] = None metric: Optional[Union[Global[int], Variable, Default[None]]] = None - metric_type: Optional[Union[Global[MetricType], Variable, Default[None]]] = Field(alias="metricType", default=None) + metric_type: Optional[Union[Global[MetricType], Variable, Default[None]]] = Field( + serialization_alias="metricType", validation_alias="metricType", default=None + ) external: Optional[Union[Global[int], Variable, Default[int]]] = None - inter_area: Optional[Union[Global[int], Variable, Default[int]]] = Field(alias="interArea", default=None) - intra_area: Optional[Union[Global[int], Variable, Default[int]]] = Field(alias="intraArea", default=None) + inter_area: Optional[Union[Global[int], Variable, Default[int]]] = Field( + serialization_alias="interArea", validation_alias="interArea", default=None + ) + intra_area: Optional[Union[Global[int], Variable, Default[int]]] = Field( + serialization_alias="intraArea", validation_alias="intraArea", default=None + ) delay: Optional[Union[Global[int], Variable, Default[int]]] = None - initial_hold: Optional[Union[Global[int], Variable, Default[int]]] = Field(alias="initialHold", default=None) - max_hold: Optional[Union[Global[int], Variable, Default[int]]] = Field(alias="maxHold", default=None) + initial_hold: Optional[Union[Global[int], Variable, Default[int]]] = Field( + serialization_alias="initialHold", validation_alias="initialHold", default=None + ) + max_hold: Optional[Union[Global[int], Variable, Default[int]]] = Field( + serialization_alias="maxHold", validation_alias="maxHold", default=None + ) redistribute: Optional[List[RedistributedRoute]] = None - router_lsa: Optional[List[RouterLsa]] = Field(alias="routerLsa", default=None) - route_policy: Optional[Union[Default[None], RefId]] = Field(alias="routePolicy", default=None) + router_lsa: Optional[List[RouterLsa]] = Field( + serialization_alias="routerLsa", validation_alias="routerLsa", default=None + ) + route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="routePolicy", validation_alias="routePolicy", default=None + ) area: Optional[List[OspfArea]] = None diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/ospfv3.py b/catalystwan/models/configuration/feature_profile/sdwan/service/ospfv3.py index 43fba91f6..4c05ba240 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/ospfv3.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/ospfv3.py @@ -1,33 +1,53 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId from catalystwan.models.configuration.feature_profile.common import Prefix - -class NetworkType(str, Enum): - BROADCAST = "broadcast" - POINT_TO_POINT = "point-to-point" - NON_BROADCAST = "non-broadcast" - PONIT_TO_MULTIPOINT = "point-to-multipoint" - - -class NoAuthType(str, Enum): - NO_AUTH = "no-auth" - - -class IpsecSha1AuthType(str, Enum): - IPSEC_SHA1 = "ipsec-sha1" +NetworkType = Literal[ + "broadcast", + "point-to-point", + "non-broadcast", + "point-to-multipoint", +] + +NoAuthType = Literal["no-auth"] +IpsecSha1AuthType = Literal["ipsec-sha1"] + +MaxMetricRouterLsaAction = Literal[ + "disabled", + "immediately", + "on-startup", +] + +RedistributeProtocol = Literal[ + "static", + "connected", + "bgp", + "omp", + "nat-route", + "eigrp", +] + +RedistributeProtocolIPv6 = Literal[ + "static", + "connected", + "bgp", + "omp", + "eigrp", +] +MetricType = Literal["type1", "type2"] class NoAuth(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) auth_type: Union[Global[NoAuthType], Default[NoAuthType]] = Field( - alias="authType", default=Default[NoAuthType](value=NoAuthType.NO_AUTH) + serialization_alias="authType", + validation_alias="authType", + default=Default[NoAuthType](value="no-auth"), ) @@ -35,37 +55,47 @@ class IpsecSha1Auth(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) auth_type: Global[IpsecSha1AuthType] = Field( - alias="authType", default=Global[IpsecSha1AuthType](value=IpsecSha1AuthType.IPSEC_SHA1) + serialization_alias="authType", + validation_alias="authType", + default=Global[IpsecSha1AuthType](value="ipsec-sha1"), ) spi: Union[Global[int], Variable] - auth_key: Union[Global[str], Variable] = Field(alias="authKey") + auth_key: Union[Global[str], Variable] = Field(serialization_alias="authKey", validation_alias="authKey") class Ospfv3InterfaceParametres(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - name: Optional[Union[Global[str], Variable]] = Field(alias="ifName") - hello_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field(alias="helloInterval", default=None) - dead_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field(alias="deadInterval", default=None) + name: Optional[Union[Global[str], Variable]] = Field(serialization_alias="ifName", validation_alias="ifName") + hello_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field( + serialization_alias="helloInterval", validation_alias="helloInterval", default=None + ) + dead_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field( + serialization_alias="deadInterval", validation_alias="deadInterval", default=None + ) retransmit_interval: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="retransmitInterval", default=None + serialization_alias="retransmitInterval", validation_alias="retransmitInterval", default=None ) cost: Optional[Union[Global[int], Variable, Default[None]]] = None priority: Optional[Union[Global[int], Variable, Default[int]]] = None network_type: Optional[Union[Global[NetworkType], Variable, Default[None]]] = Field( - alias="networkType", default=None + serialization_alias="networkType", validation_alias="networkType", default=None ) passive_interface: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="passiveInterface", default=None + serialization_alias="passiveInterface", validation_alias="passiveInterface", default=None + ) + authentication_config: Optional[Union[NoAuth, IpsecSha1Auth]] = Field( + serialization_alias="authenticationConfig", validation_alias="authenticationConfig", default=None ) - authentication_config: Optional[Union[NoAuth, IpsecSha1Auth]] = Field(alias="authenticationConfig", default=None) class SummaryRouteIPv6(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) network: Union[Global[str], Variable] - no_advertise: Union[Global[bool], Variable, Default[bool]] = Field(alias="noAdvertise") + no_advertise: Union[Global[bool], Variable, Default[bool]] = Field( + serialization_alias="noAdvertise", validation_alias="noAdvertise" + ) cost: Optional[Union[Global[int], Variable, Default[None]]] = None @@ -74,44 +104,58 @@ class SummaryRoute(BaseModel): network: Optional[Prefix] = None cost: Optional[Union[Global[int], Variable, Default[None]]] = None - no_advertise: Optional[Union[Global[bool], Variable, Default[bool]]] = Field(alias="noAdvertise", default=None) + no_advertise: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( + serialization_alias="noAdvertise", validation_alias="noAdvertise", default=None + ) class StubArea(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - area_type: Global[str] = Field(alias="areaType", default=Global[str](value="stub")) - no_summary: Optional[Union[Global[bool], Variable, Default[bool]]] = Field(alias="noSummary", default=None) + area_type: Global[str] = Field( + serialization_alias="areaType", validation_alias="areaType", default=Global[str](value="stub") + ) + no_summary: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( + serialization_alias="noSummary", validation_alias="noSummary", default=None + ) class NssaArea(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - area_type: Global[str] = Field(alias="areaType", default=Global[str](value="nssa")) - no_summary: Optional[Union[Global[bool], Variable, Default[bool]]] = Field(alias="noSummary", default=None) + area_type: Global[str] = Field( + serialization_alias="areaType", validation_alias="areaType", default=Global[str](value="nssa") + ) + no_summary: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( + serialization_alias="noSummary", validation_alias="noSummary", default=None + ) always_translate: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="alwaysTranslate", default=None + serialization_alias="alwaysTranslate", validation_alias="alwaysTranslate", default=None ) class NormalArea(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - area_type: Global[str] = Field(alias="areaType", default=Global[str](value="normal")) + area_type: Global[str] = Field( + serialization_alias="areaType", validation_alias="areaType", default=Global[str](value="normal") + ) class DefaultArea(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - area_type: Default[None] = Field(alias="areaType", default=Default[None](value=None)) + area_type: Default[None] = Field( + serialization_alias="areaType", validation_alias="areaType", default=Default[None](value=None) + ) class Ospfv3IPv4Area(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - area_number: Union[Global[int], Variable] = Field(alias="areaNum") + area_number: Union[Global[int], Variable] = Field(serialization_alias="areaNum", validation_alias="areaNum") area_type_config: Optional[Union[StubArea, NssaArea, NormalArea, DefaultArea]] = Field( - alias="areaTypeConfig", default=None + serialization_alias="areaTypeConfig", validation_alias="areaTypeConfig", default=None ) interfaces: List[Ospfv3InterfaceParametres] ranges: Optional[List[SummaryRoute]] = None @@ -120,62 +164,42 @@ class Ospfv3IPv4Area(BaseModel): class Ospfv3IPv6Area(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - area_number: Union[Global[int], Variable] = Field(alias="areaNum") + area_number: Union[Global[int], Variable] = Field(serialization_alias="areaNum", validation_alias="areaNum") area_type_config: Optional[Union[StubArea, NssaArea, NormalArea, DefaultArea]] = Field( - alias="areaTypeConfig", default=None + serialization_alias="areaTypeConfig", validation_alias="areaTypeConfig", default=None ) interfaces: List[Ospfv3InterfaceParametres] ranges: Optional[List[SummaryRoute]] = None -class MaxMetricRouterLsaAction(str, Enum): - DISABLED = "disabled" - IMMEDIATELY = "immediately" - ON_STARTUP = "on-startup" - - class MaxMetricRouterLsa(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) action: Global[MaxMetricRouterLsaAction] - on_startup_time: Optional[Union[Global[int], Variable]] = Field(alias="onStartUpTime", default=None) - - -class RedistributeProtocol(str, Enum): - STATIC = "static" - CONNECTED = "connected" - BGP = "bgp" - OMP = "omp" - NAT = "nat-route" - EIGRP = "eigrp" - - -class RedistributeProtocolIPv6(str, Enum): - STATIC = "static" - CONNECTED = "connected" - BGP = "bgp" - OMP = "omp" - EIGRP = "eigrp" - - -class MetricType(str, Enum): - TYPE1 = "type1" - TYPE2 = "type2" + on_startup_time: Optional[Union[Global[int], Variable]] = Field( + serialization_alias="onStartUpTime", validation_alias="onStartUpTime", default=None + ) class RedistributedRoute(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) protocol: Union[Global[RedistributeProtocol], Variable] - nat_dia: Optional[Union[Global[bool], Variable, Default[bool]]] = Field(alias="natDia", default=None) - route_policy: Optional[Union[Default[None], RefId]] = Field(alias="routePolicy", default=None) + nat_dia: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( + serialization_alias="natDia", validation_alias="natDia", default=None + ) + route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="routePolicy", validation_alias="routePolicy", default=None + ) class RedistributedRouteIPv6(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) protocol: Union[Global[RedistributeProtocolIPv6], Variable] - route_policy: Optional[Union[Default[None], RefId]] = Field(alias="routePolicy", default=None) + route_policy: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="routePolicy", validation_alias="routePolicy", default=None + ) class DefaultOriginate(BaseModel): @@ -199,30 +223,36 @@ class AdvancedOspfv3Attributes(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) reference_bandwidth: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="referenceBandwidth", default=None + serialization_alias="referenceBandwidth", validation_alias="referenceBandwidth", default=None ) compatible_rfc1583: Optional[Union[Global[bool], Variable, Default[bool]]] = Field( - alias="compatibleRfc1583", default=None + serialization_alias="compatibleRfc1583", validation_alias="compatibleRfc1583", default=None + ) + default_originate: Optional[DefaultOriginate] = Field( + serialization_alias="defaultOriginate", validation_alias="defaultOriginate", default=None + ) + spf_timers: Optional[SpfTimers] = Field(serialization_alias="spfTimers", validation_alias="spfTimers", default=None) + policy_name: Optional[Union[Default[None], Global[UUID]]] = Field( + serialization_alias="policyName", validation_alias="policyName", default=None ) - default_originate: Optional[DefaultOriginate] = Field(alias="defaultOriginate", default=None) - spf_timers: Optional[SpfTimers] = Field(alias="spfTimers", default=None) - policy_name: Optional[Union[Default[None], RefId]] = Field(alias="policyName", default=None) filter: Optional[Union[Global[bool], Variable, Default[bool]]] = None class BasicOspfv3Attributes(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - router_id: Optional[Union[Global[str], Variable, Default[None]]] = Field(alias="routerId", default=None) + router_id: Optional[Union[Global[str], Variable, Default[None]]] = Field( + serialization_alias="routerId", validation_alias="routerId", default=None + ) distance: Optional[Union[Global[int], Variable, Default[int]]] = None external_distance: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="externalDistance", default=None + serialization_alias="externalDistance", validation_alias="externalDistance", default=None ) inter_area_distance: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="interAreaDistance", default=None + serialization_alias="interAreaDistance", validation_alias="interAreaDistance", default=None ) intra_area_distance: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="intraAreaDistance", default=None + serialization_alias="intraAreaDistance", validation_alias="intraAreaDistance", default=None ) @@ -232,7 +262,9 @@ class Ospfv3IPv4Data(BaseModel): basic: Optional[BasicOspfv3Attributes] = None advanced: Optional[AdvancedOspfv3Attributes] = None redistribute: Optional[RedistributedRoute] = None - max_metric_router_lsa: Optional[MaxMetricRouterLsa] = Field(alias="maxMetricRouterLsa", default=None) + max_metric_router_lsa: Optional[MaxMetricRouterLsa] = Field( + serialization_alias="maxMetricRouterLsa", validation_alias="maxMetricRouterLsa", default=None + ) area: List[Ospfv3IPv4Area] @@ -242,7 +274,9 @@ class Ospfv3IPv6Data(BaseModel): basic: Optional[BasicOspfv3Attributes] = None advanced: Optional[AdvancedOspfv3Attributes] = None redistribute: Optional[RedistributedRouteIPv6] = None - max_metric_router_lsa: Optional[MaxMetricRouterLsa] = Field(alias="maxMetricRouterLsa", default=None) + max_metric_router_lsa: Optional[MaxMetricRouterLsa] = Field( + serialization_alias="maxMetricRouterLsa", validation_alias="maxMetricRouterLsa", default=None + ) area: List[Ospfv3IPv6Area] diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/route_policy.py b/catalystwan/models/configuration/feature_profile/sdwan/service/route_policy.py index 684daf8b6..c4c452c85 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/route_policy.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/route_policy.py @@ -1,86 +1,125 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global -from catalystwan.models.configuration.common import RefId +Action = Literal[ + "reject", + "accept", +] -class Action(str, Enum): - REJECT = "reject" - ACCEPT = "accept" +Protocol = Literal[ + "IPV4", + "IPV6", + "BOTH", +] +Criteria = Literal[ + "or", + "and", + "exact", +] -class Protocol(str, Enum): - IPV4 = "IPV4" - IPV6 = "IPV6" - BOTH = "BOTH" +MetricType = Literal[ + "type1", + "type2", +] - -class Criteria(str, Enum): - OR = "or" - AND = "and" - EXACT = "exact" +Origin = Literal[ + "egp", + "igp", + "incomplete", +] class StandardCommunityList(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - criteria: Union[Global[Criteria], Default[Criteria]] = Default[Criteria](value=Criteria.OR) - standard_community_list: List[RefId] = Field(alias="standardCommunityList") + criteria: Union[Global[Criteria], Default[Criteria]] = Default[Criteria](value="or") + standard_community_list: List[Global[UUID]] = Field( + serialization_alias="standardCommunityList", validation_alias="standardCommunityList" + ) class ExpandedCommunityList(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - expanded_community_list: RefId = Field(alias="expandedCommunityList") + expanded_community_list: Global[UUID] = Field( + serialization_alias="expandedCommunityList", validation_alias="expandedCommunityList" + ) class RoutePolicyMatch(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - as_path_list: Optional[RefId] = Field(alias="asPathList", default=None) + as_path_list: Optional[Global[UUID]] = Field( + serialization_alias="asPathList", validation_alias="asPathList", default=None + ) community_list: Optional[Union[StandardCommunityList, ExpandedCommunityList]] = Field( - alias="communityList", default=None + serialization_alias="communityList", validation_alias="communityList", default=None + ) + ext_community_list: Optional[Global[UUID]] = Field( + serialization_alias="extCommunityList", validation_alias="extCommunityList", default=None + ) + bgp_local_preference: Optional[Global[int]] = Field( + serialization_alias="bgpLocalPreference", validation_alias="bgpLocalPreference", default=None ) - ext_community_list: Optional[RefId] = Field(alias="extCommunityList", default=None) - bgp_local_preference: Optional[Global[int]] = Field(alias="bgpLocalPreference", default=None) metric: Optional[Global[int]] = None - omp_tag: Optional[Global[int]] = Field(alias="ompTag", default=None) - ospf_tag: Optional[Global[int]] = Field(alias="ospfTag", default=None) - ipv4_address: Optional[RefId] = Field(alias="ipv4Address", default=None) - ipv4_nexthop: Optional[RefId] = Field(alias="ipv4NextHop", default=None) - ipv6_address: Optional[RefId] = Field(alias="ipv6Address", default=None) - ipv6_nexthop: Optional[RefId] = Field(alias="ipv6NextHop", default=None) - - -class MetricType(str, Enum): - TYPE1 = "type1" - TYPE2 = "type2" - - -class Origin(str, Enum): - EGP = "egp" - IGP = "igp" - INCOMPLETE = "incomplete" + omp_tag: Optional[Global[int]] = Field(serialization_alias="ompTag", validation_alias="ompTag", default=None) + ospf_tag: Optional[Global[int]] = Field(serialization_alias="ospfTag", validation_alias="ospfTag", default=None) + ipv4_address: Optional[Global[UUID]] = Field( + serialization_alias="ipv4Address", validation_alias="ipv4Address", default=None + ) + ipv4_nexthop: Optional[Global[UUID]] = Field( + serialization_alias="ipv4NextHop", validation_alias="ipv4NextHop", default=None + ) + ipv6_address: Optional[Global[UUID]] = Field( + serialization_alias="ipv6Address", validation_alias="ipv6Address", default=None + ) + ipv6_nexthop: Optional[Global[UUID]] = Field( + serialization_alias="ipv6NextHop", validation_alias="ipv6NextHop", default=None + ) class AcceptAction(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) enable_accept_action: Default[bool] = Default[bool](value=True) - set_as_path: Optional[Global[int]] = Field(alias="setAsPath", default=None) - set_community: Optional[Union[Global[bool], Default[bool]]] = Field(alias="setCommunity", default=None) - set_local_preference: Optional[Global[int]] = Field(alias="setLocalPreference", default=None) - set_metric: Optional[Global[int]] = Field(alias="setMetric", default=None) - set_metric_type: Optional[Global[MetricType]] = Field(alias="setMetricType", default=None) - set_omp_tag: Optional[Global[int]] = Field(alias="setOmpTag", default=None) - set_origin: Optional[Global[Origin]] = Field(alias="setOrigin", default=None) - set_ospf_tag: Optional[Global[int]] = Field(alias="setOspfTag", default=None) - set_weight: Optional[Global[int]] = Field(alias="setWeight", default=None) - set_ipv4_nexthop: Optional[Global[str]] = Field(alias="setIpv4NextHop", default=None) - set_ipv6_nexthop: Optional[Global[str]] = Field(alias="setIpv6NextHop", default=None) + set_as_path: Optional[Global[int]] = Field( + serialization_alias="setAsPath", validation_alias="setAsPath", default=None + ) + set_community: Optional[Union[Global[bool], Default[bool]]] = Field( + serialization_alias="setCommunity", validation_alias="setCommunity", default=None + ) + set_local_preference: Optional[Global[int]] = Field( + serialization_alias="setLocalPreference", validation_alias="setLocalPreference", default=None + ) + set_metric: Optional[Global[int]] = Field( + serialization_alias="setMetric", validation_alias="setMetric", default=None + ) + set_metric_type: Optional[Global[MetricType]] = Field( + serialization_alias="setMetricType", validation_alias="setMetricType", default=None + ) + set_omp_tag: Optional[Global[int]] = Field( + serialization_alias="setOmpTag", validation_alias="setOmpTag", default=None + ) + set_origin: Optional[Global[Origin]] = Field( + serialization_alias="setOrigin", validation_alias="setOrigin", default=None + ) + set_ospf_tag: Optional[Global[int]] = Field( + serialization_alias="setOspfTag", validation_alias="setOspfTag", default=None + ) + set_weight: Optional[Global[int]] = Field( + serialization_alias="setWeight", validation_alias="setWeight", default=None + ) + set_ipv4_nexthop: Optional[Global[str]] = Field( + serialization_alias="setIpv4NextHop", validation_alias="setIpv4NextHop", default=None + ) + set_ipv6_nexthop: Optional[Global[str]] = Field( + serialization_alias="setIpv6NextHop", validation_alias="setIpv6NextHop", default=None + ) class AcceptActions(BaseModel): @@ -98,13 +137,15 @@ class RejectActions(BaseModel): class RoutePolicySequence(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - sequence_id: Global[int] = Field(alias="sequenceId") - sequence_name: Global[str] = Field(alias="sequenceName") + sequence_id: Global[int] = Field(serialization_alias="sequenceId", validation_alias="sequenceId") + sequence_name: Global[str] = Field(serialization_alias="sequenceName", validation_alias="sequenceName") base_action: Union[Global[Action], Default[Action]] = Field( - alias="baseAction", default=Default[Action](value=Action.REJECT) + serialization_alias="baseAction", validation_alias="baseAction", default=Default[Action](value="reject") + ) + protocol: Union[Global[Protocol], Default[Protocol]] = Default[Protocol](value="IPV4") + match_entries: Optional[List[RoutePolicyMatch]] = Field( + serialization_alias="matchEntries", validation_alias="matchEntries", default=None ) - protocol: Union[Global[Protocol], Default[Protocol]] = Default[Protocol](value=Protocol.IPV4) - match_entries: Optional[List[RoutePolicyMatch]] = Field(alias="matchEntries", default=None) actions: Optional[List[Union[AcceptActions, RejectActions]]] = None @@ -112,7 +153,9 @@ class RoutePolicyData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) defautl_action: Union[Global[Action], Default[Action]] = Field( - alias="defaultAction", default=Default[Action](value=Action.REJECT) + serialization_alias="defaultAction", + validation_alias="defaultAction", + default=Default[Action](value="reject"), ) sequences: List[RoutePolicySequence] = [] diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/service_insertion_attachment.py b/catalystwan/models/configuration/feature_profile/sdwan/service/service_insertion_attachment.py index 1348f9bb9..44d6641b4 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/service_insertion_attachment.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/service_insertion_attachment.py @@ -1,57 +1,81 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.profileparcel.traffic_policy import RefId - -class AttachmentType(str, Enum): - CUSTOM = "custom" - AUTO = "auto" - - -class TrafficDirection(str, Enum): - UNIDIR = "UNIDIR" - BIDIR = "BIDIR" +AttachmentType = Literal[ + "custom", + "auto", +] + +TrafficDirection = Literal[ + "UNIDIR", + "BIDIR", +] + +ReachableInterfaceType = Literal[ + "ipv4", + "ipv6", + "tunnel", +] + +TrackType = Literal[ + "service-icmp", + "ipv6-service-icmp", +] + +InterfaceType = Literal[ + "fromservice", + "toservice", +] + +RedundancyType = Literal[ + "active", + "backup", +] + +ServiceType = Literal[ + "Firewall", + "Intrusion-detection", + "Intrusion-detection-prevention", + "NETSVC1", + "NETSVC2", + "NETSVC3", + "NETSVC4", + "NETSVC5", + "NETSVC6", + "NETSVC7", +] class GatewayInterface(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Optional[Union[Global[str], Variable]] = Field(alias="gatewayInterfaceName", default=None) - ip_address: Optional[Union[Global[str], Variable]] = Field(alias="gatewayIpAddress", default=None) - ipv6_address: Optional[Union[Global[str], Variable]] = Field(alias="gatewayIpv6Address", default=None) + interface_name: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="gatewayInterfaceName", validation_alias="gatewayInterfaceName", default=None + ) + ip_address: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="gatewayIpAddress", validation_alias="gatewayIpAddress", default=None + ) + ipv6_address: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="gatewayIpv6Address", validation_alias="gatewayIpv6Address", default=None + ) class ServiceInterface(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Optional[Union[Global[str], Variable]] = Field(alias="serviceInterfaceName", default=None) - ip_address: Optional[Union[Global[str], Variable]] = Field(alias="serviceIpAddress", default=None) - ipv6_address: Optional[Union[Global[str], Variable]] = Field(alias="serviceIpv6Address", default=None) - - -class ReachableInterfaceType(str, Enum): - IPV4 = "ipv4" - IPV6 = "ipv6" - TUNNEL = "tunnel" - - -class TrackType(str, Enum): - SERVICE_ICMP = "service-icmp" - IPV6_SERVICE_ICMP = "ipv6-service-icmp" - - -class InterfaceType(str, Enum): - FROM_SERVICE = "fromservice" - TO_SERVICE = "toservice" - - -class RedundancyType(str, Enum): - ACTIVE = "active" - BACKUP = "backup" + interface_name: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="serviceInterfaceName", validation_alias="serviceInterfaceName", default=None + ) + ip_address: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="serviceIpAddress", validation_alias="serviceIpAddress", default=None + ) + ipv6_address: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="serviceIpv6Address", validation_alias="serviceIpv6Address", default=None + ) class TrackingIP(BaseModel): @@ -64,31 +88,57 @@ class TrackingIP(BaseModel): class ReachableInterface(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - type: Global[ReachableInterfaceType] = Field(alias="reachableInterfaceType") - name: Optional[Union[Global[str], Variable]] = Field(alias="reachableInterfaceName") - ip_address: Optional[Union[Global[str], Variable]] = Field(alias="reachableIpAddress", default=None) - ipv6_address: Optional[Union[Global[str], Variable]] = Field(alias="reachableIpv6Address", default=None) - tracking_ip: Optional[TrackingIP] = Field(alias="trackingIp", default=None) - track_name: Optional[Union[Global[str], Variable]] = Field(alias="trackName", default=None) - track_type: Optional[Union[Global[TrackType], Variable]] = Field(alias="trackType", default=None) + type: Global[ReachableInterfaceType] = Field( + serialization_alias="reachableInterfaceType", validation_alias="reachableInterfaceType" + ) + name: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="reachableInterfaceName", validation_alias="reachableInterfaceName" + ) + ip_address: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="reachableIpAddress", validation_alias="reachableIpAddress", default=None + ) + ipv6_address: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="reachableIpv6Address", validation_alias="reachableIpv6Address", default=None + ) + tracking_ip: Optional[TrackingIP] = Field( + serialization_alias="trackingIp", validation_alias="trackingIp", default=None + ) + track_name: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="trackName", validation_alias="trackName", default=None + ) + track_type: Optional[Union[Global[TrackType], Variable]] = Field( + serialization_alias="trackType", validation_alias="trackType", default=None + ) class InterfaceProperties(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - gateway_interface: Optional[GatewayInterface] = Field(alias="gatewayInterface", default=None) - service_interface: Optional[ServiceInterface] = Field(alias="serviceInterface", default=None) - reachable_interface: Optional[ReachableInterface] = Field(alias="reachableInterface", default=None) - interface_type: Optional[Union[Global[InterfaceType], Variable]] = Field(alias="interfaceType", default=None) - redundancy_type: Optional[Union[Global[RedundancyType], Variable]] = Field(alias="redundancyType", default=None) + gateway_interface: Optional[GatewayInterface] = Field( + serialization_alias="gatewayInterface", validation_alias="gatewayInterface", default=None + ) + service_interface: Optional[ServiceInterface] = Field( + serialization_alias="serviceInterface", validation_alias="serviceInterface", default=None + ) + reachable_interface: Optional[ReachableInterface] = Field( + serialization_alias="reachableInterface", validation_alias="reachableInterface", default=None + ) + interface_type: Optional[Union[Global[InterfaceType], Variable]] = Field( + serialization_alias="interfaceType", validation_alias="interfaceType", default=None + ) + redundancy_type: Optional[Union[Global[RedundancyType], Variable]] = Field( + serialization_alias="redundancyType", validation_alias="redundancyType", default=None + ) class Attachment(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_properties: List[InterfaceProperties] = Field(alias="interfaceProperties") + interface_properties: List[InterfaceProperties] = Field( + serialization_alias="interfaceProperties", validation_alias="interfaceProperties" + ) traffic_direction: Optional[Union[Global[TrafficDirection], Variable]] = Field( - alias="trafficDirection", default=None + serialization_alias="trafficDirection", validation_alias="trafficDirection", default=None ) @@ -100,37 +150,34 @@ class TrackConfig(BaseModel): multiplier: Optional[Union[Global[int], Variable]] = None -class ServiceType(str, Enum): - FIREWALL = "Firewall" - INTRUSION_DETECION = "Intrusion-detection" - INTRUSION_DETECION_PREVENTION = "Intrusion-detection-prevention" - NETSVC1 = "NETSVC1" - NETSVC2 = "NETSVC2" - NETSVC3 = "NETSVC3" - NETSVC4 = "NETSVC4" - NETSVC5 = "NETSVC5" - NETSVC6 = "NETSVC6" - NETSVC7 = "NETSVC7" - - class Service(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - service_type: Union[Global[ServiceType], Variable] = Field(alias="serviceType") - default_track: Optional[Union[Global[bool], Default[bool]]] = Field(alias="defaultTrack", default=None) + service_type: Union[Global[ServiceType], Variable] = Field( + serialization_alias="serviceType", validation_alias="serviceType" + ) + default_track: Optional[Union[Global[bool], Default[bool]]] = Field( + serialization_alias="defaultTrack", validation_alias="defaultTrack", default=None + ) track: Optional[Global[bool]] = None - track_config: Optional[TrackConfig] = Field(alias="trackConfig", default=None) + track_config: Optional[TrackConfig] = Field( + serialization_alias="trackConfig", validation_alias="trackConfig", default=None + ) attachments: Optional[List[Attachment]] = None class ServiceInsertionAttachmentData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - attachment_type: Optional[Union[Global[AttachmentType], Variable]] = Field(alias="attachmentType", default=None) + attachment_type: Optional[Union[Global[AttachmentType], Variable]] = Field( + serialization_alias="attachmentType", validation_alias="attachmentType", default=None + ) service_chain_instance_id: Optional[Union[Global[str], Variable]] = Field( - alias="serviceChainInstanceID", default=None + serialization_alias="serviceChainInstanceID", validation_alias="serviceChainInstanceID", default=None + ) + service_chain_definition_id: Global[UUID] = Field( + serialization_alias="serviceChainDefinitionID", validation_alias="serviceChainDefinitionID" ) - service_chain_definition_id: RefId = Field(alias="serviceChainDefinitionID") vpn: Union[Global[int], Variable] services: Optional[List[Service]] = None diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/switchport.py b/catalystwan/models/configuration/feature_profile/sdwan/service/switchport.py index 1ff2bfc9a..1f28e3c34 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/switchport.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/switchport.py @@ -1,5 +1,4 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union from pydantic import BaseModel, ConfigDict, Field @@ -9,77 +8,94 @@ class StaticMacAddress(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - mac_address: Union[Global[str], Variable] = Field(alias="macaddr") + mac_address: Union[Global[str], Variable] = Field(serialization_alias="macaddr", validation_alias="macaddr") vlan: Union[Global[int], Variable] - interface_name: Optional[Union[Global[str], Variable]] = Field(alias="ifName", default=None) - - -class SwitchportMode(str, Enum): - ACCESS = "access" - TRUNK = "trunk" - - -class Duplex(str, Enum): - FULL = "full" - HALF = "half" + interface_name: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="ifName", validation_alias="ifName", default=None + ) -class PortControl(str, Enum): - AUTO = "auto" - FORCE_UNAUTHORIZED = "force-unauthorized" - FORCE_AUTHORIZED = "force-authorized" +SwitchportMode = Literal[ + "access", + "trunk", +] +Duplex = Literal[ + "full", + "half", +] -class HostMode(str, Enum): - SINGLE_HOST = "single-host" - MULTI_AUTH = "multi-auth" - MULTI_HOST = "multi-host" - MULTI_DOMAIN = "multi-domain" +PortControl = Literal[ + "auto", + "force-unauthorized", + "force-authorized", +] +HostMode = Literal[ + "single-host", + "multi-auth", + "multi-host", + "multi-domain", +] -class ControlDirection(str, Enum): - BOTH = "both" - IN = "in" +ControlDirection = Literal[ + "both", + "in", +] class SwitchportInterface(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - interface_name: Union[Global[str], Variable] = Field(alias="ifName") + interface_name: Union[Global[str], Variable] = Field(serialization_alias="ifName", validation_alias="ifName") mode: Optional[Global[SwitchportMode]] = None shutdown: Optional[Union[Global[bool], Variable, Default[bool]]] = Default[bool](value=True) speed: Optional[Union[Global[str], Variable, Default[None]]] = Default[None](value=None) duplex: Optional[Union[Global[Duplex], Variable, Default[None]]] = Default[None](value=None) switchport_access_vlan: Optional[Union[Global[int], Variable, Default[None]]] = Field( - alias="switchportAccessVlan", default=None + serialization_alias="switchportAccessVlan", validation_alias="switchportAccessVlan", default=None ) switchport_trunk_allowed_vlans: Optional[Union[Global[str], Variable, Default[None]]] = Field( - alias="switchportTrunkAllowedVlans", default=None + serialization_alias="switchportTrunkAllowedVlans", validation_alias="switchportTrunkAllowedVlans", default=None ) switchport_trunk_native_vlan: Optional[Union[Global[int], Variable, Default[None]]] = Field( - alias="switchportTrunkNativeVlan", default=None + serialization_alias="switchportTrunkNativeVlan", validation_alias="switchportTrunkNativeVlan", default=None ) port_control: Optional[Union[Global[PortControl], Variable, Default[None]]] = Field( - alias="portControl", default=None + serialization_alias="portControl", validation_alias="portControl", default=None + ) + voice_vlan: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="voiceVlan", validation_alias="voiceVlan", default=None + ) + pae_enable: Optional[Union[Global[bool], Variable, Default[None]]] = Field( + serialization_alias="paeEnable", validation_alias="paeEnable", default=None ) - voice_vlan: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="voiceVlan", default=None) - pae_enable: Optional[Union[Global[bool], Variable, Default[None]]] = Field(alias="paeEnable", default=None) mac_authentication_bypass: Optional[Union[Global[bool], Variable, Default[None]]] = Field( - alias="macAuthenticationBypass", default=None + serialization_alias="macAuthenticationBypass", validation_alias="macAuthenticationBypass", default=None + ) + host_mode: Optional[Union[Global[HostMode], Variable, Default[None]]] = Field( + serialization_alias="hostMode", validation_alias="hostMode", default=None ) - host_mode: Optional[Union[Global[HostMode], Variable, Default[None]]] = Field(alias="hostMode", default=None) enable_periodic_reauth: Optional[Union[Global[bool], Variable, Default[None]]] = Field( - alias="enablePeriodicReauth", default=None + serialization_alias="enablePeriodicReauth", validation_alias="enablePeriodicReauth", default=None ) inactivity: Optional[Union[Global[int], Variable, Default[None]]] = None reauthentication: Optional[Union[Global[int], Variable, Default[int]]] = None control_direction: Optional[Union[Global[ControlDirection], Variable, Default[None]]] = Field( - alias="controlDirection", default=None + serialization_alias="controlDirection", validation_alias="controlDirection", default=None + ) + restricted_vlan: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="restrictedVlan", validation_alias="restrictedVlan", default=None + ) + guest_vlan: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="guestVlan", validation_alias="guestVlan", default=None + ) + critical_vlan: Optional[Union[Global[int], Variable, Default[None]]] = Field( + serialization_alias="criticalVlan", validation_alias="criticalVlan", default=None + ) + enable_voice: Optional[Union[Global[bool], Variable, Default[None]]] = Field( + serialization_alias="enableVoice", validation_alias="enableVoice", default=None ) - restricted_vlan: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="restrictedVlan", default=None) - guest_vlan: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="guestVlan", default=None) - critical_vlan: Optional[Union[Global[int], Variable, Default[None]]] = Field(alias="criticalVlan", default=None) - enable_voice: Optional[Union[Global[bool], Variable, Default[None]]] = Field(alias="enableVoice", default=None) class SwitchportData(BaseModel): @@ -87,9 +103,11 @@ class SwitchportData(BaseModel): interface: Optional[List[SwitchportInterface]] = None age_time: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="ageTime", default=Default[int](value=300) + serialization_alias="ageTime", validation_alias="ageTime", default=Default[int](value=300) + ) + static_mac_address: Optional[List[StaticMacAddress]] = Field( + serialization_alias="staticMacAddress", validation_alias="staticMacAddress", default=None ) - static_mac_address: Optional[List[StaticMacAddress]] = Field(alias="staticMacAddress", default=None) class SwitchportCreationPayload(BaseModel): diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/tracker.py b/catalystwan/models/configuration/feature_profile/sdwan/service/tracker.py index 35b0c3633..2bf7d4c9a 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/tracker.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/tracker.py @@ -1,15 +1,23 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union +from uuid import UUID from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable -from catalystwan.models.configuration.common import RefId +EndpointProtocol = Literal[ + "tcp", + "udp", +] -class EndpointProtocol(str, Enum): - TCP = "tcp" - UDP = "udp" +TrackerType = Literal["endpoint"] + +EndpointTrackerType = Literal["static-route"] + +CombineBoolean = Literal[ + "and", + "or", +] class EndpointTcpUdp(BaseModel): @@ -19,30 +27,34 @@ class EndpointTcpUdp(BaseModel): port: Optional[Union[Variable, Global[int]]] = None -class TrackerType(str, Enum): - ENDPOINT = "endpoint" - - -class EndpointTrackerType(str, Enum): - STATIC_ROUTE = "static-route" - - class TrackerData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - name: Union[Variable, Global[str]] = Field(alias="trackerName") - endpoint_api_url: Optional[Union[Variable, Global[str]]] = Field(alias="endpointApiUrl", default=None) - endpoint_dns_name: Optional[Union[Variable, Global[str]]] = Field(alias="endpointDnsName", default=None) - endpoint_ip: Optional[Union[Variable, Global[str]]] = Field(alias="endpointIp", default=None) - endpoint_tcp_udp: Optional[EndpointTcpUdp] = Field(alias="endpointTcpUdp", default=None) + name: Union[Variable, Global[str]] = Field(serialization_alias="trackerName", validation_alias="trackerName") + endpoint_api_url: Optional[Union[Variable, Global[str]]] = Field( + serialization_alias="endpointApiUrl", validation_alias="endpointApiUrl", default=None + ) + endpoint_dns_name: Optional[Union[Variable, Global[str]]] = Field( + serialization_alias="endpointDnsName", validation_alias="endpointDnsName", default=None + ) + endpoint_ip: Optional[Union[Variable, Global[str]]] = Field( + serialization_alias="endpointIp", validation_alias="endpointIp", default=None + ) + endpoint_tcp_udp: Optional[EndpointTcpUdp] = Field( + serialization_alias="endpointTcpUdp", validation_alias="endpointTcpUdp", default=None + ) interval: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=60) multiplier: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=3) threshold: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=300) endpoint_tracker_type: Optional[Union[Global[EndpointTrackerType], Variable, Default[EndpointTrackerType]]] = Field( - alias="endpointTrackerType", default=Default[EndpointTrackerType](value=EndpointTrackerType.STATIC_ROUTE) + serialization_alias="endpointTrackerType", + validation_alias="endpointTrackerType", + default=Default[EndpointTrackerType](value="static-route"), ) tracker_type: Optional[Union[Global[TrackerType], Variable, Default[TrackerType]]] = Field( - alias="trackerType", default=Default[TrackerType](value=TrackerType.ENDPOINT) + serialization_alias="trackerType", + validation_alias="trackerType", + default=Default[TrackerType](value="endpoint"), ) @@ -58,20 +70,17 @@ class TrackerCreationPayload(BaseModel): class TrackerRef(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - tracker_ref: RefId = Field(alias="trackerRef") - - -class CombineBoolean(str, Enum): - AND = "and" - OR = "or" + tracker_ref: Global[UUID] = Field(serialization_alias="trackerRef", validation_alias="trackerRef") class TrackerGroupData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - tracker_refs: List[TrackerRef] = Field(alias="trackerRefs") + tracker_refs: List[TrackerRef] = Field(serialization_alias="trackerRefs", validation_alias="trackerRefs") combine_boolean: Union[Global[CombineBoolean], Variable, Default[CombineBoolean]] = Field( - alias="combineBoolean", default=Default[CombineBoolean](value=CombineBoolean.OR) + serialization_alias="combineBoolean", + validation_alias="combineBoolean", + default=Default[CombineBoolean](value="or"), ) @@ -87,4 +96,4 @@ class TrackerGroupCreationPayload(BaseModel): class TrackerAssociationPayload(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - parcel_id: str = Field(alias="parcelId") + parcel_id: str = Field(serialization_alias="parcelId", validation_alias="parcelId") diff --git a/catalystwan/models/configuration/feature_profile/sdwan/service/wireless_lan.py b/catalystwan/models/configuration/feature_profile/sdwan/service/wireless_lan.py index 4415c3ca9..e56979590 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/wireless_lan.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/wireless_lan.py @@ -1,136 +1,135 @@ -from enum import Enum -from typing import List, Optional, Union +from typing import List, Literal, Optional, Union from pydantic import BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable - -class CountryCode(str, Enum): - AE = "AE" - AR = "AR" - AT = "AT" - AU = "AU" - BA = "BA" - BB = "BB" - BE = "BE" - BG = "BG" - BH = "BH" - BN = "BN" - BO = "BO" - BR = "BR" - BY = "BY" - CA = "BA" - CA2 = "CA2" - CH = "CH" - CL = "CL" - CM = "CM" - CN = "CN" - CO = "CO" - CR = "CR" - CY = "CY" - CZ = "CZ" - DE = "DE" - DK = "DK" - DO = "DO" - DZ = "DZ" - EC = "EC" - EE = "EE" - EG = "EG" - ES = "ES" - FI = "FI" - FJ = "FJ" - FR = "FR" - GB = "GB" - GH = "GH" - GI = "GI" - GR = "GR" - HK = "HK" - HR = "HR" - HU = "HU" - ID = "ID" - IE = "IE" - IL = "IL" - IO = "IO" - IN = "IN" - IQ = "IQ" - IS = "IS" - IT = "IT" - J2 = "J2" - J4 = "J4" - JM = "JM" - JO = "JO" - KE = "KE" - KN = "KN" - KW = "KW" - KZ = "KZ" - LB = "LB" - LI = "LI" - LK = "LK" - LT = "LT" - LU = "LU" - LV = "LV" - LY = "LY" - MA = "MA" - MC = "MC" - ME = "ME" - MK = "MK" - MN = "MN" - MO = "MO" - MT = "MT" - MX = "MX" - MY = "MY" - NL = "NL" - NO = "NO" - NZ = "NZ" - OM = "OM" - PA = "PA" - PE = "PE" - PH = "PH" - PH2 = "PH2" - PK = "PK" - PL = "PL" - PR = "PR" - PT = "PT" - PY = "PY" - QA = "QA" - RO = "RO" - RS = "RS" - RU = "RU" - SA = "SA" - SE = "SE" - SG = "SG" - SI = "SI" - SK = "SK" - TH = "TH" - TN = "TN" - TR = "TR" - TW = "TW" - UA = "UA" - US = "US" - UY = "UY" - VE = "VE" - VN = "VN" - ZA = "ZA" - - -class RadioType(str, Enum): - ALL = "all" - GHZ_2_4 = "24ghz" - GHZ_5 = "5ghz" - - -class QosProfile(str, Enum): - PLATINUM = "platinum" - GOLD = "gold" - SILVER = "silver" - BRONZE = "bronze" - - -class SecurityType(str, Enum): - OPEN = "open" - PERSONAL = "personal" - ENTERPRISE = "enterprise" +CountryCode = Literal[ + "AE", + "AR", + "AT", + "AU", + "BA", + "BB", + "BE", + "BG", + "BH", + "BN", + "BO", + "BR", + "BY", + "BA", + "CA2", + "CH", + "CL", + "CM", + "CN", + "CO", + "CR", + "CY", + "CZ", + "DE", + "DK", + "DO", + "DZ", + "EC", + "EE", + "EG", + "ES", + "FI", + "FJ", + "FR", + "GB", + "GH", + "GI", + "GR", + "HK", + "HR", + "HU", + "ID", + "IE", + "IL", + "IO", + "IN", + "IQ", + "IS", + "IT", + "J2", + "J4", + "JM", + "JO", + "KE", + "KN", + "KW", + "KZ", + "LB", + "LI", + "LK", + "LT", + "LU", + "LV", + "LY", + "MA", + "MC", + "ME", + "MK", + "MN", + "MO", + "MT", + "MX", + "MY", + "NL", + "NO", + "NZ", + "OM", + "PA", + "PE", + "PH", + "PH2", + "PK", + "PL", + "PR", + "PT", + "PY", + "QA", + "RO", + "RS", + "RU", + "SA", + "SE", + "SG", + "SI", + "SK", + "TH", + "TN", + "TR", + "TW", + "UA", + "US", + "UY", + "VE", + "VN", + "ZA", +] + +RadioType = Literal[ + "all", + "24ghz", + "5ghz", +] + +QosProfile = Literal[ + "platinum", + "gold", + "silver", + "bronze", +] + +SecurityType = Literal[ + "open", + "personal", + "enterprise", +] class MeStaticIpConfig(BaseModel): @@ -138,14 +137,18 @@ class MeStaticIpConfig(BaseModel): me_ipv4_address: Union[Global[str], Variable] netmask: Union[Global[str], Variable] - default_gateway: Union[Global[str], Variable] = Field(alias="defaultGateway") + default_gateway: Union[Global[str], Variable] = Field( + serialization_alias="defaultGateway", validation_alias="defaultGateway" + ) class MeIpConfig(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) me_dynamic_ip_enabled: Union[Global[bool], Default[bool]] = Field( - alias="meDynamicIpEnabled", default=Default[bool](value=True) + serialization_alias="meDynamicIpEnabled", + validation_alias="meDynamicIpEnabled", + default=Default[bool](value=True), ) me_static_ip_config: Optional[MeStaticIpConfig] = None @@ -153,12 +156,16 @@ class MeIpConfig(BaseModel): class SecurityConfig(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) - security_type: Global[SecurityType] = Field(alias="securityType") - radius_server_ip: Optional[Union[Global[str], Variable]] = Field(alias="radiusServerIp", default=None) + security_type: Global[SecurityType] = Field(serialization_alias="securityType", validation_alias="securityType") + radius_server_ip: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="radiusServerIp", validation_alias="radiusServerIp", default=None + ) radius_server_port: Optional[Union[Global[int], Variable, Default[int]]] = Field( - alias="radiusServerPort", default=None + serialization_alias="radiusServerPort", validation_alias="radiusServerPort", default=None + ) + radius_server_secret: Optional[Union[Global[str], Variable]] = Field( + serialization_alias="radiusServerSecret", validation_alias="radiusServerSecret", default=None ) - radius_server_secret: Optional[Union[Global[str], Variable]] = Field(alias="radiusServerSecret", default=None) passphrase: Optional[Union[Global[str], Variable]] = None @@ -167,18 +174,20 @@ class SSID(BaseModel): name: Global[str] admin_state: Union[Global[bool], Variable, Default[bool]] = Field( - alias="adminState", default=Default[bool](value=True) + serialization_alias="adminState", validation_alias="adminState", default=Default[bool](value=True) ) broadcast_ssid: Union[Global[bool], Variable, Default[bool]] = Field( - alias="broadcastSsid", default=Default[bool](value=True) + serialization_alias="broadcastSsid", validation_alias="broadcastSsid", default=Default[bool](value=True) ) - vlan_id: Union[Global[int], Variable] = Field(alias="vlanId") + vlan_id: Union[Global[int], Variable] = Field(serialization_alias="vlanId", validation_alias="vlanId") radio_type: Union[Global[RadioType], Variable, Default[RadioType]] = Field( - alias="radioType", default=Default[RadioType](value=RadioType.ALL) + serialization_alias="radioType", validation_alias="radioType", default=Default[RadioType](value="all") ) - security_config: SecurityConfig = Field(alias="securityConfig") + security_config: SecurityConfig = Field(serialization_alias="securityConfig", validation_alias="securityConfig") qos_profile: Union[Global[QosProfile], Variable, Default[QosProfile]] = Field( - alias="qosProfile", default=Default[QosProfile](value=QosProfile.SILVER) + serialization_alias="qosProfile", + validation_alias="qosProfile", + default=Default[QosProfile](value="silver"), ) @@ -186,14 +195,18 @@ class WirelessLanData(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) enable_2_4G: Union[Global[bool], Variable, Default[bool]] = Field( - alias="enable24G", default=Default[bool](value=True) + serialization_alias="enable24G", validation_alias="enable24G", default=Default[bool](value=True) + ) + enable_5G: Union[Global[bool], Variable, Default[bool]] = Field( + serialization_alias="enable5G", validation_alias="enable5G", default=Default[bool](value=True) ) - enable_5G: Union[Global[bool], Variable, Default[bool]] = Field(alias="enable5G", default=Default[bool](value=True)) ssid: List[SSID] country: Union[Global[CountryCode], Variable] username: Union[Global[str], Variable] password: Union[Global[str], Variable] - me_ip_config: MeIpConfig = Field(alias="meIpConfig", default=MeIpConfig()) + me_ip_config: MeIpConfig = Field( + serialization_alias="meIpConfig", validation_alias="meIpConfig", default=MeIpConfig() + ) class WirelessLanCreationPayload(BaseModel): diff --git a/catalystwan/models/configuration/feature_profile/sdwan/transport/cellular_controller.py b/catalystwan/models/configuration/feature_profile/sdwan/transport/cellular_controller.py index 9bafe8bee..deb1c0570 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/transport/cellular_controller.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/transport/cellular_controller.py @@ -1,13 +1,10 @@ -from enum import Enum -from typing import Union +from typing import Literal, Union from pydantic import AliasPath, BaseModel, ConfigDict, Field from catalystwan.api.configuration_groups.parcel import Default, Global, Variable, _ParcelBase - -class ConfigTypeValue(Enum): - NON_E_SIM = "non-eSim" +ConfigTypeValue = Literal["non-eSim"] class ControllerConfig(BaseModel): @@ -42,7 +39,7 @@ class ControllerConfig(BaseModel): class CellularController(_ParcelBase): config_type: Default[ConfigTypeValue] = Field( - default=Default(value=ConfigTypeValue.NON_E_SIM), validation_alias=AliasPath("data", "configType") + default=Default(value="non-eSim"), validation_alias=AliasPath("data", "configType") ) controller_config: ControllerConfig = Field(validation_alias=AliasPath("data", "controllerConfig")) diff --git a/catalystwan/models/configuration/profile_type.py b/catalystwan/models/configuration/profile_type.py index e6ebbd62d..f53c8dbd6 100644 --- a/catalystwan/models/configuration/profile_type.py +++ b/catalystwan/models/configuration/profile_type.py @@ -1,8 +1,8 @@ -from enum import Enum +from typing import Literal - -class ProfileType(str, Enum): - TRANSPORT = "transport" - SYSTEM = "system" - CLI = "cli" - SERVICE = "service" +ProfileType = Literal[ + "transport", + "system", + "cli", + "service", +] diff --git a/catalystwan/models/policy/__init__.py b/catalystwan/models/policy/__init__.py index e7f3fbbc4..004df9fb9 100644 --- a/catalystwan/models/policy/__init__.py +++ b/catalystwan/models/policy/__init__.py @@ -1,11 +1,10 @@ -# This stub provide top-level "public" policy models and enums to be used with PolicyAPI() -# TODO: explore model attribute access customization with https://peps.python.org/pep-0562/ +# This stub provide top-level "public" policy models to be used with PolicyAPI() from typing import List, Union from pydantic import Field from typing_extensions import Annotated -from .centralized import CentralizedPolicy, TrafficDataDirectionEnum +from .centralized import CentralizedPolicy, TrafficDataDirection from .definitions.access_control_list import AclPolicy from .definitions.access_control_list_ipv6 import AclIPv6Policy from .definitions.control import ControlPolicy @@ -13,7 +12,7 @@ from .definitions.device_access_ipv6 import DeviceAccessIPv6Policy from .definitions.hub_and_spoke import HubAndSpokePolicy from .definitions.mesh import MeshPolicy -from .definitions.qos_map import QoSDropEnum, QoSMapPolicy +from .definitions.qos_map import QoSDropType, QoSMapPolicy from .definitions.rewrite import RewritePolicy from .definitions.rule_set import RuleSet from .definitions.security_group import SecurityGroup @@ -51,18 +50,18 @@ VPNList, ZoneList, ) -from .lists_entries import EncapEnum, PathPreferenceEnum, PolicerExceedActionEnum +from .lists_entries import EncapType, PathPreference, PolicerExceedAction from .localized import LocalizedPolicy from .policy_definition import ( - CarrierEnum, - DNSTypeEntryEnum, - MultiRegionRoleEnum, - OriginProtocolEnum, - PathTypeEnum, - PLPEntryEnum, - PolicyActionTypeEnum, - ServiceTypeEnum, - TLOCActionEnum, + Carrier, + DNSTypeEntryType, + MultiRegionRole, + OriginProtocol, + PathType, + PLPEntryType, + PolicyActionType, + ServiceType, + TLOCActionType, ) from .security import SecurityPolicy, UnifiedSecurityPolicy @@ -130,7 +129,7 @@ "AppList", "AppProbeClassList", "ASPathList", - "CarrierEnum", + "Carrier", "CentralizedPolicy", "ClassMapList", "ColorList", @@ -140,8 +139,8 @@ "DataPrefixList", "DeviceAccessIPv6Policy", "DeviceAccessPolicy", - "DNSTypeEntryEnum", - "EncapEnum", + "DNSTypeEntryType", + "EncapType", "ExpandedCommunityList", "FQDNList", "GeoLocationList", @@ -153,31 +152,31 @@ "LocalizedPolicy", "MeshPolicy", "MirrorList", - "MultiRegionRoleEnum", - "OriginProtocolEnum", - "PathPreferenceEnum", - "PathTypeEnum", - "PLPEntryEnum", - "PolicerExceedActionEnum", + "MultiRegionRole", + "OriginProtocol", + "PathPreference", + "PathType", + "PLPEntryType", + "PolicerExceedAction", "PolicerList", - "PolicyActionTypeEnum", + "PolicyActionType", "PortList", "PreferredColorGroupList", "PrefixList", "ProtocolNameList", - "QoSDropEnum", + "QoSDropType", "QoSMapPolicy", "RegionList", "RewritePolicy", "RuleSet", "SecurityGroup", "SecurityPolicy", - "ServiceTypeEnum", + "ServiceType", "SiteList", "SLAClassList", - "TLOCActionEnum", + "TLOCActionType", "TLOCList", - "TrafficDataDirectionEnum", + "TrafficDataDirection", "TrafficDataPolicy", "UnifiedSecurityPolicy", "URLBlackList", diff --git a/catalystwan/models/policy/centralized.py b/catalystwan/models/policy/centralized.py index b61ea9b71..c06d188f2 100644 --- a/catalystwan/models/policy/centralized.py +++ b/catalystwan/models/policy/centralized.py @@ -1,4 +1,3 @@ -from enum import Enum from typing import List, Literal, Optional, Union, overload from uuid import UUID @@ -13,21 +12,21 @@ PolicyInfo, ) +TrafficDataDirection = Literal[ + "service", + "tunnel", + "all", +] -class TrafficDataDirectionEnum(str, Enum): - SERVICE = "service" - TUNNEL = "tunnel" - ALL = "all" - - -class ControlDirectionEnum(str, Enum): - IN = "in" - OUT = "out" +ControlDirection = Literal[ + "in", + "out", +] class DataApplicationEntry(BaseModel): model_config = ConfigDict(populate_by_name=True) - direction: TrafficDataDirectionEnum = TrafficDataDirectionEnum.SERVICE + direction: TrafficDataDirection = "service" site_lists: Optional[List[UUID]] = Field( default=None, serialization_alias="siteLists", validation_alias="siteLists" ) @@ -46,7 +45,7 @@ class DataApplicationEntry(BaseModel): class ControlApplicationEntry(BaseModel): model_config = ConfigDict(populate_by_name=True) - direction: ControlDirectionEnum + direction: ControlDirection site_lists: Optional[List[UUID]] = Field( default=None, serialization_alias="siteLists", validation_alias="siteLists" ) @@ -61,11 +60,11 @@ class ControlPolicyItem(AssemblyItemBase): entries: List[ControlApplicationEntry] = [] def assign_to_inbound_sites(self, site_lists: List[UUID]) -> None: - entry = ControlApplicationEntry(direction=ControlDirectionEnum.IN, site_lists=site_lists) + entry = ControlApplicationEntry(direction="in", site_lists=site_lists) self.entries.append(entry) def assign_to_outbound_sites(self, site_lists: List[UUID]) -> None: - entry = ControlApplicationEntry(direction=ControlDirectionEnum.IN, site_lists=site_lists) + entry = ControlApplicationEntry(direction="in", site_lists=site_lists) self.entries.append(entry) @overload @@ -80,9 +79,7 @@ def assign_to_inbound_regions( self, *, region_ids: Optional[List[int]] = None, region_lists: Optional[List[UUID]] = None ) -> None: _region_ids = [str(rid) for rid in region_ids] if region_ids else None - entry = entry = ControlApplicationEntry( - direction=ControlDirectionEnum.IN, region_ids=_region_ids, region_lists=region_lists - ) + entry = entry = ControlApplicationEntry(direction="in", region_ids=_region_ids, region_lists=region_lists) self.entries.append(entry) @overload @@ -97,9 +94,7 @@ def assign_to_outbound_regions( self, *, region_ids: Optional[List[int]] = None, region_lists: Optional[List[UUID]] = None ) -> None: _region_ids = [str(rid) for rid in region_ids] if region_ids else None - entry = entry = ControlApplicationEntry( - direction=ControlDirectionEnum.OUT, region_ids=_region_ids, region_lists=region_lists - ) + entry = entry = ControlApplicationEntry(direction="out", region_ids=_region_ids, region_lists=region_lists) self.entries.append(entry) @@ -111,7 +106,7 @@ class TrafficDataPolicyItem(AssemblyItemBase): def assign_to( self, vpn_lists: List[UUID], - direction: TrafficDataDirectionEnum = TrafficDataDirectionEnum.SERVICE, + direction: TrafficDataDirection = "service", *, site_lists: List[UUID], ) -> None: @@ -121,7 +116,7 @@ def assign_to( def assign_to( self, vpn_lists: List[UUID], - direction: TrafficDataDirectionEnum = TrafficDataDirectionEnum.SERVICE, + direction: TrafficDataDirection = "service", *, region_lists: List[UUID], ) -> None: @@ -131,7 +126,7 @@ def assign_to( def assign_to( self, vpn_lists: List[UUID], - direction: TrafficDataDirectionEnum = TrafficDataDirectionEnum.SERVICE, + direction: TrafficDataDirection = "service", *, region_ids: List[int], ) -> None: @@ -140,7 +135,7 @@ def assign_to( def assign_to( self, vpn_lists: List[UUID], - direction: TrafficDataDirectionEnum = TrafficDataDirectionEnum.SERVICE, + direction: TrafficDataDirection = "service", *, site_lists: Optional[List[UUID]] = None, region_lists: Optional[List[UUID]] = None, diff --git a/catalystwan/models/policy/definitions/access_control_list.py b/catalystwan/models/policy/definitions/access_control_list.py index 4e13c2558..48e6f6a27 100644 --- a/catalystwan/models/policy/definitions/access_control_list.py +++ b/catalystwan/models/policy/definitions/access_control_list.py @@ -21,14 +21,12 @@ NextHopEntry, PacketLengthEntry, PLPEntry, - PLPEntryEnum, PolicerAction, - PolicyActionTypeEnum, + PolicyActionType, PolicyDefinitionBase, PolicyDefinitionSequenceBase, ProtocolEntry, Reference, - SequenceIpType, SourceDataPrefixListEntry, SourceIPEntry, SourcePortEntry, @@ -69,8 +67,8 @@ class AclPolicySequence(PolicyDefinitionSequenceBase): sequence_type: Literal["acl"] = Field( default="acl", serialization_alias="sequenceType", validation_alias="sequenceType" ) - base_action: PolicyActionTypeEnum = Field( - default=PolicyActionTypeEnum.ACCEPT, serialization_alias="baseAction", validation_alias="baseAction" + base_action: PolicyActionType = Field( + default="accept", serialization_alias="baseAction", validation_alias="baseAction" ) match: AclPolicySequenceMatch = AclPolicySequenceMatch() actions: List[AclPolicySequenceActions] = [] @@ -83,10 +81,10 @@ def match_packet_length(self, packet_lengths: Tuple[int, int]) -> None: self._insert_match(PacketLengthEntry.from_range(packet_lengths)) def match_low_plp(self) -> None: - self._insert_match(PLPEntry(value=PLPEntryEnum.LOW)) + self._insert_match(PLPEntry(value="low")) def match_high_plp(self) -> None: - self._insert_match(PLPEntry(value=PLPEntryEnum.HIGH)) + self._insert_match(PLPEntry(value="high")) def match_protocols(self, protocols: Set[int]) -> None: self._insert_match(ProtocolEntry.from_protocol_set(protocols)) @@ -145,19 +143,19 @@ def associate_policer_list_action(self, policer_list_id: UUID) -> None: class AclPolicy(AclPolicyHeader, DefinitionWithSequencesCommonBase): sequences: List[AclPolicySequence] = [] default_action: DefaultAction = Field( - default=DefaultAction(type=PolicyActionTypeEnum.DROP), + default=DefaultAction(type="drop"), serialization_alias="defaultAction", validation_alias="defaultAction", ) model_config = ConfigDict(populate_by_name=True) def add_acl_sequence( - self, name: str = "Access Control List", base_action: PolicyActionTypeEnum = PolicyActionTypeEnum.ACCEPT + self, name: str = "Access Control List", base_action: PolicyActionType = "accept" ) -> AclPolicySequence: seq = AclPolicySequence( sequence_name=name, base_action=base_action, - sequence_ip_type=SequenceIpType.IPV4, + sequence_ip_type="ipv4", ) self.add(seq) return seq diff --git a/catalystwan/models/policy/definitions/access_control_list_ipv6.py b/catalystwan/models/policy/definitions/access_control_list_ipv6.py index 9408d7e20..ee3784e9d 100644 --- a/catalystwan/models/policy/definitions/access_control_list_ipv6.py +++ b/catalystwan/models/policy/definitions/access_control_list_ipv6.py @@ -21,13 +21,11 @@ NextHopEntry, PacketLengthEntry, PLPEntry, - PLPEntryEnum, PolicerAction, - PolicyActionTypeEnum, + PolicyActionType, PolicyDefinitionBase, PolicyDefinitionSequenceBase, Reference, - SequenceIpType, SourceDataIPv6PrefixListEntry, SourceIPv6Entry, SourcePortEntry, @@ -69,8 +67,8 @@ class AclIPv6PolicySequence(PolicyDefinitionSequenceBase): sequence_type: Literal["aclv6"] = Field( default="aclv6", serialization_alias="sequenceType", validation_alias="sequenceType" ) - base_action: PolicyActionTypeEnum = Field( - default=PolicyActionTypeEnum.ACCEPT, serialization_alias="baseAction", validation_alias="baseAction" + base_action: PolicyActionType = Field( + default="accept", serialization_alias="baseAction", validation_alias="baseAction" ) match: AclIPv6PolicySequenceMatch = AclIPv6PolicySequenceMatch() actions: List[AclIPv6PolicySequenceActions] = [] @@ -83,10 +81,10 @@ def match_packet_length(self, packet_lengths: Tuple[int, int]) -> None: self._insert_match(PacketLengthEntry.from_range(packet_lengths)) def match_low_plp(self) -> None: - self._insert_match(PLPEntry(value=PLPEntryEnum.LOW)) + self._insert_match(PLPEntry(value="low")) def match_high_plp(self) -> None: - self._insert_match(PLPEntry(value=PLPEntryEnum.HIGH)) + self._insert_match(PLPEntry(value="high")) def match_source_data_prefix_list(self, data_prefix_list_id: UUID) -> None: self._insert_match(SourceDataIPv6PrefixListEntry(ref=data_prefix_list_id)) @@ -145,19 +143,19 @@ def associate_policer_list_action(self, policer_list_id: UUID) -> None: class AclIPv6Policy(AclIPv6PolicyHeader, DefinitionWithSequencesCommonBase): sequences: List[AclIPv6PolicySequence] = [] default_action: DefaultAction = Field( - default=DefaultAction(type=PolicyActionTypeEnum.DROP), + default=DefaultAction(type="drop"), serialization_alias="defaultAction", validation_alias="defaultAction", ) model_config = ConfigDict(populate_by_name=True) def add_acl_sequence( - self, name: str = "Access Control List", base_action: PolicyActionTypeEnum = PolicyActionTypeEnum.ACCEPT + self, name: str = "Access Control List", base_action: PolicyActionType = "accept" ) -> AclIPv6PolicySequence: seq = AclIPv6PolicySequence( sequence_name=name, base_action=base_action, - sequence_ip_type=SequenceIpType.IPV6, + sequence_ip_type="ipv6", ) self.add(seq) return seq diff --git a/catalystwan/models/policy/definitions/control.py b/catalystwan/models/policy/definitions/control.py index 2fa116d9a..06fe38acd 100644 --- a/catalystwan/models/policy/definitions/control.py +++ b/catalystwan/models/policy/definitions/control.py @@ -5,12 +5,12 @@ from pydantic import ConfigDict, Field from typing_extensions import Annotated -from catalystwan.models.common import TLOCColorEnum -from catalystwan.models.policy.lists_entries import EncapEnum +from catalystwan.models.common import TLOCColor +from catalystwan.models.policy.lists_entries import EncapType from catalystwan.models.policy.policy_definition import ( AffinityEntry, + Carrier, CarrierEntry, - CarrierEnum, ColorListEntry, CommunityAdditiveEntry, CommunityEntry, @@ -22,14 +22,14 @@ ExportToAction, GroupIDEntry, Match, - MultiRegionRoleEnum, + MultiRegionRole, OMPTagEntry, OriginatorEntry, OriginEntry, - OriginProtocolEnum, + OriginProtocol, + PathType, PathTypeEntry, - PathTypeEnum, - PolicyActionTypeEnum, + PolicyActionType, PolicyDefinitionBase, PolicyDefinitionSequenceBase, PreferenceEntry, @@ -37,14 +37,13 @@ RegionEntry, RegionListEntry, RoleEntry, - SequenceIpType, ServiceEntry, ServiceEntryValue, - ServiceTypeEnum, + ServiceType, SiteEntry, SiteListEntry, TLOCActionEntry, - TLOCActionEnum, + TLOCActionType, TLOCEntry, TLOCEntryValue, TLOCListEntry, @@ -118,8 +117,8 @@ class ControlPolicyRouteSequence(PolicyDefinitionSequenceBase): sequence_type: Literal["route"] = Field( default="route", serialization_alias="sequenceType", validation_alias="sequenceType" ) - base_action: PolicyActionTypeEnum = Field( - default=PolicyActionTypeEnum.REJECT, serialization_alias="baseAction", validation_alias="baseAction" + base_action: PolicyActionType = Field( + default="reject", serialization_alias="baseAction", validation_alias="baseAction" ) match: ControlPolicyRouteSequenceMatch = ControlPolicyRouteSequenceMatch() actions: List[ControlPolicyRouteSequenceActions] = [] @@ -137,26 +136,26 @@ def match_expanded_community_list(self, expanded_community_list_id: UUID) -> Non def match_omp_tag(self, omp_tag: int) -> None: self._insert_match(OMPTagEntry(value=str(omp_tag))) - def match_origin(self, origin: OriginProtocolEnum) -> None: + def match_origin(self, origin: OriginProtocol) -> None: self._insert_match(OriginEntry(value=origin)) def match_originator(self, originator: IPv4Address) -> None: self._insert_match(OriginatorEntry(value=originator)) - def match_path_type(self, path_type: PathTypeEnum) -> None: + def match_path_type(self, path_type: PathType) -> None: self._insert_match(PathTypeEntry(value=path_type)) def match_preference(self, preference: int) -> None: self._insert_match(PreferenceEntry(value=str(preference))) - def match_region(self, region_id: int, role: Optional[MultiRegionRoleEnum] = None) -> None: + def match_region(self, region_id: int, role: Optional[MultiRegionRole] = None) -> None: self._insert_match(RegionEntry(value=str(region_id))) if role is not None: self._insert_match(RoleEntry(value=role)) else: self._remove_match(RoleEntry) - def match_region_list(self, region_list_id: UUID, role: Optional[MultiRegionRoleEnum] = None) -> None: + def match_region_list(self, region_list_id: UUID, role: Optional[MultiRegionRole] = None) -> None: self._insert_match(RegionListEntry(ref=region_list_id)) if role is not None: self._insert_match(RoleEntry(value=role)) @@ -172,7 +171,7 @@ def match_site_list(self, site_list_id: UUID) -> None: def match_tloc_list(self, tloc_list_id: UUID) -> None: self._insert_match(TLOCListEntry(ref=tloc_list_id)) - def match_tloc(self, ip: IPv4Address, color: TLOCColorEnum, encap: EncapEnum) -> None: + def match_tloc(self, ip: IPv4Address, color: TLOCColor, encap: EncapType) -> None: self._insert_match(TLOCEntry(value=TLOCEntryValue(ip=ip, color=color, encap=encap))) def match_vpn_list(self, vpn_list_id: UUID) -> None: @@ -198,18 +197,18 @@ def associate_preference_action(self, preference: int) -> None: self._insert_action_in_set(PreferenceEntry(value=str(preference))) @overload - def associate_service_action(self, service_type: ServiceTypeEnum, vpn: int, *, tloc_list_id: UUID) -> None: + def associate_service_action(self, service_type: ServiceType, vpn: int, *, tloc_list_id: UUID) -> None: ... @overload def associate_service_action( - self, service_type: ServiceTypeEnum, vpn: int, *, ip: IPv4Address, color: TLOCColorEnum, encap: EncapEnum + self, service_type: ServiceType, vpn: int, *, ip: IPv4Address, color: TLOCColor, encap: EncapType ) -> None: ... @accept_action def associate_service_action( - self, service_type=ServiceTypeEnum, vpn=int, *, tloc_list_id=None, ip=None, color=None, encap=None + self, service_type=ServiceType, vpn=int, *, tloc_list_id=None, ip=None, color=None, encap=None ) -> None: if tloc_list_id is None: tloc_entry = TLOCEntryValue(ip=ip, color=color, encap=encap) @@ -221,7 +220,7 @@ def associate_service_action( self._insert_action_in_set(ServiceEntry(value=service_value)) @accept_action - def associate_tloc_action(self, tloc_action: TLOCActionEnum) -> None: + def associate_tloc_action(self, tloc_action: TLOCActionType) -> None: self._insert_action_in_set(TLOCActionEntry(value=tloc_action)) @accept_action @@ -237,14 +236,14 @@ class ControlPolicyTLOCSequence(PolicyDefinitionSequenceBase): sequence_type: Literal["tloc"] = Field( default="tloc", serialization_alias="sequenceType", validation_alias="sequenceType" ) - base_action: PolicyActionTypeEnum = Field( - default=PolicyActionTypeEnum.REJECT, serialization_alias="baseAction", validation_alias="baseAction" + base_action: PolicyActionType = Field( + default="reject", serialization_alias="baseAction", validation_alias="baseAction" ) match: ControlPolicyTLOCSequenceMatch = ControlPolicyTLOCSequenceMatch() actions: List[ControlPolicyTLOCSequenceActions] = [] model_config = ConfigDict(populate_by_name=True) - def match_carrier(self, carrier: CarrierEnum) -> None: + def match_carrier(self, carrier: Carrier) -> None: self._insert_match(CarrierEntry(value=carrier)) def match_color_list(self, color_list_id: UUID) -> None: @@ -271,14 +270,14 @@ def match_site(self, site: int) -> None: def match_site_list(self, site_list_id: UUID) -> None: self._insert_match(SiteListEntry(ref=site_list_id)) - def match_region(self, region_id: int, role: Optional[MultiRegionRoleEnum] = None) -> None: + def match_region(self, region_id: int, role: Optional[MultiRegionRole] = None) -> None: self._insert_match(RegionEntry(value=str(region_id))) if role is not None: self._insert_match(RoleEntry(value=role)) else: self._remove_match(RoleEntry) - def match_region_list(self, region_list_id: UUID, role: Optional[MultiRegionRoleEnum] = None) -> None: + def match_region_list(self, region_list_id: UUID, role: Optional[MultiRegionRole] = None) -> None: self._insert_match(RegionListEntry(ref=region_list_id)) if role is not None: self._insert_match(RoleEntry(value=role)) @@ -288,7 +287,7 @@ def match_region_list(self, region_list_id: UUID, role: Optional[MultiRegionRole def match_tloc_list(self, tloc_list_id: UUID) -> None: self._insert_match(TLOCListEntry(ref=tloc_list_id)) - def match_tloc(self, ip: IPv4Address, color: TLOCColorEnum, encap: EncapEnum) -> None: + def match_tloc(self, ip: IPv4Address, color: TLOCColor, encap: EncapType) -> None: self._insert_match(TLOCEntry(value=TLOCEntryValue(ip=ip, color=color, encap=encap))) @accept_action @@ -313,30 +312,30 @@ def associate_affinity_action(self, affinity: int) -> None: class ControlPolicy(ControlPolicyHeader, DefinitionWithSequencesCommonBase): sequences: List[AnyControlPolicySequence] = [] default_action: DefaultAction = Field( - default=DefaultAction(type=PolicyActionTypeEnum.REJECT), + default=DefaultAction(type="reject"), serialization_alias="defaultAction", validation_alias="defaultAction", ) model_config = ConfigDict(populate_by_name=True) def add_route_sequence( - self, name: str = "Route", base_action: PolicyActionTypeEnum = PolicyActionTypeEnum.REJECT + self, name: str = "Route", base_action: PolicyActionType = "reject" ) -> ControlPolicyRouteSequence: seq = ControlPolicyRouteSequence( sequence_name=name, base_action=base_action, - sequence_ip_type=SequenceIpType.IPV4, + sequence_ip_type="ipv4", ) self.add(seq) return seq def add_tloc_sequence( - self, name: str = "TLOC", base_action: PolicyActionTypeEnum = PolicyActionTypeEnum.REJECT + self, name: str = "TLOC", base_action: PolicyActionType = "reject" ) -> ControlPolicyTLOCSequence: seq = ControlPolicyTLOCSequence( sequence_name=name, base_action=base_action, - sequence_ip_type=SequenceIpType.IPV4, + sequence_ip_type="ipv4", ) self.add(seq) return seq diff --git a/catalystwan/models/policy/definitions/device_access.py b/catalystwan/models/policy/definitions/device_access.py index f4497ffab..1781f6db3 100644 --- a/catalystwan/models/policy/definitions/device_access.py +++ b/catalystwan/models/policy/definitions/device_access.py @@ -12,12 +12,11 @@ DestinationDataPrefixListEntry, DestinationIPEntry, DestinationPortEntry, - DeviceAccessProtocolEnum, + DeviceAccessProtocol, Match, - PolicyActionTypeEnum, + PolicyActionType, PolicyDefinitionBase, PolicyDefinitionSequenceBase, - SequenceIpType, SourceDataPrefixListEntry, SourceIPEntry, SourcePortEntry, @@ -50,14 +49,14 @@ class DeviceAccessPolicySequence(PolicyDefinitionSequenceBase): sequence_type: Literal["deviceaccesspolicy"] = Field( default="deviceaccesspolicy", serialization_alias="sequenceType", validation_alias="sequenceType" ) - base_action: PolicyActionTypeEnum = Field( - default=PolicyActionTypeEnum.ACCEPT, serialization_alias="baseAction", validation_alias="baseAction" + base_action: PolicyActionType = Field( + default="accept", serialization_alias="baseAction", validation_alias="baseAction" ) match: DeviceAccessPolicySequenceMatch = DeviceAccessPolicySequenceMatch() actions: List[DeviceAccessPolicySequenceActions] = [] model_config = ConfigDict(populate_by_name=True) - def match_device_access_protocol(self, port: DeviceAccessProtocolEnum) -> None: + def match_device_access_protocol(self, port: DeviceAccessProtocol) -> None: self._insert_match(DestinationPortEntry.from_port_set_and_ranges(ports={port})) def match_source_data_prefix_list(self, data_prefix_list_id: UUID) -> None: @@ -82,7 +81,7 @@ def associate_count_action(self, counter_name: str) -> None: class DeviceAccessPolicy(DeviceAccessPolicyHeader, DefinitionWithSequencesCommonBase): sequences: List[DeviceAccessPolicySequence] = [] default_action: DefaultAction = Field( - default=DefaultAction(type=PolicyActionTypeEnum.DROP), + default=DefaultAction(type="drop"), serialization_alias="defaultAction", validation_alias="defaultAction", ) @@ -91,13 +90,13 @@ class DeviceAccessPolicy(DeviceAccessPolicyHeader, DefinitionWithSequencesCommon def add_acl_sequence( self, name: str = "Device Access Control List", - base_action: PolicyActionTypeEnum = PolicyActionTypeEnum.ACCEPT, - device_access_protocol: Optional[DeviceAccessProtocolEnum] = None, + base_action: PolicyActionType = "accept", + device_access_protocol: Optional[DeviceAccessProtocol] = None, ) -> DeviceAccessPolicySequence: seq = DeviceAccessPolicySequence( sequence_name=name, base_action=base_action, - sequence_ip_type=SequenceIpType.IPV4, + sequence_ip_type="ipv4", ) if device_access_protocol is not None: seq.match_device_access_protocol(port=device_access_protocol) diff --git a/catalystwan/models/policy/definitions/device_access_ipv6.py b/catalystwan/models/policy/definitions/device_access_ipv6.py index b6c98881c..5c124f8ad 100644 --- a/catalystwan/models/policy/definitions/device_access_ipv6.py +++ b/catalystwan/models/policy/definitions/device_access_ipv6.py @@ -12,12 +12,11 @@ DestinationDataIPv6PrefixListEntry, DestinationIPv6Entry, DestinationPortEntry, - DeviceAccessProtocolEnum, + DeviceAccessProtocol, Match, - PolicyActionTypeEnum, + PolicyActionType, PolicyDefinitionBase, PolicyDefinitionSequenceBase, - SequenceIpType, SourceDataIPv6PrefixListEntry, SourceIPv6Entry, SourcePortEntry, @@ -50,14 +49,14 @@ class DeviceAccessIPv6PolicySequence(PolicyDefinitionSequenceBase): sequence_type: Literal["deviceaccesspolicyv6"] = Field( default="deviceaccesspolicyv6", serialization_alias="sequenceType", validation_alias="sequenceType" ) - base_action: PolicyActionTypeEnum = Field( - default=PolicyActionTypeEnum.ACCEPT, serialization_alias="baseAction", validation_alias="baseAction" + base_action: PolicyActionType = Field( + default="accept", serialization_alias="baseAction", validation_alias="baseAction" ) match: DeviceAccessIPv6PolicySequenceMatch = DeviceAccessIPv6PolicySequenceMatch() actions: List[DeviceAccessIPv6PolicySequenceActions] = [] model_config = ConfigDict(populate_by_name=True) - def match_device_access_protocol(self, port: DeviceAccessProtocolEnum) -> None: + def match_device_access_protocol(self, port: DeviceAccessProtocol) -> None: self._insert_match(DestinationPortEntry.from_port_set_and_ranges(ports={port})) def match_source_data_prefix_list(self, data_prefix_list_id: UUID) -> None: @@ -82,7 +81,7 @@ def associate_count_action(self, counter_name: str) -> None: class DeviceAccessIPv6Policy(DeviceAccessIPv6PolicyHeader, DefinitionWithSequencesCommonBase): sequences: List[DeviceAccessIPv6PolicySequence] = [] default_action: DefaultAction = Field( - default=DefaultAction(type=PolicyActionTypeEnum.DROP), + default=DefaultAction(type="drop"), serialization_alias="defaultAction", validation_alias="defaultAction", ) @@ -91,13 +90,13 @@ class DeviceAccessIPv6Policy(DeviceAccessIPv6PolicyHeader, DefinitionWithSequenc def add_acl_sequence( self, name: str = "Device Access Control List", - base_action: PolicyActionTypeEnum = PolicyActionTypeEnum.ACCEPT, - device_access_protocol: Optional[DeviceAccessProtocolEnum] = None, + base_action: PolicyActionType = "accept", + device_access_protocol: Optional[DeviceAccessProtocol] = None, ) -> DeviceAccessIPv6PolicySequence: seq = DeviceAccessIPv6PolicySequence( sequence_name=name, base_action=base_action, - sequence_ip_type=SequenceIpType.IPV4, + sequence_ip_type="ipv4", ) if device_access_protocol is not None: seq.match_device_access_protocol(port=device_access_protocol) diff --git a/catalystwan/models/policy/definitions/qos_map.py b/catalystwan/models/policy/definitions/qos_map.py index 52352ece3..9084ff7f8 100644 --- a/catalystwan/models/policy/definitions/qos_map.py +++ b/catalystwan/models/policy/definitions/qos_map.py @@ -1,4 +1,3 @@ -from enum import Enum from typing import List, Literal, Optional, Union from uuid import UUID @@ -6,15 +5,15 @@ from catalystwan.models.policy.policy_definition import PolicyDefinitionBase +QoSScheduling = Literal[ + "llq", + "wrr", +] -class QoSSchedulingEnum(str, Enum): - LLQ = "llq" - WRR = "wrr" - - -class QoSDropEnum(str, Enum): - TAIL = "tail-drop" - RANDOM_EARLY = "red-drop" +QoSDropType = Literal[ + "tail-drop", + "red-drop", +] class QoSScheduler(BaseModel): @@ -23,8 +22,8 @@ class QoSScheduler(BaseModel): bandwidth_percent: str = Field("1", serialization_alias="bandwidthPercent", validation_alias="bandwidthPercent") buffer_percent: str = Field("1", serialization_alias="bufferPercent", validation_alias="bufferPercent") burst: Optional[str] = None - scheduling: QoSSchedulingEnum = QoSSchedulingEnum.WRR - drops: QoSDropEnum = QoSDropEnum.TAIL + scheduling: QoSScheduling = "wrr" + drops: QoSDropType = "tail-drop" temp_key_values: Optional[str] = Field( default=None, serialization_alias="tempKeyValues", validation_alias="tempKeyValues" ) @@ -37,8 +36,8 @@ def get_default_control_scheduler() -> "QoSScheduler": bandwidth_percent="100", buffer_percent="100", burst="15000", - scheduling=QoSSchedulingEnum.LLQ, - drops=QoSDropEnum.TAIL, + scheduling="llq", + drops="tail-drop", ) model_config = ConfigDict(populate_by_name=True) @@ -79,8 +78,8 @@ def add_scheduler( class_map_ref: UUID, bandwidth: int = 1, buffer: int = 1, - scheduling: QoSSchedulingEnum = QoSSchedulingEnum.WRR, - drops: QoSDropEnum = QoSDropEnum.TAIL, + scheduling: QoSScheduling = "wrr", + drops: QoSDropType = "tail-drop", burst: Optional[int] = None, ) -> None: self.definition.qos_schedulers.append( diff --git a/catalystwan/models/policy/definitions/rewrite.py b/catalystwan/models/policy/definitions/rewrite.py index ea803d274..d6685d483 100644 --- a/catalystwan/models/policy/definitions/rewrite.py +++ b/catalystwan/models/policy/definitions/rewrite.py @@ -5,7 +5,7 @@ from catalystwan.models.policy.policy_definition import ( DefinitionWithSequencesCommonBase, - PLPEntryEnum, + PLPEntryType, PolicyDefinitionBase, ) @@ -29,7 +29,7 @@ class RewritePolicyDefinition(BaseModel): class RewritePolicy(RewritePolicyHeader, DefinitionWithSequencesCommonBase): definition: RewritePolicyDefinition = RewritePolicyDefinition() - def add_rule(self, class_map_ref: UUID, dscp: int, l2cos: int, plp: PLPEntryEnum) -> None: + def add_rule(self, class_map_ref: UUID, dscp: int, l2cos: int, plp: PLPEntryType) -> None: self.definition.rules.append(RewritePolicyRule(class_=class_map_ref, plp=plp, dscp=str(dscp), l2cos=str(l2cos))) model_config = ConfigDict(populate_by_name=True) diff --git a/catalystwan/models/policy/definitions/security_group.py b/catalystwan/models/policy/definitions/security_group.py index 3fb1d6fb2..b73212351 100644 --- a/catalystwan/models/policy/definitions/security_group.py +++ b/catalystwan/models/policy/definitions/security_group.py @@ -1,4 +1,3 @@ -from enum import Enum from ipaddress import IPv4Network, IPv6Network from typing import Literal, Optional, Union @@ -7,10 +6,10 @@ from catalystwan.models.common import check_any_of_exclusive_field_sets, check_fields_exclusive from catalystwan.models.policy.policy_definition import PolicyDefinitionBase, Reference, VariableName - -class SequenceIPType(str, Enum): - IPV4 = "ipv4" - IPV6 = "ipv6" +SequenceIPType = Literal[ + "ipv4", + "ipv6", +] class SecurityGroupIPv4Definition(BaseModel): diff --git a/catalystwan/models/policy/definitions/traffic_data.py b/catalystwan/models/policy/definitions/traffic_data.py index 56535464c..f0c6f6907 100644 --- a/catalystwan/models/policy/definitions/traffic_data.py +++ b/catalystwan/models/policy/definitions/traffic_data.py @@ -5,8 +5,8 @@ from pydantic import ConfigDict, Field from typing_extensions import Annotated -from catalystwan.models.common import TLOCColorEnum -from catalystwan.models.policy.lists_entries import EncapEnum +from catalystwan.models.common import ServiceChainNumber, TLOCColor +from catalystwan.models.policy.lists_entries import EncapType from catalystwan.models.policy.policy_definition import ( AppListEntry, CFlowDAction, @@ -17,11 +17,9 @@ DestinationIPEntry, DestinationPortEntry, DestinationRegionEntry, - DestinationRegionEntryValues, DNSAppListEntry, DNSEntry, - DNSEntryValues, - DNSTypeEntryEnum, + DNSTypeEntryType, DREOptimizationAction, DSCPEntry, FallBackToRoutingAction, @@ -30,25 +28,23 @@ LocalTLOCListEntryValue, LogAction, LossProtectionAction, - LossProtectionEnum, LossProtectionFECAction, LossProtectionPacketDuplicationAction, + LossProtectionType, Match, NATAction, NextHopEntry, NextHopLooseEntry, PacketLengthEntry, PLPEntry, - PLPEntryEnum, PolicerListEntry, - PolicyActionTypeEnum, + PolicyActionType, PolicyDefinitionBase, PolicyDefinitionSequenceBase, PrefferedColorGroupListEntry, ProtocolEntry, RedirectDNSAction, SecureInternetGatewayAction, - SequenceIpType, ServiceChainEntry, ServiceChainEntryValue, ServiceNodeGroupAction, @@ -62,7 +58,6 @@ TLOCEntryValue, TLOCListEntry, TrafficToEntry, - TrafficToEntryValues, VPNEntry, accept_action, ) @@ -117,10 +112,10 @@ def match_dns_app_list(self, dns_app_list_id: UUID) -> None: self._insert_match(DNSAppListEntry(ref=dns_app_list_id)) def match_dns_request(self) -> None: - self._insert_match(DNSEntry(value=DNSEntryValues.REQUEST)) + self._insert_match(DNSEntry(value="request")) def match_dns_response(self) -> None: - self._insert_match(DNSEntry(value=DNSEntryValues.RESPONSE)) + self._insert_match(DNSEntry(value="response")) def match_dscp(self, dscp: int) -> None: self._insert_match(DSCPEntry(value=str(dscp))) @@ -129,10 +124,10 @@ def match_packet_length(self, packet_lengths: Tuple[int, int]) -> None: self._insert_match(PacketLengthEntry.from_range(packet_lengths)) def match_low_plp(self) -> None: - self._insert_match(PLPEntry(value=PLPEntryEnum.LOW)) + self._insert_match(PLPEntry(value="low")) def match_high_plp(self) -> None: - self._insert_match(PLPEntry(value=PLPEntryEnum.HIGH)) + self._insert_match(PLPEntry(value="high")) def match_protocols(self, protocols: Set[int]) -> None: self._insert_match(ProtocolEntry.from_protocol_set(protocols)) @@ -153,13 +148,13 @@ def match_destination_ip(self, networks: List[IPv4Network]) -> None: self._insert_match(DestinationIPEntry.from_ipv4_networks(networks)) def match_primary_destination_region(self) -> None: - self._insert_match(DestinationRegionEntry(value=DestinationRegionEntryValues.PRIMARY)) + self._insert_match(DestinationRegionEntry(value="primary-region")) def match_secondary_destination_region(self) -> None: - self._insert_match(DestinationRegionEntry(value=DestinationRegionEntryValues.SECONDARY)) + self._insert_match(DestinationRegionEntry(value="secondary-region")) def match_other_destination_region(self) -> None: - self._insert_match(DestinationRegionEntry(value=DestinationRegionEntryValues.OTHER)) + self._insert_match(DestinationRegionEntry(value="other-region")) def match_destination_port(self, ports: Set[int] = set(), port_ranges: List[Tuple[int, int]] = []) -> None: self._insert_match(DestinationPortEntry.from_port_set_and_ranges(ports, port_ranges)) @@ -168,13 +163,13 @@ def match_tcp(self) -> None: self._insert_match(TCPEntry()) def match_traffic_to_access(self) -> None: - self._insert_match(TrafficToEntry(value=TrafficToEntryValues.ACCESS)) + self._insert_match(TrafficToEntry(value="access")) def match_traffic_to_core(self) -> None: - self._insert_match(TrafficToEntry(value=TrafficToEntryValues.CORE)) + self._insert_match(TrafficToEntry(value="core")) def match_traffic_to_service(self) -> None: - self._insert_match(TrafficToEntry(value=TrafficToEntryValues.SERVICE)) + self._insert_match(TrafficToEntry(value="service")) def associate_count_action(self, counter_name: str) -> None: self._insert_action(CountAction(parameter=counter_name)) @@ -191,7 +186,7 @@ def associate_forwarding_class_action(self, fwclass: str) -> None: self._insert_action_in_set(ForwardingClassEntry(value=fwclass)) @accept_action - def associate_local_tloc_action(self, color: TLOCColorEnum, encap: EncapEnum, restrict: bool = False) -> None: + def associate_local_tloc_action(self, color: TLOCColor, encap: EncapType, restrict: bool = False) -> None: tloc_entry = LocalTLOCListEntry( value=LocalTLOCListEntryValue( color=color, @@ -239,7 +234,7 @@ def associate_redirect_dns_action(self, *, ip: IPv4Address) -> None: ... @overload - def associate_redirect_dns_action(self, *, dns_type: DNSTypeEntryEnum = DNSTypeEntryEnum.HOST) -> None: + def associate_redirect_dns_action(self, *, dns_type: DNSTypeEntryType = "host") -> None: ... @accept_action @@ -251,7 +246,9 @@ def associate_redirect_dns_action(self, *, ip=None, dns_type=None) -> None: self._insert_action(redirect_dns_action) @accept_action - def associate_local_service_chain_action(self, sc_type: str, vpn: int, restrict: bool = False) -> None: + def associate_local_service_chain_action( + self, sc_type: ServiceChainNumber, vpn: int, restrict: bool = False + ) -> None: self._insert_action_in_set( ServiceChainEntry( value=ServiceChainEntryValue( @@ -265,7 +262,13 @@ def associate_local_service_chain_action(self, sc_type: str, vpn: int, restrict: @accept_action def associate_remote_service_chain_action( - self, sc_type: str, vpn: int, ip: IPv4Address, color: TLOCColorEnum, encap: EncapEnum, restrict: bool = False + self, + sc_type: ServiceChainNumber, + vpn: int, + ip: IPv4Address, + color: TLOCColor, + encap: EncapType, + restrict: bool = False, ) -> None: self._insert_action_in_set( ServiceChainEntry( @@ -302,7 +305,7 @@ def associate_app_qoe_optimization_action( @accept_action def associate_loss_correction_fec_action(self, adaptive: bool = False, threshold: Optional[int] = None) -> None: self._remove_action(LossProtectionPacketDuplicationAction().type) - fec_type = LossProtectionEnum.FEC_ADAPTIVE if adaptive else LossProtectionEnum.FEC_ALWAYS + fec_type: LossProtectionType = "fecAdaptive" if adaptive else "fecAlways" fec_value = str(threshold) if adaptive and threshold is not None else None self._insert_action(LossProtectionAction(parameter=fec_type)) self._insert_action(LossProtectionFECAction(parameter=fec_type, value=fec_value)) @@ -310,7 +313,7 @@ def associate_loss_correction_fec_action(self, adaptive: bool = False, threshold @accept_action def associate_loss_correction_packet_duplication_action(self) -> None: self._remove_action(LossProtectionFECAction().type) - self._insert_action(LossProtectionAction(parameter=LossProtectionEnum.PACKET_DUPLICATION)) + self._insert_action(LossProtectionAction(parameter="packetDuplication")) self._insert_action(LossProtectionPacketDuplicationAction()) @accept_action @@ -323,7 +326,7 @@ def associate_tloc_action(self, *, tloc_list_id: UUID) -> None: ... @overload - def associate_tloc_action(self, *, ip: IPv4Address, color: TLOCColorEnum, encap: EncapEnum) -> None: + def associate_tloc_action(self, *, ip: IPv4Address, color: TLOCColor, encap: EncapType) -> None: ... @accept_action @@ -357,12 +360,12 @@ class TrafficDataPolicy(TrafficDataPolicyHeader, DefinitionWithSequencesCommonBa model_config = ConfigDict(populate_by_name=True) def add_ipv4_sequence( - self, name: str = "Custom", base_action: PolicyActionTypeEnum = PolicyActionTypeEnum.DROP, log: bool = False + self, name: str = "Custom", base_action: PolicyActionType = "drop", log: bool = False ) -> TrafficDataPolicySequence: seq = TrafficDataPolicySequence( sequence_name=name, base_action=base_action, - sequence_ip_type=SequenceIpType.IPV4, + sequence_ip_type="ipv4", ) self.add(seq) return seq diff --git a/catalystwan/models/policy/definitions/zone_based_firewall.py b/catalystwan/models/policy/definitions/zone_based_firewall.py index 19d5933d0..716361994 100644 --- a/catalystwan/models/policy/definitions/zone_based_firewall.py +++ b/catalystwan/models/policy/definitions/zone_based_firewall.py @@ -18,14 +18,13 @@ DestinationPortListEntry, LogAction, Match, - PolicyActionTypeEnum, + PolicyActionType, PolicyDefinitionBase, PolicyDefinitionSequenceBase, ProtocolEntry, ProtocolNameEntry, ProtocolNameListEntry, RuleSetListEntry, - SequenceIpType, SourceDataPrefixListEntry, SourceFQDNEntry, SourceFQDNListEntry, @@ -88,8 +87,8 @@ def match_rule_set_lists(self, rule_set_ids: Set[UUID]) -> None: self._insert_match(RuleSetListEntry.from_rule_set_ids(rule_set_ids)) def match_app_list(self, app_list_id: UUID) -> None: - if self.base_action != PolicyActionTypeEnum.INSPECT: - raise ValueError("Action must be Inspect when Application/Application Family List is selected.") + if self.base_action != "inspect": + raise ValueError("Action must be inspect when Application/Application Family List is selected.") self._insert_match(AppListEntry(ref=app_list_id)) @@ -102,8 +101,8 @@ class ZoneBasedFWPolicySequence(PolicyDefinitionSequenceBase): model_config = ConfigDict(populate_by_name=True) def match_app_list(self, app_list_id: UUID) -> None: - if self.base_action != PolicyActionTypeEnum.INSPECT: - raise ValueError("Action must be Inspect when Application/Application Family List is selected.") + if self.base_action != "inspect": + raise ValueError("Action must be inspect when Application/Application Family List is selected.") self._insert_match(AppListEntry(ref=app_list_id)) def match_destination_data_prefix_list(self, data_prefix_list_id: UUID) -> None: @@ -194,7 +193,7 @@ class ZoneBasedFWPolicy(ZoneBasedFWPolicyHeader): definition: ZoneBasedFWPolicyDefinition = ZoneBasedFWPolicyDefinition() def add_ipv4_rule( - self, name: str, base_action: PolicyActionTypeEnum = PolicyActionTypeEnum.DROP, log: bool = False + self, name: str, base_action: PolicyActionType = "drop", log: bool = False ) -> ZoneBasedFWPolicySequence: """Adds new IPv4 Rule to Zone Based Firewall Policy @@ -209,7 +208,7 @@ def add_ipv4_rule( sequence = ZoneBasedFWPolicySequence( sequence_name=name, base_action=base_action, - sequence_ip_type=SequenceIpType.IPV4, + sequence_ip_type="ipv4", match=ZoneBasedFWPolicyMatches(), ) if log: @@ -218,12 +217,12 @@ def add_ipv4_rule( return sequence def add_ipv4_rule_sets( - self, name: str, base_action: PolicyActionTypeEnum = PolicyActionTypeEnum.DROP, log: bool = False + self, name: str, base_action: PolicyActionType = "drop", log: bool = False ) -> ZoneBasedFWPolicySequenceWithRuleSets: sequence = ZoneBasedFWPolicySequenceWithRuleSets( sequence_name=name, base_action=base_action, - sequence_ip_type=SequenceIpType.IPV4, + sequence_ip_type="ipv4", match=ZoneBasedFWPolicyMatches(), ) if log: diff --git a/catalystwan/models/policy/lists.py b/catalystwan/models/policy/lists.py index 8e837a14c..c707b35ec 100644 --- a/catalystwan/models/policy/lists.py +++ b/catalystwan/models/policy/lists.py @@ -4,7 +4,7 @@ from pydantic import BaseModel, Field -from catalystwan.models.common import InterfaceTypeEnum, TLOCColorEnum, WellKnownBGPCommunitiesEnum +from catalystwan.models.common import InterfaceType, TLOCColor, WellKnownBGPCommunities from catalystwan.models.policy.lists_entries import ( AppListEntry, AppProbeClassListEntry, @@ -15,7 +15,7 @@ CommunityListEntry, DataIPv6PrefixListEntry, DataPrefixListEntry, - EncapEnum, + EncapType, FQDNListEntry, GeoLocationListEntry, IPSSignatureListEntry, @@ -23,8 +23,8 @@ LocalAppListEntry, LocalDomainListEntry, MirrorListEntry, - PathPreferenceEnum, - PolicerExceedActionEnum, + PathPreference, + PolicerExceedAction, PolicerListEntry, PortListEntry, PreferredColorGroupListEntry, @@ -97,7 +97,7 @@ class ZoneList(PolicyListBase): def assign_vpns(self, vpns: Set[int]) -> None: self.entries = [ZoneListEntry(vpn=str(vpn)) for vpn in vpns] - def assign_interfaces(self, ifs: Set[InterfaceTypeEnum]) -> None: + def assign_interfaces(self, ifs: Set[InterfaceType]) -> None: self.entries = [ZoneListEntry(interface=interface) for interface in ifs] @@ -141,7 +141,7 @@ class ColorList(PolicyListBase): type: Literal["color"] = "color" entries: List[ColorListEntry] = [] - def add_color(self, color: TLOCColorEnum) -> None: + def add_color(self, color: TLOCColor) -> None: self._add_entry(ColorListEntry(color=color)) @@ -176,7 +176,7 @@ class URLBlackList(PolicyListBase): class _CommunityListBase(PolicyListBase): entries: List[CommunityListEntry] = [] - def add_well_known_community(self, community: WellKnownBGPCommunitiesEnum) -> None: + def add_well_known_community(self, community: WellKnownBGPCommunities) -> None: self._add_entry(CommunityListEntry(community=community)) def add_community(self, as_number: int, community_number: int) -> None: @@ -195,7 +195,7 @@ class PolicerList(PolicyListBase): type: Literal["policer"] = "policer" entries: List[PolicerListEntry] = [] - def police(self, burst: int, rate: int, exceed: PolicerExceedActionEnum = PolicerExceedActionEnum.DROP) -> None: + def police(self, burst: int, rate: int, exceed: PolicerExceedAction = "drop") -> None: # Policer list must have only single entry! entry = PolicerListEntry(burst=str(burst), exceed=exceed, rate=str(rate)) self._add_entry(entry, single=True) @@ -268,9 +268,7 @@ class TLOCList(PolicyListBase): type: Literal["tloc"] = "tloc" entries: List[TLOCListEntry] = [] - def add_tloc( - self, tloc: IPv4Address, color: TLOCColorEnum, encap: EncapEnum, preference: Optional[int] = None - ) -> None: + def add_tloc(self, tloc: IPv4Address, color: TLOCColor, encap: EncapType, preference: Optional[int] = None) -> None: _preference = str(preference) if preference is not None else None self.entries.append(TLOCListEntry(tloc=tloc, color=color, encap=encap, preference=_preference)) @@ -281,9 +279,9 @@ class PreferredColorGroupList(PolicyListBase): def assign_color_groups( self, - primary: Tuple[Set[TLOCColorEnum], PathPreferenceEnum], - secondary: Optional[Tuple[Set[TLOCColorEnum], PathPreferenceEnum]] = None, - tertiary: Optional[Tuple[Set[TLOCColorEnum], PathPreferenceEnum]] = None, + primary: Tuple[Set[TLOCColor], PathPreference], + secondary: Optional[Tuple[Set[TLOCColor], PathPreference]] = None, + tertiary: Optional[Tuple[Set[TLOCColor], PathPreference]] = None, ) -> PreferredColorGroupListEntry: primary_preference = ColorGroupPreference.from_color_set_and_path(*primary) secondary_preference = ( diff --git a/catalystwan/models/policy/lists_entries.py b/catalystwan/models/policy/lists_entries.py index 843cccd53..6b75eaad9 100644 --- a/catalystwan/models/policy/lists_entries.py +++ b/catalystwan/models/policy/lists_entries.py @@ -1,11 +1,10 @@ -from enum import Enum from ipaddress import IPv4Address, IPv4Network, IPv6Network from typing import List, Literal, Optional, Set from uuid import UUID from pydantic import BaseModel, ConfigDict, Field, IPvAnyAddress, field_validator, model_validator -from catalystwan.models.common import InterfaceTypeEnum, TLOCColorEnum, check_fields_exclusive +from catalystwan.models.common import InterfaceType, TLOCColor, check_fields_exclusive def check_jitter_ms(jitter_str: str) -> str: @@ -23,24 +22,25 @@ def check_loss_percent(loss_str: str) -> str: return loss_str -class PolicerExceedActionEnum(str, Enum): - DROP = "drop" - REMARK = "remark" +PolicerExceedAction = Literal[ + "drop", + "remark", +] +EncapType = Literal[ + "ipsec", + "gre", +] -class EncapEnum(str, Enum): - IPSEC = "ipsec" - GRE = "gre" - - -class PathPreferenceEnum(str, Enum): - DIRECT_PATH = "direct-path" - MULTI_HOP_PATH = "multi-hop-path" - ALL_PATHS = "all-paths" +PathPreference = Literal[ + "direct-path", + "multi-hop-path", + "all-paths", +] class ColorDSCPMap(BaseModel): - color: TLOCColorEnum + color: TLOCColor dscp: int = Field(ge=0, le=63) @@ -48,11 +48,11 @@ class ColorGroupPreference(BaseModel): model_config = ConfigDict(populate_by_name=True) color_preference: str = Field(serialization_alias="colorPreference", validation_alias="colorPreference") - path_preference: PathPreferenceEnum = Field(serialization_alias="pathPreference", validation_alias="pathPreference") + path_preference: PathPreference = Field(serialization_alias="pathPreference", validation_alias="pathPreference") @staticmethod def from_color_set_and_path( - color_preference: Set[TLOCColorEnum], path_preference: PathPreferenceEnum + color_preference: Set[TLOCColor], path_preference: PathPreference ) -> "ColorGroupPreference": return ColorGroupPreference(color_preference=" ".join(color_preference), path_preference=path_preference) @@ -155,7 +155,7 @@ def check_vpn_range(cls, vpns_str: str): class ZoneListEntry(BaseModel): vpn: Optional[str] = Field(default=None, description="0-65530 single number") - interface: Optional[InterfaceTypeEnum] = None + interface: Optional[InterfaceType] = None @field_validator("vpn") @classmethod @@ -226,7 +226,7 @@ def check_app_xor_appfamily(self): class ColorListEntry(BaseModel): - color: TLOCColorEnum + color: TLOCColor class DataIPv6PrefixListEntry(BaseModel): @@ -271,7 +271,7 @@ class PolicerListEntry(BaseModel): model_config = ConfigDict(populate_by_name=True) burst: str = Field(description="bytes: integer in range 15000-10000000") - exceed: PolicerExceedActionEnum = PolicerExceedActionEnum.DROP + exceed: PolicerExceedAction = "drop" rate: str = Field(description="bps: integer in range 8-100000000000") @field_validator("burst") @@ -316,7 +316,7 @@ class AppProbeClassListEntry(BaseModel): forwarding_class: str = Field(serialization_alias="forwardingClass", validation_alias="forwardingClass") map: List[ColorDSCPMap] = [] - def add_color_mapping(self, color: TLOCColorEnum, dscp: int) -> None: + def add_color_mapping(self, color: TLOCColor, dscp: int) -> None: self.map.append(ColorDSCPMap(color=color, dscp=dscp)) @@ -362,8 +362,8 @@ def add_fallback_loss_criteria(self, loss_variance: int) -> None: class TLOCListEntry(BaseModel): tloc: IPv4Address - color: TLOCColorEnum - encap: EncapEnum + color: TLOCColor + encap: EncapType preference: Optional[str] = None @field_validator("preference") diff --git a/catalystwan/models/policy/policy_definition.py b/catalystwan/models/policy/policy_definition.py index 7b38f132e..c8388eb71 100644 --- a/catalystwan/models/policy/policy_definition.py +++ b/catalystwan/models/policy/policy_definition.py @@ -1,5 +1,4 @@ import datetime -from enum import Enum from functools import wraps from ipaddress import IPv4Address, IPv4Network, IPv6Network from typing import Any, Dict, List, MutableSequence, Optional, Protocol, Sequence, Set, Tuple, Union @@ -8,9 +7,9 @@ from pydantic import BaseModel, ConfigDict, Field, RootModel, model_validator from typing_extensions import Annotated, Literal -from catalystwan.models.common import TLOCColorEnum, check_fields_exclusive +from catalystwan.models.common import ServiceChainNumber, TLOCColor, check_fields_exclusive from catalystwan.models.misc.application_protocols import ApplicationProtocol -from catalystwan.models.policy.lists_entries import EncapEnum +from catalystwan.models.policy.lists_entries import EncapType from catalystwan.typed_list import DataSequence @@ -26,97 +25,72 @@ def networks_to_str(networks: Sequence[Union[IPv4Network, IPv6Network]]) -> str: return " ".join(str(net) for net in networks) -class Reference(BaseModel): - ref: UUID - - -class VariableName(BaseModel): - vip_variable_name: str = Field(serialization_alias="vipVariableName", validation_alias="vipVariableName") - - -class PLPEntryEnum(str, Enum): - LOW = "low" - HIGH = "high" - - -class DNSEntryValues(str, Enum): - REQUEST = "request" - RESPONSE = "response" - - -class TrafficToEntryValues(str, Enum): - ACCESS = "access" - CORE = "core" - SERVICE = "service" - - -class DestinationRegionEntryValues(str, Enum): - PRIMARY = "primary-region" - SECONDARY = "secondary-region" - OTHER = "other-region" - - -class OriginProtocolEnum(str, Enum): - AGGREGATE = "aggregate" - BGP = "bgp" - BGP_EXTERNAL = "bgp-external" - BGP_INTERNAL = "bgp-internal" - CONNECTED = "connected" - EIGRP = "eigrp" - OSPF = "ospf" - OSPF_INTER_AREA = "ospf-inter-area" - OSPF_INTRA_AREA = "ospf-intra-area" - OSPF_EXTERNAL_1 = "ospf-external1" - OSPF_EXTERNAL_2 = "ospf-external2" - RIP = "rip" - STATIC = "static" - EIGRP_SUMMARY = "eigrp-summary" - EIGRP_INTERNAL = "eigrp-internal" - EIGRP_EXTERNAL = "eigrp-external" - LISP = "lisp" - NAT_DIA = "nat-dia" - NATPOOL = "natpool" - ISIS = "isis" - ISIS_LEVEL_1 = "isis-level1" - ISIS_LEVEL_2 = "isis-level2" - - -class PathTypeEnum(str, Enum): - HIERARCHICAL = "hierarchical-path" - DIRECT = "direct-path" - TRANSPORT_GATEWAY = "transport-gateway-path" - - -class DeviceAccessProtocolEnum(int, Enum): - SSH = 22 - SNMP = 161 - - -class LocalTLOCListEntryValue(BaseModel): - color: TLOCColorEnum - encap: EncapEnum - restrict: Optional[str] = None +PLPEntryType = Literal[ + "low", + "high", +] +DNSEntryType = Literal[ + "request", + "response", +] -class TLOCEntryValue(BaseModel): - ip: IPv4Address - color: TLOCColorEnum - encap: EncapEnum +TrafficTargetType = Literal[ + "access", + "core", + "service", +] +DestinationRegion = Literal[ + "primary-region", + "secondary-region", + "other-region", +] -class SequenceIpType(str, Enum): - IPV4 = "ipv4" - IPV6 = "ipv6" - ALL = "all" +OriginProtocol = Literal[ + "aggregate", + "bgp", + "bgp-external", + "bgp-internal", + "connected", + "eigrp", + "ospf", + "ospf-inter-area", + "ospf-intra-area", + "ospf-external1", + "ospf-external2", + "rip", + "static", + "eigrp-summary", + "eigrp-internal", + "eigrp-external", + "lisp", + "nat-dia", + "natpool", + "isis", + "isis-level1", + "isis-level2", +] +PathType = Literal[ + "hierarchical-path", + "direct-path", + "transport-gateway-path", +] -class PolicyActionTypeEnum(str, Enum): - DROP = "drop" - ACCEPT = "accept" - PASS = "pass" - INSPECT = "inspect" - REJECT = "reject" +SequenceIpType = Literal[ + "ipv4", + "ipv6", + "all", +] +PolicyActionType = Literal[ + "drop", + "accept", + "pass", + "inspect", + "reject", +] SequenceType = Literal[ "applicationFirewall", @@ -134,58 +108,81 @@ class PolicyActionTypeEnum(str, Enum): ] -class Optimized(str, Enum): - TRUE = "true" - FALSE = "false" +Optimized = Literal[ + "true", + "false", +] + +DNSTypeEntryType = Literal[ + "host", + "umbrella", +] + +LossProtectionType = Literal[ + "fecAdaptive", + "fecAlways", + "packetDuplication", +] + +MultiRegionRole = Literal[ + "border-router", + "edge-router", +] +ServiceType = Literal[ + "FW", + "IDP", + "IDS", + "netsvc1", + "netsvc2", + "netsvc3", + "netsvc4", +] -class DNSTypeEntryEnum(str, Enum): - HOST = "host" - UMBRELLA = "umbrella" +TLOCActionType = Literal[ + "strict", + "primary", + "backup", + "ecmp", +] +Carrier = Literal[ + "default", + "carrier1", + "carrier2", + "carrier3", + "carrier4", + "carrier5", + "carrier6", + "carrier7", + "carrier8", +] -class LossProtectionEnum(str, Enum): - FEC_ADAPTIVE = "fecAdaptive" - FEC_ALWAYS = "fecAlways" - PACKET_DUPLICATION = "packetDuplication" +DeviceAccessProtocol = Literal[22, 161] -class MultiRegionRoleEnum(str, Enum): - BORDER = "border-router" - EDGE = "edge-router" +class Reference(BaseModel): + ref: UUID -class ServiceTypeEnum(str, Enum): - FIREWALL = "FW" - INTRUSION_DETECTION_PREVENTION = "IDP" - INTRUSION_DETECTION_SYSTEM = "IDS" - NET_SERVICE_1 = "netsvc1" - NET_SERVICE_2 = "netsvc2" - NET_SERVICE_3 = "netsvc3" - NET_SERVICE_4 = "netsvc4" +class VariableName(BaseModel): + vip_variable_name: str = Field(serialization_alias="vipVariableName", validation_alias="vipVariableName") -class TLOCActionEnum(str, Enum): - STRICT = "strict" - PRIMARY = "primary" - BACKUP = "backup" - EQUAL_COST_MULTI_PATH = "ecmp" +class LocalTLOCListEntryValue(BaseModel): + color: TLOCColor + encap: EncapType + restrict: Optional[str] = None -class CarrierEnum(str, Enum): - DEFAULT = "default" - CARRIER_1 = "carrier1" - CARRIER_2 = "carrier2" - CARRIER_3 = "carrier3" - CARRIER_4 = "carrier4" - CARRIER_5 = "carrier5" - CARRIER_6 = "carrier6" - CARRIER_7 = "carrier7" - CARRIER_8 = "carrier8" +class TLOCEntryValue(BaseModel): + ip: IPv4Address + color: TLOCColor + encap: EncapType class ServiceChainEntryValue(BaseModel): - type: str = Field("SC1", pattern=r"SC(1[0-6]|[1-9])") + type: ServiceChainNumber = Field(default="SC1") vpn: str restrict: Optional[str] = None local: Optional[str] = None @@ -205,7 +202,7 @@ def from_range(packet_lengths: Tuple[int, int]) -> "PacketLengthEntry": class PLPEntry(BaseModel): field: Literal["plp"] = "plp" - value: PLPEntryEnum + value: PLPEntryType class ProtocolEntry(BaseModel): @@ -306,17 +303,17 @@ class TCPEntry(BaseModel): class DNSEntry(BaseModel): field: Literal["dns"] = "dns" - value: DNSEntryValues + value: DNSEntryType class TrafficToEntry(BaseModel): field: Literal["trafficTo"] = "trafficTo" - value: TrafficToEntryValues + value: TrafficTargetType class DestinationRegionEntry(BaseModel): field: Literal["destinationRegion"] = "destinationRegion" - value: DestinationRegionEntryValues + value: DestinationRegion class SourceFQDNEntry(BaseModel): @@ -385,7 +382,7 @@ class OMPTagEntry(BaseModel): class OriginEntry(BaseModel): field: Literal["origin"] = "origin" - value: OriginProtocolEnum + value: OriginProtocol class OriginatorEntry(BaseModel): @@ -400,7 +397,7 @@ class PreferenceEntry(BaseModel): class PathTypeEntry(BaseModel): field: Literal["pathType"] = "pathType" - value: PathTypeEnum + value: PathType class RegionEntry(BaseModel): @@ -410,7 +407,7 @@ class RegionEntry(BaseModel): class RoleEntry(BaseModel): field: Literal["role"] = "role" - value: MultiRegionRoleEnum + value: MultiRegionRole class SiteEntry(BaseModel): @@ -425,7 +422,7 @@ class LocalTLOCListEntry(BaseModel): class DNSTypeEntry(BaseModel): field: Literal["dnsType"] = "dnsType" - value: DNSTypeEntryEnum + value: DNSTypeEntryType class ServiceChainEntry(BaseModel): @@ -455,7 +452,7 @@ class CommunityAdditiveEntry(BaseModel): class CarrierEntry(BaseModel): field: Literal["carrier"] = "carrier" - value: CarrierEnum + value: Carrier class DomainIDEntry(BaseModel): @@ -621,7 +618,7 @@ class ClassMapListEntry(BaseModel): class ServiceEntryValue(BaseModel): model_config = ConfigDict(populate_by_name=True) - type: ServiceTypeEnum + type: ServiceType vpn: str tloc: Optional[TLOCEntryValue] = None tloc_list: Optional[TLOCListEntry] = Field( @@ -641,7 +638,7 @@ class ServiceEntry(BaseModel): class TLOCActionEntry(BaseModel): field: Literal["tlocAction"] = "tlocAction" - value: TLOCActionEnum + value: TLOCActionType class AffinityEntry(BaseModel): @@ -688,7 +685,7 @@ def from_ip_address(ip: IPv4Address) -> "RedirectDNSAction": return RedirectDNSAction(parameter=IPAddressEntry(value=ip)) @staticmethod - def from_dns_type(dns_type: DNSTypeEntryEnum = DNSTypeEntryEnum.HOST) -> "RedirectDNSAction": + def from_dns_type(dns_type: DNSTypeEntryType = "host") -> "RedirectDNSAction": return RedirectDNSAction(parameter=DNSTypeEntry(value=dns_type)) @@ -709,18 +706,18 @@ class ServiceNodeGroupAction(BaseModel): class LossProtectionAction(BaseModel): type: Literal["lossProtect"] = "lossProtect" - parameter: LossProtectionEnum + parameter: LossProtectionType class LossProtectionFECAction(BaseModel): type: Literal["lossProtectFec"] = "lossProtectFec" - parameter: LossProtectionEnum = LossProtectionEnum.FEC_ALWAYS + parameter: LossProtectionType = "fecAlways" value: Optional[str] = Field(default=None, description="BETA number in range 1-5") class LossProtectionPacketDuplicationAction(BaseModel): type: Literal["lossProtectPktDup"] = "lossProtectPktDup" - parameter: LossProtectionEnum = LossProtectionEnum.PACKET_DUPLICATION + parameter: LossProtectionType = "packetDuplication" class SecureInternetGatewayAction(BaseModel): @@ -908,8 +905,8 @@ class Action(BaseModel): class PolicyDefinitionSequenceBase(BaseModel): sequence_id: int = Field(default=0, serialization_alias="sequenceId", validation_alias="sequenceId") sequence_name: str = Field(serialization_alias="sequenceName", validation_alias="sequenceName") - base_action: PolicyActionTypeEnum = Field( - default=PolicyActionTypeEnum.DROP, serialization_alias="baseAction", validation_alias="baseAction" + base_action: PolicyActionType = Field( + default="drop", serialization_alias="baseAction", validation_alias="baseAction" ) sequence_type: SequenceType = Field(serialization_alias="sequenceType", validation_alias="sequenceType") sequence_ip_type: SequenceIpType = Field(serialization_alias="sequenceIpType", validation_alias="sequenceIpType") @@ -1001,16 +998,14 @@ def _remove_action_from_set(self, field_name: str) -> None: def accept_action(method): @wraps(method) def wrapper(self: PolicyDefinitionSequenceBase, *args, **kwargs): - assert ( - self.base_action == PolicyActionTypeEnum.ACCEPT - ), f"{method.__name__} only allowed when base_action is {PolicyActionTypeEnum.ACCEPT}" + assert self.base_action == "accept", f"{method.__name__} only allowed when base_action is accept" return method(self, *args, **kwargs) return wrapper class DefaultAction(BaseModel): - type: PolicyActionTypeEnum + type: PolicyActionType class InfoTag(BaseModel): @@ -1028,7 +1023,7 @@ class PolicyReference(BaseModel): class DefinitionWithSequencesCommonBase(BaseModel): default_action: Optional[DefaultAction] = Field( - default=DefaultAction(type=PolicyActionTypeEnum.DROP), + default=DefaultAction(type="drop"), serialization_alias="defaultAction", validation_alias="defaultAction", ) @@ -1088,7 +1083,7 @@ class PolicyDefinitionBase(BaseModel): description: str = "default description" type: str mode: Optional[str] = None - optimized: Optional[Optimized] = Optimized.FALSE + optimized: Optional[Optimized] = "false" class PolicyDefinitionInfo(PolicyDefinitionBase, PolicyDefinitionId): diff --git a/catalystwan/models/policy/security.py b/catalystwan/models/policy/security.py index 6679b232e..7b79d99d9 100644 --- a/catalystwan/models/policy/security.py +++ b/catalystwan/models/policy/security.py @@ -1,4 +1,3 @@ -from enum import Enum from typing import List, Literal, Optional, Union from uuid import UUID @@ -38,15 +37,15 @@ Field(discriminator="type"), ] +FailureMode = Literal[ + "open", + "close", +] -class FailureMode(str, Enum): - OPEN = "open" - CLOSE = "close" - - -class ZoneToNoZoneInternet(str, Enum): - ALLOW = "allow" - DENY = "deny" +ZoneToNoZoneInternet = Literal[ + "allow", + "deny", +] class HighSpeedLoggingEntry(BaseModel): @@ -70,9 +69,7 @@ class LoggingEntry(BaseModel): class SecurityPolicySettings(BaseModel): logging: Optional[List[LoggingEntry]] = None failure_mode: Optional[FailureMode] = Field(default=None, alias="failureMode") - zone_to_no_zone_internet: ZoneToNoZoneInternet = Field( - default=ZoneToNoZoneInternet.DENY, alias="zoneToNozoneInternet" - ) + zone_to_no_zone_internet: ZoneToNoZoneInternet = Field(default="deny", alias="zoneToNozoneInternet") tcp_syn_flood_limit: Optional[str] = Field(default=None, alias="tcpSynFloodLimit") high_speed_logging: Optional[HighSpeedLoggingEntry] = Field(default=None, alias="highSpeedLogging") audit_trail: Optional[str] = Field(default=None, alias="auditTrail") diff --git a/catalystwan/models/profileparcel/traffic_policy.py b/catalystwan/models/profileparcel/traffic_policy.py deleted file mode 100644 index a8011179c..000000000 --- a/catalystwan/models/profileparcel/traffic_policy.py +++ /dev/null @@ -1,938 +0,0 @@ -# mypy: disable-error-code="valid-type" -# generated by datamodel-codegen: -# filename: apidocs/schema/profileparcel/sdwan/application-priority/traffic-policy/post/request_schema.json -# timestamp: 2023-09-07T08:34:35+00:00 - -from __future__ import annotations - -from enum import Enum -from ipaddress import IPv4Address, IPv6Address -from typing import List, Optional, Union - -from pydantic.v1 import BaseModel, Extra, Field, conint, constr - - -class Entries(BaseModel): - pass - - -class SlaClass(BaseModel): - pass - - -class Set(BaseModel): - pass - - -class Actions(BaseModel): - pass - - -class CgFpPpNameDef(BaseModel): - __root__: constr(regex=r'^[^&<>! "]+$', min_length=1, max_length=128) # noqa: F722 - - -class GlobalOptionTypeDef(Enum): - global_ = "global" - - -class UuidDef(BaseModel): - __root__: constr(regex=r"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}") # noqa: F722 - - -class BooleanDef(BaseModel): - __root__: bool - - -class Ipv4PrefixDef(BaseModel): - __root__: constr( - regex=r"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\/)([0-2]?[0-9]$|[3]?[0-2])" # noqa: F722, E501 - ) - - -class Ipv6PrefixDef(BaseModel): - __root__: constr( - regex=r"((^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*(\/)(\b([0-9]{1,2}|1[01][0-9]|12[0-8])\b)$))" # noqa: F722, E501 - ) - - -class OneOfMatchEntriesSourceIpv6OptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: Ipv6PrefixDef - - -class OneOfMatchEntriesSourceIpv6OptionsDef(BaseModel): - __root__: OneOfMatchEntriesSourceIpv6OptionsDefItem - - -class ColorDef(Enum): - field_3g = "3g" - biz_internet = "biz-internet" - blue = "blue" - bronze = "bronze" - custom1 = "custom1" - custom2 = "custom2" - custom3 = "custom3" - default = "default" - gold = "gold" - green = "green" - lte = "lte" - metro_ethernet = "metro-ethernet" - mpls = "mpls" - private1 = "private1" - private2 = "private2" - private3 = "private3" - private4 = "private4" - private5 = "private5" - private6 = "private6" - public_internet = "public-internet" - red = "red" - silver = "silver" - - -class Count(BaseModel): - __root__: constr(min_length=1, max_length=20) - - -class DestinationRegion(Enum): - primary_region = "primary-region" - secondary_region = "secondary-region" - other_region = "other-region" - - -class Dns(Enum): - request = "request" - response = "response" - - -class Ipv4AddressDef(BaseModel): - class Config: - extra = Extra.forbid - - __root__: IPv4Address - - -class Ipv6AddressDef(BaseModel): - class Config: - extra = Extra.forbid - - __root__: IPv6Address - - -class MatchEntriesDscpDef(BaseModel): - __root__: conint(ge=0, le=63) - - -class MatchEntriesIcmp6MessageDef(Enum): - beyond_scope = "beyond-scope" - cp_advertisement = "cp-advertisement" - cp_solicitation = "cp-solicitation" - destination_unreachable = "destination-unreachable" - dhaad_reply = "dhaad-reply" - dhaad_request = "dhaad-request" - echo_reply = "echo-reply" - echo_request = "echo-request" - header = "header" - hop_limit = "hop-limit" - ind_advertisement = "ind-advertisement" - ind_solicitation = "ind-solicitation" - mld_query = "mld-query" - mld_reduction = "mld-reduction" - mld_report = "mld-report" - mldv2_report = "mldv2-report" - mpd_advertisement = "mpd-advertisement" - mpd_solicitation = "mpd-solicitation" - mr_advertisement = "mr-advertisement" - mr_solicitation = "mr-solicitation" - mr_termination = "mr-termination" - nd_na = "nd-na" - nd_ns = "nd-ns" - next_header_type = "next-header-type" - ni_query = "ni-query" - ni_query_name = "ni-query-name" - ni_query_v4_address = "ni-query-v4-address" - ni_query_v6_address = "ni-query-v6-address" - ni_response = "ni-response" - ni_response_qtype_unknown = "ni-response-qtype-unknown" - ni_response_refuse = "ni-response-refuse" - ni_response_success = "ni-response-success" - no_admin = "no-admin" - no_route = "no-route" - packet_too_big = "packet-too-big" - parameter_option = "parameter-option" - parameter_problem = "parameter-problem" - port_unreachable = "port-unreachable" - reassembly_timeout = "reassembly-timeout" - redirect = "redirect" - reject_route = "reject-route" - renum_command = "renum-command" - renum_result = "renum-result" - renum_seq_number = "renum-seq-number" - router_advertisement = "router-advertisement" - router_renumbering = "router-renumbering" - router_solicitation = "router-solicitation" - rpl_control = "rpl-control" - source_policy = "source-policy" - source_route_header = "source-route-header" - time_exceeded = "time-exceeded" - unreachable = "unreachable" - - -class MatchEntriesIcmpMessageDef(Enum): - administratively_prohibited = "administratively-prohibited" - dod_host_prohibited = "dod-host-prohibited" - dod_net_prohibited = "dod-net-prohibited" - echo = "echo" - echo_reply = "echo-reply" - echo_reply_no_error = "echo-reply-no-error" - extended_echo = "extended-echo" - extended_echo_reply = "extended-echo-reply" - general_parameter_problem = "general-parameter-problem" - host_isolated = "host-isolated" - host_precedence_unreachable = "host-precedence-unreachable" - host_redirect = "host-redirect" - host_tos_redirect = "host-tos-redirect" - host_tos_unreachable = "host-tos-unreachable" - host_unknown = "host-unknown" - host_unreachable = "host-unreachable" - interface_error = "interface-error" - malformed_query = "malformed-query" - multiple_interface_match = "multiple-interface-match" - net_redirect = "net-redirect" - net_tos_redirect = "net-tos-redirect" - net_tos_unreachable = "net-tos-unreachable" - net_unreachable = "net-unreachable" - network_unknown = "network-unknown" - no_room_for_option = "no-room-for-option" - option_missing = "option-missing" - packet_too_big = "packet-too-big" - parameter_problem = "parameter-problem" - photuris = "photuris" - port_unreachable = "port-unreachable" - precedence_unreachable = "precedence-unreachable" - protocol_unreachable = "protocol-unreachable" - reassembly_timeout = "reassembly-timeout" - redirect = "redirect" - router_advertisement = "router-advertisement" - router_solicitation = "router-solicitation" - source_route_failed = "source-route-failed" - table_entry_error = "table-entry-error" - time_exceeded = "time-exceeded" - timestamp_reply = "timestamp-reply" - timestamp_request = "timestamp-request" - ttl_exceeded = "ttl-exceeded" - unreachable = "unreachable" - - -class MatchEntriesTcpDef(Enum): - syn = "syn" - - -class MatchEntriesTrafficClassOptionsDef(Enum): - gold_voip_telephony = "gold-voip-telephony" - gold_broadcast_video = "gold-broadcast-video" - gold_real_time_interactive = "gold-real-time-interactive" - gold_multimedia_conferencing = "gold-multimedia-conferencing" - gold_multimedia_streaming = "gold-multimedia-streaming" - gold_network_control = "gold-network-control" - gold_signaling = "gold-signaling" - gold_ops_admin_mgmt = "gold-ops-admin-mgmt" - gold_transactional_data = "gold-transactional-data" - gold_bulk_data = "gold-bulk-data" - silver = "silver" - bronze = "bronze" - - -class NatPool(BaseModel): - __root__: conint(ge=1, le=31) - - -class ProtocolDef(BaseModel): - __root__: constr(regex=r"^(0|[1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$") # noqa: F722, E501 - - -class RedirectDn(Enum): - umbrella = "umbrella" - host = "host" - - -class RedirectDns(BaseModel): - __root__: Union[RedirectDn, Ipv4AddressDef] - - -class RedirectDnsTypes(Enum): - ip_address = "ipAddress" - dns_host = "dnsHost" - - -class SequencesBaseActionDef(Enum): - drop = "drop" - accept = "accept" - - -class SequencesSequenceIdDef(BaseModel): - __root__: conint(ge=1, le=65536) - - -class SequencesSequenceIpTypeDef(Enum): - ipv4 = "ipv4" - ipv6 = "ipv6" - all = "all" - - -class SequencesSequenceNameDef(BaseModel): - __root__: str - - -class TargetDirectionDef(Enum): - service = "service" - tunnel = "tunnel" - all = "all" - - -class TargetVpnDef(BaseModel): - __root__: str - - -class TrafficTo(Enum): - core = "core" - service = "service" - access = "access" - - -class VpnDef(BaseModel): - class Config: - extra = Extra.forbid - - __root__: conint(ge=0, le=65530) - - -class Encap(Enum): - ipsec = "ipsec" - gre = "gre" - - -class EncapDef(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: Encap - - -class PortNoDef(BaseModel): - __root__: constr( - regex=r"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$" # noqa: F722, E501 - ) - - -class PortRangeDef(BaseModel): - __root__: constr( - regex=r"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\-(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$" # noqa: F722, E501 - ) - - -class SequencesMatchEntriesPacketLengthDef(BaseModel): - __root__: constr( - regex=r"^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$" # noqa: F722, E501 - ) - - -class SequencesMatchEntriesPacketLengthRangeDef(BaseModel): - __root__: constr( - regex=r"^([0-9]|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])\-([1-9]|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$" # noqa: F722, E501 - ) - - -class TypeDefinition(Enum): - fw = "FW" - ids = "IDS" - idp = "IDP" - netsvc1 = "netsvc1" - netsvc2 = "netsvc2" - netsvc3 = "netsvc3" - netsvc4 = "netsvc4" - appqoe = "appqoe" - - -class RefId(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: UuidDef - - -class ParcelReferenceDef(BaseModel): - class Config: - extra = Extra.forbid - - ref_id: RefId = Field(..., alias="refId") - - -class BooleanDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: BooleanDef - - -class BooleanDefModel(BaseModel): - __root__: BooleanDefItem - - -class ColorMatchListDef(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: List[ColorDef] = Field(..., min_items=1, unique_items=True) - - -class CountDef(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: Count - - -class DestinationRegionDef(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: DestinationRegion - - -class DnsDef(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: Dns - - -class Ipv4PrefixDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: Ipv4PrefixDef - - -class Ipv4PrefixDefModel(BaseModel): - __root__: Ipv4PrefixDefItem - - -class UseVpn(BaseModel): - option_type: Optional[GlobalOptionTypeDef] = Field(None, alias="optionType") - value: Optional[BooleanDefModel] = None - - -class NatDef(BaseModel): - class Config: - extra = Extra.forbid - - use_vpn: UseVpn = Field(..., alias="useVpn") - fallback: Optional[BooleanDefModel] = None - - -class NatPoolDef(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: NatPool - - -class OneOfMatchEntriesDestinationIpv6OptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: Ipv6PrefixDef - - -class OneOfMatchEntriesDestinationIpv6OptionsDef(BaseModel): - __root__: OneOfMatchEntriesDestinationIpv6OptionsDefItem - - -class OneOfMatchEntriesDscpOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: MatchEntriesDscpDef - - -class OneOfMatchEntriesDscpOptionsDef(BaseModel): - __root__: OneOfMatchEntriesDscpOptionsDefItem - - -class OneOfMatchEntriesIcmp6MessageOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: List[MatchEntriesIcmp6MessageDef] = Field(..., min_items=1, unique_items=True) - - -class OneOfMatchEntriesIcmp6MessageOptionsDef(BaseModel): - __root__: OneOfMatchEntriesIcmp6MessageOptionsDefItem - - -class OneOfMatchEntriesIcmpMessageOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: List[MatchEntriesIcmpMessageDef] = Field(..., min_items=1, unique_items=True) - - -class OneOfMatchEntriesIcmpMessageOptionsDef(BaseModel): - __root__: OneOfMatchEntriesIcmpMessageOptionsDefItem - - -class OneOfMatchEntriesProtocolOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: List[ProtocolDef] = Field(..., min_items=1, unique_items=True) - - -class OneOfMatchEntriesProtocolOptionsDef(BaseModel): - __root__: OneOfMatchEntriesProtocolOptionsDefItem - - -class OneOfMatchEntriesTcpOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: MatchEntriesTcpDef - - -class OneOfMatchEntriesTcpOptionsDef(BaseModel): - __root__: OneOfMatchEntriesTcpOptionsDefItem - - -class OneOfMatchEntriesTrafficClassOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: MatchEntriesTrafficClassOptionsDef - - -class OneOfMatchEntriesTrafficClassOptionsDef(BaseModel): - __root__: OneOfMatchEntriesTrafficClassOptionsDefItem - - -class FieldModel(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: RedirectDnsTypes - - -class Value(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: RedirectDns - - -class OneOfRedirectDnsDef(BaseModel): - field: Optional[FieldModel] = None - value: Optional[Value] = None - - -class OneOfSequencesBaseActionOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: SequencesBaseActionDef - - -class OneOfSequencesBaseActionOptionsDef(BaseModel): - __root__: OneOfSequencesBaseActionOptionsDefItem - - -class OneOfSequencesSequenceIdOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: SequencesSequenceIdDef - - -class OneOfSequencesSequenceIdOptionsDef(BaseModel): - __root__: OneOfSequencesSequenceIdOptionsDefItem - - -class OneOfSequencesSequenceIpTypeOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: SequencesSequenceIpTypeDef - - -class OneOfSequencesSequenceIpTypeOptionsDef(BaseModel): - __root__: OneOfSequencesSequenceIpTypeOptionsDefItem - - -class OneOfSequencesSequenceNameOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: SequencesSequenceNameDef - - -class OneOfSequencesSequenceNameOptionsDef(BaseModel): - __root__: OneOfSequencesSequenceNameOptionsDefItem - - -class OneOfTargetDirectionOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: TargetDirectionDef - - -class OneOfTargetDirectionOptionsDef(BaseModel): - __root__: OneOfTargetDirectionOptionsDefItem - - -class OneOfTargetVpnOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: List[TargetVpnDef] = Field(..., min_items=1, unique_items=True) - - -class OneOfTargetVpnOptionsDef(BaseModel): - __root__: OneOfTargetVpnOptionsDefItem - - -class SlaClassDef(BaseModel): - class Config: - extra = Extra.forbid - - sla_name: Optional[ParcelReferenceDef] = Field(None, alias="slaName") - preferred_color: Optional[ColorMatchListDef] = Field(None, alias="preferredColor") - preferred_color_group: Optional[ParcelReferenceDef] = Field(None, alias="preferredColorGroup") - strict: Optional[BooleanDefModel] = None - fallback_to_best_path: Optional[BooleanDefModel] = Field(None, alias="fallbackToBestPath") - - -class TrafficToDef(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: TrafficTo - - -class EncapListDef(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: List[Encap] = Field(..., min_items=1, unique_items=True) - - -class Ipv4AddressDefModel(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: Ipv4AddressDef - - -class Ipv6AddressDefModel(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: Ipv6AddressDef - - -class OneOfSequencesMatchEntriesPacketLengthValueDef(BaseModel): - __root__: Union[SequencesMatchEntriesPacketLengthDef, SequencesMatchEntriesPacketLengthRangeDef] - - -class PortValueDef(BaseModel): - __root__: Union[PortNoDef, PortRangeDef] - - -class TlocDef(BaseModel): - class Config: - extra = Extra.forbid - - color: ColorMatchListDef - encap: EncapDef - ip: Ipv4AddressDefModel - - -class TypeDef(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: TypeDefinition - - -class VpnDefModel(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: VpnDef - - -class Restrict(BaseModel): - __root__: BooleanDefModel - - -class Target(BaseModel): - class Config: - extra = Extra.forbid - - vpn: Optional[OneOfTargetVpnOptionsDef] = Field(None, description="") - direction: Optional[OneOfTargetDirectionOptionsDef] = Field(None, description="") - - -class OneOfMatchEntriesDestinationPortOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: List[PortValueDef] = Field(..., min_items=1) - - -class OneOfMatchEntriesDestinationPortOptionsDef(BaseModel): - __root__: OneOfMatchEntriesDestinationPortOptionsDefItem - - -class OneOfMatchEntriesPacketLengthOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: OneOfSequencesMatchEntriesPacketLengthValueDef - - -class OneOfMatchEntriesPacketLengthOptionsDef(BaseModel): - __root__: OneOfMatchEntriesPacketLengthOptionsDefItem - - -class OneOfMatchEntriesSourcePortOptionsDefItem(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: List[PortValueDef] = Field(..., min_items=1) - - -class OneOfMatchEntriesSourcePortOptionsDef(BaseModel): - __root__: OneOfMatchEntriesSourcePortOptionsDefItem - - -class ServiceItem(BaseModel): - class Config: - extra = Extra.forbid - - tloc: TlocDef - vpn: VpnDefModel - type: TypeDef - - -class ServiceItem1(BaseModel): - class Config: - extra = Extra.forbid - - tloc_list: ParcelReferenceDef = Field(..., alias="tlocList") - vpn: VpnDefModel - type: TypeDef - - -class RestrictDef(BaseModel): - class Config: - extra = Extra.forbid - - option_type: GlobalOptionTypeDef = Field(..., alias="optionType") - value: Restrict - - -class Entry(BaseModel): - class Config: - extra = Extra.forbid - - app_list: Optional[ParcelReferenceDef] = Field(None, alias="appList", description="App list Reference") - saas_app_list: Optional[ParcelReferenceDef] = Field( - None, alias="saasAppList", description="Saas App list Reference" - ) - dns_app_list: Optional[ParcelReferenceDef] = Field(None, alias="dnsAppList", description="dns App list Reference") - traffic_class: Optional[OneOfMatchEntriesTrafficClassOptionsDef] = Field( - None, alias="trafficClass", description="Traffic Class" - ) - dscp: Optional[OneOfMatchEntriesDscpOptionsDef] = Field(None, description="DSCP number") - packet_length: Optional[OneOfMatchEntriesPacketLengthOptionsDef] = Field( - None, alias="packetLength", description="Packet Length" - ) - protocol: Optional[OneOfMatchEntriesProtocolOptionsDef] = Field( - None, - description="protocol (0-255) range or individual number separated by space", - ) - icmp_message: Optional[OneOfMatchEntriesIcmpMessageOptionsDef] = Field( - None, alias="icmpMessage", description="ICMP Message" - ) - icmp6_message: Optional[OneOfMatchEntriesIcmp6MessageOptionsDef] = Field( - None, alias="icmp6Message", description="ICMP6 Message" - ) - source_data_prefix_list: Optional[ParcelReferenceDef] = Field( - None, alias="sourceDataPrefixList", description="Source Data Prefix Parcel UUID" - ) - source_data_ipv6_prefix_list: Optional[ParcelReferenceDef] = Field( - None, - alias="sourceDataIpv6PrefixList", - description="Source Data Prefix Parcel UUID", - ) - source_ip: Optional[Ipv4PrefixDefModel] = Field(None, alias="sourceIp", description="Source Data IP Prefix") - source_ipv6: Optional[OneOfMatchEntriesSourceIpv6OptionsDef] = Field( - None, alias="sourceIpv6", description="Source Data IP Prefix" - ) - source_port: Optional[OneOfMatchEntriesSourcePortOptionsDef] = Field( - None, - alias="sourcePort", - description="Source Port (0-65535) range or individual number separated by space", - ) - destination_data_prefix_list: Optional[ParcelReferenceDef] = Field( - None, - alias="destinationDataPrefixList", - description="Destination Data Prefix Parcel UUID", - ) - destination_data_ipv6_prefix_list: Optional[ParcelReferenceDef] = Field( - None, - alias="destinationDataIpv6PrefixList", - description="Destination Data Prefix Parcel UUID", - ) - destination_ip: Optional[Ipv4PrefixDefModel] = Field( - None, alias="destinationIp", description="Destination Data IP Prefix" - ) - destination_ipv6: Optional[OneOfMatchEntriesDestinationIpv6OptionsDef] = Field( - None, alias="destinationIpv6", description="Destination Data IP Prefix" - ) - destination_port: Optional[OneOfMatchEntriesDestinationPortOptionsDef] = Field( - None, - alias="destinationPort", - description="Destination Port (0-65535) range or individual number separated by space", - ) - tcp: Optional[OneOfMatchEntriesTcpOptionsDef] = Field(None, description="TCP States") - destination_region: Optional[DestinationRegionDef] = Field( - None, alias="destinationRegion", description="Destination Region" - ) - traffic_to: Optional[TrafficToDef] = Field(None, alias="trafficTo", description="Traffic to") - dns: Optional[DnsDef] = Field(None, description="Dns") - - -class Match(BaseModel): - class Config: - extra = Extra.forbid - - entries: Union[List[Entry], Entries] = Field(..., unique_items=True) - - -class LocalTlocList(BaseModel): - class Config: - extra = Extra.forbid - - color: ColorMatchListDef - restrict: Optional[RestrictDef] = None - encap: EncapListDef - - -class SetProperties(BaseModel): - class Config: - extra = Extra.forbid - - dscp: Optional[OneOfMatchEntriesDscpOptionsDef] = None - policer: Optional[ParcelReferenceDef] = None - preferred_color_group: Optional[ParcelReferenceDef] = Field(None, alias="preferredColorGroup") - forwarding_class: Optional[ParcelReferenceDef] = Field(None, alias="forwardingClass") - local_tloc_list: Optional[LocalTlocList] = Field(None, alias="localTlocList") - tloc: Optional[TlocDef] = None - tloc_list: Optional[ParcelReferenceDef] = Field(None, alias="tlocList") - service: Optional[Union[ServiceItem, ServiceItem1]] = None - next_hop: Optional[Ipv4AddressDefModel] = Field(None, alias="nextHop") - next_hop_ipv6: Optional[Ipv6AddressDefModel] = Field(None, alias="nextHopIpv6") - next_hop_loose: Optional[BooleanDefModel] = Field(None, alias="nextHopLoose") - vpn: Optional[VpnDefModel] = None - - -class Action(BaseModel): - class Config: - extra = Extra.forbid - - sla_class: Optional[Union[List[SlaClassDef], SlaClass]] = Field(None, alias="slaClass", description="slaClass") - backup_sla_preferred_color: Optional[ColorMatchListDef] = Field( - None, alias="backupSlaPreferredColor", description="Backup SLA perferred color" - ) - set: Optional[Union[List[SetProperties], Set]] = None - redirect_dns: Optional[OneOfRedirectDnsDef] = Field(None, alias="redirectDns") - count: Optional[CountDef] = None - log: Optional[BooleanDefModel] = None - cloud_saas: Optional[BooleanDefModel] = Field(None, alias="cloudSaas") - cflowd: Optional[BooleanDefModel] = None - nat_pool: Optional[NatPoolDef] = Field(None, alias="natPool") - nat: Optional[NatDef] = None - sig: Optional[BooleanDefModel] = None - fallback_to_routing: Optional[BooleanDefModel] = Field(None, alias="fallbackToRouting") - - -class Sequence(BaseModel): - class Config: - extra = Extra.forbid - - sequence_id: Optional[OneOfSequencesSequenceIdOptionsDef] = Field( - None, alias="sequenceId", description="Sequence Id" - ) - sequence_name: Optional[OneOfSequencesSequenceNameOptionsDef] = Field( - None, alias="sequenceName", description="Sequence Name" - ) - base_action: Optional[OneOfSequencesBaseActionOptionsDef] = Field( - None, alias="baseAction", description="Base Action" - ) - sequence_ip_type: Optional[OneOfSequencesSequenceIpTypeOptionsDef] = Field( - None, alias="sequenceIpType", description="Sequence IP Type" - ) - match: Optional[Match] = None - actions: Optional[Union[List[Action], Actions]] = None - - -class Data(BaseModel): - class Config: - extra = Extra.forbid - - simple_flow: Optional[BooleanDefModel] = Field(None, alias="simpleFlow") - target: Optional[Target] = Field(None, description="Target vpn and direction") - sequences: Optional[List[Sequence]] = Field(None, description="Traffic policy sequence list", unique_items=True) - - -class TrafficPolicyParcelSchema(BaseModel): - name: Optional[CgFpPpNameDef] = None - description: Optional[str] = None - data: Data diff --git a/examples/parcel_configuration_guide.py b/examples/parcel_configuration_guide.py index a66bfb264..97e4fa224 100644 --- a/examples/parcel_configuration_guide.py +++ b/examples/parcel_configuration_guide.py @@ -7,7 +7,6 @@ from catalystwan.api.feature_profile_api import PolicyObjectFeatureProfileAPI from catalystwan.endpoints.configuration_feature_profile import ConfigurationFeatureProfile -from catalystwan.models.common import InterfaceTypeEnum, TLOCColorEnum, WellKnownBGPCommunitiesEnum from catalystwan.models.configuration.feature_profile.common import ParcelCreationResponse from catalystwan.models.configuration.feature_profile.sdwan.policy_object import ( ApplicationListParcel, @@ -30,14 +29,12 @@ SecurityDataPrefixParcel, SecurityPortParcel, SecurityZoneListParcel, - SLAClassCriteriaEnum, SLAClassParcel, StandardCommunityParcel, TlocParcel, URLAllowParcel, URLBlockParcel, ) -from catalystwan.models.policy.lists_entries import EncapEnum, PathPreferenceEnum, PolicerExceedActionEnum logger = logging.getLogger(__name__) @@ -128,8 +125,8 @@ def configure_groups_of_interest(profile_id: UUID, api: PolicyObjectFeatureProfi # Create Security Zone parcel and add interfaces security_zone = SecurityZoneListParcel(parcel_name="SecurityZoneListParcel") - security_zone.add_interface(InterfaceTypeEnum.ETHERNET) - security_zone.add_interface(InterfaceTypeEnum.TUNNEL) + security_zone.add_interface("Ethernet") + security_zone.add_interface("Tunnel") # Create Application parcel and add applications security_application_list = SecurityApplicationListParcel(parcel_name="SecurityApplListParcelExample") @@ -154,9 +151,9 @@ def configure_groups_of_interest(profile_id: UUID, api: PolicyObjectFeatureProfi # Create Color parcel and add colors color_parcel = ColorParcel(parcel_name="ColorParcelExample") - color_parcel.add_color(TLOCColorEnum.BIZ_INTERNET) - color_parcel.add_color(TLOCColorEnum.METRO_ETHERNET) - color_parcel.add_color(TLOCColorEnum.PUBLIC_INTERNET) + color_parcel.add_color("biz-internet") + color_parcel.add_color("metro-ethernet") + color_parcel.add_color("public-internet") # Create Data prefix parcel and add data prefixes data_prefix_parcel = DataPrefixParcel(parcel_name="DataPrefixExample") @@ -188,19 +185,15 @@ def configure_groups_of_interest(profile_id: UUID, api: PolicyObjectFeatureProfi # Create Preferred color parcel and add preferred colors preferred_group_color = PreferredColorGroupParcel(parcel_name="PreferredColorGroupParcelExmaple") preferred_group_color.add_primary( - color_preference=[TLOCColorEnum.BIZ_INTERNET, TLOCColorEnum.MPLS], - path_preference=PathPreferenceEnum.DIRECT_PATH, - ) - preferred_group_color.add_secondary( - color_preference=[TLOCColorEnum.BRONZE, TLOCColorEnum.SILVER], path_preference=PathPreferenceEnum.DIRECT_PATH - ) - preferred_group_color.add_tertiary( - color_preference=[TLOCColorEnum.METRO_ETHERNET], path_preference=PathPreferenceEnum.MULTI_HOP_PATH + color_preference=["biz-internet", "mpls"], + path_preference="direct-path", ) + preferred_group_color.add_secondary(color_preference=["bronze", "silver"], path_preference="direct-path") + preferred_group_color.add_tertiary(color_preference=["metro-ethernet"], path_preference="multi-hop-path") # Create Policier parcel and add policiers policier = PolicierParcel(parcel_name="PolicierParcelExmaple") - policier.add_entry(burst=17000, exceed=PolicerExceedActionEnum.DROP, rate=1000) + policier.add_entry(burst=17000, exceed="drop", rate=1000) # Create Fowarding Class parcel and add fowarding classes fowarding_class = FowardingClassParcel(parcel_name="FowardingClassParcelExmaple") @@ -208,18 +201,14 @@ def configure_groups_of_interest(profile_id: UUID, api: PolicyObjectFeatureProfi # Create Tloc Parcel and add tlocs tloc_list = TlocParcel(parcel_name="TlocParcelExample") - tloc_list.add_entry( - tloc=IPv4Address("40.0.0.0"), color=TLOCColorEnum.PRIVATE3, encapsulation=EncapEnum.GRE, preference="1000" - ) - tloc_list.add_entry( - tloc=IPv4Address("50.0.0.0"), color=TLOCColorEnum.CUSTOM1, encapsulation=EncapEnum.GRE, preference="10000" - ) + tloc_list.add_entry(tloc=IPv4Address("40.0.0.0"), color="private3", encapsulation="gre", preference="1000") + tloc_list.add_entry(tloc=IPv4Address("50.0.0.0"), color="custom1", encapsulation="gre", preference="10000") # Create Standard Community Parcel and add standard communities standard_community = StandardCommunityParcel(parcel_name="StandardCommunityParcelExample") - standard_community.add_community(WellKnownBGPCommunitiesEnum.INTERNET) - standard_community.add_community(WellKnownBGPCommunitiesEnum.LOCAL_AS) - standard_community.add_community(WellKnownBGPCommunitiesEnum.NO_ADVERTISE) + standard_community.add_community("internet") + standard_community.add_community("local-AS") + standard_community.add_community("no-advertise") # Create Expanded Community Parcel and add expanded communities expanded_community = ExpandedCommunityParcel(parcel_name="ExpandedCommunityParcel") @@ -230,9 +219,9 @@ def configure_groups_of_interest(profile_id: UUID, api: PolicyObjectFeatureProfi # Create App Probe Parcel and add app probes app_probe = AppProbeParcel(parcel_name="AppProbeParcelExample") app_probe.add_fowarding_class("FowardingClassParcelExmaple") - app_probe.add_map(color=TLOCColorEnum.CUSTOM1, dscp=33) - app_probe.add_map(color=TLOCColorEnum.BLUE, dscp=40) - app_probe.add_map(color=TLOCColorEnum.PUBLIC_INTERNET, dscp=43) + app_probe.add_map(color="custom1", dscp=33) + app_probe.add_map(color="blue", dscp=40) + app_probe.add_map(color="public-internet", dscp=43) items.append(fqdn) items.append(local_domain) @@ -269,9 +258,7 @@ def configure_groups_of_interest(profile_id: UUID, api: PolicyObjectFeatureProfi sla = SLAClassParcel(parcel_name="SLAClassParcelExample") sla.add_entry(app_probe_class_id=_id.id, jitter=20, latency=50, loss=100) - sla.add_fallback( - criteria=SLAClassCriteriaEnum.JITTER_LATENCY_LOSS, latency_variance=10, jitter_variance=10, loss_variance=10 - ) + sla.add_fallback(criteria="jitter-latency-loss", latency_variance=10, jitter_variance=10, loss_variance=10) items_ids.append((api.create(profile_id, sla), sla.__class__)) diff --git a/examples/policies_configuration_guide.py b/examples/policies_configuration_guide.py index 3ec8dea33..7c2abe9df 100644 --- a/examples/policies_configuration_guide.py +++ b/examples/policies_configuration_guide.py @@ -28,11 +28,9 @@ from catalystwan.api.policy_api import PolicyAPI from catalystwan.exceptions import CatalystwanException -from catalystwan.models.common import TLOCColorEnum, WellKnownBGPCommunitiesEnum from catalystwan.models.policy import ( AppList, AppProbeClassList, - CarrierEnum, CentralizedPolicy, ClassMapList, ColorList, @@ -40,25 +38,15 @@ ControlPolicy, DataIPv6PrefixList, DataPrefixList, - DNSTypeEntryEnum, - EncapEnum, ExpandedCommunityList, HubAndSpokePolicy, MeshPolicy, - MultiRegionRoleEnum, - OriginProtocolEnum, - PathPreferenceEnum, - PathTypeEnum, - PolicerExceedActionEnum, PolicerList, - PolicyActionTypeEnum, PreferredColorGroupList, PrefixList, RegionList, - ServiceTypeEnum, SiteList, SLAClassList, - TLOCActionEnum, TLOCList, TrafficDataPolicy, VPNList, @@ -113,21 +101,21 @@ def configure_groups_of_interest(api: PolicyAPI) -> List[ConfigItem]: # Configure Color color_list = ColorList(name="MyColors") - color_list.add_color(TLOCColorEnum.BIZ_INTERNET) - color_list.add_color(TLOCColorEnum.PUBLIC_INTERNET) + color_list.add_color("biz-internet") + color_list.add_color("public-internet") color_list_id = api.lists.create(color_list) configured_items.append(ConfigItem(ColorList, color_list.name, color_list_id)) # Configure Community community_list = CommunityList(name="MyCommunities") community_list.add_community(1000, 10000) - community_list.add_well_known_community(WellKnownBGPCommunitiesEnum.LOCAL_AS) + community_list.add_well_known_community("local-AS") community_list_id = api.lists.create(community_list) configured_items.append(ConfigItem(CommunityList, community_list.name, community_list_id)) expanded_community_list = ExpandedCommunityList(name="MyExpandedCommunities") expanded_community_list.add_community(1000, 9999999) - expanded_community_list.add_well_known_community(WellKnownBGPCommunitiesEnum.INTERNET) + expanded_community_list.add_well_known_community("internet") expanded_community_list_id = api.lists.create(expanded_community_list) configured_items.append(ConfigItem(ExpandedCommunityList, expanded_community_list.name, expanded_community_list_id)) @@ -146,7 +134,7 @@ def configure_groups_of_interest(api: PolicyAPI) -> List[ConfigItem]: # Configure Policer policer = PolicerList(name="MyPolicer") - policer.police(2**17, 8, PolicerExceedActionEnum.REMARK) + policer.police(2**17, 8, "remark") policer_id = api.lists.create(policer) configured_items.append(ConfigItem(PolicerList, policer.name, policer_id)) @@ -196,7 +184,7 @@ def configure_groups_of_interest(api: PolicyAPI) -> List[ConfigItem]: configured_items.append(ConfigItem(ClassMapList, class_map.name, class_map_id)) app_probe_class = AppProbeClassList(name="MyAppProbeClass") - app_probe_class.assign_forwarding_class("MyClassMap").add_color_mapping(TLOCColorEnum.THREEG, 5) + app_probe_class.assign_forwarding_class("MyClassMap").add_color_mapping("3g", 5) app_probe_class_id = api.lists.create(app_probe_class) configured_items.append(ConfigItem(AppProbeClassList, app_probe_class.name, app_probe_class_id)) @@ -210,8 +198,8 @@ def configure_groups_of_interest(api: PolicyAPI) -> List[ConfigItem]: # Configure TLOC tloc_list = TLOCList(name="MyTLOCList") - tloc_list.add_tloc(IPv4Address("10.0.0.55"), color=TLOCColorEnum.BLUE, encap=EncapEnum.GRE) - tloc_list.add_tloc(IPv4Address("10.0.0.56"), color=TLOCColorEnum.SILVER, encap=EncapEnum.IPSEC, preference=5678) + tloc_list.add_tloc(IPv4Address("10.0.0.55"), color="blue", encap="gre") + tloc_list.add_tloc(IPv4Address("10.0.0.56"), color="silver", encap="ipsec", preference=5678) tloc_list_id = api.lists.create(tloc_list) configured_items.append(ConfigItem(TLOCList, tloc_list.name, tloc_list_id)) @@ -247,9 +235,9 @@ def configure_groups_of_interest(api: PolicyAPI) -> List[ConfigItem]: # Configure preffered colors preferred_color_group_list = PreferredColorGroupList(name="MyPreferredColorGroups") preferred_color_group_list.assign_color_groups( - primary=({TLOCColorEnum.GREEN, TLOCColorEnum.LTE, TLOCColorEnum.METRO_ETHERNET}, PathPreferenceEnum.ALL_PATHS), - secondary=({TLOCColorEnum.METRO_ETHERNET}, PathPreferenceEnum.ALL_PATHS), - tertiary=({TLOCColorEnum.PRIVATE1, TLOCColorEnum.PRIVATE2}, PathPreferenceEnum.MULTI_HOP_PATH), + primary=({"green", "lte", "metro-ethernet"}, "all-paths"), + secondary=({"metro-ethernet"}, "all-paths"), + tertiary=({"private1", "private2"}, "multi-hop-path"), ) preferred_color_group_list_id = api.lists.create(preferred_color_group_list) configured_items.append( @@ -303,40 +291,38 @@ def create_custom_control_topology(api: PolicyAPI, items: Sequence[ConfigItem]) policy = ControlPolicy(name="MyControlPolicy") # add first route sequence - route_1 = policy.add_route_sequence(base_action=PolicyActionTypeEnum.ACCEPT) + route_1 = policy.add_route_sequence(base_action="accept") route_1.match_color_list(find_id(items, "MyColors")) route_1.match_community_list(find_id(items, "MyCommunities")) route_1.match_expanded_community_list(find_id(items, "MyExpandedCommunities")) route_1.match_omp_tag(4321) - route_1.match_origin(OriginProtocolEnum.OSPF_INTER_AREA) + route_1.match_origin("ospf-inter-area") route_1.match_originator(IPv4Address("10.0.0.123")) - route_1.match_path_type(PathTypeEnum.DIRECT) + route_1.match_path_type("direct-path") route_1.match_preference(5432) route_1.match_prefix_list(find_id(items, "MyPrefixes")) - route_1.match_region(7, MultiRegionRoleEnum.BORDER) + route_1.match_region(7, "border-router") route_1.associate_affinity_action(3) route_1.associate_community_action("local-AS") route_1.associate_export_to_action(find_id(items, "MyExportVPN")) route_1.associate_omp_tag_action(4) route_1.associate_preference_action(5) - route_1.associate_service_action( - ServiceTypeEnum.INTRUSION_DETECTION_PREVENTION, 19, tloc_list_id=find_id(items, "MyTLOCList") - ) + route_1.associate_service_action("IDP", 19, tloc_list_id=find_id(items, "MyTLOCList")) # add second route sequence - route_2 = policy.add_route_sequence("Route-2", base_action=PolicyActionTypeEnum.ACCEPT) + route_2 = policy.add_route_sequence("Route-2", base_action="accept") route_2.match_region_list(find_id(items, "MyRegions")) - route_2.associate_tloc_action(TLOCActionEnum.PRIMARY) + route_2.associate_tloc_action("primary") # add TLOC sequence - tloc = policy.add_tloc_sequence(base_action=PolicyActionTypeEnum.ACCEPT) - tloc.match_carrier(CarrierEnum.CARRIER_1) + tloc = policy.add_tloc_sequence(base_action="accept") + tloc.match_carrier("carrier1") tloc.match_color_list(find_id(items, "MyColors")) tloc.match_domain_id(6543) tloc.match_group_id(7654) tloc.match_omp_tag(8765) tloc.match_preference(9876) - tloc.match_region_list(find_id(items, "MyRegions"), MultiRegionRoleEnum.EDGE) + tloc.match_region_list(find_id(items, "MyRegions"), "edge-router") tloc.match_site(20) # commit policy to sdwan manager, store id @@ -349,7 +335,7 @@ def create_traffic_data_policy(api: PolicyAPI, items: List[ConfigItem]) -> Confi policy = TrafficDataPolicy(name="MyTrafficDataPolicy") # add first sequence - seq_1 = policy.add_ipv4_sequence(base_action=PolicyActionTypeEnum.ACCEPT) + seq_1 = policy.add_ipv4_sequence(base_action="accept") seq_1.match_app_list(find_id(items, "Microsoft_Apps")) seq_1.match_destination_ip([IPv4Network("19.3.0.0/16")]) seq_1.match_destination_port(port_ranges=[(1000, 5000)]) @@ -375,7 +361,7 @@ def create_traffic_data_policy(api: PolicyAPI, items: List[ConfigItem]) -> Confi seq_1.associate_nat_action(nat_pool=1) # add second sequence - seq_2 = policy.add_ipv4_sequence("Second Sequence", base_action=PolicyActionTypeEnum.ACCEPT) + seq_2 = policy.add_ipv4_sequence("Second Sequence", base_action="accept") seq_2.match_dns_response() seq_2.match_low_plp() seq_2.match_secondary_destination_region() @@ -387,7 +373,7 @@ def create_traffic_data_policy(api: PolicyAPI, items: List[ConfigItem]) -> Confi seq_2.associate_next_hop_action(next_hop=IPv4Address("12.0.1.12"), loose=True) seq_2.associate_policer_list_action(find_id(items, "MyPolicer")) seq_2.associate_preffered_color_group(find_id(items, "MyPreferredColorGroups")) - seq_2.associate_redirect_dns_action(dns_type=DNSTypeEntryEnum.HOST) + seq_2.associate_redirect_dns_action(dns_type="host") seq_2.associate_secure_internet_gateway_action(fallback_to_routing=True) seq_2.associate_tloc_action(tloc_list_id=find_id(items, "MyTLOCList")) seq_2.associate_vpn_action(11) diff --git a/examples/policy_forwarding_qos.py b/examples/policy_forwarding_qos.py index ca6023495..d56c3da7f 100644 --- a/examples/policy_forwarding_qos.py +++ b/examples/policy_forwarding_qos.py @@ -23,8 +23,6 @@ from typing import Dict, Optional from uuid import UUID -from catalystwan.models.policy import PLPEntryEnum, PolicyActionTypeEnum, QoSDropEnum, TrafficDataDirectionEnum - logger = logging.getLogger(__name__) @@ -128,7 +126,7 @@ def run_demo(args: CmdArguments): qos_map.add_scheduler(queue=3, class_map_ref=pol_dict["DEFAULT"], bandwidth=20, buffer=20) qos_map.add_scheduler(queue=4, class_map_ref=pol_dict["INTERACTIVE_VIDEO"], bandwidth=20, buffer=20) qos_map.add_scheduler( - queue=5, class_map_ref=pol_dict["CONTROL_SIGNALING"], bandwidth=10, buffer=10, drops=QoSDropEnum.TAIL + queue=5, class_map_ref=pol_dict["CONTROL_SIGNALING"], bandwidth=10, buffer=10, drops="tail-drop" ) pol_dict["My-QosMap-Policy"] = api.definitions.create(qos_map) @@ -167,20 +165,17 @@ def run_demo(args: CmdArguments): logger.info("II.C. Configure Localized Policy: Create Re-write Policy") from catalystwan.models.policy import RewritePolicy - _low = PLPEntryEnum.LOW - _high = PLPEntryEnum.HIGH - rw_pol = RewritePolicy(name="My-Rewrite-Policy") - rw_pol.add_rule(class_map_ref=pol_dict["BULK"], plp=_low, dscp=10, l2cos=1) - rw_pol.add_rule(class_map_ref=pol_dict["BULK"], plp=_high, dscp=10, l2cos=1) - rw_pol.add_rule(class_map_ref=pol_dict["DEFAULT"], plp=_low, dscp=0, l2cos=0) - rw_pol.add_rule(class_map_ref=pol_dict["DEFAULT"], plp=_high, dscp=0, l2cos=0) - rw_pol.add_rule(class_map_ref=pol_dict["CONTROL_SIGNALING"], plp=_low, dscp=18, l2cos=2) - rw_pol.add_rule(class_map_ref=pol_dict["CONTROL_SIGNALING"], plp=_high, dscp=18, l2cos=2) - rw_pol.add_rule(class_map_ref=pol_dict["CRITICAL_DATA"], plp=_low, dscp=18, l2cos=2) - rw_pol.add_rule(class_map_ref=pol_dict["CRITICAL_DATA"], plp=_high, dscp=18, l2cos=2) - rw_pol.add_rule(class_map_ref=pol_dict["BULK"], plp=_low, dscp=10, l2cos=4) - rw_pol.add_rule(class_map_ref=pol_dict["BULK"], plp=_high, dscp=10, l2cos=4) + rw_pol.add_rule(class_map_ref=pol_dict["BULK"], plp="low", dscp=10, l2cos=1) + rw_pol.add_rule(class_map_ref=pol_dict["BULK"], plp="high", dscp=10, l2cos=1) + rw_pol.add_rule(class_map_ref=pol_dict["DEFAULT"], plp="low", dscp=0, l2cos=0) + rw_pol.add_rule(class_map_ref=pol_dict["DEFAULT"], plp="high", dscp=0, l2cos=0) + rw_pol.add_rule(class_map_ref=pol_dict["CONTROL_SIGNALING"], plp="low", dscp=18, l2cos=2) + rw_pol.add_rule(class_map_ref=pol_dict["CONTROL_SIGNALING"], plp="high", dscp=18, l2cos=2) + rw_pol.add_rule(class_map_ref=pol_dict["CRITICAL_DATA"], plp="low", dscp=18, l2cos=2) + rw_pol.add_rule(class_map_ref=pol_dict["CRITICAL_DATA"], plp="high", dscp=18, l2cos=2) + rw_pol.add_rule(class_map_ref=pol_dict["BULK"], plp="low", dscp=10, l2cos=4) + rw_pol.add_rule(class_map_ref=pol_dict["BULK"], plp="high", dscp=10, l2cos=4) pol_dict["My-Rewrite-Policy"] = api.definitions.create(rw_pol) loc_pol.add_rewrite_rule(pol_dict["My-Rewrite-Policy"]) pol_dict["My-Localized-Policy"] = api.localized.create(loc_pol) @@ -246,7 +241,7 @@ def run_demo(args: CmdArguments): centralized_pol = CentralizedPolicy(policy_name="My-Centralized-Policy") data_pol = TrafficDataPolicy(name="My-Traffic-Data-Policy") - data_pol_seq = data_pol.add_ipv4_sequence(base_action=PolicyActionTypeEnum.ACCEPT) + data_pol_seq = data_pol.add_ipv4_sequence(base_action="accept") data_pol_seq.associate_forwarding_class_action(fwclass="CONTROL_SIGNALING") pol_dict["My-Traffic-Data-Policy"] = api.definitions.create(data_pol) @@ -274,9 +269,7 @@ def run_demo(args: CmdArguments): vpn_list.add_vpn_range((100, 300)) pol_dict["My-VPN-List"] = api.lists.create(vpn_list) - pol_application.assign_to( - [pol_dict["My-VPN-List"]], TrafficDataDirectionEnum.TUNNEL, site_lists=[pol_dict["My-Site-List"]] - ) + pol_application.assign_to([pol_dict["My-VPN-List"]], "tunnel", site_lists=[pol_dict["My-Site-List"]]) pol_dict["My-Centralized-Policy"] = api.centralized.create(centralized_pol) try: