@nutanix-scratch/security-js-client 4.0.1-beta.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 (333) hide show
  1. package/LICENSE.txt +202 -0
  2. package/README.md +217 -0
  3. package/dist/Ntnx-Security-js-client-prod.js +1 -0
  4. package/dist/Ntnx-Security-js-client.js +1246 -0
  5. package/dist/es/ApiClient.d.ts +166 -0
  6. package/dist/es/ApiClient.js +1271 -0
  7. package/dist/es/Paginable.d.ts +95 -0
  8. package/dist/es/Paginable.js +287 -0
  9. package/dist/es/apis/approvalpolicies-endpoints.d.ts +90 -0
  10. package/dist/es/apis/approvalpolicies-endpoints.js +295 -0
  11. package/dist/es/apis/stigs-endpoints.d.ts +108 -0
  12. package/dist/es/apis/stigs-endpoints.js +202 -0
  13. package/dist/es/index.d.ts +158 -0
  14. package/dist/es/index.js +628 -0
  15. package/dist/es/models/common/v1/config/Flag.d.ts +64 -0
  16. package/dist/es/models/common/v1/config/Flag.js +319 -0
  17. package/dist/es/models/common/v1/config/KVPair.d.ts +71 -0
  18. package/dist/es/models/common/v1/config/KVPair.js +378 -0
  19. package/dist/es/models/common/v1/config/MapOfStringWrapper.d.ts +58 -0
  20. package/dist/es/models/common/v1/config/MapOfStringWrapper.js +275 -0
  21. package/dist/es/models/common/v1/config/Message.d.ts +87 -0
  22. package/dist/es/models/common/v1/config/Message.js +386 -0
  23. package/dist/es/models/common/v1/config/MessageSeverity.d.ts +19 -0
  24. package/dist/es/models/common/v1/config/MessageSeverity.js +91 -0
  25. package/dist/es/models/common/v1/config/TenantAwareModel.d.ts +52 -0
  26. package/dist/es/models/common/v1/config/TenantAwareModel.js +275 -0
  27. package/dist/es/models/common/v1/response/ApiLink.d.ts +64 -0
  28. package/dist/es/models/common/v1/response/ApiLink.js +312 -0
  29. package/dist/es/models/common/v1/response/ApiResponseMetadata.d.ts +133 -0
  30. package/dist/es/models/common/v1/response/ApiResponseMetadata.js +482 -0
  31. package/dist/es/models/common/v1/response/ExternalizableAbstractModel.d.ts +48 -0
  32. package/dist/es/models/common/v1/response/ExternalizableAbstractModel.js +310 -0
  33. package/dist/es/models/iam/v4/authn/BucketsAccessKey.d.ts +166 -0
  34. package/dist/es/models/iam/v4/authn/BucketsAccessKey.js +667 -0
  35. package/dist/es/models/iam/v4/authn/BucketsAccessKeyStatusType.d.ts +19 -0
  36. package/dist/es/models/iam/v4/authn/BucketsAccessKeyStatusType.js +91 -0
  37. package/dist/es/models/iam/v4/authn/CreationType.d.ts +19 -0
  38. package/dist/es/models/iam/v4/authn/CreationType.js +91 -0
  39. package/dist/es/models/iam/v4/authn/User.d.ts +318 -0
  40. package/dist/es/models/iam/v4/authn/User.js +1140 -0
  41. package/dist/es/models/iam/v4/authn/UserStatusType.d.ts +19 -0
  42. package/dist/es/models/iam/v4/authn/UserStatusType.js +85 -0
  43. package/dist/es/models/iam/v4/authn/UserType.d.ts +19 -0
  44. package/dist/es/models/iam/v4/authn/UserType.js +103 -0
  45. package/dist/es/models/prism/v4/config/TaskReference.d.ts +52 -0
  46. package/dist/es/models/prism/v4/config/TaskReference.js +287 -0
  47. package/dist/es/models/security/v4/common/Cluster.d.ts +64 -0
  48. package/dist/es/models/security/v4/common/Cluster.js +311 -0
  49. package/dist/es/models/security/v4/common/ClusterProjection.d.ts +10 -0
  50. package/dist/es/models/security/v4/common/ClusterProjection.js +150 -0
  51. package/dist/es/models/security/v4/common/Timescale.d.ts +19 -0
  52. package/dist/es/models/security/v4/common/Timescale.js +103 -0
  53. package/dist/es/models/security/v4/config/AddPublicKeyApiResponse.d.ts +102 -0
  54. package/dist/es/models/security/v4/config/AddPublicKeyApiResponse.js +343 -0
  55. package/dist/es/models/security/v4/config/ChangePasswordSpec.d.ts +74 -0
  56. package/dist/es/models/security/v4/config/ChangePasswordSpec.js +317 -0
  57. package/dist/es/models/security/v4/config/ChangeSystemUserPasswordApiResponse.d.ts +102 -0
  58. package/dist/es/models/security/v4/config/ChangeSystemUserPasswordApiResponse.js +343 -0
  59. package/dist/es/models/security/v4/config/DeletePublicKeyApiResponse.d.ts +99 -0
  60. package/dist/es/models/security/v4/config/DeletePublicKeyApiResponse.js +343 -0
  61. package/dist/es/models/security/v4/config/HardeningStatus.d.ts +154 -0
  62. package/dist/es/models/security/v4/config/HardeningStatus.js +641 -0
  63. package/dist/es/models/security/v4/config/HardeningStatusProjection.d.ts +53 -0
  64. package/dist/es/models/security/v4/config/HardeningStatusProjection.js +358 -0
  65. package/dist/es/models/security/v4/config/HardeningVisibilitySetting.d.ts +121 -0
  66. package/dist/es/models/security/v4/config/HardeningVisibilitySetting.js +539 -0
  67. package/dist/es/models/security/v4/config/PasswordStatus.d.ts +19 -0
  68. package/dist/es/models/security/v4/config/PasswordStatus.js +97 -0
  69. package/dist/es/models/security/v4/config/PasswordVerificationStatus.d.ts +19 -0
  70. package/dist/es/models/security/v4/config/PasswordVerificationStatus.js +91 -0
  71. package/dist/es/models/security/v4/config/PublicKey.d.ts +80 -0
  72. package/dist/es/models/security/v4/config/PublicKey.js +373 -0
  73. package/dist/es/models/security/v4/config/PublicKeyProjection.d.ts +51 -0
  74. package/dist/es/models/security/v4/config/PublicKeyProjection.js +309 -0
  75. package/dist/es/models/security/v4/config/Schedule.d.ts +19 -0
  76. package/dist/es/models/security/v4/config/Schedule.js +97 -0
  77. package/dist/es/models/security/v4/config/SystemType.d.ts +19 -0
  78. package/dist/es/models/security/v4/config/SystemType.js +97 -0
  79. package/dist/es/models/security/v4/config/SystemUserPassword.d.ts +110 -0
  80. package/dist/es/models/security/v4/config/SystemUserPassword.js +500 -0
  81. package/dist/es/models/security/v4/config/SystemUserPasswordProjection.d.ts +49 -0
  82. package/dist/es/models/security/v4/config/SystemUserPasswordProjection.js +330 -0
  83. package/dist/es/models/security/v4/config/UpdateHardeningStatusesApiResponse.d.ts +99 -0
  84. package/dist/es/models/security/v4/config/UpdateHardeningStatusesApiResponse.js +343 -0
  85. package/dist/es/models/security/v4/config/UpdateHardeningVisibilitySettingApiResponse.d.ts +99 -0
  86. package/dist/es/models/security/v4/config/UpdateHardeningVisibilitySettingApiResponse.js +365 -0
  87. package/dist/es/models/security/v4/config/VerifyPassword.d.ts +36 -0
  88. package/dist/es/models/security/v4/config/VerifyPassword.js +272 -0
  89. package/dist/es/models/security/v4/config/VerifyPasswordSpec.d.ts +62 -0
  90. package/dist/es/models/security/v4/config/VerifyPasswordSpec.js +279 -0
  91. package/dist/es/models/security/v4/config/VerifySystemUserPasswordApiResponse.d.ts +99 -0
  92. package/dist/es/models/security/v4/config/VerifySystemUserPasswordApiResponse.js +343 -0
  93. package/dist/es/models/security/v4/error/AppMessage.d.ts +117 -0
  94. package/dist/es/models/security/v4/error/AppMessage.js +464 -0
  95. package/dist/es/models/security/v4/error/ErrorResponse.d.ts +52 -0
  96. package/dist/es/models/security/v4/error/ErrorResponse.js +330 -0
  97. package/dist/es/models/security/v4/error/SchemaValidationError.d.ts +108 -0
  98. package/dist/es/models/security/v4/error/SchemaValidationError.js +440 -0
  99. package/dist/es/models/security/v4/error/SchemaValidationErrorMessage.d.ts +76 -0
  100. package/dist/es/models/security/v4/error/SchemaValidationErrorMessage.js +350 -0
  101. package/dist/es/models/security/v4/management/ApprovalPolicy.d.ts +204 -0
  102. package/dist/es/models/security/v4/management/ApprovalPolicy.js +543 -0
  103. package/dist/es/models/security/v4/management/ApproverGroup.d.ts +160 -0
  104. package/dist/es/models/security/v4/management/ApproverGroup.js +385 -0
  105. package/dist/es/models/security/v4/management/AssociatePoliciesApiResponse.d.ts +99 -0
  106. package/dist/es/models/security/v4/management/AssociatePoliciesApiResponse.js +343 -0
  107. package/dist/es/models/security/v4/management/CreateApprovalPolicyApiResponse.d.ts +99 -0
  108. package/dist/es/models/security/v4/management/CreateApprovalPolicyApiResponse.js +343 -0
  109. package/dist/es/models/security/v4/management/EventType.d.ts +19 -0
  110. package/dist/es/models/security/v4/management/EventType.js +85 -0
  111. package/dist/es/models/security/v4/management/GetApprovalPolicyApiResponse.d.ts +99 -0
  112. package/dist/es/models/security/v4/management/GetApprovalPolicyApiResponse.js +343 -0
  113. package/dist/es/models/security/v4/management/ListApprovalPoliciesApiResponse.d.ts +99 -0
  114. package/dist/es/models/security/v4/management/ListApprovalPoliciesApiResponse.js +365 -0
  115. package/dist/es/models/security/v4/management/PolicyType.d.ts +19 -0
  116. package/dist/es/models/security/v4/management/PolicyType.js +79 -0
  117. package/dist/es/models/security/v4/management/SecuredEntityType.d.ts +19 -0
  118. package/dist/es/models/security/v4/management/SecuredEntityType.js +85 -0
  119. package/dist/es/models/security/v4/management/SecuredPolicy.d.ts +77 -0
  120. package/dist/es/models/security/v4/management/SecuredPolicy.js +323 -0
  121. package/dist/es/models/security/v4/management/SecurityValidationSpec.d.ts +160 -0
  122. package/dist/es/models/security/v4/management/SecurityValidationSpec.js +582 -0
  123. package/dist/es/models/security/v4/management/TriggerApprovalPolicyValidationApiResponse.d.ts +99 -0
  124. package/dist/es/models/security/v4/management/TriggerApprovalPolicyValidationApiResponse.js +343 -0
  125. package/dist/es/models/security/v4/management/TriggerScanApiResponse.d.ts +99 -0
  126. package/dist/es/models/security/v4/management/TriggerScanApiResponse.js +343 -0
  127. package/dist/es/models/security/v4/management/UpdateApprovalPolicyApiResponse.d.ts +99 -0
  128. package/dist/es/models/security/v4/management/UpdateApprovalPolicyApiResponse.js +343 -0
  129. package/dist/es/models/security/v4/report/IssueSummary.d.ts +71 -0
  130. package/dist/es/models/security/v4/report/IssueSummary.js +326 -0
  131. package/dist/es/models/security/v4/report/ListStigSummariesApiResponse.d.ts +100 -0
  132. package/dist/es/models/security/v4/report/ListStigSummariesApiResponse.js +370 -0
  133. package/dist/es/models/security/v4/report/ListStigsApiResponse.d.ts +100 -0
  134. package/dist/es/models/security/v4/report/ListStigsApiResponse.js +370 -0
  135. package/dist/es/models/security/v4/report/Severity.d.ts +19 -0
  136. package/dist/es/models/security/v4/report/Severity.js +97 -0
  137. package/dist/es/models/security/v4/report/SoftwareType.d.ts +19 -0
  138. package/dist/es/models/security/v4/report/SoftwareType.js +91 -0
  139. package/dist/es/models/security/v4/report/Stig.d.ts +143 -0
  140. package/dist/es/models/security/v4/report/Stig.js +623 -0
  141. package/dist/es/models/security/v4/report/StigProjection.d.ts +10 -0
  142. package/dist/es/models/security/v4/report/StigProjection.js +154 -0
  143. package/dist/es/models/security/v4/report/StigStatus.d.ts +19 -0
  144. package/dist/es/models/security/v4/report/StigStatus.js +91 -0
  145. package/dist/es/models/security/v4/report/StigSummary.d.ts +73 -0
  146. package/dist/es/models/security/v4/report/StigSummary.js +382 -0
  147. package/dist/es/models/security/v4/report/StigSummaryProjection.d.ts +46 -0
  148. package/dist/es/models/security/v4/report/StigSummaryProjection.js +298 -0
  149. package/dist/es/models/security/v4/report/Summary.d.ts +149 -0
  150. package/dist/es/models/security/v4/report/Summary.js +490 -0
  151. package/dist/es/models/security/v4/report/SummaryProjection.d.ts +97 -0
  152. package/dist/es/models/security/v4/report/SummaryProjection.js +329 -0
  153. package/dist/es/models/security/v4/report/TrendValue.d.ts +64 -0
  154. package/dist/es/models/security/v4/report/TrendValue.js +313 -0
  155. package/dist/es/models/security/v4/report/Vulnerability.d.ts +116 -0
  156. package/dist/es/models/security/v4/report/Vulnerability.js +543 -0
  157. package/dist/es/models/security/v4/report/VulnerabilityProjection.d.ts +10 -0
  158. package/dist/es/models/security/v4/report/VulnerabilityProjection.js +153 -0
  159. package/dist/es/models/security/v4/report/VulnerabilitySummary.d.ts +72 -0
  160. package/dist/es/models/security/v4/report/VulnerabilitySummary.js +393 -0
  161. package/dist/es/models/security/v4/report/VulnerabilitySummaryProjection.d.ts +10 -0
  162. package/dist/es/models/security/v4/report/VulnerabilitySummaryProjection.js +153 -0
  163. package/dist/es/models/validation/ValidationError.d.ts +13 -0
  164. package/dist/es/models/validation/ValidationError.js +60 -0
  165. package/dist/es/models/validation/ValidationScopes.d.ts +9 -0
  166. package/dist/es/models/validation/ValidationScopes.js +38 -0
  167. package/dist/es/utils/ValidationUtils.d.ts +13 -0
  168. package/dist/es/utils/ValidationUtils.js +85 -0
  169. package/dist/lib/ApiClient.d.ts +166 -0
  170. package/dist/lib/ApiClient.js +1271 -0
  171. package/dist/lib/Paginable.d.ts +95 -0
  172. package/dist/lib/Paginable.js +287 -0
  173. package/dist/lib/apis/approvalpolicies-endpoints.d.ts +90 -0
  174. package/dist/lib/apis/approvalpolicies-endpoints.js +295 -0
  175. package/dist/lib/apis/stigs-endpoints.d.ts +108 -0
  176. package/dist/lib/apis/stigs-endpoints.js +202 -0
  177. package/dist/lib/index.d.ts +158 -0
  178. package/dist/lib/index.js +628 -0
  179. package/dist/lib/models/common/v1/config/Flag.d.ts +64 -0
  180. package/dist/lib/models/common/v1/config/Flag.js +319 -0
  181. package/dist/lib/models/common/v1/config/KVPair.d.ts +71 -0
  182. package/dist/lib/models/common/v1/config/KVPair.js +378 -0
  183. package/dist/lib/models/common/v1/config/MapOfStringWrapper.d.ts +58 -0
  184. package/dist/lib/models/common/v1/config/MapOfStringWrapper.js +275 -0
  185. package/dist/lib/models/common/v1/config/Message.d.ts +87 -0
  186. package/dist/lib/models/common/v1/config/Message.js +386 -0
  187. package/dist/lib/models/common/v1/config/MessageSeverity.d.ts +19 -0
  188. package/dist/lib/models/common/v1/config/MessageSeverity.js +91 -0
  189. package/dist/lib/models/common/v1/config/TenantAwareModel.d.ts +52 -0
  190. package/dist/lib/models/common/v1/config/TenantAwareModel.js +275 -0
  191. package/dist/lib/models/common/v1/response/ApiLink.d.ts +64 -0
  192. package/dist/lib/models/common/v1/response/ApiLink.js +312 -0
  193. package/dist/lib/models/common/v1/response/ApiResponseMetadata.d.ts +133 -0
  194. package/dist/lib/models/common/v1/response/ApiResponseMetadata.js +482 -0
  195. package/dist/lib/models/common/v1/response/ExternalizableAbstractModel.d.ts +48 -0
  196. package/dist/lib/models/common/v1/response/ExternalizableAbstractModel.js +310 -0
  197. package/dist/lib/models/iam/v4/authn/BucketsAccessKey.d.ts +166 -0
  198. package/dist/lib/models/iam/v4/authn/BucketsAccessKey.js +667 -0
  199. package/dist/lib/models/iam/v4/authn/BucketsAccessKeyStatusType.d.ts +19 -0
  200. package/dist/lib/models/iam/v4/authn/BucketsAccessKeyStatusType.js +91 -0
  201. package/dist/lib/models/iam/v4/authn/CreationType.d.ts +19 -0
  202. package/dist/lib/models/iam/v4/authn/CreationType.js +91 -0
  203. package/dist/lib/models/iam/v4/authn/User.d.ts +318 -0
  204. package/dist/lib/models/iam/v4/authn/User.js +1140 -0
  205. package/dist/lib/models/iam/v4/authn/UserStatusType.d.ts +19 -0
  206. package/dist/lib/models/iam/v4/authn/UserStatusType.js +85 -0
  207. package/dist/lib/models/iam/v4/authn/UserType.d.ts +19 -0
  208. package/dist/lib/models/iam/v4/authn/UserType.js +103 -0
  209. package/dist/lib/models/prism/v4/config/TaskReference.d.ts +52 -0
  210. package/dist/lib/models/prism/v4/config/TaskReference.js +287 -0
  211. package/dist/lib/models/security/v4/common/Cluster.d.ts +64 -0
  212. package/dist/lib/models/security/v4/common/Cluster.js +311 -0
  213. package/dist/lib/models/security/v4/common/ClusterProjection.d.ts +10 -0
  214. package/dist/lib/models/security/v4/common/ClusterProjection.js +150 -0
  215. package/dist/lib/models/security/v4/common/Timescale.d.ts +19 -0
  216. package/dist/lib/models/security/v4/common/Timescale.js +103 -0
  217. package/dist/lib/models/security/v4/config/AddPublicKeyApiResponse.d.ts +102 -0
  218. package/dist/lib/models/security/v4/config/AddPublicKeyApiResponse.js +343 -0
  219. package/dist/lib/models/security/v4/config/ChangePasswordSpec.d.ts +74 -0
  220. package/dist/lib/models/security/v4/config/ChangePasswordSpec.js +317 -0
  221. package/dist/lib/models/security/v4/config/ChangeSystemUserPasswordApiResponse.d.ts +102 -0
  222. package/dist/lib/models/security/v4/config/ChangeSystemUserPasswordApiResponse.js +343 -0
  223. package/dist/lib/models/security/v4/config/DeletePublicKeyApiResponse.d.ts +99 -0
  224. package/dist/lib/models/security/v4/config/DeletePublicKeyApiResponse.js +343 -0
  225. package/dist/lib/models/security/v4/config/HardeningStatus.d.ts +154 -0
  226. package/dist/lib/models/security/v4/config/HardeningStatus.js +641 -0
  227. package/dist/lib/models/security/v4/config/HardeningStatusProjection.d.ts +53 -0
  228. package/dist/lib/models/security/v4/config/HardeningStatusProjection.js +358 -0
  229. package/dist/lib/models/security/v4/config/HardeningVisibilitySetting.d.ts +121 -0
  230. package/dist/lib/models/security/v4/config/HardeningVisibilitySetting.js +539 -0
  231. package/dist/lib/models/security/v4/config/PasswordStatus.d.ts +19 -0
  232. package/dist/lib/models/security/v4/config/PasswordStatus.js +97 -0
  233. package/dist/lib/models/security/v4/config/PasswordVerificationStatus.d.ts +19 -0
  234. package/dist/lib/models/security/v4/config/PasswordVerificationStatus.js +91 -0
  235. package/dist/lib/models/security/v4/config/PublicKey.d.ts +80 -0
  236. package/dist/lib/models/security/v4/config/PublicKey.js +373 -0
  237. package/dist/lib/models/security/v4/config/PublicKeyProjection.d.ts +51 -0
  238. package/dist/lib/models/security/v4/config/PublicKeyProjection.js +309 -0
  239. package/dist/lib/models/security/v4/config/Schedule.d.ts +19 -0
  240. package/dist/lib/models/security/v4/config/Schedule.js +97 -0
  241. package/dist/lib/models/security/v4/config/SystemType.d.ts +19 -0
  242. package/dist/lib/models/security/v4/config/SystemType.js +97 -0
  243. package/dist/lib/models/security/v4/config/SystemUserPassword.d.ts +110 -0
  244. package/dist/lib/models/security/v4/config/SystemUserPassword.js +500 -0
  245. package/dist/lib/models/security/v4/config/SystemUserPasswordProjection.d.ts +49 -0
  246. package/dist/lib/models/security/v4/config/SystemUserPasswordProjection.js +330 -0
  247. package/dist/lib/models/security/v4/config/UpdateHardeningStatusesApiResponse.d.ts +99 -0
  248. package/dist/lib/models/security/v4/config/UpdateHardeningStatusesApiResponse.js +343 -0
  249. package/dist/lib/models/security/v4/config/UpdateHardeningVisibilitySettingApiResponse.d.ts +99 -0
  250. package/dist/lib/models/security/v4/config/UpdateHardeningVisibilitySettingApiResponse.js +365 -0
  251. package/dist/lib/models/security/v4/config/VerifyPassword.d.ts +36 -0
  252. package/dist/lib/models/security/v4/config/VerifyPassword.js +272 -0
  253. package/dist/lib/models/security/v4/config/VerifyPasswordSpec.d.ts +62 -0
  254. package/dist/lib/models/security/v4/config/VerifyPasswordSpec.js +279 -0
  255. package/dist/lib/models/security/v4/config/VerifySystemUserPasswordApiResponse.d.ts +99 -0
  256. package/dist/lib/models/security/v4/config/VerifySystemUserPasswordApiResponse.js +343 -0
  257. package/dist/lib/models/security/v4/error/AppMessage.d.ts +117 -0
  258. package/dist/lib/models/security/v4/error/AppMessage.js +464 -0
  259. package/dist/lib/models/security/v4/error/ErrorResponse.d.ts +52 -0
  260. package/dist/lib/models/security/v4/error/ErrorResponse.js +330 -0
  261. package/dist/lib/models/security/v4/error/SchemaValidationError.d.ts +108 -0
  262. package/dist/lib/models/security/v4/error/SchemaValidationError.js +440 -0
  263. package/dist/lib/models/security/v4/error/SchemaValidationErrorMessage.d.ts +76 -0
  264. package/dist/lib/models/security/v4/error/SchemaValidationErrorMessage.js +350 -0
  265. package/dist/lib/models/security/v4/management/ApprovalPolicy.d.ts +204 -0
  266. package/dist/lib/models/security/v4/management/ApprovalPolicy.js +543 -0
  267. package/dist/lib/models/security/v4/management/ApproverGroup.d.ts +160 -0
  268. package/dist/lib/models/security/v4/management/ApproverGroup.js +385 -0
  269. package/dist/lib/models/security/v4/management/AssociatePoliciesApiResponse.d.ts +99 -0
  270. package/dist/lib/models/security/v4/management/AssociatePoliciesApiResponse.js +343 -0
  271. package/dist/lib/models/security/v4/management/CreateApprovalPolicyApiResponse.d.ts +99 -0
  272. package/dist/lib/models/security/v4/management/CreateApprovalPolicyApiResponse.js +343 -0
  273. package/dist/lib/models/security/v4/management/EventType.d.ts +19 -0
  274. package/dist/lib/models/security/v4/management/EventType.js +85 -0
  275. package/dist/lib/models/security/v4/management/GetApprovalPolicyApiResponse.d.ts +99 -0
  276. package/dist/lib/models/security/v4/management/GetApprovalPolicyApiResponse.js +343 -0
  277. package/dist/lib/models/security/v4/management/ListApprovalPoliciesApiResponse.d.ts +99 -0
  278. package/dist/lib/models/security/v4/management/ListApprovalPoliciesApiResponse.js +365 -0
  279. package/dist/lib/models/security/v4/management/PolicyType.d.ts +19 -0
  280. package/dist/lib/models/security/v4/management/PolicyType.js +79 -0
  281. package/dist/lib/models/security/v4/management/SecuredEntityType.d.ts +19 -0
  282. package/dist/lib/models/security/v4/management/SecuredEntityType.js +85 -0
  283. package/dist/lib/models/security/v4/management/SecuredPolicy.d.ts +77 -0
  284. package/dist/lib/models/security/v4/management/SecuredPolicy.js +323 -0
  285. package/dist/lib/models/security/v4/management/SecurityValidationSpec.d.ts +160 -0
  286. package/dist/lib/models/security/v4/management/SecurityValidationSpec.js +582 -0
  287. package/dist/lib/models/security/v4/management/TriggerApprovalPolicyValidationApiResponse.d.ts +99 -0
  288. package/dist/lib/models/security/v4/management/TriggerApprovalPolicyValidationApiResponse.js +343 -0
  289. package/dist/lib/models/security/v4/management/TriggerScanApiResponse.d.ts +99 -0
  290. package/dist/lib/models/security/v4/management/TriggerScanApiResponse.js +343 -0
  291. package/dist/lib/models/security/v4/management/UpdateApprovalPolicyApiResponse.d.ts +99 -0
  292. package/dist/lib/models/security/v4/management/UpdateApprovalPolicyApiResponse.js +343 -0
  293. package/dist/lib/models/security/v4/report/IssueSummary.d.ts +71 -0
  294. package/dist/lib/models/security/v4/report/IssueSummary.js +326 -0
  295. package/dist/lib/models/security/v4/report/ListStigSummariesApiResponse.d.ts +100 -0
  296. package/dist/lib/models/security/v4/report/ListStigSummariesApiResponse.js +370 -0
  297. package/dist/lib/models/security/v4/report/ListStigsApiResponse.d.ts +100 -0
  298. package/dist/lib/models/security/v4/report/ListStigsApiResponse.js +370 -0
  299. package/dist/lib/models/security/v4/report/Severity.d.ts +19 -0
  300. package/dist/lib/models/security/v4/report/Severity.js +97 -0
  301. package/dist/lib/models/security/v4/report/SoftwareType.d.ts +19 -0
  302. package/dist/lib/models/security/v4/report/SoftwareType.js +91 -0
  303. package/dist/lib/models/security/v4/report/Stig.d.ts +143 -0
  304. package/dist/lib/models/security/v4/report/Stig.js +623 -0
  305. package/dist/lib/models/security/v4/report/StigProjection.d.ts +10 -0
  306. package/dist/lib/models/security/v4/report/StigProjection.js +154 -0
  307. package/dist/lib/models/security/v4/report/StigStatus.d.ts +19 -0
  308. package/dist/lib/models/security/v4/report/StigStatus.js +91 -0
  309. package/dist/lib/models/security/v4/report/StigSummary.d.ts +73 -0
  310. package/dist/lib/models/security/v4/report/StigSummary.js +382 -0
  311. package/dist/lib/models/security/v4/report/StigSummaryProjection.d.ts +46 -0
  312. package/dist/lib/models/security/v4/report/StigSummaryProjection.js +298 -0
  313. package/dist/lib/models/security/v4/report/Summary.d.ts +149 -0
  314. package/dist/lib/models/security/v4/report/Summary.js +490 -0
  315. package/dist/lib/models/security/v4/report/SummaryProjection.d.ts +97 -0
  316. package/dist/lib/models/security/v4/report/SummaryProjection.js +329 -0
  317. package/dist/lib/models/security/v4/report/TrendValue.d.ts +64 -0
  318. package/dist/lib/models/security/v4/report/TrendValue.js +313 -0
  319. package/dist/lib/models/security/v4/report/Vulnerability.d.ts +116 -0
  320. package/dist/lib/models/security/v4/report/Vulnerability.js +543 -0
  321. package/dist/lib/models/security/v4/report/VulnerabilityProjection.d.ts +10 -0
  322. package/dist/lib/models/security/v4/report/VulnerabilityProjection.js +153 -0
  323. package/dist/lib/models/security/v4/report/VulnerabilitySummary.d.ts +72 -0
  324. package/dist/lib/models/security/v4/report/VulnerabilitySummary.js +393 -0
  325. package/dist/lib/models/security/v4/report/VulnerabilitySummaryProjection.d.ts +10 -0
  326. package/dist/lib/models/security/v4/report/VulnerabilitySummaryProjection.js +153 -0
  327. package/dist/lib/models/validation/ValidationError.d.ts +13 -0
  328. package/dist/lib/models/validation/ValidationError.js +60 -0
  329. package/dist/lib/models/validation/ValidationScopes.d.ts +9 -0
  330. package/dist/lib/models/validation/ValidationScopes.js +38 -0
  331. package/dist/lib/utils/ValidationUtils.d.ts +13 -0
  332. package/dist/lib/utils/ValidationUtils.js +85 -0
  333. package/package.json +53 -0
