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

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


# enumeration
class Type(Enumeration):
    idlType = "auth.Type:1.0.0"
    values = ["LOCAL", "RADIUS", "KERBEROS", "TACACS_PLUS", "LDAP"]


Type.LOCAL = Type(0)
Type.RADIUS = Type(1)
Type.KERBEROS = Type(2)
Type.TACACS_PLUS = Type(3)
Type.LDAP = Type(4)

# structure
class Policy(Structure):
    idlType = "auth.Policy:1.0.0"
    elements = ["type", "useLocalIfRemoteFailed"]

    def __init__(self, type, useLocalIfRemoteFailed):
        typecheck.is_enum(type, raritan.rpc.auth.Type, AssertionError)
        typecheck.is_bool(useLocalIfRemoteFailed, AssertionError)

        self.type = type
        self.useLocalIfRemoteFailed = useLocalIfRemoteFailed

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            type=raritan.rpc.auth.Type.decode(json["type"]),
            useLocalIfRemoteFailed=json["useLocalIfRemoteFailed"],
        )
        return obj

    def encode(self):
        json = {}
        json["type"] = raritan.rpc.auth.Type.encode(self.type)
        json["useLocalIfRemoteFailed"] = self.useLocalIfRemoteFailed
        return json


# interface
class AuthManager(Interface):
    idlType = "auth.AuthManager:1.0.0"

    ERR_UNSUPPORTED_TYPE = 1

    def getPolicy(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getPolicy", args)
        _ret_ = raritan.rpc.auth.Policy.decode(rsp["_ret_"], agent)
        typecheck.is_struct(_ret_, raritan.rpc.auth.Policy, DecodeException)
        return _ret_

    def setPolicy(self, p):
        agent = self.agent
        typecheck.is_struct(p, raritan.rpc.auth.Policy, AssertionError)
        args = {}
        args["p"] = raritan.rpc.auth.Policy.encode(p)
        rsp = agent.json_rpc(self.target, "setPolicy", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_


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

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


# interface
class RadiusManager(Interface):
    idlType = "auth.RadiusManager:1.0.0"

    ERR_INVALID_CFG = 1

    ERR_SERVER_UNSPECIFIED = 2

    ERR_INVALID_SHARED_SECRET = 3

    ERR_SERVER_UNREACHABLE = 4

    ERR_AUTHENTICATION_FAILED = 5

    ERR_NO_ROLES = 6

    ERR_NO_KNOWN_ROLES = 7

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

    def setRadiusServers(self, serverList):
        agent = self.agent
        for x0 in serverList:
            typecheck.is_struct(x0, raritan.rpc.radius.ServerSettings, AssertionError)
        args = {}
        args["serverList"] = [
            raritan.rpc.radius.ServerSettings.encode(x0) for x0 in serverList
        ]
        rsp = agent.json_rpc(self.target, "setRadiusServers", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_

    def testRadiusServer(self, username, password, settings):
        agent = self.agent
        typecheck.is_string(username, AssertionError)
        typecheck.is_string(password, AssertionError)
        typecheck.is_struct(settings, raritan.rpc.radius.ServerSettings, AssertionError)
        args = {}
        args["username"] = username
        args["password"] = password
        args["settings"] = raritan.rpc.radius.ServerSettings.encode(settings)
        rsp = agent.json_rpc(self.target, "testRadiusServer", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_


# 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/libldap_cfg/src/idl/LdapServerSettings.idl"
#

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

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

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


# interface
class LdapManager(Interface):
    idlType = "auth.LdapManager:1.0.1"

    def getLdapServers(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getLdapServers", args)
        _ret_ = [
            raritan.rpc.auth.ldapsrv.ServerSettings.decode(x0, agent)
            for x0 in rsp["_ret_"]
        ]
        for x0 in _ret_:
            typecheck.is_struct(
                x0, raritan.rpc.auth.ldapsrv.ServerSettings, DecodeException
            )
        return _ret_

    ERR_CYCLIC_DEP = 1

    ERR_INVALID_CFG = 2

    def setLdapServers(self, serverList):
        agent = self.agent
        for x0 in serverList:
            typecheck.is_struct(
                x0, raritan.rpc.auth.ldapsrv.ServerSettings, AssertionError
            )
        args = {}
        args["serverList"] = [
            raritan.rpc.auth.ldapsrv.ServerSettings.encode(x0) for x0 in serverList
        ]
        rsp = agent.json_rpc(self.target, "setLdapServers", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_

    ERR_SERVER_UNSPECIFIED = 1

    ERR_SERVER_UNREACHABLE = 3

    ERR_AUTHENTICATION_FAILED = 4

    ERR_NO_ROLES = 5

    ERR_NO_KNOWN_ROLES = 6

    def testLdapServer(self, username, password, settings):
        agent = self.agent
        typecheck.is_string(username, AssertionError)
        typecheck.is_string(password, AssertionError)
        typecheck.is_struct(
            settings, raritan.rpc.auth.ldapsrv.ServerSettings, AssertionError
        )
        args = {}
        args["username"] = username
        args["password"] = password
        args["settings"] = raritan.rpc.auth.ldapsrv.ServerSettings.encode(settings)
        rsp = agent.json_rpc(self.target, "testLdapServer", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_
