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

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


# interface
class ModelPush(Interface):
    idlType = "modelpush.ModelPush:1.0.0"

    ERR_INVALID_PARAMS = 1

    # structure
    class Configuration(Structure):
        idlType = "modelpush.ModelPush.Configuration:1.0.0"
        elements = [
            "enabled",
            "interval",
            "host",
            "port",
            "path",
            "useHttps",
            "caCert",
            "useAuth",
            "username",
            "password",
        ]

        def __init__(
            self,
            enabled,
            interval,
            host,
            port,
            path,
            useHttps,
            caCert,
            useAuth,
            username,
            password,
        ):
            typecheck.is_bool(enabled, AssertionError)
            typecheck.is_int(interval, AssertionError)
            typecheck.is_string(host, AssertionError)
            typecheck.is_int(port, AssertionError)
            typecheck.is_string(path, AssertionError)
            typecheck.is_bool(useHttps, AssertionError)
            typecheck.is_string(caCert, AssertionError)
            typecheck.is_bool(useAuth, AssertionError)
            typecheck.is_string(username, AssertionError)
            typecheck.is_string(password, AssertionError)

            self.enabled = enabled
            self.interval = interval
            self.host = host
            self.port = port
            self.path = path
            self.useHttps = useHttps
            self.caCert = caCert
            self.useAuth = useAuth
            self.username = username
            self.password = password

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                enabled=json["enabled"],
                interval=json["interval"],
                host=json["host"],
                port=json["port"],
                path=json["path"],
                useHttps=json["useHttps"],
                caCert=json["caCert"],
                useAuth=json["useAuth"],
                username=json["username"],
                password=json["password"],
            )
            return obj

        def encode(self):
            json = {}
            json["enabled"] = self.enabled
            json["interval"] = self.interval
            json["host"] = self.host
            json["port"] = self.port
            json["path"] = self.path
            json["useHttps"] = self.useHttps
            json["caCert"] = self.caCert
            json["useAuth"] = self.useAuth
            json["username"] = self.username
            json["password"] = self.password
            return json

    def getConfiguration(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getConfiguration", args)
        _ret_ = raritan.rpc.modelpush.ModelPush.Configuration.decode(
            rsp["_ret_"], agent
        )
        typecheck.is_struct(
            _ret_, raritan.rpc.modelpush.ModelPush.Configuration, DecodeException
        )
        return _ret_

    def setConfiguration(self, cfg):
        agent = self.agent
        typecheck.is_struct(
            cfg, raritan.rpc.modelpush.ModelPush.Configuration, AssertionError
        )
        args = {}
        args["cfg"] = raritan.rpc.modelpush.ModelPush.Configuration.encode(cfg)
        rsp = agent.json_rpc(self.target, "setConfiguration", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_
