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

Use AnyPolicyDefinitionInfo / AnyPolicyListInfo in UX1Config #523

Merged
merged 36 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
61bf5c0
phase 1
sbasan Mar 13, 2024
eb50414
separate endpoint from models, add app_probe list
sbasan Mar 13, 2024
19d3d9c
separate app-list
sbasan Mar 13, 2024
c0225c0
separate as-path-list
sbasan Mar 13, 2024
9b08773
separate class-map-list
sbasan Mar 13, 2024
2a303b1
separate community-list, expanded-community-list
sbasan Mar 13, 2024
79ab87c
separate data-ipv6-prefix-list
sbasan Mar 13, 2024
f8d1a98
separate data-prefix-list
sbasan Mar 13, 2024
9c913e7
separate fqdn-list
sbasan Mar 13, 2024
2198dbd
separate geo-location-list
sbasan Mar 13, 2024
22e9bc0
separate ips-signature-list
sbasan Mar 13, 2024
404a299
separate ipv6-prefix-list
sbasan Mar 14, 2024
3b410a7
separate local-app-list
sbasan Mar 14, 2024
19182ad
separate local-domain-list
sbasan Mar 14, 2024
6454e72
separate mirror-list
sbasan Mar 14, 2024
9cb7eb7
separate policer-list
sbasan Mar 14, 2024
9c55b00
separate port-list
sbasan Mar 14, 2024
cd96609
separate preferred-color-group-list
sbasan Mar 14, 2024
f8cde35
separate prefix-list
sbasan Mar 14, 2024
0c33c40
separate protocol-name-list
sbasan Mar 14, 2024
2e7b8eb
separate region-list
sbasan Mar 14, 2024
02d7bfe
separate site-list
sbasan Mar 14, 2024
6645d8e
separate sla-class-list
sbasan Mar 14, 2024
4902258
separate tloc-list
sbasan Mar 14, 2024
d427dff
separate url-lists
sbasan Mar 14, 2024
0579c35
separate vpn-list
sbasan Mar 14, 2024
0db6ed9
separate zone-list
sbasan Mar 14, 2024
f4846ea
move PolicyListBase
sbasan Mar 14, 2024
476f4c5
add copyright
sbasan Mar 14, 2024
1f5db57
separate policy definition models from endpoints
sbasan Mar 14, 2024
935a28d
sort
sbasan Mar 14, 2024
2e5dd90
use AnyPolicyDefinitionInfo, AnyPolicyListInfo in UX1Config
sbasan Mar 14, 2024
801f50d
fix policy_list converter
sbasan Mar 14, 2024
d9f9803
include missing file
sbasan Mar 14, 2024
cd1baf9
remove unused file
sbasan Mar 14, 2024
267269b
include entry definitions within owning policy list
sbasan Mar 14, 2024
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
148 changes: 50 additions & 98 deletions catalystwan/api/policy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,108 +6,48 @@
from uuid import UUID

