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

Commit

Permalink
convert standard community
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Mar 12, 2024
1 parent 8e01525 commit 6a770c1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class StandardCommunityEntry(BaseModel):
model_config = ConfigDict(populate_by_name=True)
standard_community: Global[WellKnownBGPCommunities] = Field(
standard_community: Global[str] = Field(
serialization_alias="standardCommunity", validation_alias="standardCommunity"
)

Expand All @@ -19,7 +19,11 @@ class StandardCommunityParcel(_ParcelBase):
type_: Literal["standard-community"] = Field(default="standard-community", exclude=True)
entries: List[StandardCommunityEntry] = Field(default=[], validation_alias=AliasPath("data", "entries"))

def add_community(self, standard_community: WellKnownBGPCommunities):
self.entries.append(
StandardCommunityEntry(standard_community=as_global(standard_community, WellKnownBGPCommunities))
)
def _add_community(self, standard_community: str):
self.entries.append(StandardCommunityEntry(standard_community=as_global(standard_community)))

def add_well_known_community(self, standard_community: WellKnownBGPCommunities):
self._add_community(standard_community)

def add_community(self, as_number: int, community_number: int) -> None:
self._add_community(f"{as_number}:{community_number}")
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def color(in_: ColorList) -> ColorParcel:

def community(in_: CommunityList) -> StandardCommunityParcel:
out = StandardCommunityParcel(**_get_parcel_name_desc(in_))
for entry in in_.entries:
out._add_community(entry.community)
return out


Expand Down

0 comments on commit 6a770c1

Please sign in to comment.