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

Commit

Permalink
Pre-commit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PrzeG committed Mar 6, 2024
1 parent bc037e1 commit ca08cfa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
16 changes: 12 additions & 4 deletions catalystwan/api/templates/models/cisco_secure_internet_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ class Interface(FeatureTemplateValidator):
description: Optional[str] = None
unnumbered: bool = True
address: Optional[ipaddress.IPv4Interface] = None
tunnel_source: Optional[ipaddress.IPv4Address] = Field(default=None, json_schema_extra={"vmanage_key": "tunnel-source"})
tunnel_source_interface: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "tunnel-source-interface"})
tunnel_source: Optional[ipaddress.IPv4Address] = Field(
default=None, json_schema_extra={"vmanage_key": "tunnel-source"}
)
tunnel_source_interface: Optional[str] = Field(
default=None, json_schema_extra={"vmanage_key": "tunnel-source-interface"}
)
tunnel_route_via: Optional[str] = Field(default=None, json_schema_extra={"vmanage_key": "tunnel-route-via"})
tunnel_destination: str = Field(json_schema_extra={"vmanage_key": "tunnel-destination"})
application: Application = Application.SIG
Expand Down Expand Up @@ -157,7 +161,9 @@ class RefreshTimeUnit(str, Enum):

class Service(FeatureTemplateValidator):
svc_type: SvcType = Field(SvcType.SIG, json_schema_extra={"vmanage_key": "svc-type"})
interface_pair: List[InterfacePair] = Field(json_schema_extra={"data_path": ["ha-pairs"], "vmanage_key": "interface-pair"})
interface_pair: List[InterfacePair] = Field(
json_schema_extra={"data_path": ["ha-pairs"], "vmanage_key": "interface-pair"}
)
auth_required: Optional[bool] = Field(False, json_schema_extra={"vmanage_key": "auth-required"})
xff_forward_enabled: Optional[bool] = Field(False, json_schema_extra={"vmanage_key": "xff-forward-enabled"})
ofw_enabled: Optional[bool] = Field(False, json_schema_extra={"vmanage_key": "ofw-enabled"})
Expand Down Expand Up @@ -208,7 +214,9 @@ class CiscoSecureInternetGatewayModel(FeatureTemplate):
vpn_id: int = Field(DEFAULT_SIG_VPN_ID, json_schema_extra={"vmanage_key": "vpn-id"})
interface: List[Interface]
service: List[Service]
tracker_src_ip: Optional[ipaddress.IPv4Interface] = Field(default=None, json_schema_extra={"vmanage_key": "tracker-src-ip"})
tracker_src_ip: Optional[ipaddress.IPv4Interface] = Field(
default=None, json_schema_extra={"vmanage_key": "tracker-src-ip"}
)
tracker: Optional[List[Tracker]] = None

payload_path: ClassVar[Path] = Path(__file__).parent / "DEPRECATED"
Expand Down
7 changes: 2 additions & 5 deletions catalystwan/integration_tests/test_find_template_values.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import json
import os
import unittest
from typing import Any, List, cast
import json

from pydantic import ValidationError
from catalystwan.exceptions import TemplateTypeError

from catalystwan.session import create_manager_session
from catalystwan.utils.feature_template.find_template_values import find_template_values
Expand All @@ -19,7 +16,7 @@ def setUp(self) -> None:
password=cast(str, os.environ.get("TEST_VMANAGE_PASSWORD")),
)
self.templates = self.session.api.templates._get_feature_templates(summary=False)

def test_find_template_value(self):
for template in self.templates:
definition = json.loads(template.template_definiton)
Expand Down
2 changes: 1 addition & 1 deletion catalystwan/utils/feature_template/find_template_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def find_template_values(
else:
current_nesting[field_key].append(find_template_values(item, device_specific_variables))
else:
current_nesting[field_key].append(item)
current_nesting[field_key].append(item)
elif template_definition["vipObjectType"] != "tree":
current_nesting = get_nested_dict(templated_values, path[:-1])
current_nesting[field_key] = template_value
Expand Down

0 comments on commit ca08cfa

Please sign in to comment.