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

Commit

Permalink
policy list: faxprotocol
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Oct 25, 2024
1 parent d123d63 commit 879b311
Show file tree
Hide file tree
Showing 7 changed files with 146 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 @@ -59,6 +59,7 @@
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.extended_community import ConfigurationPolicyExtendedCommunityList
from catalystwan.endpoints.configuration.policy.list.fax_protocol import ConfigurationPolicyFaxProtocolList
from catalystwan.endpoints.configuration.policy.list.fqdn import ConfigurationPolicyFQDNList, FQDNListInfo
from catalystwan.endpoints.configuration.policy.list.geo_location import ConfigurationPolicyGeoLocationList
from catalystwan.endpoints.configuration.policy.list.identity import ConfigurationPolicyIdentityList
Expand Down Expand Up @@ -192,6 +193,7 @@
)
from catalystwan.models.policy.list.data_ipv6_prefix import DataIPv6PrefixListInfo
from catalystwan.models.policy.list.data_prefix import DataPrefixListInfo
from catalystwan.models.policy.list.fax_protocol import FaxProtocolList, FaxProtocolListInfo
from catalystwan.models.policy.list.geo_location import GeoLocationListInfo
from catalystwan.models.policy.list.identity import IdentityList, IdentityListInfo
from catalystwan.models.policy.list.ips_signature import IPSSignatureListInfo
Expand Down Expand Up @@ -241,6 +243,7 @@
DataPrefixList: ConfigurationPolicyDataPrefixList,
ExpandedCommunityList: ConfigurationPolicyExpandedCommunityList,
ExtendedCommunityList: ConfigurationPolicyExtendedCommunityList,
FaxProtocolList: ConfigurationPolicyFaxProtocolList,
FQDNList: ConfigurationPolicyFQDNList,
GeoLocationList: ConfigurationPolicyGeoLocationList,
IdentityList: ConfigurationPolicyIdentityList,
Expand Down Expand Up @@ -475,6 +478,10 @@ def get(self, type: Type[ExpandedCommunityList]) -> DataSequence[ExpandedCommuni
def get(self, type: Type[ExtendedCommunityList]) -> DataSequence[ExtendedCommunityListInfo]:
...

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

@overload
def get(self, type: Type[FQDNList]) -> DataSequence[FQDNListInfo]:
...
Expand Down Expand Up @@ -633,6 +640,10 @@ def get(self, type: Type[ExpandedCommunityList], id: UUID) -> ExpandedCommunityL
def get(self, type: Type[ExtendedCommunityList], id: UUID) -> ExtendedCommunityListInfo:
...

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

@overload
def get(self, type: Type[FQDNList], id: UUID) -> FQDNListInfo:
...
Expand Down
48 changes: 48 additions & 0 deletions catalystwan/endpoints/configuration/policy/list/fax_protocol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 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.fax_protocol import FaxProtocolList, FaxProtocolListEditPayload, FaxProtocolListInfo
from catalystwan.models.policy.policy_list import InfoTag, PolicyListId, PolicyListPreview
from catalystwan.typed_list import DataSequence


class ConfigurationPolicyFaxProtocolList(APIEndpoints, PolicyListEndpoints):
@post("/template/policy/list/faxprotocol")
def create_policy_list(self, payload: FaxProtocolList) -> PolicyListId:
...

@delete("/template/policy/list/faxprotocol/{id}")
def delete_policy_list(self, id: UUID) -> None:
...

@delete("/template/policy/list/faxprotocol")
def delete_policy_lists_with_info_tag(self, params: InfoTag) -> None:
...

@put("/template/policy/list/faxprotocol/{id}")
def edit_policy_list(self, id: UUID, payload: FaxProtocolListEditPayload) -> None:
...

@get("/template/policy/list/faxprotocol/{id}")
def get_lists_by_id(self, id: UUID) -> FaxProtocolListInfo:
...

@get("/template/policy/list/faxprotocol", "data")
def get_policy_lists(self) -> DataSequence[FaxProtocolListInfo]:
...

@get("/template/policy/list/faxprotocol/filtered", "data")
def get_policy_lists_with_info_tag(self, params: InfoTag) -> DataSequence[FaxProtocolListInfo]:
...

@post("/template/policy/list/faxprotocol/preview")
def preview_policy_list(self, payload: FaxProtocolList) -> PolicyListPreview:
...

@get("/template/policy/list/faxprotocol/preview/{id}")
def preview_policy_list_by_id(self, id: UUID) -> PolicyListPreview:
...
2 changes: 2 additions & 0 deletions catalystwan/endpoints/endpoints_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
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.extended_community import ConfigurationPolicyExtendedCommunityList
from catalystwan.endpoints.configuration.policy.list.fax_protocol import ConfigurationPolicyFaxProtocolList
from catalystwan.endpoints.configuration.policy.list.fqdn import ConfigurationPolicyFQDNList
from catalystwan.endpoints.configuration.policy.list.geo_location import ConfigurationPolicyGeoLocationList
from catalystwan.endpoints.configuration.policy.list.ips_signature import ConfigurationPolicyIPSSignatureList
Expand Down Expand Up @@ -129,6 +130,7 @@ def __init__(self, session: ManagerSession):
self.data_prefix = ConfigurationPolicyDataPrefixList(session)
self.expanded_community = ConfigurationPolicyExpandedCommunityList(session)
self.extended_community = ConfigurationPolicyExtendedCommunityList(session)
self.fax_protocol = ConfigurationPolicyFaxProtocolList(session)
self.fqdn = ConfigurationPolicyFQDNList(session)
self.geo_location = ConfigurationPolicyGeoLocationList(session)
self.ips_signature = ConfigurationPolicyIPSSignatureList(session)
Expand Down
37 changes: 36 additions & 1 deletion catalystwan/models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,42 @@ def str_as_interface_list(val: Union[str, Sequence[InterfaceStr]]) -> Sequence[I
"ilbc",
]

ModemPassThroughCodec = Literal[
FaxProtocols = Literal[
"Fax Pass-through G711alaw No ECM",
"Fax Pass-through G711alaw",
"Fax Pass-through G711ulaw No ECM",
"Fax Pass-through G711ulaw",
"None",
"T.38 Fax Relay Version 0 No ECM",
"T.38 Fax Relay Version 0 NSE force No ECM",
"T.38 Fax Relay Version 0 NSE force Rate 14.4 No ECM",
"T.38 Fax Relay Version 0 NSE force Rate 14.4",
"T.38 Fax Relay Version 0 NSE force Rate 9.6 No ECM",
"T.38 Fax Relay Version 0 NSE force Rate 9.6",
"T.38 Fax Relay Version 0 NSE force",
"T.38 Fax Relay Version 0 NSE No ECM",
"T.38 Fax Relay Version 0 NSE Rate 14.4 No ECM",
"T.38 Fax Relay Version 0 NSE Rate 14.4",
"T.38 Fax Relay Version 0 NSE Rate 9.6 No ECM",
"T.38 Fax Relay Version 0 NSE Rate 9.6",
"T.38 Fax Relay Version 0 NSE",
"T.38 Fax Relay Version 0 Rate 14.4 No ECM",
"T.38 Fax Relay Version 0 Rate 14.4",
"T.38 Fax Relay Version 0 Rate 9.6 No ECM",
"T.38 Fax Relay Version 0",
"T.38 Fax Relay Version 3 NSE force",
"T.38 Fax Relay Version 3 NSE",
"T.38 Fax Relay Version 3",
]

FaxPrimaryProtocols = Literal[
"none",
"t38",
"g711ulaw",
"g711alaw",
]

FaxFallBackProtocols = Literal[
"none",
"g711ulaw",
"g711alaw",
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 @@ -22,6 +22,7 @@
)
from catalystwan.models.policy.list.data_ipv6_prefix import DataIPv6PrefixList, DataIPv6PrefixListInfo
from catalystwan.models.policy.list.data_prefix import DataPrefixList, DataPrefixListInfo
from catalystwan.models.policy.list.fax_protocol import FaxProtocolList
from catalystwan.models.policy.list.fqdn import FQDNList, FQDNListInfo
from catalystwan.models.policy.list.geo_location import GeoLocationList, GeoLocationListInfo
from catalystwan.models.policy.list.identity import IdentityList, IdentityListInfo
Expand Down Expand Up @@ -133,6 +134,7 @@
DataPrefixList,
ExpandedCommunityList,
ExtendedCommunityList,
FaxProtocolList,
FQDNList,
GeoLocationList,
IdentityList,
Expand Down
45 changes: 45 additions & 0 deletions catalystwan/models/policy/list/fax_protocol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates

from typing import List, Literal, Optional

from pydantic import BaseModel, ConfigDict, Field

from catalystwan.models.common import FaxFallBackProtocols, FaxPrimaryProtocols
from catalystwan.models.policy.policy_list import PolicyListBase, PolicyListId, PolicyListInfo


class T38Options(BaseModel):
model_config = ConfigDict(populate_by_name=True)
version: int = Field(ge=0)
rate: str
nse: str
lowSpeed: int = Field(ge=0, validation_alias="lowSpeed", serialization_alias="lowSpeed")
highSpeed: int = Field(ge=0, validation_alias="highSpeed", serialization_alias="highSpeed")
fallbackProtocol: FaxFallBackProtocols = Field(
validation_alias="fallbackProtocol", serialization_alias="fallbackProtocol"
)


class FaxProtocolListEntry(BaseModel):
model_config = ConfigDict(populate_by_name=True)
primary_protocol: FaxPrimaryProtocols = Field(
validation_alias="primaryProtocol", serialization_alias="primaryProtocol"
)
ecm: bool = Field(default=False)
t38_options: Optional[T38Options] = Field(
default=None, serialization_alias="t38Options", validation_alias="t38Options"
)


class FaxProtocolList(PolicyListBase):
model_config = ConfigDict(populate_by_name=True)
type: Literal["faxProtocol", "faxprotocol"] = "faxProtocol"
entries: List[FaxProtocolListEntry] = Field(default_factory=list)


class FaxProtocolListEditPayload(FaxProtocolList, PolicyListId):
pass


class FaxProtocolListInfo(FaxProtocolList, PolicyListInfo):
pass
4 changes: 2 additions & 2 deletions catalystwan/models/policy/list/modem_pass_through.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

from pydantic import BaseModel, ConfigDict, Field

from catalystwan.models.common import ModemPassThroughCodec
from catalystwan.models.common import FaxFallBackProtocols
from catalystwan.models.policy.policy_list import PolicyListBase, PolicyListId, PolicyListInfo


class ModemPassThroughListEntry(BaseModel):
model_config = ConfigDict(populate_by_name=True)
protocol: ModemPassThroughCodec
protocol: FaxFallBackProtocols


class ModemPassThroughList(PolicyListBase):
Expand Down

0 comments on commit 879b311

Please sign in to comment.