# Copyright (c) 2020 CloudZero - ALL RIGHTS RESERVED - PROPRIETARY AND CONFIDENTIAL
# Unauthorized copying of this file and/or project, via any medium is strictly prohibited.
# Direct all questions to legal@cloudzero.com
import importlib
import os
from czc.module_property import create_property, configure_resolver

configure_resolver(__name__)


def try_import_value(path: str, name: str):
    try:
        module = importlib.import_module(path)
        return getattr(module, name)
    except Exception:
        return None


FEATURE_NAME = (try_import_value('src.common.constants', 'FEATURE_NAME') or
                try_import_value('src.functions.constants', 'FEATURE_NAME') or
                os.environ.get('FEATURE', 'czc'))

PROJECT_NAME = f'cz-{FEATURE_NAME}'
NAMESPACE = create_property(lambda: os.environ.get('NAMESPACE'))

DYNAMODB_TTL_OVERRIDE = 'DYNAMODB_TTL_OVERRIDE'

CLOUDZERO_IDEMPOTENCY_KEY_EVENT_PARAMETER = '__idempotency_key__'
CLOUDZERO_TEST_KEY_EVENT_PARAMETER = '__test_key__'

CLOUDZERO_TEST_KEY_DO_NOT_FORWARD_SUFFIX = '-do-not-forward'
