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

Commit

Permalink
policy definition: fxsport
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Oct 26, 2024
1 parent 16f6583 commit f3369bd
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 3 deletions.
11 changes: 11 additions & 0 deletions catalystwan/api/policy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
)
from catalystwan.endpoints.configuration.policy.definition.dns_security import ConfigurationPolicyDnsSecurityDefinition
from catalystwan.endpoints.configuration.policy.definition.fxo_port import ConfigurationPolicyFxoPortDefinition
from catalystwan.endpoints.configuration.policy.definition.fxs_port import ConfigurationPolicyFxsPortDefinition
from catalystwan.endpoints.configuration.policy.definition.hub_and_spoke import ConfigurationPolicyHubAndSpokeDefinition
from catalystwan.endpoints.configuration.policy.definition.intrusion_prevention import (
ConfigurationPolicyIntrusionPreventionDefinition,
Expand Down Expand Up @@ -169,6 +170,7 @@
)
from catalystwan.models.policy.definition.dns_security import DnsSecurityPolicy, DnsSecurityPolicyGetResponse
from catalystwan.models.policy.definition.fxo_port import FxoPortPolicy, FxoPortPolicyGetResponse
from catalystwan.models.policy.definition.fxs_port import FxsPortPolicy, FxsPortPolicyGetResponse
from catalystwan.models.policy.definition.hub_and_spoke import HubAndSpokePolicy, HubAndSpokePolicyGetResponse
from catalystwan.models.policy.definition.intrusion_prevention import (
IntrusionPreventionPolicy,
Expand Down Expand Up @@ -297,6 +299,7 @@
DeviceAccessPolicy: ConfigurationPolicyDeviceAccessDefinition,
DnsSecurityPolicy: ConfigurationPolicyDnsSecurityDefinition,
FxoPortPolicy: ConfigurationPolicyFxoPortDefinition,
FxsPortPolicy: ConfigurationPolicyFxsPortDefinition,
HubAndSpokePolicy: ConfigurationPolicyHubAndSpokeDefinition,
IntrusionPreventionPolicy: ConfigurationPolicyIntrusionPreventionDefinition,
MeshPolicy: ConfigurationPolicyMeshDefinition,
Expand Down Expand Up @@ -914,6 +917,10 @@ def get(self, type: Type[AppRoutePolicy]) -> DataSequence[PolicyDefinitionInfo]:
def get(self, type: Type[FxoPortPolicy]) -> DataSequence[PolicyDefinitionInfo]:
...

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

# get by id
@overload
def get(self, type: Type[IntrusionPreventionPolicy], id: UUID) -> IntrusionPreventionPolicyGetResponse:
Expand Down Expand Up @@ -1015,6 +1022,10 @@ def get(self, type: Type[AppRoutePolicy], id: UUID) -> AppRoutePolicyGetResponse
def get(self, type: Type[FxoPortPolicy], id: UUID) -> FxoPortPolicyGetResponse:
...

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

def get(self, type: Type[AnyPolicyDefinition], id: Optional[UUID] = None) -> Any:
endpoints = self.__get_definition_endpoints_instance(type)
if id is not None:
Expand Down
57 changes: 57 additions & 0 deletions catalystwan/endpoints/configuration/policy/definition/fxs_port.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# 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.fxs_port import (
FxsPortPolicy,
FxsPortPolicyEditPayload,
FxsPortPolicyGetResponse,
)
from catalystwan.models.policy.policy_definition import (
PolicyDefinitionEditResponse,
PolicyDefinitionId,
PolicyDefinitionInfo,
PolicyDefinitionPreview,
)
from catalystwan.typed_list import DataSequence


class ConfigurationPolicyFxsPortDefinition(APIEndpoints, PolicyDefinitionEndpoints):
@post("/template/policy/definition/fxsport")
def create_policy_definition(self, payload: FxsPortPolicy) -> PolicyDefinitionId:
...

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

def edit_multiple_policy_definition(self):
# PUT /template/policy/definition/fxsport/multiple/{id}
...

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

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

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

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

@get("/template/policy/definition/fxsport/preview/{id}")
def preview_policy_definition_by_id(self, id: UUID) -> PolicyDefinitionPreview:
...

def save_policy_definition_in_bulk(self):
# PUT /template/policy/definition/fxsport/bulk
...
2 changes: 2 additions & 0 deletions catalystwan/endpoints/endpoints_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
ConfigurationPolicyDeviceAccessIPv6Definition,
)
from catalystwan.endpoints.configuration.policy.definition.fxo_port import ConfigurationPolicyFxoPortDefinition
from catalystwan.endpoints.configuration.policy.definition.fxs_port import ConfigurationPolicyFxsPortDefinition
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
Expand Down Expand Up @@ -175,6 +176,7 @@ def __init__(self, session: ManagerSession):
self.device_access = ConfigurationPolicyDeviceAccessDefinition(session)
self.device_access_ipv6 = ConfigurationPolicyDeviceAccessIPv6Definition(session)
self.fxo_port = ConfigurationPolicyFxoPortDefinition(session)
self.fxs_port = ConfigurationPolicyFxsPortDefinition(session)
self.hub_and_spoke = ConfigurationPolicyHubAndSpokeDefinition(session)
self.mesh = ConfigurationPolicyMeshDefinition(session)
self.qos_map = ConfigurationPolicyQoSMapDefinition(session)
Expand Down
3 changes: 3 additions & 0 deletions catalystwan/models/policy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from catalystwan.models.policy.definition.app_route import AppRoutePolicy, AppRoutePolicyGetResponse
from catalystwan.models.policy.definition.fxo_port import FxoPortPolicy, FxoPortPolicyGetResponse
from catalystwan.models.policy.definition.fxs_port import FxsPortPolicy, FxsPortPolicyGetResponse
from catalystwan.models.policy.list.app import AppList, AppListInfo
from catalystwan.models.policy.list.app_probe import AppProbeClassList, AppProbeClassListInfo
from catalystwan.models.policy.list.as_path import ASPathList, ASPathListInfo
Expand Down Expand Up @@ -110,6 +111,7 @@
DeviceAccessPolicy,
DnsSecurityPolicy,
FxoPortPolicy,
FxsPortPolicy,
HubAndSpokePolicy,
IntrusionPreventionPolicy,
MeshPolicy,
Expand Down Expand Up @@ -235,6 +237,7 @@
DeviceAccessPolicyGetResponse,
DnsSecurityPolicyGetResponse,
FxoPortPolicyGetResponse,
FxsPortPolicyGetResponse,
HubAndSpokePolicyGetResponse,
IntrusionPreventionPolicyGetResponse,
MeshPolicyGetResponse,
Expand Down
4 changes: 2 additions & 2 deletions catalystwan/models/policy/definition/fxo_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

