// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright 2020 Raritan Inc. All rights reserved.
//
// This file was generated by IdlC from EDevice.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.pdumodel {
  public class EDevice : ObjectProxy {

    static public readonly new TypeInfo typeInfo = new TypeInfo("pdumodel.EDevice:1.0.0", null);

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

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

    public class GetParentsResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.pdumodel.EDevice> _ret_;
    }

    public GetParentsResult getParents() {
      JsonObject _parameters = null;
      var _result = RpcCall("getParents", _parameters);
      var _ret = new GetParentsResult();
      _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.pdumodel.EDevice>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.pdumodel.EDevice.StaticCast(ObjectProxy.Decode(_value, agent))));
      return _ret;
    }

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

    public AsyncRequest getParents(AsyncRpcResponse<GetParentsResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getParents", _parameters,
        _result => {
          try {
            var _ret = new GetParentsResult();
            _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.pdumodel.EDevice>(_result["_ret_"].AsJsonArray.Select(
              _value => Com.Raritan.Idl.pdumodel.EDevice.StaticCast(ObjectProxy.Decode(_value, agent))));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetChildrenResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.pdumodel.EDevice> _ret_;
    }

    public GetChildrenResult getChildren() {
      JsonObject _parameters = null;
      var _result = RpcCall("getChildren", _parameters);
      var _ret = new GetChildrenResult();
      _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.pdumodel.EDevice>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.pdumodel.EDevice.StaticCast(ObjectProxy.Decode(_value, agent))));
      return _ret;
    }

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

    public AsyncRequest getChildren(AsyncRpcResponse<GetChildrenResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getChildren", _parameters,
        _result => {
          try {
            var _ret = new GetChildrenResult();
            _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.pdumodel.EDevice>(_result["_ret_"].AsJsonArray.Select(
              _value => Com.Raritan.Idl.pdumodel.EDevice.StaticCast(ObjectProxy.Decode(_value, agent))));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

  }
}
