'Rename this collection.
If operating in auth mode, client must be authorized as an
admin to perform this operation. Raises :class:`TypeError` if
`new_name` is not an instance of :class:`basestring`
(:class:`str` in python 3). Raises :class:`~pymongo.errors.InvalidName`
if `new_name` is not a valid collection name.
:Parameters:
- `new_name`: new name for this collection
- `**kwargs` (optional): additional arguments to the rename command
may be passed as keyword arguments to this helper method
(i.e. ``dropTarget=True``)
.. note:: The :attr:`~pymongo.collection.Collection.write_concern` of
this collection is automatically applied to this operation when using
MongoDB >= 3.4.
.. versionchanged:: 3.4
Apply this collection\'s write concern automatically to this operation
when connected to MongoDB >= 3.4.'

def rename(self, new_name, **kwargs):

    if (not isinstance(new_name, string_type)):
        raise TypeError(('new_name    must    be    an    instance    of    %s' % (string_type.__name__,)))
    if ((not new_name) or ('..' in new_name)):
        raise InvalidName('collection    names    cannot    be    empty')
    if ((new_name[0] == '.') or (new_name[(-1)] == '.')):
        raise InvalidName("collecion    names    must    not    start    or    end    with    '.'")
    if (('$' in new_name) and (not new_name.startswith('oplog.$main'))):
        raise InvalidName("collection    names    must    not    contain    '$'")
    new_name = ('%s.%s' % (self.__database.name, new_name))
    cmd = SON([('renameCollection', self.__full_name), ('to', new_name)])
    with self._socket_for_writes() as sock_info:
        if ((sock_info.max_wire_version >= 5) and self.write_concern):
            cmd['writeConcern'] = self.write_concern.document
        cmd.update(kwargs)
        sock_info.command('admin', cmd, parse_write_concern_error=True)