from catalystwan.api.task_status_api import Task
from catalystwan.endpoints.configuration.policy.definition.access_control_list import (
AclPolicyGetResponse,
ConfigurationPolicyAclDefinition,
)
from catalystwan.endpoints.configuration.policy.abstractions import PolicyDefinitionEndpoints, PolicyListEndpoints
from catalystwan.endpoints.configuration.policy.definition.access_control_list import ConfigurationPolicyAclDefinition
from catalystwan.endpoints.configuration.policy.definition.access_control_list_ipv6 import (
AclIPv6PolicyGetResponse,
ConfigurationPolicyAclIPv6Definition,
)
from catalystwan.endpoints.configuration.policy.definition.control import (
ConfigurationPolicyControlDefinition,
ControlPolicyGetResponse,
)
from catalystwan.endpoints.configuration.policy.definition.control import ConfigurationPolicyControlDefinition
from catalystwan.endpoints.configuration.policy.definition.device_access import (
ConfigurationPolicyDeviceAccessDefinition,
DeviceAccessPolicyGetResponse,
)
from catalystwan.endpoints.configuration.policy.definition.device_access_ipv6 import (
ConfigurationPolicyDeviceAccessIPv6Definition,
DeviceAccessIPv6PolicyGetResponse,
)
from catalystwan.endpoints.configuration.policy.definition.hub_and_spoke import (
ConfigurationPolicyHubAndSpokeDefinition,
HubAndSpokePolicyGetResponse,
)
from catalystwan.endpoints.configuration.policy.definition.mesh import (
ConfigurationPolicyMeshDefinition,
MeshPolicyGetResponse,
)
from catalystwan.endpoints.configuration.policy.definition.qos_map import (
ConfigurationPolicyQoSMapDefinition,
QoSMapPolicyGetResponse,
)
from catalystwan.endpoints.configuration.policy.definition.rewrite import (
ConfigurationPolicyRewriteRuleDefinition,
RewritePolicyGetResponse,
)
from catalystwan.endpoints.configuration.policy.definition.rule_set import (
ConfigurationPolicyRuleSetDefinition,
RuleSetGetResponse,
)
from catalystwan.endpoints.configuration.policy.definition.hub_and_spoke import ConfigurationPolicyHubAndSpokeDefinition
from catalystwan.endpoints.configuration.policy.definition.mesh import ConfigurationPolicyMeshDefinition
from catalystwan.endpoints.configuration.policy.definition.qos_map import ConfigurationPolicyQoSMapDefinition
from catalystwan.endpoints.configuration.policy.definition.rewrite import ConfigurationPolicyRewriteRuleDefinition
from catalystwan.endpoints.configuration.policy.definition.rule_set import ConfigurationPolicyRuleSetDefinition
from catalystwan.endpoints.configuration.policy.definition.security_group import (
ConfigurationPolicySecurityGroupDefinition,
SecurityGroupGetResponse,
)
from catalystwan.endpoints.configuration.policy.definition.traffic_data import (
ConfigurationPolicyDataDefinition,
TrafficDataPolicy,
TrafficDataPolicyGetResponse,
)
from catalystwan.endpoints.configuration.policy.definition.traffic_data import ConfigurationPolicyDataDefinition
from catalystwan.endpoints.configuration.policy.definition.vpn_membership import (
ConfigurationPolicyVPNMembershipGroupDefinition,
VPNMembershipPolicyGetResponse,
)
from catalystwan.endpoints.configuration.policy.definition.zone_based_firewall import (
ConfigurationPolicyZoneBasedFirewallDefinition,
ZoneBasedFWPolicyGetResponse,
)
from catalystwan.endpoints.configuration.policy.list.app import AppListInfo, ConfigurationPolicyApplicationList
from catalystwan.endpoints.configuration.policy.list.app_probe import (
AppProbeClassListInfo,
ConfigurationPolicyAppProbeClassList,
)
from catalystwan.endpoints.configuration.policy.list.app_probe import ConfigurationPolicyAppProbeClassList
from catalystwan.endpoints.configuration.policy.list.as_path import ASPathListInfo, ConfigurationPolicyASPathList
from catalystwan.endpoints.configuration.policy.list.class_map import (
ClassMapListInfo,
ConfigurationPolicyForwardingClassList,
)
from catalystwan.endpoints.configuration.policy.list.class_map import ConfigurationPolicyForwardingClassList
from catalystwan.endpoints.configuration.policy.list.color import ColorListInfo, ConfigurationPolicyColorList
from catalystwan.endpoints.configuration.policy.list.community import (
CommunityListInfo,
ConfigurationPolicyCommunityList,
)
from catalystwan.endpoints.configuration.policy.list.data_ipv6_prefix import (
ConfigurationPolicyDataIPv6PrefixList,
DataIPv6PrefixListInfo,
)
from catalystwan.endpoints.configuration.policy.list.data_prefix import (
ConfigurationPolicyDataPrefixList,
DataPrefixListInfo,
)
from catalystwan.endpoints.configuration.policy.list.expanded_community import (
ConfigurationPolicyExpandedCommunityList,
ExpandedCommunityListInfo,
)
from catalystwan.endpoints.configuration.policy.list.community import ConfigurationPolicyCommunityList
from catalystwan.endpoints.configuration.policy.list.data_ipv6_prefix import ConfigurationPolicyDataIPv6PrefixList
from catalystwan.endpoints.configuration.policy.list.data_prefix import ConfigurationPolicyDataPrefixList
from catalystwan.endpoints.configuration.policy.list.expanded_community import ConfigurationPolicyExpandedCommunityList
from catalystwan.endpoints.configuration.policy.list.fqdn import ConfigurationPolicyFQDNList, FQDNListInfo
from catalystwan.endpoints.configuration.policy.list.geo_location import (
ConfigurationPolicyGeoLocationList,
GeoLocationListInfo,
)
from catalystwan.endpoints.configuration.policy.list.ips_signature import (
ConfigurationPolicyIPSSignatureList,
IPSSignatureListInfo,
)
from catalystwan.endpoints.configuration.policy.list.ipv6_prefix import (
ConfigurationPolicyIPv6PrefixList,
IPv6PrefixListInfo,
)
from catalystwan.endpoints.configuration.policy.list.geo_location import ConfigurationPolicyGeoLocationList
from catalystwan.endpoints.configuration.policy.list.ips_signature import ConfigurationPolicyIPSSignatureList
from catalystwan.endpoints.configuration.policy.list.ipv6_prefix import ConfigurationPolicyIPv6PrefixList
from catalystwan.endpoints.configuration.policy.list.local_app import ConfigurationPolicyLocalAppList, LocalAppListInfo
from catalystwan.endpoints.configuration.policy.list.local_domain import (
ConfigurationPolicyLocalDomainList,
LocalDomainListInfo,
)
from catalystwan.endpoints.configuration.policy.list.local_domain import ConfigurationPolicyLocalDomainList
from catalystwan.endpoints.configuration.policy.list.mirror import ConfigurationPolicyMirrorList, MirrorListInfo
from catalystwan.endpoints.configuration.policy.list.policer import ConfigurationPolicyPolicerClassList, PolicerListInfo
from catalystwan.endpoints.configuration.policy.list.port import ConfigurationPolicyPortList, PortListInfo
Expand Down Expand Up @@ -141,22 +81,9 @@
VSmartConnectivityStatus,
)
from catalystwan.models.misc.application_protocols import ApplicationProtocol
from catalystwan.models.policy import AnyPolicyDefinition, AnyPolicyList
from catalystwan.models.policy.centralized import CentralizedPolicy, CentralizedPolicyEditPayload, CentralizedPolicyInfo
from catalystwan.models.policy.definitions.access_control_list import AclPolicy
from catalystwan.models.policy.definitions.access_control_list_ipv6 import AclIPv6Policy
from catalystwan.models.policy.definitions.control import ControlPolicy
from catalystwan.models.policy.definitions.device_access import DeviceAccessPolicy
from catalystwan.models.policy.definitions.device_access_ipv6 import DeviceAccessIPv6Policy
from catalystwan.models.policy.definitions.hub_and_spoke import HubAndSpokePolicy
from catalystwan.models.policy.definitions.mesh import MeshPolicy
from catalystwan.models.policy.definitions.qos_map import QoSMapPolicy
from catalystwan.models.policy.definitions.rewrite import RewritePolicy
from catalystwan.models.policy.definitions.rule_set import RuleSet
from catalystwan.models.policy.definitions.security_group import SecurityGroup
from catalystwan.models.policy.definitions.vpn_membership import VPNMembershipPolicy
from catalystwan.models.policy.definitions.zone_based_firewall import ZoneBasedFWPolicy
from catalystwan.models.policy.lists import (
from catalystwan.models.policy import (
AnyPolicyDefinition,
AnyPolicyList,
AppList,
AppProbeClassList,
ASPathList,
Expand All @@ -174,7 +101,6 @@
LocalDomainList,
MirrorList,
PolicerList,
PolicyListBase,
PortList,
PreferredColorGroupList,
PrefixList,
Expand All @@ -188,6 +114,33 @@
VPNList,
ZoneList,
)
from catalystwan.models.policy.centralized import CentralizedPolicy, CentralizedPolicyEditPayload, CentralizedPolicyInfo
from catalystwan.models.policy.definition.access_control_list import AclPolicy, AclPolicyGetResponse
from catalystwan.models.policy.definition.access_control_list_ipv6 import AclIPv6Policy, AclIPv6PolicyGetResponse
from catalystwan.models.policy.definition.control import ControlPolicy, ControlPolicyGetResponse
from catalystwan.models.policy.definition.device_access import DeviceAccessPolicy, DeviceAccessPolicyGetResponse
from catalystwan.models.policy.definition.device_access_ipv6 import (
DeviceAccessIPv6Policy,
DeviceAccessIPv6PolicyGetResponse,
)
from catalystwan.models.policy.definition.hub_and_spoke import HubAndSpokePolicy, HubAndSpokePolicyGetResponse
from catalystwan.models.policy.definition.mesh import MeshPolicy, MeshPolicyGetResponse
from catalystwan.models.policy.definition.qos_map import QoSMapPolicy, QoSMapPolicyGetResponse
from catalystwan.models.policy.definition.rewrite import RewritePolicy, RewritePolicyGetResponse
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.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
from catalystwan.models.policy.list.class_map import ClassMapListInfo
from catalystwan.models.policy.list.communities import CommunityListInfo, ExpandedCommunityListInfo
from catalystwan.models.policy.list.data_ipv6_prefix import DataIPv6PrefixListInfo
from catalystwan.models.policy.list.data_prefix import DataPrefixListInfo
from catalystwan.models.policy.list.geo_location import GeoLocationListInfo
from catalystwan.models.policy.list.ips_signature import IPSSignatureListInfo
from catalystwan.models.policy.list.ipv6_prefix import IPv6PrefixListInfo
from catalystwan.models.policy.list.local_domain import LocalDomainListInfo
from catalystwan.models.policy.localized import (
LocalizedPolicy,
LocalizedPolicyDeviceInfo,
Expand All @@ -197,10 +150,9 @@
from catalystwan.models.policy.policy_definition import (
PolicyDefinitionBase,
PolicyDefinitionEditResponse,
PolicyDefinitionEndpoints,
PolicyDefinitionInfo,
)
from catalystwan.models.policy.policy_list import PolicyListEndpoints
from catalystwan.models.policy.policy_list import PolicyListBase
from catalystwan.models.policy.security import (
AnySecurityPolicy,
AnySecurityPolicyInfo,
Expand Down
48 changes: 48 additions & 0 deletions catalystwan/endpoints/configuration/policy/abstractions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from typing import Protocol
from uuid import UUID

from pydantic import BaseModel

from catalystwan.models.policy import AnyPolicyList
from catalystwan.models.policy.policy_definition import (
PolicyDefinitionEditResponse,
PolicyDefinitionGetResponse,
PolicyDefinitionId,
PolicyDefinitionInfo,
)
from catalystwan.models.policy.policy_list import PolicyListId, PolicyListInfo
from catalystwan.typed_list import DataSequence


class PolicyListEndpoints(Protocol):
def create_policy_list(self, payload: AnyPolicyList) -> PolicyListId:
...

def delete_policy_list(self, id: UUID) -> None:
...

def edit_policy_list(self, id: UUID, payload: AnyPolicyList) -> None:
...

def get_lists_by_id(self, id: UUID) -> PolicyListInfo:
...

def get_policy_lists(self) -> DataSequence[PolicyListInfo]:
...


class PolicyDefinitionEndpoints(Protocol):
def create_policy_definition(self, payload: BaseModel) -> PolicyDefinitionId:
...

def delete_policy_definition(self, id: UUID) -> None:
...

def edit_policy_definition(self, id: UUID, payload: BaseModel) -> PolicyDefinitionEditResponse:
...

def get_definitions(self) -> DataSequence[PolicyDefinitionInfo]:
...

def get_policy_definition(self, id: UUID) -> PolicyDefinitionGetResponse:
...
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@
from uuid import UUID

from catalystwan.endpoints import APIEndpoints, delete, get, post, put
from catalystwan.models.policy.definitions.access_control_list import AclPolicy
from catalystwan.endpoints.configuration.policy.abstractions import PolicyDefinitionEndpoints
from catalystwan.models.policy.definition.access_control_list import (
AclPolicy,
AclPolicyEditPayload,
AclPolicyGetResponse,
)
from catalystwan.models.policy.policy_definition import (
PolicyDefinitionEditResponse,
PolicyDefinitionEndpoints,
PolicyDefinitionGetResponse,
PolicyDefinitionId,
PolicyDefinitionInfo,
PolicyDefinitionPreview,
)
from catalystwan.typed_list import DataSequence


class AclPolicyEditPayload(AclPolicy, PolicyDefinitionId):
pass


class AclPolicyGetResponse(AclPolicy, PolicyDefinitionGetResponse):
pass


class ConfigurationPolicyAclDefinition(APIEndpoints, PolicyDefinitionEndpoints):
@post("/template/policy/definition/acl")
def create_policy_definition(self, payload: AclPolicy) -> PolicyDefinitionId:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@
from uuid import UUID

from catalystwan.endpoints import APIEndpoints, delete, get, post, put
from catalystwan.models.policy.definitions.access_control_list_ipv6 import AclIPv6Policy
from catalystwan.endpoints.configuration.policy.abstractions import PolicyDefinitionEndpoints
from catalystwan.models.policy.definition.access_control_list_ipv6 import (
AclIPv6Policy,
AclIPv6PolicyEditPayload,
AclIPv6PolicyGetResponse,
)
from catalystwan.models.policy.policy_definition import (
PolicyDefinitionEditResponse,
PolicyDefinitionEndpoints,
PolicyDefinitionGetResponse,
PolicyDefinitionId,
PolicyDefinitionInfo,
PolicyDefinitionPreview,
)
from catalystwan.typed_list import DataSequence


class AclIPv6PolicyEditPayload(AclIPv6Policy, PolicyDefinitionId):
pass


class AclIPv6PolicyGetResponse(AclIPv6Policy, PolicyDefinitionGetResponse):
pass


class ConfigurationPolicyAclIPv6Definition(APIEndpoints, PolicyDefinitionEndpoints):
@post("/template/policy/definition/aclv6")
def create_policy_definition(self, payload: AclIPv6Policy) -> PolicyDefinitionId:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@
from uuid import UUID

from catalystwan.endpoints import APIEndpoints, delete, get, post, put
from catalystwan.models.policy.definitions.control import ControlPolicy
from catalystwan.endpoints.configuration.policy.abstractions import PolicyDefinitionEndpoints
from catalystwan.models.policy.definition.control import (
ControlPolicy,
ControlPolicyEditPayload,
ControlPolicyGetResponse,
)
from catalystwan.models.policy.policy_definition import (
PolicyDefinitionEditResponse,
PolicyDefinitionEndpoints,
PolicyDefinitionGetResponse,
PolicyDefinitionId,
PolicyDefinitionInfo,
PolicyDefinitionPreview,
)
from catalystwan.typed_list import DataSequence


class ControlPolicyEditPayload(ControlPolicy, PolicyDefinitionId):
pass


class ControlPolicyGetResponse(ControlPolicy, PolicyDefinitionGetResponse):
pass


class ConfigurationPolicyControlDefinition(APIEndpoints, PolicyDefinitionEndpoints):
@post("/template/policy/definition/control")
def create_policy_definition(self, payload: ControlPolicy) -> PolicyDefinitionId:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@
from uuid import UUID

from catalystwan.endpoints import APIEndpoints, delete, get, post, put
from catalystwan.models.policy.definitions.device_access import DeviceAccessPolicy
from catalystwan.endpoints.configuration.policy.abstractions import PolicyDefinitionEndpoints
from catalystwan.models.policy.definition.device_access import (
DeviceAccessPolicy,
DeviceAccessPolicyEditPayload,
DeviceAccessPolicyGetResponse,
)
from catalystwan.models.policy.policy_definition import (
PolicyDefinitionEditResponse,
PolicyDefinitionEndpoints,
PolicyDefinitionGetResponse,
PolicyDefinitionId,
PolicyDefinitionInfo,
PolicyDefinitionPreview,
)
from catalystwan.typed_list import DataSequence


class DeviceAccessPolicyEditPayload(DeviceAccessPolicy, PolicyDefinitionId):
pass


class DeviceAccessPolicyGetResponse(DeviceAccessPolicy, PolicyDefinitionGetResponse):
pass


class ConfigurationPolicyDeviceAccessDefinition(APIEndpoints, PolicyDefinitionEndpoints):
@post("/template/policy/definition/deviceaccesspolicy")
def create_policy_definition(self, payload: DeviceAccessPolicy) -> PolicyDefinitionId:
Expand Down
Loading
Loading