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

Commit

Permalink
Change Interest Group to Policy Object
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuba committed Feb 19, 2024
1 parent b8b968d commit 9510cc8
Show file tree
Hide file tree
Showing 29 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[flake8]
per-file-ignores =
catalystwan/models/policy/__init__.py: F401
catalystwan/models/configuration/feature_profile/sdwan/interest_groups/__init__.py: F401
catalystwan/models/configuration/feature_profile/sdwan/policy_object/__init__.py: F401
max-line-length = 120
inline-quotes = double
# https://black.readthedocs.io/en/stable/faq.html#why-are-flake8-s-e203-and-w503-violated
Expand Down
24 changes: 12 additions & 12 deletions catalystwan/api/feature_profile_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
from catalystwan.session import ManagerSession

from catalystwan.api.parcel_api import SDRoutingFullConfigParcelAPI
from catalystwan.endpoints.configuration.feature_profile.sdwan.interest_groups import PolicyObjectFeatureProfile
from catalystwan.endpoints.configuration.feature_profile.sdwan.policy_object import PolicyObjectFeatureProfile
from catalystwan.endpoints.configuration_feature_profile import SDRoutingConfigurationFeatureProfile
from catalystwan.models.configuration.feature_profile.common import (
FeatureProfileCreationPayload,
FeatureProfileCreationResponse,
Parcel,
ParcelCreationResponse,
)
from catalystwan.models.configuration.feature_profile.sdwan.interest_groups import (
INTEREST_GROUP_PAYLOAD_ENDPOINT_MAPPING,
AnyInterestGroupParcel,
from catalystwan.models.configuration.feature_profile.sdwan.policy_object import (
POLICY_OBJECT_PAYLOAD_ENDPOINT_MAPPING,
AnyPolicyObjectParcel,
ApplicationListParcel,
AppProbeParcel,
ColorParcel,
Expand Down Expand Up @@ -337,37 +337,37 @@ def get(self, profile_id: UUID, parcel_type: Type[URLBlockParcel], parcel_id: UU
def get(
self,
profile_id: UUID,
parcel_type: Type[AnyInterestGroupParcel],
parcel_type: Type[AnyPolicyObjectParcel],
parcel_id: Union[UUID, None] = None,
) -> DataSequence[Parcel[Any]]:
"""
Get all Policy Objects for selected profile_id and selected type or get one Policy Object given parcel id
"""

policy_object_list_type = INTEREST_GROUP_PAYLOAD_ENDPOINT_MAPPING[parcel_type]
policy_object_list_type = POLICY_OBJECT_PAYLOAD_ENDPOINT_MAPPING[parcel_type]
if not parcel_id:
return self.endpoint.get_all(profile_id=profile_id, policy_object_list_type=policy_object_list_type)
parcel = self.endpoint.get_by_id(
profile_id=profile_id, policy_object_list_type=policy_object_list_type, list_object_id=parcel_id
)
return DataSequence(Parcel, [parcel])

def create(self, profile_id: UUID, payload: AnyInterestGroupParcel) -> ParcelCreationResponse:
def create(self, profile_id: UUID, payload: AnyPolicyObjectParcel) -> ParcelCreationResponse:
"""
Create Policy Object for selected profile_id based on payload type
"""

policy_object_list_type = INTEREST_GROUP_PAYLOAD_ENDPOINT_MAPPING[type(payload)]
policy_object_list_type = POLICY_OBJECT_PAYLOAD_ENDPOINT_MAPPING[type(payload)]
return self.endpoint.create(
profile_id=profile_id, policy_object_list_type=policy_object_list_type, payload=payload
)

def update(self, profile_id: UUID, payload: AnyInterestGroupParcel, list_object_id: UUID):
def update(self, profile_id: UUID, payload: AnyPolicyObjectParcel, list_object_id: UUID):
"""
Update Policy Object for selected profile_id based on payload type
"""

policy_type = INTEREST_GROUP_PAYLOAD_ENDPOINT_MAPPING[type(payload)]
policy_type = POLICY_OBJECT_PAYLOAD_ENDPOINT_MAPPING[type(payload)]
return self.endpoint.update(
profile_id=profile_id, policy_object_list_type=policy_type, list_object_id=list_object_id, payload=payload
)
Expand Down Expand Up @@ -468,12 +468,12 @@ def delete(self, profile_id: UUID, parcel_type: Type[URLAllowParcel], list_objec
def delete(self, profile_id: UUID, parcel_type: Type[URLBlockParcel], list_object_id: UUID) -> None:
...

def delete(self, profile_id: UUID, parcel_type: Type[AnyInterestGroupParcel], list_object_id: UUID) -> None:
def delete(self, profile_id: UUID, parcel_type: Type[AnyPolicyObjectParcel], list_object_id: UUID) -> None:
"""
Delete Policy Object for selected profile_id based on payload type
"""

policy_object_list_type = INTEREST_GROUP_PAYLOAD_ENDPOINT_MAPPING[parcel_type]
policy_object_list_type = POLICY_OBJECT_PAYLOAD_ENDPOINT_MAPPING[parcel_type]
return self.endpoint.delete(
profile_id=profile_id, policy_object_list_type=policy_object_list_type, list_object_id=list_object_id
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

from catalystwan.endpoints import APIEndpoints, delete, get, post, put, versions
from catalystwan.models.configuration.feature_profile.common import Parcel, ParcelCreationResponse
from catalystwan.models.configuration.feature_profile.sdwan.interest_groups import AnyInterestGroupParcel
from catalystwan.models.configuration.feature_profile.sdwan.policy_object import AnyPolicyObjectParcel
from catalystwan.typed_list import DataSequence


class PolicyObjectFeatureProfile(APIEndpoints):
@versions(supported_versions=(">=20.13"), raises=False)
@post("/v1/feature-profile/sdwan/policy-object/{profile_id}/{policy_object_list_type}")
def create(
self, profile_id: UUID, policy_object_list_type: str, payload: AnyInterestGroupParcel
self, profile_id: UUID, policy_object_list_type: str, payload: AnyPolicyObjectParcel
) -> ParcelCreationResponse:
...

Expand All @@ -37,7 +37,7 @@ def delete(self, profile_id: UUID, policy_object_list_type: str, list_object_id:
@versions(supported_versions=(">=20.13"), raises=False)
@put("/v1/feature-profile/sdwan/policy-object/{profile_id}/{policy_object_list_type}/{list_object_id}")
def update(
self, profile_id: UUID, policy_object_list_type: str, list_object_id: UUID, payload: AnyInterestGroupParcel
self, profile_id: UUID, policy_object_list_type: str, list_object_id: UUID, payload: AnyPolicyObjectParcel
) -> ParcelCreationResponse:
...

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
from .security.zone import SecurityZoneListEntry as SecurityZoneListEntry
from .security.zone import SecurityZoneListParcel as SecurityZoneListParcel

AnyInterestGroupParcel = Annotated[
AnyPolicyObjectParcel = Annotated[
Union[
AppProbeParcel,
ApplicationListParcel,
Expand Down Expand Up @@ -90,7 +90,7 @@
Field(discriminator="type"),
]

INTEREST_GROUP_PAYLOAD_ENDPOINT_MAPPING: Mapping[type, str] = {
POLICY_OBJECT_PAYLOAD_ENDPOINT_MAPPING: Mapping[type, str] = {
AppProbeParcel: "app-probe",
ApplicationListParcel: "app-list",
ColorParcel: "color",
Expand Down
2 changes: 1 addition & 1 deletion examples/parcel_configuration_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from catalystwan.endpoints.configuration_feature_profile import ConfigurationFeatureProfile
from catalystwan.models.common import InterfaceTypeEnum, TLOCColorEnum, WellKnownBGPCommunitiesEnum
from catalystwan.models.configuration.feature_profile.common import ParcelCreationResponse
from catalystwan.models.configuration.feature_profile.sdwan.interest_groups import (
from catalystwan.models.configuration.feature_profile.sdwan.policy_object import (
ApplicationListParcel,
AppProbeParcel,
ColorParcel,
Expand Down

0 comments on commit 9510cc8

Please sign in to comment.