Skip to content

Commit 801c6b9

Browse files
committed
docs(schema): update rules to include JSON values; update image
1 parent c34b7ff commit 801c6b9

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

aws_lambda_powertools/utilities/feature_flags/schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class SchemaValidator(BaseValidator):
4949
A dictionary containing default value and rules for matching.
5050
The value MUST be an object and MIGHT contain the following members:
5151
52-
* **default**: Union[`bool`, `JSONType`]. Defines default feature value. This MUST be present
52+
* **default**: `Union[bool, JSONType]`. Defines default feature value. This MUST be present
5353
* **boolean_type**: bool. Defines whether feature has non-boolean value (`JSONType`). This MIGHT be present
5454
* **rules**: `Dict[str, Dict]`. Rules object. This MIGHT be present
5555
@@ -74,7 +74,7 @@ class SchemaValidator(BaseValidator):
7474
A dictionary with each rule and their conditions that a feature might have.
7575
The value MIGHT be present, and when defined it MUST contain the following members:
7676
77-
* **when_match**: Union[`bool`, `JSONType`]. Defines value to return when context matches conditions
77+
* **when_match**: `Union[bool, JSONType]`. Defines value to return when context matches conditions
7878
* **conditions**: `List[Dict]`. Conditions object. This MUST be present
7979
8080
```python
-69 KB
Binary file not shown.

docs/utilities/feature_flags.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,15 @@ A feature can simply have its name and a `default` value. This is either on or o
389389

390390
=== "minimal_schema.json"
391391

392-
```json hl_lines="2-3"
392+
```json hl_lines="2-3 6-7"
393393
{
394394
"global_feature": {
395395
"default": true
396-
}
396+
},
397+
"non_boolean_global_feature": {
398+
"default": {"group": "read-only"},
399+
"boolean_type": False
400+
},
397401
}
398402
```
399403

@@ -404,12 +408,12 @@ If you need more control and want to provide context such as user group, permiss
404408
When adding `rules` to a feature, they must contain:
405409

406410
1. A rule name as a key
407-
2. `when_match` boolean value that should be used when conditions match
411+
2. `when_match` boolean or JSON value that should be used when conditions match
408412
3. A list of `conditions` for evaluation
409413

410414
=== "feature_with_rules.json"
411415

412-
```json hl_lines="4-11"
416+
```json hl_lines="4-11 19-26"
413417
{
414418
"premium_feature": {
415419
"default": false,
@@ -425,6 +429,21 @@ When adding `rules` to a feature, they must contain:
425429
]
426430
}
427431
}
432+
},
433+
"non_boolean_premium_feature": {
434+
"default": [],
435+
"rules": {
436+
"customer tier equals premium": {
437+
"when_match": ["remove_limits", "remove_ads"],
438+
"conditions": [
439+
{
440+
"action": "EQUALS",
441+
"key": "tier",
442+
"value": "premium"
443+
}
444+
]
445+
}
446+
}
428447
}
429448
}
430449
```
@@ -474,9 +493,9 @@ Action | Equivalent expression
474493

475494
#### Rule engine flowchart
476495

477-
Now that you've seen all properties of a feature flag schema, this flowchart describes how the rule engines makes a decision on when to return `True` or `False`.
496+
Now that you've seen all properties of a feature flag schema, this flowchart describes how the rule engine decides what value to return.
478497

479-
![Rule engine ](../media/feat_flags_evaluation_workflow.png)
498+
![Rule engine ](../media/feature_flags_diagram.png)
480499

481500
### Adjusting in-memory cache
482501

0 commit comments

Comments
 (0)