docs: def get_links(network_id, template_id=None, **kwargs):
      """
          Get all the links in a network.
          args:
              network_id (int): The network in which to search
              template_id (int): Only return links whose type is in this template.
      """
      user_id = kwargs.get('user_id')
      try:
          net_i = db.DBSession.query(Network).filter(Network.id == network_id).one()
          net_i.check_read_permission(user_id=user_id)
      except NoResultFound:
          raise ResourceNotFoundError("Network %s not found"%(network_id))
  
      link_qry = db.DBSession.query(Link).filter(
                                          Link.network_id==network_id,
                                          Link.status=='A').options(
                                              noload('network')
                                          ).options(
                                              joinedload_all('types.templatetype')
                                          ).options(
                                              joinedload_all('attributes.attr')
                                          )
  
      if template_id is not None:
          link_qry = link_qry.filter(ResourceType.link_id==Link.id,
                                     TemplateType.id==ResourceType.type_id,
                                     TemplateType.template_id==template_id)
  
      links = link_qry.all()
      return links