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

Commit

Permalink
Merge branch 'dev-uxmt' into dev/wan/interface/t1e1serial
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkrajewski committed May 7, 2024
2 parents 7b57b72 + 6105e53 commit c4d06ec
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 15 deletions.
13 changes: 13 additions & 0 deletions catalystwan/api/policy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
ConfigurationPolicySecurityGroupDefinition,
)
from catalystwan.endpoints.configuration.policy.definition.traffic_data import ConfigurationPolicyDataDefinition
from catalystwan.endpoints.configuration.policy.definition.url_filtering import (
ConfigurationPolicyUrlFilteringDefinition,
)
from catalystwan.endpoints.configuration.policy.definition.vpn_membership import (
ConfigurationPolicyVPNMembershipGroupDefinition,
)
Expand Down Expand Up @@ -144,6 +147,7 @@
from catalystwan.models.policy.definition.rule_set import RuleSet, RuleSetGetResponse
from catalystwan.models.policy.definition.security_group import SecurityGroup, SecurityGroupGetResponse
from catalystwan.models.policy.definition.traffic_data import TrafficDataPolicy, TrafficDataPolicyGetResponse
from catalystwan.models.policy.definition.url_filtering import UrlFilteringPolicy, UrlFilteringPolicyGetResponse
from catalystwan.models.policy.definition.vpn_membership import VPNMembershipPolicy, VPNMembershipPolicyGetResponse
from catalystwan.models.policy.definition.zone_based_firewall import ZoneBasedFWPolicy, ZoneBasedFWPolicyGetResponse
from catalystwan.models.policy.list.app_probe import AppProbeClassListInfo
Expand Down Expand Up @@ -233,6 +237,7 @@
DeviceAccessIPv6Policy: ConfigurationPolicyDeviceAccessIPv6Definition,
AdvancedMalwareProtectionPolicy: ConfigurationPolicyAMPDefinition,
IntrusionPreventionPolicy: ConfigurationPolicyIntrusionPreventionDefinition,
UrlFilteringPolicy: ConfigurationPolicyUrlFilteringDefinition,
}