@@ -0,0 +1,1271 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ApiClient = void 0;
7
+ var _superagent = _interopRequireDefault(require("superagent"));
8
+ var _Paginable = _interopRequireDefault(require("./Paginable"));
9
+ var _uuid = require("uuid");
10
+ var _superagentRetryDelay = _interopRequireDefault(require("superagent-retry-delay"));
11
+ var _https = _interopRequireDefault(require("https"));
12
+ var _fs2 = _interopRequireDefault(require("fs"));
13
+ var _path = _interopRequireDefault(require("path"));
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"));
17
+ var _ApiClient;
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) { 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); }
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); }
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; }
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; }
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; }
32
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
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); }
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"); }
37
+ function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
38
+ function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
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"); } /*
40
+ * Nutanix Security APIs
41
+ *
42
+ * OpenAPI spec version: 4.0.1-beta-1
43
+ *
44
+ * NOTE: This class is auto generated by the Open API Dev Platform.
45
+ *
46
+ * Open API Dev Platform Codegen version: 16.9.0.8546-RELEASE
47
+ *
48
+ * Do not edit the class manually.
49
+ *
50
+ */
51
+ (0, _superagentRetryDelay["default"])(_superagent["default"]);
52
+ /**
53
+ * Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
54
+ * application to use this class directly - the *Api and model classes provide the public API for the service. The
55
+ * contents of this file should be regarded as internal but are documented for completeness.
56
+ * @module ApiClient
57
+ * @version 4.0.1-beta-1
58
+ */
59
+ var _protocol = /*#__PURE__*/new WeakMap();
60
+ var _cookie = /*#__PURE__*/new WeakMap();
61
+ var _logger = /*#__PURE__*/new WeakMap();
62
+ var _verifySslFlag = /*#__PURE__*/new WeakMap();
63
+ var _defaultConnectTimeout = /*#__PURE__*/new WeakMap();
64
+ var _defaultReadTimeout = /*#__PURE__*/new WeakMap();
65
+ var _defaultMaxTimeout = /*#__PURE__*/new WeakMap();
66
+ var _LOG_LEVEL = /*#__PURE__*/new WeakMap();
67
+ var _ApiClient_brand = /*#__PURE__*/new WeakSet();
68
+ var ApiClient = exports.ApiClient = /*#__PURE__*/function () {
69
+ /**
70
+ * @alias module:ApiClient
71
+ * @class
72
+ */
73
+ function ApiClient() {
74
+ _classCallCheck(this, ApiClient);
75
+ /*
76
+ * Checks whether the given content type represents JSON.<br>
77
+ * JSON content type examples:<br>
78
+ * <ul>
79
+ * <li>application/json</li>
80
+ * <li>application/json; charset=UTF8</li>
81
+ * <li>APPLICATION/JSON</li>
82
+ * </ul>
83
+ * @param {String} contentType The MIME content type to check.
84
+ * @returns {Boolean} <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>.
85
+ */
86
+ _classPrivateMethodInitSpec(this, _ApiClient_brand);
87
+ // PRIVATE VARIABLES
88
+ _classPrivateFieldInitSpec(this, _protocol, void 0);
89
+ _classPrivateFieldInitSpec(this, _cookie, void 0);
90
+ _classPrivateFieldInitSpec(this, _logger, void 0);
91
+ _classPrivateFieldInitSpec(this, _verifySslFlag, void 0);
92
+ _classPrivateFieldInitSpec(this, _defaultConnectTimeout, void 0);
93
+ _classPrivateFieldInitSpec(this, _defaultReadTimeout, void 0);
94
+ _classPrivateFieldInitSpec(this, _defaultMaxTimeout, void 0);
95
+ _classPrivateFieldInitSpec(this, _LOG_LEVEL, void 0);
96
+ _classPrivateFieldSet(_LOG_LEVEL, this, Object.freeze({
97
+ DEBUG: {
98
+ key: "DEBUG",
99
+ value: Symbol(0)
100
+ },
101
+ INFO: {
102
+ key: "INFO",
103
+ value: Symbol(1)
104
+ },
105
+ WARN: {
106
+ key: "WARN",
107
+ value: Symbol(2)
108
+ },
109
+ ERROR: {
110
+ key: "ERROR",
111
+ value: Symbol(3)
112
+ }
113
+ }));
114
+
115
+ /**
116
+ * URI scheme for connecting to the cluster (HTTP or HTTPS using SSL/TLS)
117
+ * @type {String}
118
+ * @default https
119
+ */
120
+ this.scheme = 'https';
121
+
122
+ /**
123
+ * The hostname of the URL against which to resolve every API call's (relative) path.
124
+ * @type {String}
125
+ * @default localhost
126
+ */
127
+ this.host = typeof self === 'undefined' ? 'localhost' : self.location.hostname;
128
+
129
+ /**
130
+ * The port of the base URL.
131
+ * @type {String}
132
+ * @default 9440
133
+ */
134
+ this.port = typeof self === 'undefined' ? '9440' : self.location.port;
135
+
136
+ /**
137
+ * The authentication methods to be included for all API calls.
138
+ * @type {Array.<String>}
139
+ */
140
+ this.authentications = {
141
+ 'apiKeyAuthScheme': {
142
+ type: 'apiKey',
143
+ 'in': 'header',
144
+ name: 'X-ntnx-api-key'
145
+ },
146
+ 'basicAuthScheme': {
147
+ type: 'basic'
148
+ }
149
+ };
150
+
151
+ /**
152
+ * The default HTTP headers to be included for all API calls.
153
+ * @type {Array.<String>}
154
+ * @default {}
155
+ */
156
+ this.defaultHeaders = {};
157
+ _classPrivateFieldSet(_defaultConnectTimeout, this, 30000);
158
+ _classPrivateFieldSet(_defaultReadTimeout, this, 30000);
159
+ _classPrivateFieldSet(_defaultMaxTimeout, this, 10800000);
160
+
161
+ /**
162
+ * The default HTTP read timeout in milliseconds for all API calls.
163
+ * @type {Number}
164
+ * @default 30000
165
+ */
166
+ this.readTimeout = _classPrivateFieldGet(_defaultReadTimeout, this);
167
+
168
+ /**
169
+ * The default HTTP connection timeout in milliseconds for all API calls.
170
+ * @type {Number}
171
+ * @default 30000
172
+ */
173
+ this.connectTimeout = _classPrivateFieldGet(_defaultConnectTimeout, this);
174
+
175
+ /**
176
+ * If set to false an additional timestamp parameter is added to all API GET calls to
177
+ * prevent browser caching
178
+ * @type {Boolean}
179
+ * @default true
180
+ */
181
+ this.cache = true;
182
+
183
+ /**
184
+ * Saved Cookies
185
+ * @default null
186
+ */
187
+ _classPrivateFieldSet(_cookie, this, null);
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
+
196
+ /**
197
+ * The maximum number of retry attempts to be made by the client
198
+ * in case of server error.
199
+ * @type {Number}
200
+ * @default 5
201
+ */
202
+ this.maxRetryAttempts = 5;
203
+
204
+ /**
205
+ * The delay period (in milliseconds) between two consecutive retry attempts
206
+ * @type {Number}
207
+ * @default 3000
208
+ */
209
+ this.retryInterval = 3000;
210
+ if (typeof self === 'undefined') {
211
+ this.agent = new _superagent["default"].agent();
212
+ }
213
+
214
+ /**
215
+ * Allow user to override superagent agent
216
+ */
217
+ this.requestAgent = null;
218
+
219
+ /**
220
+ * Allow SDK to print debug logs
221
+ */
222
+ this.debug = false;
223
+ _classPrivateFieldSet(_logger, this, null);
224
+
225
+ /**
226
+ * Username for basic auth
227
+ */
228
+ this.username = null;
229
+
230
+ /**
231
+ * Password for basic auth
232
+ */
233
+ this.password = null;
234
+ _classPrivateFieldSet(_verifySslFlag, this, true);
235
+
236
+ /*
237
+ * Non Browser Environment : path to directory where downloaded files will be stored
238
+ * Browser Environment : WritableStream to pipe downloaded file to
239
+ */
240
+ this.downloadDestination = null;
241
+
242
+ /*
243
+ * Log file to write activity logs
244
+ */
245
+ this.loggerFile = null;
246
+ }
247
+
248
+ /**
249
+ * Enable/Disable SSL Verification
250
+ * @param verifySsl (boolean)
251
+ */
252
+ return _createClass(ApiClient, [{
253
+ key: "verifySsl",
254
+ get: function get() {
255
+ return _classPrivateFieldGet(_verifySslFlag, this);
256
+ }
257
+
258
+ /**
259
+ * Configure log file to write activity logs
260
+ * @param logfile The destination file (write stream / string)
261
+ */,
262
+ set: function set(verifySsl) {
263
+ if (verifySsl) {
264
+ this.requestAgent = null;
265
+ } else {
266
+ this.requestAgent = new _https["default"].Agent({
267
+ rejectUnauthorized: false
268
+ });
269
+ }
270
+ _classPrivateFieldSet(_verifySslFlag, this, verifySsl);
271
+ }
272
+ }, {
273
+ key: "loggerFile",
274
+ set: function set(logfile) {
275
+ if (logfile !== null && typeof logfile !== 'undefined') {
276
+ if (typeof logfile === 'string' || logfile instanceof String) {
277
+ logfile = _fs2["default"].createWriteStream(logfile, {
278
+ flags: 'a'
279
+ });
280
+ }
281
+ _classPrivateFieldSet(_logger, this, new console.Console({
282
+ stdout: logfile,
283
+ stderr: logfile
284
+ }));
285
+ }
286
+ }
287
+
288
+ /**
289
+ * Adds key value pair to default headers map, (to be added to every API call request)
290
+ * @param {String} key The key
291
+ * @param {String} value The corresponding value
292
+ */
293
+ }, {
294
+ key: "addDefaultHeader",
295
+ value: function addDefaultHeader(key, value) {
296
+ if (key === "Authorization") {
297
+ _classPrivateFieldSet(_cookie, this, null);
298
+ }
299
+ this.defaultHeaders[key] = value;
300
+ }
301
+
302
+ /*
303
+ * Returns a string representation for an actual parameter.
304
+ * @param param The actual parameter.
305
+ * @returns {String} The string representation of <code>param</code>.
306
+ */
307
+ }, {
308
+ key: "paramToString",
309
+ value: function paramToString(param) {
310
+ if (param == undefined || param == null) {
311
+ return '';
312
+ }
313
+ if (param instanceof Date) {
314
+ return param.toJSON();
315
+ }
316
+ return param.toString();
317
+ }
318
+ }, {
319
+ key: "buildUrl",
320
+ value: function buildUrl(path, pathParams) {
321
+ var _this = this;
322
+ if (!path.match(/^\//)) {
323
+ path = '/' + path;
324
+ }
325
+
326
+ // The protocol of the base URL, including the colon (:).
327
+ _classPrivateFieldSet(_protocol, this, typeof self === 'undefined' ? this.scheme + ':' : self.location.protocol);
328
+ var basePath = ''; //default
329
+ if (_classPrivateFieldGet(_protocol, this) !== '' && this.host !== '' && this.port !== '') {
330
+ basePath = _classPrivateFieldGet(_protocol, this) + '\/\/' + this.host + ':' + this.port;
331
+ } else if (typeof self !== "undefined") {
332
+ basePath = self.origin;
333
+ }
334
+ var url = basePath + path;
335
+ url = url.replace(/\{([\w-]+)\}/g, function (fullMatch, key) {
336
+ var value;
337
+ if (pathParams.hasOwnProperty(key)) {
338
+ value = _this.paramToString(pathParams[key]);
339
+ } else {
340
+ value = fullMatch;
341
+ }
342
+ return encodeURIComponent(value);
343
+ });
344
+ return url;
345
+ }
346
+ }, {
347
+ key: "buildCollectionParam",
348
+ value:
349
+ /*
350
+ * Builds a string representation of an array-type actual parameter, according to the given collection format.
351
+ * @param {Array} param An array parameter.
352
+ * @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
353
+ * @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
354
+ * <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
355
+ */
356
+ function buildCollectionParam(param, collectionFormat) {
357
+ if (param == null) {
358
+ return null;
359
+ }
360
+ switch (collectionFormat) {
361
+ case 'csv':
362
+ return param.map(this.paramToString).join(',');
363
+ case 'ssv':
364
+ return param.map(this.paramToString).join(' ');
365
+ case 'tsv':
366
+ return param.map(this.paramToString).join('\t');
367
+ case 'pipes':
368
+ return param.map(this.paramToString).join('|');
369
+ case 'multi':
370
+ //return the array directly as SuperAgent will handle it as expected
371
+ return param.map(this.paramToString);
372
+ default:
373
+ throw new Error('Unknown collection format: ' + collectionFormat);
374
+ }
375
+ }
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
+
392
+ /*
393
+ * Applies authentication headers to the request.
394
+ * @param {Object} request The request object created by a <code>superagent()</code> call.
395
+ * @param {Array.<String>} authNames An array of authentication method names.
396
+ */
397
+ }, {
398
+ key: "addEtagToReservedMap",
399
+ value: function addEtagToReservedMap(response, data) {
400
+ if (response.hasOwnProperty("headers") && response.headers.hasOwnProperty("etag")) {
401
+ var etagRef = response.headers.etag;
402
+ if (data.getData() !== undefined) {
403
+ if (Array.isArray(data.getData()) && data.getData().length > 0) {
404
+ var _iterator = _createForOfIteratorHelper(data.getData()),
405
+ _step;
406
+ try {
407
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
408
+ var item = _step.value;
409
+ if (item.hasOwnProperty("$reserved") && item.get$Reserved() !== undefined) {
410
+ item.get$Reserved()["ETag"] = etagRef;
411
+ }
412
+ }
413
+ } catch (err) {
414
+ _iterator.e(err);
415
+ } finally {
416
+ _iterator.f();
417
+ }
418
+ } else if (data.getData().hasOwnProperty("$reserved") && data.getData().get$Reserved() !== undefined) {
419
+ data.getData().get$Reserved()["ETag"] = etagRef;
420
+ }
421
+ }
422
+ }
423
+ return data;
424
+ }
425
+
426
+ /**
427
+ * Get ETag from an object if exists.
428
+ * The ETag is usually provided in the response of the GET API calls,
429
+ * which can further be used in other HTTP operations.
430
+ *
431
+ * @param object Object from which ETag needs to be retrieved
432
+ * @returns {(String|null)} returns ETag header in the object if it's an API response object, otherwise null
433
+ */
434
+ }, {
435
+ key: "callApi",
436
+ value:
437
+ /**
438
+ * Invokes the REST service using the supplied settings and parameters.
439
+ * @param {String} path The base URL to invoke.
440
+ * @param {String} httpMethod The HTTP method to use.
441
+ * @param {Object.<String, String>} pathParams A map of path parameters and their values.
442
+ * @param {Object.<String, Object>} queryParams A map of query parameters and their values.
443
+ * @param {Object.<String, Object>} headerParams A map of header parameters and their values.
444
+ * @param {Object.<String, Object>} formParams A map of form parameters and their values.
445
+ * @param {Object} bodyParam The value to pass as the request body.
446
+ * @param {Array.<String>} authNames An array of authentication type names.
447
+ * @param {Array.<String>} contentTypes An array of request MIME types.
448
+ * @param {Array.<String>} accepts An array of acceptable response MIME types.
449
+ * @param {(String|Array|Object|Function)} returnType The required type to return; can be a string for simple types or the
450
+ * constructor for a complex type.
451
+ * @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
452
+ */
453
+ function callApi(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType) {
454
+ var _this2 = this;
455
+ var url = this.buildUrl(path, pathParams);
456
+ var request = (0, _superagent["default"])(httpMethod, url);
457
+
458
+ // override request callback to retry only required status codes
459
+ request.oldCallback = request.callback;
460
+ request.callback = function (err, res) {
461
+ if (res && res.status) {
462
+ var status = res.status;
463
+ if (status >= 400 && !(status === 401 || status === 408 || status === 429 || status === 503 || status === 504)) {
464
+ this._maxRetries = 0;
465
+ }
466
+ if (res.status === 401) {
467
+ this.unset("Cookie");
468
+ this._maxRetries = 1;
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
+ }
477
+ }
478
+ this.oldCallback(err, res);
479
+ };
480
+
481
+ // apply authentications
482
+ _assertClassBrand(_ApiClient_brand, this, _applyAuthToRequest).call(this, request, authNames);
483
+
484
+ // set query parameters
485
+ if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
486
+ queryParams['_'] = new Date().getTime();
487
+ }
488
+ request.query(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, queryParams));
489
+
490
+ // set header parameters
491
+ request.set(this.defaultHeaders).set(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, headerParams));
492
+ if ((this.defaultHeaders['NTNX-Request-Id'] === null || this.defaultHeaders['NTNX-Request-Id'] === undefined) && (headerParams['NTNX-Request-Id'] === null || headerParams['NTNX-Request-Id'] === undefined)) {
493
+ var requestId = (0, _uuid.v4)();
494
+ request.set(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, {
495
+ 'NTNX-Request-Id': requestId
496
+ }));
497
+ }
498
+
499
+ // Set User-Agent header only if it is not a browser environment
500
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
501
+ if (!isBrowser) {
502
+ this.downloadDestination = '.';
503
+ request.set(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, {
504
+ 'User-Agent': 'Nutanix-security-js-client/4.0.1-beta.1'
505
+ }));
506
+ }
507
+
508
+ // set requestAgent if it is set by user
509
+ if (this.requestAgent) {
510
+ request.agent(this.requestAgent);
511
+ }
512
+
513
+ // set request timeouts
514
+ var timeoutOptions = {};
515
+ timeoutOptions["response"] = _assertClassBrand(_ApiClient_brand, this, _getValidTimeout).call(this, this.connectTimeout, _classPrivateFieldGet(_defaultConnectTimeout, this));
516
+ timeoutOptions["deadline"] = _assertClassBrand(_ApiClient_brand, this, _getValidTimeout).call(this, this.readTimeout, _classPrivateFieldGet(_defaultReadTimeout, this));
517
+ request.timeout(timeoutOptions);
518
+ var contentType = headerParams.hasOwnProperty("Content-Type") ? headerParams["Content-Type"] : _assertClassBrand(_ApiClient_brand, this, _jsonPreferredMime).call(this, contentTypes);
519
+ if (contentType) {
520
+ // Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746)
521
+ if (contentType != 'multipart/form-data') {
522
+ request.type(contentType);
523
+ }
524
+ } else if (!request.header['Content-Type']) {
525
+ request.type('application/json');
526
+ }
527
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Request URL :", httpMethod, url);
528
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, _assertClassBrand(_ApiClient_brand, this, _flatten), "Request Headers :", typeof request.header === "undefined" ? "" : request.header);
529
+ if (contentType === 'application/x-www-form-urlencoded') {
530
+ request.send(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, formParams));
531
+ } else if (contentType == 'multipart/form-data') {
532
+ var _formParams = _assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, formParams);
533
+ for (var key in _formParams) {
534
+ if (_formParams.hasOwnProperty(key)) {
535
+ if (_assertClassBrand(_ApiClient_brand, this, _isFileParam).call(this, _formParams[key])) {
536
+ // file field
537
+ request.attach(key, _formParams[key]);
538
+ } else {
539
+ request.field(key, _formParams[key]);
540
+ }
541
+ }
542
+ }
543
+ } else if (contentType === 'application/octet-stream' && bodyParam !== null && typeof bodyParam !== 'undefined' && typeof bodyParam.pipe === 'function') {
544
+ // FILE UPLOAD SUPPORT
545
+
546
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Piping octet-stream request");
547
+ if (typeof bodyParam.pipe === 'function') {
548
+ bodyParam.pipe(request);
549
+ } else if (typeof require === 'function') {
550
+ var webstream;
551
+ try {
552
+ webstream = require('stream/web');
553
+ } catch (err) {
554
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Error fetching steam/web");
555
+ }
556
+ if (bodyParam instanceof webstream.ReadableStream) {
557
+ bodyParam.pipeTo(new webstream.WritableStream({
558
+ write: function write(chunk) {
559
+ request.write(chunk);
560
+ },
561
+ close: function close() {
562
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "READABLE STREAM CLOSED");
563
+ },
564
+ abort: function abort(err) {
565
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "READABLE STREAM ABORTED");
566
+ }
567
+ }));
568
+ } else {
569
+ request.send(bodyParam);
570
+ }
571
+ } else {
572
+ request.send(bodyParam);
573
+ }
574
+ return new Promise(function (resolve, reject) {
575
+ request.on('error', function (err) {
576
+ _assertClassBrand(_ApiClient_brand, _this2, _log).call(_this2, _classPrivateFieldGet(_LOG_LEVEL, _this2).DEBUG, null, "Caught the following error :", err);
577
+ reject(err);
578
+ }).on('response', function (response) {
579
+ _assertClassBrand(_ApiClient_brand, _this2, _handleApiResponseForPromise).call(_this2, response, path, queryParams, returnType, resolve, reject);
580
+ });
581
+ });
582
+ } else if (bodyParam) {
583
+ request.send(bodyParam);
584
+ }
585
+ if (typeof returnType === 'Blob') {
586
+ request.responseType('blob');
587
+ } else if (returnType === 'String') {
588
+ request.responseType('string');
589
+ }
590
+ _assertClassBrand(_ApiClient_brand, this, _attachCookies).call(this, request);
591
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Request Body :", typeof request._data === "undefined" ? "" : request._data);
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);
608
+ }
609
+ reject(error);
610
+ } else {
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"];
616
+ }
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);
664
+ });
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
+ }
670
+ }
671
+ } else {
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);
686
+ }
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
+ }
712
+ }
713
+ });
714
+ });
715
+ }
716
+ }], [{
717
+ key: "getEtag",
718
+ value: function getEtag(object) {
719
+ var etag = null;
720
+ if (object !== undefined) {
721
+ if (object.hasOwnProperty('$reserved') && object.get$Reserved() !== undefined) {
722
+ etag = this.getValueForCaseInsensitiveKeyMatch(object.get$Reserved(), 'ETag');
723
+ }
724
+ if (etag == null && object.hasOwnProperty("data") && object.getData().hasOwnProperty('$reserved') && object.getData().get$Reserved() !== undefined) {
725
+ etag = this.getValueForCaseInsensitiveKeyMatch(object.getData().get$Reserved(), 'ETag');
726
+ }
727
+ }
728
+ return etag;
729
+ }
730
+ }, {
731
+ key: "getValueForCaseInsensitiveKeyMatch",
732
+ value: function getValueForCaseInsensitiveKeyMatch(object, key) {
733
+ if (object && key) {
734
+ var searchKey = key.toLowerCase();
735
+ var matchedKey = Object.keys(object).find(function (key) {
736
+ return key.toLowerCase() === searchKey;
737
+ });
738
+ return matchedKey ? object[matchedKey] : null;
739
+ }
740
+ return null;
741
+ }
742
+
743
+ // Gets a valid timeout
744
+ // 1. Sets to provided default timeout in case invalid value is passed
745
+ // 2. Sets to default max value of 30 minutes in case a value of more than 30 minutes is passed
746
+ }, {
747
+ key: "addEtagReferenceToHeader",
748
+ value: function addEtagReferenceToHeader(bodyParam, headerParams) {
749
+ // set If-Match header from postBody $reserved map
750
+ if (typeof bodyParam !== 'undefined' && bodyParam !== null) {
751
+ if (bodyParam.hasOwnProperty('$reserved') && bodyParam.$reserved.hasOwnProperty('ETag')) {
752
+ var eTagReference = bodyParam.$reserved['ETag'];
753
+ if (typeof eTagReference !== 'undefined' && eTagReference !== null && eTagReference !== "") {
754
+ headerParams['If-Match'] = eTagReference;
755
+ }
756
+ }
757
+ }
758
+ }
759
+
760
+ /*
761
+ * Parses an ISO-8601 string representation of a date value.
762
+ * @param {String} str The date value as a string.
763
+ * @returns {Date} The parsed date object.
764
+ */
765
+ }, {
766
+ key: "parseDate",
767
+ value: function parseDate(str) {
768
+ return new Date(str);
769
+ }
770
+
771
+ /*
772
+ * Parses queryParams and path to find a given query param value
773
+ * @param {String} path The path given to callApi method
774
+ * @param {Object.<String, Object>} queryParams The queryParams given to callApi method
775
+ * @param {String} param Parameter name to look for
776
+ * @param {String} defaultValue The default value for the missing param if not present
777
+ * @returns {String} The value of given parameter
778
+ */
779
+ }, {
780
+ key: "parseQueryParam",
781
+ value: function parseQueryParam(path, queryParams, param, defaultValue) {
782
+ var value = null;
783
+ if (typeof queryParams !== 'undefined' && queryParams.hasOwnProperty(param)) {
784
+ value = queryParams[param];
785
+ }
786
+ if (value === null && (typeof path === 'string' || path instanceof String)) {
787
+ var escapedParam = param.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
788
+ var regexResult = path.match(new RegExp("".concat(escapedParam, "=([0-9]+)")));
789
+ if (regexResult) {
790
+ value = regexResult[1];
791
+ }
792
+ }
793
+ if (value === null) {
794
+ value = defaultValue;
795
+ }
796
+ return value;
797
+ }
798
+
799
+ /**
800
+ * Converts a value to the specified type.
801
+ * @param {(String|Object)} data The data to convert, as a string or object.
802
+ * @param {(String|Array.<String>|Object.<String, Object>|Function)} type The type to return. Pass a string for simple types
803
+ * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
804
+ * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
805
+ * all properties on <code>data<code> will be converted to this type.
806
+ * @returns An instance of the specified type or null or undefined if data is null or undefined.
807
+ */
808
+ }, {
809
+ key: "convertToType",
810
+ value: function convertToType(data, type) {
811
+ if (data === null || data === undefined) return data;
812
+ switch (type) {
813
+ case 'Boolean':
814
+ return Boolean(data);
815
+ case 'Integer':
816
+ return parseInt(data, 10);
817
+ case 'Number':
818
+ return parseFloat(data);
819
+ case 'String':
820
+ return String(data);
821
+ case 'Date':
822
+ return ApiClient.parseDate(String(data));
823
+ case 'Blob':
824
+ return data;
825
+ default:
826
+ if (type === Object) {
827
+ // generic object, return directly
828
+ return data;
829
+ } else if (typeof type === 'function') {
830
+ // for model type like: User
831
+ return type.constructFromObject(data);
832
+ } else if (Array.isArray(type)) {
833
+ // for array type like: ['String']
834
+ var itemType = type[0];
835
+ return data.map(function (item) {
836
+ return ApiClient.convertToType(item, itemType);
837
+ });
838
+ } else if (_typeof(type) === 'object') {
839
+ // for plain object type like: {'String': 'Integer'}
840
+ var keyType, valueType;
841
+ for (var k in type) {
842
+ if (type.hasOwnProperty(k)) {
843
+ keyType = k;
844
+ valueType = type[k];
845
+ break;
846
+ }
847
+ }
848
+ var result = {};
849
+ for (var k in data) {
850
+ if (data.hasOwnProperty(k)) {
851
+ var key = ApiClient.convertToType(k, keyType);
852
+ var value = ApiClient.convertToType(data[k], valueType);
853
+ result[key] = value;
854
+ }
855
+ }
856
+ return result;
857
+ } else {
858
+ // for unknown type, return the data directly
859
+ return data;
860
+ }
861
+ }
862
+ }
863
+
864
+ /**
865
+ * Constructs a new map or array model from REST data.
866
+ * @param data {Object|Array} The REST data.
867
+ * @param obj {Object|Array} The target object or array.
868
+ */
869
+ }, {
870
+ key: "constructFromObject",
871
+ value: function constructFromObject(data, obj, itemType) {
872
+ if (Array.isArray(data)) {
873
+ for (var i = 0; i < data.length; i++) {
874
+ if (data.hasOwnProperty(i)) obj[i] = ApiClient.convertToType(data[i], itemType);
875
+ }
876
+ } else {
877
+ for (var k in data) {
878
+ if (data.hasOwnProperty(k)) obj[k] = ApiClient.convertToType(data[k], itemType);
879
+ }
880
+ }
881
+ }
882
+ }]);
883
+ }();
884
+ /**
885
+ * The default API client implementation.
886
+ * @type {ApiClient}
887
+ * @memberOf ApiClient
888
+ */
889
+ _ApiClient = ApiClient;
890
+ function _isJsonMime(contentType) {
891
+ return Boolean(contentType != null && contentType.match(/^application\/json(;.*)?$/i));
892
+ }
893
+ /*
894
+ * Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
895
+ * @param {Array.<String>} contentTypes
896
+ * @returns {String} The chosen content type, preferring JSON.
897
+ */
898
+ function _jsonPreferredMime(contentTypes) {
899
+ for (var i = 0; i < contentTypes.length; i++) {
900
+ if (_assertClassBrand(_ApiClient_brand, this, _isJsonMime).call(this, contentTypes[i])) {
901
+ return contentTypes[i];
902
+ }
903
+ }
904
+ return contentTypes[0];
905
+ }
906
+ /*
907
+ * Checks whether the given parameter value represents file-like content.
908
+ * @param param The parameter to check.
909
+ * @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
910
+ */
911
+ function _isFileParam(param) {
912
+ // fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
913
+ if (typeof require === 'function') {
914
+ var _fs;
915
+ try {
916
+ _fs = require('fs');
917
+ } catch (err) {}
918
+ if (_fs && _fs.ReadStream && param instanceof _fs.ReadStream) {
919
+ return true;
920
+ }
921
+ }
922
+
923
+ // Buffer in Node.js
924
+ if (typeof Buffer === 'function' && param instanceof Buffer) {
925
+ return true;
926
+ }
927
+
928
+ // Blob in browser
929
+ if (typeof _buffer.Blob === 'function' && param instanceof _buffer.Blob) {
930
+ return true;
931
+ }
932
+
933
+ // File in browser (it seems File object is also instance of Blob, but keep this for safe)
934
+ if (typeof File === 'function' && param instanceof File) {
935
+ return true;
936
+ }
937
+ return false;
938
+ }
939
+ /*
940
+ * Normalizes parameter values:
941
+ * <ul>
942
+ * <li>remove nils</li>
943
+ * <li>keep files and arrays</li>
944
+ * <li>format to string with `paramToString` for other cases</li>
945
+ * </ul>
946
+ * @param {Object.<String, Object>} params The parameters as object properties.
947
+ * @returns {Object.<String, Object>} normalized parameters.
948
+ */
949
+ function _normalizeParams(params) {
950
+ var newParams = {};
951
+ for (var key in params) {
952
+ if (params.hasOwnProperty(key) && params[key] != undefined && params[key] != null) {
953
+ var value = params[key];
954
+ if (_assertClassBrand(_ApiClient_brand, this, _isFileParam).call(this, value) || Array.isArray(value)) {
955
+ newParams[key] = value;
956
+ } else {
957
+ newParams[key] = this.paramToString(value);
958
+ }
959
+ }
960
+ }
961
+ return newParams;
962
+ }
963
+ function _applyAuthToRequest(request, authNames) {
964
+ var _this3 = this;
965
+ authNames.forEach(function (authName) {
966
+ var auth = _this3.authentications[authName];
967
+ switch (auth.type) {
968
+ case 'basic':
969
+ if (auth.username || auth.password) {
970
+ request.auth(auth.username || '', auth.password || '');
971
+ } else if (_this3.username || _this3.password) {
972
+ request.auth(_this3.username || '', _this3.password || '');
973
+ }
974
+ _assertClassBrand(_ApiClient_brand, _this3, _log).call(_this3, _classPrivateFieldGet(_LOG_LEVEL, _this3).DEBUG, null, "Basic Auth applied to request");
975
+ break;
976
+ case 'apiKey':
977
+ if (auth.apiKey) {
978
+ var data = {};
979
+ if (auth.apiKeyPrefix) {
980
+ data[auth.name] = auth.apiKeyPrefix + ' ' + auth.apiKey;
981
+ } else {
982
+ data[auth.name] = auth.apiKey;
983
+ }
984
+ if (auth['in'] === 'header') {
985
+ request.set(data);
986
+ } else {
987
+ request.query(data);
988
+ }
989
+ }
990
+ _assertClassBrand(_ApiClient_brand, _this3, _log).call(_this3, _classPrivateFieldGet(_LOG_LEVEL, _this3).DEBUG, null, "apiKey applied to request");
991
+ break;
992
+ case 'oauth2':
993
+ if (auth.accessToken) {
994
+ request.set({
995
+ 'Authorization': 'Bearer ' + auth.accessToken
996
+ });
997
+ }
998
+ _assertClassBrand(_ApiClient_brand, _this3, _log).call(_this3, _classPrivateFieldGet(_LOG_LEVEL, _this3).DEBUG, null, "oauth2 applied to request");
999
+ break;
1000
+ default:
1001
+ _assertClassBrand(_ApiClient_brand, _this3, _log).call(_this3, _classPrivateFieldGet(_LOG_LEVEL, _this3).ERROR, null, "Unknown authentication type:", auth.type);
1002
+ throw new Error('Unknown authentication type: ' + auth.type);
1003
+ }
1004
+ });
1005
+ }
1006
+ /**
1007
+ * Wraps errors in generic response format.
1008
+ * @param {Object} error object encountered during request.
1009
+ * @returns an error object with wrapped response within error.data .
1010
+ */
1011
+ function _wrapErrorInResponse(error) {
1012
+ var response = {
1013
+ data: {},
1014
+ metadata: {}
1015
+ };
1016
+ response.data.status = error.status;
1017
+ response.data.message = error.message;
1018
+ }
1019
+ /**
1020
+ * Deserializes an HTTP response body into a value of the specified type.
1021
+ * @param {Object} response A SuperAgent response object.
1022
+ * @param {(String|Array.<String>|Object.<String, Object>|Function)} returnType The type to return. Pass a string for simple types
1023
+ * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
1024
+ * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
1025
+ * all properties on <code>data<code> will be converted to this type.
1026
+ * @returns A value of the specified type.
1027
+ */
1028
+ function _deserialize(response, returnType) {
1029
+ if (response == null || returnType == null || response.status == 204) {
1030
+ return null;
1031
+ }
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
+ // Rely on SuperAgent for parsing response body.
1050
+ // See http://visionmedia.github.io/superagent/#parsing-response-bodies
1051
+ var data = response.body;
1052
+ if (data == null || _typeof(data) === 'object' && typeof data.length === 'undefined' && !Object.keys(data).length) {
1053
+ // SuperAgent does not always produce a body; use the unparsed response as a fallback
1054
+ data = response.text;
1055
+ }
1056
+ return _ApiClient.convertToType(data, returnType);
1057
+ }
1058
+ /**
1059
+ * Set pagination data if response is a Paginable object
1060
+ * @param {Object} data The response data already passed through deserialize
1061
+ * @param {String} path The path given to callApi method
1062
+ * @param {Object.<String, Object>} queryParams The queryParams given to callApi method
1063
+ */
1064
+ function _paginateIfNeeded(data, path, queryParams) {
1065
+ // If response is not a Paginable instance, nothing to do
1066
+ if (!(data instanceof _Paginable["default"])) {
1067
+ return;
1068
+ }
1069
+ // Retrieve current page number, defaults to 0
1070
+ var page = parseInt(this.constructor.parseQueryParam(path, queryParams, '$page', "0"), 10);
1071
+ // Retrieve current limit (results per page) number, defaults to 50
1072
+ var resultsPerPage = parseInt(this.constructor.parseQueryParam(path, queryParams, '$limit', "50"), 10);
1073
+
1074
+ // Populate pagination data
1075
+ data.populatePaginationMetadata(this,
1076
+ // current ApiClient instance
1077
+ page, resultsPerPage);
1078
+ }
1079
+ function _getValidTimeout(timeout, defaultTimeout) {
1080
+ if (timeout <= 0) {
1081
+ timeout = defaultTimeout;
1082
+ } else if (timeout > _classPrivateFieldGet(_defaultMaxTimeout, this)) {
1083
+ timeout = _classPrivateFieldGet(_defaultMaxTimeout, this);
1084
+ }
1085
+ return timeout;
1086
+ }
1087
+ // If enabled, update cookie information to reuse in subsequent requests for a valid response
1088
+ function _updateCookies(response) {
1089
+ if (response.hasOwnProperty("headers") && response.headers.hasOwnProperty("set-cookie")) {
1090
+ var finalCookie = "";
1091
+ var cookieList = response.headers["set-cookie"];
1092
+ if (cookieList.length > 0) {
1093
+ // add all cookies separated by ;
1094
+ var _iterator2 = _createForOfIteratorHelper(cookieList),
1095
+ _step2;
1096
+ try {
1097
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1098
+ var cookieItem = _step2.value;
1099
+ cookieItem = cookieItem.split(";")[0];
1100
+ if (cookieItem.includes("=")) {
1101
+ cookieItem.trim();
1102
+ finalCookie = finalCookie.concat(cookieItem).concat(";");
1103
+ }
1104
+ }
1105
+ // remove trailing ;
1106
+ } catch (err) {
1107
+ _iterator2.e(err);
1108
+ } finally {
1109
+ _iterator2.f();
1110
+ }
1111
+ if (finalCookie !== "") {
1112
+ finalCookie = finalCookie.substr(0, finalCookie.length - 1);
1113
+ }
1114
+ }
1115
+ _classPrivateFieldSet(_cookie, this, finalCookie);
1116
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Retained cookie :", finalCookie);
1117
+ } else {
1118
+ _classPrivateFieldSet(_cookie, this, null);
1119
+ }
1120
+ }
1121
+ // If enabled, attach saved cookies to request
1122
+ function _attachCookies(request) {
1123
+ if (_classPrivateFieldGet(_cookie, this) != null) {
1124
+ request.set(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, {
1125
+ 'Cookie': _classPrivateFieldGet(_cookie, this)
1126
+ }));
1127
+ }
1128
+ }
1129
+ function _log(level, mapper) {
1130
+ for (var _len = arguments.length, messages = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1131
+ messages[_key - 2] = arguments[_key];
1132
+ }
1133
+ // Set default log level to INFO
1134
+ if (_typeof(level) !== "object" || !("key" in level) || !("value" in level) || _typeof(level["value"]) !== "symbol") {
1135
+ level = _classPrivateFieldGet(_LOG_LEVEL, this).INFO;
1136
+ }
1137
+ if (!_assertClassBrand(_ApiClient_brand, this, _skipLogging).call(this, level)) {
1138
+ // Preprocess message to prefix with timestamp and log level
1139
+ messages = messages.map(function (message) {
1140
+ return typeof message === "string" ? message : mapper ? mapper(message) : JSON.stringify(message);
1141
+ });
1142
+ var message = messages.join(' ');
1143
+ message = _assertClassBrand(_ApiClient_brand, this, _getLocalDateTime).call(this) + ' ' + level.key + ' - ' + message;
1144
+ if (typeof _classPrivateFieldGet(_logger, this) !== "undefined" && _classPrivateFieldGet(_logger, this) !== null && typeof _classPrivateFieldGet(_logger, this).log === 'function') {
1145
+ _classPrivateFieldGet(_logger, this).log(message);
1146
+ } else {
1147
+ console.log(message);
1148
+ }
1149
+ }
1150
+ }
1151
+ function _skipLogging(level) {
1152
+ // Skip logging if log level is DEBUG but debug is not enabled.
1153
+ return !this.debug && level === _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG;
1154
+ }
1155
+ function _getLocalDateTime() {
1156
+ // Current epoch UTC time in milliseconds
1157
+ var epochTime = Date.now();
1158
+
1159
+ // "getTimezoneOffset" returns the difference, in minutes, between a date as evaluated in the UTC time zone,
1160
+ // and the same date as evaluated in the local time zone.
1161
+ // if you are in timezone UTC-1, outputs 60
1162
+ // if you are in timezone UTC+3, outputs -180
1163
+ var timezoneOffsetInMinutes = new Date().getTimezoneOffset();
1164
+ var timezoneOffsetInMilliseconds = timezoneOffsetInMinutes * 60 * 1000;
1165
+
1166
+ // Create a new date with adjusted epoch time based on timezone offset
1167
+ var date = new Date(epochTime - timezoneOffsetInMilliseconds);
1168
+ return date.toISOString().slice(0, 23);
1169
+ }
1170
+ // A mapper function to flatten a simple non-nested (key:value) object to string
1171
+ function _flatten(obj) {
1172
+ if (_typeof(obj) !== "object") {
1173
+ return obj;
1174
+ }
1175
+ var output = '\n';
1176
+ if (obj) {
1177
+ Object.keys(obj).forEach(function (e) {
1178
+ output += e + '=[' + obj[e] + ']\n';
1179
+ });
1180
+ }
1181
+ return output === '\n' ? obj : output;
1182
+ }
1183
+ // handle and deserialize received response
1184
+ function _handleApiResponseForPromise(response, path, queryParams, returnType, resolve, reject) {
1185
+ try {
1186
+ var data = _assertClassBrand(_ApiClient_brand, this, _deserialize).call(this, response, returnType);
1187
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Response Status :", response.status);
1188
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, _assertClassBrand(_ApiClient_brand, this, _flatten), "Response Headers :", response.headers);
1189
+ _assertClassBrand(_ApiClient_brand, this, _updateCookies).call(this, response || {});
1190
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Response Body :", data);
1191
+ if (response.status == 204 && data == null) {
1192
+ resolve({
1193
+ data: data,
1194
+ response: response
1195
+ });
1196
+ } else if (response.ok && data != null) {
1197
+ this.addEtagToReservedMap(response, data);
1198
+ _assertClassBrand(_ApiClient_brand, this, _paginateIfNeeded).call(this, data, path, queryParams);
1199
+ resolve({
1200
+ data: data,
1201
+ response: response
1202
+ });
1203
+ } else {
1204
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, data);
1205
+ reject(_objectSpread(_objectSpread({}, response.error), {}, {
1206
+ data: data
1207
+ }));
1208
+ }
1209
+ } catch (err) {
1210
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Caught error while processing response!");
1211
+ _assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, err);
1212
+ err.data = _assertClassBrand(_ApiClient_brand, this, _wrapErrorInResponse).call(this, err);
1213
+ reject(err);
1214
+ }
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
+ }
1271
+ ApiClient.instance = new ApiClient();