@nutanix-scratch/objects-js-client 4.0.1-alpha.2 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/LICENSE.txt +202 -49
  2. package/README.md +39 -27
  3. package/dist/Ntnx-Objects-js-client-prod.js +1 -1
  4. package/dist/Ntnx-Objects-js-client.js +227 -96
  5. package/dist/es/ApiClient.d.ts +8 -1
  6. package/dist/es/ApiClient.js +249 -189
  7. package/dist/es/Paginable.d.ts +1 -1
  8. package/dist/es/Paginable.js +9 -9
  9. package/dist/es/apis/objectstores-endpoints.d.ts +66 -95
  10. package/dist/es/apis/objectstores-endpoints.js +205 -170
  11. package/dist/es/apis/stats-endpoints.d.ts +69 -0
  12. package/dist/es/apis/stats-endpoints.js +154 -0
  13. package/dist/es/index.d.ts +43 -21
  14. package/dist/es/index.js +135 -47
  15. package/dist/es/models/common/v1/config/FQDN.d.ts +24 -20
  16. package/dist/es/models/common/v1/config/FQDN.js +56 -21
  17. package/dist/es/models/common/v1/config/Flag.d.ts +32 -26
  18. package/dist/es/models/common/v1/config/Flag.js +65 -21
  19. package/dist/es/models/common/v1/config/IPAddress.d.ts +42 -26
  20. package/dist/es/models/common/v1/config/IPAddress.js +53 -21
  21. package/dist/es/models/common/v1/config/IPv4Address.d.ts +40 -26
  22. package/dist/es/models/common/v1/config/IPv4Address.js +64 -23
  23. package/dist/es/models/common/v1/config/IPv6Address.d.ts +40 -26
  24. package/dist/es/models/common/v1/config/IPv6Address.js +64 -23
  25. package/dist/es/models/common/v1/config/KVPair.d.ts +35 -26
  26. package/dist/es/models/common/v1/config/KVPair.js +70 -24
  27. package/dist/es/models/common/v1/config/MapOfStringWrapper.d.ts +58 -0
  28. package/dist/es/models/common/v1/config/MapOfStringWrapper.js +275 -0
  29. package/dist/es/models/common/v1/config/Message.d.ts +41 -38
  30. package/dist/es/models/common/v1/config/Message.js +57 -25
  31. package/dist/es/models/common/v1/config/MessageSeverity.js +7 -7
  32. package/dist/es/models/common/v1/config/Metadata.d.ts +46 -44
  33. package/dist/es/models/common/v1/config/Metadata.js +65 -27
  34. package/dist/es/models/common/v1/config/TenantAwareModel.d.ts +22 -20
  35. package/dist/es/models/common/v1/config/TenantAwareModel.js +51 -19
  36. package/dist/es/models/common/v1/response/ApiLink.d.ts +28 -26
  37. package/dist/es/models/common/v1/response/ApiLink.js +53 -21
  38. package/dist/es/models/common/v1/response/ApiResponseMetadata.d.ts +79 -44
  39. package/dist/es/models/common/v1/response/ApiResponseMetadata.js +71 -27
  40. package/dist/es/models/common/v1/response/ExternalizableAbstractModel.d.ts +24 -18
  41. package/dist/es/models/common/v1/response/ExternalizableAbstractModel.js +71 -31
  42. package/dist/es/models/common/v1/stats/DownSamplingOperator.d.ts +19 -0
  43. package/dist/es/models/common/v1/stats/DownSamplingOperator.js +109 -0
  44. package/dist/es/models/common/v1/stats/TimeIntValuePair.d.ts +64 -0
  45. package/dist/es/models/common/v1/stats/TimeIntValuePair.js +313 -0
  46. package/dist/es/models/objects/v4/config/Certificate.d.ts +146 -0
  47. package/dist/es/models/objects/v4/{operations → config}/Certificate.js +184 -43
  48. package/dist/es/models/objects/v4/{operations → config}/CertificateProjection.d.ts +2 -1
  49. package/dist/{lib/models/objects/v4/operations → es/models/objects/v4/config}/CertificateProjection.js +41 -17
  50. package/dist/es/models/objects/v4/config/CreateCertificateApiResponse.d.ts +101 -0
  51. package/dist/es/models/objects/v4/config/CreateCertificateApiResponse.js +343 -0
  52. package/dist/es/models/objects/v4/config/CreateObjectstoreApiResponse.d.ts +99 -0
  53. package/dist/{lib/models/objects/v4/operations/TaskReferenceApiResponse.js → es/models/objects/v4/config/CreateObjectstoreApiResponse.js} +86 -54
  54. package/dist/es/models/objects/v4/config/DeleteObjectstoreApiResponse.d.ts +99 -0
  55. package/dist/es/models/objects/v4/config/DeleteObjectstoreApiResponse.js +343 -0
  56. package/dist/es/models/objects/v4/config/GetCaApiResponse.d.ts +98 -0
  57. package/dist/es/models/objects/v4/{operations/TaskReferenceApiResponse.js → config/GetCaApiResponse.js} +88 -57
  58. package/dist/es/models/objects/v4/config/GetCertificateApiResponse.d.ts +99 -0
  59. package/dist/es/models/objects/v4/{operations/CertificateApiResponse.js → config/GetCertificateApiResponse.js} +88 -56
  60. package/dist/es/models/objects/v4/config/GetObjectstoreApiResponse.d.ts +101 -0
  61. package/dist/{lib/models/objects/v4/operations/ObjectstoreApiResponse.js → es/models/objects/v4/config/GetObjectstoreApiResponse.js} +89 -57
  62. package/dist/es/models/objects/v4/config/ListCertificatesApiResponse.d.ts +100 -0
  63. package/dist/es/models/objects/v4/{operations/CertificateListApiResponse.js → config/ListCertificatesApiResponse.js} +89 -57
  64. package/dist/es/models/objects/v4/config/ListObjectstoresApiResponse.d.ts +100 -0
  65. package/dist/es/models/objects/v4/{operations/ObjectstoreListApiResponse.js → config/ListObjectstoresApiResponse.js} +92 -60
  66. package/dist/es/models/objects/v4/config/ObjectStore.d.ts +313 -0
  67. package/dist/es/models/objects/v4/{operations/Objectstore.js → config/ObjectStore.js} +213 -157
  68. package/dist/es/models/objects/v4/config/ObjectStoreProjection.d.ts +174 -0
  69. package/dist/{lib/models/objects/v4/operations/ObjectstoreProjection.js → es/models/objects/v4/config/ObjectStoreProjection.js} +211 -65
  70. package/dist/es/models/objects/v4/{operations/StateEnum.d.ts → config/State.d.ts} +6 -6
  71. package/dist/es/models/objects/v4/config/State.js +133 -0
  72. package/dist/es/models/objects/v4/config/UpdateObjectstoreApiResponse.d.ts +99 -0
  73. package/dist/es/models/objects/v4/config/UpdateObjectstoreApiResponse.js +343 -0
  74. package/dist/es/models/objects/v4/error/AppMessage.d.ts +57 -48
  75. package/dist/es/models/objects/v4/error/AppMessage.js +61 -29
  76. package/dist/es/models/objects/v4/error/ErrorResponse.d.ts +23 -19
  77. package/dist/es/models/objects/v4/error/ErrorResponse.js +62 -25
  78. package/dist/es/models/objects/v4/error/SchemaValidationError.d.ts +53 -43
  79. package/dist/es/models/objects/v4/error/SchemaValidationError.js +62 -29
  80. package/dist/es/models/objects/v4/error/SchemaValidationErrorMessage.d.ts +34 -32
  81. package/dist/es/models/objects/v4/error/SchemaValidationErrorMessage.js +55 -23
  82. package/dist/es/models/objects/v4/stats/GetObjectstoreStatsApiResponse.d.ts +99 -0
  83. package/dist/es/models/objects/v4/stats/GetObjectstoreStatsApiResponse.js +343 -0
  84. package/dist/es/models/objects/v4/stats/ObjectstoreStats.d.ts +423 -0
  85. package/dist/es/models/objects/v4/stats/ObjectstoreStats.js +1425 -0
  86. package/dist/es/models/objects/v4/stats/TimeFloatValuePair.d.ts +64 -0
  87. package/dist/es/models/objects/v4/stats/TimeFloatValuePair.js +313 -0
  88. package/dist/es/models/prism/v4/config/TaskReference.d.ts +22 -20
  89. package/dist/es/models/prism/v4/config/TaskReference.js +55 -20
  90. package/dist/es/models/validation/ValidationError.js +5 -5
  91. package/dist/es/utils/ValidationUtils.js +5 -5
  92. package/dist/lib/ApiClient.d.ts +8 -1
  93. package/dist/lib/ApiClient.js +249 -189
  94. package/dist/lib/Paginable.d.ts +1 -1
  95. package/dist/lib/Paginable.js +9 -9
  96. package/dist/lib/apis/objectstores-endpoints.d.ts +66 -95
  97. package/dist/lib/apis/objectstores-endpoints.js +205 -170
  98. package/dist/lib/apis/stats-endpoints.d.ts +69 -0
  99. package/dist/lib/apis/stats-endpoints.js +154 -0
  100. package/dist/lib/index.d.ts +43 -21
  101. package/dist/lib/index.js +135 -47
  102. package/dist/lib/models/common/v1/config/FQDN.d.ts +24 -20
  103. package/dist/lib/models/common/v1/config/FQDN.js +56 -21
  104. package/dist/lib/models/common/v1/config/Flag.d.ts +32 -26
  105. package/dist/lib/models/common/v1/config/Flag.js +65 -21
  106. package/dist/lib/models/common/v1/config/IPAddress.d.ts +42 -26
  107. package/dist/lib/models/common/v1/config/IPAddress.js +53 -21
  108. package/dist/lib/models/common/v1/config/IPv4Address.d.ts +40 -26
  109. package/dist/lib/models/common/v1/config/IPv4Address.js +64 -23
  110. package/dist/lib/models/common/v1/config/IPv6Address.d.ts +40 -26
  111. package/dist/lib/models/common/v1/config/IPv6Address.js +64 -23
  112. package/dist/lib/models/common/v1/config/KVPair.d.ts +35 -26
  113. package/dist/lib/models/common/v1/config/KVPair.js +70 -24
  114. package/dist/lib/models/common/v1/config/MapOfStringWrapper.d.ts +58 -0
  115. package/dist/lib/models/common/v1/config/MapOfStringWrapper.js +275 -0
  116. package/dist/lib/models/common/v1/config/Message.d.ts +41 -38
  117. package/dist/lib/models/common/v1/config/Message.js +57 -25
  118. package/dist/lib/models/common/v1/config/MessageSeverity.js +7 -7
  119. package/dist/lib/models/common/v1/config/Metadata.d.ts +46 -44
  120. package/dist/lib/models/common/v1/config/Metadata.js +65 -27
  121. package/dist/lib/models/common/v1/config/TenantAwareModel.d.ts +22 -20
  122. package/dist/lib/models/common/v1/config/TenantAwareModel.js +51 -19
  123. package/dist/lib/models/common/v1/response/ApiLink.d.ts +28 -26
  124. package/dist/lib/models/common/v1/response/ApiLink.js +53 -21
  125. package/dist/lib/models/common/v1/response/ApiResponseMetadata.d.ts +79 -44
  126. package/dist/lib/models/common/v1/response/ApiResponseMetadata.js +71 -27
  127. package/dist/lib/models/common/v1/response/ExternalizableAbstractModel.d.ts +24 -18
  128. package/dist/lib/models/common/v1/response/ExternalizableAbstractModel.js +71 -31
  129. package/dist/lib/models/common/v1/stats/DownSamplingOperator.d.ts +19 -0
  130. package/dist/lib/models/common/v1/stats/DownSamplingOperator.js +109 -0
  131. package/dist/lib/models/common/v1/stats/TimeIntValuePair.d.ts +64 -0
  132. package/dist/lib/models/common/v1/stats/TimeIntValuePair.js +313 -0
  133. package/dist/lib/models/objects/v4/config/Certificate.d.ts +146 -0
  134. package/dist/lib/models/objects/v4/{operations → config}/Certificate.js +184 -43
  135. package/dist/lib/models/objects/v4/{operations → config}/CertificateProjection.d.ts +2 -1
  136. package/dist/{es/models/objects/v4/operations → lib/models/objects/v4/config}/CertificateProjection.js +41 -17
  137. package/dist/lib/models/objects/v4/config/CreateCertificateApiResponse.d.ts +101 -0
  138. package/dist/lib/models/objects/v4/config/CreateCertificateApiResponse.js +343 -0
  139. package/dist/lib/models/objects/v4/config/CreateObjectstoreApiResponse.d.ts +99 -0
  140. package/dist/lib/models/objects/v4/config/CreateObjectstoreApiResponse.js +343 -0
  141. package/dist/lib/models/objects/v4/config/DeleteObjectstoreApiResponse.d.ts +99 -0
  142. package/dist/lib/models/objects/v4/config/DeleteObjectstoreApiResponse.js +343 -0
  143. package/dist/lib/models/objects/v4/config/GetCaApiResponse.d.ts +98 -0
  144. package/dist/lib/models/objects/v4/{operations/CertificateApiResponse.js → config/GetCaApiResponse.js} +88 -57
  145. package/dist/lib/models/objects/v4/config/GetCertificateApiResponse.d.ts +99 -0
  146. package/dist/lib/models/objects/v4/config/GetCertificateApiResponse.js +343 -0
  147. package/dist/lib/models/objects/v4/config/GetObjectstoreApiResponse.d.ts +101 -0
  148. package/dist/{es/models/objects/v4/operations/ObjectstoreApiResponse.js → lib/models/objects/v4/config/GetObjectstoreApiResponse.js} +89 -57
  149. package/dist/lib/models/objects/v4/config/ListCertificatesApiResponse.d.ts +100 -0
  150. package/dist/lib/models/objects/v4/{operations/CertificateListApiResponse.js → config/ListCertificatesApiResponse.js} +89 -57
  151. package/dist/lib/models/objects/v4/config/ListObjectstoresApiResponse.d.ts +100 -0
  152. package/dist/lib/models/objects/v4/{operations/ObjectstoreListApiResponse.js → config/ListObjectstoresApiResponse.js} +92 -60
  153. package/dist/lib/models/objects/v4/config/ObjectStore.d.ts +313 -0
  154. package/dist/lib/models/objects/v4/{operations/Objectstore.js → config/ObjectStore.js} +213 -157
  155. package/dist/lib/models/objects/v4/config/ObjectStoreProjection.d.ts +174 -0
  156. package/dist/{es/models/objects/v4/operations/ObjectstoreProjection.js → lib/models/objects/v4/config/ObjectStoreProjection.js} +211 -65
  157. package/dist/lib/models/objects/v4/{operations/StateEnum.d.ts → config/State.d.ts} +6 -6
  158. package/dist/lib/models/objects/v4/config/State.js +133 -0
  159. package/dist/lib/models/objects/v4/config/UpdateObjectstoreApiResponse.d.ts +99 -0
  160. package/dist/lib/models/objects/v4/config/UpdateObjectstoreApiResponse.js +343 -0
  161. package/dist/lib/models/objects/v4/error/AppMessage.d.ts +57 -48
  162. package/dist/lib/models/objects/v4/error/AppMessage.js +61 -29
  163. package/dist/lib/models/objects/v4/error/ErrorResponse.d.ts +23 -19
  164. package/dist/lib/models/objects/v4/error/ErrorResponse.js +62 -25
  165. package/dist/lib/models/objects/v4/error/SchemaValidationError.d.ts +53 -43
  166. package/dist/lib/models/objects/v4/error/SchemaValidationError.js +62 -29
  167. package/dist/lib/models/objects/v4/error/SchemaValidationErrorMessage.d.ts +34 -32
  168. package/dist/lib/models/objects/v4/error/SchemaValidationErrorMessage.js +55 -23
  169. package/dist/lib/models/objects/v4/stats/GetObjectstoreStatsApiResponse.d.ts +99 -0
  170. package/dist/lib/models/objects/v4/stats/GetObjectstoreStatsApiResponse.js +343 -0
  171. package/dist/lib/models/objects/v4/stats/ObjectstoreStats.d.ts +423 -0
  172. package/dist/lib/models/objects/v4/stats/ObjectstoreStats.js +1425 -0
  173. package/dist/lib/models/objects/v4/stats/TimeFloatValuePair.d.ts +64 -0
  174. package/dist/lib/models/objects/v4/stats/TimeFloatValuePair.js +313 -0
  175. package/dist/lib/models/prism/v4/config/TaskReference.d.ts +22 -20
  176. package/dist/lib/models/prism/v4/config/TaskReference.js +55 -20
  177. package/dist/lib/models/validation/ValidationError.js +5 -5
  178. package/dist/lib/utils/ValidationUtils.js +5 -5
  179. package/package.json +1 -1
  180. package/dist/es/models/objects/v4/operations/Certificate.d.ts +0 -78
  181. package/dist/es/models/objects/v4/operations/CertificateApiResponse.d.ts +0 -59
  182. package/dist/es/models/objects/v4/operations/CertificateListApiResponse.d.ts +0 -59
  183. package/dist/es/models/objects/v4/operations/Objectstore.d.ts +0 -242
  184. package/dist/es/models/objects/v4/operations/ObjectstoreApiResponse.d.ts +0 -59
  185. package/dist/es/models/objects/v4/operations/ObjectstoreListApiResponse.d.ts +0 -59
  186. package/dist/es/models/objects/v4/operations/ObjectstoreProjection.d.ts +0 -50
  187. package/dist/es/models/objects/v4/operations/StateEnum.js +0 -145
  188. package/dist/es/models/objects/v4/operations/TaskReferenceApiResponse.d.ts +0 -59
  189. package/dist/lib/models/objects/v4/operations/Certificate.d.ts +0 -78
  190. package/dist/lib/models/objects/v4/operations/CertificateApiResponse.d.ts +0 -59
  191. package/dist/lib/models/objects/v4/operations/CertificateListApiResponse.d.ts +0 -59
  192. package/dist/lib/models/objects/v4/operations/Objectstore.d.ts +0 -242
  193. package/dist/lib/models/objects/v4/operations/ObjectstoreApiResponse.d.ts +0 -59
  194. package/dist/lib/models/objects/v4/operations/ObjectstoreListApiResponse.d.ts +0 -59
  195. package/dist/lib/models/objects/v4/operations/ObjectstoreProjection.d.ts +0 -50
  196. package/dist/lib/models/objects/v4/operations/StateEnum.js +0 -145
  197. package/dist/lib/models/objects/v4/operations/TaskReferenceApiResponse.d.ts +0 -59
