Skip to content

Commit

Permalink
dev: Add models - translation rule, translation profile (#4)
Browse files Browse the repository at this point in the history
* Add models

* Add models to init

* Change ethernet field serializtion
  • Loading branch information
jpkrajewski authored Nov 21, 2024
1 parent 234cd1b commit c3c514c
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,9 @@ def serialize(self, handler: SerializerFunctionWrapHandler, info: SerializationI
class Trustsec(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

enable_sgt_propagation: Annotated[
Union[Global[bool], Default[bool]],
VersionedField(versions="<=20.13", serialization_alias="enableSGTPropogation"),
] = Field(
enable_sgt_propagation: Union[Global[bool], Default[bool]] = Field(
serialization_alias="enableSGTPropagation",
validation_alias=AliasChoices("enableSGTPropagation", "enableSGTPropogation"),
validation_alias="enableSGTPropogation",
default=Default[bool](value=False),
)
propagate: Annotated[
Expand All @@ -152,13 +149,10 @@ class Trustsec(BaseModel):
security_group_tag: Optional[Union[Global[int], Variable, Default[None]]] = Field(
serialization_alias="securityGroupTag", validation_alias="securityGroupTag", default=None
)
enable_enforced_propagation: Annotated[
Union[Global[bool], Default[None]],
VersionedField(versions="<=20.13", serialization_alias="enableEnforcedPropogation"),
] = Field(
enable_enforced_propagation: Union[Global[bool], Default[None]] = Field(
default=Default[None](value=None),
serialization_alias="enableEnforcedPropagation",
validation_alias=AliasChoices("enableEnforcedPropagation", "enableEnforcedPropogation"),
validation_alias="enableEnforcedPropogation",
)
enforced_security_group_tag: Union[Global[int], Variable, Default[None]] = Field(
default=Default[None](value=None),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@
from typing_extensions import Annotated

from catalystwan.models.configuration.feature_profile.sdwan.uc_voice.media_profile import MediaProfileParcel
from catalystwan.models.configuration.feature_profile.sdwan.uc_voice.translation_profile import TranslationProfileParcel
from catalystwan.models.configuration.feature_profile.sdwan.uc_voice.translation_rule import TranslationRuleParcel
from catalystwan.models.configuration.feature_profile.sdwan.uc_voice.trunk_group import TrunkGroupParcel

from .dsp_farm import DspFarmParcel

AnyUcVoiceParcel = Annotated[
Union[
DspFarmParcel,
MediaProfileParcel,
TrunkGroupParcel,
],
Union[DspFarmParcel, MediaProfileParcel, TrunkGroupParcel, TranslationRuleParcel, TranslationProfileParcel],
Field(discriminator="type_"),
]

__all__ = ("AnyUcVoiceParcel", "DspFarmParcel", "MediaProfileParcel", "TrunkGroupParcel")
__all__ = (
"AnyUcVoiceParcel",
"DspFarmParcel",
"MediaProfileParcel",
"TrunkGroupParcel",
"TranslationProfileParcel",
"TranslationRuleParcel",
)


def __dir__() -> "List[str]":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates
from typing import List, Literal, Optional, Union

from pydantic import AliasPath, BaseModel, ConfigDict, Field

from catalystwan.api.configuration_groups.parcel import Global, Variable, _ParcelBase
from catalystwan.models.configuration.feature_profile.common import RefIdItem

CallType = Literal[
"called",
"calling",
]


class TranslationProfileSettings(BaseModel):
model_config = ConfigDict(populate_by_name=True, extra="forbid")
call_type: Union[Variable, Global[CallType]] = Field(validation_alias="callType", serialization_alias="callType")
translation_rule: Optional[RefIdItem] = Field(
default=None, validation_alias="translationRule", serialization_alias="translationRule"
)


class TranslationProfileParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True, extra="forbid")
type_: Literal["translation-profile"] = Field(default="translation-profile", exclude=True)
translation_profile_settings: List[TranslationProfileSettings] = Field(
validation_alias=AliasPath("data", "translationProfileSettings"),
description="Translation Profile configuration",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates
from typing import List, Literal, Optional

from pydantic import AliasPath, BaseModel, ConfigDict, Field

from catalystwan.api.configuration_groups.parcel import Global, _ParcelBase

Action = Literal[
"reject",
"replace",
]


class RuleSettings(BaseModel):
model_config = ConfigDict(populate_by_name=True, extra="forbid")
action: Optional[Global[Action]] = Field(default=None)
match: Optional[Global[str]] = Field(default=None)
replacement_pattern: Optional[Global[str]] = Field(
default=None, validation_alias="replacementPattern", serialization_alias="replacementPattern"
)
rule_num: Optional[Global[int]] = Field(default=None, validation_alias="ruleNum", serialization_alias="ruleNum")


class TranslationRuleParcel(_ParcelBase):
model_config = ConfigDict(populate_by_name=True, extra="forbid")
type_: Literal["translation-rule"] = Field(default="translation-rule", exclude=True)
rule_settings: List[RuleSettings] = Field(
validation_alias=AliasPath("data", "ruleSettings"),
description="Translation Rule configuration",
)
rule_name: Optional[Global[int]] = Field(default=None, validation_alias="ruleName", serialization_alias="ruleName")

0 comments on commit c3c514c

Please sign in to comment.