from catalystwan.models.policy.policy_definition import (
CommonStation,
FxoTuningParams,
LineParams,
PolicyDefinitionBase,
PolicyDefinitionGetResponse,
PolicyDefinitionId,
SupervisoryDisconnectEntry,
TranslationProfileEntry,
TrunkGroupPreference,
TuningParams,
)


Expand All @@ -25,7 +25,7 @@ class FxoPortPolicyDefinition(BaseModel):
line_params: Optional[LineParams] = Field(
default=None, serialization_alias="lineParams", validation_alias="lineParams"
)
tuning_params: Optional[TuningParams] = Field(
tuning_params: Optional[FxoTuningParams] = Field(
default=None, serialization_alias="tuningParams", validation_alias="tuningParams"
)
trunk_group: Optional[List[TrunkGroupPreference]] = Field(
Expand Down
53 changes: 53 additions & 0 deletions catalystwan/models/policy/definition/fxs_port.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates

from typing import List, Literal, Optional

from pydantic import BaseModel, ConfigDict, Field

from catalystwan.models.policy.policy_definition import (
CommonStation,
FxsTuningParams,
LineParams,
PolicyDefinitionBase,
PolicyDefinitionGetResponse,
PolicyDefinitionId,
TranslationProfileEntry,
TrunkGroupPreference,
)


class FxsPortPolicyDefinition(BaseModel):
model_config = ConfigDict(populate_by_name=True)
common_station: Optional[CommonStation] = Field(
default=None, serialization_alias="commonStation", validation_alias="commonStation"
)
line_params: Optional[LineParams] = Field(
default=None, serialization_alias="lineParams", validation_alias="lineParams"
)
tuning_params: Optional[FxsTuningParams] = Field(
default=None, serialization_alias="tuningParams", validation_alias="tuningParams"
)
trunk_group: Optional[List[TrunkGroupPreference]] = Field(
default=None, serialization_alias="trunkGroup", validation_alias="trunkGroup"
)
incoming_translation_profile: Optional[TranslationProfileEntry] = Field(
default=None, serialization_alias="incomingTranslationProfile", validation_alias="incomingTranslationProfile"
)
outgoing_translation_profile: Optional[TranslationProfileEntry] = Field(
default=None, serialization_alias="outgoingTranslationProfile", validation_alias="outgoingTranslationProfile"
)


class FxsPortPolicy(PolicyDefinitionBase):
model_config = ConfigDict(populate_by_name=True)
type: Literal["fxsPort", "fxsport"] = "fxsPort"
port_type: Optional[str] = Field(default=None, serialization_alias="portType", validation_alias="portType")
definition: FxsPortPolicyDefinition = FxsPortPolicyDefinition()


class FxsPortPolicyEditPayload(FxsPortPolicy, PolicyDefinitionId):
pass


class FxsPortPolicyGetResponse(FxsPortPolicy, PolicyDefinitionGetResponse):
pass
21 changes: 20 additions & 1 deletion catalystwan/models/policy/policy_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class LineParams(BaseModel):
impedance: str


class TuningParams(BaseModel):
class FxoTuningParams(BaseModel):
model_config = ConfigDict(populate_by_name=True)
pre_dial_delay: int = Field(ge=0, serialization_alias="preDialDelay", validation_alias="preDialDelay")
timing_sup_disc: IntStr = Field(serialization_alias="timingSupDisc", validation_alias="timingSupDisc")
Expand All @@ -150,6 +150,25 @@ class TuningParams(BaseModel):
)


class FxsTuningParams(BaseModel):
model_config = ConfigDict(populate_by_name=True)
timing_hookflash_in_min: IntStr = Field(
ge=0, le=400, serialization_alias="timingHookflashInMin", validation_alias="timingHookflashInMin"
)
timing_hookflash_in_max: IntStr = Field(
ge=50, le=1500, serialization_alias="timingHookflashInMax", validation_alias="timingHookflashInMax"
)
loop_length: str = Field(serialization_alias="loopLength", validation_alias="loopLength")
ring_frequency: IntStr = Field(serialization_alias="ringFrequency", validation_alias="ringFrequency")
ring_dc_offset: Optional[str] = Field(
default=None, serialization_alias="ringDcOffset", validation_alias="ringDcOffset"
)
pulse_digit_detection: bool = Field(
serialization_alias="pulseDigitDetection", validation_alias="pulseDigitDetection"
)
ren: IntStr = Field(ge=1, le=5)


class TrunkGroupPreference(BaseModel):
model_config = ConfigDict(populate_by_name=True)
ref: UUID
Expand Down

0 comments on commit f3369bd

Please sign in to comment.