From aad1cd55f3d8126284dd7fb52095f7ccbac860cd Mon Sep 17 00:00:00 2001 From: Szymon Basan Date: Fri, 25 Oct 2024 16:54:18 +0200 Subject: [PATCH] policy list: supervisorydisc --- catalystwan/api/policy_api.py | 16 +++++ .../policy/list/supervisory_disconnect.py | 52 ++++++++++++++++ catalystwan/endpoints/endpoints_container.py | 4 ++ catalystwan/models/policy/__init__.py | 2 + .../models/policy/list/modem_pass_through.py | 2 +- .../policy/list/supervisory_disconnect.py | 62 +++++++++++++++++++ 6 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 catalystwan/endpoints/configuration/policy/list/supervisory_disconnect.py create mode 100644 catalystwan/models/policy/list/supervisory_disconnect.py diff --git a/catalystwan/api/policy_api.py b/catalystwan/api/policy_api.py index 620fbb88..09df1b18 100644 --- a/catalystwan/api/policy_api.py +++ b/catalystwan/api/policy_api.py @@ -85,6 +85,9 @@ from catalystwan.endpoints.configuration.policy.list.scalable_group_tag import ConfigurationPolicyScalableGroupTagList from catalystwan.endpoints.configuration.policy.list.site import ConfigurationPolicySiteList, SiteListInfo from catalystwan.endpoints.configuration.policy.list.sla import ConfigurationPolicySLAClassList, SLAClassListInfo +from catalystwan.endpoints.configuration.policy.list.supervisory_disconnect import ( + ConfigurationPolicySupervisoryDisconnectList, +) from catalystwan.endpoints.configuration.policy.list.threat_grid_api_key import ConfigurationPolicyThreatGridApiKeyList from catalystwan.endpoints.configuration.policy.list.tloc import ConfigurationPolicyTLOCList, TLOCListInfo from catalystwan.endpoints.configuration.policy.list.translation_profile import ( @@ -202,6 +205,10 @@ from catalystwan.models.policy.list.media_profile import MediaProfileList, MediaProfileListInfo from catalystwan.models.policy.list.modem_pass_through import ModemPassThroughList, ModemPassThroughListInfo from catalystwan.models.policy.list.scalable_group_tag import ScalableGroupTagList, ScalableGroupTagListInfo +from catalystwan.models.policy.list.supervisory_disconnect import ( + SupervisoryDisconnectList, + SupervisoryDisconnectListInfo, +) from catalystwan.models.policy.list.threat_grid_api_key import ThreatGridApiKeyList, ThreatGridApiKeyListInfo from catalystwan.models.policy.list.translation_profile import TranslationProfileList, TranslationProfileListInfo from catalystwan.models.policy.list.translation_rules import TranslationRulesList, TranslationRulesListInfo @@ -263,6 +270,7 @@ ScalableGroupTagList: ConfigurationPolicyScalableGroupTagList, SiteList: ConfigurationPolicySiteList, SLAClassList: ConfigurationPolicySLAClassList, + SupervisoryDisconnectList: ConfigurationPolicySupervisoryDisconnectList, ThreatGridApiKeyList: ConfigurationPolicyThreatGridApiKeyList, TLOCList: ConfigurationPolicyTLOCList, TranslationProfileList: ConfigurationPolicyTranslationProfileList, @@ -550,6 +558,10 @@ def get(self, type: Type[SiteList]) -> DataSequence[SiteListInfo]: def get(self, type: Type[SLAClassList]) -> DataSequence[SLAClassListInfo]: ... + @overload + def get(self, type: Type[SupervisoryDisconnectList]) -> DataSequence[SupervisoryDisconnectListInfo]: + ... + @overload def get(self, type: Type[ThreatGridApiKeyList]) -> DataSequence[ThreatGridApiKeyListInfo]: ... @@ -712,6 +724,10 @@ def get(self, type: Type[SiteList], id: UUID) -> SiteListInfo: def get(self, type: Type[SLAClassList], id: UUID) -> SLAClassListInfo: ... + @overload + def get(self, type: Type[SupervisoryDisconnectList], id: UUID) -> SupervisoryDisconnectListInfo: + ... + @overload def get(self, type: Type[ThreatGridApiKeyList], id: UUID) -> ThreatGridApiKeyListInfo: ... diff --git a/catalystwan/endpoints/configuration/policy/list/supervisory_disconnect.py b/catalystwan/endpoints/configuration/policy/list/supervisory_disconnect.py new file mode 100644 index 00000000..4e12aa3a --- /dev/null +++ b/catalystwan/endpoints/configuration/policy/list/supervisory_disconnect.py @@ -0,0 +1,52 @@ +# 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 PolicyListEndpoints +from catalystwan.models.policy.list.supervisory_disconnect import ( + SupervisoryDisconnectList, + SupervisoryDisconnectListEditPayload, + SupervisoryDisconnectListInfo, +) +from catalystwan.models.policy.policy_list import InfoTag, PolicyListId, PolicyListPreview +from catalystwan.typed_list import DataSequence + + +class ConfigurationPolicySupervisoryDisconnectList(APIEndpoints, PolicyListEndpoints): + @post("/template/policy/list/supervisorydisc") + def create_policy_list(self, payload: SupervisoryDisconnectList) -> PolicyListId: + ... + + @delete("/template/policy/list/supervisorydisc/{id}") + def delete_policy_list(self, id: UUID) -> None: + ... + + @delete("/template/policy/list/supervisorydisc") + def delete_policy_lists_with_info_tag(self, params: InfoTag) -> None: + ... + + @put("/template/policy/list/supervisorydisc/{id}") + def edit_policy_list(self, id: UUID, payload: SupervisoryDisconnectListEditPayload) -> None: + ... + + @get("/template/policy/list/supervisorydisc/{id}") + def get_lists_by_id(self, id: UUID) -> SupervisoryDisconnectListInfo: + ... + + @get("/template/policy/list/supervisorydisc", "data") + def get_policy_lists(self) -> DataSequence[SupervisoryDisconnectListInfo]: + ... + + @get("/template/policy/list/supervisorydisc/filtered", "data") + def get_policy_lists_with_info_tag(self, params: InfoTag) -> DataSequence[SupervisoryDisconnectListInfo]: + ... + + @post("/template/policy/list/supervisorydisc/preview") + def preview_policy_list(self, payload: SupervisoryDisconnectList) -> PolicyListPreview: + ... + + @get("/template/policy/list/supervisorydisc/preview/{id}") + def preview_policy_list_by_id(self, id: UUID) -> PolicyListPreview: + ... diff --git a/catalystwan/endpoints/endpoints_container.py b/catalystwan/endpoints/endpoints_container.py index 4a1daa78..19de685c 100644 --- a/catalystwan/endpoints/endpoints_container.py +++ b/catalystwan/endpoints/endpoints_container.py @@ -75,6 +75,9 @@ from catalystwan.endpoints.configuration.policy.list.region import ConfigurationPolicyRegionList from catalystwan.endpoints.configuration.policy.list.site import ConfigurationPolicySiteList from catalystwan.endpoints.configuration.policy.list.sla import ConfigurationPolicySLAClassList +from catalystwan.endpoints.configuration.policy.list.supervisory_disconnect import ( + ConfigurationPolicySupervisoryDisconnectList, +) from catalystwan.endpoints.configuration.policy.list.tloc import ConfigurationPolicyTLOCList from catalystwan.endpoints.configuration.policy.list.translation_profile import ( ConfigurationPolicyTranslationProfileList, @@ -148,6 +151,7 @@ def __init__(self, session: ManagerSession): self.region = ConfigurationPolicyRegionList(session) self.site = ConfigurationPolicySiteList(session) self.sla = ConfigurationPolicySLAClassList(session) + self.supervisory_disconnect = ConfigurationPolicySupervisoryDisconnectList(session) self.tloc = ConfigurationPolicyTLOCList(session) self.translation_profile = ConfigurationPolicyTranslationProfileList(session) self.translation_rules = ConfigurationPolicyTranslationRulesList(session) diff --git a/catalystwan/models/policy/__init__.py b/catalystwan/models/policy/__init__.py index f17dc513..c746d78e 100644 --- a/catalystwan/models/policy/__init__.py +++ b/catalystwan/models/policy/__init__.py @@ -42,6 +42,7 @@ from catalystwan.models.policy.list.scalable_group_tag import ScalableGroupTagList, ScalableGroupTagListInfo from catalystwan.models.policy.list.site import SiteList, SiteListInfo from catalystwan.models.policy.list.sla import SLAClassList, SLAClassListInfo +from catalystwan.models.policy.list.supervisory_disconnect import SupervisoryDisconnectList from catalystwan.models.policy.list.threat_grid_api_key import ThreatGridApiKeyList, ThreatGridApiKeyListInfo from catalystwan.models.policy.list.tloc import TLOCList, TLOCListInfo from catalystwan.models.policy.list.translation_profile import TranslationProfileList @@ -154,6 +155,7 @@ ScalableGroupTagList, SiteList, SLAClassList, + SupervisoryDisconnectList, ThreatGridApiKeyList, TLOCList, TranslationProfileList, diff --git a/catalystwan/models/policy/list/modem_pass_through.py b/catalystwan/models/policy/list/modem_pass_through.py index 17d3dfd4..0d538d8d 100644 --- a/catalystwan/models/policy/list/modem_pass_through.py +++ b/catalystwan/models/policy/list/modem_pass_through.py @@ -16,7 +16,7 @@ class ModemPassThroughListEntry(BaseModel): class ModemPassThroughList(PolicyListBase): model_config = ConfigDict(populate_by_name=True) type: Literal["modemPassthrough", "modempassthrough"] = "modemPassthrough" - entires: List[ModemPassThroughListEntry] = Field(default_factory=list, max_length=1) + entries: List[ModemPassThroughListEntry] = Field(default_factory=list, max_length=1) class ModemPassThroughListEditPayload(ModemPassThroughList, PolicyListId): diff --git a/catalystwan/models/policy/list/supervisory_disconnect.py b/catalystwan/models/policy/list/supervisory_disconnect.py new file mode 100644 index 00000000..7ad72f8d --- /dev/null +++ b/catalystwan/models/policy/list/supervisory_disconnect.py @@ -0,0 +1,62 @@ +# Copyright 2024 Cisco Systems, Inc. and its affiliates + +from typing import List, Literal, Union + +from pydantic import BaseModel, ConfigDict, Field +from typing_extensions import Annotated + +from catalystwan.models.common import IntStr +from catalystwan.models.policy.policy_list import PolicyListBase, PolicyListId, PolicyListInfo + + +class DualToneModeEntry(BaseModel): + model_config = ConfigDict(populate_by_name=True) + mode: Literal["dualtone_mode"] = "dualtone_mode" + cadence_variable: IntStr = Field( + ge=0, le=200, serialization_alias="cadenceVariable", validation_alias="cadenceVariable" + ) + frequency_max_delay: IntStr = Field( + ge=10, le=100, serialization_alias="frequencyMaxDelay", validation_alias="frequencyMaxDelay" + ) + frequency_max_deviation: IntStr = Field( + ge=10, le=125, serialization_alias="frequencyMaxDeviation", validation_alias="frequencyMaxDeviation" + ) + frequency_max_power: IntStr = Field( + ge=0, le=20, serialization_alias="frequencyMaxPower", validation_alias="frequencyMaxPower" + ) + frequency_min_power: IntStr = Field( + ge=10, le=35, serialization_alias="frequencyMinPower", validation_alias="frequencyMinPower" + ) + frequency_min_power_twist: IntStr = Field( + ge=0, le=15, serialization_alias="frequencyMinPowerTwist", validation_alias="frequencyMinPowerTwist" + ) + + +class CustomModeEntry(BaseModel): + model_config = ConfigDict(populate_by_name=True) + mode: Literal["custom_mode"] = "custom_mode" + dualtone_type: str = Field(validation_alias="dualtoneType", serialization_alias="dualtoneType") + cadence: IntStr = Field(ge=50, le=10_000) + dualtone_frequency1: IntStr = Field( + ge=300, le=3600, validation_alias="dualtoneFrequency1", serialization_alias="dualtoneFrequency1" + ) + dualtone_frequency2: IntStr = Field( + ge=300, le=3600, validation_alias="dualtoneFrequency2", serialization_alias="dualtoneFrequency2" + ) + + +SupervisoryDisconnectListEntry = Annotated[Union[DualToneModeEntry, CustomModeEntry], Field(discriminator="mode")] + + +class SupervisoryDisconnectList(PolicyListBase): + model_config = ConfigDict(populate_by_name=True) + type: Literal["supervisoryDisc", "supervisorydisc"] = "supervisoryDisc" + entries: List[SupervisoryDisconnectListEntry] = Field(default_factory=list) + + +class SupervisoryDisconnectListEditPayload(SupervisoryDisconnectList, PolicyListId): + pass + + +class SupervisoryDisconnectListInfo(SupervisoryDisconnectList, PolicyListInfo): + pass