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

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

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

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

    public class GetFeaturePortsResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.portsmodel.Port> _ret_;
    }

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

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

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

    public class GetAuxiliaryPortsResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.portsmodel.Port> _ret_;
    }

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

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

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

  }
}
