def create_folder(service, name, folder_id=None, **kwargs):
    """
    Creates a folder and returns the FileId
    :param service: Service object
    :param name: name of the folder
    :param folder_id: (Optional) FileId of the containing folder
    :return: folder object
    """
    kwargs['name'] = name
    kwargs['mimeType'] = 'application/vnd.google-apps.folder'
    if folder_id:
        kwargs['parents'] = [folder_id]
    return service.files().create(body=kwargs).execute()