Expand Down Expand Up @@ -664,6 +669,10 @@ def get(self, type: Type[IntrusionPreventionPolicy]) -> DataSequence[PolicyDefin
def get(self, type: Type[TrafficDataPolicy]) -> DataSequence[PolicyDefinitionInfo]:
...

@overload
def get(self, type: Type[UrlFilteringPolicy]) -> DataSequence[PolicyDefinitionInfo]:
...

@overload
def get(self, type: Type[AdvancedMalwareProtectionPolicy]) -> DataSequence[PolicyDefinitionInfo]:
...
Expand Down Expand Up @@ -729,6 +738,10 @@ def get(self, type: Type[IntrusionPreventionPolicy], id: UUID) -> IntrusionPreve
def get(self, type: Type[TrafficDataPolicy], id: UUID) -> TrafficDataPolicyGetResponse:
...

@overload
def get(self, type: Type[UrlFilteringPolicy], id: UUID) -> UrlFilteringPolicyGetResponse:
...

@overload
def get(self, type: Type[AdvancedMalwareProtectionPolicy], id: UUID) -> AdvancedMalwareProtectionPolicyGetResponse:
...
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates

# mypy: disable-error-code="empty-body"

from uuid import UUID

from catalystwan.endpoints import APIEndpoints, delete, get, post, put
from catalystwan.endpoints.configuration.policy.abstractions import PolicyDefinitionEndpoints
from catalystwan.models.policy.definition.url_filtering import (
UrlFilteringPolicy,
UrlFilteringPolicyEditPayload,
UrlFilteringPolicyGetResponse,
)
from catalystwan.models.policy.policy_definition import (
PolicyDefinitionEditResponse,
PolicyDefinitionId,
PolicyDefinitionInfo,
PolicyDefinitionPreview,
)
from catalystwan.typed_list import DataSequence


class ConfigurationPolicyUrlFilteringDefinition(APIEndpoints, PolicyDefinitionEndpoints):
@post("/template/policy/definition/urlfiltering")
def create_policy_definition(self, payload: UrlFilteringPolicy) -> PolicyDefinitionId:
...

@delete("/template/policy/definition/urlfiltering/{id}")
def delete_policy_definition(self, id: UUID) -> None:
...

@put("/template/policy/definition/urlfiltering/{id}")
def edit_policy_definition(self, id: UUID, payload: UrlFilteringPolicyEditPayload) -> PolicyDefinitionEditResponse:
...

@get("/template/policy/definition/urlfiltering", "data")
def get_definitions(self) -> DataSequence[PolicyDefinitionInfo]:
...

@get("/template/policy/definition/urlfiltering/{id}")
def get_policy_definition(self, id: UUID) -> UrlFilteringPolicyGetResponse:
...

@post("/template/policy/definition/urlfiltering/preview")
def preview_policy_definition(self, payload: UrlFilteringPolicy) -> PolicyDefinitionPreview:
...

@get("/template/policy/definition/urlfiltering/preview/{id}")
def preview_policy_definition_by_id(self, id: UUID) -> PolicyDefinitionPreview:
...
7 changes: 5 additions & 2 deletions catalystwan/endpoints/configuration_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# mypy: disable-error-code="empty-body"
from datetime import datetime
from typing import Any, List, Optional
from typing import Any, List, Optional, Union
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field
Expand Down Expand Up @@ -88,9 +88,12 @@ class ConfigGroupVariablesCreatePayload(BaseModel):
suggestions: bool = True


VariableType = Union[str, int, bool, List[Union[str, int, bool]]]


class VariableData(BaseModel):
name: str
value: str
value: Optional[VariableType] = None


class DeviceVariables(BaseModel):
Expand Down
12 changes: 12 additions & 0 deletions catalystwan/integration_tests/feature_profile/sdwan/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def test_when_default_values_banner_parcel_expect_successful_post(self):
# Assert
assert parcel_id

self.api.delete_parcel(self.profile_uuid, banner_parcel, parcel_id)

def test_when_fully_specified_banner_parcel_expect_successful_post(self):
# Arrange
banner_parcel = BannerParcel(
Expand All @@ -44,6 +46,8 @@ def test_when_fully_specified_banner_parcel_expect_successful_post(self):
# Assert
assert parcel_id

self.api.delete_parcel(self.profile_uuid, banner_parcel, parcel_id)

def test_when_default_values_logging_parcel_expect_successful_post(self):
# Arrange
logging_parcel = LoggingParcel(
Expand All @@ -55,6 +59,8 @@ def test_when_default_values_logging_parcel_expect_successful_post(self):
# Assert
assert parcel_id

self.api.delete_parcel(self.profile_uuid, logging_parcel, parcel_id)

def test_when_fully_specified_logging_parcel_expect_successful_post(self):
# Arrange
logging_parcel = LoggingParcel(
Expand Down Expand Up @@ -99,6 +105,8 @@ def test_when_fully_specified_logging_parcel_expect_successful_post(self):
# Assert
assert parcel_id

self.api.delete_parcel(self.profile_uuid, logging_parcel, parcel_id)

def test_when_default_values_bfd_parcel_expect_successful_post(self):
# Arrange
bfd_parcel = BFDParcel(
Expand All @@ -110,6 +118,8 @@ def test_when_default_values_bfd_parcel_expect_successful_post(self):
# Assert
assert parcel_id

self.api.delete_parcel(self.profile_uuid, bfd_parcel, parcel_id)

def test_when_fully_specified_bfd_parcel_expect_successful_post(self):
# Arrange
bfd_parcel = BFDParcel(
Expand All @@ -128,6 +138,8 @@ def test_when_fully_specified_bfd_parcel_expect_successful_post(self):
# Assert
assert parcel_id

self.api.delete_parcel(self.profile_uuid, bfd_parcel, parcel_id)

def test_when_default_values_basic_parcel_expect_successful_post(self):
# Arrange
basic_parcel = BasicParcel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from catalystwan.api.configuration_groups.parcel import Default, Global, Variable, _ParcelBase, as_default, as_global

DEFAULT_USER_PRIVILEGE = "15"


class PubkeyChainItem(BaseModel):
model_config = ConfigDict(extra="forbid", populate_by_name=True)
Expand Down Expand Up @@ -37,7 +39,7 @@ class UserItem(BaseModel):
)
)
privilege: Union[Global[str], Variable, Default[str], None] = Field(
default=None, description="Set Privilege Level for this user"
default=as_default(DEFAULT_USER_PRIVILEGE), description="Set Privilege Level for this user"
)
pubkey_chain: Optional[List[PubkeyChainItem]] = Field(
default=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ class OMPParcel(_ParcelBase):
shutdown: Union[Variable, Global[bool], Default[bool]] = Field(
default=as_default(False), validation_alias=AliasPath("data", "shutdown"), description="Variable"
)
omp_admin_distance_ipv4: Union[Variable, Global[int], Default[Optional[int]]] = Field(
omp_admin_distance_ipv4: Union[Variable, Global[int], Default[int]] = Field(
default=as_default(251),
validation_alias=AliasPath("data", "ompAdminDistanceIpv4"),
description="OMP Admin Distance IPv4",
)
omp_admin_distance_ipv6: Union[Variable, Global[int], Default[Optional[int]]] = Field(
omp_admin_distance_ipv6: Union[Variable, Global[int], Default[int]] = Field(
default=as_default(251),
validation_alias=AliasPath("data", "ompAdminDistanceIpv6"),
description="OMP Admin Distance IPv6",
Expand Down
4 changes: 4 additions & 0 deletions catalystwan/models/policy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from .definition.rule_set import RuleSet, RuleSetGetResponse
from .definition.security_group import SecurityGroup, SecurityGroupGetResponse
from .definition.traffic_data import TrafficDataPolicy, TrafficDataPolicyGetResponse
from .definition.url_filtering import UrlFilteringPolicy, UrlFilteringPolicyGetResponse
from .definition.vpn_membership import VPNMembershipPolicy, VPNMembershipPolicyGetResponse
from .definition.zone_based_firewall import ZoneBasedFWPolicy, ZoneBasedFWPolicyGetResponse
from .localized import LocalizedPolicy
Expand Down Expand Up @@ -88,6 +89,7 @@
RuleSet,
SecurityGroup,
TrafficDataPolicy,
UrlFilteringPolicy,
VPNMembershipPolicy,
ZoneBasedFWPolicy,
],
Expand Down Expand Up @@ -184,6 +186,7 @@
RuleSetGetResponse,
SecurityGroupGetResponse,
TrafficDataPolicyGetResponse,
UrlFilteringPolicyGetResponse,
VPNMembershipPolicyGetResponse,
ZoneBasedFWPolicyGetResponse,
],
Expand Down Expand Up @@ -252,6 +255,7 @@
"UnifiedSecurityPolicy",
"URLBlockList",
"URLAllowList",
"UrlFilteringPolicy",
"VPNList",
"VPNMembershipPolicy",
"ZoneBasedFWPolicy",
Expand Down
8 changes: 2 additions & 6 deletions catalystwan/models/policy/definition/intrusion_prevention.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates

from typing import List, Literal, Optional
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field

Expand All @@ -10,22 +9,19 @@
PolicyDefinitionBase,
PolicyDefinitionGetResponse,
PolicyDefinitionId,
Reference,
)

SignatureSetType = Literal["balanced", "connectivity", "security"]
InspectionModeType = Literal["protection", "detection"]
LogLevel = Literal["emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"]


class SignatureWhiteList(BaseModel):
ref: Optional[UUID] = Field(default=None)


class IntrusionPreventionDefinition(BaseModel):
model_config = ConfigDict(populate_by_name=True)
signature_set: SignatureSetType = Field(validation_alias="signatureSet", serialization_alias="signatureSet")
inspection_mode: InspectionModeType = Field(validation_alias="inspectionMode", serialization_alias="inspectionMode")
signature_white_list: Optional[SignatureWhiteList] = Field(
signature_white_list: Optional[Reference] = Field(
default=None, validation_alias="signatureWhiteList", serialization_alias="signatureWhiteList"
)
log_level: Optional[LogLevel] = Field(default="error", validation_alias="logLevel", serialization_alias="logLevel")
Expand Down
Loading

0 comments on commit c4d06ec

Please sign in to comment.