fix: ValueError if monitor authMethod is None
This commit is contained in:
parent
144e426ed9
commit
ce6f25d604
1 changed files with 7 additions and 4 deletions
|
@ -49,15 +49,18 @@ def int_to_bool(data, keys) -> None:
|
||||||
data[key] = True if data[key] == 1 else False
|
data[key] = True if data[key] == 1 else False
|
||||||
|
|
||||||
|
|
||||||
def parse_value(data, key, type_) -> None:
|
def parse_value(data, key, type_, default=None) -> None:
|
||||||
if not data:
|
if not data:
|
||||||
return
|
return
|
||||||
if isinstance(data, list):
|
if isinstance(data, list):
|
||||||
for d in data:
|
for d in data:
|
||||||
parse_value(d, key, type_)
|
parse_value(d, key, type_, default)
|
||||||
else:
|
else:
|
||||||
if key in data:
|
if key in data:
|
||||||
|
if data[key] is not None:
|
||||||
data[key] = type_(data[key])
|
data[key] = type_(data[key])
|
||||||
|
elif default is not None:
|
||||||
|
data[key] = default
|
||||||
|
|
||||||
|
|
||||||
# monitor
|
# monitor
|
||||||
|
@ -70,7 +73,7 @@ def parse_monitor_type(data) -> None:
|
||||||
|
|
||||||
|
|
||||||
def parse_auth_method(data) -> None:
|
def parse_auth_method(data) -> None:
|
||||||
parse_value(data, "authMethod", AuthMethod)
|
parse_value(data, "authMethod", AuthMethod, AuthMethod.NONE)
|
||||||
|
|
||||||
|
|
||||||
# notification
|
# notification
|
||||||
|
|
Loading…
Reference in a new issue