diff --git a/aws_lambda_powertools/utilities/feature_flags/appconfig.py b/aws_lambda_powertools/utilities/feature_flags/appconfig.py index 6c075eac1a1..df506940ee1 100644 --- a/aws_lambda_powertools/utilities/feature_flags/appconfig.py +++ b/aws_lambda_powertools/utilities/feature_flags/appconfig.py @@ -23,7 +23,7 @@ def __init__( name: str, cache_seconds: int, sdk_config: Optional[Config] = None, - envelope: str = "", + envelope: Optional[str] = "", jmespath_options: Optional[Dict] = None, ): """This class fetches JSON schemas from AWS AppConfig @@ -40,9 +40,9 @@ def __init__( cache expiration time, how often to call AppConfig to fetch latest configuration sdk_config: Optional[Config] Botocore Config object to pass during client initialization - envelope : str + envelope : Optional[str] JMESPath expression to pluck feature flags data from config - jmespath_options : Dict + jmespath_options : Optional[Dict] Alternative JMESPath options to be included when filtering expr """ super().__init__() diff --git a/aws_lambda_powertools/utilities/feature_flags/base.py b/aws_lambda_powertools/utilities/feature_flags/base.py index 1df90f19ac8..edb94c4f45d 100644 --- a/aws_lambda_powertools/utilities/feature_flags/base.py +++ b/aws_lambda_powertools/utilities/feature_flags/base.py @@ -19,27 +19,28 @@ def get_configuration(self) -> Dict[str, Any]: **Example** - ```python - { - "premium_features": { - "default": False, - "rules": { - "customer tier equals premium": { - "when_match": True, - "conditions": [ - { - "action": "EQUALS", - "key": "tier", - "value": "premium", - } - ], - } - }, + ```python + { + "premium_features": { + "default": False, + "rules": { + "customer tier equals premium": { + "when_match": True, + "conditions": [ + { + "action": "EQUALS", + "key": "tier", + "value": "premium", + } + ], + } }, - "feature_two": { - "default": False - } + }, + "feature_two": { + "default": False } + } + ``` """ return NotImplemented # pragma: no cover diff --git a/aws_lambda_powertools/utilities/feature_flags/feature_flags.py b/aws_lambda_powertools/utilities/feature_flags/feature_flags.py index a862baf61c2..3d913de98d4 100644 --- a/aws_lambda_powertools/utilities/feature_flags/feature_flags.py +++ b/aws_lambda_powertools/utilities/feature_flags/feature_flags.py @@ -115,28 +115,28 @@ def get_configuration(self) -> Union[Dict[str, Dict], Dict]: **Example** - ```python - { - "premium_features": { - "default": False, - "rules": { - "customer tier equals premium": { - "when_match": True, - "conditions": [ - { - "action": "EQUALS", - "key": "tier", - "value": "premium", - } - ], - } - }, + ```python + { + "premium_features": { + "default": False, + "rules": { + "customer tier equals premium": { + "when_match": True, + "conditions": [ + { + "action": "EQUALS", + "key": "tier", + "value": "premium", + } + ], + } }, - "feature_two": { - "default": False - } + }, + "feature_two": { + "default": False } - ``` + } + ``` """ # parse result conf as JSON, keep in cache for max age defined in store logger.debug(f"Fetching schema from registered store, store={self._store}") @@ -217,9 +217,9 @@ def get_enabled_features(self, *, context: Optional[Dict[str, Any]] = None) -> L **Example** - ```python - ["premium_features", "my_feature_two", "always_true_feature"] - ``` + ```python + ["premium_features", "my_feature_two", "always_true_feature"] + ``` Raises ------ diff --git a/aws_lambda_powertools/utilities/feature_flags/schema.py b/aws_lambda_powertools/utilities/feature_flags/schema.py index 3de7ac22363..6f2d2bf713c 100644 --- a/aws_lambda_powertools/utilities/feature_flags/schema.py +++ b/aws_lambda_powertools/utilities/feature_flags/schema.py @@ -42,7 +42,7 @@ class SchemaValidator(BaseValidator): * **default**: `bool`. Defines default feature value. This MUST be present * **rules**: `Dict[str, Dict]`. Rules object. This MIGHT be present - ```json + ```python { "my_feature": { "default": True, @@ -59,7 +59,7 @@ class SchemaValidator(BaseValidator): * **when_match**: `bool`. Defines value to return when context matches conditions * **conditions**: `List[Dict]`. Conditions object. This MUST be present - ```json + ```python { "my_feature": { "default": True, @@ -83,7 +83,7 @@ class SchemaValidator(BaseValidator): * **key**: `str`. Key in given context to perform operation * **value**: `Any`. Value in given context that should match action operation. - ```json + ```python { "my_feature": { "default": True,