This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add/parcel/aaa
- Loading branch information
Showing
85 changed files
with
3,554 additions
and
1,414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from typing import Optional, Protocol, Type, TypeVar | ||
|
||
from packaging.version import Version # type: ignore | ||
|
||
from catalystwan.typed_list import DataSequence | ||
from catalystwan.utils.session_type import SessionType | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
class APIEndpointClientResponse(Protocol): | ||
""" | ||
Interface to response object. Fits "requests.Response" | ||
but set of methods is minimal to allow easy migration to another client if needed | ||
""" | ||
|
||
@property | ||
def text(self) -> str: | ||
... | ||
|
||
@property | ||
def content(self) -> bytes: | ||
... | ||
|
||
def dataobj(self, cls: Type[T], sourcekey: Optional[str]) -> T: | ||
... | ||
|
||
def dataseq(self, cls: Type[T], sourcekey: Optional[str]) -> DataSequence[T]: | ||
... | ||
|
||
def json(self) -> dict: | ||
... | ||
|
||
|
||
class APIEndpointClient(Protocol): | ||
""" | ||
Interface to client object. | ||
We only need a 'request' function and few vmanage session properties obtained from server. | ||
Matched to fit "requests.Session" but migration to other client is possible. | ||
At his point not very clean as injection of custom kwargs is possible (and sometimes used) | ||
""" | ||
|
||
def request(self, method: str, url: str, **kwargs) -> APIEndpointClientResponse: | ||
... | ||
|
||
@property | ||
def api_version(self) -> Optional[Version]: | ||
... | ||
|
||
@property | ||
def session_type(self) -> Optional[SessionType]: | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.