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

Commit

Permalink
Prepare the rest service parcels for converter
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkrajewski committed Mar 27, 2024
1 parent 0a3f50d commit 8322442
Show file tree
Hide file tree
Showing 14 changed files with 320 additions and 396 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from typing import List, Literal, Optional, Union
from uuid import UUID

from pydantic import BaseModel, ConfigDict, Field
from pydantic import AliasPath, BaseModel, ConfigDict, Field

from catalystwan.api.configuration_groups.parcel import Default, Global, Variable
from catalystwan.api.configuration_groups.parcel import Default, Global, Variable, _ParcelBase
from catalystwan.models.common import ServiceChainNumber

Action = Literal[
Expand Down Expand Up @@ -116,77 +116,77 @@


class SourceDataIPv4Prefix(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

source_ip_prefix: Union[Global[str], Variable] = Field(
serialization_alias="sourceIpPrefix", validation_alias="sourceIpPrefix"
)


class SourceDataIPv6Prefix(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

source_ip_prefix: Union[Global[str], Variable] = Field(
serialization_alias="sourceIpPrefix", validation_alias="sourceIpPrefix"
)


class SourceDataIPv4PrefixParcel(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

source_data_prefix_list: Global[UUID] = Field(
serialization_alias="sourceDataPrefixList", validation_alias="sourceDataPrefixList"
)


class SourceDataIPv6PrefixParcel(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

source_data_prefix_list: Global[UUID] = Field(
serialization_alias="sourceDataPrefixList", validation_alias="sourceDataPrefixList"
)


class SourcePort(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

source_port: Global[int] = Field(serialization_alias="sourcePort", validation_alias="sourcePort")


class DestinationDataIPv4Prefix(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

destination_ip_prefix: Union[Global[str], Variable] = Field(
serialization_alias="destinationIpPrefix", validation_alias="destinationIpPrefix"
)


class DestinationDataIPv6Prefix(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

destination_ip_prefix: Union[Global[str], Variable] = Field(
serialization_alias="destinationIpPrefix", validation_alias="destinationIpPrefix"
)


class DestinationDataIPv4PrefixParcel(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

destination_data_prefix_list: Global[UUID] = Field(
serialization_alias="destinationDataPrefixList", validation_alias="destinationDataPrefixList"
)


class DestinationDataIPv6PrefixParcel(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

destination_data_prefix_list: Global[UUID] = Field(
serialization_alias="destinationDataPrefixList", validation_alias="destinationDataPrefixList"
)


class DestinationPort(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

destination_port: Global[int] = Field(serialization_alias="destinationPort", validation_alias="destinationPort")

Expand All @@ -195,7 +195,7 @@ class DestinationPort(BaseModel):


class IPv4Match(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

dscp: Optional[Global[List[int]]] = None
packet_length: Optional[Global[int]] = Field(
Expand All @@ -221,7 +221,7 @@ class IPv4Match(BaseModel):


class IPv6Match(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

next_header: Optional[Global[int]] = Field(
serialization_alias="nextHeader", validation_alias="nextHeader", default=None
Expand Down Expand Up @@ -249,7 +249,7 @@ class IPv6Match(BaseModel):


class ServiceChain(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

service_chain_number: Union[Global[ServiceChainNumber], Variable] = Field(
serialization_alias="serviceChainNumber", validation_alias="serviceChainNumber"
Expand All @@ -259,7 +259,7 @@ class ServiceChain(BaseModel):


class AcceptActionIPv4(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

set_dscp: Optional[Global[int]] = Field(serialization_alias="setDscp", validation_alias="setDscp", default=None)
counter_name: Optional[Global[str]] = Field(
Expand All @@ -277,7 +277,7 @@ class AcceptActionIPv4(BaseModel):


class AcceptActionIPv6(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

counter_name: Optional[Global[str]] = Field(
serialization_alias="counterName", validation_alias="counterName", default=None
Expand All @@ -297,7 +297,7 @@ class AcceptActionIPv6(BaseModel):


class DropAction(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

counter_name: Optional[Global[str]] = Field(
serialization_alias="counterName", validation_alias="counterName", default=None
Expand All @@ -306,25 +306,25 @@ class DropAction(BaseModel):


class AcceptActionsIPv4(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

accept: AcceptActionIPv4


class AcceptActionsIPv6(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

accept: AcceptActionIPv6


class DropActions(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

drop: DropAction


class IPv4SequenceBaseAction(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

sequence_id: Global[int] = Field(serialization_alias="sequenceId", validation_alias="sequenceId")
sequence_name: Global[str] = Field(serialization_alias="sequenceName", validation_alias="sequenceName")
Expand All @@ -337,7 +337,7 @@ class IPv4SequenceBaseAction(BaseModel):


class IPv6SequenceBaseAction(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

sequence_id: Global[int] = Field(serialization_alias="sequenceId", validation_alias="sequenceId")
sequence_name: Global[str] = Field(serialization_alias="sequenceName", validation_alias="sequenceName")
Expand All @@ -350,7 +350,7 @@ class IPv6SequenceBaseAction(BaseModel):


class IPv4SequenceActions(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

sequence_id: Global[int] = Field(serialization_alias="sequenceId", validation_alias="sequenceId")
sequence_name: Global[str] = Field(serialization_alias="sequenceName", validation_alias="sequenceName")
Expand All @@ -363,7 +363,7 @@ class IPv4SequenceActions(BaseModel):


class IPv6SequenceActions(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

sequence_id: Global[int] = Field(serialization_alias="sequenceId", validation_alias="sequenceId")
sequence_name: Global[str] = Field(serialization_alias="sequenceName", validation_alias="sequenceName")
Expand All @@ -375,35 +375,23 @@ class IPv6SequenceActions(BaseModel):
)


class IPv4AclData(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
class IPv4AclParcel(_ParcelBase):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

defautl_action: Union[Global[Action], Default[Action]] = Field(
serialization_alias="defaultAction", validation_alias="defaultAction", default=Default[Action](value="drop")
validation_alias=AliasPath("data", "defaultAction"), default=Default[Action](value="drop")
)
sequences: List[Union[IPv4SequenceBaseAction, IPv4SequenceActions]] = Field(
validation_alias=AliasPath("data", "sequences")
)
sequences: List[Union[IPv4SequenceBaseAction, IPv4SequenceActions]]


class IPv4AclCreationPayload(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)

name: str
description: Optional[str] = None
data: IPv4AclData


class IPv6AclData(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
class IPv6AclParcel(_ParcelBase):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

defautl_action: Union[Global[Action], Default[Action]] = Field(
serialization_alias="defaultAction", validation_alias="defaultAction", default=Default[Action](value="drop")
validation_alias=AliasPath("data", "defaultAction"), default=Default[Action](value="drop")
)
sequences: List[Union[IPv6SequenceBaseAction, IPv6SequenceActions]] = Field(
validation_alias=AliasPath("data", "sequences")
)
sequences: List[Union[IPv6SequenceBaseAction, IPv6SequenceActions]]


class IPv6AclCreationPayload(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)

name: str
description: Optional[str] = None
data: IPv6AclData
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@


class VirtualApplication(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

instance_id: Global[int] = Field(
default=Global(value=1), serialization_alias="instanceId", validation_alias="instanceId"
Expand All @@ -88,7 +88,7 @@ class VirtualApplication(BaseModel):


class Appqoe(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

name: Default[str] = Default(value="/1")
appnav_controller_group: Global[AppnavControllerGroupName] = Field(
Expand Down Expand Up @@ -123,7 +123,7 @@ class ServiceNodeInformation(BaseModel):


class ForwarderController(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

address: Union[Global[str], Global[IPv4Address], Variable]
vpn: Global[int] = Field(
Expand All @@ -132,7 +132,7 @@ class ForwarderController(BaseModel):


class ForwarderAppnavControllerGroup(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

group_name: Default[AppnavControllerGroupName] = Field(
default=Default(value="ACG-APPQOE"), serialization_alias="groupName", validation_alias="groupName"
Expand All @@ -143,7 +143,7 @@ class ForwarderAppnavControllerGroup(BaseModel):


class ForwarderNodeGroup(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

name: Union[Global[str], Default[ServiceNodeGroupName]]
internal: Default[bool] = Default[bool](value=False)
Expand All @@ -153,7 +153,7 @@ class ForwarderNodeGroup(BaseModel):


class ForwarderRole(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

appnav_controller_group: List[ForwarderAppnavControllerGroup] = Field(
serialization_alias="appnavControllerGroup", validation_alias="appnavControllerGroup"
Expand All @@ -180,7 +180,7 @@ class ForwarderAndServiceNodeController(BaseModel):


class ForwarderAndServiceNodeAppnavControllerGroup(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

group_name: Default[AppnavControllerGroupName] = Field(
default=Default[AppnavControllerGroupName](value="ACG-APPQOE"),
Expand All @@ -193,7 +193,7 @@ class ForwarderAndServiceNodeAppnavControllerGroup(BaseModel):


class ForwarderAndServiceNodeGroup(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

name: Default[ServiceNodeGroupName] = Default[ServiceNodeGroupName](value="SNG-APPQOE")
internal: Default[bool] = Default[bool](value=True)
Expand All @@ -203,7 +203,7 @@ class ForwarderAndServiceNodeGroup(BaseModel):


class ForwarderAndServiceNodeRole(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

appnav_controller_group: List[ForwarderAndServiceNodeAppnavControllerGroup] = Field(
serialization_alias="appnavControllerGroup", validation_alias="appnavControllerGroup"
Expand All @@ -219,7 +219,7 @@ class ForwarderAndServiceNodeRole(BaseModel):


class ServiceNodeInformationExternal(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

address: Default[ServiceNodeExternalAddress] = Default[ServiceNodeExternalAddress](value="192.168.2.2")
vpg_ip: Default[ServiceNodeExternalVpgIp] = Field(
Expand All @@ -230,7 +230,7 @@ class ServiceNodeInformationExternal(BaseModel):


class ServiceNodeGroup(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

name: Default[ServiceNodeGroupName] = Default[ServiceNodeGroupName](value="SNG-APPQOE")
external_node: Default[bool] = Field(
Expand All @@ -242,7 +242,7 @@ class ServiceNodeGroup(BaseModel):


class ServiceNodeRole(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

service_node_group: List[ServiceNodeGroup] = Field(
default=[ServiceNodeGroup()], serialization_alias="serviceNodeGroup", validation_alias="serviceNodeGroup"
Expand All @@ -251,7 +251,7 @@ class ServiceNodeRole(BaseModel):

class AppqoeParcel(_ParcelBase):
type_: Literal["appqoe"] = Field(default="appqoe", exclude=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True, extra="forbid")

dreopt: Optional[Union[Global[bool], Default[bool]]] = Field(
default=as_default(False), validation_alias=AliasPath("data", "dreopt")
Expand Down
Loading

0 comments on commit 8322442

Please sign in to comment.