code: def iter_rules(self, endpoint=None):
          
          self.update()
          if endpoint is not None:
              return iter(self._rules_by_endpoint[endpoint])
          return iter(self._rules)
docs: Iterate over all rules or the rules of an endpoint.
  
          :param endpoint: if provided only the rules for that endpoint
                           are returned.
          :return: an iterator