# 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)
        """
        valid_objects = [
            "hostgroup", "location", "organization", "environment",
            "host"
        ]
        filter_object = {
            "hostgroup" : "title", "location": "name", "host" : "name",
            "organization" : "title", "environment" : "name"
        }
        try:
            if api_object.lower() not in valid_objects:
                #invalid type
                raise ValueError(
                    "Unable to lookup name by invalid field"
                    " type '{}'".format(api_object)
                )
            else:
                #get ID by name
                result_obj = json.loads(
                    self.api_get("/{}s".format(api_object))
                )
                #TODO: nicer way than looping? numpy? Direct URL?
                for entry in result_obj["results"]:
                    if entry[filter_object[api_object]].lower() == name.lower():
                        self.LOGGER.debug(
                            "%s %s seems to have ID #%s",
                            api_object, name, entry["id"]
                        )
                        return entry["id"]
                #not found

# 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)

        """
        valid_objects = [
            "hostgroup", "location", "organization", "environment",
            "host"
        ]
        filter_object = {
            "hostgroup" : "title", "location": "name", "host" : "name",
            "organization" : "title", "environment" : "name"
        }
        try:
            if api_object.lower() not in valid_objects:
                #invalid type
                raise ValueError(
                    "Unable to lookup name by invalid field"
                    " type '{}'".format(api_object)
                )
            else:
                #get ID by name
                result_obj = json.loads(
                    self.api_get("/{}s".format(api_object))
                )
                #TODO: nicer way than looping? numpy? Direct URL?
                for entry in result_obj["results"]:
                    if entry[filter_object[api_object]].lower() == name.lower():
                        self.LOGGER.debug(
                            "%s %s seems to have ID #%s",
                            api_object, name, entry["id"]
                        )
                        return entry["id"]
                #not found

                raise SessionException("Object not found")