src/dirbs/api/v2/resources/imei.py
def imei_info_api(imei: str) -> jsonify:
    """
    IMEI-Info API method handler.

    Arguments:
        imei: IMEI value to extract information
    Returns:
        JSON response if exists otherwise
    """
    imei_norm = validate_imei(imei)

    with get_db_connection() as db_conn, db_conn.cursor() as cursor:
        cursor.execute("""SELECT imei_norm, make, model, status, model_number, brand_name, device_type,
                                 radio_interface
                            FROM registration_list
                           WHERE imei_norm = %(imei_norm)s
                             AND virt_imei_shard = calc_virt_imei_shard(%(imei_norm)s)""",
                       {'imei_norm': imei_norm})
        info_rec = cursor.fetchone()

        cursor.execute("""SELECT imei_norm
                            FROM registration_list
                           WHERE device_id = (SELECT device_id
                                                FROM registration_list
                                               WHERE imei_norm = %(imei_norm)s
                                                 AND virt_imei_shard = calc_virt_imei_shard(%(imei_norm)s))
                             AND imei_norm NOT IN (%(imei_norm)s)""",
                       {'imei_norm': imei_norm})

        if info_rec is not None:
            response = info_rec._asdict()
            response['associated_imeis'] = [rec.imei_norm for rec in cursor] \
                if cursor is not None else []
            return jsonify(IMEIInfo().dump(response).data)
        return {}

    IMEI-Info API method handler.

    Arguments:
        imei: IMEI value to extract information
    Returns:
        JSON response if exists otherwise
    
IMEI-Info API method handler.
IMEI - Info API method handler .
def imei_info_api(imei: str) -> jsonify:
    imei_norm = validate_imei(imei)
    with get_db_connection() as db_conn, db_conn.cursor() as cursor:
        cursor.execute("""SELECT imei_norm, make, model, status, model_number, brand_name, device_type,
                                 radio_interface
                            FROM registration_list
                           WHERE imei_norm = %(imei_norm)s
                             AND virt_imei_shard = calc_virt_imei_shard(%(imei_norm)s)""",
                       {'imei_norm': imei_norm})
        info_rec = cursor.fetchone()
        cursor.execute("""SELECT imei_norm
                            FROM registration_list
                           WHERE device_id = (SELECT device_id
                                                FROM registration_list
                                               WHERE imei_norm = %(imei_norm)s
                                                 AND virt_imei_shard = calc_virt_imei_shard(%(imei_norm)s))
                             AND imei_norm NOT IN (%(imei_norm)s)""",
                       {'imei_norm': imei_norm})
        if info_rec is not None:
            response = info_rec._asdict()
            response['associated_imeis'] = [rec.imei_norm for rec in cursor] \
                if cursor is not None else []
            return jsonify(IMEIInfo().dump(response).data)
        return {}
def imei_info_api ( imei : str ) -> jsonify : imei_norm = validate_imei ( imei ) with get_db_connection ( ) as db_conn , db_conn . cursor ( ) as cursor : cursor . execute ( """SELECT imei_norm, make, model, status, model_number, brand_name, device_type,
                                 radio_interface
                            FROM registration_list
                           WHERE imei_norm = %(imei_norm)s
                             AND virt_imei_shard = calc_virt_imei_shard(%(imei_norm)s)""" , { 'imei_norm' : imei_norm } ) info_rec = cursor . fetchone ( ) cursor . execute ( """SELECT imei_norm
                            FROM registration_list
                           WHERE device_id = (SELECT device_id
                                                FROM registration_list
                                               WHERE imei_norm = %(imei_norm)s
                                                 AND virt_imei_shard = calc_virt_imei_shard(%(imei_norm)s))
                             AND imei_norm NOT IN (%(imei_norm)s)""" , { 'imei_norm' : imei_norm } ) if info_rec is not None : response = info_rec . _asdict ( ) response [ 'associated_imeis' ] = [ rec . imei_norm for rec in cursor ] if cursor is not None else [ ] return jsonify ( IMEIInfo ( ) . dump ( response ) . data ) return { }
IMEI-Info API method handler.
IMEI - Info API method handler .
"""
    IMEI-Info API method handler.

    Arguments:
        imei: IMEI value to extract information
    Returns:
        JSON response if exists otherwise
    """
JSON response if exists otherwise
JSON response if exists otherwise
imei
str
IMEI value to extract information
IMEI value to extract information