"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.SubnetIPReservationApi = void 0;
var _ApiClient = require("../ApiClient");
var _TaskReferenceApiResponse = _interopRequireDefault(require("../models/networking/v4/config/TaskReferenceApiResponse"));
var _IpReserveSpec = _interopRequireDefault(require("../models/networking/v4/config/IpReserveSpec"));
var _IpUnreserveSpec = _interopRequireDefault(require("../models/networking/v4/config/IpUnreserveSpec"));
var _ListSubnetReservedIpsApiResponse = _interopRequireDefault(require("../models/networking/v4/config/ListSubnetReservedIpsApiResponse"));
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 _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } /*
 * 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.
 *
 */
/**
 * SubnetIPReservation service.
 * @version 4.0.1
 * @class SubnetIPReservationApi
 */
var _headersToSkip = /*#__PURE__*/new WeakMap();
var SubnetIPReservationApi = exports.SubnetIPReservationApi = /*#__PURE__*/function () {
  /**
   * Constructs a new SubnetIPReservationApi. 
   * @alias module:api/SubnetIPReservationApi
   * @class
   * @param {module:ApiClient} [apiClient] Optional API client implementation to use,
   * default to {@link module:ApiClient#instance} if unspecified.
   */
  function SubnetIPReservationApi(apiClient) {
    _classCallCheck(this, SubnetIPReservationApi);
    _classPrivateFieldInitSpec(this, _headersToSkip, void 0);
    this.apiClient = apiClient || _ApiClient.ApiClient.instance;
    _classPrivateFieldSet(_headersToSkip, this, new Set());
    _classPrivateFieldGet(_headersToSkip, this).add('authorization');
    _classPrivateFieldGet(_headersToSkip, this).add('cookie');
    _classPrivateFieldGet(_headersToSkip, this).add('host');
    _classPrivateFieldGet(_headersToSkip, this).add('user-agent');
  }

  /**
   * List reserved IPs of a managed subnet
   * Get the list of reserved IP addresses on a particular managed subnet.
   * @param { String } subnetExtId The UUID of the subnet.
   * @param {Object} opts Optional parameters defined for the operation
   * @param { Number } opts.$page A URL query parameter that specifies the page number of the result set. It must be a positive integer between 0 and the maximum number of pages that are available for that resource. Any number out of this range might lead to no results.
    * @param { Number } opts.$limit A URL query parameter that specifies the total number of records returned in the result set.  Must be a positive integer between 1 and 100. Any number out of this range will lead to a validation error. If the limit is not provided, a default value of 50 records will be returned in the result set.
    * @param { String } opts.$filter A URL query parameter that allows clients to filter a collection of resources. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response. Expression specified with the $filter must conform to the [OData V4.01](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html) URL conventions.<br>
   * For example, filter '$filter=name eq 'karbon-ntnx-1.0' would filter the result on cluster name 'karbon-ntnx1.0', filter '$filter=startswith(name, 'C')' would filter on cluster name starting with 'C'.<br>
   * The filter can be applied to the following fields:<br>
   * - clientContext
   * @param { String } opts.$orderby A URL query parameter that allows clients to specify the sort criteria for the returned list of objects. Resources can be sorted in ascending order using asc or descending order using desc. If asc or desc are not specified, the resources will be sorted in ascending order by default. For example, '$orderby=templateName desc' would get all templates sorted by templateName in descending order.<br>
   * The orderby can be applied to the following fields:<br>
   * - ipv4Address
   * @param { String } opts.$select A URL query parameter that allows clients to request a specific set of properties for each entity or complex type. Expression specified with the $select must conform to the [OData V4.01](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html) URL conventions. If a $select expression consists of a single select item that is an asterisk (i.e., *), then all properties on the matching resource will be returned.
  - clientContext
  - extId
  - ipv4Address
  - links
  - tenantId
    * @param {Object} args Additional Arguments
   * @return {Promise<ListSubnetReservedIpsApiResponse>} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link ListSubnetReservedIpsApiResponse } and HTTP response
   */
  return _createClass(SubnetIPReservationApi, [{
    key: "listReservedIpsBySubnetId",
    value: function listReservedIpsBySubnetId(subnetExtId, opts) {
      var _this = this;
      var argMap = (arguments.length <= 2 ? 0 : arguments.length - 2) > 0 ? arguments.length <= 2 ? undefined : arguments[2] : {};
      opts = opts || {};
      var postBody = null;
      // verify the required parameter 'subnetExtId' is set
      if (typeof subnetExtId === 'undefined' || subnetExtId === null) {
        throw new Error("Missing the required parameter 'subnetExtId' when calling listReservedIpsBySubnetId");
      }
      var pathParams = {
        'subnetExtId': subnetExtId
      };
      var queryParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, opts.hasOwnProperty('$page') ? {
        '$page': opts['$page']
      } : {}), opts.hasOwnProperty('$limit') ? {
        '$limit': opts['$limit']
      } : {}), opts.hasOwnProperty('$filter') ? {
        '$filter': opts['$filter']
      } : {}), opts.hasOwnProperty('$orderby') ? {
        '$orderby': opts['$orderby']
      } : {}), opts.hasOwnProperty('$select') ? {
        '$select': opts['$select']
      } : {});
      var headersToInclude = {};
      Object.keys(argMap).forEach(function (header) {
        if (!_classPrivateFieldGet(_headersToSkip, _this).has(header.toLowerCase())) {
          headersToInclude[header] = argMap[header];
        }
      });
      var headerParams = _objectSpread({}, headersToInclude);
      var formParams = {};
      var authNames = ['apiKeyAuthScheme', 'basicAuthScheme'];
      var contentTypes = [];
      var accepts = ['application/json'];
      var returnType = _ListSubnetReservedIpsApiResponse["default"];
      return this.apiClient.callApi('/api/networking/v4.0/config/subnets/{subnetExtId}/reserved-ips', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType);
    }

    /**
     * Reserve IP addresses on a subnet
     * Reserve IP addresses on a subnet.
     * @param { Required<Pick<IpReserveSpec, 'reserveType'>> & Partial<IpReserveSpec> } body specification
     * @param { String } extId The UUID of the subnet.
     * @param {Object} args Additional Arguments
     * @return {Promise<ConfigTaskReferenceApiResponse>} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link ConfigTaskReferenceApiResponse } and HTTP response
     */
  }, {
    key: "reserveIpsBySubnetId",
    value: function reserveIpsBySubnetId(extId, body) {
      var _this2 = this;
      var argMap = (arguments.length <= 2 ? 0 : arguments.length - 2) > 0 ? arguments.length <= 2 ? undefined : arguments[2] : {};
      var postBody = null;
      if (body instanceof _IpReserveSpec["default"] && typeof body.toJson === 'function') {
        postBody = body.toJson();
      } else {
        postBody = body;
      }
      // verify the required parameter 'extId' is set
      if (typeof extId === 'undefined' || extId === null) {
        throw new Error("Missing the required parameter 'extId' when calling reserveIpsBySubnetId");
      }
      // verify the required parameter 'body' is set
      if (typeof postBody === 'undefined' || postBody === null) {
        throw new Error("Invalid body when calling reserveIpsBySubnetId");
      }
      var pathParams = {
        'extId': extId
      };
      var queryParams = {};
      var headersToInclude = {};
      Object.keys(argMap).forEach(function (header) {
        if (!_classPrivateFieldGet(_headersToSkip, _this2).has(header.toLowerCase())) {
          headersToInclude[header] = argMap[header];
        }
      });
      var headerParams = _objectSpread({}, headersToInclude);
      var formParams = {};
      _ApiClient.ApiClient.addEtagReferenceToHeader(body, headerParams);
      var authNames = ['apiKeyAuthScheme', 'basicAuthScheme'];
      var contentTypes = ['application/json'];
      var accepts = ['application/json'];
      var returnType = _TaskReferenceApiResponse["default"];
      return this.apiClient.callApi('/api/networking/v4.0/config/subnets/{extId}/addresses/$actions/reserve', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType);
    }

    /**
     * Unreserve IP addresses on a subnet
     * Unreserve IP addresses on a subnet.
     * @param { Required<Pick<IpUnreserveSpec, 'unreserveType'>> & Partial<IpUnreserveSpec> } body specification
     * @param { String } extId The UUID of the subnet.
     * @param {Object} args Additional Arguments
     * @return {Promise<ConfigTaskReferenceApiResponse>} a {@link https://www.promisejs.org/|Promise}, with an object containing data of type {@link ConfigTaskReferenceApiResponse } and HTTP response
     */
  }, {
    key: "unreserveIpsBySubnetId",
    value: function unreserveIpsBySubnetId(extId, body) {
      var _this3 = this;
      var argMap = (arguments.length <= 2 ? 0 : arguments.length - 2) > 0 ? arguments.length <= 2 ? undefined : arguments[2] : {};
      var postBody = null;
      if (body instanceof _IpUnreserveSpec["default"] && typeof body.toJson === 'function') {
        postBody = body.toJson();
      } else {
        postBody = body;
      }
      // verify the required parameter 'extId' is set
      if (typeof extId === 'undefined' || extId === null) {
        throw new Error("Missing the required parameter 'extId' when calling unreserveIpsBySubnetId");
      }
      // verify the required parameter 'body' is set
      if (typeof postBody === 'undefined' || postBody === null) {
        throw new Error("Invalid body when calling unreserveIpsBySubnetId");
      }
      var pathParams = {
        'extId': extId
      };
      var queryParams = {};
      var headersToInclude = {};
      Object.keys(argMap).forEach(function (header) {
        if (!_classPrivateFieldGet(_headersToSkip, _this3).has(header.toLowerCase())) {
          headersToInclude[header] = argMap[header];
        }
      });
      var headerParams = _objectSpread({}, headersToInclude);
      var formParams = {};
      _ApiClient.ApiClient.addEtagReferenceToHeader(body, headerParams);
      var authNames = ['apiKeyAuthScheme', 'basicAuthScheme'];
      var contentTypes = ['application/json'];
      var accepts = ['application/json'];
      var returnType = _TaskReferenceApiResponse["default"];
      return this.apiClient.callApi('/api/networking/v4.0/config/subnets/{extId}/addresses/$actions/unreserve', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType);
    }
  }], [{
    key: "ApiClient",
    get:
    /**
    * Make the default {@link ApiClient} class available for developers to be able to extend it and bring
    * their own fetch methods into the SDK
    */
    function get() {
      return _ApiClient.ApiClient;
    }
  }]);
}();