From 879b311c3bd7f2cd37da1865c65cb521fd0f682c Mon Sep 17 00:00:00 2001 From: Szymon Basan Date: Fri, 25 Oct 2024 15:31:36 +0200 Subject: [PATCH] policy list: faxprotocol --- catalystwan/api/policy_api.py | 11 +++++ .../configuration/policy/list/fax_protocol.py | 48 +++++++++++++++++++ catalystwan/endpoints/endpoints_container.py | 2 + catalystwan/models/common.py | 37 +++++++++++++- catalystwan/models/policy/__init__.py | 2 + .../models/policy/list/fax_protocol.py | 45 +++++++++++++++++ .../models/policy/list/modem_pass_through.py | 4 +- 7 files changed, 146 insertions(+), 3 deletions(-) create mode 100644 catalystwan/endpoints/configuration/policy/list/fax_protocol.py create mode 100644 catalystwan/models/policy/list/fax_protocol.py diff --git a/catalystwan/api/policy_api.py b/catalystwan/api/policy_api.py index 9dc2f57c..620fbb88 100644 --- a/catalystwan/api/policy_api.py +++ b/catalystwan/api/policy_api.py @@ -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 @@ -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 @@ -241,6 +243,7 @@ DataPrefixList: ConfigurationPolicyDataPrefixList, ExpandedCommunityList: ConfigurationPolicyExpandedCommunityList, ExtendedCommunityList: ConfigurationPolicyExtendedCommunityList, + FaxProtocolList: ConfigurationPolicyFaxProtocolList, FQDNList: ConfigurationPolicyFQDNList, GeoLocationList: ConfigurationPolicyGeoLocationList, IdentityList: ConfigurationPolicyIdentityList, @@ -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]: ... @@ -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: ... diff --git a/catalystwan/endpoints/configuration/policy/list/fax_protocol.py b/catalystwan/endpoints/configuration/policy/list/fax_protocol.py new file mode 100644 index 00000000..9941f1b1 --- /dev/null +++ b/catalystwan/endpoints/configuration/policy/list/fax_protocol.py @@ -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: + ... diff --git a/catalystwan/endpoints/endpoints_container.py b/catalystwan/endpoints/endpoints_container.py index 392ac84c..4a1daa78 100644 --- a/catalystwan/endpoints/endpoints_container.py +++ b/catalystwan/endpoints/endpoints_container.py @@ -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 @@ -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) diff --git a/catalystwan/models/common.py b/catalystwan/models/common.py index 1481ce4a..112f94ee 100644 --- a/catalystwan/models/common.py +++ b/catalystwan/models/common.py @@ -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", diff --git a/catalystwan/models/policy/__init__.py b/catalystwan/models/policy/__init__.py index 3b125cf2..f17dc513 100644 --- a/catalystwan/models/policy/__init__.py +++ b/catalystwan/models/policy/__init__.py @@ -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 @@ -133,6 +134,7 @@ DataPrefixList, ExpandedCommunityList, ExtendedCommunityList, + FaxProtocolList, FQDNList, GeoLocationList, IdentityList, diff --git a/catalystwan/models/policy/list/fax_protocol.py b/catalystwan/models/policy/list/fax_protocol.py new file mode 100644 index 00000000..8da6986f --- /dev/null +++ b/catalystwan/models/policy/list/fax_protocol.py @@ -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 diff --git a/catalystwan/models/policy/list/modem_pass_through.py b/catalystwan/models/policy/list/modem_pass_through.py index 7fd92463..17d3dfd4 100644 --- a/catalystwan/models/policy/list/modem_pass_through.py +++ b/catalystwan/models/policy/list/modem_pass_through.py @@ -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):