Source code for luna_licenses.crutches_on_wheels.cow.utils.rid
"""
Module realizes  getting and checking request id
"""
import uuid
from log import getLogTimestamp
from .regexps import REQUEST_ID_REGEXP
# var contains actual requst id
[docs]
def generateRequestId(timeIsLocal: bool) -> str:
    """
    Generate correct request id.
    Args:
        timeIsLocal: timestamp generate in localtime or not
    Returns:
        standard request id string.
    """
    requestId = f"{getLogTimestamp(timeIsLocal)},{uuid.uuid4()}"
    return requestId 
[docs]
def checkRequestId(requestId: str) -> bool:
    """
    Validate request id str
    Args:
        requestId: str for checking
    Returns:
        True if requestId match with REQUEST_ID_REGEXP otherwise False
    """
    match = REQUEST_ID_REGEXP.match(requestId)
    return match is not None