This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce trunkgroup policy list (#28)
* introduce trunkgroup policy list * Update trunkgroup.py --------- Co-authored-by: radkrawczyk <[email protected]>
- Loading branch information
1 parent
2c49ba8
commit 89aaf1c
Showing
5 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
catalystwan/endpoints/configuration/policy/list/trunkgroup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.trunkgroup import TrunkGroupList, TrunkGroupListEditPayload, TrunkGroupListInfo | ||
from catalystwan.models.policy.policy_list import InfoTag, PolicyListId, PolicyListPreview | ||
from catalystwan.typed_list import DataSequence | ||
|
||
|
||
class ConfigurationPolicyTrunkGroupList(APIEndpoints, PolicyListEndpoints): | ||
@post("/template/policy/list/trunkgroup") | ||
def create_policy_list(self, payload: TrunkGroupList) -> PolicyListId: | ||
... | ||
|
||
@delete("/template/policy/list/trunkgroup/{id}") | ||
def delete_policy_list(self, id: UUID) -> None: | ||
... | ||
|
||
@delete("/template/policy/list/trunkgroup") | ||
def delete_policy_lists_with_info_tag(self, params: InfoTag) -> None: | ||
... | ||
|
||
@put("/template/policy/list/trunkgroup/{id}") | ||
def edit_policy_list(self, id: UUID, payload: TrunkGroupListEditPayload) -> None: | ||
... | ||
|
||
@get("/template/policy/list/trunkgroup/{id}") | ||
def get_lists_by_id(self, id: UUID) -> TrunkGroupListInfo: | ||
... | ||
|
||
@get("/template/policy/list/trunkgroup", "data") | ||
def get_policy_lists(self) -> DataSequence[TrunkGroupListInfo]: | ||
... | ||
|
||
@get("/template/policy/list/trunkgroup/filtered", "data") | ||
def get_policy_lists_with_info_tag(self, params: InfoTag) -> DataSequence[TrunkGroupListInfo]: | ||
... | ||
|
||
@post("/template/policy/list/trunkgroup/preview") | ||
def preview_policy_list(self, payload: TrunkGroupList) -> PolicyListPreview: | ||
... | ||
|
||
@get("/template/policy/list/trunkgroup/preview/{id}") | ||
def preview_policy_list_by_id(self, id: UUID) -> PolicyListPreview: | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright 2022 Cisco Systems, Inc. and its affiliates | ||
|
||
from typing import List, Literal, Optional | ||
|
||
from pydantic import BaseModel, ConfigDict, Field | ||
|
||
from catalystwan.models.policy.policy_list import PolicyListBase, PolicyListId, PolicyListInfo | ||
|
||
HuntSchemeMethods = Literal["least-idle", "least-used", "longest-idle", "round-robin", "sequential", "random"] | ||
HuntSchemeMethodPrecedences = Literal["even", "odd", "both"] | ||
|
||
|
||
class TrunkGroupListEntry(BaseModel): | ||
model_config = ConfigDict(populate_by_name=True) | ||
hunt_scheme_method: HuntSchemeMethods = Field( | ||
validation_alias="huntSchemeMethod", serialization_alias="huntSchemeMethod" | ||
) | ||
hunt_scheme_precedence: Optional[HuntSchemeMethodPrecedences] = Field( | ||
default=None, validation_alias="huntSchemePrecedence", serialization_alias="huntSchemePrecedence" | ||
) | ||
max_calls_in: Optional[int] = Field( | ||
default=None, validation_alias="maxCallsIn", serialization_alias="maxCallsIn", ge=0, le=1000 | ||
) | ||
max_calls_out: Optional[int] = Field( | ||
default=None, validation_alias="maxCallsOut", serialization_alias="maxCallsOut", ge=0, le=1000 | ||
) | ||
max_retries: int = Field(validation_alias="maxRetries", serialization_alias="maxRetries", ge=1, le=5) | ||
|
||
|
||
class TrunkGroupList(PolicyListBase): | ||
type: Literal["trunkGroup"] = "trunkGroup" | ||
entries: List[TrunkGroupListEntry] = [] | ||
|
||
def add_entry( | ||
self, | ||
hunt_scheme_method: HuntSchemeMethods, | ||
hunt_scheme_precedence: Optional[HuntSchemeMethodPrecedences], | ||
max_retries: int, | ||
max_calls_in: Optional[int] = None, | ||
max_calls_out: Optional[int] = None, | ||
) -> None: | ||
entry = TrunkGroupListEntry( | ||
hunt_scheme_method=hunt_scheme_method, | ||
hunt_scheme_precedence=hunt_scheme_precedence, | ||
max_retries=max_retries, | ||
max_calls_in=max_calls_in, | ||
max_calls_out=max_calls_out, | ||
) | ||
self.entries.append(entry) | ||
|
||
|
||
class TrunkGroupListEditPayload(TrunkGroupList, PolicyListId): | ||
pass | ||
|
||
|
||
class TrunkGroupListInfo(TrunkGroupList, PolicyListInfo): | ||
pass |