@@ -3,7 +3,7 @@
3
3
  * application to use this class directly - the *Api and model classes provide the public API for the service. The
4
4
  * contents of this file should be regarded as internal but are documented for completeness.
5
5
  * @module ApiClient
6
- * @version 4.0.1-alpha-2
6
+ * @version 4.0.1
7
7
  */
8
8
  export class ApiClient {
9
9
  /**
@@ -83,6 +83,12 @@ export class ApiClient {
83
83
  * @default true
84
84
  */
85
85
  cache: boolean;
86
+ /**
87
+ * The maximum number of redirects to be followed for all API calls.
88
+ * @type {Number}
89
+ * @default 1
90
+ */
91
+ maxRedirects: number;
86
92
  /**
87
93
  * The maximum number of retry attempts to be made by the client
88
94
  * in case of server error.
@@ -134,6 +140,7 @@ export class ApiClient {
134
140
  paramToString(param: any): any;
135
141
  buildUrl(path: any, pathParams: any): string;
136
142
  buildCollectionParam(param: any, collectionFormat: any): any;
143
+ setApiKey(key: any): void;
137
144
  addEtagToReservedMap(response: any, data: any): any;
138
145
  /**
139
146
  * Invokes the REST service using the supplied settings and parameters.
@@ -12,36 +12,38 @@ var _https = _interopRequireDefault(require("https"));
12
12
  var _fs2 = _interopRequireDefault(require("fs"));
13
13
  var _path = _interopRequireDefault(require("path"));
14
14
  var _buffer = require("buffer");
15
+ var _ApiResponseMetadata = _interopRequireDefault(require("./models/common/v1/response/ApiResponseMetadata"));
16
+ var _Flag = _interopRequireDefault(require("./models/common/v1/config/Flag"));
15
17
  var _ApiClient;
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
- 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); }
18
- function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { var t = o[r]; return "$" + (Array.isArray(t) ? t.join("$") : t); })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != _typeof(e[e.length - 1]) && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); }
19
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
20
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
18
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
19
+ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)(>|$)/g, function (e, r, t) { if ("" === t) return e; var p = o[r]; return Array.isArray(p) ? "$" + p.join("$") : "number" == typeof p ? "$" + p : ""; })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != _typeof(e[e.length - 1]) && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); }
20
+ 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); }
21
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
21
22
  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; }
22
23
  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; }
23
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
25
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
26
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
27
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
28
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
29
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
24
+ 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; }
25
+ 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); }
26
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
27
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
28
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
29
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
30
+ 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); } }
31
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
30
32
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
31
33
  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); }
32
- function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
33
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
34
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
34
+ function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
35
+ function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
36
+ function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
35
37
  function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
36
38
  function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
37
39
  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"); } /*
38
40
  * Nutanix Objects Storage Management APIs
39
41
  *
40
- * OpenAPI spec version: 4.0.1-alpha-2
42
+ * OpenAPI spec version: 4.0.1
41
43
  *
42
44
  * NOTE: This class is auto generated by the Open API Dev Platform.
43
45
  *
44
- * Open API Dev Platform Codegen version: 16.8.0.7344-RELEASE
46
+ * Open API Dev Platform Codegen version: 16.9.1.8738-RELEASE
45
47
  *
46
48
  * Do not edit the class manually.
47
49
  *
@@ -52,7 +54,7 @@ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.h
52
54
  * application to use this class directly - the *Api and model classes provide the public API for the service. The
53
55
  * contents of this file should be regarded as internal but are documented for completeness.
54
56
  * @module ApiClient
55
- * @version 4.0.1-alpha-2
57
+ * @version 4.0.1
56
58
  */
57
59
  var _protocol = /*#__PURE__*/new WeakMap();
58
60
  var _cookie = /*#__PURE__*/new WeakMap();
@@ -136,6 +138,11 @@ var ApiClient = exports.ApiClient = /*#__PURE__*/function () {
136
138
  * @type {Array.<String>}
137
139
  */
138
140
  this.authentications = {
141
+ 'apiKeyAuthScheme': {
142
+ type: 'apiKey',
143
+ 'in': 'header',
144
+ name: 'X-ntnx-api-key'
145
+ },
139
146
  'basicAuthScheme': {
140
147
  type: 'basic'
141
148
  }
@@ -149,7 +156,7 @@ var ApiClient = exports.ApiClient = /*#__PURE__*/function () {
149
156
  this.defaultHeaders = {};
150
157
  _classPrivateFieldSet(_defaultConnectTimeout, this, 30000);
151
158
  _classPrivateFieldSet(_defaultReadTimeout, this, 30000);
152
- _classPrivateFieldSet(_defaultMaxTimeout, this, 1800000);
159
+ _classPrivateFieldSet(_defaultMaxTimeout, this, 10800000);
153
160
 
154
161
  /**
155
162
  * The default HTTP read timeout in milliseconds for all API calls.
@@ -179,6 +186,13 @@ var ApiClient = exports.ApiClient = /*#__PURE__*/function () {
179
186
  */
180
187
  _classPrivateFieldSet(_cookie, this, null);
181
188
 
189
+ /**
190
+ * The maximum number of redirects to be followed for all API calls.
191
+ * @type {Number}
192
+ * @default 1
193
+ */
194
+ this.maxRedirects = 1;
195
+
182
196
  /**
183
197
  * The maximum number of retry attempts to be made by the client
184
198
  * in case of server error.
@@ -360,6 +374,21 @@ var ApiClient = exports.ApiClient = /*#__PURE__*/function () {
360
374
  }
361
375
  }
362
376
 
377
+ /*
378
+ * Sets API key for authentication
379
+ *
380
+ * @param {String} key The API key for authentication
381
+ */
382
+ }, {
383
+ key: "setApiKey",
384
+ value: function setApiKey(key) {
385
+ if (key == undefined || typeof key === 'string' || key instanceof String) {
386
+ this.authentications['apiKeyAuthScheme']['apiKey'] = key;
387
+ } else {
388
+ this.authentications['apiKeyAuthScheme']['apiKey'] = undefined;
389
+ }
390
+ }
391
+
363
392
  /*
364
393
  * Applies authentication headers to the request.
365
394
  * @param {Object} request The request object created by a <code>superagent()</code> call.
@@ -431,13 +460,20 @@ var ApiClient = exports.ApiClient = /*#__PURE__*/function () {
431
460
  request.callback = function (err, res) {
432
461
  if (res && res.status) {
433
462
  var status = res.status;
434
- if (status >= 400 && !(status === 401 || status === 408 || status === 503 || status === 504)) {
463
+ if (status >= 400 && !(status === 401 || status === 408 || status === 429 || status === 503 || status === 504)) {
435
464
  this._maxRetries = 0;
436
465
  }
437
466
  if (res.status === 401) {
438
467
  this.unset("Cookie");
439
468
  this._maxRetries = 1;
440
469
  }
470
+ if (status === 429) {
471
+ var retryAfter = res.headers['retry-after'];
472
+ if (retryAfter) {
473
+ var delay = parseInt(retryAfter, 10) * 1000;
474
+ this._retryDelays[this._retries] = delay;
475
+ }
476
+ }
441
477
  }
442
478
  this.oldCallback(err, res);
443
479
  };
@@ -463,8 +499,9 @@ var ApiClient = exports.ApiClient = /*#__PURE__*/function () {
463
499
  // Set User-Agent header only if it is not a browser environment
464
500
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
465
501
  if (!isBrowser) {
502
+ this.downloadDestination = '.';
466
503
  request.set(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, {
467
- 'User-Agent': 'Nutanix-objects-js-client/4.0.1-alpha.2'
504
+ 'User-Agent': 'Nutanix-objects-js-client/4.0.1'
468
505
  }));
469
506
  }
470
507
 
@@ -552,180 +589,127 @@ var ApiClient = exports.ApiClient = /*#__PURE__*/function () {
552
589
  }
553
590
  _assertClassBrand(_ApiClient_brand, this, _attachCookies).call(this, request);
554
591
  _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Request Body :", typeof request._data === "undefined" ? "" : request._data);
555
- var accept = headerParams.hasOwnProperty("Accept") ? headerParams["Accept"] : _assertClassBrand(_ApiClient_brand, this, _jsonPreferredMime).call(this, accepts);
556
- var fetchStream = headerParams.hasOwnProperty("Accept") && headerParams["Accept"] === "application/octet-stream" || accepts.length == 1 && accepts[0] === "application/octet-stream";
557
-
558
- /*
559
- * 4xx 5xx auto generated responses always append 'application/json' to accepts array
560
- * octet-stream will be overlooked during jsonPreferredMime call, therefore additional check added
561
- */
562
- if (fetchStream) {
563
- // FILE DOWNLOAD SUPPORT
564
-
565
- request.accept('application/octet-stream');
566
- request.buffer(false);
567
- return new Promise(function (resolve, reject) {
568
- var tempFilename = null;
569
-
570
- /*
571
- * Browser environment :
572
- * uses Web Streams, downloadDestination expected to be a WritableStream (i.e. sink for response to be streamed to)
573
- * Node.js environment :
574
- * uses File System, downloadDestination expected to be a directory path, file is downloaded to this directory
575
- */
576
-
577
- if (isBrowser) {
578
- /*
579
- * Browser environment :
580
- * - fetch webstream module
581
- * - write file to WritableStream downloadDestination
582
- * - if webstream if not available or downloadDestination is not instance of WritableStream
583
- * code flow goes to main request.then execution
584
- */
585
-
586
- if (typeof require === 'function') {
587
- var _webstream;
588
- try {
589
- _webstream = require('stream/web');
590
- } catch (err) {
591
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, "Error fetching steam/web");
592
- }
593
- if (_this2.downloadDestination instanceof _webstream.WritableStream) {
594
- // Piping Data
595
- var writer = _this2.downloadDestination.getWriter();
596
- try {
597
- request.on('data', function (chunk) {
598
- writer.write(chunk);
599
- });
600
- } catch (err) {
601
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, "Issue while downloading file", err);
602
- }
603
-
604
- // Receiving Response in case of 4xx 5xx
605
- request.on('response', function (response) {
606
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).INFO, null, "Response Status :", response.status);
607
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).DEBUG, _assertClassBrand(_ApiClient_brand, _this2, _flatten), "Response Headers :", response.headers);
608
- var data = _assertClassBrand(_ApiClient_brand, _this2, _deserialize).call(_this2, response, returnType);
609
- resolve({
610
- data: data,
611
- response: response
612
- });
613
- }).on('error', function (err) {
614
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, "Caught the following error :", err);
615
- reject(err);
616
- });
617
- } else {
618
- var errMsg = "Incompatible downloadDestination for Browser Environment, must be WritableStream";
619
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, errMsg);
620
- reject(errMsg);
621
- }
592
+ var accept = headerParams.hasOwnProperty("Accept") && headerParams["Accept"] != undefined ? headerParams["Accept"] : accepts.join(', ');
593
+ var binaryMediaTypes = ['application/octet-stream', 'application/pdf', 'application/zip'];
594
+ if (accept) {
595
+ request.accept(accept);
596
+ }
597
+ return new Promise(function (resolve, reject) {
598
+ request.buffer(false).redirects(0).retry(_this2.maxRetryAttempts, _this2.retryInterval, []).on('error', function (err) {
599
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).DEBUG, null, "Caught the following error :", err);
600
+ }).end(function (error, response) {
601
+ if (error) {
602
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).DEBUG, null, "Caught error during the request!");
603
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, error);
604
+ if (error.response !== null && typeof error.response !== 'undefined') {
605
+ error.data = _assertClassBrand(_ApiClient_brand, _this2, _deserialize).call(_this2, error.response, returnType);
606
+ } else {
607
+ error.data = _assertClassBrand(_ApiClient_brand, _this2, _wrapErrorInResponse).call(_this2, error);
622
608
  }
609
+ reject(error);
623
610
  } else {
624
- /*
625
- * Non Browser environment :
626
- * - stream data to file
627
- * - fetch response headers and body (if exists)
628
- * - return in case of error or after stream finish
629
- *
630
- * NOTE :
631
- * superagent does not provide access to headers before pipe, therefore response is piped to
632
- * file with temporary name, which is renamed to proper filename after Content-Disposition header is available
633
- */
634
-
635
- // Sanitizing downloadDestination
636
- if (_this2.downloadDestination === null || typeof _this2.downloadDestination === 'undefined' || typeof _this2.downloadDestination !== 'string') {
637
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, "Incompatible downloadDestination must be string, is", _this2.downloadDestination);
638
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, "Downloading file to base directory");
639
- _this2.downloadDestination = ".";
611
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).INFO, null, "Response Status :", response.status);
612
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).DEBUG, _assertClassBrand(_ApiClient_brand, _this2, _flatten), "Response Headers :", response.headers);
613
+ var _contentType = '';
614
+ if (response.headers.hasOwnProperty('content-type')) {
615
+ _contentType = response.headers["content-type"];
640
616
  }
