link_index()

link_index() function seems only work in apperance label of link
is it posible to use it on device apperacne/ services? as parameter can use device name like

link_index(“GigabitEthernet3/13”)

i really need that functionality but can’t figure out how to achive this. Existing functions in my humble opinion are to simple to find this index when we know only device name. If i am wrong please correct me.