"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _IPAddress = _interopRequireDefault(require("../../../common/v1/config/IPAddress"));
var _TenantAwareModel = _interopRequireDefault(require("../../../common/v1/config/TenantAwareModel"));
var _ExternalizableAbstractModel = _interopRequireDefault(require("../../../common/v1/response/ExternalizableAbstractModel"));
var _ExternalSubnet = _interopRequireDefault(require("./ExternalSubnet"));
var _IPSubnet = _interopRequireDefault(require("./IPSubnet"));
var _NetworkingBaseModel = _interopRequireDefault(require("./NetworkingBaseModel"));
var _Vpc2 = _interopRequireDefault(require("./Vpc"));
var _VpcDhcpOptions = _interopRequireDefault(require("./VpcDhcpOptions"));
var _VpcType = _interopRequireDefault(require("./VpcType"));
var _ValidationScopes = _interopRequireDefault(require("../../../validation/ValidationScopes"));
var _ValidationUtils = _interopRequireDefault(require("../../../../utils/ValidationUtils"));
var _ValidationError = _interopRequireDefault(require("../../../validation/ValidationError"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /*
 * Nutanix Networking APIs
 *
 * OpenAPI spec version: 4.0.1
 *
 * NOTE: This class is auto generated by the Open API Dev Platform.
 *
 * Open API Dev Platform Codegen version: 16.9.0.8546-RELEASE
 *
 * Do not edit the class manually.
 *
 */
/**
 * The VpcProjection model module.
 * @module Ntnx/VpcProjection
 * @version 4.0.1
 * @class VpcProjection
 * @extends Vpc
 */
var VpcProjection = exports["default"] = /*#__PURE__*/function (_Vpc) {
  /**
   * Constructs a new <code>VpcProjection</code>.
   * @alias module:Ntnx/VpcProjection
   * @extends module:Ntnx/Vpc
  */
  function VpcProjection() {
    var _this;
    _classCallCheck(this, VpcProjection);
    _this = _callSuper(this, VpcProjection);
    _this.$objectType = "networking.v4.config.VpcProjection";
    /** @type {object<string, any>} */
    _this.$reserved = {
      '$fv': "v4.r0"
    };
    /** @type {object<string, any>} */
    _this.$unknownFields = {};
    return _this;
  }

  /**
   * Constructs a <code>VpcProjection</code> from a plain JavaScript object, optionally creating a new instance.
   * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not.
   * @param {Object} data The plain JavaScript object bearing properties of interest.
   * @param {module:Ntnx/VpcProjection} obj Optional instance to populate.
   * @param callFromChild {Boolean} Flag to recognise calling instance
   * @return {module:Ntnx/VpcProjection} The populated <code>VpcProjection</code> instance.
   */
  _inherits(VpcProjection, _Vpc);
  return _createClass(VpcProjection, [{
    key: "validate",
    value: function validate(scope, properties) {
      var _this2 = this;
      var propList = [];
      if (arguments.length === 0 || arguments.length === 1 && arguments[0] instanceof _ValidationScopes["default"]) {
        //cases validate() and validate(scope)
        propList = [];
      } else if (arguments.length === 1) {
        //case validate(properties)
        propList = arguments[0];
        scope = null;
      } else {
        //case validate(scope, properties)
        propList = arguments[1];
      }
      var res = [];
      var err = null;
      propList.forEach(function (property) {
        err = _this2.validateProperty(property, scope);
        if (err) {
          res.push(err);
        }
      });
      return new Promise(function (resolve, reject) {
        if (res.length !== 0) {
          reject(err);
        } else {
          resolve();
        }
      });
    }
  }, {
    key: "validateProperty",
    value: function validateProperty(scope, property) {
      return new _ValidationError["default"](property, "no such property exists");
    }
  }], [{
    key: "constructFromObject",
    value: function constructFromObject(data) {
      var obj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
      var callFromChild = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
      var items, item, i, itemArr, discriminator;
      if (data) {
        obj = obj || new VpcProjection();
        _Vpc2["default"].constructFromObject(data, obj, true);
        if (!callFromChild) {
          obj.$unknownFields = _objectSpread({}, data.$unknownFields);
          for (var property in data) {
            // Check if the `property` is not already present in `obj` keys, either in snake_case or camelCase,
            // as the model's fields are generated in camelCase, but the server might return snake_case (e.g., due to standards like OIDC).
            // Also, ensure the `property` does not start with '$' and end with 'ItemDiscriminator'.
            // If all conditions are true, add the `property` from `data` to `obj.$unknownFields` as an unknown field.
            if (!Object.keys(obj).includes(property) && !Object.keys(obj).includes(this.snakeToCamel(property)) && !(property[0] === "$" && property.endsWith("ItemDiscriminator"))) {
              obj.$unknownFields[property] = data[property];
            }
          }
        }
      }
      return obj;
    }

    /**
    * Converts a given snake_case string to camelCase.
    * @param {string} snakeStr - The input string in snake_case format.
    * @returns {string} - The converted string in camelCase format.
    */
  }, {
    key: "snakeToCamel",
    value: function snakeToCamel(snakeStr) {
      return snakeStr.replace(/(_\w)/g, function (match) {
        return match[1].toUpperCase();
      });
    }
  }]);
}(_Vpc2["default"]);