'Registers an instance of a ``Resource`` subclass with the API.
Optionally accept a ``canonical`` argument, which indicates that the
resource being registered is the canonical variant. Defaults to
``True``.'

def register(self, resource, canonical=True):

    resource_name = getattr(resource._meta, u'resource_name', None)
    if (not isinstance(resource, Resource)):
        raise ValueError((u'An    instance    of    ``Resource``    subclass    should    be    passed    in    for    %s' % resource_name))
    if (resource_name is None):
        raise ImproperlyConfigured((u"Resource    %r    must    define    a    'resource_name'." % resource))
    self._registry[resource_name] = resource
    if (canonical is True):
        if (resource_name in self._canonicals):
            warnings.warn((u"A    new    resource    '%r'    is    replacing    the    existing    canonical    URL    for    '%s'." % (resource, resource_name)), Warning, stacklevel=2)
        self._canonicals[resource_name] = resource
        resource._meta.api_name = self.api_name
        resource.__class__.Meta.api_name = self.api_name
