code: def for_(cls, operation, ns, qs=None, type=None, allow_templates=False, **kwargs):
          
          assert isinstance(ns, Namespace)
          try:
              href, templated = ns.href_for(operation, qs=qs, **kwargs), False
          except BuildError as error:
              if not allow_templates:
                  raise
              uri_templates = {
                  argument: "{{{}}}".format(argument)
                  for argument in error.suggested.arguments
              }
              kwargs.update(uri_templates)
              href, templated = ns.href_for(operation, qs=qs, **kwargs), True
  
          return cls(
              href=href,
              type=type,
              templated=templated,
          )
docs: Create a link to an operation on a resource object.
  
          Supports link templating if enabled by making a best guess as to the URI
          template construction.
  
          See also [RFC 6570]( https://tools.ietf.org/html/rfc6570).
  
          :param operation: the operation
          :param ns: the namespace
          :param qs: an optional query string (e.g. for paging)
          :param type: an optional link type
          :param allow_templates: whether generated links are allowed to contain templates
          :param kwargs: optional endpoint expansion arguments (e.g. for URI parameters)
          :raises BuildError: if link templating is needed and disallowed