641
-
642
- // Piping data to temporary file
643
- tempFilename = _this2.downloadDestination + '/downloaded_file_' + Date.now() + '.txt'; // temporary filename
644
- var stream = _fs2["default"].createWriteStream(tempFilename);
645
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).INFO, null, "Streaming response to : ", tempFilename);
646
- request.pipe(stream);
647
-
648
- // Receiving response (json response for 4xx 5xx, or Component-Disposition header for successful pipe)
649
- request.on('response', function (response) {
650
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).INFO, null, "Response Status :", response.status);
651
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).DEBUG, _assertClassBrand(_ApiClient_brand, _this2, _flatten), "Response Headers :", response.headers);
652
-
653
- // deserialize response if any
654
- var data = _assertClassBrand(_ApiClient_brand, _this2, _deserialize).call(_this2, response, returnType);
655
- if (!response.ok) {
656
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, data);
657
- reject(_objectSpread(_objectSpread({}, response.error), {}, {
658
- data: data
659
- }));
660
- }
661
-
662
- // Fetch filename
663
- var filename = "";
664
- if (typeof response.headers['content-disposition'] !== 'undefined' && response.headers['content-disposition'] !== null) {
665
- var match = response.headers['content-disposition'].match( /*#__PURE__*/_wrapRegExp(/.*filename="(.*)".*/, {
666
- filename: 1
667
- }));
668
- var filepath = _path["default"].parse(match.groups['filename']);
669
- filename = _this2.downloadDestination + '/' + filepath.name + '_' + Date.now() + filepath.ext;
670
- if (typeof data === 'undefined') {
671
- data = new returnType();
672
- data.data = {
673
- "path": _path["default"].parse(filename),
674
- $objectType: "Path"
675
- };
676
- }
677
- }
678
- stream.on('finish', function () {
679
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).INFO, null, "Finished streaming response");
680
- if (filename.length !== 0) {
681
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).INFO, null, "Content-Disposition header found [", filename, "] is final filename");
682
- stream.close();
683
- _fs2["default"].rename(tempFilename, filename, function () {
684
- resolve({
685
- data: data,
686
- response: response
617
+ var fetchStream = binaryMediaTypes.some(function (binaryMediaType) {
618
+ return _contentType.includes(binaryMediaType);
619
+ });
620
+ if (fetchStream) {
621
+ /*
622
+ * Browser environment :
623
+ * uses Web Streams, downloadDestination expected to be a WritableStream (i.e. sink for response to be streamed to)
624
+ * Node.js environment :
625
+ * uses File System, downloadDestination expected to be a directory path, file is downloaded to this directory
626
+ */
627
+ if (isBrowser) {
628
+ /*
629
+ * Browser environment :
630
+ * - fetch webstream module
631
+ * - write file to WritableStream downloadDestination
632
+ * - if webstream if not available or downloadDestination is not instance of WritableStream
633
+ * code flow goes to main request.then execution
634
+ */
635
+ if (typeof require === 'function') {
636
+ var _webstream;
637
+ try {
638
+ _webstream = require('stream/web');
639
+ } catch (err) {
640
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, "Error fetching steam/web");
641
+ }
642
+ if (_this2.downloadDestination instanceof _webstream.WritableStream) {
643
+ // Piping Data
644
+ var writer = _this2.downloadDestination.getWriter();
645
+ try {
646
+ response.on('data', function (chunk) {
647
+ writer.write(chunk);
648
+ });
649
+ } catch (err) {
650
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, "Issue while downloading file", err);
651
+ }
652
+ response.on('end', function () {
653
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).INFO, null, "Finished streaming response");
654
+ writer.close();
655
+ var data = _assertClassBrand(_ApiClient_brand, _this2, _deserialize).call(_this2, response, returnType);
656
+ resolve({
657
+ data: data,
658
+ response: response
659
+ });
660
+ }).on('error', function (err) {
661
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, "Caught the following error :", err);
662
+ err.data = _assertClassBrand(_ApiClient_brand, _this2, _wrapErrorInResponse).call(_this2, err);
663
+ reject(err);
687
664
  });
688
- });
689
- } else {
690
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, "Content-Disposition header not found [", tempFilename, "] is final filename");
691
- resolve({
692
- data: data,
693
- response: response
694
- });
665
+ } else {
666
+ var errMsg = "Incompatible downloadDestination for Browser Environment, must be WritableStream";
667
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, errMsg);
668
+ reject(errMsg);
669
+ }
695
670
  }
