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

  public class IpFw_2_0_0 : ICloneable {
    public object Clone() {
      IpFw_2_0_0 copy = new IpFw_2_0_0();
      copy.enabled = this.enabled;
      copy.defaultPolicyIn = this.defaultPolicyIn;
      copy.defaultPolicyOut = this.defaultPolicyOut;
      copy.ruleSetIn = this.ruleSetIn;
      copy.ruleSetOut = this.ruleSetOut;
      return copy;
    }

    public LightJson.JsonObject Encode() {
      LightJson.JsonObject json = new LightJson.JsonObject();
      json["enabled"] = this.enabled;
      json["defaultPolicyIn"] = (int)this.defaultPolicyIn;
      json["defaultPolicyOut"] = (int)this.defaultPolicyOut;
      json["ruleSetIn"] = new JsonArray(this.ruleSetIn.Select(
        _value => (JsonValue)(_value.Encode())));
      json["ruleSetOut"] = new JsonArray(this.ruleSetOut.Select(
        _value => (JsonValue)(_value.Encode())));
      return json;
    }

    public static IpFw_2_0_0 Decode(LightJson.JsonObject json, Agent agent) {
      IpFw_2_0_0 inst = new IpFw_2_0_0();
      inst.enabled = (bool)json["enabled"];
      inst.defaultPolicyIn = (Com.Raritan.Idl.security.IpfwPolicy)(int)json["defaultPolicyIn"];
      inst.defaultPolicyOut = (Com.Raritan.Idl.security.IpfwPolicy)(int)json["defaultPolicyOut"];
      inst.ruleSetIn = new System.Collections.Generic.List<Com.Raritan.Idl.security.IpfwRule>(json["ruleSetIn"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.security.IpfwRule.Decode(_value, agent)));
      inst.ruleSetOut = new System.Collections.Generic.List<Com.Raritan.Idl.security.IpfwRule>(json["ruleSetOut"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.security.IpfwRule.Decode(_value, agent)));
      return inst;
    }

    public bool enabled = false;
    public Com.Raritan.Idl.security.IpfwPolicy defaultPolicyIn = Com.Raritan.Idl.security.IpfwPolicy.ACCEPT;
    public Com.Raritan.Idl.security.IpfwPolicy defaultPolicyOut = Com.Raritan.Idl.security.IpfwPolicy.ACCEPT;
    public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.security.IpfwRule> ruleSetIn = new System.Collections.Generic.List<Com.Raritan.Idl.security.IpfwRule>();
    public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.security.IpfwRule> ruleSetOut = new System.Collections.Generic.List<Com.Raritan.Idl.security.IpfwRule>();
  }
}
