From 203b41dce10f0b18f9b2ce3cb7380dda75b7801a Mon Sep 17 00:00:00 2001 From: Szymon Basan Date: Tue, 17 Sep 2024 01:50:18 +0200 Subject: [PATCH] fix: create policy-object profile --- catalystwan/api/feature_profile_api.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/catalystwan/api/feature_profile_api.py b/catalystwan/api/feature_profile_api.py index 68ef29ff..0e313282 100644 --- a/catalystwan/api/feature_profile_api.py +++ b/catalystwan/api/feature_profile_api.py @@ -141,6 +141,12 @@ ) +def removeprefix(s: str, prefix: str) -> str: + if s.startswith(prefix): + return s[len(prefix) :] + return s + + class SDRoutingFeatureProfilesAPI: def __init__(self, session: ManagerSession): self.cli = SDRoutingCLIFeatureProfileAPI(session=session) @@ -342,7 +348,9 @@ def update_parcel( """ if vpn_uuid is not None: vpn_parcel = self._get_vpn_parcel(profile_id, vpn_uuid).payload - parcel_type = payload._get_parcel_type().removeprefix("wan/vpn/").removeprefix("management/vpn/") + parcel_type = payload._get_parcel_type() + parcel_type = removeprefix(parcel_type, "wan/vpn/") + parcel_type = removeprefix(parcel_type, "management/vpn/") if vpn_parcel._get_parcel_type() == TransportVpnParcel._get_parcel_type(): return self.endpoint.update_transport_vpn_sub_parcel( profile_id, vpn_uuid, parcel_type, parcel_id, payload @@ -700,7 +708,7 @@ def get_parcel( """ if vpn_uuid is not None: return self.endpoint.get_lan_vpn_sub_parcel( - profile_id, vpn_uuid, parcel_type._get_parcel_type().removeprefix("lan/vpn/"), parcel_id + profile_id, vpn_uuid, removeprefix(parcel_type._get_parcel_type(), "lan/vpn/"), parcel_id ) return self.endpoint.get_by_id(profile_id, parcel_type._get_parcel_type(), parcel_id) @@ -717,7 +725,7 @@ def update_parcel( """ if vpn_uuid is not None: return self.endpoint.update_lan_vpn_sub_parcel( - profile_id, vpn_uuid, parcel_type._get_parcel_type().removeprefix("lan/vpn/"), parcel_id, payload + profile_id, vpn_uuid, removeprefix(parcel_type._get_parcel_type(), "lan/vpn/"), parcel_id, payload ) return self.endpoint.update(profile_id, parcel_type._get_parcel_type(), parcel_id, payload) @@ -1114,7 +1122,7 @@ def get_profiles(self) -> DataSequence[FeatureProfileInfo]: return self.endpoint.get_profiles() def create_profile(self, profile: FeatureProfileCreationPayload) -> FeatureProfileCreationResponse: - return self.endpoint.create_profile() + return self.endpoint.create_profile(profile) def delete_profile(self, profile_id: UUID) -> None: return self.endpoint.delete_profile(profile_id=profile_id)