-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started working on replacing modification via a generator created some new helper methods with polymorphic views Signed-off-by: Jason <[email protected]>
- Loading branch information
1 parent
3f3ba4d
commit 94186d4
Showing
5 changed files
with
147 additions
and
53 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,58 @@ | ||
from typing import TYPE_CHECKING, Final, Literal, NamedTuple | ||
from dataclasses import dataclass | ||
from typing import TYPE_CHECKING, Dict, Final, List, Literal, NamedTuple, Optional | ||
|
||
from rest_framework.serializers import BaseSerializer | ||
|
||
if TYPE_CHECKING: | ||
from core.api.v3.objects import BaseProvider | ||
|
||
type APIObjOperations = Final[Literal["single", "new", "list", "retrieve"]] | ||
|
||
type PathData = NamedTuple[str, "BaseProvider", dict] | ||
|
||
|
||
@dataclass | ||
class APISerializerOperations: | ||
operation: APIObjOperations | ||
serializer: BaseSerializer | ||
|
||
def __hash__(self): | ||
return hash(self.operation.__class__.__name__) | ||
|
||
# tags? | ||
|
||
|
||
@dataclass | ||
class SingleOperationData: | ||
providers: List["BaseProvider"] | ||
operation: APIObjOperations | ||
data: dict | ||
|
||
|
||
@dataclass | ||
class ProviderDetails: | ||
provider: "BaseProvider" | ||
operations_supported: List[APISerializerOperations] | ||
url: Optional[str] = None | ||
data: Optional[Dict] = None | ||
|
||
def __hash__(self): | ||
return hash(self.provider.__class__.__name__) | ||
|
||
|
||
@dataclass | ||
class ObjectModificationData: | ||
retrieve: Optional[SingleOperationData] = None | ||
single: Optional[SingleOperationData] = None | ||
list: Optional[SingleOperationData] = None | ||
new: Optional[SingleOperationData] = None | ||
|
||
def __iter__(self): | ||
return iter( | ||
[ | ||
("retrieve", self.retrieve), | ||
("single", self.single), | ||
("list", self.list), | ||
("new", self.new), | ||
] | ||
) |
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