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

dev: Add update method to service api. Move to literals for variable, global and default #828

Merged
merged 5 commits into from
Sep 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
sbasan marked this conversation as resolved.
Show resolved Hide resolved

def delete_profile(self, profile_id: UUID) -> None:
return self.endpoint.delete_profile(profile_id=profile_id)
Expand Down