# 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/Cfg.idl"
#

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


# structure
class KeyValue(Structure):
    idlType = "cfg.KeyValue:1.0.0"
    elements = ["key", "value"]

    def __init__(self, key, value):
        typecheck.is_string(key, AssertionError)
        typecheck.is_string(value, AssertionError)

        self.key = key
        self.value = value

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            key=json["key"],
            value=json["value"],
        )
        return obj

    def encode(self):
        json = {}
        json["key"] = self.key
        json["value"] = self.value
        return json


# interface
class Cfg(Interface):
    idlType = "cfg.Cfg:1.0.1"

    ERR_INVALID_KEY = 1

    ERR_INVALID_VALUE = 2

    ERR_NOT_ALLOWED_IN_FIPS_MODE = 3

    def getValues(self, keys):
        agent = self.agent
        for x0 in keys:
            typecheck.is_string(x0, AssertionError)
        args = {}
        args["keys"] = [x0 for x0 in keys]
        rsp = agent.json_rpc(self.target, "getValues", args)
        _ret_ = rsp["_ret_"]
        values = [x0 for x0 in rsp["values"]]
        typecheck.is_int(_ret_, DecodeException)
        for x0 in values:
            typecheck.is_string(x0, DecodeException)
        return (_ret_, values)

    def setValues(self, keyvaluepairs):
        agent = self.agent
        for x0 in keyvaluepairs:
            typecheck.is_struct(x0, raritan.rpc.cfg.KeyValue, AssertionError)
        args = {}
        args["keyvaluepairs"] = [
            raritan.rpc.cfg.KeyValue.encode(x0) for x0 in keyvaluepairs
        ]
        rsp = agent.json_rpc(self.target, "setValues", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_
