loadero_python.resources.resource module

Describes generics and utility functions of Loadero resources.

class loadero_python.resources.resource.DuplicateResourceBodyParams(name: str | None = None)[source]

Bases: LoaderoResourceParams

Duplicate resource body params.

class loadero_python.resources.resource.FilterKey(value)[source]

Bases: Enum

FilterKey is a base class that all resource filter keys inherit form.

class loadero_python.resources.resource.LoaderoResource(params: LoaderoResourceParams)[source]

Bases: object

Base class for Loadero resources.

All Loadero resources have

params attribute that contains the resources data.

__str__ method.

class loadero_python.resources.resource.LoaderoResourceParams(**kwargs)[source]

Bases: ParamsSerializer

Base class for Loadero resource params.

class loadero_python.resources.resource.ParamsSerializer(attribute_map: dict[str, str] = {}, custom_deserializers: dict[str, Any] = {}, body_attributes: list[str] = [], required_body_attributes: list[str] = [])[source]

Bases: Serializable

ParamsSerializer implements Serializable for Loadero resource params.

from_dict(json_dict: Dict[str, Any]) ParamsSerializer[source]

Sets the attributes of the resource params object from a JSON representation.

Args:

json_dict (dict[str, any]): JSON parsed as dictionary representation of the resource.

Returns:

ParamsSerializer: The resource params object.

to_dict() Dict[str, Any][source]

Converts the resource params object to a dictionary JSON representation that contains only the body attributes.

Raises:

ValueError: If one or more required attributes is missing.

Returns:

dict[str, any]: The resource params object as a dictionary.

to_dict_full() Dict[str, Any][source]

Returns a dictionary representation of the object that contains all of the objects attributes.

Returns:

dict[str, any]: dictionary representation of the object.

class loadero_python.resources.resource.QueryParams[source]

Bases: object

QueryParams allows setting pagination settings an filters for requests.

filter(key: FilterKey, *values: Any) QueryParams[source]

Set filter for read all operation.

Args:

key (ResourceFilters): Filter key.

value (any): Filter value. Variadic argument.

Returns:

QueryParams: QueryParams with filter set.

limit(limit: int) QueryParams[source]

Set maximum number of resources to return in a single read all operation.

Args:

limit (int): Maximum number of resources to return.

Returns:

QueryParams: QueryParams with limit set.

offset(offset: int) QueryParams[source]

Set the number of resources the read all response should be offset by.

Args:

offset (int): Offset of resources.

Returns:

QueryParams: QueryParams with offset set.

parse() List[Tuple[str, Any]][source]
Parses QueryParams into a list of tuples representation that will be

used for sending the request.

Returns:

list[tuple[str, any]]: List of tuples representation of QueryParams.

class loadero_python.resources.resource.Serializable[source]

Bases: object

Base class for serializable objects. Serializable objects can be converted to and from JSON using Python dictionary as a JSON representation.

from_dict(_: Dict[str, Any]) Serializable[source]

Returns an instance of the object from a dictionary.

to_dict() Dict[str, Any][source]

Returns a dictionary representation of the object.

to_dict_full() Dict[str, Any][source]

Returns a dictionary representation of the object that contains all of the objects attributes.

class loadero_python.resources.resource.URL(url: str = '')[source]

Bases: Serializable

URL describes a single Loadero log file or artifact. Allows downloading without manually supplying access token.

download() str[source]

Downloads the contents of a the URL, storing the result as a file in current working directory

Returns

str: File name of the download.

from_dict(json_dict: str) URL[source]

Returns an instance of the object from a dictionary.

to_dict() str[source]

Returns a dictionary representation of the object.

to_dict_full() str[source]

Returns a dictionary representation of the object that contains all of the objects attributes.

url() str[source]

Returns URL string

Returns:

str: URL string

loadero_python.resources.resource.convert_params_list(resource_class: type, params: List[LoaderoResource]) list[source]

Converts a list of resource params to a list of resource objects. User of this function is responsible for matching the type of params and resource, otherwise the function will produce invalid resource instances.

Args:

resource_class (type): Class name of the target resource object type.

params (list[LoaderoResource]): List of resource params.

Returns:

List[LoaderoResource]: List of resource objects.

loadero_python.resources.resource.from_dict_as_list(resource_params_class: type) Callable[[Dict[str, Any]], List[LoaderoResourceParams]][source]

Returns a function that deserializes a dictionary to a list of new instances of the resource params class

Args:

resource_params_class (type): Loadero resource params class.

Returns:

function: Function that deserializes a json dictionary to a list of new LoaderoResourceParams objects.

loadero_python.resources.resource.from_dict_as_new(resource_params_class: type) Callable[[Dict[str, Any]], LoaderoResourceParams][source]

Returns a function that deserializes a dictionary to a new instance of the resource params class.

Args:

resource_params_class (type): Loadero resource params class.

Returns:

function: Function that deserializes a json dictionary to a new LoaderoResourceParams object.