Skip to content

Commit

Permalink
fix: mypy violations
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Dec 2, 2024
1 parent a0c2f45 commit 64c4f95
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion catalystwan/api/templates/models/cisco_bgp_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Ipv6Neighbor(FeatureTemplateValidator):
address: str
description: Optional[str] = None
shutdown: Optional[BoolStr] = None
remote_as: int = Field(default=None, json_schema_extra={"vmanage_key": "remote-as"})
remote_as: int = Field(json_schema_extra={"vmanage_key": "remote-as"})
keepalive: Optional[int] = Field(default=None, json_schema_extra={"data_path": ["timers"]})
holdtime: Optional[int] = Field(default=None, json_schema_extra={"data_path": ["timers"]})
if_name: Optional[str] = Field(
Expand Down
4 changes: 2 additions & 2 deletions catalystwan/api/templates/models/cisco_snmp_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class Target(FeatureTemplateValidator):
vpn_id: int = Field(json_schema_extra={"vmanage_key": "vpn-id"})
ip: str
port: int
community_name: str = Field(default=None, json_schema_extra={"vmanage_key": "community-name"})
community_name: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "community-name"})
user: Optional[str] = None
source_interface: str = Field(default=None, json_schema_extra={"vmanage_key": "source-interface"})
source_interface: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "source-interface"})
model_config = ConfigDict(populate_by_name=True)


Expand Down
6 changes: 4 additions & 2 deletions catalystwan/api/templates/models/cisco_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from enum import Enum
from pathlib import Path
from typing import ClassVar, List, Optional
from typing import ClassVar, List, Optional, Union

from pydantic import ConfigDict, Field

Expand Down Expand Up @@ -151,7 +151,9 @@ class CiscoSystemModel(FeatureTemplate):
default=DeviceVariable(name="system_system_ip"), json_schema_extra={"vmanage_key": "system-ip"}
)
overlay_id: Optional[int] = Field(default=None, json_schema_extra={"vmanage_key": "overlay-id"})
site_id: int = Field(default=DeviceVariable(name="system_site_id"), json_schema_extra={"vmanage_key": "site-id"})
site_id: Union[int, DeviceVariable] = Field(
default=DeviceVariable(name="system_site_id"), json_schema_extra={"vmanage_key": "site-id"}
)
site_type: Optional[List[SiteType]] = Field(default=None, json_schema_extra={"vmanage_key": "site-type"})
port_offset: Optional[int] = Field(default=None, json_schema_extra={"vmanage_key": "port-offset"})
port_hop: Optional[BoolStr] = Field(default=None, json_schema_extra={"vmanage_key": "port-hop"})
Expand Down
2 changes: 1 addition & 1 deletion catalystwan/api/templates/models/cisco_vpn_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class Overload(str, Enum):
class Natpool(FeatureTemplateValidator):
name: int
prefix_length: Optional[int] = Field(default=None, json_schema_extra={"vmanage_key": "prefix-length"})
range_start: str = Field(default=None, json_schema_extra={"vmanage_key": "range-start"})
range_start: str = Field(json_schema_extra={"vmanage_key": "range-start"})
range_end: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "range-end"})
overload: Overload = Overload.TRUE
direction: Direction
Expand Down
2 changes: 1 addition & 1 deletion catalystwan/api/templates/models/system_vsmart_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class SystemVsmart(FeatureTemplate):
device_groups: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "device-groups"})
longitude: Optional[int] = Field(default=None, ge=-180, le=180)
latitude: Optional[int] = Field(default=None, ge=-90, le=90)
system_tunnel_mtu: Optional[str] = Field(default=1024, json_schema_extra={"vmanage_key": "system-tunnel-mtu"})
system_tunnel_mtu: Optional[int] = Field(default=1024, json_schema_extra={"vmanage_key": "system-tunnel-mtu"})
location: Optional[str] = None
host_name: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "host-name"})

Expand Down
8 changes: 5 additions & 3 deletions catalystwan/endpoints/configuration/software_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions catalystwan/endpoints/configuration_dashboard_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")


Expand Down
2 changes: 1 addition & 1 deletion catalystwan/models/configuration/feature_profile/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class IPv4Prefix(BaseModel):
class WANIPv4StaticRoute(BaseModel):
prefix: IPv4Prefix = Field()
gateway: Global[Literal["nextHop", "null0", "dhcp"]] = Field(default=Global(value="nextHop"), alias="gateway")
next_hops: Optional[List[NextHop]] = Field(default_factory=list, alias="nextHop")
next_hops: Optional[List[NextHop]] = Field(default=None, serialization_alias="nextHop", validation_alias="nextHop")
distance: Optional[Global[int]] = Field(default=None, alias="distance")

def set_to_next_hop(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
class ManagementVPN(BaseModel):
# TODO (mlembke): vpn_id can't have other value, it needs to be constant. How to do that?
vpn_id: Default[int] = Field(default=Default(value=512), frozen=True, alias="vpnId")
ipv4_routes: Optional[List[WANIPv4StaticRoute]] = Field(default=[], alias="ipv4Route")
ipv6_routes: Optional[List[WANIPv6StaticRoute]] = Field(default=[], alias="ipv6Route")
ipv4_routes: Optional[List[WANIPv4StaticRoute]] = Field(default=None, alias="ipv4Route")
ipv6_routes: Optional[List[WANIPv6StaticRoute]] = Field(default=None, alias="ipv6Route")
dns_ipv4: Optional[DNSIPv4] = Field(default=None, alias="dnsIpv4")
dns_ipv6: Optional[DNSIPv6] = Field(default=None, alias="dnsIpv6")
new_host_mapping: Optional[List[HostMapping]] = Field(default=[], alias="newHostMapping")
new_host_mapping: Optional[List[HostMapping]] = Field(default=None, alias="newHostMapping")
# TODO (mlembke): add interfaces
interface: Optional[Any] = Field(default=None)
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class BgpIPv4Neighbor(BaseModel):
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(serialization_alias="remoteAs", validation_alias="remoteAs")
local_as: Union[Global[int], Variable] = Field(
local_as: Optional[Union[Global[str], Global[int], Variable, Default[None]]] = Field(
serialization_alias="localAs", validation_alias="localAs", default=None
)
keepalive: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=60)
Expand Down Expand Up @@ -199,7 +199,7 @@ class BgpIPv6Neighbor(BaseModel):
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(serialization_alias="remoteAs", validation_alias="remoteAs")
local_as: Union[Global[int], Variable] = Field(
local_as: Optional[Union[Global[str], Global[int], Variable, Default[None]]] = Field(
serialization_alias="localAs", validation_alias="localAs", default=None
)
keepalive: Optional[Union[Global[int], Variable, Default[int]]] = Default[int](value=60)
Expand Down

0 comments on commit 64c4f95

Please sign in to comment.