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

    static public readonly new TypeInfo typeInfo = new TypeInfo("rawcfg.RawConfiguration:1.0.1", null);

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

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

    public enum Status {
      UNKNOWN,
      UPLOAD_FAILED,
      UPDATE_PENDING,
      UPDATE_OK,
      UPDATE_FAILED,
    }

    public class GetStatusResult {
      public Com.Raritan.Idl.rawcfg.RawConfiguration_1_0_1.Status status;
      public System.DateTime timeStamp;
    }

    public GetStatusResult getStatus() {
      JsonObject _parameters = null;
      var _result = RpcCall("getStatus", _parameters);
      var _ret = new GetStatusResult();
      _ret.status = (Com.Raritan.Idl.rawcfg.RawConfiguration_1_0_1.Status)(int)_result["status"];
      _ret.timeStamp = new System.DateTime(_result["timeStamp"] * System.TimeSpan.TicksPerSecond + new System.DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc).Ticks, System.DateTimeKind.Utc).ToLocalTime();
      return _ret;
    }

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

    public AsyncRequest getStatus(AsyncRpcResponse<GetStatusResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getStatus", _parameters,
        _result => {
          try {
            var _ret = new GetStatusResult();
            _ret.status = (Com.Raritan.Idl.rawcfg.RawConfiguration_1_0_1.Status)(int)_result["status"];
            _ret.timeStamp = new System.DateTime(_result["timeStamp"] * System.TimeSpan.TicksPerSecond + new System.DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc).Ticks, System.DateTimeKind.Utc).ToLocalTime();
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class RawConfigDownloadedEvent : Com.Raritan.Idl._event.UserEvent {
      static public readonly new TypeInfo typeInfo = new TypeInfo("rawcfg.RawConfiguration_1_0_1.RawConfigDownloadedEvent:1.0.0", Com.Raritan.Idl._event.UserEvent.typeInfo);

    }

    public class RawConfigUpdatedEvent : Com.Raritan.Idl._event.UserEvent {
      static public readonly new TypeInfo typeInfo = new TypeInfo("rawcfg.RawConfiguration_1_0_1.RawConfigUpdatedEvent:1.0.0", Com.Raritan.Idl._event.UserEvent.typeInfo);

    }

  }
}
