@@ -114,13 +114,15 @@ def get_configuration(self) -> Dict[str, Any]:
114114 self ._schema_validator .validate_json_schema (schema )
115115 return schema
116116
117- def get_feature_toggle (self , * , feature_name : str , rules_context : Dict [str , Any ], value_if_missing : bool ) -> bool :
117+ def get_feature_toggle (
118+ self , * , feature_name : str , rules_context : Optional [Dict [str , Any ]] = None , value_if_missing : bool
119+ ) -> bool :
118120 """get a feature toggle boolean value. Value is calculated according to a set of rules and conditions.
119121 see below for explanation.
120122
121123 Args:
122124 feature_name (str): feature name that you wish to fetch
123- rules_context (Dict[str, Any]): dict of attributes that you would like to match the rules
125+ rules_context (Optional[ Dict[str, Any] ]): dict of attributes that you would like to match the rules
124126 against, can be {'tenant_id: 'X', 'username':' 'Y', 'region': 'Z'} etc.
125127 value_if_missing (bool): this will be the returned value in case the feature toggle doesn't exist in
126128 the schema or there has been an error while fetching the
@@ -134,6 +136,9 @@ def get_feature_toggle(self, *, feature_name: str, rules_context: Dict[str, Any]
134136 the defined feature
135137 3. feature exists and a rule matches -> rule_default_value of rule is returned
136138 """
139+ if rules_context is None :
140+ rules_context = {}
141+
137142 try :
138143 toggles_dict : Dict [str , Any ] = self .get_configuration ()
139144 except ConfigurationException :
@@ -166,17 +171,19 @@ def get_feature_toggle(self, *, feature_name: str, rules_context: Dict[str, Any]
166171 rules = rules_list ,
167172 )
168173
169- def get_all_enabled_feature_toggles (self , * , rules_context : Dict [str , Any ]) -> List [str ]:
174+ def get_all_enabled_feature_toggles (self , * , rules_context : Optional [ Dict [str , Any ]] = None ) -> List [str ]:
170175 """Get all enabled feature toggles while also taking into account rule_context (when a feature has defined rules)
171176
172177 Args:
173- rules_context (Dict[str, Any]): dict of attributes that you would like to match the rules
178+ rules_context (Optional[ Dict[str, Any] ]): dict of attributes that you would like to match the rules
174179 against, can be {'tenant_id: 'X', 'username':' 'Y', 'region': 'Z'} etc.
175180
176181 Returns:
177182 List[str]: a list of all features name that are enabled by also taking into account
178183 rule_context (when a feature has defined rules)
179184 """
185+ if rules_context is None :
186+ rules_context = {}
180187 try :
181188 toggles_dict : Dict [str , Any ] = self .get_configuration ()
182189 except ConfigurationException :
0 commit comments