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

Commit

Permalink
dev-uxmt: System Feature Profile API type hinting (#44)
Browse files Browse the repository at this point in the history
* Changes to feature profile system api. Add generic typing to endpoints. Move parcel classes to separate file

* fix: pre commit issues

* fullConfigCli field is optional

* fix imports after rebase

* fix tests after rebase

* remove print statements

---------

Co-authored-by: sbasan <[email protected]>
  • Loading branch information
jpkrajewski and sbasan authored Apr 25, 2024
1 parent 74fdf22 commit 47c96e9
Show file tree
Hide file tree
Showing 13 changed files with 379 additions and 200 deletions.
109 changes: 58 additions & 51 deletions catalystwan/api/feature_profile_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
FeatureProfileCreationResponse,
FeatureProfileInfo,
GetFeatureProfilesPayload,
)
from catalystwan.models.configuration.feature_profile.parcel import (
Parcel,
ParcelAssociationPayload,
ParcelCreationResponse,
Expand Down Expand Up @@ -357,56 +359,56 @@ def get_parcels(
def get_parcels(
self,
profile_id: UUID,
parcel_type: Type[BFDParcel],
) -> DataSequence[Parcel[BFDParcel]]:
parcel_type: Type[BannerParcel],
) -> DataSequence[Parcel[BannerParcel]]:
...

@overload
def get_parcels(
self,
profile_id: UUID,
parcel_type: Type[LoggingParcel],
) -> DataSequence[Parcel[LoggingParcel]]:
parcel_type: Type[BasicParcel],
) -> DataSequence[Parcel[BasicParcel]]:
...

@overload
def get_parcels(
self,
profile_id: UUID,
parcel_type: Type[BannerParcel],
) -> DataSequence[Parcel[BannerParcel]]:
parcel_type: Type[BFDParcel],
) -> DataSequence[Parcel[BFDParcel]]:
...

@overload
def get_parcels(
self,
profile_id: UUID,
parcel_type: Type[BasicParcel],
) -> DataSequence[Parcel[BasicParcel]]:
parcel_type: Type[GlobalParcel],
) -> DataSequence[Parcel[GlobalParcel]]:
...

@overload
def get_parcels(
self,
profile_id: UUID,
parcel_type: Type[GlobalParcel],
) -> DataSequence[Parcel[GlobalParcel]]:
parcel_type: Type[LoggingParcel],
) -> DataSequence[Parcel[LoggingParcel]]:
...

@overload
def get_parcels(
self,
profile_id: UUID,
parcel_type: Type[NTPParcel],
) -> DataSequence[Parcel[NTPParcel]]:
parcel_type: Type[MRFParcel],
) -> DataSequence[Parcel[MRFParcel]]:
...

@overload
def get_parcels(
self,
profile_id: UUID,
parcel_type: Type[MRFParcel],
) -> DataSequence[Parcel[MRFParcel]]:
parcel_type: Type[NTPParcel],
) -> DataSequence[Parcel[NTPParcel]]:
...

@overload
Expand All @@ -433,119 +435,124 @@ def get_parcels(
) -> DataSequence[Parcel[SNMPParcel]]:
...

# get by id
def get_parcels(
self,
profile_id: UUID,
parcel_type: Type[AnySystemParcel],
) -> DataSequence:
"""
Get all System Parcels given profile id and parcel type
"""
return self.endpoint.get_all(profile_id, parcel_type._get_parcel_type())

@overload
def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[AAAParcel],
parcel_id: UUID,
) -> DataSequence[Parcel[AAAParcel]]:
) -> Parcel[AAAParcel]:
...

@overload
def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[BFDParcel],
parcel_type: Type[BannerParcel],
parcel_id: UUID,
) -> DataSequence[Parcel[BFDParcel]]:
) -> Parcel[BannerParcel]:
...

@overload
def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[LoggingParcel],
parcel_type: Type[BasicParcel],
parcel_id: UUID,
) -> DataSequence[Parcel[LoggingParcel]]:
) -> Parcel[BasicParcel]:
...

@overload
def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[BannerParcel],
parcel_type: Type[BFDParcel],
parcel_id: UUID,
) -> DataSequence[Parcel[BannerParcel]]:
) -> Parcel[BFDParcel]:
...

@overload
def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[BasicParcel],
parcel_type: Type[GlobalParcel],
parcel_id: UUID,
) -> DataSequence[Parcel[BasicParcel]]:
) -> Parcel[GlobalParcel]:
...

@overload
def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[GlobalParcel],
parcel_type: Type[LoggingParcel],
parcel_id: UUID,
) -> DataSequence[Parcel[GlobalParcel]]:
) -> Parcel[LoggingParcel]:
...

@overload
def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[NTPParcel],
parcel_type: Type[MRFParcel],
parcel_id: UUID,
) -> DataSequence[Parcel[NTPParcel]]:
) -> Parcel[MRFParcel]:
...

@overload
def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[MRFParcel],
parcel_type: Type[NTPParcel],
parcel_id: UUID,
) -> DataSequence[Parcel[MRFParcel]]:
) -> Parcel[NTPParcel]:
...

@overload
def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[OMPParcel],
parcel_id: UUID,
) -> DataSequence[Parcel[OMPParcel]]:
) -> Parcel[OMPParcel]:
...

@overload
def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[SecurityParcel],
parcel_id: UUID,
) -> DataSequence[Parcel[SecurityParcel]]:
) -> Parcel[SecurityParcel]:
...

@overload
def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[SNMPParcel],
parcel_id: UUID,
) -> DataSequence[Parcel[SNMPParcel]]:
) -> Parcel[SNMPParcel]:
...

def get_parcels(
def get_parcel(
self,
profile_id: UUID,
parcel_type: Type[AnySystemParcel],
parcel_id: Union[UUID, None] = None,
) -> DataSequence[Parcel[Any]]:
parcel_id: UUID,
) -> Parcel:
"""
Get all System Parcels for selected profile_id and selected type or get one System Parcel given parcel id
Get one System Parcel given profile id, parcel type and parcel id
"""

if not parcel_id:
return self.endpoint.get_all(profile_id, parcel_type._get_parcel_type())
return self.endpoint.get_by_id(profile_id, parcel_type._get_parcel_type(), parcel_id)

def create_parcel(self, profile_id: UUID, payload: AnySystemParcel) -> ParcelCreationResponse:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
FeatureProfileCreationResponse,
FeatureProfileInfo,
GetFeatureProfilesPayload,
Parcel,
ParcelId,
)
from catalystwan.models.configuration.feature_profile.parcel import Parcel, ParcelId
from catalystwan.typed_list import DataSequence


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from uuid import UUID

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.parcel import Parcel, ParcelCreationResponse
from catalystwan.models.configuration.feature_profile.sdwan.policy_object import AnyPolicyObjectParcel
from catalystwan.typed_list import DataSequence

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
FeatureProfileCreationResponse,
FeatureProfileInfo,
GetFeatureProfilesPayload,
ParcelAssociationPayload,
ParcelCreationResponse,
)
from catalystwan.models.configuration.feature_profile.parcel import ParcelAssociationPayload, ParcelCreationResponse
from catalystwan.models.configuration.feature_profile.sdwan.service import (
AnyLanVpnInterfaceParcel,
AnyTopLevelServiceParcel,
Expand Down
Loading

0 comments on commit 47c96e9

Please sign in to comment.