Skip to content

Commit

Permalink
docs(feature-toggles): correct docs and typing (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Brewer authored Aug 5, 2021
1 parent 92d4a6d commit 4eb4aaa
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 48 deletions.
6 changes: 3 additions & 3 deletions aws_lambda_powertools/utilities/feature_flags/appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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__()
Expand Down
39 changes: 20 additions & 19 deletions aws_lambda_powertools/utilities/feature_flags/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
46 changes: 23 additions & 23 deletions aws_lambda_powertools/utilities/feature_flags/feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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
------
Expand Down
6 changes: 3 additions & 3 deletions aws_lambda_powertools/utilities/feature_flags/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 4eb4aaa

Please sign in to comment.