#Generated by quicktype.io

# To use this code, make sure you
#
#     import json
#
# and then, to convert JSON from a string, do
#
#     result = RunPatternfromdict(json.loads(json_string))

from typing import List, Any, TypeVar, Callable, Type, cast


T = TypeVar("T")


def from_str(x: Any) -> str:
    assert isinstance(x, str)
    return x


def from_int(x: Any) -> int:
    assert isinstance(x, int) and not isinstance(x, bool)
    return x


def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
    assert isinstance(x, list)
    return [f(y) for y in x]


def to_class(c: Type[T], x: Any) -> dict:
    assert isinstance(x, c)
    return cast(Any, x).to_dict()


class RunPatternClass:
    file: str
    data: str
    id: str
    state: int
    zoneName: List[str]

    def __init__(self, state: int, zoneName: List[str], file: str = "", id: str = "", data: str = "") -> None:
        self.file = file
        self.data = data
        self.id = id
        self.state = state
        self.zoneName = zoneName

    @staticmethod
    def from_dict(obj: Any) -> 'RunPatternClass':
        assert isinstance(obj, dict)
        file = from_str(obj.get("file"))
        data = from_str(obj.get("data"))
        id = from_str(obj.get("id"))
        state = from_int(obj.get("state"))
        zoneName = from_list(from_str, obj.get("zoneName"))
        return RunPatternClass(file, data, id, state, zoneName)

    def to_dict(self) -> dict:
        result: dict = {'file': from_str(self.file)}
        result["data"] = from_str(self.data)
        result["id"] = from_str(self.id)
        result["state"] = from_int(self.state)
        result["zoneName"] = from_list(from_str, self.zoneName)
        return result


class RunPattern:
    cmd: str
    runPattern: RunPatternClass

    def __init__(self, cmd: str, runPattern: RunPatternClass) -> None:
        self.cmd = cmd
        self.runPattern = runPattern

    @staticmethod
    def from_dict(obj: Any) -> 'RunPattern':
        assert isinstance(obj, dict)
        cmd = from_str(obj.get("cmd"))
        runPattern = RunPatternClass.from_dict(obj.get("runPattern"))
        return RunPattern(cmd, runPattern)

    def to_dict(self) -> dict:
        result: dict = {'cmd': from_str(self.cmd)}
        result["runPattern"] = to_class(RunPatternClass, self.runPattern)
        return result


def RunPatternfromdict(s: Any) -> RunPattern:
    return RunPattern.from_dict(s)


def RunPatterntodict(x: RunPattern) -> Any:
    return to_class(RunPattern, x)
