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

Commit

Permalink
fix: create policy-object profile
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Sep 16, 2024
1 parent 8b148bd commit 203b41d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions catalystwan/api/feature_profile_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 203b41d

Please sign in to comment.