# -*- coding: utf-8 -*-
"""
Library for interacting with Mattermost Incoming Webhooks
:configuration: This module can be used by specifying the name of a
    configuration profile in the minion config, minion pillar, or master
    config.
    For example:
    .. code-block:: yaml
        mattermost:
          hook: 3tdgo8restnxiykdx88wqtxryr
          api_url: https://example.com
"""
from __future__ import absolute_import, unicode_literals

import logging

import salt.ext.six.moves.http_client

# pylint: enable=import-error,no-name-in-module
import salt.utils.http
from salt.ext import six

# Import 3rd-party libs
# pylint: disable=import-error,no-name-in-module,redefined-builtin
from salt.ext.six.moves.urllib.parse import urljoin as _urljoin
from salt.version import __version__

log = logging.getLogger(__name__)


def query(hook=None, api_url=None, data=None):
    """
    Mattermost object method function to construct and execute on the API URL.
    :param api_url:     The Mattermost API URL
    :param hook:        The Mattermost hook.
    :param data:        The data to be sent for POST method.
    :return:            The json response from the API call or False.
    """
    method = "POST"

    ret = {"message": "", "res": True}

    base_url = _urljoin(api_url, "/hooks/")
    url = _urljoin(base_url, six.text_type(hook))

    result = salt.utils.http.query(url, method, data=data, decode=True, status=True)

    if result.get("status", None) == salt.ext.six.moves.http_client.OK:
        ret["message"] = "Message posted {0} correctly".format(data)
        return ret
    elif result.get("status", None) == salt.ext.six.moves.http_client.NO_CONTENT:
        return True
    else:
        log.debug(url)
        log.debug(data)
        log.debug(result)
        if "dict" in result:
            _result = result["dict"]
            if "error" in _result:
                ret["message"] = result["error"]
                ret["res"] = False
                return ret
            ret["message"] = "Message not posted"
        else:
            ret["message"] = "invalid_auth"
            ret["res"] = False
    return ret

@@ -1,28 +1,4 @@
-# -*- coding: utf-8 -*-%0A
 %22%22%22%0A
@@ -360,65 +360,27 @@
 %22%22%22%0A
-from __future__ import absolute_import, unicode_literals%0A
+%0Aimport http.client
 %0Aimp
@@ -395,299 +395,51 @@
 ing%0A
-%0A
 import 
-salt.ext.six.moves.http_client%0A%0A# pylint: enable=import-error,no-name-in-module%0Aimport salt.utils.http%0Afrom salt.ext import six%0A%0A# Import 3rd-party libs%0A# pylint: disable=import-error,no-name-in-module,redefined-builtin%0Afrom salt.ext.six.moves.urllib.parse import urljoin as _urljoin
+urllib.parse%0A%0Aimport salt.utils.http
 %0Afro
@@ -946,25 +946,37 @@
  base_url = 
-_
+urllib.parse.
 urljoin(api_
@@ -1001,17 +1001,29 @@
   url = 
-_
+urllib.parse.
 urljoin(
@@ -1037,20 +1037,10 @@
 l, s
-ix.text_type
+tr
 (hoo
@@ -1171,32 +1171,13 @@
  == 
-salt.ext.six.moves.
 http
-_
+.
 clie
@@ -1229,9 +1229,8 @@
 ed %7B
-0
 %7D co
@@ -1313,32 +1313,13 @@
  == 
-salt.ext.six.moves.
 http
-_
+.
 clie

Drop Py2 and six on salt/utils/mattermost.py