welkin.util =========== .. py:module:: welkin.util Classes ------- .. autoapisummary:: welkin.util.Target Functions --------- .. autoapisummary:: welkin.util.clean_data welkin.util.clean_request_payload welkin.util.clean_json_list welkin.util.clean_request_params welkin.util.clean_date welkin.util.clean_datetime welkin.util.find_model_id welkin.util.model_id welkin.util.reset_file_offsets welkin.util.to_camel_case welkin.util.to_snake_case Module Contents --------------- .. py:class:: Target .. py:function:: clean_data(value: Any) -> Any Clean data for JSON serialization. :param value: The value to clean. :type value: Any :returns: The cleaned value. :rtype: Any .. py:function:: clean_request_payload(payload: dict) -> dict .. py:function:: clean_json_list(data: list) -> list .. py:function:: clean_request_params(params: dict) -> dict .. py:function:: clean_date(date: clean_date.date) -> str .. py:function:: clean_datetime(dt: datetime.datetime) -> str .. py:function:: find_model_id(instance: welkin.models.base.Collection | welkin.models.base.Resource, model_name: str) -> str Recursively traverse the `_parent` chain searching for a model id. :param instance: The instanceect instance to inspect. :type instance: Union[Collection, Resource] :param model_name: The class name of the model to find. :type model_name: str :raises AttributeError: If recursion ends without finding the model id. :returns: The model id. :rtype: str .. py:function:: model_id(*models: tuple[str]) -> Callable Insert values for `model_id` arguments if not provided. :param \*models: The model names to search for. :type \*models: tuple[str] :raises TypeError: If no ID is found and no arguments are provided. .. py:function:: reset_file_offsets(files: list) -> None Reset file-like objects to the beginning of the file. :param files: The list of files from the request. :type files: list .. py:function:: to_camel_case(s: str) -> str Convert a string to camelCase. :param s: The string to convert. :type s: str :returns: The converted camelCase string. :rtype: str .. py:function:: to_snake_case(s: str) -> str Convert a string to snake_case. :param s: The string to convert. :type s: str :returns: The converted snake_case string. :rtype: str