Lists all teams with the organization.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    ignore_cache
        Bypasses the use of cached teams.

    CLI Example:

    .. code-block:: bash

        salt myminion github.list_teams

    .. versionadded:: 2016.11.0

def list_teams(profile="github", ignore_cache=False):
    '''
    Lists all teams with the organization.

    profile
        The name of the profile configuration to use. Defaults to ``github``.

    ignore_cache
        Bypasses the use of cached teams.

    CLI Example:

    .. code-block:: bash

        salt myminion github.list_teams

    .. versionadded:: 2016.11.0
    '''
    key = 'github.{0}:teams'.format(
        _get_config_value(profile, 'org_name')
    )

    if key not in __context__ or ignore_cache:
        client = _get_client(profile)
        organization = client.get_organization(
            _get_config_value(profile, 'org_name')
        )
        teams_data = organization.get_teams()
        teams = {}
        for team in teams_data:
            # Note that _rawData is used to access some properties here as they
            # are not exposed in older versions of PyGithub. It's VERY important
            # to use team._rawData instead of team.raw_data, as the latter forces
            # an API call to retrieve team details again.
            teams[team.name] = {
                'id': team.id,
                'slug': team.slug,
                'description': team._rawData['description'],
                'permission': team.permission,
                'privacy': team._rawData['privacy']
            }
        __context__[key] = teams

    return __context__[key]