@nutanix-scratch/aiops-js-client 4.0.3-alpha.2 → 4.2.2-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.
- package/LICENSE.txt +202 -49
- package/README.md +70 -43
- package/dist/Ntnx-Aiops-js-client-prod.js +1 -11
- package/dist/Ntnx-Aiops-js-client.js +1045 -1019
- package/dist/es/ApiClient.d.ts +43 -7
- package/dist/es/ApiClient.js +1071 -678
- package/dist/es/Paginable.d.ts +1 -1
- package/dist/es/Paginable.js +153 -194
- package/dist/es/apis/scenarios-endpoints.d.ts +181 -0
- package/dist/es/apis/scenarios-endpoints.js +624 -0
- package/dist/es/apis/stats-endpoints.d.ts +31 -41
- package/dist/es/apis/stats-endpoints.js +215 -230
- package/dist/es/index.d.ts +157 -21
- package/dist/es/index.js +669 -126
- package/dist/es/models/aiops/v4/clusterMetrics/Cluster.d.ts +144 -0
- package/dist/es/models/aiops/v4/clusterMetrics/Cluster.js +597 -0
- package/dist/es/models/aiops/v4/clusterMetrics/ClusterMetrics.d.ts +274 -0
- package/dist/es/models/aiops/v4/clusterMetrics/ClusterMetrics.js +1062 -0
- package/dist/es/models/aiops/v4/clusterMetrics/ClusterProjection.d.ts +31 -0
- package/dist/es/models/aiops/v4/clusterMetrics/ClusterProjection.js +368 -0
- package/dist/es/models/aiops/v4/clusterMetrics/Node.d.ts +81 -0
- package/dist/es/models/aiops/v4/clusterMetrics/Node.js +366 -0
- package/dist/es/models/aiops/v4/clusterMetrics/NodeProjection.d.ts +10 -0
- package/dist/es/models/aiops/v4/clusterMetrics/NodeProjection.js +121 -0
- package/dist/es/models/aiops/v4/clusterMetrics/Vm.d.ts +81 -0
- package/dist/es/models/aiops/v4/clusterMetrics/Vm.js +366 -0
- package/dist/es/models/aiops/v4/clusterMetrics/VmProjection.d.ts +10 -0
- package/dist/es/models/aiops/v4/clusterMetrics/VmProjection.js +121 -0
- package/dist/es/models/aiops/v4/common/ClusterType.d.ts +19 -0
- package/dist/es/models/aiops/v4/common/ClusterType.js +77 -0
- package/dist/es/models/aiops/v4/config/CapacityType.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/CapacityType.js +95 -0
- package/dist/es/models/aiops/v4/config/CapacityUnit.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/CapacityUnit.js +83 -0
- package/dist/es/models/aiops/v4/config/CapacityUpdateConfig.d.ts +71 -0
- package/dist/es/models/aiops/v4/config/CapacityUpdateConfig.js +281 -0
- package/dist/es/models/aiops/v4/config/CapacityUpdateType.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/CapacityUpdateType.js +83 -0
- package/dist/es/models/aiops/v4/config/CitrixXenProvisionType.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/CitrixXenProvisionType.js +83 -0
- package/dist/es/models/aiops/v4/config/CitrixXenWorkload.d.ts +70 -0
- package/dist/es/models/aiops/v4/config/CitrixXenWorkload.js +338 -0
- package/dist/es/models/aiops/v4/config/CitrixXenWorkloadVendor.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/CitrixXenWorkloadVendor.js +77 -0
- package/dist/es/models/aiops/v4/config/ClusterConfig.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/ClusterConfig.js +279 -0
- package/dist/es/models/aiops/v4/config/ClusterType.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/ClusterType.js +83 -0
- package/dist/es/models/aiops/v4/config/CreateScenarioApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/CreateScenarioApiResponse.js +288 -0
- package/dist/es/models/aiops/v4/config/CreateSimulationApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/CreateSimulationApiResponse.js +288 -0
- package/dist/es/models/aiops/v4/config/DataStoreConfig.d.ts +191 -0
- package/dist/es/models/aiops/v4/config/DataStoreConfig.js +616 -0
- package/dist/es/models/aiops/v4/config/DeleteScenarioApiResponse.d.ts +57 -0
- package/dist/es/models/aiops/v4/config/DeleteScenarioApiResponse.js +290 -0
- package/dist/es/models/aiops/v4/config/DeleteSimulationApiResponse.d.ts +57 -0
- package/dist/es/models/aiops/v4/config/DeleteSimulationApiResponse.js +290 -0
- package/dist/es/models/aiops/v4/config/EntityDescriptor.d.ts +67 -0
- package/dist/es/models/aiops/v4/config/EntityDescriptor.js +396 -0
- package/dist/es/models/aiops/v4/config/EntityDescriptorListApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/EntityDescriptorListApiResponse.js +310 -0
- package/dist/es/models/aiops/v4/config/EntityDetail.d.ts +29 -0
- package/dist/es/models/aiops/v4/config/EntityDetail.js +260 -0
- package/dist/es/models/aiops/v4/config/EntityType.d.ts +22 -0
- package/dist/es/models/aiops/v4/config/EntityType.js +233 -0
- package/dist/es/models/aiops/v4/config/EntityTypeListApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/EntityTypeListApiResponse.js +310 -0
- package/dist/es/models/aiops/v4/config/GenerateRecommendationApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/GenerateRecommendationApiResponse.js +288 -0
- package/dist/es/models/aiops/v4/config/GenerateReportApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/GenerateReportApiResponse.js +288 -0
- package/dist/es/models/aiops/v4/config/GenerateRunwayApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/GenerateRunwayApiResponse.js +288 -0
- package/dist/es/models/aiops/v4/config/GetScenarioApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/GetScenarioApiResponse.js +288 -0
- package/dist/es/models/aiops/v4/config/GetScenarioReportApiResponse.d.ts +57 -0
- package/dist/es/models/aiops/v4/config/GetScenarioReportApiResponse.js +287 -0
- package/dist/es/models/aiops/v4/config/GetSimulationApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/GetSimulationApiResponse.js +288 -0
- package/dist/es/models/aiops/v4/config/ListScenariosApiResponse.d.ts +59 -0
- package/dist/es/models/aiops/v4/config/ListScenariosApiResponse.js +315 -0
- package/dist/es/models/aiops/v4/config/ListSimulationsApiResponse.d.ts +59 -0
- package/dist/es/models/aiops/v4/config/ListSimulationsApiResponse.js +315 -0
- package/dist/es/models/aiops/v4/config/MetricDescriptor.d.ts +155 -0
- package/dist/es/models/aiops/v4/config/MetricDescriptor.js +604 -0
- package/dist/es/models/aiops/v4/config/MicrosoftXenProvisionType.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/MicrosoftXenProvisionType.js +77 -0
- package/dist/es/models/aiops/v4/config/MicrosoftXenWorkload.d.ts +70 -0
- package/dist/es/models/aiops/v4/config/MicrosoftXenWorkload.js +338 -0
- package/dist/es/models/aiops/v4/config/MicrosoftXenWorkloadVendor.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/MicrosoftXenWorkloadVendor.js +77 -0
- package/dist/es/models/aiops/v4/config/NodeConfig.d.ts +135 -0
- package/dist/es/models/aiops/v4/config/NodeConfig.js +478 -0
- package/dist/es/models/aiops/v4/config/NodeSource.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/NodeSource.js +89 -0
- package/dist/es/models/aiops/v4/config/PolicyType.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/PolicyType.js +83 -0
- package/dist/es/models/aiops/v4/config/ReplicationFactor.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/ReplicationFactor.js +83 -0
- package/dist/es/models/aiops/v4/config/ResourceCapacity.d.ts +117 -0
- package/dist/es/models/aiops/v4/config/ResourceCapacity.js +404 -0
- package/dist/es/models/aiops/v4/config/Runway.d.ts +125 -0
- package/dist/es/models/aiops/v4/config/Runway.js +437 -0
- package/dist/es/models/aiops/v4/config/Scenario.d.ts +134 -0
- package/dist/es/models/aiops/v4/config/Scenario.js +626 -0
- package/dist/es/models/aiops/v4/config/ScenarioProjection.d.ts +10 -0
- package/dist/es/models/aiops/v4/config/ScenarioProjection.js +127 -0
- package/dist/es/models/aiops/v4/config/SimulatedVmResourceSpec.d.ts +98 -0
- package/dist/es/models/aiops/v4/config/SimulatedVmResourceSpec.js +358 -0
- package/dist/es/models/aiops/v4/config/SimulatedVmResourceSpecProjection.d.ts +16 -0
- package/dist/es/models/aiops/v4/config/SimulatedVmResourceSpecProjection.js +133 -0
- package/dist/es/models/aiops/v4/config/Simulation.d.ts +32 -0
- package/dist/es/models/aiops/v4/config/Simulation.js +273 -0
- package/dist/es/models/aiops/v4/config/SimulationProjection.d.ts +10 -0
- package/dist/es/models/aiops/v4/config/SimulationProjection.js +124 -0
- package/dist/es/models/aiops/v4/config/Source.d.ts +22 -0
- package/dist/es/models/aiops/v4/config/Source.js +233 -0
- package/dist/es/models/aiops/v4/config/SourceListApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/SourceListApiResponse.js +310 -0
- package/dist/es/models/aiops/v4/config/SplunkWorkload.d.ts +110 -0
- package/dist/es/models/aiops/v4/config/SplunkWorkload.js +401 -0
- package/dist/es/models/aiops/v4/config/SqlProfileType.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/SqlProfileType.js +89 -0
- package/dist/es/models/aiops/v4/config/SqlTransactionType.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/SqlTransactionType.js +83 -0
- package/dist/es/models/aiops/v4/config/SqlWorkload.d.ts +102 -0
- package/dist/es/models/aiops/v4/config/SqlWorkload.js +370 -0
- package/dist/es/models/aiops/v4/config/UpdateScenarioApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/UpdateScenarioApiResponse.js +288 -0
- package/dist/es/models/aiops/v4/config/UpdateSimulationApiResponse.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/UpdateSimulationApiResponse.js +310 -0
- package/dist/es/models/aiops/v4/config/ValueRange.d.ts +58 -0
- package/dist/es/models/aiops/v4/config/ValueRange.js +271 -0
- package/dist/es/models/aiops/v4/{stats → config}/ValueType.js +12 -15
- package/dist/es/models/aiops/v4/config/VdiProvisionType.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/VdiProvisionType.js +101 -0
- package/dist/es/models/aiops/v4/config/VdiUserType.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/VdiUserType.js +95 -0
- package/dist/es/models/aiops/v4/config/VdiVendor.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/VdiVendor.js +83 -0
- package/dist/es/models/aiops/v4/config/VdiWorkload.d.ts +101 -0
- package/dist/es/models/aiops/v4/config/VdiWorkload.js +367 -0
- package/dist/es/models/aiops/v4/config/Vendor.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/Vendor.js +125 -0
- package/dist/es/models/aiops/v4/config/VmCategoryWorkload.d.ts +79 -0
- package/dist/es/models/aiops/v4/config/VmCategoryWorkload.js +311 -0
- package/dist/es/models/aiops/v4/config/VmWorkload.d.ts +74 -0
- package/dist/es/models/aiops/v4/config/VmWorkload.js +294 -0
- package/dist/es/models/aiops/v4/config/Workload.d.ts +105 -0
- package/dist/es/models/aiops/v4/config/Workload.js +398 -0
- package/dist/es/models/aiops/v4/config/XenOperatingSystem.d.ts +19 -0
- package/dist/es/models/aiops/v4/config/XenOperatingSystem.js +83 -0
- package/dist/es/models/aiops/v4/config/XenWorkload.d.ts +141 -0
- package/dist/es/models/aiops/v4/config/XenWorkload.js +483 -0
- package/dist/es/models/aiops/v4/config/XfitPolicy.d.ts +121 -0
- package/dist/es/models/aiops/v4/config/XfitPolicy.js +541 -0
- package/dist/es/models/aiops/v4/config/XfitPolicyProjection.d.ts +14 -0
- package/dist/es/models/aiops/v4/config/XfitPolicyProjection.js +134 -0
- package/dist/es/models/aiops/v4/error/AppMessage.d.ts +62 -55
- package/dist/es/models/aiops/v4/error/AppMessage.js +303 -310
- package/dist/es/models/aiops/v4/error/ErrorResponse.d.ts +23 -24
- package/dist/es/models/aiops/v4/error/ErrorResponse.js +224 -223
- package/dist/es/models/aiops/v4/error/SchemaValidationError.d.ts +52 -48
- package/dist/es/models/aiops/v4/error/SchemaValidationError.js +287 -292
- package/dist/es/models/aiops/v4/error/SchemaValidationErrorMessage.d.ts +37 -36
- package/dist/es/models/aiops/v4/error/SchemaValidationErrorMessage.js +224 -228
- package/dist/es/models/aiops/v4/stats/BoolList.d.ts +29 -27
- package/dist/es/models/aiops/v4/stats/BoolList.js +182 -185
- package/dist/es/models/aiops/v4/stats/BoolVal.d.ts +29 -27
- package/dist/es/models/aiops/v4/stats/BoolVal.js +175 -178
- package/dist/es/models/aiops/v4/stats/DoubleList.d.ts +29 -27
- package/dist/es/models/aiops/v4/stats/DoubleList.js +182 -185
- package/dist/es/models/aiops/v4/stats/DoubleVal.d.ts +29 -27
- package/dist/es/models/aiops/v4/stats/DoubleVal.js +175 -178
- package/dist/es/models/aiops/v4/stats/Entity.d.ts +25 -37
- package/dist/es/models/aiops/v4/stats/Entity.js +269 -280
- package/dist/es/models/aiops/v4/stats/EntityListApiResponse.d.ts +29 -30
- package/dist/es/models/aiops/v4/stats/EntityListApiResponse.js +239 -265
- package/dist/es/models/aiops/v4/stats/IntList.d.ts +29 -27
- package/dist/es/models/aiops/v4/stats/IntList.js +182 -185
- package/dist/es/models/aiops/v4/stats/IntVal.d.ts +29 -27
- package/dist/es/models/aiops/v4/stats/IntVal.js +175 -178
- package/dist/es/models/aiops/v4/stats/Metric.d.ts +29 -30
- package/dist/es/models/aiops/v4/stats/Metric.js +197 -205
- package/dist/es/models/aiops/v4/stats/Point.d.ts +34 -30
- package/dist/es/models/aiops/v4/stats/Point.js +231 -246
- package/dist/es/models/aiops/v4/stats/StrList.d.ts +29 -27
- package/dist/es/models/aiops/v4/stats/StrList.js +182 -185
- package/dist/es/models/aiops/v4/stats/StrVal.d.ts +29 -27
- package/dist/es/models/aiops/v4/stats/StrVal.js +175 -178
- package/dist/es/models/aiops/v4/stats/TimeSeries.d.ts +29 -30
- package/dist/es/models/aiops/v4/stats/TimeSeries.js +207 -218
- package/dist/es/models/common/v1/config/Flag.d.ts +30 -30
- package/dist/es/models/common/v1/config/Flag.js +203 -202
- package/dist/es/models/common/v1/config/IPv4Address.d.ts +70 -0
- package/dist/es/models/common/v1/config/IPv4Address.js +288 -0
- package/dist/es/models/common/v1/config/KVPair.d.ts +34 -31
- package/dist/es/models/common/v1/config/KVPair.js +259 -260
- package/dist/es/models/common/v1/config/KVStringPair.d.ts +58 -0
- package/dist/es/models/common/v1/config/KVStringPair.js +277 -0
- package/dist/es/models/common/v1/config/MapOfStringWrapper.d.ts +53 -0
- package/dist/es/models/common/v1/config/MapOfStringWrapper.js +236 -0
- package/dist/es/models/common/v1/config/Message.d.ts +37 -42
- package/dist/es/models/common/v1/config/Message.js +244 -259
- package/dist/es/models/common/v1/config/MessageSeverity.js +18 -21
- package/dist/es/models/common/v1/config/TenantAwareModel.d.ts +23 -26
- package/dist/es/models/common/v1/config/TenantAwareModel.js +169 -179
- package/dist/es/models/common/v1/response/ApiLink.d.ts +26 -30
- package/dist/es/models/common/v1/response/ApiLink.js +197 -208
- package/dist/es/models/common/v1/response/ApiResponseMetadata.d.ts +47 -50
- package/dist/es/models/common/v1/response/ApiResponseMetadata.js +313 -334
- package/dist/es/models/common/v1/response/ExternalizableAbstractModel.d.ts +15 -23
- package/dist/es/models/common/v1/response/ExternalizableAbstractModel.js +195 -206
- package/dist/es/models/common/v1/stats/DownSamplingOperator.js +24 -27
- package/dist/es/models/prism/v4/config/TaskReference.d.ts +47 -0
- package/dist/es/models/prism/v4/config/TaskReference.js +244 -0
- package/dist/es/models/validation/ValidationError.js +27 -45
- package/dist/es/models/validation/ValidationScopes.js +3 -4
- package/dist/es/utils/ValidationUtils.js +40 -72
- package/dist/lib/ApiClient.d.ts +43 -7
- package/dist/lib/ApiClient.js +1071 -678
- package/dist/lib/Paginable.d.ts +1 -1
- package/dist/lib/Paginable.js +153 -194
- package/dist/lib/apis/scenarios-endpoints.d.ts +181 -0
- package/dist/lib/apis/scenarios-endpoints.js +624 -0
- package/dist/lib/apis/stats-endpoints.d.ts +31 -41
- package/dist/lib/apis/stats-endpoints.js +215 -230
- package/dist/lib/index.d.ts +157 -21
- package/dist/lib/index.js +669 -126
- package/dist/lib/models/aiops/v4/clusterMetrics/Cluster.d.ts +144 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/Cluster.js +597 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/ClusterMetrics.d.ts +274 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/ClusterMetrics.js +1062 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/ClusterProjection.d.ts +31 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/ClusterProjection.js +368 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/Node.d.ts +81 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/Node.js +366 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/NodeProjection.d.ts +10 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/NodeProjection.js +121 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/Vm.d.ts +81 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/Vm.js +366 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/VmProjection.d.ts +10 -0
- package/dist/lib/models/aiops/v4/clusterMetrics/VmProjection.js +121 -0
- package/dist/lib/models/aiops/v4/common/ClusterType.d.ts +19 -0
- package/dist/lib/models/aiops/v4/common/ClusterType.js +77 -0
- package/dist/lib/models/aiops/v4/config/CapacityType.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/CapacityType.js +95 -0
- package/dist/lib/models/aiops/v4/config/CapacityUnit.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/CapacityUnit.js +83 -0
- package/dist/lib/models/aiops/v4/config/CapacityUpdateConfig.d.ts +71 -0
- package/dist/lib/models/aiops/v4/config/CapacityUpdateConfig.js +281 -0
- package/dist/lib/models/aiops/v4/config/CapacityUpdateType.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/CapacityUpdateType.js +83 -0
- package/dist/lib/models/aiops/v4/config/CitrixXenProvisionType.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/CitrixXenProvisionType.js +83 -0
- package/dist/lib/models/aiops/v4/config/CitrixXenWorkload.d.ts +70 -0
- package/dist/lib/models/aiops/v4/config/CitrixXenWorkload.js +338 -0
- package/dist/lib/models/aiops/v4/config/CitrixXenWorkloadVendor.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/CitrixXenWorkloadVendor.js +77 -0
- package/dist/lib/models/aiops/v4/config/ClusterConfig.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/ClusterConfig.js +279 -0
- package/dist/lib/models/aiops/v4/config/ClusterType.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/ClusterType.js +83 -0
- package/dist/lib/models/aiops/v4/config/CreateScenarioApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/CreateScenarioApiResponse.js +288 -0
- package/dist/lib/models/aiops/v4/config/CreateSimulationApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/CreateSimulationApiResponse.js +288 -0
- package/dist/lib/models/aiops/v4/config/DataStoreConfig.d.ts +191 -0
- package/dist/lib/models/aiops/v4/config/DataStoreConfig.js +616 -0
- package/dist/lib/models/aiops/v4/config/DeleteScenarioApiResponse.d.ts +57 -0
- package/dist/lib/models/aiops/v4/config/DeleteScenarioApiResponse.js +290 -0
- package/dist/lib/models/aiops/v4/config/DeleteSimulationApiResponse.d.ts +57 -0
- package/dist/lib/models/aiops/v4/config/DeleteSimulationApiResponse.js +290 -0
- package/dist/lib/models/aiops/v4/config/EntityDescriptor.d.ts +67 -0
- package/dist/lib/models/aiops/v4/config/EntityDescriptor.js +396 -0
- package/dist/lib/models/aiops/v4/config/EntityDescriptorListApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/EntityDescriptorListApiResponse.js +310 -0
- package/dist/lib/models/aiops/v4/config/EntityDetail.d.ts +29 -0
- package/dist/lib/models/aiops/v4/config/EntityDetail.js +260 -0
- package/dist/lib/models/aiops/v4/config/EntityType.d.ts +22 -0
- package/dist/lib/models/aiops/v4/config/EntityType.js +233 -0
- package/dist/lib/models/aiops/v4/config/EntityTypeListApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/EntityTypeListApiResponse.js +310 -0
- package/dist/lib/models/aiops/v4/config/GenerateRecommendationApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/GenerateRecommendationApiResponse.js +288 -0
- package/dist/lib/models/aiops/v4/config/GenerateReportApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/GenerateReportApiResponse.js +288 -0
- package/dist/lib/models/aiops/v4/config/GenerateRunwayApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/GenerateRunwayApiResponse.js +288 -0
- package/dist/lib/models/aiops/v4/config/GetScenarioApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/GetScenarioApiResponse.js +288 -0
- package/dist/lib/models/aiops/v4/config/GetScenarioReportApiResponse.d.ts +57 -0
- package/dist/lib/models/aiops/v4/config/GetScenarioReportApiResponse.js +287 -0
- package/dist/lib/models/aiops/v4/config/GetSimulationApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/GetSimulationApiResponse.js +288 -0
- package/dist/lib/models/aiops/v4/config/ListScenariosApiResponse.d.ts +59 -0
- package/dist/lib/models/aiops/v4/config/ListScenariosApiResponse.js +315 -0
- package/dist/lib/models/aiops/v4/config/ListSimulationsApiResponse.d.ts +59 -0
- package/dist/lib/models/aiops/v4/config/ListSimulationsApiResponse.js +315 -0
- package/dist/lib/models/aiops/v4/config/MetricDescriptor.d.ts +155 -0
- package/dist/lib/models/aiops/v4/config/MetricDescriptor.js +604 -0
- package/dist/lib/models/aiops/v4/config/MicrosoftXenProvisionType.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/MicrosoftXenProvisionType.js +77 -0
- package/dist/lib/models/aiops/v4/config/MicrosoftXenWorkload.d.ts +70 -0
- package/dist/lib/models/aiops/v4/config/MicrosoftXenWorkload.js +338 -0
- package/dist/lib/models/aiops/v4/config/MicrosoftXenWorkloadVendor.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/MicrosoftXenWorkloadVendor.js +77 -0
- package/dist/lib/models/aiops/v4/config/NodeConfig.d.ts +135 -0
- package/dist/lib/models/aiops/v4/config/NodeConfig.js +478 -0
- package/dist/lib/models/aiops/v4/config/NodeSource.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/NodeSource.js +89 -0
- package/dist/lib/models/aiops/v4/config/PolicyType.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/PolicyType.js +83 -0
- package/dist/lib/models/aiops/v4/config/ReplicationFactor.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/ReplicationFactor.js +83 -0
- package/dist/lib/models/aiops/v4/config/ResourceCapacity.d.ts +117 -0
- package/dist/lib/models/aiops/v4/config/ResourceCapacity.js +404 -0
- package/dist/lib/models/aiops/v4/config/Runway.d.ts +125 -0
- package/dist/lib/models/aiops/v4/config/Runway.js +437 -0
- package/dist/lib/models/aiops/v4/config/Scenario.d.ts +134 -0
- package/dist/lib/models/aiops/v4/config/Scenario.js +626 -0
- package/dist/lib/models/aiops/v4/config/ScenarioProjection.d.ts +10 -0
- package/dist/lib/models/aiops/v4/config/ScenarioProjection.js +127 -0
- package/dist/lib/models/aiops/v4/config/SimulatedVmResourceSpec.d.ts +98 -0
- package/dist/lib/models/aiops/v4/config/SimulatedVmResourceSpec.js +358 -0
- package/dist/lib/models/aiops/v4/config/SimulatedVmResourceSpecProjection.d.ts +16 -0
- package/dist/lib/models/aiops/v4/config/SimulatedVmResourceSpecProjection.js +133 -0
- package/dist/lib/models/aiops/v4/config/Simulation.d.ts +32 -0
- package/dist/lib/models/aiops/v4/config/Simulation.js +273 -0
- package/dist/lib/models/aiops/v4/config/SimulationProjection.d.ts +10 -0
- package/dist/lib/models/aiops/v4/config/SimulationProjection.js +124 -0
- package/dist/lib/models/aiops/v4/config/Source.d.ts +22 -0
- package/dist/lib/models/aiops/v4/config/Source.js +233 -0
- package/dist/lib/models/aiops/v4/config/SourceListApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/SourceListApiResponse.js +310 -0
- package/dist/lib/models/aiops/v4/config/SplunkWorkload.d.ts +110 -0
- package/dist/lib/models/aiops/v4/config/SplunkWorkload.js +401 -0
- package/dist/lib/models/aiops/v4/config/SqlProfileType.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/SqlProfileType.js +89 -0
- package/dist/lib/models/aiops/v4/config/SqlTransactionType.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/SqlTransactionType.js +83 -0
- package/dist/lib/models/aiops/v4/config/SqlWorkload.d.ts +102 -0
- package/dist/lib/models/aiops/v4/config/SqlWorkload.js +370 -0
- package/dist/lib/models/aiops/v4/config/UpdateScenarioApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/UpdateScenarioApiResponse.js +288 -0
- package/dist/lib/models/aiops/v4/config/UpdateSimulationApiResponse.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/UpdateSimulationApiResponse.js +310 -0
- package/dist/lib/models/aiops/v4/config/ValueRange.d.ts +58 -0
- package/dist/lib/models/aiops/v4/config/ValueRange.js +271 -0
- package/dist/lib/models/aiops/v4/{stats → config}/ValueType.js +12 -15
- package/dist/lib/models/aiops/v4/config/VdiProvisionType.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/VdiProvisionType.js +101 -0
- package/dist/lib/models/aiops/v4/config/VdiUserType.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/VdiUserType.js +95 -0
- package/dist/lib/models/aiops/v4/config/VdiVendor.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/VdiVendor.js +83 -0
- package/dist/lib/models/aiops/v4/config/VdiWorkload.d.ts +101 -0
- package/dist/lib/models/aiops/v4/config/VdiWorkload.js +367 -0
- package/dist/lib/models/aiops/v4/config/Vendor.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/Vendor.js +125 -0
- package/dist/lib/models/aiops/v4/config/VmCategoryWorkload.d.ts +79 -0
- package/dist/lib/models/aiops/v4/config/VmCategoryWorkload.js +311 -0
- package/dist/lib/models/aiops/v4/config/VmWorkload.d.ts +74 -0
- package/dist/lib/models/aiops/v4/config/VmWorkload.js +294 -0
- package/dist/lib/models/aiops/v4/config/Workload.d.ts +105 -0
- package/dist/lib/models/aiops/v4/config/Workload.js +398 -0
- package/dist/lib/models/aiops/v4/config/XenOperatingSystem.d.ts +19 -0
- package/dist/lib/models/aiops/v4/config/XenOperatingSystem.js +83 -0
- package/dist/lib/models/aiops/v4/config/XenWorkload.d.ts +141 -0
- package/dist/lib/models/aiops/v4/config/XenWorkload.js +483 -0
- package/dist/lib/models/aiops/v4/config/XfitPolicy.d.ts +121 -0
- package/dist/lib/models/aiops/v4/config/XfitPolicy.js +541 -0
- package/dist/lib/models/aiops/v4/config/XfitPolicyProjection.d.ts +14 -0
- package/dist/lib/models/aiops/v4/config/XfitPolicyProjection.js +134 -0
- package/dist/lib/models/aiops/v4/error/AppMessage.d.ts +62 -55
- package/dist/lib/models/aiops/v4/error/AppMessage.js +303 -310
- package/dist/lib/models/aiops/v4/error/ErrorResponse.d.ts +23 -24
- package/dist/lib/models/aiops/v4/error/ErrorResponse.js +224 -223
- package/dist/lib/models/aiops/v4/error/SchemaValidationError.d.ts +52 -48
- package/dist/lib/models/aiops/v4/error/SchemaValidationError.js +287 -292
- package/dist/lib/models/aiops/v4/error/SchemaValidationErrorMessage.d.ts +37 -36
- package/dist/lib/models/aiops/v4/error/SchemaValidationErrorMessage.js +224 -228
- package/dist/lib/models/aiops/v4/stats/BoolList.d.ts +29 -27
- package/dist/lib/models/aiops/v4/stats/BoolList.js +182 -185
- package/dist/lib/models/aiops/v4/stats/BoolVal.d.ts +29 -27
- package/dist/lib/models/aiops/v4/stats/BoolVal.js +175 -178
- package/dist/lib/models/aiops/v4/stats/DoubleList.d.ts +29 -27
- package/dist/lib/models/aiops/v4/stats/DoubleList.js +182 -185
- package/dist/lib/models/aiops/v4/stats/DoubleVal.d.ts +29 -27
- package/dist/lib/models/aiops/v4/stats/DoubleVal.js +175 -178
- package/dist/lib/models/aiops/v4/stats/Entity.d.ts +25 -37
- package/dist/lib/models/aiops/v4/stats/Entity.js +269 -280
- package/dist/lib/models/aiops/v4/stats/EntityListApiResponse.d.ts +29 -30
- package/dist/lib/models/aiops/v4/stats/EntityListApiResponse.js +239 -265
- package/dist/lib/models/aiops/v4/stats/IntList.d.ts +29 -27
- package/dist/lib/models/aiops/v4/stats/IntList.js +182 -185
- package/dist/lib/models/aiops/v4/stats/IntVal.d.ts +29 -27
- package/dist/lib/models/aiops/v4/stats/IntVal.js +175 -178
- package/dist/lib/models/aiops/v4/stats/Metric.d.ts +29 -30
- package/dist/lib/models/aiops/v4/stats/Metric.js +197 -205
- package/dist/lib/models/aiops/v4/stats/Point.d.ts +34 -30
- package/dist/lib/models/aiops/v4/stats/Point.js +231 -246
- package/dist/lib/models/aiops/v4/stats/StrList.d.ts +29 -27
- package/dist/lib/models/aiops/v4/stats/StrList.js +182 -185
- package/dist/lib/models/aiops/v4/stats/StrVal.d.ts +29 -27
- package/dist/lib/models/aiops/v4/stats/StrVal.js +175 -178
- package/dist/lib/models/aiops/v4/stats/TimeSeries.d.ts +29 -30
- package/dist/lib/models/aiops/v4/stats/TimeSeries.js +207 -218
- package/dist/lib/models/common/v1/config/Flag.d.ts +30 -30
- package/dist/lib/models/common/v1/config/Flag.js +203 -202
- package/dist/lib/models/common/v1/config/IPv4Address.d.ts +70 -0
- package/dist/lib/models/common/v1/config/IPv4Address.js +288 -0
- package/dist/lib/models/common/v1/config/KVPair.d.ts +34 -31
- package/dist/lib/models/common/v1/config/KVPair.js +259 -260
- package/dist/lib/models/common/v1/config/KVStringPair.d.ts +58 -0
- package/dist/lib/models/common/v1/config/KVStringPair.js +277 -0
- package/dist/lib/models/common/v1/config/MapOfStringWrapper.d.ts +53 -0
- package/dist/lib/models/common/v1/config/MapOfStringWrapper.js +236 -0
- package/dist/lib/models/common/v1/config/Message.d.ts +37 -42
- package/dist/lib/models/common/v1/config/Message.js +244 -259
- package/dist/lib/models/common/v1/config/MessageSeverity.js +18 -21
- package/dist/lib/models/common/v1/config/TenantAwareModel.d.ts +23 -26
- package/dist/lib/models/common/v1/config/TenantAwareModel.js +169 -179
- package/dist/lib/models/common/v1/response/ApiLink.d.ts +26 -30
- package/dist/lib/models/common/v1/response/ApiLink.js +197 -208
- package/dist/lib/models/common/v1/response/ApiResponseMetadata.d.ts +47 -50
- package/dist/lib/models/common/v1/response/ApiResponseMetadata.js +313 -334
- package/dist/lib/models/common/v1/response/ExternalizableAbstractModel.d.ts +15 -23
- package/dist/lib/models/common/v1/response/ExternalizableAbstractModel.js +195 -206
- package/dist/lib/models/common/v1/stats/DownSamplingOperator.js +24 -27
- package/dist/lib/models/prism/v4/config/TaskReference.d.ts +47 -0
- package/dist/lib/models/prism/v4/config/TaskReference.js +244 -0
- package/dist/lib/models/validation/ValidationError.js +27 -45
- package/dist/lib/models/validation/ValidationScopes.js +3 -4
- package/dist/lib/utils/ValidationUtils.js +40 -72
- package/package.json +6 -5
- package/dist/es/models/aiops/v4/stats/DeprecationModel.d.ts +0 -86
- package/dist/es/models/aiops/v4/stats/DeprecationModel.js +0 -358
- package/dist/es/models/aiops/v4/stats/EntityDescriptor.d.ts +0 -78
- package/dist/es/models/aiops/v4/stats/EntityDescriptor.js +0 -403
- package/dist/es/models/aiops/v4/stats/EntityDescriptorListApiResponse.d.ts +0 -59
- package/dist/es/models/aiops/v4/stats/EntityDescriptorListApiResponse.js +0 -336
- package/dist/es/models/aiops/v4/stats/EntityType.d.ts +0 -32
- package/dist/es/models/aiops/v4/stats/EntityType.js +0 -227
- package/dist/es/models/aiops/v4/stats/EntityTypeListApiResponse.d.ts +0 -59
- package/dist/es/models/aiops/v4/stats/EntityTypeListApiResponse.js +0 -336
- package/dist/es/models/aiops/v4/stats/MetricDescriptor.d.ts +0 -174
- package/dist/es/models/aiops/v4/stats/MetricDescriptor.js +0 -667
- package/dist/es/models/aiops/v4/stats/Source.d.ts +0 -32
- package/dist/es/models/aiops/v4/stats/Source.js +0 -227
- package/dist/es/models/aiops/v4/stats/SourceListApiResponse.d.ts +0 -59
- package/dist/es/models/aiops/v4/stats/SourceListApiResponse.js +0 -336
- package/dist/es/models/aiops/v4/stats/ValueRange.d.ts +0 -58
- package/dist/es/models/aiops/v4/stats/ValueRange.js +0 -276
- package/dist/lib/models/aiops/v4/stats/DeprecationModel.d.ts +0 -86
- package/dist/lib/models/aiops/v4/stats/DeprecationModel.js +0 -358
- package/dist/lib/models/aiops/v4/stats/EntityDescriptor.d.ts +0 -78
- package/dist/lib/models/aiops/v4/stats/EntityDescriptor.js +0 -403
- package/dist/lib/models/aiops/v4/stats/EntityDescriptorListApiResponse.d.ts +0 -59
- package/dist/lib/models/aiops/v4/stats/EntityDescriptorListApiResponse.js +0 -336
- package/dist/lib/models/aiops/v4/stats/EntityType.d.ts +0 -32
- package/dist/lib/models/aiops/v4/stats/EntityType.js +0 -227
- package/dist/lib/models/aiops/v4/stats/EntityTypeListApiResponse.d.ts +0 -59
- package/dist/lib/models/aiops/v4/stats/EntityTypeListApiResponse.js +0 -336
- package/dist/lib/models/aiops/v4/stats/MetricDescriptor.d.ts +0 -174
- package/dist/lib/models/aiops/v4/stats/MetricDescriptor.js +0 -667
- package/dist/lib/models/aiops/v4/stats/Source.d.ts +0 -32
- package/dist/lib/models/aiops/v4/stats/Source.js +0 -227
- package/dist/lib/models/aiops/v4/stats/SourceListApiResponse.d.ts +0 -59
- package/dist/lib/models/aiops/v4/stats/SourceListApiResponse.js +0 -336
- package/dist/lib/models/aiops/v4/stats/ValueRange.d.ts +0 -58
- package/dist/lib/models/aiops/v4/stats/ValueRange.js +0 -276
- /package/dist/es/models/aiops/v4/{stats → config}/ValueType.d.ts +0 -0
- /package/dist/lib/models/aiops/v4/{stats → config}/ValueType.d.ts +0 -0
package/dist/es/ApiClient.js
CHANGED
|
@@ -9,48 +9,37 @@ var _Paginable = _interopRequireDefault(require("./Paginable"));
|
|
|
9
9
|
var _uuid = require("uuid");
|
|
10
10
|
var _superagentRetryDelay = _interopRequireDefault(require("superagent-retry-delay"));
|
|
11
11
|
var _https = _interopRequireDefault(require("https"));
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
function
|
|
20
|
-
function
|
|
21
|
-
function
|
|
22
|
-
function
|
|
23
|
-
function
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
* OpenAPI spec version: 4.0.3-alpha-2
|
|
39
|
-
*
|
|
40
|
-
* NOTE: This class is auto generated by the Open API Dev Platform.
|
|
41
|
-
*
|
|
42
|
-
* Open API Dev Platform Codegen version: 16.8.0.6343-RELEASE
|
|
43
|
-
*
|
|
44
|
-
* Do not edit the class manually.
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
(0, _superagentRetryDelay["default"])(_superagent["default"]);
|
|
12
|
+
var _fs = _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 _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
20
|
+
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
21
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
22
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
23
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
24
|
+
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"); } /*
|
|
25
|
+
* Nutanix AIOps APIs
|
|
26
|
+
*
|
|
27
|
+
* OpenAPI spec version: 4.2.2-beta-1
|
|
28
|
+
*
|
|
29
|
+
* NOTE: This class is auto generated by the Open API Dev Platform.
|
|
30
|
+
*
|
|
31
|
+
* Open API Dev Platform Codegen version: 17.5.1.10573-RELEASE
|
|
32
|
+
*
|
|
33
|
+
* Do not edit the class manually.
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
(0, _superagentRetryDelay.default)(_superagent.default);
|
|
48
37
|
/**
|
|
49
38
|
* Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
|
|
50
39
|
* application to use this class directly - the *Api and model classes provide the public API for the service. The
|
|
51
40
|
* contents of this file should be regarded as internal but are documented for completeness.
|
|
52
41
|
* @module ApiClient
|
|
53
|
-
* @version 4.
|
|
42
|
+
* @version 4.2.2-beta-1
|
|
54
43
|
*/
|
|
55
44
|
var _protocol = /*#__PURE__*/new WeakMap();
|
|
56
45
|
var _cookie = /*#__PURE__*/new WeakMap();
|
|
@@ -59,94 +48,17 @@ var _verifySslFlag = /*#__PURE__*/new WeakMap();
|
|
|
59
48
|
var _defaultConnectTimeout = /*#__PURE__*/new WeakMap();
|
|
60
49
|
var _defaultReadTimeout = /*#__PURE__*/new WeakMap();
|
|
61
50
|
var _defaultMaxTimeout = /*#__PURE__*/new WeakMap();
|
|
51
|
+
var _host = /*#__PURE__*/new WeakMap();
|
|
52
|
+
var _negotiationCompleted = /*#__PURE__*/new WeakMap();
|
|
53
|
+
var _negotiatedVersion = /*#__PURE__*/new WeakMap();
|
|
62
54
|
var _LOG_LEVEL = /*#__PURE__*/new WeakMap();
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
var _isFileParam = /*#__PURE__*/new WeakSet();
|
|
66
|
-
var _normalizeParams = /*#__PURE__*/new WeakSet();
|
|
67
|
-
var _applyAuthToRequest = /*#__PURE__*/new WeakSet();
|
|
68
|
-
var _wrapErrorInResponse = /*#__PURE__*/new WeakSet();
|
|
69
|
-
var _deserialize = /*#__PURE__*/new WeakSet();
|
|
70
|
-
var _paginateIfNeeded = /*#__PURE__*/new WeakSet();
|
|
71
|
-
var _getValidTimeout = /*#__PURE__*/new WeakSet();
|
|
72
|
-
var _updateCookies = /*#__PURE__*/new WeakSet();
|
|
73
|
-
var _attachCookies = /*#__PURE__*/new WeakSet();
|
|
74
|
-
var _log = /*#__PURE__*/new WeakSet();
|
|
75
|
-
var _skipLogging = /*#__PURE__*/new WeakSet();
|
|
76
|
-
var _getLocalDateTime = /*#__PURE__*/new WeakSet();
|
|
77
|
-
var _flatten = /*#__PURE__*/new WeakSet();
|
|
78
|
-
var ApiClient = /*#__PURE__*/function () {
|
|
55
|
+
var _ApiClient_brand = /*#__PURE__*/new WeakSet();
|
|
56
|
+
class ApiClient {
|
|
79
57
|
/**
|
|
80
58
|
* @alias module:ApiClient
|
|
81
59
|
* @class
|
|
82
60
|
*/
|
|
83
|
-
|
|
84
|
-
_classCallCheck(this, ApiClient);
|
|
85
|
-
// A mapper function to flatten a simple non-nested (key:value) object to string
|
|
86
|
-
_classPrivateMethodInitSpec(this, _flatten);
|
|
87
|
-
_classPrivateMethodInitSpec(this, _getLocalDateTime);
|
|
88
|
-
_classPrivateMethodInitSpec(this, _skipLogging);
|
|
89
|
-
_classPrivateMethodInitSpec(this, _log);
|
|
90
|
-
// If enabled, attach saved cookies to request
|
|
91
|
-
_classPrivateMethodInitSpec(this, _attachCookies);
|
|
92
|
-
// If enabled, update cookie information to reuse in subsequent requests for a valid response
|
|
93
|
-
_classPrivateMethodInitSpec(this, _updateCookies);
|
|
94
|
-
// Gets a valid timeout
|
|
95
|
-
// 1. Sets to provided default timeout in case invalid value is passed
|
|
96
|
-
// 2. Sets to default max value of 30 minutes in case a value of more than 30 minutes is passed
|
|
97
|
-
_classPrivateMethodInitSpec(this, _getValidTimeout);
|
|
98
|
-
/**
|
|
99
|
-
* Set pagination data if response is a Paginable object
|
|
100
|
-
* @param {Object} data The response data already passed through deserialize
|
|
101
|
-
* @param {String} path The path given to callApi method
|
|
102
|
-
* @param {Object.<String, Object>} queryParams The queryParams given to callApi method
|
|
103
|
-
*/
|
|
104
|
-
_classPrivateMethodInitSpec(this, _paginateIfNeeded);
|
|
105
|
-
/**
|
|
106
|
-
* Deserializes an HTTP response body into a value of the specified type.
|
|
107
|
-
* @param {Object} response A SuperAgent response object.
|
|
108
|
-
* @param {(String|Array.<String>|Object.<String, Object>|Function)} returnType The type to return. Pass a string for simple types
|
|
109
|
-
* or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
|
|
110
|
-
* return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
|
|
111
|
-
* all properties on <code>data<code> will be converted to this type.
|
|
112
|
-
* @returns A value of the specified type.
|
|
113
|
-
*/
|
|
114
|
-
_classPrivateMethodInitSpec(this, _deserialize);
|
|
115
|
-
/**
|
|
116
|
-
* Wraps errors in generic response format.
|
|
117
|
-
* @param {Object} error object encountered during request.
|
|
118
|
-
* @returns an error object with wrapped response within error.data .
|
|
119
|
-
*/
|
|
120
|
-
_classPrivateMethodInitSpec(this, _wrapErrorInResponse);
|
|
121
|
-
/*
|
|
122
|
-
* Applies authentication headers to the request.
|
|
123
|
-
* @param {Object} request The request object created by a <code>superagent()</code> call.
|
|
124
|
-
* @param {Array.<String>} authNames An array of authentication method names.
|
|
125
|
-
*/
|
|
126
|
-
_classPrivateMethodInitSpec(this, _applyAuthToRequest);
|
|
127
|
-
/*
|
|
128
|
-
* Normalizes parameter values:
|
|
129
|
-
* <ul>
|
|
130
|
-
* <li>remove nils</li>
|
|
131
|
-
* <li>keep files and arrays</li>
|
|
132
|
-
* <li>format to string with `paramToString` for other cases</li>
|
|
133
|
-
* </ul>
|
|
134
|
-
* @param {Object.<String, Object>} params The parameters as object properties.
|
|
135
|
-
* @returns {Object.<String, Object>} normalized parameters.
|
|
136
|
-
*/
|
|
137
|
-
_classPrivateMethodInitSpec(this, _normalizeParams);
|
|
138
|
-
/*
|
|
139
|
-
* Checks whether the given parameter value represents file-like content.
|
|
140
|
-
* @param param The parameter to check.
|
|
141
|
-
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
|
|
142
|
-
*/
|
|
143
|
-
_classPrivateMethodInitSpec(this, _isFileParam);
|
|
144
|
-
/*
|
|
145
|
-
* Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
|
|
146
|
-
* @param {Array.<String>} contentTypes
|
|
147
|
-
* @returns {String} The chosen content type, preferring JSON.
|
|
148
|
-
*/
|
|
149
|
-
_classPrivateMethodInitSpec(this, _jsonPreferredMime);
|
|
61
|
+
constructor() {
|
|
150
62
|
/*
|
|
151
63
|
* Checks whether the given content type represents JSON.<br>
|
|
152
64
|
* JSON content type examples:<br>
|
|
@@ -158,41 +70,20 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
158
70
|
* @param {String} contentType The MIME content type to check.
|
|
159
71
|
* @returns {Boolean} <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>.
|
|
160
72
|
*/
|
|
161
|
-
_classPrivateMethodInitSpec(this,
|
|
73
|
+
_classPrivateMethodInitSpec(this, _ApiClient_brand);
|
|
162
74
|
// PRIVATE VARIABLES
|
|
163
|
-
_classPrivateFieldInitSpec(this, _protocol,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
_classPrivateFieldInitSpec(this,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
_classPrivateFieldInitSpec(this,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
_classPrivateFieldInitSpec(this, _verifySslFlag, {
|
|
176
|
-
writable: true,
|
|
177
|
-
value: void 0
|
|
178
|
-
});
|
|
179
|
-
_classPrivateFieldInitSpec(this, _defaultConnectTimeout, {
|
|
180
|
-
writable: true,
|
|
181
|
-
value: void 0
|
|
182
|
-
});
|
|
183
|
-
_classPrivateFieldInitSpec(this, _defaultReadTimeout, {
|
|
184
|
-
writable: true,
|
|
185
|
-
value: void 0
|
|
186
|
-
});
|
|
187
|
-
_classPrivateFieldInitSpec(this, _defaultMaxTimeout, {
|
|
188
|
-
writable: true,
|
|
189
|
-
value: void 0
|
|
190
|
-
});
|
|
191
|
-
_classPrivateFieldInitSpec(this, _LOG_LEVEL, {
|
|
192
|
-
writable: true,
|
|
193
|
-
value: void 0
|
|
194
|
-
});
|
|
195
|
-
_classPrivateFieldSet(this, _LOG_LEVEL, Object.freeze({
|
|
75
|
+
_classPrivateFieldInitSpec(this, _protocol, void 0);
|
|
76
|
+
_classPrivateFieldInitSpec(this, _cookie, void 0);
|
|
77
|
+
_classPrivateFieldInitSpec(this, _logger, void 0);
|
|
78
|
+
_classPrivateFieldInitSpec(this, _verifySslFlag, void 0);
|
|
79
|
+
_classPrivateFieldInitSpec(this, _defaultConnectTimeout, void 0);
|
|
80
|
+
_classPrivateFieldInitSpec(this, _defaultReadTimeout, void 0);
|
|
81
|
+
_classPrivateFieldInitSpec(this, _defaultMaxTimeout, void 0);
|
|
82
|
+
_classPrivateFieldInitSpec(this, _host, void 0);
|
|
83
|
+
_classPrivateFieldInitSpec(this, _negotiationCompleted, void 0);
|
|
84
|
+
_classPrivateFieldInitSpec(this, _negotiatedVersion, void 0);
|
|
85
|
+
_classPrivateFieldInitSpec(this, _LOG_LEVEL, void 0);
|
|
86
|
+
_classPrivateFieldSet(_LOG_LEVEL, this, Object.freeze({
|
|
196
87
|
DEBUG: {
|
|
197
88
|
key: "DEBUG",
|
|
198
89
|
value: Symbol(0)
|
|
@@ -223,7 +114,7 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
223
114
|
* @type {String}
|
|
224
115
|
* @default localhost
|
|
225
116
|
*/
|
|
226
|
-
this
|
|
117
|
+
_classPrivateFieldSet(_host, this, typeof self === 'undefined' ? 'localhost' : self.location.hostname);
|
|
227
118
|
|
|
228
119
|
/**
|
|
229
120
|
* The port of the base URL.
|
|
@@ -237,6 +128,11 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
237
128
|
* @type {Array.<String>}
|
|
238
129
|
*/
|
|
239
130
|
this.authentications = {
|
|
131
|
+
'apiKeyAuthScheme': {
|
|
132
|
+
type: 'apiKey',
|
|
133
|
+
'in': 'header',
|
|
134
|
+
name: 'X-ntnx-api-key'
|
|
135
|
+
},
|
|
240
136
|
'basicAuthScheme': {
|
|
241
137
|
type: 'basic'
|
|
242
138
|
}
|
|
@@ -248,23 +144,23 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
248
144
|
* @default {}
|
|
249
145
|
*/
|
|
250
146
|
this.defaultHeaders = {};
|
|
251
|
-
_classPrivateFieldSet(
|
|
252
|
-
_classPrivateFieldSet(
|
|
253
|
-
_classPrivateFieldSet(
|
|
147
|
+
_classPrivateFieldSet(_defaultConnectTimeout, this, 30000);
|
|
148
|
+
_classPrivateFieldSet(_defaultReadTimeout, this, 30000);
|
|
149
|
+
_classPrivateFieldSet(_defaultMaxTimeout, this, 10800000);
|
|
254
150
|
|
|
255
151
|
/**
|
|
256
152
|
* The default HTTP read timeout in milliseconds for all API calls.
|
|
257
153
|
* @type {Number}
|
|
258
154
|
* @default 30000
|
|
259
155
|
*/
|
|
260
|
-
this.readTimeout = _classPrivateFieldGet(
|
|
156
|
+
this.readTimeout = _classPrivateFieldGet(_defaultReadTimeout, this);
|
|
261
157
|
|
|
262
158
|
/**
|
|
263
159
|
* The default HTTP connection timeout in milliseconds for all API calls.
|
|
264
160
|
* @type {Number}
|
|
265
161
|
* @default 30000
|
|
266
162
|
*/
|
|
267
|
-
this.connectTimeout = _classPrivateFieldGet(
|
|
163
|
+
this.connectTimeout = _classPrivateFieldGet(_defaultConnectTimeout, this);
|
|
268
164
|
|
|
269
165
|
/**
|
|
270
166
|
* If set to false an additional timestamp parameter is added to all API GET calls to
|
|
@@ -278,7 +174,14 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
278
174
|
* Saved Cookies
|
|
279
175
|
* @default null
|
|
280
176
|
*/
|
|
281
|
-
_classPrivateFieldSet(
|
|
177
|
+
_classPrivateFieldSet(_cookie, this, null);
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The maximum number of redirects to be followed for all API calls.
|
|
181
|
+
* @type {Number}
|
|
182
|
+
* @default 1
|
|
183
|
+
*/
|
|
184
|
+
this.maxRedirects = 1;
|
|
282
185
|
|
|
283
186
|
/**
|
|
284
187
|
* The maximum number of retry attempts to be made by the client
|
|
@@ -294,20 +197,34 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
294
197
|
* @default 3000
|
|
295
198
|
*/
|
|
296
199
|
this.retryInterval = 3000;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* A boolean value that indicates whether cross-site Access-Control requests should be made using auth credentials.
|
|
203
|
+
* @type {Boolean}
|
|
204
|
+
* @default false
|
|
205
|
+
*/
|
|
206
|
+
this.withCredentials = false;
|
|
297
207
|
if (typeof self === 'undefined') {
|
|
298
|
-
this.agent = new _superagent
|
|
208
|
+
this.agent = new _superagent.default.agent();
|
|
299
209
|
}
|
|
300
210
|
|
|
301
211
|
/**
|
|
302
212
|
* Allow user to override superagent agent
|
|
303
213
|
*/
|
|
304
214
|
this.requestAgent = null;
|
|
215
|
+
_classPrivateFieldSet(_negotiatedVersion, this, null);
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Allow SDK to fetch version info and negotiate version
|
|
219
|
+
*/
|
|
220
|
+
this.allowVersionNegotiation = true;
|
|
221
|
+
_classPrivateFieldSet(_negotiationCompleted, this, false);
|
|
305
222
|
|
|
306
223
|
/**
|
|
307
224
|
* Allow SDK to print debug logs
|
|
308
225
|
*/
|
|
309
226
|
this.debug = false;
|
|
310
|
-
_classPrivateFieldSet(
|
|
227
|
+
_classPrivateFieldSet(_logger, this, null);
|
|
311
228
|
|
|
312
229
|
/**
|
|
313
230
|
* Username for basic auth
|
|
@@ -318,7 +235,13 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
318
235
|
* Password for basic auth
|
|
319
236
|
*/
|
|
320
237
|
this.password = null;
|
|
321
|
-
_classPrivateFieldSet(
|
|
238
|
+
_classPrivateFieldSet(_verifySslFlag, this, true);
|
|
239
|
+
|
|
240
|
+
/*
|
|
241
|
+
* Non Browser Environment : path to directory where downloaded files will be stored
|
|
242
|
+
* Browser Environment : WritableStream to pipe downloaded file to
|
|
243
|
+
*/
|
|
244
|
+
this.downloadDestination = null;
|
|
322
245
|
|
|
323
246
|
/*
|
|
324
247
|
* Log file to write activity logs
|
|
@@ -330,514 +253,713 @@ var ApiClient = /*#__PURE__*/function () {
|
|
|
330
253
|
* Enable/Disable SSL Verification
|
|
331
254
|
* @param verifySsl (boolean)
|
|
332
255
|
*/
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
256
|
+
set verifySsl(verifySsl) {
|
|
257
|
+
this.requestAgent = verifySsl ? null : new _https.default.Agent({
|
|
258
|
+
rejectUnauthorized: verifySsl
|
|
259
|
+
});
|
|
260
|
+
_classPrivateFieldSet(_verifySslFlag, this, verifySsl);
|
|
261
|
+
}
|
|
262
|
+
get verifySsl() {
|
|
263
|
+
return _classPrivateFieldGet(_verifySslFlag, this);
|
|
264
|
+
}
|
|
338
265
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
266
|
+
/**
|
|
267
|
+
* Set the hostname for base URL
|
|
268
|
+
* @param {String} hostname the hostname
|
|
269
|
+
*/
|
|
270
|
+
set host(hostname) {
|
|
271
|
+
_classPrivateFieldSet(_host, this, hostname);
|
|
272
|
+
// Reset negotiation flags when host changes
|
|
273
|
+
_classPrivateFieldSet(_negotiationCompleted, this, false);
|
|
274
|
+
_classPrivateFieldSet(_negotiatedVersion, this, null);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Get the hostname for base URL
|
|
279
|
+
* @returns {String} the hostname
|
|
280
|
+
*/
|
|
281
|
+
get host() {
|
|
282
|
+
return _classPrivateFieldGet(_host, this);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Configure log file to write activity logs
|
|
287
|
+
* @param logfile The destination file (write stream / string)
|
|
288
|
+
*/
|
|
289
|
+
set loggerFile(logfile) {
|
|
290
|
+
if (logfile !== null && typeof logfile !== 'undefined') {
|
|
291
|
+
if (typeof logfile === 'string' || logfile instanceof String) {
|
|
292
|
+
logfile = _fs.default.createWriteStream(logfile, {
|
|
293
|
+
flags: 'a'
|
|
349
294
|
});
|
|
350
295
|
}
|
|
351
|
-
_classPrivateFieldSet(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
set: function set(logfile) {
|
|
356
|
-
if (logfile !== null && typeof logfile !== 'undefined') {
|
|
357
|
-
if (typeof logfile === 'string' || logfile instanceof String) {
|
|
358
|
-
logfile = _fs2["default"].createWriteStream(logfile, {
|
|
359
|
-
flags: 'a'
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
_classPrivateFieldSet(this, _logger, new console.Console({
|
|
363
|
-
stdout: logfile,
|
|
364
|
-
stderr: logfile
|
|
365
|
-
}));
|
|
366
|
-
}
|
|
296
|
+
_classPrivateFieldSet(_logger, this, new console.Console({
|
|
297
|
+
stdout: logfile,
|
|
298
|
+
stderr: logfile
|
|
299
|
+
}));
|
|
367
300
|
}
|
|
301
|
+
}
|
|
368
302
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
key
|
|
376
|
-
|
|
377
|
-
if (key === "Authorization") {
|
|
378
|
-
_classPrivateFieldSet(this, _cookie, null);
|
|
379
|
-
}
|
|
380
|
-
this.defaultHeaders[key] = value;
|
|
303
|
+
/**
|
|
304
|
+
* Adds key value pair to default headers map, (to be added to every API call request)
|
|
305
|
+
* @param {String} key The key
|
|
306
|
+
* @param {String} value The corresponding value
|
|
307
|
+
*/
|
|
308
|
+
addDefaultHeader(key, value) {
|
|
309
|
+
if (key === "Authorization") {
|
|
310
|
+
_classPrivateFieldSet(_cookie, this, null);
|
|
381
311
|
}
|
|
312
|
+
this.defaultHeaders[key] = value;
|
|
313
|
+
}
|
|
382
314
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
315
|
+
/*
|
|
316
|
+
* Returns a string representation for an actual parameter.
|
|
317
|
+
* @param param The actual parameter.
|
|
318
|
+
* @returns {String} The string representation of <code>param</code>.
|
|
319
|
+
*/
|
|
320
|
+
paramToString(param) {
|
|
321
|
+
if (param == undefined || param == null) {
|
|
322
|
+
return '';
|
|
323
|
+
}
|
|
324
|
+
if (param instanceof Date) {
|
|
325
|
+
return param.toJSON();
|
|
326
|
+
}
|
|
327
|
+
return param.toString();
|
|
328
|
+
}
|
|
329
|
+
buildUrl(path, pathParams) {
|
|
330
|
+
if (!path.match(/^\//)) {
|
|
331
|
+
path = '/' + path;
|
|
332
|
+
}
|
|
333
|
+
if (typeof _classPrivateFieldGet(_negotiatedVersion, this) !== 'undefined' && _classPrivateFieldGet(_negotiatedVersion, this) !== null && _classPrivateFieldGet(_negotiatedVersion, this).match(/v\d+\.\d+(\.[a|b]\d+)?/) !== null && _classPrivateFieldGet(_negotiatedVersion, this) !== "v4.2.b1") {
|
|
334
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Changing uri", path, "to negotiated version", _classPrivateFieldGet(_negotiatedVersion, this));
|
|
335
|
+
var uriRegExp = new RegExp("(?<=/[-\\w]+/)v\\d+\\.\\d+(\\.[a|b]\\d+)?(?=/.*)", "i");
|
|
336
|
+
path = path.replace(uriRegExp, _classPrivateFieldGet(_negotiatedVersion, this));
|
|
398
337
|
}
|
|
399
|
-
}, {
|
|
400
|
-
key: "buildUrl",
|
|
401
|
-
value: function buildUrl(path, pathParams) {
|
|
402
|
-
var _this = this;
|
|
403
|
-
if (!path.match(/^\//)) {
|
|
404
|
-
path = '/' + path;
|
|
405
|
-
}
|
|
406
338
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
var url = basePath + path;
|
|
416
|
-
url = url.replace(/\{([\w-]+)\}/g, function (fullMatch, key) {
|
|
417
|
-
var value;
|
|
418
|
-
if (pathParams.hasOwnProperty(key)) {
|
|
419
|
-
value = _this.paramToString(pathParams[key]);
|
|
420
|
-
} else {
|
|
421
|
-
value = fullMatch;
|
|
422
|
-
}
|
|
423
|
-
return encodeURIComponent(value);
|
|
424
|
-
});
|
|
425
|
-
return url;
|
|
339
|
+
// The protocol of the base URL, including the colon (:).
|
|
340
|
+
_classPrivateFieldSet(_protocol, this, typeof self === 'undefined' ? this.scheme + ':' : self.location.protocol);
|
|
341
|
+
let basePath = ''; //default
|
|
342
|
+
if (_classPrivateFieldGet(_protocol, this) !== '' && this.host !== '' && this.port !== '') {
|
|
343
|
+
basePath = _classPrivateFieldGet(_protocol, this) + '\/\/' + this.host + ':' + this.port;
|
|
344
|
+
} else if (typeof self !== "undefined") {
|
|
345
|
+
basePath = self.origin;
|
|
426
346
|
}
|
|
427
|
-
|
|
428
|
-
key
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
* @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
|
|
435
|
-
* <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
|
|
436
|
-
*/
|
|
437
|
-
function buildCollectionParam(param, collectionFormat) {
|
|
438
|
-
if (param == null) {
|
|
439
|
-
return null;
|
|
440
|
-
}
|
|
441
|
-
switch (collectionFormat) {
|
|
442
|
-
case 'csv':
|
|
443
|
-
return param.map(this.paramToString).join(',');
|
|
444
|
-
case 'ssv':
|
|
445
|
-
return param.map(this.paramToString).join(' ');
|
|
446
|
-
case 'tsv':
|
|
447
|
-
return param.map(this.paramToString).join('\t');
|
|
448
|
-
case 'pipes':
|
|
449
|
-
return param.map(this.paramToString).join('|');
|
|
450
|
-
case 'multi':
|
|
451
|
-
//return the array directly as SuperAgent will handle it as expected
|
|
452
|
-
return param.map(this.paramToString);
|
|
453
|
-
default:
|
|
454
|
-
throw new Error('Unknown collection format: ' + collectionFormat);
|
|
347
|
+
var url = basePath + path;
|
|
348
|
+
url = url.replace(/\{([\w-]+)\}/g, (fullMatch, key) => {
|
|
349
|
+
var value;
|
|
350
|
+
if (pathParams.hasOwnProperty(key)) {
|
|
351
|
+
value = this.paramToString(pathParams[key]);
|
|
352
|
+
} else {
|
|
353
|
+
value = fullMatch;
|
|
455
354
|
}
|
|
355
|
+
return encodeURIComponent(value);
|
|
356
|
+
});
|
|
357
|
+
return url;
|
|
358
|
+
}
|
|
359
|
+
/*
|
|
360
|
+
* Builds a string representation of an array-type actual parameter, according to the given collection format.
|
|
361
|
+
* @param {Array} param An array parameter.
|
|
362
|
+
* @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
|
|
363
|
+
* @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
|
|
364
|
+
* <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
|
|
365
|
+
*/
|
|
366
|
+
buildCollectionParam(param, collectionFormat) {
|
|
367
|
+
if (param == null) {
|
|
368
|
+
return null;
|
|
456
369
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
} catch (err) {
|
|
474
|
-
_iterator.e(err);
|
|
475
|
-
} finally {
|
|
476
|
-
_iterator.f();
|
|
477
|
-
}
|
|
478
|
-
} else if (data.getData().hasOwnProperty("$reserved") && data.getData().get$Reserved() !== undefined) {
|
|
479
|
-
data.getData().get$Reserved()["ETag"] = etagRef;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
return data;
|
|
370
|
+
switch (collectionFormat) {
|
|
371
|
+
case 'csv':
|
|
372
|
+
return param.map(this.paramToString).join(',');
|
|
373
|
+
case 'ssv':
|
|
374
|
+
return param.map(this.paramToString).join(' ');
|
|
375
|
+
case 'tsv':
|
|
376
|
+
return param.map(this.paramToString).join('\t');
|
|
377
|
+
case 'pipes':
|
|
378
|
+
return param.map(this.paramToString).join('|');
|
|
379
|
+
case 'multi':
|
|
380
|
+
//return the array directly as SuperAgent will handle it as expected
|
|
381
|
+
return param.map(this.paramToString);
|
|
382
|
+
default:
|
|
383
|
+
throw new Error('Unknown collection format: ' + collectionFormat);
|
|
484
384
|
}
|
|
385
|
+
}
|
|
485
386
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
* Invokes the REST service using the supplied settings and parameters.
|
|
499
|
-
* @param {String} path The base URL to invoke.
|
|
500
|
-
* @param {String} httpMethod The HTTP method to use.
|
|
501
|
-
* @param {Object.<String, String>} pathParams A map of path parameters and their values.
|
|
502
|
-
* @param {Object.<String, Object>} queryParams A map of query parameters and their values.
|
|
503
|
-
* @param {Object.<String, Object>} headerParams A map of header parameters and their values.
|
|
504
|
-
* @param {Object.<String, Object>} formParams A map of form parameters and their values.
|
|
505
|
-
* @param {Object} bodyParam The value to pass as the request body.
|
|
506
|
-
* @param {Array.<String>} authNames An array of authentication type names.
|
|
507
|
-
* @param {Array.<String>} contentTypes An array of request MIME types.
|
|
508
|
-
* @param {Array.<String>} accepts An array of acceptable response MIME types.
|
|
509
|
-
* @param {(String|Array|Object|Function)} returnType The required type to return; can be a string for simple types or the
|
|
510
|
-
* constructor for a complex type.
|
|
511
|
-
* @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
|
|
512
|
-
*/
|
|
513
|
-
function callApi(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType) {
|
|
514
|
-
var _this2 = this;
|
|
515
|
-
var url = this.buildUrl(path, pathParams);
|
|
516
|
-
var request = (0, _superagent["default"])(httpMethod, url);
|
|
387
|
+
/*
|
|
388
|
+
* Sets API key for authentication
|
|
389
|
+
*
|
|
390
|
+
* @param {String} key The API key for authentication
|
|
391
|
+
*/
|
|
392
|
+
setApiKey(key) {
|
|
393
|
+
if (key == undefined || typeof key === 'string' || key instanceof String) {
|
|
394
|
+
this.authentications['apiKeyAuthScheme']['apiKey'] = key;
|
|
395
|
+
} else {
|
|
396
|
+
this.authentications['apiKeyAuthScheme']['apiKey'] = undefined;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
517
399
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
400
|
+
/*
|
|
401
|
+
* Applies authentication headers to the request.
|
|
402
|
+
* @param {Object} request The request object created by a <code>superagent()</code> call.
|
|
403
|
+
* @param {Array.<String>} authNames An array of authentication method names.
|
|
404
|
+
*/
|
|
405
|
+
|
|
406
|
+
addEtagToReservedMap(response, data) {
|
|
407
|
+
if (response.hasOwnProperty("headers") && response.headers.hasOwnProperty("etag")) {
|
|
408
|
+
let etagRef = response.headers.etag;
|
|
409
|
+
if (data.getData() !== undefined) {
|
|
410
|
+
if (Array.isArray(data.getData()) && data.getData().length > 0) {
|
|
411
|
+
for (var item of data.getData()) {
|
|
412
|
+
if (item.hasOwnProperty("$reserved") && item.get$Reserved() !== undefined) {
|
|
413
|
+
item.get$Reserved()["ETag"] = etagRef;
|
|
414
|
+
}
|
|
529
415
|
}
|
|
416
|
+
} else if (data.getData().hasOwnProperty("$reserved") && data.getData().get$Reserved() !== undefined) {
|
|
417
|
+
data.getData().get$Reserved()["ETag"] = etagRef;
|
|
530
418
|
}
|
|
531
|
-
this.oldCallback(err, res);
|
|
532
|
-
};
|
|
533
|
-
|
|
534
|
-
// apply authentications
|
|
535
|
-
_classPrivateMethodGet(this, _applyAuthToRequest, _applyAuthToRequest2).call(this, request, authNames);
|
|
536
|
-
|
|
537
|
-
// set query parameters
|
|
538
|
-
if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
|
|
539
|
-
queryParams['_'] = new Date().getTime();
|
|
540
419
|
}
|
|
541
|
-
|
|
420
|
+
}
|
|
421
|
+
return data;
|
|
422
|
+
}
|
|
542
423
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
424
|
+
/**
|
|
425
|
+
* Get ETag from an object if exists.
|
|
426
|
+
* The ETag is usually provided in the response of the GET API calls,
|
|
427
|
+
* which can further be used in other HTTP operations.
|
|
428
|
+
*
|
|
429
|
+
* @param object Object from which ETag needs to be retrieved
|
|
430
|
+
* @returns {(String|null)} returns ETag header in the object if it's an API response object, otherwise null
|
|
431
|
+
*/
|
|
432
|
+
static getEtag(object) {
|
|
433
|
+
let etag = null;
|
|
434
|
+
if (object !== undefined) {
|
|
435
|
+
if (object.hasOwnProperty('$reserved') && object.get$Reserved() !== undefined) {
|
|
436
|
+
etag = this.getValueForCaseInsensitiveKeyMatch(object.get$Reserved(), 'ETag');
|
|
550
437
|
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
554
|
-
if (!isBrowser) {
|
|
555
|
-
request.set(_classPrivateMethodGet(this, _normalizeParams, _normalizeParams2).call(this, {
|
|
556
|
-
'User-Agent': 'Nutanix-aiops-js-client/4.0.3-alpha.2'
|
|
557
|
-
}));
|
|
438
|
+
if (etag == null && object.hasOwnProperty("data") && object.getData().hasOwnProperty('$reserved') && object.getData().get$Reserved() !== undefined) {
|
|
439
|
+
etag = this.getValueForCaseInsensitiveKeyMatch(object.getData().get$Reserved(), 'ETag');
|
|
558
440
|
}
|
|
441
|
+
}
|
|
442
|
+
return etag;
|
|
443
|
+
}
|
|
444
|
+
static getValueForCaseInsensitiveKeyMatch(object, key) {
|
|
445
|
+
if (object && key) {
|
|
446
|
+
const searchKey = key.toLowerCase();
|
|
447
|
+
const matchedKey = Object.keys(object).find(key => key.toLowerCase() === searchKey);
|
|
448
|
+
return matchedKey ? object[matchedKey] : null;
|
|
449
|
+
}
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
559
452
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
453
|
+
/**
|
|
454
|
+
* Get SDK's negotiated version.
|
|
455
|
+
* @returns {String} negotiated version.
|
|
456
|
+
*/
|
|
457
|
+
getNegotiatedVersion() {
|
|
458
|
+
return _classPrivateFieldGet(_negotiatedVersion, this);
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Call relevant options api and negotiate version
|
|
462
|
+
* Negotiated version available via getNegotiatedVersion()
|
|
463
|
+
* @param {ApiClient} selfInstance
|
|
464
|
+
* @param {Array.<String>} authNames An array of allowed authentication type names i.e. basicAuthScheme
|
|
465
|
+
* @returns {Promise<ApiClient>} a {@link https://www.promisejs.org/|Promise}
|
|
466
|
+
*/
|
|
467
|
+
negotiateVersion(selfInstance, authNames) {
|
|
468
|
+
return new Promise(resolve => {
|
|
469
|
+
if (this.allowVersionNegotiation === true && _classPrivateFieldGet(_negotiationCompleted, this) === false) {
|
|
470
|
+
this.callApiInternal('/api/aiops/unversioned/info', 'OPTIONS', {}, {}, {}, {}, null, authNames, [], ['application/json'], Object).then(({
|
|
471
|
+
data,
|
|
472
|
+
response
|
|
473
|
+
}) => {
|
|
474
|
+
if (response.status === 200 && data.hasOwnProperty("data") && data.data !== null) {
|
|
475
|
+
const serverVersion = data.data;
|
|
476
|
+
const minimumSupportedVersion = "v4.2.b1";
|
|
564
477
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
// Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746)
|
|
573
|
-
if (contentType != 'multipart/form-data') {
|
|
574
|
-
request.type(contentType);
|
|
575
|
-
}
|
|
576
|
-
} else if (!request.header['Content-Type']) {
|
|
577
|
-
request.type('application/json');
|
|
578
|
-
}
|
|
579
|
-
if (contentType === 'application/x-www-form-urlencoded') {
|
|
580
|
-
request.send(_classPrivateMethodGet(this, _normalizeParams, _normalizeParams2).call(this, formParams));
|
|
581
|
-
} else if (contentType == 'multipart/form-data') {
|
|
582
|
-
var _formParams = _classPrivateMethodGet(this, _normalizeParams, _normalizeParams2).call(this, formParams);
|
|
583
|
-
for (var key in _formParams) {
|
|
584
|
-
if (_formParams.hasOwnProperty(key)) {
|
|
585
|
-
if (_classPrivateMethodGet(this, _isFileParam, _isFileParam2).call(this, _formParams[key])) {
|
|
586
|
-
// file field
|
|
587
|
-
request.attach(key, _formParams[key]);
|
|
588
|
-
} else {
|
|
589
|
-
request.field(key, _formParams[key]);
|
|
478
|
+
// Check if server version is below minimum supported version
|
|
479
|
+
if (_assertClassBrand(_ApiClient_brand, this, _isSmallerMinorVersion).call(this, _assertClassBrand(_ApiClient_brand, this, _getVersionDetails).call(this, serverVersion), _assertClassBrand(_ApiClient_brand, this, _getVersionDetails).call(this, minimumSupportedVersion))) {
|
|
480
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).WARN, null, "Server version", serverVersion, "is below minimum supported version", minimumSupportedVersion, ". Version negotiation will not be performed.");
|
|
481
|
+
_classPrivateFieldSet(_negotiatedVersion, this, null);
|
|
482
|
+
_classPrivateFieldSet(_negotiationCompleted, this, false);
|
|
483
|
+
resolve(selfInstance);
|
|
484
|
+
return;
|
|
590
485
|
}
|
|
486
|
+
_classPrivateFieldSet(_negotiatedVersion, this, _assertClassBrand(_ApiClient_brand, this, _performNegotiationBetweenVersions).call(this, "v4.2.b1", serverVersion));
|
|
487
|
+
_classPrivateFieldSet(_negotiationCompleted, this, true);
|
|
488
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Negotiated Version with server :", _classPrivateFieldGet(_negotiatedVersion, this));
|
|
489
|
+
resolve(selfInstance);
|
|
490
|
+
} else {
|
|
491
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Could not fetch supported versions from server");
|
|
492
|
+
_classPrivateFieldSet(_negotiatedVersion, this, null);
|
|
493
|
+
_classPrivateFieldSet(_negotiationCompleted, this, false);
|
|
494
|
+
resolve(selfInstance);
|
|
591
495
|
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
if (returnType === 'Blob') {
|
|
601
|
-
request.responseType('blob');
|
|
602
|
-
} else if (returnType === 'String') {
|
|
603
|
-
request.responseType('string');
|
|
496
|
+
}).catch(error => {
|
|
497
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Could not fetch supported versions from server");
|
|
498
|
+
_classPrivateFieldSet(_negotiatedVersion, this, null);
|
|
499
|
+
_classPrivateFieldSet(_negotiationCompleted, this, false);
|
|
500
|
+
resolve(selfInstance);
|
|
501
|
+
});
|
|
502
|
+
} else {
|
|
503
|
+
resolve(selfInstance);
|
|
604
504
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// Gets a valid timeout
|
|
509
|
+
// 1. Sets to provided default timeout in case invalid value is passed
|
|
510
|
+
// 2. Sets to default max value of 30 minutes in case a value of more than 30 minutes is passed
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Invokes the REST service using the supplied settings and parameters.
|
|
514
|
+
* @param {String} path The base URL to invoke.
|
|
515
|
+
* @param {String} httpMethod The HTTP method to use.
|
|
516
|
+
* @param {Object.<String, String>} pathParams A map of path parameters and their values.
|
|
517
|
+
* @param {Object.<String, Object>} queryParams A map of query parameters and their values.
|
|
518
|
+
* @param {Object.<String, Object>} headerParams A map of header parameters and their values.
|
|
519
|
+
* @param {Object.<String, Object>} formParams A map of form parameters and their values.
|
|
520
|
+
* @param {Object} bodyParam The value to pass as the request body.
|
|
521
|
+
* @param {Array.<String>} authNames An array of authentication type names.
|
|
522
|
+
* @param {Array.<String>} contentTypes An array of request MIME types.
|
|
523
|
+
* @param {Array.<String>} accepts An array of acceptable response MIME types.
|
|
524
|
+
* @param {(String|Array|Object|Function)} returnType The required type to return; can be a string for simple types or the
|
|
525
|
+
* constructor for a complex type.
|
|
526
|
+
* @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
|
|
527
|
+
*/
|
|
528
|
+
callApi(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType) {
|
|
529
|
+
return this.negotiateVersion(this, authNames).then(function (selfInstance) {
|
|
530
|
+
return selfInstance.callApiInternal(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType);
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
callApiInternal(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType) {
|
|
534
|
+
var url = this.buildUrl(path, pathParams);
|
|
535
|
+
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
536
|
+
let binaryMediaTypes = ['application/octet-stream', 'application/pdf', 'application/zip'];
|
|
537
|
+
if (accepts && accepts.length > 0 && accepts.some(accept => binaryMediaTypes.includes(accept)) && isBrowser && this.downloadDestination) {
|
|
538
|
+
return new Promise((resolve, reject) => {
|
|
539
|
+
// Prepare request for browser download
|
|
540
|
+
const fetchParams = _assertClassBrand(_ApiClient_brand, this, _prepareDownloadBrowserParams).call(this, url, httpMethod, queryParams, headerParams, bodyParam, authNames, contentTypes, accepts);
|
|
541
|
+
fetch(fetchParams.url, fetchParams.options).then(response => {
|
|
542
|
+
if (!response.ok) {
|
|
543
|
+
const err = new Error(`HTTP error ${response.status}`);
|
|
544
|
+
err.status = response.status;
|
|
545
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Error downloading file:", err);
|
|
636
546
|
reject(err);
|
|
637
547
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
error.data = _classPrivateMethodGet(_this2, _deserialize, _deserialize2).call(_this2, error.response, returnType);
|
|
643
|
-
} else {
|
|
644
|
-
error.data = _classPrivateMethodGet(_this2, _wrapErrorInResponse, _wrapErrorInResponse2).call(_this2, error);
|
|
548
|
+
if (!(this.downloadDestination instanceof WritableStream)) {
|
|
549
|
+
let errMsg = "Incompatible downloadDestination for Browser Environment, must be WritableStream";
|
|
550
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, errMsg);
|
|
551
|
+
reject(errMsg);
|
|
645
552
|
}
|
|
553
|
+
const reader = response.body.getReader();
|
|
554
|
+
const writer = this.downloadDestination.getWriter();
|
|
555
|
+
const pump = () => {
|
|
556
|
+
return reader.read().then(({
|
|
557
|
+
done,
|
|
558
|
+
value
|
|
559
|
+
}) => {
|
|
560
|
+
if (done) {
|
|
561
|
+
writer.close();
|
|
562
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Finished streaming response");
|
|
563
|
+
resolve({
|
|
564
|
+
data: {},
|
|
565
|
+
response
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
return writer.write(value).then(pump);
|
|
569
|
+
});
|
|
570
|
+
};
|
|
571
|
+
return pump();
|
|
572
|
+
}).catch(error => {
|
|
573
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Caught the following error :", error);
|
|
646
574
|
reject(error);
|
|
647
575
|
});
|
|
648
576
|
});
|
|
649
577
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
578
|
+
var request = (0, _superagent.default)(httpMethod, url);
|
|
579
|
+
|
|
580
|
+
// override request callback to retry only required status codes
|
|
581
|
+
request.oldCallback = request.callback;
|
|
582
|
+
request.callback = function (err, res) {
|
|
583
|
+
if (res && res.status) {
|
|
584
|
+
const status = res.status;
|
|
585
|
+
if (status >= 400 && !(status === 408 || status === 429 || status === 503 || status === 504)) {
|
|
586
|
+
this._maxRetries = 0;
|
|
657
587
|
}
|
|
658
|
-
if (
|
|
659
|
-
|
|
588
|
+
if (res.status === 401 && this.header["Cookie"]) {
|
|
589
|
+
this.unset("Cookie");
|
|
590
|
+
this._maxRetries = 1;
|
|
660
591
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
value: function getValueForCaseInsensitiveKeyMatch(object, key) {
|
|
667
|
-
if (object && key) {
|
|
668
|
-
var searchKey = key.toLowerCase();
|
|
669
|
-
var matchedKey = Object.keys(object).find(function (key) {
|
|
670
|
-
return key.toLowerCase() === searchKey;
|
|
671
|
-
});
|
|
672
|
-
return matchedKey ? object[matchedKey] : null;
|
|
673
|
-
}
|
|
674
|
-
return null;
|
|
675
|
-
}
|
|
676
|
-
}, {
|
|
677
|
-
key: "addEtagReferenceToHeader",
|
|
678
|
-
value: function addEtagReferenceToHeader(bodyParam, headerParams) {
|
|
679
|
-
// set If-Match header from postBody $reserved map
|
|
680
|
-
if (typeof bodyParam !== 'undefined' && bodyParam !== null) {
|
|
681
|
-
if (bodyParam.hasOwnProperty('$reserved') && bodyParam.$reserved.hasOwnProperty('ETag')) {
|
|
682
|
-
var eTagReference = bodyParam.$reserved['ETag'];
|
|
683
|
-
if (typeof eTagReference !== 'undefined' && eTagReference !== null && eTagReference !== "") {
|
|
684
|
-
headerParams['If-Match'] = eTagReference;
|
|
592
|
+
if (status === 429) {
|
|
593
|
+
let retryAfter = res.headers['retry-after'];
|
|
594
|
+
if (retryAfter) {
|
|
595
|
+
let delay = parseInt(retryAfter, 10) * 1000;
|
|
596
|
+
this._retryDelays[this._retries] = delay;
|
|
685
597
|
}
|
|
686
598
|
}
|
|
687
599
|
}
|
|
600
|
+
this.oldCallback(err, res);
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
// apply authentications
|
|
604
|
+
_assertClassBrand(_ApiClient_brand, this, _applyAuthToRequest).call(this, request, authNames);
|
|
605
|
+
|
|
606
|
+
// set query parameters
|
|
607
|
+
if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
|
|
608
|
+
queryParams['_'] = new Date().getTime();
|
|
688
609
|
}
|
|
610
|
+
request.query(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, queryParams));
|
|
689
611
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
value: function parseDate(str) {
|
|
698
|
-
return new Date(str);
|
|
612
|
+
// set header parameters
|
|
613
|
+
request.set(this.defaultHeaders).set(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, headerParams));
|
|
614
|
+
if ((this.defaultHeaders['NTNX-Request-Id'] === null || this.defaultHeaders['NTNX-Request-Id'] === undefined) && (headerParams['NTNX-Request-Id'] === null || headerParams['NTNX-Request-Id'] === undefined)) {
|
|
615
|
+
let requestId = (0, _uuid.v4)();
|
|
616
|
+
request.set(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, {
|
|
617
|
+
'NTNX-Request-Id': requestId
|
|
618
|
+
}));
|
|
699
619
|
}
|
|
700
620
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
621
|
+
// Set User-Agent header only if it is not a browser environment
|
|
622
|
+
if (!isBrowser) {
|
|
623
|
+
this.downloadDestination = '.';
|
|
624
|
+
request.set(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, {
|
|
625
|
+
'User-Agent': 'Nutanix-aiops-js-client/4.2.2-beta.1'
|
|
626
|
+
}));
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// set requestAgent if it is set by user
|
|
630
|
+
if (this.requestAgent) {
|
|
631
|
+
request.agent(this.requestAgent);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// set request timeouts
|
|
635
|
+
var timeoutOptions = {};
|
|
636
|
+
timeoutOptions["response"] = _assertClassBrand(_ApiClient_brand, this, _getValidTimeout).call(this, this.connectTimeout, _classPrivateFieldGet(_defaultConnectTimeout, this));
|
|
637
|
+
timeoutOptions["deadline"] = _assertClassBrand(_ApiClient_brand, this, _getValidTimeout).call(this, this.readTimeout, _classPrivateFieldGet(_defaultReadTimeout, this));
|
|
638
|
+
request.timeout(timeoutOptions);
|
|
639
|
+
var contentType = headerParams.hasOwnProperty("Content-Type") ? headerParams["Content-Type"] : _assertClassBrand(_ApiClient_brand, this, _jsonPreferredMime).call(this, contentTypes);
|
|
640
|
+
if (contentType) {
|
|
641
|
+
// Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746)
|
|
642
|
+
if (contentType != 'multipart/form-data') {
|
|
643
|
+
request.type(contentType);
|
|
715
644
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
645
|
+
} else if (!request.header['Content-Type']) {
|
|
646
|
+
request.type('application/json');
|
|
647
|
+
}
|
|
648
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Request URL :", httpMethod, url);
|
|
649
|
+
_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);
|
|
650
|
+
if (contentType === 'application/x-www-form-urlencoded') {
|
|
651
|
+
request.send(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, formParams));
|
|
652
|
+
} else if (contentType == 'multipart/form-data') {
|
|
653
|
+
var _formParams = _assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, formParams);
|
|
654
|
+
for (var key in _formParams) {
|
|
655
|
+
if (_formParams.hasOwnProperty(key)) {
|
|
656
|
+
if (_assertClassBrand(_ApiClient_brand, this, _isFileParam).call(this, _formParams[key])) {
|
|
657
|
+
// file field
|
|
658
|
+
request.attach(key, _formParams[key]);
|
|
659
|
+
} else {
|
|
660
|
+
request.field(key, _formParams[key]);
|
|
661
|
+
}
|
|
721
662
|
}
|
|
722
663
|
}
|
|
723
|
-
|
|
724
|
-
|
|
664
|
+
} else if (contentType === 'application/octet-stream' && bodyParam !== null && typeof bodyParam !== 'undefined' && typeof bodyParam.pipe === 'function') {
|
|
665
|
+
// FILE UPLOAD SUPPORT
|
|
666
|
+
|
|
667
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Piping octet-stream request");
|
|
668
|
+
if (typeof bodyParam.pipe === 'function') {
|
|
669
|
+
bodyParam.pipe(request);
|
|
670
|
+
} else if (typeof require === 'function') {
|
|
671
|
+
let webstream;
|
|
672
|
+
try {
|
|
673
|
+
webstream = require('stream/web');
|
|
674
|
+
} catch (err) {
|
|
675
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Error fetching steam/web");
|
|
676
|
+
}
|
|
677
|
+
if (bodyParam instanceof webstream.ReadableStream) {
|
|
678
|
+
bodyParam.pipeTo(new webstream.WritableStream({
|
|
679
|
+
write(chunk) {
|
|
680
|
+
request.write(chunk);
|
|
681
|
+
},
|
|
682
|
+
close() {
|
|
683
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "READABLE STREAM CLOSED");
|
|
684
|
+
},
|
|
685
|
+
abort(err) {
|
|
686
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "READABLE STREAM ABORTED");
|
|
687
|
+
}
|
|
688
|
+
}));
|
|
689
|
+
} else {
|
|
690
|
+
request.send(bodyParam);
|
|
691
|
+
}
|
|
692
|
+
} else {
|
|
693
|
+
request.send(bodyParam);
|
|
725
694
|
}
|
|
726
|
-
return
|
|
695
|
+
return new Promise((resolve, reject) => {
|
|
696
|
+
request.on('error', err => {
|
|
697
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Caught the following error :", err);
|
|
698
|
+
reject(err);
|
|
699
|
+
}).on('response', response => {
|
|
700
|
+
_assertClassBrand(_ApiClient_brand, this, _handleApiResponseForPromise).call(this, response, path, queryParams, returnType, resolve, reject);
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
} else if (['POST', 'PUT', 'PATCH'].includes(httpMethod.toUpperCase()) && bodyParam) {
|
|
704
|
+
request.send(bodyParam);
|
|
705
|
+
}
|
|
706
|
+
if (typeof returnType === 'Blob') {
|
|
707
|
+
request.responseType('blob');
|
|
708
|
+
} else if (returnType === 'String') {
|
|
709
|
+
request.responseType('string');
|
|
710
|
+
}
|
|
711
|
+
_assertClassBrand(_ApiClient_brand, this, _attachCookies).call(this, request);
|
|
712
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Request Body :", typeof request._data === "undefined" ? "" : request._data);
|
|
713
|
+
var accept = headerParams.hasOwnProperty("Accept") && headerParams["Accept"] != undefined ? headerParams["Accept"] : accepts.join(', ');
|
|
714
|
+
if (accept) {
|
|
715
|
+
request.accept(accept);
|
|
727
716
|
}
|
|
717
|
+
return new Promise((resolve, reject) => {
|
|
718
|
+
request.buffer(false).redirects(0).retry(this.maxRetryAttempts, this.retryInterval, []).withCredentials(this.withCredentials).on('error', err => {
|
|
719
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Caught the following error :", err);
|
|
720
|
+
}).end((error, response) => {
|
|
721
|
+
if (error) {
|
|
722
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Caught error during the request!");
|
|
723
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, error);
|
|
724
|
+
// Reset negotiation flags on 404 to allow future negotiation attempts
|
|
725
|
+
if (error.status === 404) {
|
|
726
|
+
_classPrivateFieldSet(_negotiationCompleted, this, false);
|
|
727
|
+
_classPrivateFieldSet(_negotiatedVersion, this, null);
|
|
728
|
+
}
|
|
729
|
+
if (error.response !== null && typeof error.response !== 'undefined') {
|
|
730
|
+
error.data = _assertClassBrand(_ApiClient_brand, this, _deserialize).call(this, error.response, returnType);
|
|
731
|
+
} else {
|
|
732
|
+
error.data = _assertClassBrand(_ApiClient_brand, this, _wrapErrorInResponse).call(this, error);
|
|
733
|
+
}
|
|
734
|
+
reject(error);
|
|
735
|
+
} else {
|
|
736
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Response Status :", response.status);
|
|
737
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, _assertClassBrand(_ApiClient_brand, this, _flatten), "Response Headers :", response.headers);
|
|
738
|
+
let contentType = '';
|
|
739
|
+
if (response.headers.hasOwnProperty('content-type')) {
|
|
740
|
+
contentType = response.headers["content-type"];
|
|
741
|
+
}
|
|
742
|
+
let fetchStream = binaryMediaTypes.includes(contentType);
|
|
743
|
+
if (fetchStream) {
|
|
744
|
+
/*
|
|
745
|
+
* Browser environment :
|
|
746
|
+
* Already handled
|
|
747
|
+
* Node.js environment :
|
|
748
|
+
* uses File System, downloadDestination expected to be a directory path, file is downloaded to this directory
|
|
749
|
+
*/
|
|
750
|
+
if (!isBrowser) {
|
|
751
|
+
/*
|
|
752
|
+
* Non Browser environment :
|
|
753
|
+
* - stream data to file
|
|
754
|
+
* - fetch response headers and body (if exists)
|
|
755
|
+
* - return in case of error or after stream finish
|
|
756
|
+
*
|
|
757
|
+
* NOTE :
|
|
758
|
+
* superagent does not provide access to headers before pipe, therefore response is piped to
|
|
759
|
+
* file with temporary name, which is renamed to proper filename after Content-Disposition header is available
|
|
760
|
+
*/
|
|
728
761
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
* @param {(String|Array.<String>|Object.<String, Object>|Function)} type The type to return. Pass a string for simple types
|
|
733
|
-
* or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
|
|
734
|
-
* return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
|
|
735
|
-
* all properties on <code>data<code> will be converted to this type.
|
|
736
|
-
* @returns An instance of the specified type or null or undefined if data is null or undefined.
|
|
737
|
-
*/
|
|
738
|
-
}, {
|
|
739
|
-
key: "convertToType",
|
|
740
|
-
value: function convertToType(data, type) {
|
|
741
|
-
if (data === null || data === undefined) return data;
|
|
742
|
-
switch (type) {
|
|
743
|
-
case 'Boolean':
|
|
744
|
-
return Boolean(data);
|
|
745
|
-
case 'Integer':
|
|
746
|
-
return parseInt(data, 10);
|
|
747
|
-
case 'Number':
|
|
748
|
-
return parseFloat(data);
|
|
749
|
-
case 'String':
|
|
750
|
-
return String(data);
|
|
751
|
-
case 'Date':
|
|
752
|
-
return ApiClient.parseDate(String(data));
|
|
753
|
-
case 'Blob':
|
|
754
|
-
return data;
|
|
755
|
-
default:
|
|
756
|
-
if (type === Object) {
|
|
757
|
-
// generic object, return directly
|
|
758
|
-
return data;
|
|
759
|
-
} else if (typeof type === 'function') {
|
|
760
|
-
// for model type like: User
|
|
761
|
-
return type.constructFromObject(data);
|
|
762
|
-
} else if (Array.isArray(type)) {
|
|
763
|
-
// for array type like: ['String']
|
|
764
|
-
var itemType = type[0];
|
|
765
|
-
return data.map(function (item) {
|
|
766
|
-
return ApiClient.convertToType(item, itemType);
|
|
767
|
-
});
|
|
768
|
-
} else if (_typeof(type) === 'object') {
|
|
769
|
-
// for plain object type like: {'String': 'Integer'}
|
|
770
|
-
var keyType, valueType;
|
|
771
|
-
for (var k in type) {
|
|
772
|
-
if (type.hasOwnProperty(k)) {
|
|
773
|
-
keyType = k;
|
|
774
|
-
valueType = type[k];
|
|
775
|
-
break;
|
|
776
|
-
}
|
|
762
|
+
let tempFilename = this.downloadDestination + '/downloaded_file_' + Date.now() + '.txt'; // temporary filename
|
|
763
|
+
let stream = _fs.default.createWriteStream(tempFilename);
|
|
764
|
+
_assertClassBrand(_ApiClient_brand, this, _processDownloadedFile).call(this, response, stream, tempFilename, resolve, reject, returnType);
|
|
777
765
|
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
766
|
+
} else if (response.status == 302) {
|
|
767
|
+
/*
|
|
768
|
+
* Handling 302 Redirects
|
|
769
|
+
* - Reads X-Redirect-Token header from response and writes into Cookie header for redirected request
|
|
770
|
+
*/
|
|
771
|
+
let tempFilename = this.downloadDestination + '/downloaded_file_' + Date.now() + '.txt'; // temporary filename
|
|
772
|
+
let context = this;
|
|
773
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Redirecting to :", response.headers.location);
|
|
774
|
+
var redirectRequest = (0, _superagent.default)(httpMethod, response.headers.location);
|
|
775
|
+
redirectRequest.set(request.header);
|
|
776
|
+
if (response.headers.hasOwnProperty("x-redirect-token")) {
|
|
777
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Writing X-Redirect-Token into Cookie");
|
|
778
|
+
redirectRequest.set("Cookie", response.headers["x-redirect-token"]);
|
|
779
|
+
}
|
|
780
|
+
if (this.requestAgent) {
|
|
781
|
+
redirectRequest.agent(this.requestAgent);
|
|
785
782
|
}
|
|
786
|
-
|
|
783
|
+
redirectRequest.redirects(0);
|
|
784
|
+
redirectRequest.withCredentials(this.withCredentials);
|
|
785
|
+
redirectRequest.buffer(false);
|
|
786
|
+
let redirectedStream = _fs.default.createWriteStream(tempFilename);
|
|
787
|
+
redirectRequest.pipe(redirectedStream);
|
|
788
|
+
redirectRequest.on('response', function (redirectResponse) {
|
|
789
|
+
_assertClassBrand(_ApiClient_brand, context, _log).call(context, _classPrivateFieldGet(_LOG_LEVEL, context).INFO, null, "Received response after redirection :", redirectResponse.status);
|
|
790
|
+
_assertClassBrand(_ApiClient_brand, context, _processDownloadedFile).call(context, redirectResponse, redirectedStream, tempFilename, resolve, reject, returnType);
|
|
791
|
+
});
|
|
787
792
|
} else {
|
|
788
|
-
|
|
789
|
-
return data;
|
|
793
|
+
_assertClassBrand(_ApiClient_brand, this, _handleApiResponseForPromise).call(this, response, path, queryParams, returnType, resolve, reject);
|
|
790
794
|
}
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
static addEtagReferenceToHeader(bodyParam, headerParams) {
|
|
800
|
+
// set If-Match header from postBody $reserved map
|
|
801
|
+
if (typeof bodyParam !== 'undefined' && bodyParam !== null) {
|
|
802
|
+
if (bodyParam.hasOwnProperty('$reserved') && bodyParam.$reserved.hasOwnProperty('ETag')) {
|
|
803
|
+
let eTagReference = bodyParam.$reserved['ETag'];
|
|
804
|
+
if (typeof eTagReference !== 'undefined' && eTagReference !== null && eTagReference !== "") {
|
|
805
|
+
headerParams['If-Match'] = eTagReference;
|
|
806
|
+
}
|
|
791
807
|
}
|
|
792
808
|
}
|
|
809
|
+
}
|
|
793
810
|
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
811
|
+
/*
|
|
812
|
+
* Parses an ISO-8601 string representation of a date value.
|
|
813
|
+
* @param {String} str The date value as a string.
|
|
814
|
+
* @returns {Date} The parsed date object.
|
|
815
|
+
*/
|
|
816
|
+
static parseDate(str) {
|
|
817
|
+
return new Date(str);
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/*
|
|
821
|
+
* Parses queryParams and path to find a given query param value
|
|
822
|
+
* @param {String} path The path given to callApi method
|
|
823
|
+
* @param {Object.<String, Object>} queryParams The queryParams given to callApi method
|
|
824
|
+
* @param {String} param Parameter name to look for
|
|
825
|
+
* @param {String} defaultValue The default value for the missing param if not present
|
|
826
|
+
* @returns {String} The value of given parameter
|
|
827
|
+
*/
|
|
828
|
+
static parseQueryParam(path, queryParams, param, defaultValue) {
|
|
829
|
+
let value = null;
|
|
830
|
+
if (typeof queryParams !== 'undefined' && queryParams.hasOwnProperty(param)) {
|
|
831
|
+
value = queryParams[param];
|
|
832
|
+
}
|
|
833
|
+
if (value === null && (typeof path === 'string' || path instanceof String)) {
|
|
834
|
+
const escapedParam = param.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
835
|
+
const regexResult = path.match(new RegExp(`${escapedParam}=([0-9]+)`));
|
|
836
|
+
if (regexResult) {
|
|
837
|
+
value = regexResult[1];
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
if (value === null) {
|
|
841
|
+
value = defaultValue;
|
|
842
|
+
}
|
|
843
|
+
return value;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Converts a value to the specified type.
|
|
848
|
+
* @param {(String|Object)} data The data to convert, as a string or object.
|
|
849
|
+
* @param {(String|Array.<String>|Object.<String, Object>|Function)} type The type to return. Pass a string for simple types
|
|
850
|
+
* or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
|
|
851
|
+
* return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
|
|
852
|
+
* all properties on <code>data<code> will be converted to this type.
|
|
853
|
+
* @returns An instance of the specified type or null or undefined if data is null or undefined.
|
|
854
|
+
*/
|
|
855
|
+
static convertToType(data, type) {
|
|
856
|
+
if (data === null || data === undefined) return data;
|
|
857
|
+
switch (type) {
|
|
858
|
+
case 'Boolean':
|
|
859
|
+
return Boolean(data);
|
|
860
|
+
case 'Integer':
|
|
861
|
+
return parseInt(data, 10);
|
|
862
|
+
case 'Number':
|
|
863
|
+
return parseFloat(data);
|
|
864
|
+
case 'String':
|
|
865
|
+
return String(data);
|
|
866
|
+
case 'Date':
|
|
867
|
+
return ApiClient.parseDate(String(data));
|
|
868
|
+
case 'Blob':
|
|
869
|
+
return data;
|
|
870
|
+
default:
|
|
871
|
+
if (type === Object) {
|
|
872
|
+
// generic object, return directly
|
|
873
|
+
return data;
|
|
874
|
+
} else if (typeof type === 'function') {
|
|
875
|
+
// for model type like: User
|
|
876
|
+
return type.constructFromObject(data);
|
|
877
|
+
} else if (Array.isArray(type)) {
|
|
878
|
+
// for array type like: ['String']
|
|
879
|
+
var itemType = type[0];
|
|
880
|
+
return data.map(item => {
|
|
881
|
+
return ApiClient.convertToType(item, itemType);
|
|
882
|
+
});
|
|
883
|
+
} else if (typeof type === 'object') {
|
|
884
|
+
// for plain object type like: {'String': 'Integer'}
|
|
885
|
+
var keyType, valueType;
|
|
886
|
+
for (var k in type) {
|
|
887
|
+
if (type.hasOwnProperty(k)) {
|
|
888
|
+
keyType = k;
|
|
889
|
+
valueType = type[k];
|
|
890
|
+
break;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
var result = {};
|
|
894
|
+
for (var k in data) {
|
|
895
|
+
if (data.hasOwnProperty(k)) {
|
|
896
|
+
var key = ApiClient.convertToType(k, keyType);
|
|
897
|
+
var value = ApiClient.convertToType(data[k], valueType);
|
|
898
|
+
result[key] = value;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
return result;
|
|
902
|
+
} else {
|
|
903
|
+
// for unknown type, return the data directly
|
|
904
|
+
return data;
|
|
809
905
|
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Constructs a new map or array model from REST data.
|
|
911
|
+
* @param data {Object|Array} The REST data.
|
|
912
|
+
* @param obj {Object|Array} The target object or array.
|
|
913
|
+
*/
|
|
914
|
+
static constructFromObject(data, obj, itemType) {
|
|
915
|
+
if (Array.isArray(data)) {
|
|
916
|
+
for (var i = 0; i < data.length; i++) {
|
|
917
|
+
if (data.hasOwnProperty(i)) obj[i] = ApiClient.convertToType(data[i], itemType);
|
|
918
|
+
}
|
|
919
|
+
} else {
|
|
920
|
+
for (var k in data) {
|
|
921
|
+
if (data.hasOwnProperty(k)) obj[k] = ApiClient.convertToType(data[k], itemType);
|
|
810
922
|
}
|
|
811
923
|
}
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
|
|
815
927
|
/**
|
|
816
928
|
* The default API client implementation.
|
|
817
929
|
* @type {ApiClient}
|
|
818
930
|
* @memberOf ApiClient
|
|
819
931
|
*/
|
|
820
932
|
exports.ApiClient = ApiClient;
|
|
821
|
-
|
|
822
|
-
function
|
|
933
|
+
_ApiClient = ApiClient;
|
|
934
|
+
function _isJsonMime(contentType) {
|
|
823
935
|
return Boolean(contentType != null && contentType.match(/^application\/json(;.*)?$/i));
|
|
824
936
|
}
|
|
825
|
-
|
|
937
|
+
/*
|
|
938
|
+
* Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
|
|
939
|
+
* @param {Array.<String>} contentTypes
|
|
940
|
+
* @returns {String} The chosen content type, preferring JSON.
|
|
941
|
+
*/
|
|
942
|
+
function _jsonPreferredMime(contentTypes) {
|
|
826
943
|
for (var i = 0; i < contentTypes.length; i++) {
|
|
827
|
-
if (
|
|
944
|
+
if (_assertClassBrand(_ApiClient_brand, this, _isJsonMime).call(this, contentTypes[i])) {
|
|
828
945
|
return contentTypes[i];
|
|
829
946
|
}
|
|
830
947
|
}
|
|
831
948
|
return contentTypes[0];
|
|
832
949
|
}
|
|
833
|
-
|
|
950
|
+
/*
|
|
951
|
+
* Checks whether the given parameter value represents file-like content.
|
|
952
|
+
* @param param The parameter to check.
|
|
953
|
+
* @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
|
|
954
|
+
*/
|
|
955
|
+
function _isFileParam(param) {
|
|
834
956
|
// fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
|
|
835
957
|
if (typeof require === 'function') {
|
|
836
|
-
|
|
958
|
+
let fs;
|
|
837
959
|
try {
|
|
838
|
-
|
|
960
|
+
fs = require('fs');
|
|
839
961
|
} catch (err) {}
|
|
840
|
-
if (
|
|
962
|
+
if (fs && fs.ReadStream && param instanceof fs.ReadStream) {
|
|
841
963
|
return true;
|
|
842
964
|
}
|
|
843
965
|
}
|
|
@@ -848,7 +970,7 @@ function _isFileParam2(param) {
|
|
|
848
970
|
}
|
|
849
971
|
|
|
850
972
|
// Blob in browser
|
|
851
|
-
if (typeof Blob === 'function' && param instanceof Blob) {
|
|
973
|
+
if (typeof _buffer.Blob === 'function' && param instanceof _buffer.Blob) {
|
|
852
974
|
return true;
|
|
853
975
|
}
|
|
854
976
|
|
|
@@ -858,12 +980,22 @@ function _isFileParam2(param) {
|
|
|
858
980
|
}
|
|
859
981
|
return false;
|
|
860
982
|
}
|
|
861
|
-
|
|
983
|
+
/*
|
|
984
|
+
* Normalizes parameter values:
|
|
985
|
+
* <ul>
|
|
986
|
+
* <li>remove nils</li>
|
|
987
|
+
* <li>keep files and arrays</li>
|
|
988
|
+
* <li>format to string with `paramToString` for other cases</li>
|
|
989
|
+
* </ul>
|
|
990
|
+
* @param {Object.<String, Object>} params The parameters as object properties.
|
|
991
|
+
* @returns {Object.<String, Object>} normalized parameters.
|
|
992
|
+
*/
|
|
993
|
+
function _normalizeParams(params) {
|
|
862
994
|
var newParams = {};
|
|
863
995
|
for (var key in params) {
|
|
864
996
|
if (params.hasOwnProperty(key) && params[key] != undefined && params[key] != null) {
|
|
865
997
|
var value = params[key];
|
|
866
|
-
if (
|
|
998
|
+
if (_assertClassBrand(_ApiClient_brand, this, _isFileParam).call(this, value) || Array.isArray(value)) {
|
|
867
999
|
newParams[key] = value;
|
|
868
1000
|
} else {
|
|
869
1001
|
newParams[key] = this.paramToString(value);
|
|
@@ -872,18 +1004,17 @@ function _normalizeParams2(params) {
|
|
|
872
1004
|
}
|
|
873
1005
|
return newParams;
|
|
874
1006
|
}
|
|
875
|
-
function
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
var auth = _this3.authentications[authName];
|
|
1007
|
+
function _applyAuthToRequest(request, authNames) {
|
|
1008
|
+
authNames.forEach(authName => {
|
|
1009
|
+
var auth = this.authentications[authName];
|
|
879
1010
|
switch (auth.type) {
|
|
880
1011
|
case 'basic':
|
|
881
1012
|
if (auth.username || auth.password) {
|
|
882
1013
|
request.auth(auth.username || '', auth.password || '');
|
|
883
|
-
} else if (
|
|
884
|
-
request.auth(
|
|
1014
|
+
} else if (this.username || this.password) {
|
|
1015
|
+
request.auth(this.username || '', this.password || '');
|
|
885
1016
|
}
|
|
886
|
-
|
|
1017
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Basic Auth applied to request");
|
|
887
1018
|
break;
|
|
888
1019
|
case 'apiKey':
|
|
889
1020
|
if (auth.apiKey) {
|
|
@@ -899,7 +1030,7 @@ function _applyAuthToRequest2(request, authNames) {
|
|
|
899
1030
|
request.query(data);
|
|
900
1031
|
}
|
|
901
1032
|
}
|
|
902
|
-
|
|
1033
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "apiKey applied to request");
|
|
903
1034
|
break;
|
|
904
1035
|
case 'oauth2':
|
|
905
1036
|
if (auth.accessToken) {
|
|
@@ -907,15 +1038,20 @@ function _applyAuthToRequest2(request, authNames) {
|
|
|
907
1038
|
'Authorization': 'Bearer ' + auth.accessToken
|
|
908
1039
|
});
|
|
909
1040
|
}
|
|
910
|
-
|
|
1041
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "oauth2 applied to request");
|
|
911
1042
|
break;
|
|
912
1043
|
default:
|
|
913
|
-
|
|
1044
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Unknown authentication type:", auth.type);
|
|
914
1045
|
throw new Error('Unknown authentication type: ' + auth.type);
|
|
915
1046
|
}
|
|
916
1047
|
});
|
|
917
1048
|
}
|
|
918
|
-
|
|
1049
|
+
/**
|
|
1050
|
+
* Wraps errors in generic response format.
|
|
1051
|
+
* @param {Object} error object encountered during request.
|
|
1052
|
+
* @returns an error object with wrapped response within error.data .
|
|
1053
|
+
*/
|
|
1054
|
+
function _wrapErrorInResponse(error) {
|
|
919
1055
|
var response = {
|
|
920
1056
|
data: {},
|
|
921
1057
|
metadata: {}
|
|
@@ -923,134 +1059,391 @@ function _wrapErrorInResponse2(error) {
|
|
|
923
1059
|
response.data.status = error.status;
|
|
924
1060
|
response.data.message = error.message;
|
|
925
1061
|
}
|
|
926
|
-
|
|
1062
|
+
/**
|
|
1063
|
+
* Deserializes an HTTP response body into a value of the specified type.
|
|
1064
|
+
* @param {Object} response A SuperAgent response object.
|
|
1065
|
+
* @param {(String|Array.<String>|Object.<String, Object>|Function)} returnType The type to return. Pass a string for simple types
|
|
1066
|
+
* or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
|
|
1067
|
+
* return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
|
|
1068
|
+
* all properties on <code>data<code> will be converted to this type.
|
|
1069
|
+
* @returns A value of the specified type.
|
|
1070
|
+
*/
|
|
1071
|
+
function _deserialize(response, returnType) {
|
|
927
1072
|
if (response == null || returnType == null || response.status == 204) {
|
|
928
1073
|
return null;
|
|
929
1074
|
}
|
|
930
1075
|
|
|
1076
|
+
// Handle text response
|
|
1077
|
+
if (response.headers && ['text/event-stream', 'text/html', 'text/xml', 'text/csv', 'text/javascript', 'text/markdown', 'text/vcard'].includes(response.headers['content-type'])) {
|
|
1078
|
+
var data = new returnType();
|
|
1079
|
+
data.data = new _buffer.Blob([response.text], {
|
|
1080
|
+
type: response.headers['content-type']
|
|
1081
|
+
});
|
|
1082
|
+
let flag = new _Flag.default();
|
|
1083
|
+
flag.name = "hasError";
|
|
1084
|
+
flag.value = false;
|
|
1085
|
+
let flags = [flag];
|
|
1086
|
+
let metadata = new _ApiResponseMetadata.default();
|
|
1087
|
+
metadata.flags = flags;
|
|
1088
|
+
data.metadata = metadata;
|
|
1089
|
+
return data;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
931
1092
|
// Rely on SuperAgent for parsing response body.
|
|
932
1093
|
// See http://visionmedia.github.io/superagent/#parsing-response-bodies
|
|
933
1094
|
var data = response.body;
|
|
934
|
-
if (data == null ||
|
|
1095
|
+
if (data == null || typeof data === 'object' && typeof data.length === 'undefined' && !Object.keys(data).length) {
|
|
935
1096
|
// SuperAgent does not always produce a body; use the unparsed response as a fallback
|
|
936
1097
|
data = response.text;
|
|
937
1098
|
}
|
|
938
|
-
return
|
|
1099
|
+
return _ApiClient.convertToType(data, returnType);
|
|
939
1100
|
}
|
|
940
|
-
|
|
1101
|
+
/**
|
|
1102
|
+
* Set pagination data if response is a Paginable object
|
|
1103
|
+
* @param {Object} data The response data already passed through deserialize
|
|
1104
|
+
* @param {String} path The path given to callApi method
|
|
1105
|
+
* @param {Object.<String, Object>} queryParams The queryParams given to callApi method
|
|
1106
|
+
*/
|
|
1107
|
+
function _paginateIfNeeded(data, path, queryParams) {
|
|
941
1108
|
// If response is not a Paginable instance, nothing to do
|
|
942
|
-
if (!(data instanceof _Paginable
|
|
1109
|
+
if (!(data instanceof _Paginable.default)) {
|
|
943
1110
|
return;
|
|
944
1111
|
}
|
|
945
1112
|
// Retrieve current page number, defaults to 0
|
|
946
|
-
|
|
1113
|
+
const page = parseInt(this.constructor.parseQueryParam(path, queryParams, '$page', "0"), 10);
|
|
947
1114
|
// Retrieve current limit (results per page) number, defaults to 50
|
|
948
|
-
|
|
1115
|
+
const resultsPerPage = parseInt(this.constructor.parseQueryParam(path, queryParams, '$limit', "50"), 10);
|
|
949
1116
|
|
|
950
1117
|
// Populate pagination data
|
|
951
1118
|
data.populatePaginationMetadata(this,
|
|
952
1119
|
// current ApiClient instance
|
|
953
1120
|
page, resultsPerPage);
|
|
954
1121
|
}
|
|
955
|
-
function
|
|
1122
|
+
function _performNegotiationBetweenVersions(sdk, server) {
|
|
1123
|
+
if (!sdk || !server) {
|
|
1124
|
+
return sdk;
|
|
1125
|
+
}
|
|
1126
|
+
let sdkProps = _assertClassBrand(_ApiClient_brand, this, _getVersionDetails).call(this, sdk);
|
|
1127
|
+
let serverProps = _assertClassBrand(_ApiClient_brand, this, _getVersionDetails).call(this, server);
|
|
1128
|
+
// if major version is different, then do not negotiate
|
|
1129
|
+
// maintain sdk version
|
|
1130
|
+
if (!sdkProps["family"] === serverProps["family"]) {
|
|
1131
|
+
return sdk;
|
|
1132
|
+
}
|
|
1133
|
+
// if sdk version is smaller than highest server version, then maintain sdk version
|
|
1134
|
+
if (_assertClassBrand(_ApiClient_brand, this, _isSmallerMinorVersion).call(this, sdkProps, serverProps)) {
|
|
1135
|
+
return sdk;
|
|
1136
|
+
}
|
|
1137
|
+
// since sdk version is higher than highest server version, use server version
|
|
1138
|
+
return server;
|
|
1139
|
+
}
|
|
1140
|
+
function _isSmallerMinorVersion(p1, p2) {
|
|
1141
|
+
// if revision different, then compare revision
|
|
1142
|
+
if (parseInt(p1["revision"]) != parseInt(p2["revision"])) {
|
|
1143
|
+
return parseInt(p1["revision"]) < parseInt(p2["revision"]);
|
|
1144
|
+
}
|
|
1145
|
+
// revision is same, so compare version_type (release_type + release_type_revision)
|
|
1146
|
+
if (p1["versionType"] === "released") {
|
|
1147
|
+
return false;
|
|
1148
|
+
}
|
|
1149
|
+
let p1ReleaseType = p1["versionType"].substring(0, 1);
|
|
1150
|
+
let p2ReleaseType = p2["versionType"].substring(0, 1);
|
|
1151
|
+
let p1ReleaseTypeRevision = parseInt(p1["versionType"].substring(1));
|
|
1152
|
+
let p2ReleaseTypeRevision = p2["versionType"] === "released" ? 0 : parseInt(p2["versionType"].substring(1));
|
|
1153
|
+
if (p1ReleaseType === p2ReleaseType) {
|
|
1154
|
+
// release type is same, so compare release type revision
|
|
1155
|
+
return p1ReleaseTypeRevision < p2ReleaseTypeRevision;
|
|
1156
|
+
}
|
|
1157
|
+
// release type is different, so alpha must be smallest and released must be largest
|
|
1158
|
+
return p1ReleaseType === "a" || p2["versionType"] === "released";
|
|
1159
|
+
}
|
|
1160
|
+
function _getVersionDetails(version) {
|
|
1161
|
+
let ret = {};
|
|
1162
|
+
if ("unversioned" === version) {
|
|
1163
|
+
ret["family"] = "unversioned";
|
|
1164
|
+
ret["versionType"] = "released";
|
|
1165
|
+
} else {
|
|
1166
|
+
let versionParts = version.toString().split('.');
|
|
1167
|
+
if ("unversioned" === versionParts[0]) {
|
|
1168
|
+
ret["family"] = "unversioned";
|
|
1169
|
+
ret["versionType"] = versionParts[1];
|
|
1170
|
+
} else {
|
|
1171
|
+
ret["family"] = versionParts[0].substring(1);
|
|
1172
|
+
ret["revision"] = versionParts[1];
|
|
1173
|
+
if (versionParts.length == 2) {
|
|
1174
|
+
ret["versionType"] = "released";
|
|
1175
|
+
} else {
|
|
1176
|
+
ret["versionType"] = versionParts[2];
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
return ret;
|
|
1181
|
+
}
|
|
1182
|
+
function _getValidTimeout(timeout, defaultTimeout) {
|
|
956
1183
|
if (timeout <= 0) {
|
|
957
1184
|
timeout = defaultTimeout;
|
|
958
|
-
} else if (timeout > _classPrivateFieldGet(
|
|
959
|
-
timeout = _classPrivateFieldGet(
|
|
1185
|
+
} else if (timeout > _classPrivateFieldGet(_defaultMaxTimeout, this)) {
|
|
1186
|
+
timeout = _classPrivateFieldGet(_defaultMaxTimeout, this);
|
|
960
1187
|
}
|
|
961
1188
|
return timeout;
|
|
962
1189
|
}
|
|
963
|
-
|
|
1190
|
+
// If enabled, update cookie information to reuse in subsequent requests for a valid response
|
|
1191
|
+
function _updateCookies(response) {
|
|
964
1192
|
if (response.hasOwnProperty("headers") && response.headers.hasOwnProperty("set-cookie")) {
|
|
965
|
-
|
|
966
|
-
|
|
1193
|
+
let finalCookie = "";
|
|
1194
|
+
let cookieList = response.headers["set-cookie"];
|
|
967
1195
|
if (cookieList.length > 0) {
|
|
968
1196
|
// add all cookies separated by ;
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
cookieItem = cookieItem.split(";")[0];
|
|
975
|
-
if (cookieItem.includes("=")) {
|
|
976
|
-
cookieItem.trim();
|
|
977
|
-
finalCookie = finalCookie.concat(cookieItem).concat(";");
|
|
978
|
-
}
|
|
1197
|
+
for (let cookieItem of cookieList) {
|
|
1198
|
+
cookieItem = cookieItem.split(";")[0];
|
|
1199
|
+
if (cookieItem.includes("=")) {
|
|
1200
|
+
cookieItem.trim();
|
|
1201
|
+
finalCookie = finalCookie.concat(cookieItem).concat(";");
|
|
979
1202
|
}
|
|
980
|
-
// remove trailing ;
|
|
981
|
-
} catch (err) {
|
|
982
|
-
_iterator2.e(err);
|
|
983
|
-
} finally {
|
|
984
|
-
_iterator2.f();
|
|
985
1203
|
}
|
|
1204
|
+
// remove trailing ;
|
|
986
1205
|
if (finalCookie !== "") {
|
|
987
1206
|
finalCookie = finalCookie.substr(0, finalCookie.length - 1);
|
|
988
1207
|
}
|
|
989
1208
|
}
|
|
990
|
-
_classPrivateFieldSet(
|
|
991
|
-
|
|
1209
|
+
_classPrivateFieldSet(_cookie, this, finalCookie);
|
|
1210
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Retained cookie :", finalCookie);
|
|
992
1211
|
} else {
|
|
993
|
-
_classPrivateFieldSet(
|
|
1212
|
+
_classPrivateFieldSet(_cookie, this, null);
|
|
994
1213
|
}
|
|
995
1214
|
}
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1215
|
+
// If enabled, attach saved cookies to request
|
|
1216
|
+
function _attachCookies(request) {
|
|
1217
|
+
if (_classPrivateFieldGet(_cookie, this) != null) {
|
|
1218
|
+
request.set(_assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, {
|
|
1219
|
+
'Cookie': _classPrivateFieldGet(_cookie, this)
|
|
1000
1220
|
}));
|
|
1001
1221
|
}
|
|
1002
1222
|
}
|
|
1003
|
-
function
|
|
1004
|
-
for (var _len = arguments.length, messages = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
1005
|
-
messages[_key - 2] = arguments[_key];
|
|
1006
|
-
}
|
|
1223
|
+
function _log(level, mapper, ...messages) {
|
|
1007
1224
|
// Set default log level to INFO
|
|
1008
|
-
if (
|
|
1009
|
-
level = _classPrivateFieldGet(
|
|
1225
|
+
if (typeof level !== "object" || !("key" in level) || !("value" in level) || typeof level["value"] !== "symbol") {
|
|
1226
|
+
level = _classPrivateFieldGet(_LOG_LEVEL, this).INFO;
|
|
1010
1227
|
}
|
|
1011
|
-
if (!
|
|
1228
|
+
if (!_assertClassBrand(_ApiClient_brand, this, _skipLogging).call(this, level)) {
|
|
1012
1229
|
// Preprocess message to prefix with timestamp and log level
|
|
1013
|
-
messages = messages.map(
|
|
1230
|
+
messages = messages.map(message => {
|
|
1014
1231
|
return typeof message === "string" ? message : mapper ? mapper(message) : JSON.stringify(message);
|
|
1015
1232
|
});
|
|
1016
|
-
|
|
1017
|
-
message =
|
|
1018
|
-
if (typeof _classPrivateFieldGet(
|
|
1019
|
-
_classPrivateFieldGet(
|
|
1233
|
+
let message = messages.join(' ');
|
|
1234
|
+
message = new Date().toISOString() + ' ' + level.key + ' - ' + message;
|
|
1235
|
+
if (typeof _classPrivateFieldGet(_logger, this) !== "undefined" && _classPrivateFieldGet(_logger, this) !== null && typeof _classPrivateFieldGet(_logger, this).log === 'function') {
|
|
1236
|
+
_classPrivateFieldGet(_logger, this).log(message);
|
|
1020
1237
|
} else {
|
|
1021
1238
|
console.log(message);
|
|
1022
1239
|
}
|
|
1023
1240
|
}
|
|
1024
1241
|
}
|
|
1025
|
-
function
|
|
1242
|
+
function _skipLogging(level) {
|
|
1026
1243
|
// Skip logging if log level is DEBUG but debug is not enabled.
|
|
1027
|
-
return !this.debug && level === _classPrivateFieldGet(
|
|
1028
|
-
}
|
|
1029
|
-
function _getLocalDateTime2() {
|
|
1030
|
-
// Current epoch UTC time in milliseconds
|
|
1031
|
-
var epochTime = Date.now();
|
|
1032
|
-
|
|
1033
|
-
// "getTimezoneOffset" returns the difference, in minutes, between a date as evaluated in the UTC time zone,
|
|
1034
|
-
// and the same date as evaluated in the local time zone.
|
|
1035
|
-
// if you are in timezone UTC-1, outputs 60
|
|
1036
|
-
// if you are in timezone UTC+3, outputs -180
|
|
1037
|
-
var timezoneOffsetInMinutes = new Date().getTimezoneOffset();
|
|
1038
|
-
var timezoneOffsetInMilliseconds = timezoneOffsetInMinutes * 60 * 1000;
|
|
1039
|
-
|
|
1040
|
-
// Create a new date with adjusted epoch time based on timezone offset
|
|
1041
|
-
var date = new Date(epochTime - timezoneOffsetInMilliseconds);
|
|
1042
|
-
return date.toISOString().slice(0, 23);
|
|
1244
|
+
return !this.debug && level === _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG;
|
|
1043
1245
|
}
|
|
1044
|
-
function
|
|
1045
|
-
|
|
1246
|
+
// A mapper function to flatten a simple non-nested (key:value) object to string
|
|
1247
|
+
function _flatten(obj) {
|
|
1248
|
+
if (typeof obj !== "object") {
|
|
1046
1249
|
return obj;
|
|
1047
1250
|
}
|
|
1048
|
-
|
|
1251
|
+
let output = '\n';
|
|
1049
1252
|
if (obj) {
|
|
1050
|
-
Object.keys(obj).forEach(
|
|
1253
|
+
Object.keys(obj).forEach(e => {
|
|
1051
1254
|
output += e + '=[' + obj[e] + ']\n';
|
|
1052
1255
|
});
|
|
1053
1256
|
}
|
|
1054
1257
|
return output === '\n' ? obj : output;
|
|
1055
1258
|
}
|
|
1259
|
+
// handle and deserialize received response
|
|
1260
|
+
function _handleApiResponseForPromise(response, path, queryParams, returnType, resolve, reject) {
|
|
1261
|
+
try {
|
|
1262
|
+
var data = _assertClassBrand(_ApiClient_brand, this, _deserialize).call(this, response, returnType);
|
|
1263
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Response Status :", response.status);
|
|
1264
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, _assertClassBrand(_ApiClient_brand, this, _flatten), "Response Headers :", response.headers);
|
|
1265
|
+
_assertClassBrand(_ApiClient_brand, this, _updateCookies).call(this, response || {});
|
|
1266
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Response Body :", data);
|
|
1267
|
+
if (response.status == 204 && data == null) {
|
|
1268
|
+
resolve({
|
|
1269
|
+
data,
|
|
1270
|
+
response
|
|
1271
|
+
});
|
|
1272
|
+
} else if (response.ok && data != null) {
|
|
1273
|
+
this.addEtagToReservedMap(response, data);
|
|
1274
|
+
_assertClassBrand(_ApiClient_brand, this, _paginateIfNeeded).call(this, data, path, queryParams);
|
|
1275
|
+
resolve({
|
|
1276
|
+
data,
|
|
1277
|
+
response
|
|
1278
|
+
});
|
|
1279
|
+
} else {
|
|
1280
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, data);
|
|
1281
|
+
reject({
|
|
1282
|
+
...response.error,
|
|
1283
|
+
data: data
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
} catch (err) {
|
|
1287
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Caught error while processing response!");
|
|
1288
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, err);
|
|
1289
|
+
err.data = _assertClassBrand(_ApiClient_brand, this, _wrapErrorInResponse).call(this, err);
|
|
1290
|
+
reject(err);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
function _prepareDownloadBrowserParams(url, httpMethod, queryParams, headerParams, bodyParam, authNames, contentTypes, accepts) {
|
|
1294
|
+
let authHeaders = {};
|
|
1295
|
+
|
|
1296
|
+
// Apply authentication logic
|
|
1297
|
+
authNames.forEach(authName => {
|
|
1298
|
+
const auth = this.authentications[authName];
|
|
1299
|
+
switch (auth.type) {
|
|
1300
|
+
case 'basic':
|
|
1301
|
+
let username = '';
|
|
1302
|
+
let password = '';
|
|
1303
|
+
if (auth.username || auth.password) {
|
|
1304
|
+
username = auth.username || '';
|
|
1305
|
+
password = auth.password || '';
|
|
1306
|
+
} else if (this.username || this.password) {
|
|
1307
|
+
username = this.username || '';
|
|
1308
|
+
password = this.password || '';
|
|
1309
|
+
}
|
|
1310
|
+
if (username || password) {
|
|
1311
|
+
const credentials = btoa(`${username}:${password}`);
|
|
1312
|
+
authHeaders['Authorization'] = `Basic ${credentials}`;
|
|
1313
|
+
}
|
|
1314
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Basic Auth applied to request");
|
|
1315
|
+
break;
|
|
1316
|
+
case 'apiKey':
|
|
1317
|
+
if (auth.apiKey) {
|
|
1318
|
+
let apiKeyValue = '';
|
|
1319
|
+
if (auth.apiKeyPrefix) {
|
|
1320
|
+
apiKeyValue = auth.apiKeyPrefix + ' ' + auth.apiKey;
|
|
1321
|
+
} else {
|
|
1322
|
+
apiKeyValue = auth.apiKey;
|
|
1323
|
+
}
|
|
1324
|
+
if (auth['in'] === 'header') {
|
|
1325
|
+
authHeaders[auth.name] = 'Bearer ' + apiKeyValue;
|
|
1326
|
+
} else if (auth['in'] === 'query') {
|
|
1327
|
+
queryParams[auth.name] = apiKeyValue;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "apiKey applied to request");
|
|
1331
|
+
break;
|
|
1332
|
+
case 'oauth2':
|
|
1333
|
+
if (auth.accessToken) {
|
|
1334
|
+
authHeaders['Authorization'] = 'Bearer ' + auth.accessToken;
|
|
1335
|
+
}
|
|
1336
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "oauth2 applied to request");
|
|
1337
|
+
break;
|
|
1338
|
+
default:
|
|
1339
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Unknown authentication type:", auth.type);
|
|
1340
|
+
throw new Error('Unknown authentication type: ' + auth.type);
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
|
|
1344
|
+
// set query parameters
|
|
1345
|
+
if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
|
|
1346
|
+
queryParams['cache'] = 'false';
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
// Build URL with query parameters
|
|
1350
|
+
const normalizedParams = _assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, queryParams);
|
|
1351
|
+
const queryString = Object.keys(normalizedParams).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(normalizedParams[key])}`).join('&');
|
|
1352
|
+
let finalUrl = url;
|
|
1353
|
+
if (queryString) {
|
|
1354
|
+
finalUrl += (finalUrl.includes('?') ? '&' : '?') + queryString;
|
|
1355
|
+
}
|
|
1356
|
+
const finalHeaders = {
|
|
1357
|
+
...this.defaultHeaders,
|
|
1358
|
+
..._assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, headerParams),
|
|
1359
|
+
...authHeaders
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1362
|
+
// set header parameters
|
|
1363
|
+
if ((this.defaultHeaders['NTNX-Request-Id'] === null || this.defaultHeaders['NTNX-Request-Id'] === undefined) && (headerParams['NTNX-Request-Id'] === null || headerParams['NTNX-Request-Id'] === undefined)) {
|
|
1364
|
+
let requestId = (0, _uuid.v4)();
|
|
1365
|
+
finalHeaders['NTNX-Request-Id'] = requestId;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
//Add cookies if they exist
|
|
1369
|
+
if (_classPrivateFieldGet(_cookie, this) != null) {
|
|
1370
|
+
finalHeaders['Cookie'] = _assertClassBrand(_ApiClient_brand, this, _normalizeParams).call(this, {
|
|
1371
|
+
'Cookie': _classPrivateFieldGet(_cookie, this)
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
// Set content type
|
|
1376
|
+
var contentType = headerParams.hasOwnProperty("Content-Type") ? headerParams["Content-Type"] : _assertClassBrand(_ApiClient_brand, this, _jsonPreferredMime).call(this, contentTypes);
|
|
1377
|
+
finalHeaders['Content-Type'] = contentType;
|
|
1378
|
+
|
|
1379
|
+
// Set Accept Header
|
|
1380
|
+
var accept = headerParams.hasOwnProperty("Accept") && headerParams["Accept"] != undefined ? headerParams["Accept"] : accepts.join(', ');
|
|
1381
|
+
if (accept) {
|
|
1382
|
+
finalHeaders['Accept'] = accept;
|
|
1383
|
+
}
|
|
1384
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Request URL :", httpMethod, url);
|
|
1385
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, _assertClassBrand(_ApiClient_brand, this, _flatten), "Request Headers :", finalHeaders);
|
|
1386
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).DEBUG, null, "Request Body :", bodyParam || "");
|
|
1387
|
+
return {
|
|
1388
|
+
url: finalUrl,
|
|
1389
|
+
options: {
|
|
1390
|
+
method: httpMethod,
|
|
1391
|
+
headers: finalHeaders,
|
|
1392
|
+
body: bodyParam,
|
|
1393
|
+
credentials: this.withCredentials ? 'include' : 'same-origin'
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
function _processDownloadedFile(response, stream, tempFilename, resolve, reject, returnType) {
|
|
1398
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Streaming response to : ", tempFilename);
|
|
1399
|
+
try {
|
|
1400
|
+
response.on('data', chunk => {
|
|
1401
|
+
stream.write(chunk);
|
|
1402
|
+
});
|
|
1403
|
+
} catch (err) {
|
|
1404
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Issue while downloading file", err);
|
|
1405
|
+
}
|
|
1406
|
+
let data = new returnType();
|
|
1407
|
+
// Fetch filename
|
|
1408
|
+
let filename = "";
|
|
1409
|
+
if (typeof response.headers['content-disposition'] !== 'undefined' && response.headers['content-disposition'] !== null) {
|
|
1410
|
+
let match = response.headers['content-disposition'].match(/.*filename=\"(?<filename>.*)\".*/);
|
|
1411
|
+
let filepath = _path.default.parse(match.groups['filename']);
|
|
1412
|
+
filename = this.downloadDestination + '/' + filepath.name + '_' + Date.now() + filepath.ext;
|
|
1413
|
+
data.data = {
|
|
1414
|
+
"path": _path.default.parse(filename),
|
|
1415
|
+
$objectType: "Path"
|
|
1416
|
+
};
|
|
1417
|
+
let flag = new _Flag.default();
|
|
1418
|
+
flag.name = "hasError";
|
|
1419
|
+
flag.value = false;
|
|
1420
|
+
let flags = [flag];
|
|
1421
|
+
let metadata = new _ApiResponseMetadata.default();
|
|
1422
|
+
metadata.flags = flags;
|
|
1423
|
+
data.metadata = metadata;
|
|
1424
|
+
}
|
|
1425
|
+
response.on('end', () => {
|
|
1426
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Finished streaming response");
|
|
1427
|
+
if (filename.length !== 0) {
|
|
1428
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).INFO, null, "Content-Disposition header found [", filename, "] is final filename");
|
|
1429
|
+
stream.close();
|
|
1430
|
+
_fs.default.renameSync(tempFilename, filename);
|
|
1431
|
+
resolve({
|
|
1432
|
+
data,
|
|
1433
|
+
response
|
|
1434
|
+
});
|
|
1435
|
+
} else {
|
|
1436
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Content-Disposition header not found [", tempFilename, "] is final filename");
|
|
1437
|
+
resolve({
|
|
1438
|
+
data,
|
|
1439
|
+
response
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
response.on('error', err => {
|
|
1444
|
+
_assertClassBrand(_ApiClient_brand, this, _log).call(this, _classPrivateFieldGet(_LOG_LEVEL, this).ERROR, null, "Caught the following error :", err);
|
|
1445
|
+
error.data = _assertClassBrand(_ApiClient_brand, this, _wrapErrorInResponse).call(this, error);
|
|
1446
|
+
reject(err);
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1056
1449
|
ApiClient.instance = new ApiClient();
|