Install a capability

    Args:
        capability (str): The capability to install
        source (Optional[str]): The optional source of the capability. Default
            is set by group policy and can be Windows Update.
        limit_access (Optional[bool]): Prevent DISM from contacting Windows
            Update for the source package
        image (Optional[str]): The path to the root directory of an offline
            Windows image. If `None` is passed, the running operating system is
            targeted. Default is None.
        restart (Optional[bool]): Reboot the machine if required by the install

    Raises:
        NotImplementedError: For all versions of Windows that are not Windows 10
        and later. Server editions of Windows use ServerManager instead.

    Returns:
        dict: A dictionary containing the results of the command

    CLI Example:

    .. code-block:: bash

        salt '*' dism.add_capability Tools.Graphics.DirectX~~~~0.0.1.0

def add_capability(capability,
                   source=None,
                   limit_access=False,
                   image=None,
                   restart=False):
    '''
    Install a capability

    Args:
        capability (str): The capability to install
        source (Optional[str]): The optional source of the capability. Default
            is set by group policy and can be Windows Update.
        limit_access (Optional[bool]): Prevent DISM from contacting Windows
            Update for the source package
        image (Optional[str]): The path to the root directory of an offline
            Windows image. If `None` is passed, the running operating system is
            targeted. Default is None.
        restart (Optional[bool]): Reboot the machine if required by the install

    Raises:
        NotImplementedError: For all versions of Windows that are not Windows 10
        and later. Server editions of Windows use ServerManager instead.

    Returns:
        dict: A dictionary containing the results of the command

    CLI Example:

    .. code-block:: bash

        salt '*' dism.add_capability Tools.Graphics.DirectX~~~~0.0.1.0
    '''
    if salt.utils.versions.version_cmp(__grains__['osversion'], '10') == -1:
        raise NotImplementedError(
            '`install_capability` is not available on this version of Windows: '
            '{0}'.format(__grains__['osversion']))

    cmd = ['DISM',
           '/Quiet',
           '/Image:{0}'.format(image) if image else '/Online',
           '/Add-Capability',
           '/CapabilityName:{0}'.format(capability)]

    if source:
        cmd.append('/Source:{0}'.format(source))
    if limit_access:
        cmd.append('/LimitAccess')
    if not restart:
        cmd.append('/NoRestart')

    return __salt__['cmd.run_all'](cmd)