Utils¶
pyatlan.utils
¶
Classes¶
API(path: str, method: HTTPMethod, expected_status: int, endpoint: EndPoint, consumes: str = APPLICATION_JSON, produces: str = APPLICATION_JSON)
¶
Source code in pyatlan/utils.py
Functions¶
multipart_urljoin(base_path, *path_elems)
staticmethod
¶
Join a base path and multiple context path elements. Handle single
leading and trailing / characters transparently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_path
|
string
|
the base path or url (ie. |
required |
*path_elems
|
string
|
multiple relative path elements (ie. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
string |
the result of joining the base_path with the additional path elements |
Source code in pyatlan/utils.py
AuthorizationFilter
¶
Bases: Filter
A Filter that will replace the authorization header with the text 'REDACTED'
ContextVarWrapper(contextvar: ContextVar, key_name: str)
¶
Bases: Mapping
This class implements the Mapping protocol on a ContextVar. This allows 'extra' information needed for a LogAdaptor to be obtained from a ContextVar.
Create the ContextVarWrapper :param contextvar: the ContextVar that will provide the data :param key_name: the name that should be used to obtain a value from the contextvar
Source code in pyatlan/utils.py
JsonFormatter
¶
Bases: Formatter
A custom JSON log formatter
Functions¶
format(record: logging.LogRecord) -> str
¶
Format the log record
:param record: The log record to be formatted :returns: The formatted log message
Source code in pyatlan/utils.py
RequestIdAdapter(logger: logging.Logger, contextvar: ContextVar)
¶
Bases: LoggerAdapter
This is a LoggerAdapter that can be used to provide a reqquestid from a ContextVar
Create the LoggerAdapter the will get the value to be used for 'requestid' from the given ContextVar :param logger: the Logger to wrap :param contextvar: the ContextVar from which to obtain the value to be used for 'requestid'
Source code in pyatlan/utils.py
RequestIdFilter
¶
Bases: Filter
A filter that will add requestid to the LogRecord if it is not already present. This is to support adding the requestid to the logging formatter
Functions¶
deep_get(dictionary, keys, default=None)
¶
Returns dict key value using dict and it's dot_key string,
ie: key1.key2_nested.key3_nested, if found, otherwise returns default (None).
Source code in pyatlan/utils.py
get_parent_qualified_name(qualified_name: str) -> str
¶
Returns qualified name of the parent asset :param qualified_name: qualified of the asset
get_python_version() -> str
¶
Get the current Python version as a string.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Python version in format "major.minor.micro" or "unknown" if unavailable |
Source code in pyatlan/utils.py
init_guid(func)
¶
Decorator function that can be used on the Create method of an asset to initialize the guid.
Source code in pyatlan/utils.py
select_optional_set_fields(params: Dict[str, Any]) -> Dict
¶
Filter the provided parameters to include
only those fields that are not set to None.
validate_type(name: str, _type, value)
¶
Validate that the given value is of the specified type.
:param name: the name of the variable to be used in the error message :param _type: the type of the variable to be validated :param value: the value to be validated that it is of the specified type