docs: def get_link_mappings(link_id, link_2_id=None, **kwargs):
      """
          Get all the resource attribute mappings in a network. If another network
          is specified, only return the mappings between the two networks.
      """
      qry = db.DBSession.query(ResourceAttrMap).filter(
          or_(
              and_(
                  ResourceAttrMap.resource_attr_id_a == ResourceAttr.id,
                  ResourceAttr.link_id == link_id),
              and_(
                  ResourceAttrMap.resource_attr_id_b == ResourceAttr.id,
                  ResourceAttr.link_id == link_id)))
  
      if link_2_id is not None:
          aliased_ra = aliased(ResourceAttr, name="ra2")
          qry = qry.filter(or_(
              and_(
                  ResourceAttrMap.resource_attr_id_a == aliased_ra.id,
                  aliased_ra.link_id == link_2_id),
              and_(
                  ResourceAttrMap.resource_attr_id_b == aliased_ra.id,
                  aliased_ra.link_id == link_2_id)))
  
      return qry.all()