696
- }).on('error', function (err) {
697
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, "Caught the following error :", err);
698
- error.data = _assertClassBrand(_ApiClient_brand, _this2, _wrapErrorInResponse).call(_this2, error);
699
- reject(err);
700
- });
701
- }).on('error', function (error) {
702
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, "Caught the following error :", err);
703
- if (error.response !== null && typeof error.response !== 'undefined') {
704
- error.data = _assertClassBrand(_ApiClient_brand, _this2, _deserialize).call(_this2, error.response, returnType);
705
671
  } else {
706
- error.data = _assertClassBrand(_ApiClient_brand, _this2, _wrapErrorInResponse).call(_this2, error);
672
+ /*
673
+ * Non Browser environment :
674
+ * - stream data to file
675
+ * - fetch response headers and body (if exists)
676
+ * - return in case of error or after stream finish
677
+ *
678
+ * NOTE :
679
+ * superagent does not provide access to headers before pipe, therefore response is piped to
680
+ * file with temporary name, which is renamed to proper filename after Content-Disposition header is available
681
+ */
682
+
683
+ var tempFilename = _this2.downloadDestination + '/downloaded_file_' + Date.now() + '.txt'; // temporary filename
684
+ var stream = _fs2["default"].createWriteStream(tempFilename);
685
+ _assertClassBrand(_ApiClient_brand, _this2, _processDownloadedFile).call(_this2, response, stream, tempFilename, resolve, reject, returnType);
707
686
  }
708
- reject(error);
709
- });
710
- }
711
- });
712
- } else if (accept) {
713
- request.accept(accept);
714
- }
715
- return new Promise(function (resolve, reject) {
716
- request.on('error', function (err) {
717
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).DEBUG, null, "Caught the following error :", err);
718
- }).retry(_this2.maxRetryAttempts, _this2.retryInterval, []).then(function (response) {
719
- _assertClassBrand(_ApiClient_brand, _this2, _handleApiResponseForPromise).call(_this2, response, path, queryParams, returnType, resolve, reject);
720
- })["catch"](function (error) {
721
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).DEBUG, null, "Caught error during the request!");
722
- _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).ERROR, null, error);
723
- if (error.response !== null && typeof error.response !== 'undefined') {
724
- error.data = _assertClassBrand(_ApiClient_brand, _this2, _deserialize).call(_this2, error.response, returnType);
725
- } else {
726
- error.data = _assertClassBrand(_ApiClient_brand, _this2, _wrapErrorInResponse).call(_this2, error);
687
+ } else if (response.status == 302) {
688
+ /*
689
+ * Handling 302 Redirects
690
+ * - Reads X-Redirect-Token header from response and writes into Cookie header for redirected request
691
+ */
692
+ var _tempFilename = _this2.downloadDestination + '/downloaded_file_' + Date.now() + '.txt'; // temporary filename
693
+ var context = _this2;
694
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).INFO, null, "Redirecting to :", response.headers.location);
695
+ var redirectRequest = (0, _superagent["default"])(httpMethod, response.headers.location);
696
+ redirectRequest.set(request.header);
697
+ if (response.headers.hasOwnProperty("x-redirect-token")) {
698
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).INFO, null, "Writing X-Redirect-Token into Cookie");
699
+ redirectRequest.set("Cookie", response.headers["x-redirect-token"]);
700
+ }
701
+ redirectRequest.redirects(0);
702
+ redirectRequest.buffer(false);
703
+ var redirectedStream = _fs2["default"].createWriteStream(_tempFilename);
704
+ redirectRequest.pipe(redirectedStream);
705
+ redirectRequest.on('response', function (redirectResponse) {
706
+ _assertClassBrand(_ApiClient_brand, context, _log).call(context, _classPrivateFieldGet(_LOG_LEVEL, context).INFO, null, "Received response after redirection :", redirectResponse.status);
707
+ _assertClassBrand(_ApiClient_brand, context, _processDownloadedFile).call(context, redirectResponse, redirectedStream, _tempFilename, resolve, reject, returnType);
708
+ });
709
+ } else {
710
+ _assertClassBrand(_ApiClient_brand, _this2, _handleApiResponseForPromise).call(_this2, response, path, queryParams, returnType, resolve, reject);
711
+ }
727
712
  }
