# Path: sevenbridges/errors.py
# class SbgError(Exception):
#     """Base class for SBG errors.
# 
#     Provides a base exception for all errors
#     that are thrown by sevenbridges-python library.
#     """
# 
#     def __init__(self, message=None, code=None, status=None, more_info=None):
#         """
#         :param code: Custom error code
#         :param status: Http status code.
#         :param message: Message describing the error.
#         """
#         self.code = code
#         self.status = status
#         self.message = message
#         self.more_info = more_info
# 
#     def __str__(self):
#         return str(self.message)


import os
import logging
import configparser
from sevenbridges.errors import SbgError

class Config:
    """
    Utility configuration class.
    """

    def __init__(self, profile=None, proxies=None, advance_access=None):
        """
        Configures the bindings to use api url and token specified
        in the .ini like configuration file.
        :param profile: ini section, if not supplied [default] profile is used.
        """

        self.profile = profile

        cfg_profile = None

        if not self.profile:
            # Try os.environ
            self.auth_token = os.environ.get('SB_AUTH_TOKEN')
            self.api_endpoint = os.environ.get('SB_API_ENDPOINT')
            self.proxies = {
                'http': os.environ.get('HTTP_PROXY'),
                'https': os.environ.get('HTTPS_PROXY')
            }
            if not self.auth_token:
                logger.warning('Missing SB_AUTH_TOKEN os variable.')
                raise SbgError('Missing SB_AUTH_TOKEN')
            if not self.api_endpoint:
                logger.warning('Missing SB_API_ENDPOINT os variable.')

# Path: sevenbridges/errors.py
# class SbgError(Exception):
#     """Base class for SBG errors.
# 
#     Provides a base exception for all errors
#     that are thrown by sevenbridges-python library.
#     """
# 
#     def __init__(self, message=None, code=None, status=None, more_info=None):
#         """
#         :param code: Custom error code
#         :param status: Http status code.
#         :param message: Message describing the error.
#         """
#         self.code = code
#         self.status = status
#         self.message = message
#         self.more_info = more_info
# 
#     def __str__(self):
#         return str(self.message)


# Path: sevenbridges/config.py
import os
import logging
import configparser
from sevenbridges.errors import SbgError


class Config:
    """
    Utility configuration class.
    """

    def __init__(self, profile=None, proxies=None, advance_access=None):
        """
        Configures the bindings to use api url and token specified
        in the .ini like configuration file.
        :param profile: ini section, if not supplied [default] profile is used.
        """

        self.profile = profile

        cfg_profile = None

        if not self.profile:
            # Try os.environ
            self.auth_token = os.environ.get('SB_AUTH_TOKEN')
            self.api_endpoint = os.environ.get('SB_API_ENDPOINT')
            self.proxies = {
                'http': os.environ.get('HTTP_PROXY'),
                'https': os.environ.get('HTTPS_PROXY')
            }
            if not self.auth_token:
                logger.warning('Missing SB_AUTH_TOKEN os variable.')
                raise SbgError('Missing SB_AUTH_TOKEN')
            if not self.api_endpoint:
                logger.warning('Missing SB_API_ENDPOINT os variable.')

                raise SbgError('Missing SB_API_ENDPOINT')