"""Model for ows_features.""" import logging import config import const import requests from models.api_exceptions import PersistentException logger = logging.getLogger() logger.setLevel(logging.INFO) def get_features(account_type, account_id, session=requests): """Get feature permissions. Args: account_type: The account type. account_id: The account id. session: Session object to make requests with. The default is the requests module because it creates a Session object internally and has the same interface. """ url = const.get_service_url( environment=config.ENVIRONMENT, service_name=const.OWS_FEATURES, path=const.OWS_FEATURES_GET_FEATURES_ENDPOINT ) response = session.get(url, params={ 'account_id': account_id, 'account_type': account_type }, timeout=10) if response.status_code != 200: logger.error('Unable to fetch account features from ows-features') raise PersistentException(response.text) return response.json()