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

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


# interface
class Cascading(Interface):
    idlType = "cascading.Cascading:1.0.1"

    ERR_NOT_AVAILABLE = 1

    ERR_NOT_SUPPORTED_ON_SLAVE = 2

    # enumeration
    class Type(Enumeration):
        idlType = "cascading.Cascading.Type:1.0.0"
        values = ["USB_MULTI_IP", "USB_SINGLE_IP_NAT"]

    Type.USB_MULTI_IP = Type(0)
    Type.USB_SINGLE_IP_NAT = Type(1)

    # structure
    class ProtocolMapping(Structure):
        idlType = "cascading.Cascading.ProtocolMapping:1.0.0"
        elements = ["appProtoId", "appProtoName", "transportProtoName"]

        def __init__(self, appProtoId, appProtoName, transportProtoName):
            typecheck.is_int(appProtoId, AssertionError)
            typecheck.is_string(appProtoName, AssertionError)
            typecheck.is_string(transportProtoName, AssertionError)

            self.appProtoId = appProtoId
            self.appProtoName = appProtoName
            self.transportProtoName = transportProtoName

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                appProtoId=json["appProtoId"],
                appProtoName=json["appProtoName"],
                transportProtoName=json["transportProtoName"],
            )
            return obj

        def encode(self):
            json = {}
            json["appProtoId"] = self.appProtoId
            json["appProtoName"] = self.appProtoName
            json["transportProtoName"] = self.transportProtoName
            return json

    def setType(self, type):
        agent = self.agent
        typecheck.is_enum(type, raritan.rpc.cascading.Cascading.Type, AssertionError)
        args = {}
        args["type"] = raritan.rpc.cascading.Cascading.Type.encode(type)
        rsp = agent.json_rpc(self.target, "setType", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_

    def getType(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getType", args)
        _ret_ = rsp["_ret_"]
        type = raritan.rpc.cascading.Cascading.Type.decode(rsp["type"])
        typecheck.is_int(_ret_, DecodeException)
        typecheck.is_enum(type, raritan.rpc.cascading.Cascading.Type, DecodeException)
        return (_ret_, type)

    def getIndex(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getIndex", args)
        idx = rsp["idx"]
        typecheck.is_int(idx, DecodeException)
        return idx

    def getMasterIpAddress(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getMasterIpAddress", args)
        masterIpAddress = rsp["masterIpAddress"]
        typecheck.is_string(masterIpAddress, DecodeException)
        return masterIpAddress

    def getMasterIpV6Address(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getMasterIpV6Address", args)
        masterIpV6Address = rsp["masterIpV6Address"]
        typecheck.is_string(masterIpV6Address, DecodeException)
        return masterIpV6Address

    def getProtocolMappings(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getProtocolMappings", args)
        mappings = [
            raritan.rpc.cascading.Cascading.ProtocolMapping.decode(x0, agent)
            for x0 in rsp["mappings"]
        ]
        for x0 in mappings:
            typecheck.is_struct(
                x0, raritan.rpc.cascading.Cascading.ProtocolMapping, DecodeException
            )
        return mappings
