Creates a new permission for a file.

        :param file_id: a spreadsheet ID (aka file ID.)
        :type file_id: str
        :param value: user or group e-mail address, domain name
                      or None for 'default' type.
        :type value: str, None
        :param perm_type: (optional) The account type.
               Allowed values are: ``user``, ``group``, ``domain``,
               ``anyone``
        :type perm_type: str
        :param role: (optional) The primary role for this user.
               Allowed values are: ``owner``, ``writer``, ``reader``
        :type str:

        :param notify: (optional) Whether to send an email to the target user/domain.
        :type notify: str
        :param email_message: (optional) An email message to be sent if notify=True.
        :type email_message: str
        
        :param with_link: (optional) Whether the link is required for this permission to be active.
        :type with_link: bool

        Examples::

            # Give write permissions to otto@example.com

            gc.insert_permission(
                '0BmgG6nO_6dprnRRUWl1UFE',
                'otto@example.org',
                perm_type='user',
                role='writer'
            )

            # Make the spreadsheet publicly readable

            gc.insert_permission(
                '0BmgG6nO_6dprnRRUWl1UFE',
                None,
                perm_type='anyone',
                role='reader'
            )

def insert_permission(
        self,
        file_id,
        value,
        perm_type,
        role,
        notify=True,
        email_message=None,
        with_link=False
    ):
        """Creates a new permission for a file.

        :param file_id: a spreadsheet ID (aka file ID.)
        :type file_id: str
        :param value: user or group e-mail address, domain name
                      or None for 'default' type.
        :type value: str, None
        :param perm_type: (optional) The account type.
               Allowed values are: ``user``, ``group``, ``domain``,
               ``anyone``
        :type perm_type: str
        :param role: (optional) The primary role for this user.
               Allowed values are: ``owner``, ``writer``, ``reader``
        :type str:

        :param notify: (optional) Whether to send an email to the target user/domain.
        :type notify: str
        :param email_message: (optional) An email message to be sent if notify=True.
        :type email_message: str
        
        :param with_link: (optional) Whether the link is required for this permission to be active.
        :type with_link: bool

        Examples::

            # Give write permissions to otto@example.com

            gc.insert_permission(
                '0BmgG6nO_6dprnRRUWl1UFE',
                'otto@example.org',
                perm_type='user',
                role='writer'
            )

            # Make the spreadsheet publicly readable

            gc.insert_permission(
                '0BmgG6nO_6dprnRRUWl1UFE',
                None,
                perm_type='anyone',
                role='reader'
            )

        """

        url = '{0}/{1}/permissions'.format(DRIVE_FILES_API_V2_URL, file_id)

        payload = {
            'value': value,
            'type': perm_type,
            'role': role,
            'withLink': with_link
        }

        params = {
            'sendNotificationEmails': notify,
            'emailMessage': email_message
        }

        self.request(
            'post',
            url,
            json=payload,
            params=params
        )