Builders

Building from .json files
CRUDableEntityBuilder
- class crudcreator.builder.CRUDableEntityBuilder.CRUDableEntityBuilder(
- crudable_source: AbstractCRUDableEntityType | None,
Enables you to build an entity type.
- Parameters:
crudable_source (AbstractCRUDableEntityType | None) –
- async from_file(
- file_path: str,
- subs_index: dict[str, Any],
- addon_source: dict[str, Type[AbstractCRUDableEntityTypeSource]],
- addon_proxy: dict[str, Type[AbstractCRUDableEntityTypeProxy]],
Builds an entity type from a .json file that lists the source and proxies.
- Parameters:
file_path (str) – The path to the .json file
subs_index (dict[str, Any]) – An index that indicates the corresponding Python object for variables in descriptors.
addon_source (dict[str, Type[AbstractCRUDableEntityTypeSource]]) – An index of the library user’s custom source modules.
addon_proxy (dict[str, Type[AbstractCRUDableEntityTypeProxy]]) – An index of the library user’s custom proxy modules.
- get_built_entity() AbstractCRUDableEntityType
Returns the constructed entity.
- Return type:
SetBuilder
- class crudcreator.builder.SetBuilder.SetBuilder
Allows multiple entity types to be constructed. Useful when entities refer to each other.
- async build(
- list_entity_descriptor: list[EntityDescriptor],
- subs_index: dict[str, Any],
- addon_source: dict[str, AbstractCRUDableEntityTypeSource],
- addon_proxy: dict[str, AbstractCRUDableEntityTypeProxy],
Builds multiple entity types from a list of .json files. Stores in an index references as it encounters them, which it merges with subs_index.
- Parameters:
list_entity_descriptor (list[EntityDescriptor]) – The list of json files.
subs_index (dict[str, Any]) – An index that indicates the corresponding Python object for variables in descriptors.
addon_source (dict[str, AbstractCRUDableEntityTypeSource]) – An index of the library user’s custom source modules.
addon_proxy (dict[str, AbstractCRUDableEntityTypeProxy]) – An index of the library user’s custom proxy modules.
- Return type:
Descriptors
- pydantic model crudcreator.AbstractDescriptor.AbstractDescriptor
Describes a module, without having built it. Is an intermediate class used by CRUD constructors to build entity types. Library users should never have to use this class directly.
- field addons: dict[str, Type[AbstractCRUDableEntityType]] [Required]
Index of personal modules implemented by the crudcreator user.
- field name: str [Required]
Name of the module to be built.
- field params: dict [Required]
Parameters of the module to be built.
- field subs_index: dict[str, Any] [Required]
Index of Python objects associated with variables in the descriptor.
- build() AbstractCRUDableEntityType
To be overloaded. Builds the entity type associated with this descriptor.
- Return type:
- get_class() T
Returns the class associated with the descriptor. Fetches the class from the index of modules pre-implemented by crudcreator. Otherwise, search in addons.
- Return type:
T
- get_index() dict[str, Any]
To be overloaded. Must return the index of modules pre-implemented by the library.
- Return type:
dict[str, Any]
- get_params() U
Builds the parameters associated with the descriptor, after substituting variables with their Python object.
- Return type:
U
- get_params_class() Type[BaseModel]
Returns the pydantic model of the module parameters associated with the descriptor.
- Return type:
Type[BaseModel]
- pydantic model crudcreator.source.SourceDescriptor.SourceDescriptor
- field addons: dict[str, Type[AbstractCRUDableEntityTypeSource]] [Required]
Index of personal modules implemented by the crudcreator user.
- field interface: dict [Required]
- build() AbstractCRUDableEntityTypeSource
To be overloaded. Builds the entity type associated with this descriptor.
- Return type:
- get_index() AbstractCRUDableEntityTypeSource
To be overloaded. Must return the index of modules pre-implemented by the library.
- Return type:
- pydantic model crudcreator.proxy.ProxyDescriptor.ProxyDescriptor
- field addons: dict[str, Type[AbstractCRUDableEntityTypeProxy]] [Required]
Index of personal modules implemented by the crudcreator user.
- field base: AbstractCRUDableEntityType | None = None
The module for which this descriptor will be the proxy.
- build() AbstractCRUDableEntityTypeProxy
Builds the proxy associated with the descriptor.
- Return type:
- get_index() AbstractCRUDableEntityTypeProxy
To be overloaded. Must return the index of modules pre-implemented by the library.
- Return type: