# Path: katprep/management/base.py
# class BaseConnector(metaclass=ABCMeta):
#     """
#     Basic management connector that connects on creation.
#     """
# 
#     def __init__(self, username, password, **kwargs):
#         self._username = username
#         self._password = password
#         self._session = None
#         self._connect()
# 
#     @abstractmethod
#     def _connect(self):
#         pass
# 
# Path: katprep/exceptions.py
# class APILevelNotSupportedException(Exception):
#     """
#     Dummy class for unsupported API levels
# 
#     .. class:: APILevelNotSupportedException
#     """
# 
# class InvalidCredentialsException(Exception):
#     """
#     Dummy class for invalid credentials
# 
#     .. class:: InvalidCredentialsException
#     """
# 
# class SessionException(Exception):
#     """
#     Dummy class for session errors
# 
#     .. class:: SessionException
#     """


import logging
import json
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from .base import BaseConnector
from ..exceptions import (APILevelNotSupportedException,
InvalidCredentialsException, SessionException)

        :param sub_url: relative path within the API tree (e.g. /hosts)
        :type sub_url: str
        :param payload: payload for POST/PUT requests
        :type payload: str
        """
        return self.__api_request("put", sub_url, payload)



    def validate_api_support(self):
        """
        Checks whether the API version on the Foreman server is supported.
        Using older version than API v2 is not recommended. In this case, an
        exception will be thrown.
        """
        try:
            #get api version
            result_obj = json.loads(
                self.api_get("/status")
            )
            self.LOGGER.debug("API version %s found", result_obj["api_version"])
            if result_obj["api_version"] != self.API_MIN:
                raise APILevelNotSupportedException(
                    "Your API version (%s) does not support the required calls."
                    "You'll need API version %s - stop using historic"
                    " software!", result_obj["api_version"], self.API_MIN
                )
        except ValueError as err:
            self.LOGGER.error(err)

# Path: katprep/management/base.py
# class BaseConnector(metaclass=ABCMeta):
#     """
#     Basic management connector that connects on creation.
#     """
# 
#     def __init__(self, username, password, **kwargs):
#         self._username = username
#         self._password = password
#         self._session = None
#         self._connect()
# 
#     @abstractmethod
#     def _connect(self):
#         pass
# 
# Path: katprep/exceptions.py
# class APILevelNotSupportedException(Exception):
#     """
#     Dummy class for unsupported API levels
# 
#     .. class:: APILevelNotSupportedException
#     """
# 
# class InvalidCredentialsException(Exception):
#     """
#     Dummy class for invalid credentials
# 
#     .. class:: InvalidCredentialsException
#     """
# 
# class SessionException(Exception):
#     """
#     Dummy class for session errors
# 
#     .. class:: SessionException
#     """


# Path: katprep/management/foreman.py
import logging
import json
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from .base import BaseConnector
from ..exceptions import (APILevelNotSupportedException,
InvalidCredentialsException, SessionException)


        :param sub_url: relative path within the API tree (e.g. /hosts)
        :type sub_url: str
        :param payload: payload for POST/PUT requests
        :type payload: str
        """
        return self.__api_request("put", sub_url, payload)



    def validate_api_support(self):
        """
        Checks whether the API version on the Foreman server is supported.
        Using older version than API v2 is not recommended. In this case, an
        exception will be thrown.
        """
        try:
            #get api version
            result_obj = json.loads(
                self.api_get("/status")
            )
            self.LOGGER.debug("API version %s found", result_obj["api_version"])
            if result_obj["api_version"] != self.API_MIN:
                raise APILevelNotSupportedException(
                    "Your API version (%s) does not support the required calls."
                    "You'll need API version %s - stop using historic"
                    " software!", result_obj["api_version"], self.API_MIN
                )
        except ValueError as err:
            self.LOGGER.error(err)

            raise APILevelNotSupportedException("Unable to verify API version")