# 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,
)
import raritan.rpc.auth.ldapsrv


# enumeration
class ServerType(Enumeration):
    idlType = "auth.ldapsrv.ServerType:1.0.0"
    values = ["ACTIVE_DIRECTORY", "OPEN_LDAP"]


ServerType.ACTIVE_DIRECTORY = ServerType(0)
ServerType.OPEN_LDAP = ServerType(1)

# structure
class ServerSettings(Structure):
    idlType = "auth.ldapsrv.ServerSettings:1.0.0"
    elements = [
        "id",
        "primaryServer",
        "secondaryServer",
        "adoptSettingsId",
        "type",
        "port",
        "sslPort",
        "useSSL",
        "forceTrustedCert",
        "certificate",
        "adsDomain",
        "useAnonymousBind",
        "bindDN",
        "bindPwd",
        "searchBaseDN",
        "loginNameAttr",
        "userEntryObjClass",
        "userSearchFilter",
    ]

    def __init__(
        self,
        id,
        primaryServer,
        secondaryServer,
        adoptSettingsId,
        type,
        port,
        sslPort,
        useSSL,
        forceTrustedCert,
        certificate,
        adsDomain,
        useAnonymousBind,
        bindDN,
        bindPwd,
        searchBaseDN,
        loginNameAttr,
        userEntryObjClass,
        userSearchFilter,
    ):
        typecheck.is_string(id, AssertionError)
        typecheck.is_string(primaryServer, AssertionError)
        typecheck.is_string(secondaryServer, AssertionError)
        typecheck.is_string(adoptSettingsId, AssertionError)
        typecheck.is_enum(type, raritan.rpc.auth.ldapsrv.ServerType, AssertionError)
        typecheck.is_int(port, AssertionError)
        typecheck.is_int(sslPort, AssertionError)
        typecheck.is_bool(useSSL, AssertionError)
        typecheck.is_bool(forceTrustedCert, AssertionError)
        typecheck.is_string(certificate, AssertionError)
        typecheck.is_string(adsDomain, AssertionError)
        typecheck.is_bool(useAnonymousBind, AssertionError)
        typecheck.is_string(bindDN, AssertionError)
        typecheck.is_string(bindPwd, AssertionError)
        typecheck.is_string(searchBaseDN, AssertionError)
        typecheck.is_string(loginNameAttr, AssertionError)
        typecheck.is_string(userEntryObjClass, AssertionError)
        typecheck.is_string(userSearchFilter, AssertionError)

        self.id = id
        self.primaryServer = primaryServer
        self.secondaryServer = secondaryServer
        self.adoptSettingsId = adoptSettingsId
        self.type = type
        self.port = port
        self.sslPort = sslPort
        self.useSSL = useSSL
        self.forceTrustedCert = forceTrustedCert
        self.certificate = certificate
        self.adsDomain = adsDomain
        self.useAnonymousBind = useAnonymousBind
        self.bindDN = bindDN
        self.bindPwd = bindPwd
        self.searchBaseDN = searchBaseDN
        self.loginNameAttr = loginNameAttr
        self.userEntryObjClass = userEntryObjClass
        self.userSearchFilter = userSearchFilter

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            id=json["id"],
            primaryServer=json["primaryServer"],
            secondaryServer=json["secondaryServer"],
            adoptSettingsId=json["adoptSettingsId"],
            type=raritan.rpc.auth.ldapsrv.ServerType.decode(json["type"]),
            port=json["port"],
            sslPort=json["sslPort"],
            useSSL=json["useSSL"],
            forceTrustedCert=json["forceTrustedCert"],
            certificate=json["certificate"],
            adsDomain=json["adsDomain"],
            useAnonymousBind=json["useAnonymousBind"],
            bindDN=json["bindDN"],
            bindPwd=json["bindPwd"],
            searchBaseDN=json["searchBaseDN"],
            loginNameAttr=json["loginNameAttr"],
            userEntryObjClass=json["userEntryObjClass"],
            userSearchFilter=json["userSearchFilter"],
        )
        return obj

    def encode(self):
        json = {}
        json["id"] = self.id
        json["primaryServer"] = self.primaryServer
        json["secondaryServer"] = self.secondaryServer
        json["adoptSettingsId"] = self.adoptSettingsId
        json["type"] = raritan.rpc.auth.ldapsrv.ServerType.encode(self.type)
        json["port"] = self.port
        json["sslPort"] = self.sslPort
        json["useSSL"] = self.useSSL
        json["forceTrustedCert"] = self.forceTrustedCert
        json["certificate"] = self.certificate
        json["adsDomain"] = self.adsDomain
        json["useAnonymousBind"] = self.useAnonymousBind
        json["bindDN"] = self.bindDN
        json["bindPwd"] = self.bindPwd
        json["searchBaseDN"] = self.searchBaseDN
        json["loginNameAttr"] = self.loginNameAttr
        json["userEntryObjClass"] = self.userEntryObjClass
        json["userSearchFilter"] = self.userSearchFilter
        return json
