Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: Fix ethernet serialization #6

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions catalystwan/api/templates/models/aaa_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down Expand Up @@ -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",
)
Expand All @@ -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",
},
Expand All @@ -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",
Expand All @@ -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",
)
Expand Down
3 changes: 1 addition & 2 deletions catalystwan/api/templates/models/cisco_aaa_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions catalystwan/api/templates/models/cisco_system.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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"},
Expand Down
1 change: 0 additions & 1 deletion catalystwan/api/templates/models/cisco_vpn_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
)
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 @@ -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",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
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
7 changes: 3 additions & 4 deletions catalystwan/models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down
4 changes: 1 addition & 3 deletions catalystwan/models/configuration/feature_profile/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading