diff --git a/aws_lambda_powertools/utilities/feature_flags/appconfig.py b/aws_lambda_powertools/utilities/feature_flags/appconfig.py index 794530eee47..4f0ad3e4418 100644 --- a/aws_lambda_powertools/utilities/feature_flags/appconfig.py +++ b/aws_lambda_powertools/utilities/feature_flags/appconfig.py @@ -1,3 +1,7 @@ +"""Advanced feature flags utility +!!! abstract "Usage Documentation" + [`Feature Flags`](../../utilities/feature_flags.md) +""" from __future__ import annotations import logging diff --git a/aws_lambda_powertools/utilities/feature_flags/base.py b/aws_lambda_powertools/utilities/feature_flags/base.py index cd2d65fa211..03394f8ced3 100644 --- a/aws_lambda_powertools/utilities/feature_flags/base.py +++ b/aws_lambda_powertools/utilities/feature_flags/base.py @@ -28,7 +28,8 @@ def get_configuration(self) -> dict[str, Any]: dict[str, Any] parsed JSON dictionary - **Example** + Example + ------- ```python { diff --git a/aws_lambda_powertools/utilities/feature_flags/comparators.py b/aws_lambda_powertools/utilities/feature_flags/comparators.py index 47354f26e73..0d836d19b11 100644 --- a/aws_lambda_powertools/utilities/feature_flags/comparators.py +++ b/aws_lambda_powertools/utilities/feature_flags/comparators.py @@ -56,6 +56,8 @@ def compare_time_range(context_value: Any, condition_value: dict) -> bool: end_time = current_time.replace(hour=int(end_hour), minute=int(end_min)) if int(end_hour) < int(start_hour): + # In normal circumstances, we need to assert **both** conditions + """ # When the end hour is smaller than start hour, it means we are crossing a day's boundary. # In this case we need to assert that current_time is **either** on one side or the other side of the boundary # @@ -69,10 +71,9 @@ def compare_time_range(context_value: Any, condition_value: dict) -> bool: # │ │ │ # └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ # │ - + """ return (start_time <= current_time) or (current_time <= end_time) else: - # In normal circumstances, we need to assert **both** conditions return start_time <= current_time <= end_time diff --git a/aws_lambda_powertools/utilities/feature_flags/feature_flags.py b/aws_lambda_powertools/utilities/feature_flags/feature_flags.py index ae0cae6d31c..6fb8d51753a 100644 --- a/aws_lambda_powertools/utilities/feature_flags/feature_flags.py +++ b/aws_lambda_powertools/utilities/feature_flags/feature_flags.py @@ -179,7 +179,8 @@ def get_configuration(self) -> dict: dict[str, dict] parsed JSON dictionary - **Example** + Example + ------- ```python { @@ -251,7 +252,7 @@ def evaluate(self, *, name: str, context: dict[str, Any] | None = None, default: Can be boolean or any JSON values for non-boolean features. - Examples + Example -------- ```python @@ -343,7 +344,8 @@ def get_enabled_features(self, *, context: dict[str, Any] | None = None) -> list list[str] list of all feature names that either matches context or have True as default - **Example** + Example + ------- ```python ["premium_features", "my_feature_two", "always_true_feature"] @@ -400,8 +402,8 @@ def validation_exception_handler(self, exc_class: Exception | list[Exception]): exc_class : Exception | list[Exception] One or more exceptions to catch - Examples - -------- + Example + ------- ```python feature_flags = FeatureFlags(store=app_config) diff --git a/docs/api_doc/feature_flags/appconfig.md b/docs/api_doc/feature_flags/appconfig.md new file mode 100644 index 00000000000..fad198ef15c --- /dev/null +++ b/docs/api_doc/feature_flags/appconfig.md @@ -0,0 +1,2 @@ + +::: aws_lambda_powertools.utilities.feature_flags.appconfig diff --git a/docs/api_doc/feature_flags/base.md b/docs/api_doc/feature_flags/base.md new file mode 100644 index 00000000000..aef629bac52 --- /dev/null +++ b/docs/api_doc/feature_flags/base.md @@ -0,0 +1,2 @@ + +::: aws_lambda_powertools.utilities.feature_flags.base diff --git a/docs/api_doc/feature_flags/comparators.md b/docs/api_doc/feature_flags/comparators.md new file mode 100644 index 00000000000..0286336529e --- /dev/null +++ b/docs/api_doc/feature_flags/comparators.md @@ -0,0 +1,2 @@ + +::: aws_lambda_powertools.utilities.feature_flags.comparators diff --git a/docs/api_doc/feature_flags/exceptions.md b/docs/api_doc/feature_flags/exceptions.md new file mode 100644 index 00000000000..ad9d20a7731 --- /dev/null +++ b/docs/api_doc/feature_flags/exceptions.md @@ -0,0 +1,2 @@ + +::: aws_lambda_powertools.utilities.feature_flags.exceptions diff --git a/docs/api_doc/feature_flags/feature_flags.md b/docs/api_doc/feature_flags/feature_flags.md new file mode 100644 index 00000000000..dacffe23460 --- /dev/null +++ b/docs/api_doc/feature_flags/feature_flags.md @@ -0,0 +1,2 @@ + +::: aws_lambda_powertools.utilities.feature_flags.feature_flags diff --git a/docs/api_doc/feature_flags/schema.md b/docs/api_doc/feature_flags/schema.md new file mode 100644 index 00000000000..7998f31f4f2 --- /dev/null +++ b/docs/api_doc/feature_flags/schema.md @@ -0,0 +1,2 @@ + +::: aws_lambda_powertools.utilities.feature_flags.schema diff --git a/mkdocs.yml b/mkdocs.yml index 5aea420d82a..1238a20fe3d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -63,6 +63,13 @@ nav: # - Casual to regular contributor: contributing/tracks/casual_regular_contributor.md # - Customer to advocate: contributing/tracks/customer_advocate.md - API Documentation: + - Feature Flags: + - AppConfig: api_doc/feature_flags/appconfig.md + - Base: api_doc/feature_flags/base.md + - Comparators: api_doc/feature_flags/comparators.md + - Exceptions: api_doc/feature_flags/exceptions.md + - Feature flags: api_doc/feature_flags/feature_flags.md + - Schema: api_doc/feature_flags/schema.md - Idempotency: - Base: api_doc/idempotency/base.md - Config: api_doc/idempotency/config.md