From 96f74d25f931a8beff002d09997f2aa9e396eeae Mon Sep 17 00:00:00 2001 From: Jakub Krajewski Date: Thu, 21 Nov 2024 19:46:24 +0100 Subject: [PATCH 1/2] fix --- .../feature_profile/sdwan/service/lan/ethernet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 e966237b..e2753c7b 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/service/lan/ethernet.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/service/lan/ethernet.py @@ -139,7 +139,7 @@ class Trustsec(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid") enable_sgt_propagation: Union[Global[bool], Default[bool]] = Field( - serialization_alias="enableSGTPropagation", + serialization_alias="enableSGTPropogation", validation_alias="enableSGTPropogation", default=Default[bool](value=False), ) @@ -151,7 +151,7 @@ class Trustsec(BaseModel): ) enable_enforced_propagation: Union[Global[bool], Default[None]] = Field( default=Default[None](value=None), - serialization_alias="enableEnforcedPropagation", + serialization_alias="enableEnforcedPropogation", validation_alias="enableEnforcedPropogation", ) enforced_security_group_tag: Union[Global[int], Variable, Default[None]] = Field( From 5d3a0afdcfd767155be65fc00a24412b74293fff Mon Sep 17 00:00:00 2001 From: Szymon Basan Date: Fri, 22 Nov 2024 11:40:37 +0100 Subject: [PATCH 2/2] fix: mypy violations --- catalystwan/api/templates/models/aaa_model.py | 10 +- .../api/templates/models/cisco_aaa_model.py | 3 +- .../api/templates/models/cisco_system.py | 4 +- .../api/templates/models/cisco_vpn_model.py | 1 - .../templates/models/system_vsmart_model.py | 2 +- .../models/vpn_vsmart_interface_model.py | 2 +- .../configuration/software_actions.py | 8 +- .../configuration_dashboard_status.py | 4 +- catalystwan/models/common.py | 7 +- .../configuration/feature_profile/common.py | 4 +- .../application_priority/traffic_policy.py | 127 ++++++++---------- .../policy_object/security/ssl_decryption.py | 6 +- .../security/ssl_decryption_profile.py | 2 +- .../sdwan/system/logging_parcel.py | 8 +- .../sdwan/topology/custom_control.py | 2 +- .../models/policy/definition/url_filtering.py | 2 +- catalystwan/models/policy/list/identity.py | 4 +- .../tests/templates/test_serialize_model.py | 2 +- pyproject.toml | 2 +- 19 files changed, 89 insertions(+), 111 deletions(-) diff --git a/catalystwan/api/templates/models/aaa_model.py b/catalystwan/api/templates/models/aaa_model.py index 5894624b..5fbd655f 100644 --- a/catalystwan/api/templates/models/aaa_model.py +++ b/catalystwan/api/templates/models/aaa_model.py @@ -131,7 +131,7 @@ class RadiusServer(FeatureTemplateValidator): description="The accounting port for the RADIUS server", ) vpn: Optional[str] = Field( - default=0, + default="0", json_schema_extra={"vmanage_key": "vpn"}, description="Set VPN in which RADIUS server is located", ) @@ -159,7 +159,7 @@ class TacacsServer(FeatureTemplateValidator): description="The authentication port for the TACACS+ server", ) vpn: Optional[str] = Field( - default=0, + default="0", json_schema_extra={"vmanage_key": "vpn"}, description="Set VPN in which TACACS+ server is located", ) @@ -185,7 +185,7 @@ class TaskPermissions(FeatureTemplateValidator): description="Select the task to set privileges for", ) permission: List[TaskPermission] = Field( - default="pap", + default=["read"], # type: ignore json_schema_extra={ "vmanage_key": "permission", }, @@ -207,7 +207,7 @@ class UserGroup(FeatureTemplateValidator): json_schema_extra={"vmanage_key": "name"}, description="Set name of user group", ) - task: List[TaskPermissions] = Field( + task: Optional[List[TaskPermissions]] = Field( default=None, json_schema_extra={"vmanage_key": "task", "priority_order": ["mode", "permission"]}, description="Set the user group's tasks and task privileges. Skipping tasks sets all as read and write", @@ -220,7 +220,7 @@ class AAAModel(FeatureTemplate): auth_order: Optional[List[AuthenticationOrder]] = Field( validate_default=True, - default=["local", "radius", "tacacs"], + default=["local", "radius", "tacacs"], # type: ignore json_schema_extra={"vmanage_key": "auth-order", "data_path": ["aaa"]}, description="ServerGroups authentication order to user access", ) diff --git a/catalystwan/api/templates/models/cisco_aaa_model.py b/catalystwan/api/templates/models/cisco_aaa_model.py index cbe4fc8a..067dbade 100644 --- a/catalystwan/api/templates/models/cisco_aaa_model.py +++ b/catalystwan/api/templates/models/cisco_aaa_model.py @@ -138,7 +138,7 @@ class RadiusGroup(FeatureTemplateValidator): json_schema_extra={"vmanage_key": "group-name"}, description="The name of the RADIUS group", ) - vpn: Optional[int] = Field(description="The VPN ID for the RADIUS group") + vpn: Optional[int] = Field(default=None, description="The VPN ID for the RADIUS group") source_interface: Optional[str] = Field( json_schema_extra={"vmanage_key": "source-interface"}, description="The source interface for the RADIUS group", @@ -154,7 +154,6 @@ class RadiusVPN(FeatureTemplateValidator): }, ) server_key: str = Field( - default=None, description="Specify a RADIUS client server-key", json_schema_extra={ "vmanage_key": "server-key", diff --git a/catalystwan/api/templates/models/cisco_system.py b/catalystwan/api/templates/models/cisco_system.py index a1654bdb..1809ca4a 100644 --- a/catalystwan/api/templates/models/cisco_system.py +++ b/catalystwan/api/templates/models/cisco_system.py @@ -1,7 +1,7 @@ # Copyright 2023 Cisco Systems, Inc. and its affiliates from pathlib import Path -from typing import ClassVar, List, Literal, Optional +from typing import ClassVar, List, Literal, Optional, Union from pydantic import ConfigDict, Field @@ -176,7 +176,7 @@ class CiscoSystemModel(FeatureTemplate): overlay_id: Optional[int] = Field( default=None, description="The overlay ID of the device.", json_schema_extra={"vmanage_key": "overlay-id"} ) - site_id: int = Field( + site_id: Union[int, DeviceVariable] = Field( default=DeviceVariable(name="system_site_id"), description="The site ID of the device.", json_schema_extra={"vmanage_key": "site-id"}, diff --git a/catalystwan/api/templates/models/cisco_vpn_model.py b/catalystwan/api/templates/models/cisco_vpn_model.py index d1e9fd0d..564b07f6 100644 --- a/catalystwan/api/templates/models/cisco_vpn_model.py +++ b/catalystwan/api/templates/models/cisco_vpn_model.py @@ -260,7 +260,6 @@ class Natpool(FeatureTemplateValidator): json_schema_extra={"vmanage_key": "prefix-length"}, ) range_start: str = Field( - default=None, description="The starting IP address for the NAT pool range.", json_schema_extra={"vmanage_key": "range-start"}, ) diff --git a/catalystwan/api/templates/models/system_vsmart_model.py b/catalystwan/api/templates/models/system_vsmart_model.py index 6f962c63..845fdfd7 100644 --- a/catalystwan/api/templates/models/system_vsmart_model.py +++ b/catalystwan/api/templates/models/system_vsmart_model.py @@ -68,7 +68,7 @@ class SystemVsmart(FeatureTemplate): description="Geographical longitude of the vSmart controller", ) device_groups: List[str] = Field( - default=None, + default_factory=list, json_schema_extra={"vmanage_key": "device-groups"}, description="Device group names for the vSmart controller", ) diff --git a/catalystwan/api/templates/models/vpn_vsmart_interface_model.py b/catalystwan/api/templates/models/vpn_vsmart_interface_model.py index c6e24b68..f270d5e8 100644 --- a/catalystwan/api/templates/models/vpn_vsmart_interface_model.py +++ b/catalystwan/api/templates/models/vpn_vsmart_interface_model.py @@ -30,7 +30,7 @@ class VpnVsmartInterfaceModel(FeatureTemplate): model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True) _docs_description: str = "vSmart VPN Interface Feature Template configuration" - if_name: str = Field( + if_name: Optional[str] = Field( default=None, description="The name of the interface.", json_schema_extra={"vmanage_key": "if-name"} ) interface_description: Optional[str] = Field( diff --git a/catalystwan/endpoints/configuration/software_actions.py b/catalystwan/endpoints/configuration/software_actions.py index eab9f68f..9028072f 100644 --- a/catalystwan/endpoints/configuration/software_actions.py +++ b/catalystwan/endpoints/configuration/software_actions.py @@ -100,8 +100,8 @@ class RemoteServerInfo(BaseModel): class SoftwareRemoteServer(BaseModel): model_config = ConfigDict(populate_by_name=True) - filename: str = Field(default=None, serialization_alias="fileName", validation_alias="fileName") - remote_server_id: str = Field(default=None, serialization_alias="remoteServerId", validation_alias="remoteServerId") + filename: str = Field(serialization_alias="fileName", validation_alias="fileName") + remote_server_id: str = Field(serialization_alias="remoteServerId", validation_alias="remoteServerId") smu_defect_id: Optional[str] = Field( default=None, serialization_alias="smuDefectId", validation_alias="smuDefectId" ) @@ -158,7 +158,9 @@ class SoftwareImageDetails(BaseModel): vnf_properties_json: Optional[str] = Field( default=None, serialization_alias="vnfPropertiesJson", validation_alias="vnfPropertiesJson" ) - remote_server_id: str = Field(default=None, serialization_alias="remoteServerId", validation_alias="remoteServerId") + remote_server_id: Optional[str] = Field( + default=None, serialization_alias="remoteServerId", validation_alias="remoteServerId" + ) class ConfigurationSoftwareActions(APIEndpoints): diff --git a/catalystwan/endpoints/configuration_dashboard_status.py b/catalystwan/endpoints/configuration_dashboard_status.py index 0df41fd1..125ef94c 100644 --- a/catalystwan/endpoints/configuration_dashboard_status.py +++ b/catalystwan/endpoints/configuration_dashboard_status.py @@ -61,7 +61,7 @@ class Validation(BaseModel): device_id: Optional[str] = Field(default=None, serialization_alias="deviceID", validation_alias="deviceID") uuid: Optional[str] = Field(default=None, serialization_alias="uuid", validation_alias="uuid") rid: Optional[int] = Field(default=None, serialization_alias="@rid", validation_alias="@rid") - status_id: str = Field(default=None, serialization_alias="statusId", validation_alias="statusId") + status_id: str = Field(serialization_alias="statusId", validation_alias="statusId") process_id: Optional[str] = Field(default=None, serialization_alias="processId", validation_alias="processId") action_config: Optional[Union[str, Dict]] = Field( default=None, serialization_alias="actionConfig", validation_alias="actionConfig" @@ -74,7 +74,7 @@ class Validation(BaseModel): request_status: Optional[str] = Field( default=None, serialization_alias="requestStatus", validation_alias="requestStatus" ) - status: OperationStatus = Field(default=None, serialization_alias="status", validation_alias="status") + status: OperationStatus = Field(serialization_alias="status", validation_alias="status") order: Optional[int] = Field(default=None, serialization_alias="order", validation_alias="order") diff --git a/catalystwan/models/common.py b/catalystwan/models/common.py index 97f9e4c7..12339945 100644 --- a/catalystwan/models/common.py +++ b/catalystwan/models/common.py @@ -678,15 +678,14 @@ def str_as_interface_list(val: Union[str, Sequence[InterfaceStr]]) -> Sequence[I _PolicyModeType = Literal["security", "unified"] + def parse_policy_mode(val: Optional[str]) -> _PolicyModeType: if isinstance(val, str) and val == "unified": return "unified" return "security" -PolicyModeType = Annotated[ - _PolicyModeType, - BeforeValidator(parse_policy_mode) -] + +PolicyModeType = Annotated[_PolicyModeType, BeforeValidator(parse_policy_mode)] CoreRegion = Literal[ diff --git a/catalystwan/models/configuration/feature_profile/common.py b/catalystwan/models/configuration/feature_profile/common.py index a9d1c1a1..b1d30422 100644 --- a/catalystwan/models/configuration/feature_profile/common.py +++ b/catalystwan/models/configuration/feature_profile/common.py @@ -194,9 +194,7 @@ class WANIPv4StaticRoute(BaseModel): gateway: Global[Literal["nextHop", "null0", "dhcp"]] = Field( default=Global(value="nextHop"), serialization_alias="gateway", validation_alias="gateway" ) - next_hops: Optional[List[NextHop]] = Field( - default_factory=list, serialization_alias="nextHop", validation_alias="nextHop" - ) + next_hops: Optional[List[NextHop]] = Field(default=None, serialization_alias="nextHop", validation_alias="nextHop") distance: Optional[Global[int]] = Field(default=None, serialization_alias="distance", validation_alias="distance") def set_to_next_hop( diff --git a/catalystwan/models/configuration/feature_profile/sdwan/application_priority/traffic_policy.py b/catalystwan/models/configuration/feature_profile/sdwan/application_priority/traffic_policy.py index 617d2285..5b7d5b76 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/application_priority/traffic_policy.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/application_priority/traffic_policy.py @@ -66,115 +66,104 @@ class TrafficPolicyTarget(BaseModel): class AppListMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - app_list: RefIdItem = Field(default=None, validation_alias="appList", serialization_alias="appList") + app_list: RefIdItem = Field(validation_alias="appList", serialization_alias="appList") class SaasAppListMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - saas_app_list: RefIdItem = Field(default=None, validation_alias="saasAppList", serialization_alias="saasAppList") + saas_app_list: RefIdItem = Field(validation_alias="saasAppList", serialization_alias="saasAppList") class ServiceAreaMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") service_area: Global[List[ServiceAreaValue]] = Field( - default=None, validation_alias="serviceArea", serialization_alias="serviceArea" + validation_alias="serviceArea", serialization_alias="serviceArea" ) class TrafficCategoryMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") traffic_category: Global[TrafficCategory] = Field( - default=None, validation_alias="trafficCategory", serialization_alias="trafficCategory" + validation_alias="trafficCategory", serialization_alias="trafficCategory" ) class DnsAppListMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - dns_app_list: RefIdItem = Field(default=None, validation_alias="dnsAppList", serialization_alias="dnsAppList") + dns_app_list: RefIdItem = Field(validation_alias="dnsAppList", serialization_alias="dnsAppList") class TrafficClassMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - traffic_class: Global[TrafficClass] = Field( - default=None, validation_alias="trafficClass", serialization_alias="trafficClass" - ) + traffic_class: Global[TrafficClass] = Field(validation_alias="trafficClass", serialization_alias="trafficClass") class DscpMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - dscp: Global[int] = Field(default=None) + dscp: Global[int] class PacketLengthMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - packet_length: Global[str] = Field( - default=None, validation_alias="packetLength", serialization_alias="packetLength" - ) + packet_length: Global[str] = Field(validation_alias="packetLength", serialization_alias="packetLength") class ProtocolMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - protocol: Global[List[str]] = Field(default=None) + protocol: Global[List[str]] class IcmpMessageMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - icmp_message: Global[List[IcmpMsgType]] = Field( - default=None, validation_alias="icmpMessage", serialization_alias="icmpMessage" - ) + icmp_message: Global[List[IcmpMsgType]] = Field(validation_alias="icmpMessage", serialization_alias="icmpMessage") class Icmp6MessageMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") icmp6_message: Global[List[Icmp6MsgType]] = Field( - default=None, validation_alias="icmp6Message", serialization_alias="icmp6Message" + validation_alias="icmp6Message", serialization_alias="icmp6Message" ) class SourceDataPrefixListMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") source_data_prefix_list: RefIdItem = Field( - default=None, validation_alias="sourceDataPrefixList", serialization_alias="sourceDataPrefixList" + validation_alias="sourceDataPrefixList", serialization_alias="sourceDataPrefixList" ) class SourceDataIpv6PrefixListMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") source_data_ipv6_prefix_list: RefIdItem = Field( - default=None, validation_alias="sourceDataIpv6PrefixList", serialization_alias="sourceDataIpv6PrefixList" + validation_alias="sourceDataIpv6PrefixList", serialization_alias="sourceDataIpv6PrefixList" ) class SourceIpMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - source_ip: Global[IPv4Network] = Field(default=None, validation_alias="sourceIp", serialization_alias="sourceIp") + source_ip: Global[IPv4Network] = Field(validation_alias="sourceIp", serialization_alias="sourceIp") class SourceIpv6Match(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - source_ipv6: Global[IPv6Network] = Field( - default=None, validation_alias="sourceIpv6", serialization_alias="sourceIpv6" - ) + source_ipv6: Global[IPv6Network] = Field(validation_alias="sourceIpv6", serialization_alias="sourceIpv6") class SourcePortMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - source_port: Global[List[str]] = Field( - default=None, validation_alias="sourcePort", serialization_alias="sourcePort" - ) + source_port: Global[List[str]] = Field(validation_alias="sourcePort", serialization_alias="sourcePort") class DestinationDataPrefixListMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") destination_data_prefix_list: RefIdItem = Field( - default=None, validation_alias="destinationDataPrefixList", serialization_alias="destinationDataPrefixList" + validation_alias="destinationDataPrefixList", serialization_alias="destinationDataPrefixList" ) class DestinationDataIpv6PrefixListMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") destination_data_ipv6_prefix_list: RefIdItem = Field( - default=None, validation_alias="destinationDataIpv6PrefixList", serialization_alias="destinationDataIpv6PrefixList", ) @@ -182,22 +171,20 @@ class DestinationDataIpv6PrefixListMatch(BaseModel): class DestinationIpMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - destination_ip: Global[IPv4Network] = Field( - default=None, validation_alias="destinationIp", serialization_alias="destinationIp" - ) + destination_ip: Global[IPv4Network] = Field(validation_alias="destinationIp", serialization_alias="destinationIp") class DestinationIpv6Match(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") destination_ipv6: Global[IPv6Network] = Field( - default=None, validation_alias="destinationIpv6", serialization_alias="destinationIpv6" + validation_alias="destinationIpv6", serialization_alias="destinationIpv6" ) class DestinationPortMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") destination_port: Global[List[str]] = Field( - default=None, validation_alias="destinationPort", serialization_alias="destinationPort" + validation_alias="destinationPort", serialization_alias="destinationPort" ) @@ -209,20 +196,18 @@ class TcpMatch(BaseModel): class DestinationRegionMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") destination_region: Global[DestinationRegion] = Field( - default=None, validation_alias="destinationRegion", serialization_alias="destinationRegion" + validation_alias="destinationRegion", serialization_alias="destinationRegion" ) class TrafficToMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - traffic_to: Global[TrafficTargetType] = Field( - default=None, validation_alias="trafficTo", serialization_alias="trafficTo" - ) + traffic_to: Global[TrafficTargetType] = Field(validation_alias="trafficTo", serialization_alias="trafficTo") class DnsMatch(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - dns: Global[DNSEntryType] = Field(default=None) + dns: Global[DNSEntryType] Entry = Union[ @@ -282,7 +267,7 @@ class SlaClass(BaseModel): class LocalTlocList(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - color: Global[List[TLOCColor]] = Field(default=None) + color: Global[List[TLOCColor]] encap: Optional[Union[Global[EncapType], Global[List[EncapType]]]] = Field( default=None, description="encap is list <=20.12" ) @@ -295,7 +280,7 @@ def make_encap_list(self): class PreferredRemoteColor(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - color: Global[List[TLOCColor]] = Field(default=None) + color: Global[List[TLOCColor]] remote_color_restrict: Optional[Global[Global[bool]]] = Field( default=None, validation_alias="remoteColorRestrict", serialization_alias="remoteColorRestrict" ) @@ -303,16 +288,16 @@ class PreferredRemoteColor(BaseModel): class Tloc(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - color: Global[List[TLOCColor]] = Field(default=None) - encap: Global[EncapType] = Field(default=None) - ip: Global[IPv4Address] = Field(default=None) + color: Global[List[TLOCColor]] + encap: Global[EncapType] + ip: Global[IPv4Address] class ServiceTloc(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") tloc: Tloc = Field() - type: Global[ServiceType] = Field(default=None) - vpn: Global[int] = Field(default=None) + type: Global[ServiceType] + vpn: Global[int] class ServiceTlocList(BaseModel): @@ -324,11 +309,11 @@ class ServiceTlocList(BaseModel): class ServiceChain(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - local: Global[bool] = Field(default=None) - restrict: Global[bool] = Field(default=None) + local: Global[bool] + restrict: Global[bool] tloc: Optional[Tloc] = Field(default=None) tloc_list: Optional[RefIdItem] = Field(default=None, validation_alias="tlocList", serialization_alias="tlocList") - type: Global[ServiceChainNumber] = Field(default=None) + type: Global[ServiceChainNumber] vpn: Optional[Global[int]] = Field(default=None) @@ -464,9 +449,7 @@ class AppqoeOptimization(BaseModel): dre_optimization: Optional[Global[bool]] = Field( default=None, validation_alias="dreOptimization", serialization_alias="dreOptimization" ) - service_node_group: Global[str] = Field( - default=None, validation_alias="serviceNodeGroup", serialization_alias="serviceNodeGroup" - ) + service_node_group: Global[str] = Field(validation_alias="serviceNodeGroup", serialization_alias="serviceNodeGroup") tcp_optimization: Optional[Global[bool]] = Field( default=None, validation_alias="tcpOptimization", serialization_alias="tcpOptimization" ) @@ -484,7 +467,7 @@ class LossCorrection(BaseModel): default=None, validation_alias="lossCorrectFec", serialization_alias="lossCorrectFec" ) loss_correction_type: Global[LossProtectionType] = Field( - default=None, validation_alias="lossCorrectionType", serialization_alias="lossCorrectionType" + validation_alias="lossCorrectionType", serialization_alias="lossCorrectionType" ) @@ -498,7 +481,7 @@ class Nat(BaseModel): default=None, validation_alias="diaPool", serialization_alias="diaPool" ) fallback: Optional[Global[bool]] = Field(default=None) - use_vpn: Global[bool] = Field(default=None, validation_alias="useVpn", serialization_alias="useVpn") + use_vpn: Global[bool] = Field(validation_alias="useVpn", serialization_alias="useVpn") @model_serializer(mode="wrap", when_used="json") def serialize(self, handler: SerializerFunctionWrapHandler, info: SerializationInfo) -> Dict[str, Any]: @@ -514,10 +497,10 @@ def serialize(self, handler: SerializerFunctionWrapHandler, info: SerializationI class Sse(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") secure_service_edge: Global[Global[bool]] = Field( - default=None, validation_alias="secureServiceEdge", serialization_alias="secureServiceEdge" + validation_alias="secureServiceEdge", serialization_alias="secureServiceEdge" ) secure_service_edge_instance: Global[SecureServiceEdgeInstance] = Field( - default=None, validation_alias="secureServiceEdgeInstance", serialization_alias="secureServiceEdgeInstance" + validation_alias="secureServiceEdgeInstance", serialization_alias="secureServiceEdgeInstance" ) @@ -561,7 +544,7 @@ def from_params( class BackupSlaPreferredColorAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") backup_sla_preferred_color: Global[List[TLOCColor]] = Field( - default=None, validation_alias="backupSlaPreferredColor", serialization_alias="backupSlaPreferredColor" + validation_alias="backupSlaPreferredColor", serialization_alias="backupSlaPreferredColor" ) @@ -570,7 +553,7 @@ class BackupSlaPreferredColorAction(BaseModel): class SetAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - set: List[Set] = Field(default=None) + set: List[Set] = Field(default_factory=list) @property def _set(self): @@ -600,73 +583,71 @@ def _insert_action(self, action: Set) -> None: class RedirectDnsAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - redirect_dns: RedirectDns = Field(default=None, validation_alias="redirectDns", serialization_alias="redirectDns") + redirect_dns: RedirectDns = Field(validation_alias="redirectDns", serialization_alias="redirectDns") class AppqoeOptimizationAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") appqoe_optimization: AppqoeOptimization = Field( - default=None, validation_alias="appqoeOptimization", serialization_alias="appqoeOptimization" + validation_alias="appqoeOptimization", serialization_alias="appqoeOptimization" ) class LossCorrectionAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - loss_correction: LossCorrection = Field( - default=None, validation_alias="lossCorrection", serialization_alias="lossCorrection" - ) + loss_correction: LossCorrection = Field(validation_alias="lossCorrection", serialization_alias="lossCorrection") class CountAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - count: Global[str] = Field(default=None) + count: Global[str] class LogAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - log: Global[bool] = Field(default=None) + log: Global[bool] class CloudSaasAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - cloud_saas: Global[bool] = Field(default=None, validation_alias="cloudSaas", serialization_alias="cloudSaas") + cloud_saas: Global[bool] = Field(validation_alias="cloudSaas", serialization_alias="cloudSaas") class CloudProbeAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - cloud_probe: Global[bool] = Field(default=None, validation_alias="cloudProbe", serialization_alias="cloudProbe") + cloud_probe: Global[bool] = Field(validation_alias="cloudProbe", serialization_alias="cloudProbe") class CflowdAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - cflowd: Global[bool] = Field(default=None) + cflowd: Global[bool] class NatPoolAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - nat_pool: Global[int] = Field(default=None, validation_alias="natPool", serialization_alias="natPool") + nat_pool: Global[int] = Field(validation_alias="natPool", serialization_alias="natPool") class NatAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - nat: Nat = Field(default=None) + nat: Nat class SigAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - sig: Global[bool] = Field(default=None) + sig: Global[bool] class FallbackToRoutingAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") fallback_to_routing: Global[bool] = Field( - default=None, validation_alias="fallbackToRouting", serialization_alias="fallbackToRouting" + validation_alias="fallbackToRouting", serialization_alias="fallbackToRouting" ) class SseAction(BaseModel): model_config = ConfigDict(populate_by_name=True, extra="forbid") - sse: Sse = Field(default=None) + sse: Sse Action = Union[ @@ -703,7 +684,7 @@ class Sequence(BaseModel): default=None, validation_alias="sequenceId", serialization_alias="sequenceId" ) sequence_ip_type: Global[SequenceIpType] = Field( - default=None, validation_alias="sequenceIpType", serialization_alias="sequenceIpType" + validation_alias="sequenceIpType", serialization_alias="sequenceIpType" ) sequence_name: Optional[Global[str]] = Field( default=None, validation_alias="sequenceName", serialization_alias="sequenceName" diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/ssl_decryption.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/ssl_decryption.py index 1ab03723..1bb1fbf2 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/ssl_decryption.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/ssl_decryption.py @@ -59,10 +59,12 @@ class SslDecryptionParcel(_ParcelBase): ) unknown_status: Optional[Global[Action]] = Field(default=None, validation_alias=AliasPath("data", "unknownStatus")) unsupported_protocol_versions: Global[UnspportedModeAction] = Field( - default=Global[Action](value="drop"), validation_alias=AliasPath("data", "unsupportedProtocolVersions") + default=Global[UnspportedModeAction](value="drop"), + validation_alias=AliasPath("data", "unsupportedProtocolVersions"), ) unsupported_cipher_suites: Global[UnspportedModeAction] = Field( - default=Global[Action](value="drop"), validation_alias=AliasPath("data", "unsupportedCipherSuites") + default=Global[UnspportedModeAction](value="drop"), + validation_alias=AliasPath("data", "unsupportedCipherSuites"), ) failure_mode: Global[FailureMode] = Field( default=Global[FailureMode](value="close"), validation_alias=AliasPath("data", "failureMode") diff --git a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/ssl_decryption_profile.py b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/ssl_decryption_profile.py index 51e38e90..dc30863c 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/ssl_decryption_profile.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/policy_object/security/ssl_decryption_profile.py @@ -113,7 +113,7 @@ class SslDecryptionProfileParcel(_ParcelBase): default=Global[List[Categories]](value=[]), validation_alias=AliasPath("data", "neverDecryptCategories") ) skip_decrypt_categories: Global[List[Categories]] = Field( - default=None, validation_alias=AliasPath("data", "skipDecryptCategories") + default=Global[List[Categories]](value=[]), validation_alias=AliasPath("data", "skipDecryptCategories") ) reputation: Global[bool] = Field( default=Global[bool](value=False), validation_alias=AliasPath("data", "reputation") diff --git a/catalystwan/models/configuration/feature_profile/sdwan/system/logging_parcel.py b/catalystwan/models/configuration/feature_profile/sdwan/system/logging_parcel.py index e13ead03..e70dbb4f 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/system/logging_parcel.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/system/logging_parcel.py @@ -81,11 +81,9 @@ class LoggingParcel(_ParcelBase): populate_by_name=True, ) disk: Disk = Field(default_factory=Disk, validation_alias=AliasPath("data", "disk")) - tls_profile: Optional[List[TlsProfile]] = Field( - default_factory=list, validation_alias=AliasPath("data", "tlsProfile") - ) - server: Optional[List[Server]] = Field(default_factory=list, validation_alias=AliasPath("data", "server")) - ipv6_server: Optional[List[Server]] = Field(default_factory=list, validation_alias=AliasPath("data", "ipv6Server")) + tls_profile: Optional[List[TlsProfile]] = Field(default=None, validation_alias=AliasPath("data", "tlsProfile")) + server: Optional[List[Server]] = Field(default=None, validation_alias=AliasPath("data", "server")) + ipv6_server: Optional[List[Server]] = Field(default=None, validation_alias=AliasPath("data", "ipv6Server")) def set_disk(self, enable: bool, disk_file_size: int = 10, disk_file_rotate: int = 10): self.disk.disk_enable = as_global(enable) diff --git a/catalystwan/models/configuration/feature_profile/sdwan/topology/custom_control.py b/catalystwan/models/configuration/feature_profile/sdwan/topology/custom_control.py index 6c818f2d..8bb837d2 100644 --- a/catalystwan/models/configuration/feature_profile/sdwan/topology/custom_control.py +++ b/catalystwan/models/configuration/feature_profile/sdwan/topology/custom_control.py @@ -181,7 +181,7 @@ class Actions(BaseModel): class Sequence(BaseModel): model_config = ConfigDict(populate_by_name=True) - actions: Optional[List[Actions]] = Field(default_factory=list) + actions: Optional[List[Actions]] = Field(default=None) base_action: Optional[Global[AcceptRejectActionType]] = Field( default=None, validation_alias="baseAction", serialization_alias="baseAction" ) diff --git a/catalystwan/models/policy/definition/url_filtering.py b/catalystwan/models/policy/definition/url_filtering.py index d033030b..1d5b4ad6 100644 --- a/catalystwan/models/policy/definition/url_filtering.py +++ b/catalystwan/models/policy/definition/url_filtering.py @@ -41,7 +41,7 @@ class UrlFilteringDefinition(BaseModel): logging: List[str] = Field(default_factory=list) enable_alerts: bool = Field(validation_alias="enableAlerts", serialization_alias="enableAlerts") alerts: Set[UrlFilteringAlerts] = Field( - default_factory=list, validation_alias="alerts", serialization_alias="alerts" + default_factory=set, validation_alias="alerts", serialization_alias="alerts" ) target_vpns: List[VpnId] = Field( default_factory=list, validation_alias="targetVpns", serialization_alias="targetVpns" diff --git a/catalystwan/models/policy/list/identity.py b/catalystwan/models/policy/list/identity.py index ef6aeb9c..d57dd51d 100644 --- a/catalystwan/models/policy/list/identity.py +++ b/catalystwan/models/policy/list/identity.py @@ -9,8 +9,8 @@ class IdentityListEntry(BaseModel): model_config = ConfigDict(populate_by_name=True) - user: str = Field(default=None) - user_group: str = Field(default=None, validation_alias="userGroup", serialization_alias="userGroup") + user: str + user_group: str = Field(validation_alias="userGroup", serialization_alias="userGroup") class IdentityList(PolicyListBase): diff --git a/catalystwan/tests/templates/test_serialize_model.py b/catalystwan/tests/templates/test_serialize_model.py index e26beb3c..6142a6ad 100644 --- a/catalystwan/tests/templates/test_serialize_model.py +++ b/catalystwan/tests/templates/test_serialize_model.py @@ -41,7 +41,7 @@ def test_generate_feature_template_payload_definition( ) # Assert # self.assertDictEqual - self.maxDiff = 10000 + self.maxDiff = 2**16 self.assertDictEqual( definition["templateDefinition"], feature_template_payload.model_dump(by_alias=True, mode="json")["templateDefinition"], diff --git a/pyproject.toml b/pyproject.toml index 1942163a..58a58ffe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "catalystwan" -version = "0.40.0dev1" +version = "0.40.0dev2" description = "Cisco Catalyst WAN SDK for Python" authors = ["kagorski "] readme = "README.md"