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

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkrajewski committed Jul 8, 2024
1 parent 007c0e8 commit bb37178
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
from pydantic import AliasPath, BaseModel, ConfigDict, Field
from typing_extensions import Self

from catalystwan.api.configuration_groups.parcel import Global, Variable, _ParcelBase, as_optional_global
from catalystwan.api.configuration_groups.parcel import (
Global,
Variable,
_ParcelBase,
as_global,
as_optional_global,
as_variable,
)
from catalystwan.models.configuration.feature_profile.common import RefIdItem


Expand Down Expand Up @@ -89,4 +96,7 @@ def add_scheduler(
)

def set_variable_target(self, variable: str) -> None:
self.target = QosPolicyTarget(interfaces=Variable(value=variable))
self.target = QosPolicyTarget(interfaces=as_variable(value=variable))

def set_list_target(self, interfaces: List[str]) -> None:
self.target = QosPolicyTarget(interfaces=as_global(value=interfaces))
7 changes: 2 additions & 5 deletions catalystwan/models/policy/policy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2023 Cisco Systems, Inc. and its affiliates

import datetime
from typing import List, Literal, Optional, Sequence, Union
from typing import Any, List, Literal, Optional, Sequence, Union
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field
Expand Down Expand Up @@ -64,6 +64,7 @@ class SSLDecryptionAssemblyItem(AssemblyItemBase):

class PolicyDefinition(BaseModel):
assembly: Sequence[AssemblyItemBase] = []
settings: Optional[Any] = None


class PolicyCreationPayload(BaseModel):
Expand All @@ -77,10 +78,6 @@ class PolicyCreationPayload(BaseModel):
default="default description", serialization_alias="policyDescription", validation_alias="policyDescription"
)
policy_type: str = Field(serialization_alias="policyType", validation_alias="policyType")
policy_definition: Union[PolicyDefinition, str] = Field(
serialization_alias="policyDefinition",
validation_alias="policyDefinition",
)
is_policy_activated: bool = Field(
default=False, serialization_alias="isPolicyActivated", validation_alias="isPolicyActivated"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from catalystwan.utils.config_migration.converters.policy.policy_definitions import convert


class TestAdvancedMalwareProtectionConverter(unittest.TestCase):
class TestQosMapConverter(unittest.TestCase):
def setUp(self) -> None:
self.context = PolicyConvertContext()
self.uuid = uuid4()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def qos_map(in_: QoSMapPolicy, uuid: UUID, context: PolicyConvertContext) -> Con
result.output = out

# add target
out.set_variable_target("{{Interface_1}}") # for tests
# out.set_variable_target("Interface_1") # for tests

for scheduler in in_.definition.qos_schedulers:
out.add_scheduler(
Expand Down Expand Up @@ -753,8 +753,8 @@ def intrusion_prevention(
SslDecryptionUtdProfilePolicy: ssl_profile,
UrlFilteringPolicy: url_filtering,
DnsSecurityPolicy: dns_security,
# DeviceAccessIPv6Policy: device_access_ipv6,
# DeviceAccessPolicy: device_access_ipv4,
DeviceAccessIPv6Policy: device_access_ipv6,
DeviceAccessPolicy: device_access_ipv4,
RoutePolicy: route,
ZoneBasedFWPolicy: convert_zone_based_fw,
QoSMapPolicy: qos_map,
Expand Down

0 comments on commit bb37178

Please sign in to comment.