# Do NOT edit this file!
# It was generated by IdlC class idl.json.python.ProxyAsnVisitor.

#
# Section generated from "/home/nb/builds/MEGA/px2-3.0.0-3.0.9-branch-20140613-none-release-none-pdu-raritan/fwcomponents/mkdist/tmp/px2_final/libisys/src/idl/DiagLogSettings.idl"
#

import raritan.rpc
from raritan.rpc import (
    Interface,
    Structure,
    ValueObject,
    Enumeration,
    typecheck,
    DecodeException,
)
import raritan.rpc.diag


# interface
class DiagLogSettings(Interface):
    idlType = "diag.DiagLogSettings:1.0.0"

    # enumeration
    class LogLevel(Enumeration):
        idlType = "diag.DiagLogSettings.LogLevel:1.0.0"
        values = [
            "LOG_LEVEL_NONE",
            "LOG_LEVEL_ERR",
            "LOG_LEVEL_WARN",
            "LOG_LEVEL_INFO",
            "LOG_LEVEL_DEBUG",
            "LOG_LEVEL_TRACE",
        ]

    LogLevel.LOG_LEVEL_NONE = LogLevel(0)
    LogLevel.LOG_LEVEL_ERR = LogLevel(1)
    LogLevel.LOG_LEVEL_WARN = LogLevel(2)
    LogLevel.LOG_LEVEL_INFO = LogLevel(3)
    LogLevel.LOG_LEVEL_DEBUG = LogLevel(4)
    LogLevel.LOG_LEVEL_TRACE = LogLevel(5)

    # structure
    class LogLevelEntry(Structure):
        idlType = "diag.DiagLogSettings.LogLevelEntry:1.0.0"
        elements = ["ctxName", "logLevel"]

        def __init__(self, ctxName, logLevel):
            typecheck.is_string(ctxName, AssertionError)
            typecheck.is_enum(
                logLevel, raritan.rpc.diag.DiagLogSettings.LogLevel, AssertionError
            )

            self.ctxName = ctxName
            self.logLevel = logLevel

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                ctxName=json["ctxName"],
                logLevel=raritan.rpc.diag.DiagLogSettings.LogLevel.decode(
                    json["logLevel"]
                ),
            )
            return obj

        def encode(self):
            json = {}
            json["ctxName"] = self.ctxName
            json["logLevel"] = raritan.rpc.diag.DiagLogSettings.LogLevel.encode(
                self.logLevel
            )
            return json

    ERR_NONE = 0

    ERR_UNKNOWN_LOG_CONTEXT_NAME = 1

    ERR_UNKNOWN_LOG_LEVEL = 2

    def resetLogLevelsForAllCtxNames(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "resetLogLevelsForAllCtxNames", args)

    def getLogLevelsForAllCtxNames(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getLogLevelsForAllCtxNames", args)
        _ret_ = [
            raritan.rpc.diag.DiagLogSettings.LogLevelEntry.decode(x0, agent)
            for x0 in rsp["_ret_"]
        ]
        for x0 in _ret_:
            typecheck.is_struct(
                x0, raritan.rpc.diag.DiagLogSettings.LogLevelEntry, DecodeException
            )
        return _ret_

    def setLogLevelForAllCtxNames(self, logLevel):
        agent = self.agent
        typecheck.is_enum(
            logLevel, raritan.rpc.diag.DiagLogSettings.LogLevel, AssertionError
        )
        args = {}
        args["logLevel"] = raritan.rpc.diag.DiagLogSettings.LogLevel.encode(logLevel)
        rsp = agent.json_rpc(self.target, "setLogLevelForAllCtxNames", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_

    def getLogLevelByCtxName(self, ctxName):
        agent = self.agent
        typecheck.is_string(ctxName, AssertionError)
        args = {}
        args["ctxName"] = ctxName
        rsp = agent.json_rpc(self.target, "getLogLevelByCtxName", args)
        _ret_ = rsp["_ret_"]
        logLevel = raritan.rpc.diag.DiagLogSettings.LogLevel.decode(rsp["logLevel"])
        typecheck.is_int(_ret_, DecodeException)
        typecheck.is_enum(
            logLevel, raritan.rpc.diag.DiagLogSettings.LogLevel, DecodeException
        )
        return (_ret_, logLevel)

    def setLogLevelByCtxName(self, ctxName, logLevel):
        agent = self.agent
        typecheck.is_string(ctxName, AssertionError)
        typecheck.is_enum(
            logLevel, raritan.rpc.diag.DiagLogSettings.LogLevel, AssertionError
        )
        args = {}
        args["ctxName"] = ctxName
        args["logLevel"] = raritan.rpc.diag.DiagLogSettings.LogLevel.encode(logLevel)
        rsp = agent.json_rpc(self.target, "setLogLevelByCtxName", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_
