Skip to content

Commit

Permalink
#210: Add enum class for config options
Browse files Browse the repository at this point in the history
- Similar to what now happens in SciGateway Auth
  • Loading branch information
MRichards99 committed Apr 20, 2021
1 parent cab681b commit 171dbdf
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions datagateway_api/common/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from enum import Enum
import json
import logging
from pathlib import Path
Expand All @@ -9,6 +10,30 @@
log = logging.getLogger()


class APIConfigOptions(Enum):
"""
Class to map config keys to variables in Python - implemented for ease of
development (IntelliSense in IDEs)
"""

BACKEND = "backend"
CLIENT_CACHE_SIZE = "client_cache_size"
CLIENT_POOL_INIT_SIZE = "client_pool_init_size"
CLIENT_POOL_MAX_SIZE = "client_pool_max_size"
DB_URL = "db_url"
DEBUG_MODE = "debug_mode"
FLASK_RELOADER = "flask_reloader"
GENERATE_SWAGGER = "generate_swagger"
HOST = "host"
ICAT_CHECK_CERT = "icat_check_cert"
ICAT_URL = "icat_url"
LOG_LEVEL = "log_level"
LOG_LOCATION = "log_location"
PORT = "port"
TEST_MECHANISM = "test_mechanism"
TEST_USER_CREDENTIALS = "test_user_credentials"


class Config(object):
def __init__(self, path=Path(__file__).parent.parent / "config.json"):
self.path = path
Expand Down

0 comments on commit 171dbdf

Please sign in to comment.