// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright 2025 Raritan Inc. All rights reserved.
//
// This file was generated by IdlC from Snmp.idl.

using System;
using System.Linq;
using LightJson;
using Com.Raritan.Idl;
using Com.Raritan.JsonRpc;
using Com.Raritan.Util;

#pragma warning disable 0108, 0219, 0414, 1591

namespace Com.Raritan.Idl.devsettings {
  public class Snmp_1_0_2 : ObjectProxy {

    static public readonly new TypeInfo typeInfo = new TypeInfo("devsettings.Snmp:1.0.2", null);

    public Snmp_1_0_2(Agent agent, string rid, TypeInfo ti) : base(agent, rid, ti) {}
    public Snmp_1_0_2(Agent agent, string rid) : this(agent, rid, typeInfo) {}

    public static new Snmp_1_0_2 StaticCast(ObjectProxy proxy) {
      return proxy == null ? null : new Snmp_1_0_2(proxy.Agent, proxy.Rid, proxy.StaticTypeInfo);
    }

    public const int ERR_INVALID_PARAMS = 1;

    public class Configuration : ICloneable {
      public object Clone() {
        Configuration copy = new Configuration();
        copy.v2enable = this.v2enable;
        copy.v3enable = this.v3enable;
        copy.readComm = this.readComm;
        copy.writeComm = this.writeComm;
        copy.sysContact = this.sysContact;
        copy.sysName = this.sysName;
        copy.sysLocation = this.sysLocation;
        return copy;
      }

      public LightJson.JsonObject Encode() {
        LightJson.JsonObject json = new LightJson.JsonObject();
        json["v2enable"] = this.v2enable;
        json["v3enable"] = this.v3enable;
        json["readComm"] = this.readComm;
        json["writeComm"] = this.writeComm;
        json["sysContact"] = this.sysContact;
        json["sysName"] = this.sysName;
        json["sysLocation"] = this.sysLocation;
        return json;
      }

      public static Configuration Decode(LightJson.JsonObject json, Agent agent) {
        Configuration inst = new Configuration();
        inst.v2enable = (bool)json["v2enable"];
        inst.v3enable = (bool)json["v3enable"];
        inst.readComm = (string)json["readComm"];
        inst.writeComm = (string)json["writeComm"];
        inst.sysContact = (string)json["sysContact"];
        inst.sysName = (string)json["sysName"];
        inst.sysLocation = (string)json["sysLocation"];
        return inst;
      }

      public bool v2enable = false;
      public bool v3enable = false;
      public string readComm = "";
      public string writeComm = "";
      public string sysContact = "";
      public string sysName = "";
      public string sysLocation = "";
    }

    public class ConfigurationChangedEvent : Com.Raritan.Idl.idl.Event {
      static public readonly new TypeInfo typeInfo = new TypeInfo("devsettings.Snmp_1_0_2.ConfigurationChangedEvent:1.0.0", Com.Raritan.Idl.idl.Event.typeInfo);

      public string userName = "";
      public string ipAddr = "";
      public Com.Raritan.Idl.devsettings.Snmp_1_0_2.Configuration oldConfig = new Com.Raritan.Idl.devsettings.Snmp_1_0_2.Configuration();
      public Com.Raritan.Idl.devsettings.Snmp_1_0_2.Configuration newConfig = new Com.Raritan.Idl.devsettings.Snmp_1_0_2.Configuration();
    }

    public class GetConfigurationResult {
      public Com.Raritan.Idl.devsettings.Snmp_1_0_2.Configuration _ret_;
    }

    public GetConfigurationResult getConfiguration() {
      JsonObject _parameters = null;
      var _result = RpcCall("getConfiguration", _parameters);
      var _ret = new GetConfigurationResult();
      _ret._ret_ = Com.Raritan.Idl.devsettings.Snmp_1_0_2.Configuration.Decode(_result["_ret_"], agent);
      return _ret;
    }

    public AsyncRequest getConfiguration(AsyncRpcResponse<GetConfigurationResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getConfiguration(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getConfiguration(AsyncRpcResponse<GetConfigurationResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getConfiguration", _parameters,
        _result => {
          try {
            var _ret = new GetConfigurationResult();
            _ret._ret_ = Com.Raritan.Idl.devsettings.Snmp_1_0_2.Configuration.Decode(_result["_ret_"], agent);
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class SetConfigurationResult {
      public int _ret_;
    }

    public SetConfigurationResult setConfiguration(Com.Raritan.Idl.devsettings.Snmp_1_0_2.Configuration cfg) {
      var _parameters = new LightJson.JsonObject();
      _parameters["cfg"] = cfg.Encode();

      var _result = RpcCall("setConfiguration", _parameters);
      var _ret = new SetConfigurationResult();
      _ret._ret_ = (int)_result["_ret_"];
      return _ret;
    }

    public AsyncRequest setConfiguration(Com.Raritan.Idl.devsettings.Snmp_1_0_2.Configuration cfg, AsyncRpcResponse<SetConfigurationResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return setConfiguration(cfg, rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest setConfiguration(Com.Raritan.Idl.devsettings.Snmp_1_0_2.Configuration cfg, AsyncRpcResponse<SetConfigurationResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      var _parameters = new LightJson.JsonObject();
      try {
        _parameters["cfg"] = cfg.Encode();
      } catch (Exception e) {
        if (fail != null) fail(e);
      }

      return RpcCall("setConfiguration", _parameters,
        _result => {
          try {
            var _ret = new SetConfigurationResult();
            _ret._ret_ = (int)_result["_ret_"];
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetV3EngineIdResult {
      public string _ret_;
    }

    public GetV3EngineIdResult getV3EngineId() {
      JsonObject _parameters = null;
      var _result = RpcCall("getV3EngineId", _parameters);
      var _ret = new GetV3EngineIdResult();
      _ret._ret_ = (string)_result["_ret_"];
      return _ret;
    }

    public AsyncRequest getV3EngineId(AsyncRpcResponse<GetV3EngineIdResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getV3EngineId(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getV3EngineId(AsyncRpcResponse<GetV3EngineIdResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getV3EngineId", _parameters,
        _result => {
          try {
            var _ret = new GetV3EngineIdResult();
            _ret._ret_ = (string)_result["_ret_"];
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

  }
}
