class documentation

class Factory:

View In Hierarchy

Factory for creating resources.

Method getResourceClassForType Get the resource class for a given resource type.
Method initResources Initialize the resource factory.
Method resourceFromDict Create a resource from a dictionary structure.
Instance Variable resourceClassMapping Mapping of resource types to their corresponding resource classes and factory callables. The factory callable is used to create an instance of the resource class from a dictionary.
def getResourceClassForType(self, ty: ResourceTypes) -> type[Resource] | None:

Get the resource class for a given resource type.

Parameters
ty:ResourceTypesThe resource type.
Returns
type[Resource] | NoneThe resource class for the given resource type, or None if not found.
def initResources(self) -> bool:

Initialize the resource factory.

def resourceFromDict(self, resDict: JSON | None = {}, pi: str | None = None, ty: ResourceTypes | None = None, create: bool | None = False, template: bool | None = False, trusted: bool = True) -> Resource:

Create a resource from a dictionary structure.

This function will not call the resource's activate() method, therefore some attributes may need to be set separately.

Parameters
resDict:JSON | NoneDictionary with the resource definition.
pi:str | NoneThe parent's resource ID.
ty:ResourceTypes | NoneThe resource type of the resource that shall be created.
create:bool | NoneThe resource will be newly created.
template:bool | NoneTrue when the resource is used as a template. In this case some checks may not be performed.
trusted:boolTrue when the resource is created from a trusted source, such as an internal process, or was already validated.
Returns
ResourceResult object with the resource attribute set to the created resource object.
resourceClassMapping: dict[ResourceTypes, tuple[type[Resource], Callable]] =

Mapping of resource types to their corresponding resource classes and factory callables. The factory callable is used to create an instance of the resource class from a dictionary.