Skip to content

Commit 4eb4aaa

Browse files
author
Michael Brewer
authored
docs(feature-toggles): correct docs and typing (#588)
1 parent 92d4a6d commit 4eb4aaa

File tree

4 files changed

+49
-48
lines changed

4 files changed

+49
-48
lines changed

aws_lambda_powertools/utilities/feature_flags/appconfig.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(
2323
name: str,
2424
cache_seconds: int,
2525
sdk_config: Optional[Config] = None,
26-
envelope: str = "",
26+
envelope: Optional[str] = "",
2727
jmespath_options: Optional[Dict] = None,
2828
):
2929
"""This class fetches JSON schemas from AWS AppConfig
@@ -40,9 +40,9 @@ def __init__(
4040
cache expiration time, how often to call AppConfig to fetch latest configuration
4141
sdk_config: Optional[Config]
4242
Botocore Config object to pass during client initialization
43-
envelope : str
43+
envelope : Optional[str]
4444
JMESPath expression to pluck feature flags data from config
45-
jmespath_options : Dict
45+
jmespath_options : Optional[Dict]
4646
Alternative JMESPath options to be included when filtering expr
4747
"""
4848
super().__init__()

aws_lambda_powertools/utilities/feature_flags/base.py

+20-19
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,28 @@ def get_configuration(self) -> Dict[str, Any]:
1919
2020
**Example**
2121
22-
```python
23-
{
24-
"premium_features": {
25-
"default": False,
26-
"rules": {
27-
"customer tier equals premium": {
28-
"when_match": True,
29-
"conditions": [
30-
{
31-
"action": "EQUALS",
32-
"key": "tier",
33-
"value": "premium",
34-
}
35-
],
36-
}
37-
},
22+
```python
23+
{
24+
"premium_features": {
25+
"default": False,
26+
"rules": {
27+
"customer tier equals premium": {
28+
"when_match": True,
29+
"conditions": [
30+
{
31+
"action": "EQUALS",
32+
"key": "tier",
33+
"value": "premium",
34+
}
35+
],
36+
}
3837
},
39-
"feature_two": {
40-
"default": False
41-
}
38+
},
39+
"feature_two": {
40+
"default": False
4241
}
42+
}
43+
```
4344
"""
4445
return NotImplemented # pragma: no cover
4546

aws_lambda_powertools/utilities/feature_flags/feature_flags.py

+23-23
Original file line numberDiff line numberDiff line change
@@ -115,28 +115,28 @@ def get_configuration(self) -> Union[Dict[str, Dict], Dict]:
115115
116116
**Example**
117117
118-
```python
119-
{
120-
"premium_features": {
121-
"default": False,
122-
"rules": {
123-
"customer tier equals premium": {
124-
"when_match": True,
125-
"conditions": [
126-
{
127-
"action": "EQUALS",
128-
"key": "tier",
129-
"value": "premium",
130-
}
131-
],
132-
}
133-
},
118+
```python
119+
{
120+
"premium_features": {
121+
"default": False,
122+
"rules": {
123+
"customer tier equals premium": {
124+
"when_match": True,
125+
"conditions": [
126+
{
127+
"action": "EQUALS",
128+
"key": "tier",
129+
"value": "premium",
130+
}
131+
],
132+
}
134133
},
135-
"feature_two": {
136-
"default": False
137-
}
134+
},
135+
"feature_two": {
136+
"default": False
138137
}
139-
```
138+
}
139+
```
140140
"""
141141
# parse result conf as JSON, keep in cache for max age defined in store
142142
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
217217
218218
**Example**
219219
220-
```python
221-
["premium_features", "my_feature_two", "always_true_feature"]
222-
```
220+
```python
221+
["premium_features", "my_feature_two", "always_true_feature"]
222+
```
223223
224224
Raises
225225
------

aws_lambda_powertools/utilities/feature_flags/schema.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class SchemaValidator(BaseValidator):
4242
* **default**: `bool`. Defines default feature value. This MUST be present
4343
* **rules**: `Dict[str, Dict]`. Rules object. This MIGHT be present
4444
45-
```json
45+
```python
4646
{
4747
"my_feature": {
4848
"default": True,
@@ -59,7 +59,7 @@ class SchemaValidator(BaseValidator):
5959
* **when_match**: `bool`. Defines value to return when context matches conditions
6060
* **conditions**: `List[Dict]`. Conditions object. This MUST be present
6161
62-
```json
62+
```python
6363
{
6464
"my_feature": {
6565
"default": True,
@@ -83,7 +83,7 @@ class SchemaValidator(BaseValidator):
8383
* **key**: `str`. Key in given context to perform operation
8484
* **value**: `Any`. Value in given context that should match action operation.
8585
86-
```json
86+
```python
8787
{
8888
"my_feature": {
8989
"default": True,

0 commit comments

Comments
 (0)