Skip to content

Base

CLASS DESCRIPTION
StoreProvider

StoreProvider

Bases: ABC

METHOD DESCRIPTION
get_configuration

Get configuration from any store and return the parsed JSON dictionary

ATTRIBUTE DESCRIPTION
get_raw_configuration

Get configuration from any store and return the parsed JSON dictionary

TYPE: dict[str, Any]

get_raw_configuration abstractmethod property

get_raw_configuration: dict[str, Any]

Get configuration from any store and return the parsed JSON dictionary

get_configuration abstractmethod

get_configuration() -> dict[str, Any]

Get configuration from any store and return the parsed JSON dictionary

If envelope is set, it'll extract and return feature flags from configuration, otherwise it'll return the entire configuration fetched from the store.

RAISES DESCRIPTION
ConfigurationStoreError

Any error that can occur during schema fetch or JSON parse

RETURNS DESCRIPTION
dict[str, Any]

parsed JSON dictionary

Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
{
    "premium_features": {
        "default": False,
        "rules": {
            "customer tier equals premium": {
                "when_match": True,
                "conditions": [
                    {
                        "action": "EQUALS",
                        "key": "tier",
                        "value": "premium",
                    }
                ],
            }
        },
    },
    "feature_two": {
        "default": False
    }
}
Source code in aws_lambda_powertools/utilities/feature_flags/base.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@abstractmethod
def get_configuration(self) -> dict[str, Any]:
    """Get configuration from any store and return the parsed JSON dictionary

    If envelope is set, it'll extract and return feature flags from configuration,
    otherwise it'll return the entire configuration fetched from the store.

    Raises
    ------
    ConfigurationStoreError
        Any error that can occur during schema fetch or JSON parse

    Returns
    -------
    dict[str, Any]
        parsed JSON dictionary

    Example
    -------

    ```python
    {
        "premium_features": {
            "default": False,
            "rules": {
                "customer tier equals premium": {
                    "when_match": True,
                    "conditions": [
                        {
                            "action": "EQUALS",
                            "key": "tier",
                            "value": "premium",
                        }
                    ],
                }
            },
        },
        "feature_two": {
            "default": False
        }
    }
    ```
    """
    raise NotImplementedError()  # pragma: no cover