Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor() {
super();
this["odata.type"] = "SPATools.Models.ChildDerived";
}
}
constructor() {
this["odata.type"] = "SPATools.Models.Child";
}
}
conditionValue['operator'] = derived.operator ? derived.operator.toString() : 'GreaterThan';
conditionValue['threshold'] = derived.threshold;
conditionValue['windowSize'] = derived.windowSize.toIsoString();
}
if (parameters.properties.condition.type === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.LocationThresholdRuleCondition') {
conditionValue['odata.type'] = parameters.properties.condition.type;
var derived3 = parameters.properties.condition;
if (derived3.dataSource) {
var dataSourceValue2 = {};
conditionValue['dataSource'] = dataSourceValue2;
if (derived3.dataSource.type === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource') {
dataSourceValue2['odata.type'] = derived3.dataSource.type;
var derived4 = derived3.dataSource;
if (derived4.resourceUri) {
dataSourceValue2['resourceUri'] = derived4.resourceUri;
}
if (derived4.metricNamespace) {
dataSourceValue2['metricNamespace'] = derived4.metricNamespace;
}
if (derived4.metricName) {
dataSourceValue2['metricName'] = derived4.metricName;
}
}
}
ruleCreateOrUpdateParametersValue['Name'] = parameters.rule.name;
}
if (parameters.rule.description !== null && parameters.rule.description !== undefined) {
ruleCreateOrUpdateParametersValue['Description'] = parameters.rule.description;
}
if (parameters.rule.isEnabled !== null && parameters.rule.isEnabled !== undefined) {
ruleCreateOrUpdateParametersValue['IsEnabled'] = parameters.rule.isEnabled;
}
if (parameters.rule.condition !== null && parameters.rule.condition !== undefined) {
var conditionValue = {};
ruleCreateOrUpdateParametersValue['Condition'] = conditionValue;
if (parameters.rule.condition.type === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.ThresholdRuleCondition') {
conditionValue['odata.type'] = parameters.rule.condition.type;
var derived = parameters.rule.condition;
if (derived.dataSource !== null && derived.dataSource !== undefined) {
var dataSourceValue = {};
conditionValue['DataSource'] = dataSourceValue;
if (derived.dataSource.type === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource') {
dataSourceValue['odata.type'] = derived.dataSource.type;
var derived2 = derived.dataSource;
if (derived2.resourceId !== null && derived2.resourceId !== undefined) {
dataSourceValue['ResourceId'] = derived2.resourceId;
}
if (derived2.metricNamespace !== null && derived2.metricNamespace !== undefined) {
dataSourceValue['MetricNamespace'] = derived2.metricNamespace;
}
}
var windowSizeValue = conditionValue['WindowSize'];
if (windowSizeValue !== null && windowSizeValue !== undefined) {
var windowSizeInstance = moment.duration(windowSizeValue);
thresholdRuleConditionInstance.windowSize = windowSizeInstance;
}
ruleInstance.condition = thresholdRuleConditionInstance;
}
}
var actionsArray = responseDoc['Actions'];
if (actionsArray !== null && actionsArray !== undefined) {
for (var loweredIndex1 = 0; loweredIndex1 < actionsArray.length; loweredIndex1 = loweredIndex1 + 1) {
var actionsValue = actionsArray[loweredIndex1];
var typeName3 = actionsValue['odata.type'];
if (typeName3 === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleEmailAction') {
var ruleEmailActionInstance = { customEmails: [] };
var sendToServiceOwnersValue = actionsValue['SendToServiceOwners'];
if (sendToServiceOwnersValue !== null && sendToServiceOwnersValue !== undefined) {
var sendToServiceOwnersInstance = sendToServiceOwnersValue;
ruleEmailActionInstance.sendToServiceOwners = sendToServiceOwnersInstance;
}
var customEmailsArray = actionsValue['CustomEmails'];
if (customEmailsArray !== null && customEmailsArray !== undefined) {
for (var loweredIndex2 = 0; loweredIndex2 < customEmailsArray.length; loweredIndex2 = loweredIndex2 + 1) {
var customEmailsValue = customEmailsArray[loweredIndex2];
ruleEmailActionInstance.customEmails.push(customEmailsValue);
}
}
var resourceIdValue = valueValue['ResourceId'];
if (resourceIdValue) {
var resourceIdInstance = resourceIdValue;
metricSettingInstance.resourceId = resourceIdInstance;
}
var namespaceValue = valueValue['Namespace'];
if (namespaceValue) {
var namespaceInstance = namespaceValue;
metricSettingInstance.namespace = namespaceInstance;
}
var valueValue2 = valueValue['Value'];
if (valueValue2) {
var typeName = valueValue2['odata.type'];
if (typeName === 'Microsoft.WindowsAzure.Management.Monitoring.Metrics.Models.AvailabilityMetricSettingValue') {
var availabilityMetricSettingValueInstance = { availableLocations: [], endpoints: [] };
var availableLocationsArray = valueValue2['AvailableLocations'];
if (availableLocationsArray) {
for (var loweredIndex2 = 0; loweredIndex2 < availableLocationsArray.length; loweredIndex2 = loweredIndex2 + 1) {
var availableLocationsValue = availableLocationsArray[loweredIndex2];
var nameConfigInstance = {};
availabilityMetricSettingValueInstance.availableLocations.push(nameConfigInstance);
var nameValue = availableLocationsValue['Name'];
if (nameValue) {
var nameInstance = nameValue;
nameConfigInstance.name = nameInstance;
}
thresholdRuleConditionInstance.threshold = thresholdInstance;
}
var windowSizeValue = conditionValue['windowSize'];
if (windowSizeValue) {
var windowSizeInstance = moment.duration(windowSizeValue);
thresholdRuleConditionInstance.windowSize = windowSizeInstance;
}
propertiesInstance.condition = thresholdRuleConditionInstance;
}
if (typeName === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.LocationThresholdRuleCondition') {
var locationThresholdRuleConditionInstance = {};
var dataSourceValue2 = conditionValue['dataSource'];
if (dataSourceValue2) {
var typeName3 = dataSourceValue2['odata.type'];
if (typeName3 === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource') {
var ruleMetricDataSourceInstance2 = {};
var resourceUriValue2 = dataSourceValue2['resourceUri'];
if (resourceUriValue2) {
var resourceUriInstance2 = resourceUriValue2;
ruleMetricDataSourceInstance2.resourceUri = resourceUriInstance2;
}
var metricNamespaceValue2 = dataSourceValue2['metricNamespace'];
if (metricNamespaceValue2) {
var metricNamespaceInstance2 = metricNamespaceValue2;
ruleMetricDataSourceInstance2.metricNamespace = metricNamespaceInstance2;
}
var metricNameValue2 = dataSourceValue2['metricName'];
var descriptionValue = propertiesValue['description'];
if (descriptionValue) {
var descriptionInstance = descriptionValue;
propertiesInstance.description = descriptionInstance;
}
var isEnabledValue = propertiesValue['isEnabled'];
if (isEnabledValue) {
var isEnabledInstance = isEnabledValue;
propertiesInstance.isEnabled = isEnabledInstance;
}
var conditionValue = propertiesValue['condition'];
if (conditionValue) {
var typeName = conditionValue['odata.type'];
if (typeName === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.ThresholdRuleCondition') {
var thresholdRuleConditionInstance = {};
var dataSourceValue = conditionValue['dataSource'];
if (dataSourceValue) {
var typeName2 = dataSourceValue['odata.type'];
if (typeName2 === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource') {
var ruleMetricDataSourceInstance = {};
var resourceUriValue = dataSourceValue['resourceUri'];
if (resourceUriValue) {
var resourceUriInstance = resourceUriValue;
ruleMetricDataSourceInstance.resourceUri = resourceUriInstance;
}
var metricNamespaceValue = dataSourceValue['metricNamespace'];
dataSourceValue2['metricName'] = derived4.metricName;
}
}
}
conditionValue['windowSize'] = derived3.windowSize.toIsoString();
conditionValue['failedLocationCount'] = derived3.failedLocationCount;
}
}
if (parameters.properties.action) {
var actionValue = {};
propertiesValue['action'] = actionValue;
if (parameters.properties.action.type === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleEmailAction') {
actionValue['odata.type'] = parameters.properties.action.type;
var derived5 = parameters.properties.action;
actionValue['sendToServiceOwners'] = derived5.sendToServiceOwners;
if (derived5.customEmails) {
var customEmailsArray = [];
for (var loweredIndex1 = 0; loweredIndex1 < derived5.customEmails.length; loweredIndex1 = loweredIndex1 + 1) {
var customEmailsItem = derived5.customEmails[loweredIndex1];
customEmailsArray.push(customEmailsItem);
}
actionValue['customEmails'] = customEmailsArray;
}
}
}
propertiesValue['lastUpdatedTime'] = parameters.properties.lastUpdatedTime;
if (parameters.rule.isEnabled !== null && parameters.rule.isEnabled !== undefined) {
ruleCreateOrUpdateParametersValue['IsEnabled'] = parameters.rule.isEnabled;
}
if (parameters.rule.condition !== null && parameters.rule.condition !== undefined) {
var conditionValue = {};
ruleCreateOrUpdateParametersValue['Condition'] = conditionValue;
if (parameters.rule.condition.type === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.ThresholdRuleCondition') {
conditionValue['odata.type'] = parameters.rule.condition.type;
var derived = parameters.rule.condition;
if (derived.dataSource !== null && derived.dataSource !== undefined) {
var dataSourceValue = {};
conditionValue['DataSource'] = dataSourceValue;
if (derived.dataSource.type === 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource') {
dataSourceValue['odata.type'] = derived.dataSource.type;
var derived2 = derived.dataSource;
if (derived2.resourceId !== null && derived2.resourceId !== undefined) {
dataSourceValue['ResourceId'] = derived2.resourceId;
}
if (derived2.metricNamespace !== null && derived2.metricNamespace !== undefined) {
dataSourceValue['MetricNamespace'] = derived2.metricNamespace;
}
if (derived2.metricName !== null && derived2.metricName !== undefined) {
dataSourceValue['MetricName'] = derived2.metricName;
}
}
}