# Path: newrelic_api/exceptions.py
# class ConfigurationException(Exception):
#     """
#     An exception for Configuration errors
#     """
#     message = 'There was an error in the configuration'
# 
# class NewRelicAPIServerException(Exception):
#     """
#     An exception for New Relic server errors
#     """
#     message = 'There was an error from New Relic'


import os
import json
import requests
from newrelic_api.exceptions import ConfigurationException, NewRelicAPIServerException
        :type api_key: str
        :param api_key: The API key. If no key is passed, the environment
            variable NEW_RELIC_API_KEY is used.
        :raises: If the api_key parameter is not present, and no environment
            variable is present, a :class:`newrelic_api.exceptions.ConfigurationException`
            is raised.
        """
        self.api_key = api_key or os.environ.get('NEW_RELIC_API_KEY') or os.environ.get('NEWRELIC_API_KEY')

        if not self.api_key:
            raise ConfigurationException('NEW_RELIC_API_KEY or NEWRELIC_API_KEY not present in environment!')

        self.headers = {
            'Content-type': 'application/json',
            'X-Api-Key': self.api_key,
        }

    def _get(self, *args, **kwargs):
        """
        A wrapper for getting things

        :returns: The response of your get
        :rtype: dict

        :raises: This will raise a
            :class:`NewRelicAPIServerException<newrelic_api.exceptions.NewRelicAPIServerException>`
            if there is an error from New Relic
        """
        response = requests.get(*args, **kwargs)
        if not response.ok:

# Path: newrelic_api/exceptions.py
# class ConfigurationException(Exception):
#     """
#     An exception for Configuration errors
#     """
#     message = 'There was an error in the configuration'
# 
# class NewRelicAPIServerException(Exception):
#     """
#     An exception for New Relic server errors
#     """
#     message = 'There was an error from New Relic'


# Path: newrelic_api/base.py
import os
import json
import requests
from newrelic_api.exceptions import ConfigurationException, NewRelicAPIServerException

        :type api_key: str
        :param api_key: The API key. If no key is passed, the environment
            variable NEW_RELIC_API_KEY is used.
        :raises: If the api_key parameter is not present, and no environment
            variable is present, a :class:`newrelic_api.exceptions.ConfigurationException`
            is raised.
        """
        self.api_key = api_key or os.environ.get('NEW_RELIC_API_KEY') or os.environ.get('NEWRELIC_API_KEY')

        if not self.api_key:
            raise ConfigurationException('NEW_RELIC_API_KEY or NEWRELIC_API_KEY not present in environment!')

        self.headers = {
            'Content-type': 'application/json',
            'X-Api-Key': self.api_key,
        }

    def _get(self, *args, **kwargs):
        """
        A wrapper for getting things

        :returns: The response of your get
        :rtype: dict

        :raises: This will raise a
            :class:`NewRelicAPIServerException<newrelic_api.exceptions.NewRelicAPIServerException>`
            if there is an error from New Relic
        """
        response = requests.get(*args, **kwargs)
        if not response.ok:

            raise NewRelicAPIServerException('{}: {}'.format(response.status_code, response.text))