.. versionadded:: 2017.7.0

    Downloads updates that match the list of passed identifiers. It's easier to
    use this function by using list_updates and setting install=True.

    Args:

        names (str, list):
            A single update or a list of updates to download. This can be any
            combination of GUIDs, KB numbers, or names. GUIDs or KBs are
            preferred.

    .. note::
        An error will be raised if there are more results than there are items
        in the names parameter

    Returns:

        dict: A dictionary containing the details about the downloaded updates

    CLI Examples:

    .. code-block:: bash

        # Normal Usage
        salt '*' win_wua.download names=['12345678-abcd-1234-abcd-1234567890ab', 'KB2131233']

def download(names):
    '''
    .. versionadded:: 2017.7.0

    Downloads updates that match the list of passed identifiers. It's easier to
    use this function by using list_updates and setting install=True.

    Args:

        names (str, list):
            A single update or a list of updates to download. This can be any
            combination of GUIDs, KB numbers, or names. GUIDs or KBs are
            preferred.

    .. note::
        An error will be raised if there are more results than there are items
        in the names parameter

    Returns:

        dict: A dictionary containing the details about the downloaded updates

    CLI Examples:

    .. code-block:: bash

        # Normal Usage
        salt '*' win_wua.download names=['12345678-abcd-1234-abcd-1234567890ab', 'KB2131233']
    '''
    # Create a Windows Update Agent instance
    wua = salt.utils.win_update.WindowsUpdateAgent()

    # Search for Update
    updates = wua.search(names)

    if updates.count() == 0:
        raise CommandExecutionError('No updates found')

    # Make sure it's a list so count comparison is correct
    if isinstance(names, six.string_types):
        names = [names]

    if isinstance(names, six.integer_types):
        names = [six.text_type(names)]

    if updates.count() > len(names):
        raise CommandExecutionError('Multiple updates found, names need to be '
                                    'more specific')

    return wua.download(updates)