Skip to content

Commit c9d181a

Browse files
authored
fix media profile model (#70)
1 parent 57374e1 commit c9d181a

File tree

6 files changed

+25
-39
lines changed

6 files changed

+25
-39
lines changed

ENDPOINTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
**THIS FILE WAS AUTO-GENERATED DO NOT EDIT**
22

3-
Generated for: catalystwan-0.40.2.dev5
3+
Generated for: catalystwan-0.40.2.dev6
44

55
All URIs are relative to */dataservice*
66
HTTP request | Supported Versions | Method | Payload Type | Return Type | Tenancy Mode

catalystwan/models/common.py

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -377,17 +377,7 @@ def str_as_interface_list(val: Union[str, Sequence[InterfaceStr]]) -> Sequence[I
377377
"private6",
378378
]
379379

380-
MpVoiceCodec = Literal[
381-
"G711aLaw",
382-
"G711uLaw",
383-
"G722",
384-
"G729r8",
385-
"ilbc",
386-
"g711ulaw",
387-
"g711alaw",
388-
"g772",
389-
"g729r8",
390-
]
380+
MpVoiceCodec = Literal["g711ulaw", "g711alaw", "g729r8", "g729br8", "g722-64", "clear-channel", "isac", "ilbc"]
391381

392382
FaxProtocols = Literal[
393383
"Fax Pass-through G711alaw No ECM",
@@ -433,20 +423,22 @@ def str_as_interface_list(val: Union[str, Sequence[InterfaceStr]]) -> Sequence[I
433423
MpDtmf = Literal[
434424
"inband",
435425
"rtp-nte",
436-
"rtp-nte sip-kpml",
437-
"rtp-nte sip-kpml sip-notify",
438-
"rtp-nte sip-notify",
439-
"rtp-nte sip-notify sip-kpml",
440-
"sip-kpml",
441-
"sip-kpml rtp-nte",
442-
"sip-kpml rtp-nte sip-notify",
443-
"sip-kpml sip-notify",
444-
"sip-kpml sip-notify rtp-nte",
445426
"sip-notify",
446-
"sip-notify rtp-nte",
447-
"sip-notify rtp-nte sip-kpml",
448-
"sip-notify sip-kpml",
449-
"sip-notify sip-kpml rtp-nte",
427+
"sip-kpml",
428+
]
429+
430+
431+
def str_as_mp_dmtf_list(val: Union[str, Sequence[MpDtmf]]) -> Sequence[MpDtmf]:
432+
if isinstance(val, str):
433+
return [cast(MpDtmf, dtmf) for dtmf in val.split()]
434+
return val
435+
436+
437+
SpaceSeparatedMpDtmfList = Annotated[
438+
List[MpDtmf],
439+
PlainSerializer(lambda x: " ".join(map(str, x)), return_type=MpDtmf, when_used="json-unless-none"),
440+
BeforeValidator(str_as_mp_dmtf_list),
441+
Field(min_length=1),
450442
]
451443

452444
HuntSchemeMethod = Literal[

catalystwan/models/configuration/feature_profile/sdwan/uc_voice/digital_interface.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ def validate_basic_settings_values(basic_settings: List[BasicSettings], check_fo
316316
f"For {template_type} configuration, missing value for '{key}'. "
317317
f"Expected one of: {check_for[key]}."
318318
)
319+
if attribute.option_type == "variable":
320+
continue
319321
current_value = attribute.value
320322
if current_value not in values:
321323
raise ValueError(

catalystwan/models/configuration/feature_profile/sdwan/uc_voice/media_profile.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
# Copyright 2024 Cisco Systems, Inc. and its affiliates
2-
from typing import List, Literal, Optional, Union
2+
from typing import List, Literal, Union
33

4-
from pydantic import AliasPath, BaseModel, ConfigDict, Field
4+
from pydantic import AliasPath, ConfigDict, Field
55

66
from catalystwan.api.configuration_groups.parcel import Default, Global, Variable, _ParcelBase
77
from catalystwan.models.common import MpDtmf, MpVoiceCodec
88

99

10-
class Codec(BaseModel):
11-
model_config = ConfigDict(populate_by_name=True)
12-
value: Union[Variable, List[MpVoiceCodec]] = Field()
13-
pref_num: Optional[str] = Field(
14-
default=None, validation_alias="prefNum", serialization_alias="prefNum", description="Preference number"
15-
)
16-
17-
1810
class MediaProfileParcel(_ParcelBase):
1911
model_config = ConfigDict(populate_by_name=True)
2012
type_: Literal["media-profile"] = Field(default="media-profile", exclude=True)

catalystwan/models/policy/list/media_profile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
from pydantic import BaseModel, ConfigDict, Field
66
from typing_extensions import Annotated
77

8-
from catalystwan.models.common import IntStr, MpDtmf, MpVoiceCodec
8+
from catalystwan.models.common import IntStr, SpaceSeparatedMpDtmfList
99
from catalystwan.models.policy.policy_list import PolicyListBase, PolicyListId, PolicyListInfo
1010

1111

1212
class CodecEntry(BaseModel):
1313
model_config = ConfigDict(populate_by_name=True)
1414
type: Literal["codec"] = "codec"
1515
pref_num: IntStr = Field(ge=1, serialization_alias="prefNum", validation_alias="prefNum")
16-
value: MpVoiceCodec
16+
value: str
1717

1818

1919
class DtmfEntry(BaseModel):
2020
model_config = ConfigDict(populate_by_name=True)
2121
type: Literal["dtmf"] = "dtmf"
22-
value: MpDtmf
22+
value: SpaceSeparatedMpDtmfList
2323

2424

2525
AnyMediaProfileListEntry = Annotated[

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "catalystwan"
3-
version = "0.40.2dev5"
3+
version = "0.40.2dev6"
44
description = "Cisco Catalyst WAN SDK for Python"
55
authors = ["kagorski <kagorski@cisco.com>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)