-
Notifications
You must be signed in to change notification settings - Fork 6
Support all kind of attributes in protocols #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support all kind of attributes in protocols #90
Conversation
|
Should I drop all the classes I've created to only use the "primitive" ones and map everything to one of those: class String(Attribute):
value: str
class StringOptional(Attribute):
value: Optional[str]
class Integer(Attribute):
value: int
class IntegerOptional(Attribute):
value: Optional[int]
class Boolean(Attribute):
value: bool
class BooleanOptional(Attribute):
value: Optional[bool]
class DateTime(Attribute):
value: str
class DateTimeOptional(Attribute):
value: Optional[str]
class Enum(Attribute):
value: str
class EnumOptional(Attribute):
value: Optional[str]
class URL(Attribute):
value: str
class URLOptional(Attribute):
value: Optional[str]
class Dropdown(Attribute):
value: str
class DropdownOptional(Attribute):
value: Optional[str]
class IPNetwork(Attribute):
value: Union[ipaddress.IPv4Network, ipaddress.IPv6Network]
class IPNetworkOptional(Attribute):
value: Optional[Union[ipaddress.IPv4Network, ipaddress.IPv6Network]]
class IPHost(Attribute):
value: Union[ipaddress.IPv4Address, ipaddress.IPv6Address]
class IPHostOptional(Attribute):
value: Optional[Union[ipaddress.IPv4Address, ipaddress.IPv6Address]]
class HashedPassword(Attribute):
value: str
class HashedPasswordOptional(Attribute):
value: Any
class JSONAttribute(Attribute):
value: Any
class JSONAttributeOptional(Attribute):
value: Optional[Any]
class ListAttribute(Attribute):
value: list[Any]
class ListAttributeOptional(Attribute):
value: Optional[list[Any]] |
|
I'm not sure if there is a strong case to keep the existing one over yours ... either should be fine |
Ok, I tried to consolidate to the new class I've created but it roots to So for the time being I mapped everything to the "primitive" types and I'll create a task to cleanup that later. Here is the final result: class ExampleFullAttributesNode(CoreNode):
mac_address_optional: MacAddressOptional
textarea_required: String
datetime_optional: DateTimeOptional
any_required: AnyAttribute
dropdown_optional: DropdownOptional
json_optional: JSONAttributeOptional
color_required: String
ip_network_required: IPNetwork
text_optional: StringOptional
file_required: String
password_required: String
hashed_password_required: HashedPassword
number_optional: IntegerOptional
dropdown_required: Dropdown
hashed_password_optional: HashedPasswordOptional
url_required: URL
id_required: String
boolean_optional: BooleanOptional
boolean_required: Boolean
password_optional: StringOptional
email_optional: StringOptional
textarea_optional: StringOptional
color_optional: StringOptional
checkbox_required: Boolean
bandwidth_optional: IntegerOptional
ip_host_required: IPHost
bandwidth_required: Integer
any_optional: AnyAttributeOptional
number_required: Integer
checkbox_optional: BooleanOptional
id_optional: StringOptional
ip_network_optional: IPNetworkOptional
list_optional: ListAttributeOptional
file_optional: StringOptional
list_required: ListAttribute
json_required: JSONAttribute
datetime_required: DateTime
email_required: String
mac_address_required: MacAddress
text_required: String
url_optional: URLOptional
ip_host_optional: IPHostOptional
subscriber_of_groups: RelationshipManager
profiles: RelationshipManager
member_of_groups: RelationshipManager |
|
Side note, would be good to have a unit tests to validate that ATTRIBUTE_KIND_MAP includes all the supported kinds from the schema |
Example generated: