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

Commit

Permalink
policy list: supervisorydisc
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Oct 25, 2024
1 parent 879b311 commit aad1cd5
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 1 deletion.
16 changes: 16 additions & 0 deletions catalystwan/api/policy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -263,6 +270,7 @@
ScalableGroupTagList: ConfigurationPolicyScalableGroupTagList,
SiteList: ConfigurationPolicySiteList,
SLAClassList: ConfigurationPolicySLAClassList,
SupervisoryDisconnectList: ConfigurationPolicySupervisoryDisconnectList,
ThreatGridApiKeyList: ConfigurationPolicyThreatGridApiKeyList,
TLOCList: ConfigurationPolicyTLOCList,
TranslationProfileList: ConfigurationPolicyTranslationProfileList,
Expand Down Expand Up @@ -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]:
...
Expand Down Expand Up @@ -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:
...
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
...
4 changes: 4 additions & 0 deletions catalystwan/endpoints/endpoints_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions catalystwan/models/policy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -154,6 +155,7 @@
ScalableGroupTagList,
SiteList,
SLAClassList,
SupervisoryDisconnectList,
ThreatGridApiKeyList,
TLOCList,
TranslationProfileList,
Expand Down
2 changes: 1 addition & 1 deletion catalystwan/models/policy/list/modem_pass_through.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
62 changes: 62 additions & 0 deletions catalystwan/models/policy/list/supervisory_disconnect.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit aad1cd5

Please sign in to comment.