You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.2 KiB
49 lines
1.2 KiB
# Copyright (C) 2005-2024 Splunk Inc. All Rights Reserved.
|
|
|
|
import json
|
|
|
|
try:
|
|
from types import SimpleNamespace as Namespace
|
|
except ImportError:
|
|
# Python 2.x fallback
|
|
from argparse import Namespace # noqa
|
|
|
|
|
|
class FeatureFlaggingState(object):
|
|
"""
|
|
This class provides semantics of a feature flagging state object
|
|
stored in the KV Store.
|
|
"""
|
|
|
|
def __init__(self, dict):
|
|
self.suite = None
|
|
self.__dict__.update(dict)
|
|
assert self.suite, "Suite name should be set"
|
|
|
|
@classmethod
|
|
def from_suite(cls, suite):
|
|
return cls({"suite": suite})
|
|
|
|
@classmethod
|
|
def from_dict(cls, dict):
|
|
"""
|
|
De-Serializer: Converts dict object into FeatureFlaggingState object
|
|
"""
|
|
return FeatureFlaggingState(dict)
|
|
|
|
def get_suite(self):
|
|
return self.suite
|
|
|
|
def set_suite(self, suite):
|
|
self.suite = suite
|
|
|
|
def to_json(self):
|
|
"""
|
|
Serializer: Converts the FeatureFlaggingState object into dict object
|
|
"""
|
|
json_str = json.dumps(self, default=lambda x: x.__dict__)
|
|
return json.loads(json_str)
|
|
|
|
def to_dict(self):
|
|
return self.__dict__
|