728
- reject(error);
729
713
  });
730
714
  });
731
715
  }
@@ -1046,6 +1030,22 @@ function _deserialize(response, returnType) {
1046
1030
  return null;
1047
1031
  }
1048
1032
 
1033
+ // Handle text response
1034
+ if (response.headers && ['text/event-stream', 'text/html', 'text/xml', 'text/csv', 'text/javascript', 'text/markdown', 'text/vcard'].includes(response.headers['content-type'])) {
1035
+ var data = new returnType();
1036
+ data.data = new _buffer.Blob([response.text], {
1037
+ type: response.headers['content-type']
1038
+ });
1039
+ var flag = new _Flag["default"]();
1040
+ flag.name = "hasError";
1041
+ flag.value = false;
1042
+ var flags = [flag];
1043
+ var metadata = new _ApiResponseMetadata["default"]();
1044
+ metadata.flags = flags;
1045
+ data.metadata = metadata;
1046
+ return data;
1047
+ }
1048
+
1049
1049
  // Rely on SuperAgent for parsing response body.
1050
1050
  // See http://visionmedia.github.io/superagent/#parsing-response-bodies
1051
1051
  var data = response.body;
@@ -1183,12 +1183,17 @@ function _flatten(obj) {
1183
1183
  // handle and deserialize received response
1184
1184
  function _handleApiResponseForPromise(response, path, queryParams, returnType, resolve, reject) {
1185
1185
  try {
1186
+ var data = _assertClassBrand(_ApiClient_brand, this, _deserialize).call(this, response, returnType);
1186
1187
  _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Response Status :", response.status);
1187
1188
  _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, _assertClassBrand(_ApiClient_brand, this, _flatten), "Response Headers :", response.headers);
1188
1189
  _assertClassBrand(_ApiClient_brand, this, _updateCookies).call(this, response || {});
1189
- var data = _assertClassBrand(_ApiClient_brand, this, _deserialize).call(this, response, returnType);
1190
1190
  _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Response Body :", data);
1191
- if (response.ok) {
1191
+ if (response.status == 204 && data == null) {
1192
+ resolve({
1193
+ data: data,
1194
+ response: response
1195
+ });
1196
+ } else if (response.ok && data != null) {
1192
1197
  this.addEtagToReservedMap(response, data);
1193
1198
  _assertClassBrand(_ApiClient_brand, this, _paginateIfNeeded).call(this, data, path, queryParams);
1194
1199
  resolve({
@@ -1208,4 +1213,59 @@ function _handleApiResponseForPromise(response, path, queryParams, returnType, r
1208
1213
  reject(err);
1209
1214
  }
1210
1215
  }
1216
+ function _processDownloadedFile(response, stream, tempFilename, resolve, reject, returnType) {
1217
+ var _this4 = this;
1218
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Streaming response to : ", tempFilename);
1219
+ try {
1220
+ response.on('data', function (chunk) {
1221
+ stream.write(chunk);
1222
+ });
1223
+ } catch (err) {
1224
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Issue while downloading file", err);
1225
+ }
1226
+ var data = new returnType();
1227
+ // Fetch filename
1228
+ var filename = "";
1229
+ if (typeof response.headers['content-disposition'] !== 'undefined' && response.headers['content-disposition'] !== null) {
1230
+ var match = response.headers['content-disposition'].match(/*#__PURE__*/_wrapRegExp(/.*filename="(.*)".*/, {
1231
+ filename: 1
1232
+ }));
1233
+ var filepath = _path["default"].parse(match.groups['filename']);
1234
+ filename = this.downloadDestination + '/' + filepath.name + '_' + Date.now() + filepath.ext;
1235
+ data.data = {
1236
+ "path": _path["default"].parse(filename),
1237
+ $objectType: "Path"
1238
+ };
1239
+ var flag = new _Flag["default"]();
1240
+ flag.name = "hasError";
1241
+ flag.value = false;
1242
+ var flags = [flag];
1243
+ var metadata = new _ApiResponseMetadata["default"]();
1244
+ metadata.flags = flags;
1245
+ data.metadata = metadata;
1246
+ }
1247
+ response.on('end', function () {
1248
+ _assertClassBrand(_ApiClient_brand, _this4, _log).call(_this4, _classPrivateFieldGet(_LOG_LEVEL, _this4).INFO, null, "Finished streaming response");
1249
+ if (filename.length !== 0) {
1250
+ _assertClassBrand(_ApiClient_brand, _this4, _log).call(_this4, _classPrivateFieldGet(_LOG_LEVEL, _this4).INFO, null, "Content-Disposition header found [", filename, "] is final filename");
1251
+ stream.close();
1252
+ _fs2["default"].renameSync(tempFilename, filename);
1253
+ resolve({
1254
+ data: data,
1255
+ response: response
1256
+ });
1257
+ } else {
1258
+ _assertClassBrand(_ApiClient_brand, _this4, _log).call(_this4, _classPrivateFieldGet(_LOG_LEVEL, _this4).ERROR, null, "Content-Disposition header not found [", tempFilename, "] is final filename");
1259
+ resolve({
1260
+ data: data,
1261
+ response: response
1262
+ });
1263
+ }
1264
+ });
1265
+ response.on('error', function (err) {
1266
+ _assertClassBrand(_ApiClient_brand, _this4, _log).call(_this4, _classPrivateFieldGet(_LOG_LEVEL, _this4).ERROR, null, "Caught the following error :", err);
1267
+ error.data = _assertClassBrand(_ApiClient_brand, _this4, _wrapErrorInResponse).call(_this4, error);
1268
+ reject(err);
1269
+ });
1270
+ }
1211
1271
  ApiClient.instance = new ApiClient();
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * A model that represents a paginable response from a list endpoint.
3
3
  * @module Paginable
4
- * @version 4.0.1-alpha-2
4
+ * @version 4.0.1
5
5
  */
6
6
  export default class Paginable {
7
7
  /**