diff --git a/lib/services/monitor/lib/models/action.js b/lib/services/monitor/lib/models/action.js new file mode 100644 index 0000000000..91eaf1b94d --- /dev/null +++ b/lib/services/monitor/lib/models/action.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An alert action. + * + */ +class Action { + /** + * Create a Action. + * @member {string} [actionGroupId] the id of the action group to use. + * @member {object} [webhookProperties] + */ + constructor() { + } + + /** + * Defines the metadata of Action + * + * @returns {object} metadata of Action + * + */ + mapper() { + return { + required: false, + serializedName: 'Action', + type: { + name: 'Composite', + className: 'Action', + modelProperties: { + actionGroupId: { + required: false, + serializedName: 'actionGroupId', + type: { + name: 'String' + } + }, + webhookProperties: { + required: false, + serializedName: 'webhookProperties', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = Action; diff --git a/lib/services/monitor/lib/models/actionGroupList.js b/lib/services/monitor/lib/models/actionGroupList.js new file mode 100644 index 0000000000..686e1c81f9 --- /dev/null +++ b/lib/services/monitor/lib/models/actionGroupList.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A list of action groups. + */ +class ActionGroupList extends Array { + /** + * Create a ActionGroupList. + * @member {string} [nextLink] Provides the link to retrieve the next set of + * elements. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ActionGroupList + * + * @returns {object} metadata of ActionGroupList + * + */ + mapper() { + return { + required: false, + serializedName: 'ActionGroupList', + type: { + name: 'Composite', + className: 'ActionGroupList', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionGroupResourceElementType', + type: { + name: 'Composite', + className: 'ActionGroupResource' + } + } + } + } + } + } + }; + } +} + +module.exports = ActionGroupList; diff --git a/lib/services/monitor/lib/models/actionGroupPatchBody.js b/lib/services/monitor/lib/models/actionGroupPatchBody.js new file mode 100644 index 0000000000..c55155969f --- /dev/null +++ b/lib/services/monitor/lib/models/actionGroupPatchBody.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An action group object for the body of patch operations. + * + */ +class ActionGroupPatchBody { + /** + * Create a ActionGroupPatchBody. + * @member {object} [tags] Resource tags + * @member {boolean} [enabled] Indicates whether this action group is + * enabled. If an action group is not enabled, then none of its actions will + * be activated. Default value: true . + */ + constructor() { + } + + /** + * Defines the metadata of ActionGroupPatchBody + * + * @returns {object} metadata of ActionGroupPatchBody + * + */ + mapper() { + return { + required: false, + serializedName: 'ActionGroupPatchBody', + type: { + name: 'Composite', + className: 'ActionGroupPatchBody', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + enabled: { + required: false, + serializedName: 'properties.enabled', + defaultValue: true, + type: { + name: 'Boolean' + } + } + } + } + }; + } +} + +module.exports = ActionGroupPatchBody; diff --git a/lib/services/monitor/lib/models/actionGroupResource.js b/lib/services/monitor/lib/models/actionGroupResource.js new file mode 100644 index 0000000000..125c43c8e7 --- /dev/null +++ b/lib/services/monitor/lib/models/actionGroupResource.js @@ -0,0 +1,218 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An action group resource. + * + * @extends models['Resource'] + */ +class ActionGroupResource extends models['Resource'] { + /** + * Create a ActionGroupResource. + * @member {string} groupShortName The short name of the action group. This + * will be used in SMS messages. + * @member {boolean} enabled Indicates whether this action group is enabled. + * If an action group is not enabled, then none of its receivers will receive + * communications. Default value: true . + * @member {array} [emailReceivers] The list of email receivers that are part + * of this action group. + * @member {array} [smsReceivers] The list of SMS receivers that are part of + * this action group. + * @member {array} [webhookReceivers] The list of webhook receivers that are + * part of this action group. + * @member {array} [itsmReceivers] The list of ITSM receivers that are part + * of this action group. + * @member {array} [azureAppPushReceivers] The list of AzureAppPush receivers + * that are part of this action group. + * @member {array} [automationRunbookReceivers] The list of AutomationRunbook + * receivers that are part of this action group. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ActionGroupResource + * + * @returns {object} metadata of ActionGroupResource + * + */ + mapper() { + return { + required: false, + serializedName: 'ActionGroupResource', + type: { + name: 'Composite', + className: 'ActionGroupResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + groupShortName: { + required: true, + serializedName: 'properties.groupShortName', + constraints: { + MaxLength: 15 + }, + type: { + name: 'String' + } + }, + enabled: { + required: true, + serializedName: 'properties.enabled', + defaultValue: true, + type: { + name: 'Boolean' + } + }, + emailReceivers: { + required: false, + serializedName: 'properties.emailReceivers', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'EmailReceiverElementType', + type: { + name: 'Composite', + className: 'EmailReceiver' + } + } + } + }, + smsReceivers: { + required: false, + serializedName: 'properties.smsReceivers', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'SmsReceiverElementType', + type: { + name: 'Composite', + className: 'SmsReceiver' + } + } + } + }, + webhookReceivers: { + required: false, + serializedName: 'properties.webhookReceivers', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'WebhookReceiverElementType', + type: { + name: 'Composite', + className: 'WebhookReceiver' + } + } + } + }, + itsmReceivers: { + required: false, + serializedName: 'properties.itsmReceivers', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ItsmReceiverElementType', + type: { + name: 'Composite', + className: 'ItsmReceiver' + } + } + } + }, + azureAppPushReceivers: { + required: false, + serializedName: 'properties.azureAppPushReceivers', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AzureAppPushReceiverElementType', + type: { + name: 'Composite', + className: 'AzureAppPushReceiver' + } + } + } + }, + automationRunbookReceivers: { + required: false, + serializedName: 'properties.automationRunbookReceivers', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AutomationRunbookReceiverElementType', + type: { + name: 'Composite', + className: 'AutomationRunbookReceiver' + } + } + } + } + } + } + }; + } +} + +module.exports = ActionGroupResource; diff --git a/lib/services/monitor/lib/models/activityLogAlertActionGroup.js b/lib/services/monitor/lib/models/activityLogAlertActionGroup.js new file mode 100644 index 0000000000..727c96320c --- /dev/null +++ b/lib/services/monitor/lib/models/activityLogAlertActionGroup.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A pointer to an Azure Action Group. + * + */ +class ActivityLogAlertActionGroup { + /** + * Create a ActivityLogAlertActionGroup. + * @member {string} actionGroupId The resourceId of the action group. This + * cannot be null or empty. + * @member {object} [webhookProperties] the dictionary of custom properties + * to include with the post operation. These data are appended to the webhook + * payload. + */ + constructor() { + } + + /** + * Defines the metadata of ActivityLogAlertActionGroup + * + * @returns {object} metadata of ActivityLogAlertActionGroup + * + */ + mapper() { + return { + required: false, + serializedName: 'ActivityLogAlertActionGroup', + type: { + name: 'Composite', + className: 'ActivityLogAlertActionGroup', + modelProperties: { + actionGroupId: { + required: true, + serializedName: 'actionGroupId', + type: { + name: 'String' + } + }, + webhookProperties: { + required: false, + serializedName: 'webhookProperties', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = ActivityLogAlertActionGroup; diff --git a/lib/services/monitor/lib/models/activityLogAlertActionList.js b/lib/services/monitor/lib/models/activityLogAlertActionList.js new file mode 100644 index 0000000000..2de7dd16fe --- /dev/null +++ b/lib/services/monitor/lib/models/activityLogAlertActionList.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A list of activity log alert actions. + * + */ +class ActivityLogAlertActionList { + /** + * Create a ActivityLogAlertActionList. + * @member {array} [actionGroups] The list of activity log alerts. + */ + constructor() { + } + + /** + * Defines the metadata of ActivityLogAlertActionList + * + * @returns {object} metadata of ActivityLogAlertActionList + * + */ + mapper() { + return { + required: false, + serializedName: 'ActivityLogAlertActionList', + type: { + name: 'Composite', + className: 'ActivityLogAlertActionList', + modelProperties: { + actionGroups: { + required: false, + serializedName: 'actionGroups', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActivityLogAlertActionGroupElementType', + type: { + name: 'Composite', + className: 'ActivityLogAlertActionGroup' + } + } + } + } + } + } + }; + } +} + +module.exports = ActivityLogAlertActionList; diff --git a/lib/services/monitor/lib/models/activityLogAlertAllOfCondition.js b/lib/services/monitor/lib/models/activityLogAlertAllOfCondition.js new file mode 100644 index 0000000000..234f03ce70 --- /dev/null +++ b/lib/services/monitor/lib/models/activityLogAlertAllOfCondition.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An Activity Log alert condition that is met when all its member conditions + * are met. + * + */ +class ActivityLogAlertAllOfCondition { + /** + * Create a ActivityLogAlertAllOfCondition. + * @member {array} allOf The list of activity log alert conditions. + */ + constructor() { + } + + /** + * Defines the metadata of ActivityLogAlertAllOfCondition + * + * @returns {object} metadata of ActivityLogAlertAllOfCondition + * + */ + mapper() { + return { + required: false, + serializedName: 'ActivityLogAlertAllOfCondition', + type: { + name: 'Composite', + className: 'ActivityLogAlertAllOfCondition', + modelProperties: { + allOf: { + required: true, + serializedName: 'allOf', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActivityLogAlertLeafConditionElementType', + type: { + name: 'Composite', + className: 'ActivityLogAlertLeafCondition' + } + } + } + } + } + } + }; + } +} + +module.exports = ActivityLogAlertAllOfCondition; diff --git a/lib/services/monitor/lib/models/activityLogAlertLeafCondition.js b/lib/services/monitor/lib/models/activityLogAlertLeafCondition.js new file mode 100644 index 0000000000..df05750642 --- /dev/null +++ b/lib/services/monitor/lib/models/activityLogAlertLeafCondition.js @@ -0,0 +1,66 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An Activity Log alert condition that is met by comparing an activity log + * field and value. + * + */ +class ActivityLogAlertLeafCondition { + /** + * Create a ActivityLogAlertLeafCondition. + * @member {string} field The name of the field that this condition will + * examine. The possible values for this field are (case-insensitive): + * 'resourceId', 'category', 'caller', 'level', 'operationName', + * 'resourceGroup', 'resourceProvider', 'status', 'subStatus', + * 'resourceType', or anything beginning with 'properties.'. + * @member {string} equals The field value will be compared to this value + * (case-insensitive) to determine if the condition is met. + */ + constructor() { + } + + /** + * Defines the metadata of ActivityLogAlertLeafCondition + * + * @returns {object} metadata of ActivityLogAlertLeafCondition + * + */ + mapper() { + return { + required: false, + serializedName: 'ActivityLogAlertLeafCondition', + type: { + name: 'Composite', + className: 'ActivityLogAlertLeafCondition', + modelProperties: { + field: { + required: true, + serializedName: 'field', + type: { + name: 'String' + } + }, + equals: { + required: true, + serializedName: 'equals', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ActivityLogAlertLeafCondition; diff --git a/lib/services/monitor/lib/models/activityLogAlertList.js b/lib/services/monitor/lib/models/activityLogAlertList.js new file mode 100644 index 0000000000..6379f702f8 --- /dev/null +++ b/lib/services/monitor/lib/models/activityLogAlertList.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A list of activity log alerts. + */ +class ActivityLogAlertList extends Array { + /** + * Create a ActivityLogAlertList. + * @member {string} [nextLink] Provides the link to retrieve the next set of + * elements. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ActivityLogAlertList + * + * @returns {object} metadata of ActivityLogAlertList + * + */ + mapper() { + return { + required: false, + serializedName: 'ActivityLogAlertList', + type: { + name: 'Composite', + className: 'ActivityLogAlertList', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActivityLogAlertResourceElementType', + type: { + name: 'Composite', + className: 'ActivityLogAlertResource' + } + } + } + } + } + } + }; + } +} + +module.exports = ActivityLogAlertList; diff --git a/lib/services/monitor/lib/models/activityLogAlertPatchBody.js b/lib/services/monitor/lib/models/activityLogAlertPatchBody.js new file mode 100644 index 0000000000..aa120768da --- /dev/null +++ b/lib/services/monitor/lib/models/activityLogAlertPatchBody.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An activity log alert object for the body of patch operations. + * + */ +class ActivityLogAlertPatchBody { + /** + * Create a ActivityLogAlertPatchBody. + * @member {object} [tags] Resource tags + * @member {boolean} [enabled] Indicates whether this activity log alert is + * enabled. If an activity log alert is not enabled, then none of its actions + * will be activated. Default value: true . + */ + constructor() { + } + + /** + * Defines the metadata of ActivityLogAlertPatchBody + * + * @returns {object} metadata of ActivityLogAlertPatchBody + * + */ + mapper() { + return { + required: false, + serializedName: 'ActivityLogAlertPatchBody', + type: { + name: 'Composite', + className: 'ActivityLogAlertPatchBody', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + enabled: { + required: false, + serializedName: 'properties.enabled', + defaultValue: true, + type: { + name: 'Boolean' + } + } + } + } + }; + } +} + +module.exports = ActivityLogAlertPatchBody; diff --git a/lib/services/monitor/lib/models/activityLogAlertResource.js b/lib/services/monitor/lib/models/activityLogAlertResource.js new file mode 100644 index 0000000000..dc857e34d9 --- /dev/null +++ b/lib/services/monitor/lib/models/activityLogAlertResource.js @@ -0,0 +1,153 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An activity log alert resource. + * + * @extends models['Resource'] + */ +class ActivityLogAlertResource extends models['Resource'] { + /** + * Create a ActivityLogAlertResource. + * @member {array} scopes A list of resourceIds that will be used as + * prefixes. The alert will only apply to activityLogs with resourceIds that + * fall under one of these prefixes. This list must include at least one + * item. + * @member {boolean} [enabled] Indicates whether this activity log alert is + * enabled. If an activity log alert is not enabled, then none of its actions + * will be activated. Default value: true . + * @member {object} condition The condition that will cause this alert to + * activate. + * @member {array} [condition.allOf] The list of activity log alert + * conditions. + * @member {object} actions The actions that will activate when the condition + * is met. + * @member {array} [actions.actionGroups] The list of activity log alerts. + * @member {string} [description] A description of this activity log alert. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ActivityLogAlertResource + * + * @returns {object} metadata of ActivityLogAlertResource + * + */ + mapper() { + return { + required: false, + serializedName: 'ActivityLogAlertResource', + type: { + name: 'Composite', + className: 'ActivityLogAlertResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + scopes: { + required: true, + serializedName: 'properties.scopes', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + enabled: { + required: false, + serializedName: 'properties.enabled', + defaultValue: true, + type: { + name: 'Boolean' + } + }, + condition: { + required: true, + serializedName: 'properties.condition', + type: { + name: 'Composite', + className: 'ActivityLogAlertAllOfCondition' + } + }, + actions: { + required: true, + serializedName: 'properties.actions', + type: { + name: 'Composite', + className: 'ActivityLogAlertActionList' + } + }, + description: { + required: false, + serializedName: 'properties.description', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ActivityLogAlertResource; diff --git a/lib/services/monitor/lib/models/alertRuleResource.js b/lib/services/monitor/lib/models/alertRuleResource.js new file mode 100644 index 0000000000..40978cb847 --- /dev/null +++ b/lib/services/monitor/lib/models/alertRuleResource.js @@ -0,0 +1,175 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The alert rule resource. + * + * @extends models['Resource'] + */ +class AlertRuleResource extends models['Resource'] { + /** + * Create a AlertRuleResource. + * @member {string} alertRuleResourceName the name of the alert rule. + * @member {string} [description] the description of the alert rule that will + * be included in the alert email. + * @member {boolean} isEnabled the flag that indicates whether the alert rule + * is enabled. + * @member {object} condition the condition that results in the alert rule + * being activated. + * @member {object} [condition.dataSource] the resource from which the rule + * collects its data. For this type dataSource will always be of type + * RuleMetricDataSource. + * @member {string} [condition.dataSource.resourceUri] the resource + * identifier of the resource the rule monitors. **NOTE**: this property + * cannot be updated for an existing rule. + * @member {string} [condition.dataSource.odatatype] Polymorphic + * Discriminator + * @member {string} [condition.odatatype] Polymorphic Discriminator + * @member {array} [actions] the array of actions that are performed when the + * alert rule becomes active, and when an alert condition is resolved. + * @member {date} [lastUpdatedTime] Last time the rule was updated in ISO8601 + * format. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of AlertRuleResource + * + * @returns {object} metadata of AlertRuleResource + * + */ + mapper() { + return { + required: false, + serializedName: 'AlertRuleResource', + type: { + name: 'Composite', + className: 'AlertRuleResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + alertRuleResourceName: { + required: true, + serializedName: 'properties.name', + type: { + name: 'String' + } + }, + description: { + required: false, + serializedName: 'properties.description', + type: { + name: 'String' + } + }, + isEnabled: { + required: true, + serializedName: 'properties.isEnabled', + type: { + name: 'Boolean' + } + }, + condition: { + required: true, + serializedName: 'properties.condition', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleCondition', + className: 'RuleCondition' + } + }, + actions: { + required: false, + serializedName: 'properties.actions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'RuleActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleAction', + className: 'RuleAction' + } + } + } + }, + lastUpdatedTime: { + required: false, + readOnly: true, + serializedName: 'properties.lastUpdatedTime', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = AlertRuleResource; diff --git a/lib/services/monitor/lib/models/alertRuleResourceCollection.js b/lib/services/monitor/lib/models/alertRuleResourceCollection.js new file mode 100644 index 0000000000..40dd02b71e --- /dev/null +++ b/lib/services/monitor/lib/models/alertRuleResourceCollection.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Represents a collection of alert rule resources. + */ +class AlertRuleResourceCollection extends Array { + /** + * Create a AlertRuleResourceCollection. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of AlertRuleResourceCollection + * + * @returns {object} metadata of AlertRuleResourceCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'AlertRuleResourceCollection', + type: { + name: 'Composite', + className: 'AlertRuleResourceCollection', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AlertRuleResourceElementType', + type: { + name: 'Composite', + className: 'AlertRuleResource' + } + } + } + } + } + } + }; + } +} + +module.exports = AlertRuleResourceCollection; diff --git a/lib/services/monitor/lib/models/alertRuleResourcePatch.js b/lib/services/monitor/lib/models/alertRuleResourcePatch.js new file mode 100644 index 0000000000..3094d95d8b --- /dev/null +++ b/lib/services/monitor/lib/models/alertRuleResourcePatch.js @@ -0,0 +1,143 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The alert rule object for patch operations. + * + */ +class AlertRuleResourcePatch { + /** + * Create a AlertRuleResourcePatch. + * @member {object} [tags] Resource tags + * @member {string} name the name of the alert rule. + * @member {string} [description] the description of the alert rule that will + * be included in the alert email. + * @member {boolean} isEnabled the flag that indicates whether the alert rule + * is enabled. + * @member {object} condition the condition that results in the alert rule + * being activated. + * @member {object} [condition.dataSource] the resource from which the rule + * collects its data. For this type dataSource will always be of type + * RuleMetricDataSource. + * @member {string} [condition.dataSource.resourceUri] the resource + * identifier of the resource the rule monitors. **NOTE**: this property + * cannot be updated for an existing rule. + * @member {string} [condition.dataSource.odatatype] Polymorphic + * Discriminator + * @member {string} [condition.odatatype] Polymorphic Discriminator + * @member {array} [actions] the array of actions that are performed when the + * alert rule becomes active, and when an alert condition is resolved. + * @member {date} [lastUpdatedTime] Last time the rule was updated in ISO8601 + * format. + */ + constructor() { + } + + /** + * Defines the metadata of AlertRuleResourcePatch + * + * @returns {object} metadata of AlertRuleResourcePatch + * + */ + mapper() { + return { + required: false, + serializedName: 'AlertRuleResourcePatch', + type: { + name: 'Composite', + className: 'AlertRuleResourcePatch', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + name: { + required: true, + serializedName: 'properties.name', + type: { + name: 'String' + } + }, + description: { + required: false, + serializedName: 'properties.description', + type: { + name: 'String' + } + }, + isEnabled: { + required: true, + serializedName: 'properties.isEnabled', + type: { + name: 'Boolean' + } + }, + condition: { + required: true, + serializedName: 'properties.condition', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleCondition', + className: 'RuleCondition' + } + }, + actions: { + required: false, + serializedName: 'properties.actions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'RuleActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleAction', + className: 'RuleAction' + } + } + } + }, + lastUpdatedTime: { + required: false, + readOnly: true, + serializedName: 'properties.lastUpdatedTime', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = AlertRuleResourcePatch; diff --git a/lib/services/monitor/lib/models/automationRunbookReceiver.js b/lib/services/monitor/lib/models/automationRunbookReceiver.js new file mode 100644 index 0000000000..b54ae4d250 --- /dev/null +++ b/lib/services/monitor/lib/models/automationRunbookReceiver.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The Azure Automation Runbook notification receiver. + * + */ +class AutomationRunbookReceiver { + /** + * Create a AutomationRunbookReceiver. + * @member {string} automationAccountId The Azure automation account Id which + * holds this runbook and authenticate to Azure resource. + * @member {string} runbookName The name for this runbook. + * @member {string} webhookResourceId The resource id for webhook linked to + * this runbook. + * @member {boolean} isGlobalRunbook Indicates whether this instance is + * global runbook. + * @member {string} [name] Indicates name of the webhook. + * @member {string} [serviceUri] The URI where webhooks should be sent. + */ + constructor() { + } + + /** + * Defines the metadata of AutomationRunbookReceiver + * + * @returns {object} metadata of AutomationRunbookReceiver + * + */ + mapper() { + return { + required: false, + serializedName: 'AutomationRunbookReceiver', + type: { + name: 'Composite', + className: 'AutomationRunbookReceiver', + modelProperties: { + automationAccountId: { + required: true, + serializedName: 'automationAccountId', + type: { + name: 'String' + } + }, + runbookName: { + required: true, + serializedName: 'runbookName', + type: { + name: 'String' + } + }, + webhookResourceId: { + required: true, + serializedName: 'webhookResourceId', + type: { + name: 'String' + } + }, + isGlobalRunbook: { + required: true, + serializedName: 'isGlobalRunbook', + type: { + name: 'Boolean' + } + }, + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + serviceUri: { + required: false, + serializedName: 'serviceUri', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AutomationRunbookReceiver; diff --git a/lib/services/monitor/lib/models/autoscaleNotification.js b/lib/services/monitor/lib/models/autoscaleNotification.js new file mode 100644 index 0000000000..d56fcbc701 --- /dev/null +++ b/lib/services/monitor/lib/models/autoscaleNotification.js @@ -0,0 +1,86 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Autoscale notification. + * + */ +class AutoscaleNotification { + /** + * Create a AutoscaleNotification. + * @member {object} [email] the email notification. + * @member {boolean} [email.sendToSubscriptionAdministrator] a value + * indicating whether to send email to subscription administrator. + * @member {boolean} [email.sendToSubscriptionCoAdministrators] a value + * indicating whether to send email to subscription co-administrators. + * @member {array} [email.customEmails] the custom e-mails list. This value + * can be null or empty, in which case this attribute will be ignored. + * @member {array} [webhooks] the collection of webhook notifications. + */ + constructor() { + } + + /** + * Defines the metadata of AutoscaleNotification + * + * @returns {object} metadata of AutoscaleNotification + * + */ + mapper() { + return { + required: false, + serializedName: 'AutoscaleNotification', + type: { + name: 'Composite', + className: 'AutoscaleNotification', + modelProperties: { + operation: { + required: true, + isConstant: true, + serializedName: 'operation', + defaultValue: 'Scale', + type: { + name: 'String' + } + }, + email: { + required: false, + serializedName: 'email', + type: { + name: 'Composite', + className: 'EmailNotification' + } + }, + webhooks: { + required: false, + serializedName: 'webhooks', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'WebhookNotificationElementType', + type: { + name: 'Composite', + className: 'WebhookNotification' + } + } + } + } + } + } + }; + } +} + +module.exports = AutoscaleNotification; diff --git a/lib/services/monitor/lib/models/autoscaleProfile.js b/lib/services/monitor/lib/models/autoscaleProfile.js new file mode 100644 index 0000000000..a26c7a898f --- /dev/null +++ b/lib/services/monitor/lib/models/autoscaleProfile.js @@ -0,0 +1,204 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Autoscale profile. + * + */ +class AutoscaleProfile { + /** + * Create a AutoscaleProfile. + * @member {string} name the name of the profile. + * @member {object} capacity the number of instances that can be used during + * this profile. + * @member {string} [capacity.minimum] the minimum number of instances for + * the resource. + * @member {string} [capacity.maximum] the maximum number of instances for + * the resource. The actual maximum number of instances is limited by the + * cores that are available in the subscription. + * @member {string} [capacity.default] the number of instances that will be + * set if metrics are not available for evaluation. The default is only used + * if the current instance count is lower than the default. + * @member {array} rules the collection of rules that provide the triggers + * and parameters for the scaling action. A maximum of 10 rules can be + * specified. + * @member {object} [fixedDate] the specific date-time for the profile. This + * element is not used if the Recurrence element is used. + * @member {string} [fixedDate.timeZone] the timezone of the start and end + * times for the profile. Some examples of valid timezones are: Dateline + * Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, + * Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain + * Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, + * Central America Standard Time, Central Standard Time, Central Standard + * Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, + * Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, + * Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard + * Time, SA Western Standard Time, Pacific SA Standard Time, Newfoundland + * Standard Time, E. South America Standard Time, Argentina Standard Time, SA + * Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, + * Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard + * Time, Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard + * Time, Greenwich Standard Time, W. Europe Standard Time, Central Europe + * Standard Time, Romance Standard Time, Central European Standard Time, W. + * Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, + * GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria + * Standard Time, E. Europe Standard Time, South Africa Standard Time, FLE + * Standard Time, Turkey Standard Time, Israel Standard Time, Kaliningrad + * Standard Time, Libya Standard Time, Arabic Standard Time, Arab Standard + * Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard + * Time, Iran Standard Time, Arabian Standard Time, Azerbaijan Standard Time, + * Russia Time Zone 3, Mauritius Standard Time, Georgian Standard Time, + * Caucasus Standard Time, Afghanistan Standard Time, West Asia Standard + * Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard + * Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard + * Time, Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar + * Standard Time, SE Asia Standard Time, North Asia Standard Time, China + * Standard Time, North Asia East Standard Time, Singapore Standard Time, W. + * Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, + * Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. + * Australia Standard Time, AUS Central Standard Time, E. Australia Standard + * Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania + * Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia + * Time Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New + * Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard + * Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time + * @member {date} [fixedDate.start] the start time for the profile in ISO + * 8601 format. + * @member {date} [fixedDate.end] the end time for the profile in ISO 8601 + * format. + * @member {object} [recurrence] the repeating times at which this profile + * begins. This element is not used if the FixedDate element is used. + * @member {string} [recurrence.frequency] the recurrence frequency. How + * often the schedule profile should take effect. This value must be Week, + * meaning each week will have the same set of profiles. Possible values + * include: 'None', 'Second', 'Minute', 'Hour', 'Day', 'Week', 'Month', + * 'Year' + * @member {object} [recurrence.schedule] the scheduling constraints for when + * the profile begins. + * @member {string} [recurrence.schedule.timeZone] the timezone for the hours + * of the profile. Some examples of valid timezones are: Dateline Standard + * Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific + * Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, + * Mountain Standard Time (Mexico), Mountain Standard Time, Central America + * Standard Time, Central Standard Time, Central Standard Time (Mexico), + * Canada Central Standard Time, SA Pacific Standard Time, Eastern Standard + * Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard + * Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western + * Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. + * South America Standard Time, Argentina Standard Time, SA Eastern Standard + * Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard + * Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde + * Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich + * Standard Time, W. Europe Standard Time, Central Europe Standard Time, + * Romance Standard Time, Central European Standard Time, W. Central Africa + * Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard + * Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, + * E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, + * Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, + * Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus + * Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + * Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia + * Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus + * Standard Time, Afghanistan Standard Time, West Asia Standard Time, + * Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + * Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, + * Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard + * Time, SE Asia Standard Time, North Asia Standard Time, China Standard + * Time, North Asia East Standard Time, Singapore Standard Time, W. Australia + * Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo + * Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia + * Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS + * Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, + * Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + * Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard + * Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard + * Time, Samoa Standard Time, Line Islands Standard Time + * @member {array} [recurrence.schedule.days] the collection of days that the + * profile takes effect on. Possible values are Sunday through Saturday. + * @member {array} [recurrence.schedule.hours] A collection of hours that the + * profile takes effect on. Values supported are 0 to 23 on the 24-hour clock + * (AM/PM times are not supported). + * @member {array} [recurrence.schedule.minutes] A collection of minutes at + * which the profile takes effect at. + */ + constructor() { + } + + /** + * Defines the metadata of AutoscaleProfile + * + * @returns {object} metadata of AutoscaleProfile + * + */ + mapper() { + return { + required: false, + serializedName: 'AutoscaleProfile', + type: { + name: 'Composite', + className: 'AutoscaleProfile', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + capacity: { + required: true, + serializedName: 'capacity', + type: { + name: 'Composite', + className: 'ScaleCapacity' + } + }, + rules: { + required: true, + serializedName: 'rules', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ScaleRuleElementType', + type: { + name: 'Composite', + className: 'ScaleRule' + } + } + } + }, + fixedDate: { + required: false, + serializedName: 'fixedDate', + type: { + name: 'Composite', + className: 'TimeWindow' + } + }, + recurrence: { + required: false, + serializedName: 'recurrence', + type: { + name: 'Composite', + className: 'Recurrence' + } + } + } + } + }; + } +} + +module.exports = AutoscaleProfile; diff --git a/lib/services/monitor/lib/models/autoscaleSettingResource.js b/lib/services/monitor/lib/models/autoscaleSettingResource.js new file mode 100644 index 0000000000..d5363c2f72 --- /dev/null +++ b/lib/services/monitor/lib/models/autoscaleSettingResource.js @@ -0,0 +1,159 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The autoscale setting resource. + * + * @extends models['Resource'] + */ +class AutoscaleSettingResource extends models['Resource'] { + /** + * Create a AutoscaleSettingResource. + * @member {array} profiles the collection of automatic scaling profiles that + * specify different scaling parameters for different time periods. A maximum + * of 20 profiles can be specified. + * @member {array} [notifications] the collection of notifications. + * @member {boolean} [enabled] the enabled flag. Specifies whether automatic + * scaling is enabled for the resource. The default value is 'true'. Default + * value: true . + * @member {string} [autoscaleSettingResourceName] the name of the autoscale + * setting. + * @member {string} [targetResourceUri] the resource identifier of the + * resource that the autoscale setting should be added to. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of AutoscaleSettingResource + * + * @returns {object} metadata of AutoscaleSettingResource + * + */ + mapper() { + return { + required: false, + serializedName: 'AutoscaleSettingResource', + type: { + name: 'Composite', + className: 'AutoscaleSettingResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + profiles: { + required: true, + serializedName: 'properties.profiles', + constraints: { + MaxItems: 20 + }, + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AutoscaleProfileElementType', + type: { + name: 'Composite', + className: 'AutoscaleProfile' + } + } + } + }, + notifications: { + required: false, + serializedName: 'properties.notifications', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AutoscaleNotificationElementType', + type: { + name: 'Composite', + className: 'AutoscaleNotification' + } + } + } + }, + enabled: { + required: false, + serializedName: 'properties.enabled', + defaultValue: true, + type: { + name: 'Boolean' + } + }, + autoscaleSettingResourceName: { + required: false, + serializedName: 'properties.name', + type: { + name: 'String' + } + }, + targetResourceUri: { + required: false, + serializedName: 'properties.targetResourceUri', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AutoscaleSettingResource; diff --git a/lib/services/monitor/lib/models/autoscaleSettingResourceCollection.js b/lib/services/monitor/lib/models/autoscaleSettingResourceCollection.js new file mode 100644 index 0000000000..0f0ca6ac53 --- /dev/null +++ b/lib/services/monitor/lib/models/autoscaleSettingResourceCollection.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Represents a collection of autoscale setting resources. + */ +class AutoscaleSettingResourceCollection extends Array { + /** + * Create a AutoscaleSettingResourceCollection. + * @member {string} [nextLink] URL to get the next set of results. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of AutoscaleSettingResourceCollection + * + * @returns {object} metadata of AutoscaleSettingResourceCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'AutoscaleSettingResourceCollection', + type: { + name: 'Composite', + className: 'AutoscaleSettingResourceCollection', + modelProperties: { + value: { + required: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AutoscaleSettingResourceElementType', + type: { + name: 'Composite', + className: 'AutoscaleSettingResource' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AutoscaleSettingResourceCollection; diff --git a/lib/services/monitor/lib/models/autoscaleSettingResourcePatch.js b/lib/services/monitor/lib/models/autoscaleSettingResourcePatch.js new file mode 100644 index 0000000000..fe1ac2f14a --- /dev/null +++ b/lib/services/monitor/lib/models/autoscaleSettingResourcePatch.js @@ -0,0 +1,126 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The autoscale setting object for patch operations. + * + */ +class AutoscaleSettingResourcePatch { + /** + * Create a AutoscaleSettingResourcePatch. + * @member {object} [tags] Resource tags + * @member {array} profiles the collection of automatic scaling profiles that + * specify different scaling parameters for different time periods. A maximum + * of 20 profiles can be specified. + * @member {array} [notifications] the collection of notifications. + * @member {boolean} [enabled] the enabled flag. Specifies whether automatic + * scaling is enabled for the resource. The default value is 'true'. Default + * value: true . + * @member {string} [name] the name of the autoscale setting. + * @member {string} [targetResourceUri] the resource identifier of the + * resource that the autoscale setting should be added to. + */ + constructor() { + } + + /** + * Defines the metadata of AutoscaleSettingResourcePatch + * + * @returns {object} metadata of AutoscaleSettingResourcePatch + * + */ + mapper() { + return { + required: false, + serializedName: 'AutoscaleSettingResourcePatch', + type: { + name: 'Composite', + className: 'AutoscaleSettingResourcePatch', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + profiles: { + required: true, + serializedName: 'properties.profiles', + constraints: { + MaxItems: 20 + }, + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AutoscaleProfileElementType', + type: { + name: 'Composite', + className: 'AutoscaleProfile' + } + } + } + }, + notifications: { + required: false, + serializedName: 'properties.notifications', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AutoscaleNotificationElementType', + type: { + name: 'Composite', + className: 'AutoscaleNotification' + } + } + } + }, + enabled: { + required: false, + serializedName: 'properties.enabled', + defaultValue: true, + type: { + name: 'Boolean' + } + }, + name: { + required: false, + serializedName: 'properties.name', + type: { + name: 'String' + } + }, + targetResourceUri: { + required: false, + serializedName: 'properties.targetResourceUri', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AutoscaleSettingResourcePatch; diff --git a/lib/services/monitor/lib/models/azureAppPushReceiver.js b/lib/services/monitor/lib/models/azureAppPushReceiver.js new file mode 100644 index 0000000000..0360bb90f0 --- /dev/null +++ b/lib/services/monitor/lib/models/azureAppPushReceiver.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The Azure mobile App push notification receiver. + * + */ +class AzureAppPushReceiver { + /** + * Create a AzureAppPushReceiver. + * @member {string} name The name of the Azure mobile app push receiver. + * Names must be unique across all receivers within an action group. + * @member {string} emailAddress The email address registered for the Azure + * mobile app. + */ + constructor() { + } + + /** + * Defines the metadata of AzureAppPushReceiver + * + * @returns {object} metadata of AzureAppPushReceiver + * + */ + mapper() { + return { + required: false, + serializedName: 'AzureAppPushReceiver', + type: { + name: 'Composite', + className: 'AzureAppPushReceiver', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + emailAddress: { + required: true, + serializedName: 'emailAddress', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AzureAppPushReceiver; diff --git a/lib/services/monitor/lib/models/baseline.js b/lib/services/monitor/lib/models/baseline.js new file mode 100644 index 0000000000..ffd9d6f3eb --- /dev/null +++ b/lib/services/monitor/lib/models/baseline.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The baseline values for a single sensitivity value. + * + */ +class Baseline { + /** + * Create a Baseline. + * @member {string} sensitivity the sensitivity of the baseline. Possible + * values include: 'Low', 'Medium', 'High' + * @member {array} lowThresholds The low thresholds of the baseline. + * @member {array} highThresholds The high thresholds of the baseline. + */ + constructor() { + } + + /** + * Defines the metadata of Baseline + * + * @returns {object} metadata of Baseline + * + */ + mapper() { + return { + required: false, + serializedName: 'Baseline', + type: { + name: 'Composite', + className: 'Baseline', + modelProperties: { + sensitivity: { + required: true, + serializedName: 'sensitivity', + type: { + name: 'Enum', + allowedValues: [ 'Low', 'Medium', 'High' ] + } + }, + lowThresholds: { + required: true, + serializedName: 'lowThresholds', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'NumberElementType', + type: { + name: 'Number' + } + } + } + }, + highThresholds: { + required: true, + serializedName: 'highThresholds', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'NumberElementType', + type: { + name: 'Number' + } + } + } + } + } + } + }; + } +} + +module.exports = Baseline; diff --git a/lib/services/monitor/lib/models/baselineMetadataValue.js b/lib/services/monitor/lib/models/baselineMetadataValue.js new file mode 100644 index 0000000000..f0353fa4b3 --- /dev/null +++ b/lib/services/monitor/lib/models/baselineMetadataValue.js @@ -0,0 +1,65 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Represents a baseline metadata value. + * + */ +class BaselineMetadataValue { + /** + * Create a BaselineMetadataValue. + * @member {object} [name] the name of the metadata. + * @member {string} [name.value] the invariant value. + * @member {string} [name.localizedValue] the locale specific value. + * @member {string} [value] the value of the metadata. + */ + constructor() { + } + + /** + * Defines the metadata of BaselineMetadataValue + * + * @returns {object} metadata of BaselineMetadataValue + * + */ + mapper() { + return { + required: false, + serializedName: 'BaselineMetadataValue', + type: { + name: 'Composite', + className: 'BaselineMetadataValue', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'Composite', + className: 'LocalizableString' + } + }, + value: { + required: false, + serializedName: 'value', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = BaselineMetadataValue; diff --git a/lib/services/monitor/lib/models/baselineResponse.js b/lib/services/monitor/lib/models/baselineResponse.js new file mode 100644 index 0000000000..db9e23dd39 --- /dev/null +++ b/lib/services/monitor/lib/models/baselineResponse.js @@ -0,0 +1,154 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The response to a baseline query. + * + */ +class BaselineResponse { + /** + * Create a BaselineResponse. + * @member {string} [id] the metric baseline Id. + * @member {string} [type] the resource type of the baseline resource. + * @member {object} [name] the name and the display name of the metric, i.e. + * it is localizable string. + * @member {string} [name.value] the invariant value. + * @member {string} [name.localizedValue] the locale specific value. + * @member {string} [timespan] The timespan for which the data was retrieved. + * Its value consists of two datatimes concatenated, separated by '/'. This + * may be adjusted in the future and returned back from what was originally + * requested. + * @member {moment.duration} [interval] The interval (window size) for which + * the metric data was returned in. This may be adjusted in the future and + * returned back from what was originally requested. This is not present if + * a metadata request was made. + * @member {string} [aggregation] The aggregation type of the metric. + * @member {array} [timestamps] the array of timestamps of the baselines. + * @member {array} [baseline] the baseline values for each sensitivity. + * @member {array} [metadata] the baseline metadata values. + */ + constructor() { + } + + /** + * Defines the metadata of BaselineResponse + * + * @returns {object} metadata of BaselineResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'BaselineResponse', + type: { + name: 'Composite', + className: 'BaselineResponse', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'Composite', + className: 'LocalizableString' + } + }, + timespan: { + required: false, + serializedName: 'properties.timespan', + type: { + name: 'String' + } + }, + interval: { + required: false, + serializedName: 'properties.interval', + type: { + name: 'TimeSpan' + } + }, + aggregation: { + required: false, + serializedName: 'properties.aggregation', + type: { + name: 'String' + } + }, + timestamps: { + required: false, + serializedName: 'properties.timestamps', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DateElementType', + type: { + name: 'DateTime' + } + } + } + }, + baseline: { + required: false, + serializedName: 'properties.baseline', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BaselineElementType', + type: { + name: 'Composite', + className: 'Baseline' + } + } + } + }, + metadata: { + required: false, + serializedName: 'properties.metadata', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BaselineMetadataValueElementType', + type: { + name: 'Composite', + className: 'BaselineMetadataValue' + } + } + } + } + } + } + }; + } +} + +module.exports = BaselineResponse; diff --git a/lib/services/monitor/lib/models/calculateBaselineResponse.js b/lib/services/monitor/lib/models/calculateBaselineResponse.js new file mode 100644 index 0000000000..3b8328e966 --- /dev/null +++ b/lib/services/monitor/lib/models/calculateBaselineResponse.js @@ -0,0 +1,85 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The response to a calcualte baseline call. + * + */ +class CalculateBaselineResponse { + /** + * Create a CalculateBaselineResponse. + * @member {string} type the resource type of the baseline resource. + * @member {array} [timestamps] the array of timestamps of the baselines. + * @member {array} baseline the baseline values for each sensitivity. + */ + constructor() { + } + + /** + * Defines the metadata of CalculateBaselineResponse + * + * @returns {object} metadata of CalculateBaselineResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'CalculateBaselineResponse', + type: { + name: 'Composite', + className: 'CalculateBaselineResponse', + modelProperties: { + type: { + required: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + timestamps: { + required: false, + serializedName: 'timestamps', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DateElementType', + type: { + name: 'DateTime' + } + } + } + }, + baseline: { + required: true, + serializedName: 'baseline', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'BaselineElementType', + type: { + name: 'Composite', + className: 'Baseline' + } + } + } + } + } + } + }; + } +} + +module.exports = CalculateBaselineResponse; diff --git a/lib/services/monitor/lib/models/diagnosticSettingsCategoryResource.js b/lib/services/monitor/lib/models/diagnosticSettingsCategoryResource.js new file mode 100644 index 0000000000..00e2c23663 --- /dev/null +++ b/lib/services/monitor/lib/models/diagnosticSettingsCategoryResource.js @@ -0,0 +1,82 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The diagnostic settings category resource. + * + * @extends models['ProxyOnlyResource'] + */ +class DiagnosticSettingsCategoryResource extends models['ProxyOnlyResource'] { + /** + * Create a DiagnosticSettingsCategoryResource. + * @member {string} [categoryType] The type of the diagnostic settings + * category. Possible values include: 'Metrics', 'Logs' + */ + constructor() { + super(); + } + + /** + * Defines the metadata of DiagnosticSettingsCategoryResource + * + * @returns {object} metadata of DiagnosticSettingsCategoryResource + * + */ + mapper() { + return { + required: false, + serializedName: 'DiagnosticSettingsCategoryResource', + type: { + name: 'Composite', + className: 'DiagnosticSettingsCategoryResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + categoryType: { + required: false, + serializedName: 'properties.categoryType', + type: { + name: 'Enum', + allowedValues: [ 'Metrics', 'Logs' ] + } + } + } + } + }; + } +} + +module.exports = DiagnosticSettingsCategoryResource; diff --git a/lib/services/monitor/lib/models/diagnosticSettingsCategoryResourceCollection.js b/lib/services/monitor/lib/models/diagnosticSettingsCategoryResourceCollection.js new file mode 100644 index 0000000000..00199aec14 --- /dev/null +++ b/lib/services/monitor/lib/models/diagnosticSettingsCategoryResourceCollection.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Represents a collection of diagnostic setting category resources. + * + */ +class DiagnosticSettingsCategoryResourceCollection { + /** + * Create a DiagnosticSettingsCategoryResourceCollection. + * @member {array} [value] The collection of diagnostic settings category + * resources. + */ + constructor() { + } + + /** + * Defines the metadata of DiagnosticSettingsCategoryResourceCollection + * + * @returns {object} metadata of DiagnosticSettingsCategoryResourceCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'DiagnosticSettingsCategoryResourceCollection', + type: { + name: 'Composite', + className: 'DiagnosticSettingsCategoryResourceCollection', + modelProperties: { + value: { + required: false, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DiagnosticSettingsCategoryResourceElementType', + type: { + name: 'Composite', + className: 'DiagnosticSettingsCategoryResource' + } + } + } + } + } + } + }; + } +} + +module.exports = DiagnosticSettingsCategoryResourceCollection; diff --git a/lib/services/monitor/lib/models/diagnosticSettingsResource.js b/lib/services/monitor/lib/models/diagnosticSettingsResource.js new file mode 100644 index 0000000000..b255747c24 --- /dev/null +++ b/lib/services/monitor/lib/models/diagnosticSettingsResource.js @@ -0,0 +1,142 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The diagnostic setting resource. + * + * @extends models['ProxyOnlyResource'] + */ +class DiagnosticSettingsResource extends models['ProxyOnlyResource'] { + /** + * Create a DiagnosticSettingsResource. + * @member {string} [storageAccountId] The resource ID of the storage account + * to which you would like to send Diagnostic Logs. + * @member {string} [eventHubAuthorizationRuleId] The resource Id for the + * event hub authorization rule. + * @member {string} [eventHubName] The name of the event hub. If none is + * specified, the default event hub will be selected. + * @member {array} [metrics] the list of metric settings. + * @member {array} [logs] the list of logs settings. + * @member {string} [workspaceId] The workspace ID (resource ID of a Log + * Analytics workspace) for a Log Analytics workspace to which you would like + * to send Diagnostic Logs. Example: + * /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + */ + constructor() { + super(); + } + + /** + * Defines the metadata of DiagnosticSettingsResource + * + * @returns {object} metadata of DiagnosticSettingsResource + * + */ + mapper() { + return { + required: false, + serializedName: 'DiagnosticSettingsResource', + type: { + name: 'Composite', + className: 'DiagnosticSettingsResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + storageAccountId: { + required: false, + serializedName: 'properties.storageAccountId', + type: { + name: 'String' + } + }, + eventHubAuthorizationRuleId: { + required: false, + serializedName: 'properties.eventHubAuthorizationRuleId', + type: { + name: 'String' + } + }, + eventHubName: { + required: false, + serializedName: 'properties.eventHubName', + type: { + name: 'String' + } + }, + metrics: { + required: false, + serializedName: 'properties.metrics', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'MetricSettingsElementType', + type: { + name: 'Composite', + className: 'MetricSettings' + } + } + } + }, + logs: { + required: false, + serializedName: 'properties.logs', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'LogSettingsElementType', + type: { + name: 'Composite', + className: 'LogSettings' + } + } + } + }, + workspaceId: { + required: false, + serializedName: 'properties.workspaceId', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = DiagnosticSettingsResource; diff --git a/lib/services/monitor/lib/models/diagnosticSettingsResourceCollection.js b/lib/services/monitor/lib/models/diagnosticSettingsResourceCollection.js new file mode 100644 index 0000000000..89650e1336 --- /dev/null +++ b/lib/services/monitor/lib/models/diagnosticSettingsResourceCollection.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Represents a collection of alert rule resources. + * + */ +class DiagnosticSettingsResourceCollection { + /** + * Create a DiagnosticSettingsResourceCollection. + * @member {array} [value] The collection of diagnostic settings resources;. + */ + constructor() { + } + + /** + * Defines the metadata of DiagnosticSettingsResourceCollection + * + * @returns {object} metadata of DiagnosticSettingsResourceCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'DiagnosticSettingsResourceCollection', + type: { + name: 'Composite', + className: 'DiagnosticSettingsResourceCollection', + modelProperties: { + value: { + required: false, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DiagnosticSettingsResourceElementType', + type: { + name: 'Composite', + className: 'DiagnosticSettingsResource' + } + } + } + } + } + } + }; + } +} + +module.exports = DiagnosticSettingsResourceCollection; diff --git a/lib/services/monitor/lib/models/emailNotification.js b/lib/services/monitor/lib/models/emailNotification.js new file mode 100644 index 0000000000..c11f1b2d24 --- /dev/null +++ b/lib/services/monitor/lib/models/emailNotification.js @@ -0,0 +1,78 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Email notification of an autoscale event. + * + */ +class EmailNotification { + /** + * Create a EmailNotification. + * @member {boolean} [sendToSubscriptionAdministrator] a value indicating + * whether to send email to subscription administrator. + * @member {boolean} [sendToSubscriptionCoAdministrators] a value indicating + * whether to send email to subscription co-administrators. + * @member {array} [customEmails] the custom e-mails list. This value can be + * null or empty, in which case this attribute will be ignored. + */ + constructor() { + } + + /** + * Defines the metadata of EmailNotification + * + * @returns {object} metadata of EmailNotification + * + */ + mapper() { + return { + required: false, + serializedName: 'EmailNotification', + type: { + name: 'Composite', + className: 'EmailNotification', + modelProperties: { + sendToSubscriptionAdministrator: { + required: false, + serializedName: 'sendToSubscriptionAdministrator', + type: { + name: 'Boolean' + } + }, + sendToSubscriptionCoAdministrators: { + required: false, + serializedName: 'sendToSubscriptionCoAdministrators', + type: { + name: 'Boolean' + } + }, + customEmails: { + required: false, + serializedName: 'customEmails', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = EmailNotification; diff --git a/lib/services/monitor/lib/models/emailReceiver.js b/lib/services/monitor/lib/models/emailReceiver.js new file mode 100644 index 0000000000..508eac1ad4 --- /dev/null +++ b/lib/services/monitor/lib/models/emailReceiver.js @@ -0,0 +1,72 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An email receiver. + * + */ +class EmailReceiver { + /** + * Create a EmailReceiver. + * @member {string} name The name of the email receiver. Names must be unique + * across all receivers within an action group. + * @member {string} emailAddress The email address of this receiver. + * @member {string} [status] The receiver status of the e-mail. Possible + * values include: 'NotSpecified', 'Enabled', 'Disabled' + */ + constructor() { + } + + /** + * Defines the metadata of EmailReceiver + * + * @returns {object} metadata of EmailReceiver + * + */ + mapper() { + return { + required: false, + serializedName: 'EmailReceiver', + type: { + name: 'Composite', + className: 'EmailReceiver', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + emailAddress: { + required: true, + serializedName: 'emailAddress', + type: { + name: 'String' + } + }, + status: { + required: false, + readOnly: true, + serializedName: 'status', + type: { + name: 'Enum', + allowedValues: [ 'NotSpecified', 'Enabled', 'Disabled' ] + } + } + } + } + }; + } +} + +module.exports = EmailReceiver; diff --git a/lib/services/monitor/lib/models/enableRequest.js b/lib/services/monitor/lib/models/enableRequest.js new file mode 100644 index 0000000000..886d80bc33 --- /dev/null +++ b/lib/services/monitor/lib/models/enableRequest.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Describes a receiver that should be resubscribed. + * + */ +class EnableRequest { + /** + * Create a EnableRequest. + * @member {string} receiverName The name of the receiver to resubscribe. + */ + constructor() { + } + + /** + * Defines the metadata of EnableRequest + * + * @returns {object} metadata of EnableRequest + * + */ + mapper() { + return { + required: false, + serializedName: 'EnableRequest', + type: { + name: 'Composite', + className: 'EnableRequest', + modelProperties: { + receiverName: { + required: true, + serializedName: 'receiverName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = EnableRequest; diff --git a/lib/services/monitor/lib/models/eventData.js b/lib/services/monitor/lib/models/eventData.js index add52e712f..4e8b1c3046 100644 --- a/lib/services/monitor/lib/models/eventData.js +++ b/lib/services/monitor/lib/models/eventData.js @@ -51,7 +51,7 @@ class EventData { * @member {string} [httpRequest.clientIpAddress] the client Ip Address * @member {string} [httpRequest.method] the Http request method. * @member {string} [httpRequest.uri] the Uri. - * @member {string} level the event level. Possible values include: + * @member {string} [level] the event level. Possible values include: * 'Critical', 'Error', 'Warning', 'Informational', 'Verbose' * @member {string} [resourceGroupName] the resource group name of the * impacted resource. @@ -88,14 +88,14 @@ class EventData { * Status Code: 504) * @member {string} [subStatus.value] the invariant value. * @member {string} [subStatus.localizedValue] the locale specific value. - * @member {date} eventTimestamp the timestamp of when the event was + * @member {date} [eventTimestamp] the timestamp of when the event was * generated by the Azure service processing the request corresponding the * event. It in ISO 8601 format. - * @member {date} submissionTimestamp the timestamp of when the event became - * available for querying via this API. It is in ISO 8601 format. This value - * should not be confused eventTimestamp. As there might be a delay between - * the occurrence time of the event, and the time that the event is submitted - * to the Azure logging infrastructure. + * @member {date} [submissionTimestamp] the timestamp of when the event + * became available for querying via this API. It is in ISO 8601 format. This + * value should not be confused eventTimestamp. As there might be a delay + * between the occurrence time of the event, and the time that the event is + * submitted to the Azure logging infrastructure. * @member {string} [subscriptionId] the Azure subscription Id usually a * GUID. * @member {string} [tenantId] the Azure tenant Id @@ -119,6 +119,7 @@ class EventData { modelProperties: { authorization: { required: false, + readOnly: true, serializedName: 'authorization', type: { name: 'Composite', @@ -127,6 +128,7 @@ class EventData { }, claims: { required: false, + readOnly: true, serializedName: 'claims', type: { name: 'Dictionary', @@ -141,6 +143,7 @@ class EventData { }, caller: { required: false, + readOnly: true, serializedName: 'caller', type: { name: 'String' @@ -148,6 +151,7 @@ class EventData { }, description: { required: false, + readOnly: true, serializedName: 'description', type: { name: 'String' @@ -155,6 +159,7 @@ class EventData { }, id: { required: false, + readOnly: true, serializedName: 'id', type: { name: 'String' @@ -162,6 +167,7 @@ class EventData { }, eventDataId: { required: false, + readOnly: true, serializedName: 'eventDataId', type: { name: 'String' @@ -169,6 +175,7 @@ class EventData { }, correlationId: { required: false, + readOnly: true, serializedName: 'correlationId', type: { name: 'String' @@ -176,6 +183,7 @@ class EventData { }, eventName: { required: false, + readOnly: true, serializedName: 'eventName', type: { name: 'Composite', @@ -184,6 +192,7 @@ class EventData { }, category: { required: false, + readOnly: true, serializedName: 'category', type: { name: 'Composite', @@ -192,6 +201,7 @@ class EventData { }, httpRequest: { required: false, + readOnly: true, serializedName: 'httpRequest', type: { name: 'Composite', @@ -199,7 +209,8 @@ class EventData { } }, level: { - required: true, + required: false, + readOnly: true, serializedName: 'level', type: { name: 'Enum', @@ -208,6 +219,7 @@ class EventData { }, resourceGroupName: { required: false, + readOnly: true, serializedName: 'resourceGroupName', type: { name: 'String' @@ -215,6 +227,7 @@ class EventData { }, resourceProviderName: { required: false, + readOnly: true, serializedName: 'resourceProviderName', type: { name: 'Composite', @@ -223,6 +236,7 @@ class EventData { }, resourceId: { required: false, + readOnly: true, serializedName: 'resourceId', type: { name: 'String' @@ -230,6 +244,7 @@ class EventData { }, resourceType: { required: false, + readOnly: true, serializedName: 'resourceType', type: { name: 'Composite', @@ -238,6 +253,7 @@ class EventData { }, operationId: { required: false, + readOnly: true, serializedName: 'operationId', type: { name: 'String' @@ -245,6 +261,7 @@ class EventData { }, operationName: { required: false, + readOnly: true, serializedName: 'operationName', type: { name: 'Composite', @@ -253,6 +270,7 @@ class EventData { }, properties: { required: false, + readOnly: true, serializedName: 'properties', type: { name: 'Dictionary', @@ -267,6 +285,7 @@ class EventData { }, status: { required: false, + readOnly: true, serializedName: 'status', type: { name: 'Composite', @@ -275,6 +294,7 @@ class EventData { }, subStatus: { required: false, + readOnly: true, serializedName: 'subStatus', type: { name: 'Composite', @@ -282,14 +302,16 @@ class EventData { } }, eventTimestamp: { - required: true, + required: false, + readOnly: true, serializedName: 'eventTimestamp', type: { name: 'DateTime' } }, submissionTimestamp: { - required: true, + required: false, + readOnly: true, serializedName: 'submissionTimestamp', type: { name: 'DateTime' @@ -297,6 +319,7 @@ class EventData { }, subscriptionId: { required: false, + readOnly: true, serializedName: 'subscriptionId', type: { name: 'String' @@ -304,6 +327,7 @@ class EventData { }, tenantId: { required: false, + readOnly: true, serializedName: 'tenantId', type: { name: 'String' diff --git a/lib/services/monitor/lib/models/incident.js b/lib/services/monitor/lib/models/incident.js new file mode 100644 index 0000000000..a591fb7efa --- /dev/null +++ b/lib/services/monitor/lib/models/incident.js @@ -0,0 +1,93 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An alert incident indicates the activation status of an alert rule. + * + */ +class Incident { + /** + * Create a Incident. + * @member {string} [name] Incident name. + * @member {string} [ruleName] Rule name that is associated with the + * incident. + * @member {boolean} [isActive] A boolean to indicate whether the incident is + * active or resolved. + * @member {date} [activatedTime] The time at which the incident was + * activated in ISO8601 format. + * @member {date} [resolvedTime] The time at which the incident was resolved + * in ISO8601 format. If null, it means the incident is still active. + */ + constructor() { + } + + /** + * Defines the metadata of Incident + * + * @returns {object} metadata of Incident + * + */ + mapper() { + return { + required: false, + serializedName: 'Incident', + type: { + name: 'Composite', + className: 'Incident', + modelProperties: { + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + ruleName: { + required: false, + readOnly: true, + serializedName: 'ruleName', + type: { + name: 'String' + } + }, + isActive: { + required: false, + readOnly: true, + serializedName: 'isActive', + type: { + name: 'Boolean' + } + }, + activatedTime: { + required: false, + readOnly: true, + serializedName: 'activatedTime', + type: { + name: 'DateTime' + } + }, + resolvedTime: { + required: false, + readOnly: true, + serializedName: 'resolvedTime', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = Incident; diff --git a/lib/services/monitor/lib/models/incidentListResult.js b/lib/services/monitor/lib/models/incidentListResult.js new file mode 100644 index 0000000000..968388fb50 --- /dev/null +++ b/lib/services/monitor/lib/models/incidentListResult.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The List incidents operation response. + */ +class IncidentListResult extends Array { + /** + * Create a IncidentListResult. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of IncidentListResult + * + * @returns {object} metadata of IncidentListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'IncidentListResult', + type: { + name: 'Composite', + className: 'IncidentListResult', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'IncidentElementType', + type: { + name: 'Composite', + className: 'Incident' + } + } + } + } + } + } + }; + } +} + +module.exports = IncidentListResult; diff --git a/lib/services/monitor/lib/models/index.d.ts b/lib/services/monitor/lib/models/index.d.ts index 74e06c0a3b..8a6ad1d65e 100644 --- a/lib/services/monitor/lib/models/index.d.ts +++ b/lib/services/monitor/lib/models/index.d.ts @@ -18,58 +18,1472 @@ export { CloudError } from 'ms-rest-azure'; /** * @class - * Initializes a new instance of the LocalizableString class. + * Initializes a new instance of the Resource class. + * @constructor + * An azure resource object + * + * @member {string} [id] Azure resource Id + * @member {string} [name] Azure resource name + * @member {string} [type] Azure resource type + * @member {string} location Resource location + * @member {object} [tags] Resource tags + */ +export interface Resource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; + location: string; + tags?: { [propertyName: string]: string }; +} + +/** + * @class + * Initializes a new instance of the ScaleCapacity class. + * @constructor + * The number of instances that can be used during this profile. + * + * @member {string} minimum the minimum number of instances for the resource. + * @member {string} maximum the maximum number of instances for the resource. + * The actual maximum number of instances is limited by the cores that are + * available in the subscription. + * @member {string} default the number of instances that will be set if metrics + * are not available for evaluation. The default is only used if the current + * instance count is lower than the default. + */ +export interface ScaleCapacity { + minimum: string; + maximum: string; + default: string; +} + +/** + * @class + * Initializes a new instance of the MetricTrigger class. + * @constructor + * The trigger that results in a scaling action. + * + * @member {string} metricName the name of the metric that defines what the + * rule monitors. + * @member {string} metricResourceUri the resource identifier of the resource + * the rule monitors. + * @member {moment.duration} timeGrain the granularity of metrics the rule + * monitors. Must be one of the predefined values returned from metric + * definitions for the metric. Must be between 12 hours and 1 minute. + * @member {string} statistic the metric statistic type. How the metrics from + * multiple instances are combined. Possible values include: 'Average', 'Min', + * 'Max', 'Sum' + * @member {moment.duration} timeWindow the range of time in which instance + * data is collected. This value must be greater than the delay in metric + * collection, which can vary from resource-to-resource. Must be between 12 + * hours and 5 minutes. + * @member {string} timeAggregation time aggregation type. How the data that is + * collected should be combined over time. The default value is Average. + * Possible values include: 'Average', 'Minimum', 'Maximum', 'Total', 'Count' + * @member {string} operator the operator that is used to compare the metric + * data and the threshold. Possible values include: 'Equals', 'NotEquals', + * 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' + * @member {number} threshold the threshold of the metric that triggers the + * scale action. + */ +export interface MetricTrigger { + metricName: string; + metricResourceUri: string; + timeGrain: moment.Duration; + statistic: string; + timeWindow: moment.Duration; + timeAggregation: string; + operator: string; + threshold: number; +} + +/** + * @class + * Initializes a new instance of the ScaleAction class. + * @constructor + * The parameters for the scaling action. + * + * @member {string} direction the scale direction. Whether the scaling action + * increases or decreases the number of instances. Possible values include: + * 'None', 'Increase', 'Decrease' + * @member {string} type the type of action that should occur when the scale + * rule fires. Possible values include: 'ChangeCount', 'PercentChangeCount', + * 'ExactCount' + * @member {string} [value] the number of instances that are involved in the + * scaling action. This value must be 1 or greater. The default value is 1. + * Default value: '1' . + * @member {moment.duration} cooldown the amount of time to wait since the last + * scaling action before this action occurs. It must be between 1 week and 1 + * minute in ISO 8601 format. + */ +export interface ScaleAction { + direction: string; + type: string; + value?: string; + cooldown: moment.Duration; +} + +/** + * @class + * Initializes a new instance of the ScaleRule class. + * @constructor + * A rule that provide the triggers and parameters for the scaling action. + * + * @member {object} metricTrigger the trigger that results in a scaling action. + * @member {string} [metricTrigger.metricName] the name of the metric that + * defines what the rule monitors. + * @member {string} [metricTrigger.metricResourceUri] the resource identifier + * of the resource the rule monitors. + * @member {moment.duration} [metricTrigger.timeGrain] the granularity of + * metrics the rule monitors. Must be one of the predefined values returned + * from metric definitions for the metric. Must be between 12 hours and 1 + * minute. + * @member {string} [metricTrigger.statistic] the metric statistic type. How + * the metrics from multiple instances are combined. Possible values include: + * 'Average', 'Min', 'Max', 'Sum' + * @member {moment.duration} [metricTrigger.timeWindow] the range of time in + * which instance data is collected. This value must be greater than the delay + * in metric collection, which can vary from resource-to-resource. Must be + * between 12 hours and 5 minutes. + * @member {string} [metricTrigger.timeAggregation] time aggregation type. How + * the data that is collected should be combined over time. The default value + * is Average. Possible values include: 'Average', 'Minimum', 'Maximum', + * 'Total', 'Count' + * @member {string} [metricTrigger.operator] the operator that is used to + * compare the metric data and the threshold. Possible values include: + * 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + * 'LessThanOrEqual' + * @member {number} [metricTrigger.threshold] the threshold of the metric that + * triggers the scale action. + * @member {object} scaleAction the parameters for the scaling action. + * @member {string} [scaleAction.direction] the scale direction. Whether the + * scaling action increases or decreases the number of instances. Possible + * values include: 'None', 'Increase', 'Decrease' + * @member {string} [scaleAction.type] the type of action that should occur + * when the scale rule fires. Possible values include: 'ChangeCount', + * 'PercentChangeCount', 'ExactCount' + * @member {string} [scaleAction.value] the number of instances that are + * involved in the scaling action. This value must be 1 or greater. The default + * value is 1. + * @member {moment.duration} [scaleAction.cooldown] the amount of time to wait + * since the last scaling action before this action occurs. It must be between + * 1 week and 1 minute in ISO 8601 format. + */ +export interface ScaleRule { + metricTrigger: MetricTrigger; + scaleAction: ScaleAction; +} + +/** + * @class + * Initializes a new instance of the TimeWindow class. + * @constructor + * A specific date-time for the profile. + * + * @member {string} [timeZone] the timezone of the start and end times for the + * profile. Some examples of valid timezones are: Dateline Standard Time, + * UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time + * (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain + * Standard Time (Mexico), Mountain Standard Time, Central America Standard + * Time, Central Standard Time, Central Standard Time (Mexico), Canada Central + * Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern + * Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic + * Standard Time, Central Brazilian Standard Time, SA Western Standard Time, + * Pacific SA Standard Time, Newfoundland Standard Time, E. South America + * Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland + * Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, + * Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, + * Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. + * Europe Standard Time, Central Europe Standard Time, Romance Standard Time, + * Central European Standard Time, W. Central Africa Standard Time, Namibia + * Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard + * Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, + * South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel + * Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic + * Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard + * Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, + * Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, + * Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, + * West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, + * India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central + * Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, + * Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, + * China Standard Time, North Asia East Standard Time, Singapore Standard Time, + * W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, + * Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. + * Australia Standard Time, AUS Central Standard Time, E. Australia Standard + * Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania + * Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time + * Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand + * Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga + * Standard Time, Samoa Standard Time, Line Islands Standard Time + * @member {date} start the start time for the profile in ISO 8601 format. + * @member {date} end the end time for the profile in ISO 8601 format. + */ +export interface TimeWindow { + timeZone?: string; + start: Date; + end: Date; +} + +/** + * @class + * Initializes a new instance of the RecurrentSchedule class. + * @constructor + * The scheduling constraints for when the profile begins. + * + * @member {string} timeZone the timezone for the hours of the profile. Some + * examples of valid timezones are: Dateline Standard Time, UTC-11, Hawaiian + * Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), + * Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time + * (Mexico), Mountain Standard Time, Central America Standard Time, Central + * Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, + * SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard Time, + * Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard Time, + * Central Brazilian Standard Time, SA Western Standard Time, Pacific SA + * Standard Time, Newfoundland Standard Time, E. South America Standard Time, + * Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, + * Montevideo Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard + * Time, Azores Standard Time, Cape Verde Standard Time, Morocco Standard Time, + * UTC, GMT Standard Time, Greenwich Standard Time, W. Europe Standard Time, + * Central Europe Standard Time, Romance Standard Time, Central European + * Standard Time, W. Central Africa Standard Time, Namibia Standard Time, + * Jordan Standard Time, GTB Standard Time, Middle East Standard Time, Egypt + * Standard Time, Syria Standard Time, E. Europe Standard Time, South Africa + * Standard Time, FLE Standard Time, Turkey Standard Time, Israel Standard + * Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, + * Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa + * Standard Time, Iran Standard Time, Arabian Standard Time, Azerbaijan + * Standard Time, Russia Time Zone 3, Mauritius Standard Time, Georgian + * Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West Asia + * Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India + * Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central Asia + * Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, + * Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, + * China Standard Time, North Asia East Standard Time, Singapore Standard Time, + * W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, + * Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. + * Australia Standard Time, AUS Central Standard Time, E. Australia Standard + * Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania + * Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time + * Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand + * Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga + * Standard Time, Samoa Standard Time, Line Islands Standard Time + * @member {array} days the collection of days that the profile takes effect + * on. Possible values are Sunday through Saturday. + * @member {array} hours A collection of hours that the profile takes effect + * on. Values supported are 0 to 23 on the 24-hour clock (AM/PM times are not + * supported). + * @member {array} minutes A collection of minutes at which the profile takes + * effect at. + */ +export interface RecurrentSchedule { + timeZone: string; + days: string[]; + hours: number[]; + minutes: number[]; +} + +/** + * @class + * Initializes a new instance of the Recurrence class. + * @constructor + * The repeating times at which this profile begins. This element is not used + * if the FixedDate element is used. + * + * @member {string} frequency the recurrence frequency. How often the schedule + * profile should take effect. This value must be Week, meaning each week will + * have the same set of profiles. Possible values include: 'None', 'Second', + * 'Minute', 'Hour', 'Day', 'Week', 'Month', 'Year' + * @member {object} schedule the scheduling constraints for when the profile + * begins. + * @member {string} [schedule.timeZone] the timezone for the hours of the + * profile. Some examples of valid timezones are: Dateline Standard Time, + * UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time + * (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain + * Standard Time (Mexico), Mountain Standard Time, Central America Standard + * Time, Central Standard Time, Central Standard Time (Mexico), Canada Central + * Standard Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern + * Standard Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic + * Standard Time, Central Brazilian Standard Time, SA Western Standard Time, + * Pacific SA Standard Time, Newfoundland Standard Time, E. South America + * Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland + * Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, + * Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, + * Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. + * Europe Standard Time, Central Europe Standard Time, Romance Standard Time, + * Central European Standard Time, W. Central Africa Standard Time, Namibia + * Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard + * Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, + * South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel + * Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic + * Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard + * Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, + * Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, + * Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, + * West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, + * India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central + * Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, + * Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, + * China Standard Time, North Asia East Standard Time, Singapore Standard Time, + * W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, + * Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. + * Australia Standard Time, AUS Central Standard Time, E. Australia Standard + * Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania + * Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time + * Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand + * Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga + * Standard Time, Samoa Standard Time, Line Islands Standard Time + * @member {array} [schedule.days] the collection of days that the profile + * takes effect on. Possible values are Sunday through Saturday. + * @member {array} [schedule.hours] A collection of hours that the profile + * takes effect on. Values supported are 0 to 23 on the 24-hour clock (AM/PM + * times are not supported). + * @member {array} [schedule.minutes] A collection of minutes at which the + * profile takes effect at. + */ +export interface Recurrence { + frequency: string; + schedule: RecurrentSchedule; +} + +/** + * @class + * Initializes a new instance of the AutoscaleProfile class. + * @constructor + * Autoscale profile. + * + * @member {string} name the name of the profile. + * @member {object} capacity the number of instances that can be used during + * this profile. + * @member {string} [capacity.minimum] the minimum number of instances for the + * resource. + * @member {string} [capacity.maximum] the maximum number of instances for the + * resource. The actual maximum number of instances is limited by the cores + * that are available in the subscription. + * @member {string} [capacity.default] the number of instances that will be set + * if metrics are not available for evaluation. The default is only used if the + * current instance count is lower than the default. + * @member {array} rules the collection of rules that provide the triggers and + * parameters for the scaling action. A maximum of 10 rules can be specified. + * @member {object} [fixedDate] the specific date-time for the profile. This + * element is not used if the Recurrence element is used. + * @member {string} [fixedDate.timeZone] the timezone of the start and end + * times for the profile. Some examples of valid timezones are: Dateline + * Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, + * Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard + * Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central + * America Standard Time, Central Standard Time, Central Standard Time + * (Mexico), Canada Central Standard Time, SA Pacific Standard Time, Eastern + * Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay + * Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA + * Western Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, + * E. South America Standard Time, Argentina Standard Time, SA Eastern Standard + * Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard + * Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde + * Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich + * Standard Time, W. Europe Standard Time, Central Europe Standard Time, + * Romance Standard Time, Central European Standard Time, W. Central Africa + * Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard + * Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, + * E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, + * Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, Libya + * Standard Time, Arabic Standard Time, Arab Standard Time, Belarus Standard + * Time, Russian Standard Time, E. Africa Standard Time, Iran Standard Time, + * Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, + * Mauritius Standard Time, Georgian Standard Time, Caucasus Standard Time, + * Afghanistan Standard Time, West Asia Standard Time, Ekaterinburg Standard + * Time, Pakistan Standard Time, India Standard Time, Sri Lanka Standard Time, + * Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard Time, + * N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, + * North Asia Standard Time, China Standard Time, North Asia East Standard + * Time, Singapore Standard Time, W. Australia Standard Time, Taipei Standard + * Time, Ulaanbaatar Standard Time, Tokyo Standard Time, Korea Standard Time, + * Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard + * Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific + * Standard Time, Tasmania Standard Time, Magadan Standard Time, Vladivostok + * Standard Time, Russia Time Zone 10, Central Pacific Standard Time, Russia + * Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, + * Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line + * Islands Standard Time + * @member {date} [fixedDate.start] the start time for the profile in ISO 8601 + * format. + * @member {date} [fixedDate.end] the end time for the profile in ISO 8601 + * format. + * @member {object} [recurrence] the repeating times at which this profile + * begins. This element is not used if the FixedDate element is used. + * @member {string} [recurrence.frequency] the recurrence frequency. How often + * the schedule profile should take effect. This value must be Week, meaning + * each week will have the same set of profiles. Possible values include: + * 'None', 'Second', 'Minute', 'Hour', 'Day', 'Week', 'Month', 'Year' + * @member {object} [recurrence.schedule] the scheduling constraints for when + * the profile begins. + * @member {string} [recurrence.schedule.timeZone] the timezone for the hours + * of the profile. Some examples of valid timezones are: Dateline Standard + * Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific + * Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, + * Mountain Standard Time (Mexico), Mountain Standard Time, Central America + * Standard Time, Central Standard Time, Central Standard Time (Mexico), Canada + * Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US + * Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, + * Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard + * Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America + * Standard Time, Argentina Standard Time, SA Eastern Standard Time, Greenland + * Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, + * Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard Time, + * Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. + * Europe Standard Time, Central Europe Standard Time, Romance Standard Time, + * Central European Standard Time, W. Central Africa Standard Time, Namibia + * Standard Time, Jordan Standard Time, GTB Standard Time, Middle East Standard + * Time, Egypt Standard Time, Syria Standard Time, E. Europe Standard Time, + * South Africa Standard Time, FLE Standard Time, Turkey Standard Time, Israel + * Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic + * Standard Time, Arab Standard Time, Belarus Standard Time, Russian Standard + * Time, E. Africa Standard Time, Iran Standard Time, Arabian Standard Time, + * Azerbaijan Standard Time, Russia Time Zone 3, Mauritius Standard Time, + * Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, + * West Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, + * India Standard Time, Sri Lanka Standard Time, Nepal Standard Time, Central + * Asia Standard Time, Bangladesh Standard Time, N. Central Asia Standard Time, + * Myanmar Standard Time, SE Asia Standard Time, North Asia Standard Time, + * China Standard Time, North Asia East Standard Time, Singapore Standard Time, + * W. Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, + * Tokyo Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. + * Australia Standard Time, AUS Central Standard Time, E. Australia Standard + * Time, AUS Eastern Standard Time, West Pacific Standard Time, Tasmania + * Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time + * Zone 10, Central Pacific Standard Time, Russia Time Zone 11, New Zealand + * Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga + * Standard Time, Samoa Standard Time, Line Islands Standard Time + * @member {array} [recurrence.schedule.days] the collection of days that the + * profile takes effect on. Possible values are Sunday through Saturday. + * @member {array} [recurrence.schedule.hours] A collection of hours that the + * profile takes effect on. Values supported are 0 to 23 on the 24-hour clock + * (AM/PM times are not supported). + * @member {array} [recurrence.schedule.minutes] A collection of minutes at + * which the profile takes effect at. + */ +export interface AutoscaleProfile { + name: string; + capacity: ScaleCapacity; + rules: ScaleRule[]; + fixedDate?: TimeWindow; + recurrence?: Recurrence; +} + +/** + * @class + * Initializes a new instance of the EmailNotification class. + * @constructor + * Email notification of an autoscale event. + * + * @member {boolean} [sendToSubscriptionAdministrator] a value indicating + * whether to send email to subscription administrator. + * @member {boolean} [sendToSubscriptionCoAdministrators] a value indicating + * whether to send email to subscription co-administrators. + * @member {array} [customEmails] the custom e-mails list. This value can be + * null or empty, in which case this attribute will be ignored. + */ +export interface EmailNotification { + sendToSubscriptionAdministrator?: boolean; + sendToSubscriptionCoAdministrators?: boolean; + customEmails?: string[]; +} + +/** + * @class + * Initializes a new instance of the WebhookNotification class. + * @constructor + * Webhook notification of an autoscale event. + * + * @member {string} [serviceUri] the service address to receive the + * notification. + * @member {object} [properties] a property bag of settings. This value can be + * empty. + */ +export interface WebhookNotification { + serviceUri?: string; + properties?: { [propertyName: string]: string }; +} + +/** + * @class + * Initializes a new instance of the AutoscaleNotification class. + * @constructor + * Autoscale notification. + * + * @member {object} [email] the email notification. + * @member {boolean} [email.sendToSubscriptionAdministrator] a value indicating + * whether to send email to subscription administrator. + * @member {boolean} [email.sendToSubscriptionCoAdministrators] a value + * indicating whether to send email to subscription co-administrators. + * @member {array} [email.customEmails] the custom e-mails list. This value can + * be null or empty, in which case this attribute will be ignored. + * @member {array} [webhooks] the collection of webhook notifications. + */ +export interface AutoscaleNotification { + email?: EmailNotification; + webhooks?: WebhookNotification[]; +} + +/** + * @class + * Initializes a new instance of the AutoscaleSettingResource class. + * @constructor + * The autoscale setting resource. + * + * @member {array} profiles the collection of automatic scaling profiles that + * specify different scaling parameters for different time periods. A maximum + * of 20 profiles can be specified. + * @member {array} [notifications] the collection of notifications. + * @member {boolean} [enabled] the enabled flag. Specifies whether automatic + * scaling is enabled for the resource. The default value is 'true'. Default + * value: true . + * @member {string} [autoscaleSettingResourceName] the name of the autoscale + * setting. + * @member {string} [targetResourceUri] the resource identifier of the resource + * that the autoscale setting should be added to. + */ +export interface AutoscaleSettingResource extends Resource { + profiles: AutoscaleProfile[]; + notifications?: AutoscaleNotification[]; + enabled?: boolean; + autoscaleSettingResourceName?: string; + targetResourceUri?: string; +} + +/** + * @class + * Initializes a new instance of the AutoscaleSettingResourcePatch class. + * @constructor + * The autoscale setting object for patch operations. + * + * @member {object} [tags] Resource tags + * @member {array} profiles the collection of automatic scaling profiles that + * specify different scaling parameters for different time periods. A maximum + * of 20 profiles can be specified. + * @member {array} [notifications] the collection of notifications. + * @member {boolean} [enabled] the enabled flag. Specifies whether automatic + * scaling is enabled for the resource. The default value is 'true'. Default + * value: true . + * @member {string} [name] the name of the autoscale setting. + * @member {string} [targetResourceUri] the resource identifier of the resource + * that the autoscale setting should be added to. + */ +export interface AutoscaleSettingResourcePatch { + tags?: { [propertyName: string]: string }; + profiles: AutoscaleProfile[]; + notifications?: AutoscaleNotification[]; + enabled?: boolean; + name?: string; + targetResourceUri?: string; +} + +/** + * @class + * Initializes a new instance of the ErrorResponse class. + * @constructor + * Describes the format of Error response. + * + * @member {string} [code] Error code + * @member {string} [message] Error message indicating why the operation + * failed. + */ +export interface ErrorResponse { + code?: string; + message?: string; +} + +/** + * @class + * Initializes a new instance of the OperationDisplay class. + * @constructor + * Display metadata associated with the operation. + * + * @member {string} [provider] Service provider: Microsoft.Insights + * @member {string} [resource] Resource on which the operation is performed: + * AlertRules, Autoscale, etc. + * @member {string} [operation] Operation type: Read, write, delete, etc. + */ +export interface OperationDisplay { + provider?: string; + resource?: string; + operation?: string; +} + +/** + * @class + * Initializes a new instance of the Operation class. + * @constructor + * Microsoft Insights API operation definition. + * + * @member {string} [name] Operation name: {provider}/{resource}/{operation} + * @member {object} [display] Display metadata associated with the operation. + * @member {string} [display.provider] Service provider: Microsoft.Insights + * @member {string} [display.resource] Resource on which the operation is + * performed: AlertRules, Autoscale, etc. + * @member {string} [display.operation] Operation type: Read, write, delete, + * etc. + */ +export interface Operation { + name?: string; + display?: OperationDisplay; +} + +/** + * @class + * Initializes a new instance of the OperationListResult class. + * @constructor + * Result of the request to list Microsoft.Insights operations. It contains a + * list of operations and a URL link to get the next set of results. + * + * @member {array} [value] List of operations supported by the + * Microsoft.Insights provider. + * @member {string} [nextLink] URL to get the next set of operation list + * results if there are any. + */ +export interface OperationListResult { + value?: Operation[]; + nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the Incident class. + * @constructor + * An alert incident indicates the activation status of an alert rule. + * + * @member {string} [name] Incident name. + * @member {string} [ruleName] Rule name that is associated with the incident. + * @member {boolean} [isActive] A boolean to indicate whether the incident is + * active or resolved. + * @member {date} [activatedTime] The time at which the incident was activated + * in ISO8601 format. + * @member {date} [resolvedTime] The time at which the incident was resolved in + * ISO8601 format. If null, it means the incident is still active. + */ +export interface Incident { + readonly name?: string; + readonly ruleName?: string; + readonly isActive?: boolean; + readonly activatedTime?: Date; + readonly resolvedTime?: Date; +} + +/** + * @class + * Initializes a new instance of the RuleDataSource class. + * @constructor + * The resource from which the rule collects its data. + * + * @member {string} [resourceUri] the resource identifier of the resource the + * rule monitors. **NOTE**: this property cannot be updated for an existing + * rule. + * @member {string} odatatype Polymorphic Discriminator + */ +export interface RuleDataSource { + resourceUri?: string; + odatatype: string; +} + +/** + * @class + * Initializes a new instance of the RuleCondition class. + * @constructor + * The condition that results in the alert rule being activated. + * + * @member {object} [dataSource] the resource from which the rule collects its + * data. For this type dataSource will always be of type RuleMetricDataSource. + * @member {string} [dataSource.resourceUri] the resource identifier of the + * resource the rule monitors. **NOTE**: this property cannot be updated for an + * existing rule. + * @member {string} [dataSource.odatatype] Polymorphic Discriminator + * @member {string} odatatype Polymorphic Discriminator + */ +export interface RuleCondition { + dataSource?: RuleDataSource; + odatatype: string; +} + +/** + * @class + * Initializes a new instance of the RuleMetricDataSource class. + * @constructor + * A rule metric data source. The discriminator value is always + * RuleMetricDataSource in this case. + * + * @member {string} [metricName] the name of the metric that defines what the + * rule monitors. + */ +export interface RuleMetricDataSource extends RuleDataSource { + metricName?: string; +} + +/** + * @class + * Initializes a new instance of the RuleManagementEventClaimsDataSource class. + * @constructor + * The claims for a rule management event data source. + * + * @member {string} [emailAddress] the email address. + */ +export interface RuleManagementEventClaimsDataSource { + emailAddress?: string; +} + +/** + * @class + * Initializes a new instance of the RuleManagementEventDataSource class. + * @constructor + * A rule management event data source. The discriminator fields is always + * RuleManagementEventDataSource in this case. + * + * @member {string} [eventName] the event name. + * @member {string} [eventSource] the event source. + * @member {string} [level] the level. + * @member {string} [operationName] The name of the operation that should be + * checked for. If no name is provided, any operation will match. + * @member {string} [resourceGroupName] the resource group name. + * @member {string} [resourceProviderName] the resource provider name. + * @member {string} [status] The status of the operation that should be checked + * for. If no status is provided, any status will match. + * @member {string} [subStatus] the substatus. + * @member {object} [claims] the claims. + * @member {string} [claims.emailAddress] the email address. + */ +export interface RuleManagementEventDataSource extends RuleDataSource { + eventName?: string; + eventSource?: string; + level?: string; + operationName?: string; + resourceGroupName?: string; + resourceProviderName?: string; + status?: string; + subStatus?: string; + claims?: RuleManagementEventClaimsDataSource; +} + +/** + * @class + * Initializes a new instance of the ThresholdRuleCondition class. + * @constructor + * A rule condition based on a metric crossing a threshold. + * + * @member {string} operator the operator used to compare the data and the + * threshold. Possible values include: 'GreaterThan', 'GreaterThanOrEqual', + * 'LessThan', 'LessThanOrEqual' + * @member {number} threshold the threshold value that activates the alert. + * @member {moment.duration} [windowSize] the period of time (in ISO 8601 + * duration format) that is used to monitor alert activity based on the + * threshold. If specified then it must be between 5 minutes and 1 day. + * @member {string} [timeAggregation] the time aggregation operator. How the + * data that are collected should be combined over time. The default value is + * the PrimaryAggregationType of the Metric. Possible values include: + * 'Average', 'Minimum', 'Maximum', 'Total', 'Last' + */ +export interface ThresholdRuleCondition extends RuleCondition { + operator: string; + threshold: number; + windowSize?: moment.Duration; + timeAggregation?: string; +} + +/** + * @class + * Initializes a new instance of the LocationThresholdRuleCondition class. + * @constructor + * A rule condition based on a certain number of locations failing. + * + * @member {moment.duration} [windowSize] the period of time (in ISO 8601 + * duration format) that is used to monitor alert activity based on the + * threshold. If specified then it must be between 5 minutes and 1 day. + * @member {number} failedLocationCount the number of locations that must fail + * to activate the alert. + */ +export interface LocationThresholdRuleCondition extends RuleCondition { + windowSize?: moment.Duration; + failedLocationCount: number; +} + +/** + * @class + * Initializes a new instance of the ManagementEventAggregationCondition class. + * @constructor + * How the data that is collected should be combined over time. + * + * @member {string} [operator] the condition operator. Possible values include: + * 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' + * @member {number} [threshold] The threshold value that activates the alert. + * @member {moment.duration} [windowSize] the period of time (in ISO 8601 + * duration format) that is used to monitor alert activity based on the + * threshold. If specified then it must be between 5 minutes and 1 day. + */ +export interface ManagementEventAggregationCondition { + operator?: string; + threshold?: number; + windowSize?: moment.Duration; +} + +/** + * @class + * Initializes a new instance of the ManagementEventRuleCondition class. + * @constructor + * A management event rule condition. + * + * @member {object} [aggregation] How the data that is collected should be + * combined over time and when the alert is activated. Note that for management + * event alerts aggregation is optional – if it is not provided then any event + * will cause the alert to activate. + * @member {string} [aggregation.operator] the condition operator. Possible + * values include: 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + * 'LessThanOrEqual' + * @member {number} [aggregation.threshold] The threshold value that activates + * the alert. + * @member {moment.duration} [aggregation.windowSize] the period of time (in + * ISO 8601 duration format) that is used to monitor alert activity based on + * the threshold. If specified then it must be between 5 minutes and 1 day. + */ +export interface ManagementEventRuleCondition extends RuleCondition { + aggregation?: ManagementEventAggregationCondition; +} + +/** + * @class + * Initializes a new instance of the RuleAction class. + * @constructor + * The action that is performed when the alert rule becomes active, and when an + * alert condition is resolved. + * + * @member {string} odatatype Polymorphic Discriminator + */ +export interface RuleAction { + odatatype: string; +} + +/** + * @class + * Initializes a new instance of the RuleEmailAction class. + * @constructor + * Specifies the action to send email when the rule condition is evaluated. The + * discriminator is always RuleEmailAction in this case. + * + * @member {boolean} [sendToServiceOwners] Whether the administrators (service + * and co-administrators) of the service should be notified when the alert is + * activated. + * @member {array} [customEmails] the list of administrator's custom email + * addresses to notify of the activation of the alert. + */ +export interface RuleEmailAction extends RuleAction { + sendToServiceOwners?: boolean; + customEmails?: string[]; +} + +/** + * @class + * Initializes a new instance of the RuleWebhookAction class. + * @constructor + * Specifies the action to post to service when the rule condition is + * evaluated. The discriminator is always RuleWebhookAction in this case. + * + * @member {string} [serviceUri] the service uri to Post the notification when + * the alert activates or resolves. + * @member {object} [properties] the dictionary of custom properties to include + * with the post operation. These data are appended to the webhook payload. + */ +export interface RuleWebhookAction extends RuleAction { + serviceUri?: string; + properties?: { [propertyName: string]: string }; +} + +/** + * @class + * Initializes a new instance of the AlertRuleResource class. + * @constructor + * The alert rule resource. + * + * @member {string} alertRuleResourceName the name of the alert rule. + * @member {string} [description] the description of the alert rule that will + * be included in the alert email. + * @member {boolean} isEnabled the flag that indicates whether the alert rule + * is enabled. + * @member {object} condition the condition that results in the alert rule + * being activated. + * @member {object} [condition.dataSource] the resource from which the rule + * collects its data. For this type dataSource will always be of type + * RuleMetricDataSource. + * @member {string} [condition.dataSource.resourceUri] the resource identifier + * of the resource the rule monitors. **NOTE**: this property cannot be updated + * for an existing rule. + * @member {string} [condition.dataSource.odatatype] Polymorphic Discriminator + * @member {string} [condition.odatatype] Polymorphic Discriminator + * @member {array} [actions] the array of actions that are performed when the + * alert rule becomes active, and when an alert condition is resolved. + * @member {date} [lastUpdatedTime] Last time the rule was updated in ISO8601 + * format. + */ +export interface AlertRuleResource extends Resource { + alertRuleResourceName: string; + description?: string; + isEnabled: boolean; + condition: RuleCondition; + actions?: RuleAction[]; + readonly lastUpdatedTime?: Date; +} + +/** + * @class + * Initializes a new instance of the AlertRuleResourcePatch class. + * @constructor + * The alert rule object for patch operations. + * + * @member {object} [tags] Resource tags + * @member {string} name the name of the alert rule. + * @member {string} [description] the description of the alert rule that will + * be included in the alert email. + * @member {boolean} isEnabled the flag that indicates whether the alert rule + * is enabled. + * @member {object} condition the condition that results in the alert rule + * being activated. + * @member {object} [condition.dataSource] the resource from which the rule + * collects its data. For this type dataSource will always be of type + * RuleMetricDataSource. + * @member {string} [condition.dataSource.resourceUri] the resource identifier + * of the resource the rule monitors. **NOTE**: this property cannot be updated + * for an existing rule. + * @member {string} [condition.dataSource.odatatype] Polymorphic Discriminator + * @member {string} [condition.odatatype] Polymorphic Discriminator + * @member {array} [actions] the array of actions that are performed when the + * alert rule becomes active, and when an alert condition is resolved. + * @member {date} [lastUpdatedTime] Last time the rule was updated in ISO8601 + * format. + */ +export interface AlertRuleResourcePatch { + tags?: { [propertyName: string]: string }; + name: string; + description?: string; + isEnabled: boolean; + condition: RuleCondition; + actions?: RuleAction[]; + readonly lastUpdatedTime?: Date; +} + +/** + * @class + * Initializes a new instance of the RetentionPolicy class. + * @constructor + * Specifies the retention policy for the log. + * + * @member {boolean} enabled a value indicating whether the retention policy is + * enabled. + * @member {number} days the number of days for the retention in days. A value + * of 0 will retain the events indefinitely. + */ +export interface RetentionPolicy { + enabled: boolean; + days: number; +} + +/** + * @class + * Initializes a new instance of the LogProfileResource class. + * @constructor + * The log profile resource. + * + * @member {string} [storageAccountId] the resource id of the storage account + * to which you would like to send the Activity Log. + * @member {string} [serviceBusRuleId] The service bus rule ID of the service + * bus namespace in which you would like to have Event Hubs created for + * streaming the Activity Log. The rule ID is of the format: '{service bus + * resource ID}/authorizationrules/{key name}'. + * @member {array} locations List of regions for which Activity Log events + * should be stored or streamed. It is a comma separated list of valid ARM + * locations including the 'global' location. + * @member {array} categories the categories of the logs. These categories are + * created as is convenient to the user. Some values are: 'Write', 'Delete', + * and/or 'Action.' + * @member {object} retentionPolicy the retention policy for the events in the + * log. + * @member {boolean} [retentionPolicy.enabled] a value indicating whether the + * retention policy is enabled. + * @member {number} [retentionPolicy.days] the number of days for the retention + * in days. A value of 0 will retain the events indefinitely. + */ +export interface LogProfileResource extends Resource { + storageAccountId?: string; + serviceBusRuleId?: string; + locations: string[]; + categories: string[]; + retentionPolicy: RetentionPolicy; +} + +/** + * @class + * Initializes a new instance of the LogProfileResourcePatch class. + * @constructor + * The log profile resource for patch operations. + * + * @member {object} [tags] Resource tags + * @member {string} [storageAccountId] the resource id of the storage account + * to which you would like to send the Activity Log. + * @member {string} [serviceBusRuleId] The service bus rule ID of the service + * bus namespace in which you would like to have Event Hubs created for + * streaming the Activity Log. The rule ID is of the format: '{service bus + * resource ID}/authorizationrules/{key name}'. + * @member {array} locations List of regions for which Activity Log events + * should be stored or streamed. It is a comma separated list of valid ARM + * locations including the 'global' location. + * @member {array} categories the categories of the logs. These categories are + * created as is convenient to the user. Some values are: 'Write', 'Delete', + * and/or 'Action.' + * @member {object} retentionPolicy the retention policy for the events in the + * log. + * @member {boolean} [retentionPolicy.enabled] a value indicating whether the + * retention policy is enabled. + * @member {number} [retentionPolicy.days] the number of days for the retention + * in days. A value of 0 will retain the events indefinitely. + */ +export interface LogProfileResourcePatch { + tags?: { [propertyName: string]: string }; + storageAccountId?: string; + serviceBusRuleId?: string; + locations: string[]; + categories: string[]; + retentionPolicy: RetentionPolicy; +} + +/** + * @class + * Initializes a new instance of the ProxyOnlyResource class. + * @constructor + * A proxy only azure resource object + * + * @member {string} [id] Azure resource Id + * @member {string} [name] Azure resource name + * @member {string} [type] Azure resource type + */ +export interface ProxyOnlyResource extends BaseResource { + readonly id?: string; + readonly name?: string; + readonly type?: string; +} + +/** + * @class + * Initializes a new instance of the MetricSettings class. + * @constructor + * Part of MultiTenantDiagnosticSettings. Specifies the settings for a + * particular metric. + * + * @member {moment.duration} [timeGrain] the timegrain of the metric in ISO8601 + * format. + * @member {string} [category] Name of a Diagnostic Metric category for a + * resource type this setting is applied to. To obtain the list of Diagnostic + * metric categories for a resource, first perform a GET diagnostic settings + * operation. + * @member {boolean} enabled a value indicating whether this category is + * enabled. + * @member {object} [retentionPolicy] the retention policy for this category. + * @member {boolean} [retentionPolicy.enabled] a value indicating whether the + * retention policy is enabled. + * @member {number} [retentionPolicy.days] the number of days for the retention + * in days. A value of 0 will retain the events indefinitely. + */ +export interface MetricSettings { + timeGrain?: moment.Duration; + category?: string; + enabled: boolean; + retentionPolicy?: RetentionPolicy; +} + +/** + * @class + * Initializes a new instance of the LogSettings class. + * @constructor + * Part of MultiTenantDiagnosticSettings. Specifies the settings for a + * particular log. + * + * @member {string} [category] Name of a Diagnostic Log category for a resource + * type this setting is applied to. To obtain the list of Diagnostic Log + * categories for a resource, first perform a GET diagnostic settings + * operation. + * @member {boolean} enabled a value indicating whether this log is enabled. + * @member {object} [retentionPolicy] the retention policy for this log. + * @member {boolean} [retentionPolicy.enabled] a value indicating whether the + * retention policy is enabled. + * @member {number} [retentionPolicy.days] the number of days for the retention + * in days. A value of 0 will retain the events indefinitely. + */ +export interface LogSettings { + category?: string; + enabled: boolean; + retentionPolicy?: RetentionPolicy; +} + +/** + * @class + * Initializes a new instance of the DiagnosticSettingsResource class. + * @constructor + * The diagnostic setting resource. + * + * @member {string} [storageAccountId] The resource ID of the storage account + * to which you would like to send Diagnostic Logs. + * @member {string} [eventHubAuthorizationRuleId] The resource Id for the event + * hub authorization rule. + * @member {string} [eventHubName] The name of the event hub. If none is + * specified, the default event hub will be selected. + * @member {array} [metrics] the list of metric settings. + * @member {array} [logs] the list of logs settings. + * @member {string} [workspaceId] The workspace ID (resource ID of a Log + * Analytics workspace) for a Log Analytics workspace to which you would like + * to send Diagnostic Logs. Example: + * /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + */ +export interface DiagnosticSettingsResource extends ProxyOnlyResource { + storageAccountId?: string; + eventHubAuthorizationRuleId?: string; + eventHubName?: string; + metrics?: MetricSettings[]; + logs?: LogSettings[]; + workspaceId?: string; +} + +/** + * @class + * Initializes a new instance of the DiagnosticSettingsResourceCollection class. + * @constructor + * Represents a collection of alert rule resources. + * + * @member {array} [value] The collection of diagnostic settings resources;. + */ +export interface DiagnosticSettingsResourceCollection { + value?: DiagnosticSettingsResource[]; +} + +/** + * @class + * Initializes a new instance of the DiagnosticSettingsCategoryResource class. + * @constructor + * The diagnostic settings category resource. + * + * @member {string} [categoryType] The type of the diagnostic settings + * category. Possible values include: 'Metrics', 'Logs' + */ +export interface DiagnosticSettingsCategoryResource extends ProxyOnlyResource { + categoryType?: string; +} + +/** + * @class + * Initializes a new instance of the DiagnosticSettingsCategoryResourceCollection class. + * @constructor + * Represents a collection of diagnostic setting category resources. + * + * @member {array} [value] The collection of diagnostic settings category + * resources. + */ +export interface DiagnosticSettingsCategoryResourceCollection { + value?: DiagnosticSettingsCategoryResource[]; +} + +/** + * @class + * Initializes a new instance of the EmailReceiver class. + * @constructor + * An email receiver. + * + * @member {string} name The name of the email receiver. Names must be unique + * across all receivers within an action group. + * @member {string} emailAddress The email address of this receiver. + * @member {string} [status] The receiver status of the e-mail. Possible values + * include: 'NotSpecified', 'Enabled', 'Disabled' + */ +export interface EmailReceiver { + name: string; + emailAddress: string; + readonly status?: string; +} + +/** + * @class + * Initializes a new instance of the SmsReceiver class. + * @constructor + * An SMS receiver. + * + * @member {string} name The name of the SMS receiver. Names must be unique + * across all receivers within an action group. + * @member {string} countryCode The country code of the SMS receiver. + * @member {string} phoneNumber The phone number of the SMS receiver. + * @member {string} [status] The status of the receiver. Possible values + * include: 'NotSpecified', 'Enabled', 'Disabled' + */ +export interface SmsReceiver { + name: string; + countryCode: string; + phoneNumber: string; + readonly status?: string; +} + +/** + * @class + * Initializes a new instance of the WebhookReceiver class. + * @constructor + * A webhook receiver. + * + * @member {string} name The name of the webhook receiver. Names must be unique + * across all receivers within an action group. + * @member {string} serviceUri The URI where webhooks should be sent. + */ +export interface WebhookReceiver { + name: string; + serviceUri: string; +} + +/** + * @class + * Initializes a new instance of the ItsmReceiver class. + * @constructor + * An Itsm receiver. + * + * @member {string} name The name of the Itsm receiver. Names must be unique + * across all receivers within an action group. + * @member {string} workspaceId OMS LA instance identifier. + * @member {string} connectionId Unique identification of ITSM connection among + * multiple defined in above workspace. + * @member {string} ticketConfiguration JSON blob for the configurations of the + * ITSM action. CreateMultipleWorkItems option will be part of this blob as + * well. + * @member {string} region Region in which workspace resides. Supported + * values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope' + */ +export interface ItsmReceiver { + name: string; + workspaceId: string; + connectionId: string; + ticketConfiguration: string; + region: string; +} + +/** + * @class + * Initializes a new instance of the AzureAppPushReceiver class. + * @constructor + * The Azure mobile App push notification receiver. + * + * @member {string} name The name of the Azure mobile app push receiver. Names + * must be unique across all receivers within an action group. + * @member {string} emailAddress The email address registered for the Azure + * mobile app. + */ +export interface AzureAppPushReceiver { + name: string; + emailAddress: string; +} + +/** + * @class + * Initializes a new instance of the AutomationRunbookReceiver class. + * @constructor + * The Azure Automation Runbook notification receiver. + * + * @member {string} automationAccountId The Azure automation account Id which + * holds this runbook and authenticate to Azure resource. + * @member {string} runbookName The name for this runbook. + * @member {string} webhookResourceId The resource id for webhook linked to + * this runbook. + * @member {boolean} isGlobalRunbook Indicates whether this instance is global + * runbook. + * @member {string} [name] Indicates name of the webhook. + * @member {string} [serviceUri] The URI where webhooks should be sent. + */ +export interface AutomationRunbookReceiver { + automationAccountId: string; + runbookName: string; + webhookResourceId: string; + isGlobalRunbook: boolean; + name?: string; + serviceUri?: string; +} + +/** + * @class + * Initializes a new instance of the ActionGroupResource class. * @constructor - * The localizable string class. + * An action group resource. * - * @member {string} value the invariant value. - * @member {string} [localizedValue] the locale specific value. + * @member {string} groupShortName The short name of the action group. This + * will be used in SMS messages. + * @member {boolean} enabled Indicates whether this action group is enabled. If + * an action group is not enabled, then none of its receivers will receive + * communications. Default value: true . + * @member {array} [emailReceivers] The list of email receivers that are part + * of this action group. + * @member {array} [smsReceivers] The list of SMS receivers that are part of + * this action group. + * @member {array} [webhookReceivers] The list of webhook receivers that are + * part of this action group. + * @member {array} [itsmReceivers] The list of ITSM receivers that are part of + * this action group. + * @member {array} [azureAppPushReceivers] The list of AzureAppPush receivers + * that are part of this action group. + * @member {array} [automationRunbookReceivers] The list of AutomationRunbook + * receivers that are part of this action group. */ -export interface LocalizableString { - value: string; - localizedValue?: string; +export interface ActionGroupResource extends Resource { + groupShortName: string; + enabled: boolean; + emailReceivers?: EmailReceiver[]; + smsReceivers?: SmsReceiver[]; + webhookReceivers?: WebhookReceiver[]; + itsmReceivers?: ItsmReceiver[]; + azureAppPushReceivers?: AzureAppPushReceiver[]; + automationRunbookReceivers?: AutomationRunbookReceiver[]; } /** * @class - * Initializes a new instance of the UsageMetric class. + * Initializes a new instance of the EnableRequest class. * @constructor - * Usage Metric data. + * Describes a receiver that should be resubscribed. * - * @member {object} [name] the usage metric name and display name. - * @member {string} [name.value] the invariant value. - * @member {string} [name.localizedValue] the locale specific value. - * @member {number} [currentValue] the current value for the usage metric. - * @member {string} [id] the id for the usage metric. - * @member {number} [limit] the quota limit the usage metric. - * @member {string} [unit] the unit for the usage metric. - * @member {date} [nextResetTime] the next reset time for the current value. - * @member {moment.duration} [quotaPeriod] the amount of time it takes to reset - * the value. - */ -export interface UsageMetric { - name?: LocalizableString; - currentValue?: number; - id?: string; - limit?: number; - unit?: string; - nextResetTime?: Date; - quotaPeriod?: moment.Duration; + * @member {string} receiverName The name of the receiver to resubscribe. + */ +export interface EnableRequest { + receiverName: string; } /** * @class - * Initializes a new instance of the ErrorResponse class. + * Initializes a new instance of the ActionGroupPatchBody class. * @constructor - * Describes the format of Error response. + * An action group object for the body of patch operations. * - * @member {string} [code] Error code - * @member {string} [message] Error message indicating why the operation - * failed. + * @member {object} [tags] Resource tags + * @member {boolean} [enabled] Indicates whether this action group is enabled. + * If an action group is not enabled, then none of its actions will be + * activated. Default value: true . */ -export interface ErrorResponse { - code?: string; - message?: string; +export interface ActionGroupPatchBody { + tags?: { [propertyName: string]: string }; + enabled?: boolean; +} + +/** + * @class + * Initializes a new instance of the ActivityLogAlertLeafCondition class. + * @constructor + * An Activity Log alert condition that is met by comparing an activity log + * field and value. + * + * @member {string} field The name of the field that this condition will + * examine. The possible values for this field are (case-insensitive): + * 'resourceId', 'category', 'caller', 'level', 'operationName', + * 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', + * or anything beginning with 'properties.'. + * @member {string} equals The field value will be compared to this value + * (case-insensitive) to determine if the condition is met. + */ +export interface ActivityLogAlertLeafCondition { + field: string; + equals: string; +} + +/** + * @class + * Initializes a new instance of the ActivityLogAlertAllOfCondition class. + * @constructor + * An Activity Log alert condition that is met when all its member conditions + * are met. + * + * @member {array} allOf The list of activity log alert conditions. + */ +export interface ActivityLogAlertAllOfCondition { + allOf: ActivityLogAlertLeafCondition[]; +} + +/** + * @class + * Initializes a new instance of the ActivityLogAlertActionGroup class. + * @constructor + * A pointer to an Azure Action Group. + * + * @member {string} actionGroupId The resourceId of the action group. This + * cannot be null or empty. + * @member {object} [webhookProperties] the dictionary of custom properties to + * include with the post operation. These data are appended to the webhook + * payload. + */ +export interface ActivityLogAlertActionGroup { + actionGroupId: string; + webhookProperties?: { [propertyName: string]: string }; +} + +/** + * @class + * Initializes a new instance of the ActivityLogAlertActionList class. + * @constructor + * A list of activity log alert actions. + * + * @member {array} [actionGroups] The list of activity log alerts. + */ +export interface ActivityLogAlertActionList { + actionGroups?: ActivityLogAlertActionGroup[]; +} + +/** + * @class + * Initializes a new instance of the ActivityLogAlertResource class. + * @constructor + * An activity log alert resource. + * + * @member {array} scopes A list of resourceIds that will be used as prefixes. + * The alert will only apply to activityLogs with resourceIds that fall under + * one of these prefixes. This list must include at least one item. + * @member {boolean} [enabled] Indicates whether this activity log alert is + * enabled. If an activity log alert is not enabled, then none of its actions + * will be activated. Default value: true . + * @member {object} condition The condition that will cause this alert to + * activate. + * @member {array} [condition.allOf] The list of activity log alert conditions. + * @member {object} actions The actions that will activate when the condition + * is met. + * @member {array} [actions.actionGroups] The list of activity log alerts. + * @member {string} [description] A description of this activity log alert. + */ +export interface ActivityLogAlertResource extends Resource { + scopes: string[]; + enabled?: boolean; + condition: ActivityLogAlertAllOfCondition; + actions: ActivityLogAlertActionList; + description?: string; +} + +/** + * @class + * Initializes a new instance of the ActivityLogAlertPatchBody class. + * @constructor + * An activity log alert object for the body of patch operations. + * + * @member {object} [tags] Resource tags + * @member {boolean} [enabled] Indicates whether this activity log alert is + * enabled. If an activity log alert is not enabled, then none of its actions + * will be activated. Default value: true . + */ +export interface ActivityLogAlertPatchBody { + tags?: { [propertyName: string]: string }; + enabled?: boolean; +} + +/** + * @class + * Initializes a new instance of the LocalizableString class. + * @constructor + * The localizable string class. + * + * @member {string} value the invariant value. + * @member {string} [localizedValue] the locale specific value. + */ +export interface LocalizableString { + value: string; + localizedValue?: string; } /** @@ -148,8 +1562,8 @@ export interface HttpRequestInfo { * @member {string} [httpRequest.clientIpAddress] the client Ip Address * @member {string} [httpRequest.method] the Http request method. * @member {string} [httpRequest.uri] the Uri. - * @member {string} level the event level. Possible values include: 'Critical', - * 'Error', 'Warning', 'Informational', 'Verbose' + * @member {string} [level] the event level. Possible values include: + * 'Critical', 'Error', 'Warning', 'Informational', 'Verbose' * @member {string} [resourceGroupName] the resource group name of the impacted * resource. * @member {object} [resourceProviderName] the resource provider name of the @@ -184,10 +1598,10 @@ export interface HttpRequestInfo { * Code: 504) * @member {string} [subStatus.value] the invariant value. * @member {string} [subStatus.localizedValue] the locale specific value. - * @member {date} eventTimestamp the timestamp of when the event was generated - * by the Azure service processing the request corresponding the event. It in - * ISO 8601 format. - * @member {date} submissionTimestamp the timestamp of when the event became + * @member {date} [eventTimestamp] the timestamp of when the event was + * generated by the Azure service processing the request corresponding the + * event. It in ISO 8601 format. + * @member {date} [submissionTimestamp] the timestamp of when the event became * available for querying via this API. It is in ISO 8601 format. This value * should not be confused eventTimestamp. As there might be a delay between the * occurrence time of the event, and the time that the event is submitted to @@ -196,30 +1610,30 @@ export interface HttpRequestInfo { * @member {string} [tenantId] the Azure tenant Id */ export interface EventData { - authorization?: SenderAuthorization; - claims?: { [propertyName: string]: string }; - caller?: string; - description?: string; - id?: string; - eventDataId?: string; - correlationId?: string; - eventName?: LocalizableString; - category?: LocalizableString; - httpRequest?: HttpRequestInfo; - level: string; - resourceGroupName?: string; - resourceProviderName?: LocalizableString; - resourceId?: string; - resourceType?: LocalizableString; - operationId?: string; - operationName?: LocalizableString; - properties?: { [propertyName: string]: string }; - status?: LocalizableString; - subStatus?: LocalizableString; - eventTimestamp: Date; - submissionTimestamp: Date; - subscriptionId?: string; - tenantId?: string; + readonly authorization?: SenderAuthorization; + readonly claims?: { [propertyName: string]: string }; + readonly caller?: string; + readonly description?: string; + readonly id?: string; + readonly eventDataId?: string; + readonly correlationId?: string; + readonly eventName?: LocalizableString; + readonly category?: LocalizableString; + readonly httpRequest?: HttpRequestInfo; + readonly level?: string; + readonly resourceGroupName?: string; + readonly resourceProviderName?: LocalizableString; + readonly resourceId?: string; + readonly resourceType?: LocalizableString; + readonly operationId?: string; + readonly operationName?: LocalizableString; + readonly properties?: { [propertyName: string]: string }; + readonly status?: LocalizableString; + readonly subStatus?: LocalizableString; + readonly eventTimestamp?: Date; + readonly submissionTimestamp?: Date; + readonly subscriptionId?: string; + readonly tenantId?: string; } /** @@ -250,6 +1664,7 @@ export interface MetricAvailability { * dimension is required. * @member {string} [resourceId] the resource identifier of the resource that * emitted the metric. + * @member {string} [namespace] the namespace the metric blongs to. * @member {object} [name] the name and the display name of the metric, i.e. it * is a localizable string. * @member {string} [name.value] the invariant value. @@ -260,6 +1675,8 @@ export interface MetricAvailability { * @member {string} [primaryAggregationType] the primary aggregation type value * defining how to use the values for display. Possible values include: 'None', * 'Average', 'Count', 'Minimum', 'Maximum', 'Total' + * @member {array} [supportedAggregationTypes] the collection of what + * aggregation types are supported. * @member {array} [metricAvailabilities] the collection of what aggregation * intervals are available to be queried. * @member {string} [id] the resource identifier of the metric definition. @@ -269,9 +1686,11 @@ export interface MetricAvailability { export interface MetricDefinition { isDimensionRequired?: boolean; resourceId?: string; + namespace?: string; name?: LocalizableString; unit?: string; primaryAggregationType?: string; + supportedAggregationTypes?: string[]; metricAvailabilities?: MetricAvailability[]; id?: string; dimensions?: LocalizableString[]; @@ -376,24 +1795,398 @@ export interface Metric { * the metric data was returned in. This may be adjusted in the future and * returned back from what was originally requested. This is not present if a * metadata request was made. + * @member {string} [namespace] The namespace of the metrics been queried + * @member {string} [resourceregion] The region of the resource been queried + * for metrics. * @member {array} value the value of the collection. */ export interface Response { cost?: number; timespan: string; interval?: moment.Duration; + namespace?: string; + resourceregion?: string; value: Metric[]; } +/** + * @class + * Initializes a new instance of the BaselineMetadataValue class. + * @constructor + * Represents a baseline metadata value. + * + * @member {object} [name] the name of the metadata. + * @member {string} [name.value] the invariant value. + * @member {string} [name.localizedValue] the locale specific value. + * @member {string} [value] the value of the metadata. + */ +export interface BaselineMetadataValue { + name?: LocalizableString; + value?: string; +} + +/** + * @class + * Initializes a new instance of the Baseline class. + * @constructor + * The baseline values for a single sensitivity value. + * + * @member {string} sensitivity the sensitivity of the baseline. Possible + * values include: 'Low', 'Medium', 'High' + * @member {array} lowThresholds The low thresholds of the baseline. + * @member {array} highThresholds The high thresholds of the baseline. + */ +export interface Baseline { + sensitivity: string; + lowThresholds: number[]; + highThresholds: number[]; +} + +/** + * @class + * Initializes a new instance of the BaselineResponse class. + * @constructor + * The response to a baseline query. + * + * @member {string} [id] the metric baseline Id. + * @member {string} [type] the resource type of the baseline resource. + * @member {object} [name] the name and the display name of the metric, i.e. it + * is localizable string. + * @member {string} [name.value] the invariant value. + * @member {string} [name.localizedValue] the locale specific value. + * @member {string} [timespan] The timespan for which the data was retrieved. + * Its value consists of two datatimes concatenated, separated by '/'. This + * may be adjusted in the future and returned back from what was originally + * requested. + * @member {moment.duration} [interval] The interval (window size) for which + * the metric data was returned in. This may be adjusted in the future and + * returned back from what was originally requested. This is not present if a + * metadata request was made. + * @member {string} [aggregation] The aggregation type of the metric. + * @member {array} [timestamps] the array of timestamps of the baselines. + * @member {array} [baseline] the baseline values for each sensitivity. + * @member {array} [metadata] the baseline metadata values. + */ +export interface BaselineResponse { + readonly id?: string; + readonly type?: string; + readonly name?: LocalizableString; + timespan?: string; + interval?: moment.Duration; + aggregation?: string; + timestamps?: Date[]; + baseline?: Baseline[]; + metadata?: BaselineMetadataValue[]; +} + +/** + * @class + * Initializes a new instance of the TimeSeriesInformation class. + * @constructor + * The time series info needed for calculating the baseline. + * + * @member {array} sensitivities the list of sensitivities for calculating the + * baseline. + * @member {array} values The metric values to calculate the baseline. + * @member {array} [timestamps] the array of timestamps of the baselines. + */ +export interface TimeSeriesInformation { + sensitivities: string[]; + values: number[]; + timestamps?: Date[]; +} + +/** + * @class + * Initializes a new instance of the CalculateBaselineResponse class. + * @constructor + * The response to a calcualte baseline call. + * + * @member {string} type the resource type of the baseline resource. + * @member {array} [timestamps] the array of timestamps of the baselines. + * @member {array} baseline the baseline values for each sensitivity. + */ +export interface CalculateBaselineResponse { + type: string; + timestamps?: Date[]; + baseline: Baseline[]; +} + +/** + * @class + * Initializes a new instance of the Action class. + * @constructor + * An alert action. + * + * @member {string} [actionGroupId] the id of the action group to use. + * @member {object} [webhookProperties] + */ +export interface Action { + actionGroupId?: string; + webhookProperties?: { [propertyName: string]: string }; +} + +/** + * @class + * Initializes a new instance of the MetricAlertCriteria class. + * @constructor + * The rule criteria that defines the conditions of the alert rule. + * + * @member {string} odatatype Polymorphic Discriminator + */ +export interface MetricAlertCriteria { + odatatype: string; + /** + * @property Describes unknown properties. The value of an unknown property + * can be of "any" type. + */ + [property: string]: any; +} + +/** + * @class + * Initializes a new instance of the MetricAlertResource class. + * @constructor + * The metric alert resource. + * + * @member {string} description the description of the metric alert that will + * be included in the alert email. + * @member {number} severity Alert severity {0, 1, 2, 3, 4} + * @member {boolean} enabled the flag that indicates whether the metric alert + * is enabled. + * @member {array} [scopes] the list of resource id's that this metric alert is + * scoped to. + * @member {moment.duration} evaluationFrequency how often the metric alert is + * evaluated represented in ISO 8601 duration format. + * @member {moment.duration} windowSize the period of time (in ISO 8601 + * duration format) that is used to monitor alert activity based on the + * threshold. + * @member {object} criteria defines the specific alert criteria information. + * @member {string} [criteria.odatatype] Polymorphic Discriminator + * @member {array} [actions] the array of actions that are performed when the + * alert rule becomes active, and when an alert condition is resolved. + * @member {date} [lastUpdatedTime] Last time the rule was updated in ISO8601 + * format. + */ +export interface MetricAlertResource extends Resource { + description: string; + severity: number; + enabled: boolean; + scopes?: string[]; + evaluationFrequency: moment.Duration; + windowSize: moment.Duration; + criteria: MetricAlertCriteria; + actions?: Action[]; + readonly lastUpdatedTime?: Date; +} + +/** + * @class + * Initializes a new instance of the MetricAlertResourcePatch class. + * @constructor + * The metric alert resource for patch operations. + * + * @member {object} [tags] Resource tags + * @member {string} description the description of the metric alert that will + * be included in the alert email. + * @member {number} severity Alert severity {0, 1, 2, 3, 4} + * @member {boolean} enabled the flag that indicates whether the metric alert + * is enabled. + * @member {array} [scopes] the list of resource id's that this metric alert is + * scoped to. + * @member {moment.duration} evaluationFrequency how often the metric alert is + * evaluated represented in ISO 8601 duration format. + * @member {moment.duration} windowSize the period of time (in ISO 8601 + * duration format) that is used to monitor alert activity based on the + * threshold. + * @member {object} criteria defines the specific alert criteria information. + * @member {string} [criteria.odatatype] Polymorphic Discriminator + * @member {array} [actions] the array of actions that are performed when the + * alert rule becomes active, and when an alert condition is resolved. + * @member {date} [lastUpdatedTime] Last time the rule was updated in ISO8601 + * format. + */ +export interface MetricAlertResourcePatch { + tags?: { [propertyName: string]: string }; + description: string; + severity: number; + enabled: boolean; + scopes?: string[]; + evaluationFrequency: moment.Duration; + windowSize: moment.Duration; + criteria: MetricAlertCriteria; + actions?: Action[]; + readonly lastUpdatedTime?: Date; +} + +/** + * @class + * Initializes a new instance of the MetricAlertStatusProperties class. + * @constructor + * An alert status properties. + * + * @member {object} [dimensions] + * @member {string} [status] status value + * @member {date} [timestamp] UTC time when the status was checked. + */ +export interface MetricAlertStatusProperties { + dimensions?: { [propertyName: string]: string }; + status?: string; + timestamp?: Date; +} + +/** + * @class + * Initializes a new instance of the MetricAlertStatus class. + * @constructor + * An alert status. + * + * @member {string} [name] The status name. + * @member {string} [id] The alert rule arm id. + * @member {string} [type] The extended resource type name. + * @member {object} [properties] The alert status properties of the metric + * alert status. + * @member {object} [properties.dimensions] + * @member {string} [properties.status] status value + * @member {date} [properties.timestamp] UTC time when the status was checked. + */ +export interface MetricAlertStatus { + name?: string; + id?: string; + type?: string; + properties?: MetricAlertStatusProperties; +} + +/** + * @class + * Initializes a new instance of the MetricAlertStatusCollection class. + * @constructor + * Represents a collection of alert rule resources. + * + * @member {array} [value] the values for the alert rule resources. + */ +export interface MetricAlertStatusCollection { + value?: MetricAlertStatus[]; +} + +/** + * @class + * Initializes a new instance of the MetricDimension class. + * @constructor + * @member {string} name Name of the dimension. + * @member {string} operator the dimension operator. + * @member {array} values list of dimension values. + */ +export interface MetricDimension { + name: string; + operator: string; + values: string[]; +} + +/** + * @class + * Initializes a new instance of the MetricCriteria class. + * @constructor + * @member {string} name Name of the criteria. + * @member {string} metricName Name of the metric. + * @member {string} [metricNamespace] Namespace of the metric. + * @member {object} operator the criteria operator. + * @member {object} timeAggregation the criteria time aggregation types. + * @member {number} threshold the criteria threshold value that activates the + * alert. + * @member {array} [dimensions] List of dimension conditions. + */ +export interface MetricCriteria { + name: string; + metricName: string; + metricNamespace?: string; + operator: any; + timeAggregation: any; + threshold: number; + dimensions?: MetricDimension[]; +} + +/** + * @class + * Initializes a new instance of the MetricAlertSingleResourceMultipleMetricCriteria class. + * @constructor + * Specifies the metric alert criteria for a single resource that has multiple + * metric criteria. + * + * @member {array} [allOf] The list of metric criteria for this 'all of' + * operation. + */ +export interface MetricAlertSingleResourceMultipleMetricCriteria extends MetricAlertCriteria { + allOf?: MetricCriteria[]; +} + + +/** + * @class + * Initializes a new instance of the AutoscaleSettingResourceCollection class. + * @constructor + * Represents a collection of autoscale setting resources. + * + * @member {string} [nextLink] URL to get the next set of results. + */ +export interface AutoscaleSettingResourceCollection extends Array { + nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the IncidentListResult class. + * @constructor + * The List incidents operation response. + * + */ +export interface IncidentListResult extends Array { +} + +/** + * @class + * Initializes a new instance of the AlertRuleResourceCollection class. + * @constructor + * Represents a collection of alert rule resources. + * + */ +export interface AlertRuleResourceCollection extends Array { +} + +/** + * @class + * Initializes a new instance of the LogProfileCollection class. + * @constructor + * Represents a collection of log profiles. + * + */ +export interface LogProfileCollection extends Array { +} + +/** + * @class + * Initializes a new instance of the ActionGroupList class. + * @constructor + * A list of action groups. + * + * @member {string} [nextLink] Provides the link to retrieve the next set of + * elements. + */ +export interface ActionGroupList extends Array { + nextLink?: string; +} /** * @class - * Initializes a new instance of the UsageMetricCollection class. + * Initializes a new instance of the ActivityLogAlertList class. * @constructor - * Represents collection of usage metrics. + * A list of activity log alerts. * + * @member {string} [nextLink] Provides the link to retrieve the next set of + * elements. */ -export interface UsageMetricCollection extends Array { +export interface ActivityLogAlertList extends Array { + nextLink?: string; } /** @@ -429,3 +2222,13 @@ export interface EventCategoryCollection extends Array { */ export interface MetricDefinitionCollection extends Array { } + +/** + * @class + * Initializes a new instance of the MetricAlertResourceCollection class. + * @constructor + * Represents a collection of alert rule resources. + * + */ +export interface MetricAlertResourceCollection extends Array { +} diff --git a/lib/services/monitor/lib/models/index.js b/lib/services/monitor/lib/models/index.js index d1f9b2dc75..ebcc3e656b 100644 --- a/lib/services/monitor/lib/models/index.js +++ b/lib/services/monitor/lib/models/index.js @@ -18,9 +18,65 @@ var msRestAzure = require('ms-rest-azure'); exports.BaseResource = msRestAzure.BaseResource; exports.CloudError = msRestAzure.CloudError; -exports.LocalizableString = require('./localizableString'); -exports.UsageMetric = require('./usageMetric'); +exports.Resource = require('./resource'); +exports.ScaleCapacity = require('./scaleCapacity'); +exports.MetricTrigger = require('./metricTrigger'); +exports.ScaleAction = require('./scaleAction'); +exports.ScaleRule = require('./scaleRule'); +exports.TimeWindow = require('./timeWindow'); +exports.RecurrentSchedule = require('./recurrentSchedule'); +exports.Recurrence = require('./recurrence'); +exports.AutoscaleProfile = require('./autoscaleProfile'); +exports.EmailNotification = require('./emailNotification'); +exports.WebhookNotification = require('./webhookNotification'); +exports.AutoscaleNotification = require('./autoscaleNotification'); +exports.AutoscaleSettingResource = require('./autoscaleSettingResource'); +exports.AutoscaleSettingResourcePatch = require('./autoscaleSettingResourcePatch'); exports.ErrorResponse = require('./errorResponse'); +exports.OperationDisplay = require('./operationDisplay'); +exports.Operation = require('./operation'); +exports.OperationListResult = require('./operationListResult'); +exports.Incident = require('./incident'); +exports.RuleDataSource = require('./ruleDataSource'); +exports.RuleCondition = require('./ruleCondition'); +exports.RuleMetricDataSource = require('./ruleMetricDataSource'); +exports.RuleManagementEventClaimsDataSource = require('./ruleManagementEventClaimsDataSource'); +exports.RuleManagementEventDataSource = require('./ruleManagementEventDataSource'); +exports.ThresholdRuleCondition = require('./thresholdRuleCondition'); +exports.LocationThresholdRuleCondition = require('./locationThresholdRuleCondition'); +exports.ManagementEventAggregationCondition = require('./managementEventAggregationCondition'); +exports.ManagementEventRuleCondition = require('./managementEventRuleCondition'); +exports.RuleAction = require('./ruleAction'); +exports.RuleEmailAction = require('./ruleEmailAction'); +exports.RuleWebhookAction = require('./ruleWebhookAction'); +exports.AlertRuleResource = require('./alertRuleResource'); +exports.AlertRuleResourcePatch = require('./alertRuleResourcePatch'); +exports.RetentionPolicy = require('./retentionPolicy'); +exports.LogProfileResource = require('./logProfileResource'); +exports.LogProfileResourcePatch = require('./logProfileResourcePatch'); +exports.ProxyOnlyResource = require('./proxyOnlyResource'); +exports.MetricSettings = require('./metricSettings'); +exports.LogSettings = require('./logSettings'); +exports.DiagnosticSettingsResource = require('./diagnosticSettingsResource'); +exports.DiagnosticSettingsResourceCollection = require('./diagnosticSettingsResourceCollection'); +exports.DiagnosticSettingsCategoryResource = require('./diagnosticSettingsCategoryResource'); +exports.DiagnosticSettingsCategoryResourceCollection = require('./diagnosticSettingsCategoryResourceCollection'); +exports.EmailReceiver = require('./emailReceiver'); +exports.SmsReceiver = require('./smsReceiver'); +exports.WebhookReceiver = require('./webhookReceiver'); +exports.ItsmReceiver = require('./itsmReceiver'); +exports.AzureAppPushReceiver = require('./azureAppPushReceiver'); +exports.AutomationRunbookReceiver = require('./automationRunbookReceiver'); +exports.ActionGroupResource = require('./actionGroupResource'); +exports.EnableRequest = require('./enableRequest'); +exports.ActionGroupPatchBody = require('./actionGroupPatchBody'); +exports.ActivityLogAlertLeafCondition = require('./activityLogAlertLeafCondition'); +exports.ActivityLogAlertAllOfCondition = require('./activityLogAlertAllOfCondition'); +exports.ActivityLogAlertActionGroup = require('./activityLogAlertActionGroup'); +exports.ActivityLogAlertActionList = require('./activityLogAlertActionList'); +exports.ActivityLogAlertResource = require('./activityLogAlertResource'); +exports.ActivityLogAlertPatchBody = require('./activityLogAlertPatchBody'); +exports.LocalizableString = require('./localizableString'); exports.SenderAuthorization = require('./senderAuthorization'); exports.HttpRequestInfo = require('./httpRequestInfo'); exports.EventData = require('./eventData'); @@ -31,7 +87,42 @@ exports.MetadataValue = require('./metadataValue'); exports.TimeSeriesElement = require('./timeSeriesElement'); exports.Metric = require('./metric'); exports.Response = require('./response'); -exports.UsageMetricCollection = require('./usageMetricCollection'); +exports.BaselineMetadataValue = require('./baselineMetadataValue'); +exports.Baseline = require('./baseline'); +exports.BaselineResponse = require('./baselineResponse'); +exports.TimeSeriesInformation = require('./timeSeriesInformation'); +exports.CalculateBaselineResponse = require('./calculateBaselineResponse'); +exports.Action = require('./action'); +exports.MetricAlertCriteria = require('./metricAlertCriteria'); +exports.MetricAlertResource = require('./metricAlertResource'); +exports.MetricAlertResourcePatch = require('./metricAlertResourcePatch'); +exports.MetricAlertStatusProperties = require('./metricAlertStatusProperties'); +exports.MetricAlertStatus = require('./metricAlertStatus'); +exports.MetricAlertStatusCollection = require('./metricAlertStatusCollection'); +exports.MetricDimension = require('./metricDimension'); +exports.MetricCriteria = require('./metricCriteria'); +exports.MetricAlertSingleResourceMultipleMetricCriteria = require('./metricAlertSingleResourceMultipleMetricCriteria'); +exports.AutoscaleSettingResourceCollection = require('./autoscaleSettingResourceCollection'); +exports.IncidentListResult = require('./incidentListResult'); +exports.AlertRuleResourceCollection = require('./alertRuleResourceCollection'); +exports.LogProfileCollection = require('./logProfileCollection'); +exports.ActionGroupList = require('./actionGroupList'); +exports.ActivityLogAlertList = require('./activityLogAlertList'); exports.EventDataCollection = require('./eventDataCollection'); exports.EventCategoryCollection = require('./eventCategoryCollection'); exports.MetricDefinitionCollection = require('./metricDefinitionCollection'); +exports.MetricAlertResourceCollection = require('./metricAlertResourceCollection'); +exports.discriminators = { + 'RuleDataSource' : exports.RuleDataSource, + 'RuleCondition' : exports.RuleCondition, + 'RuleDataSource.Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' : exports.RuleMetricDataSource, + 'RuleDataSource.Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' : exports.RuleManagementEventDataSource, + 'RuleCondition.Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' : exports.ThresholdRuleCondition, + 'RuleCondition.Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' : exports.LocationThresholdRuleCondition, + 'RuleCondition.Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' : exports.ManagementEventRuleCondition, + 'RuleAction' : exports.RuleAction, + 'RuleAction.Microsoft.Azure.Management.Insights.Models.RuleEmailAction' : exports.RuleEmailAction, + 'RuleAction.Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' : exports.RuleWebhookAction, + 'MetricAlertCriteria' : exports.MetricAlertCriteria, + 'MetricAlertCriteria.Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' : exports.MetricAlertSingleResourceMultipleMetricCriteria +}; diff --git a/lib/services/monitor/lib/models/itsmReceiver.js b/lib/services/monitor/lib/models/itsmReceiver.js new file mode 100644 index 0000000000..a46c94b4d3 --- /dev/null +++ b/lib/services/monitor/lib/models/itsmReceiver.js @@ -0,0 +1,89 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An Itsm receiver. + * + */ +class ItsmReceiver { + /** + * Create a ItsmReceiver. + * @member {string} name The name of the Itsm receiver. Names must be unique + * across all receivers within an action group. + * @member {string} workspaceId OMS LA instance identifier. + * @member {string} connectionId Unique identification of ITSM connection + * among multiple defined in above workspace. + * @member {string} ticketConfiguration JSON blob for the configurations of + * the ITSM action. CreateMultipleWorkItems option will be part of this blob + * as well. + * @member {string} region Region in which workspace resides. Supported + * values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope' + */ + constructor() { + } + + /** + * Defines the metadata of ItsmReceiver + * + * @returns {object} metadata of ItsmReceiver + * + */ + mapper() { + return { + required: false, + serializedName: 'ItsmReceiver', + type: { + name: 'Composite', + className: 'ItsmReceiver', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + workspaceId: { + required: true, + serializedName: 'workspaceId', + type: { + name: 'String' + } + }, + connectionId: { + required: true, + serializedName: 'connectionId', + type: { + name: 'String' + } + }, + ticketConfiguration: { + required: true, + serializedName: 'ticketConfiguration', + type: { + name: 'String' + } + }, + region: { + required: true, + serializedName: 'region', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ItsmReceiver; diff --git a/lib/services/monitor/lib/models/locationThresholdRuleCondition.js b/lib/services/monitor/lib/models/locationThresholdRuleCondition.js new file mode 100644 index 0000000000..c432f200c8 --- /dev/null +++ b/lib/services/monitor/lib/models/locationThresholdRuleCondition.js @@ -0,0 +1,96 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A rule condition based on a certain number of locations failing. + * + * @extends models['RuleCondition'] + */ +class LocationThresholdRuleCondition extends models['RuleCondition'] { + /** + * Create a LocationThresholdRuleCondition. + * @member {moment.duration} [windowSize] the period of time (in ISO 8601 + * duration format) that is used to monitor alert activity based on the + * threshold. If specified then it must be between 5 minutes and 1 day. + * @member {number} failedLocationCount the number of locations that must + * fail to activate the alert. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of LocationThresholdRuleCondition + * + * @returns {object} metadata of LocationThresholdRuleCondition + * + */ + mapper() { + return { + required: false, + serializedName: 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleCondition', + className: 'LocationThresholdRuleCondition', + modelProperties: { + dataSource: { + required: false, + serializedName: 'dataSource', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleDataSource', + className: 'RuleDataSource' + } + }, + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + windowSize: { + required: false, + serializedName: 'windowSize', + type: { + name: 'TimeSpan' + } + }, + failedLocationCount: { + required: true, + serializedName: 'failedLocationCount', + constraints: { + InclusiveMinimum: 0 + }, + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = LocationThresholdRuleCondition; diff --git a/lib/services/monitor/lib/models/logProfileCollection.js b/lib/services/monitor/lib/models/logProfileCollection.js new file mode 100644 index 0000000000..d2530db617 --- /dev/null +++ b/lib/services/monitor/lib/models/logProfileCollection.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Represents a collection of log profiles. + */ +class LogProfileCollection extends Array { + /** + * Create a LogProfileCollection. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of LogProfileCollection + * + * @returns {object} metadata of LogProfileCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'LogProfileCollection', + type: { + name: 'Composite', + className: 'LogProfileCollection', + modelProperties: { + value: { + required: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'LogProfileResourceElementType', + type: { + name: 'Composite', + className: 'LogProfileResource' + } + } + } + } + } + } + }; + } +} + +module.exports = LogProfileCollection; diff --git a/lib/services/monitor/lib/models/logProfileResource.js b/lib/services/monitor/lib/models/logProfileResource.js new file mode 100644 index 0000000000..69a8f54034 --- /dev/null +++ b/lib/services/monitor/lib/models/logProfileResource.js @@ -0,0 +1,161 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The log profile resource. + * + * @extends models['Resource'] + */ +class LogProfileResource extends models['Resource'] { + /** + * Create a LogProfileResource. + * @member {string} [storageAccountId] the resource id of the storage account + * to which you would like to send the Activity Log. + * @member {string} [serviceBusRuleId] The service bus rule ID of the service + * bus namespace in which you would like to have Event Hubs created for + * streaming the Activity Log. The rule ID is of the format: '{service bus + * resource ID}/authorizationrules/{key name}'. + * @member {array} locations List of regions for which Activity Log events + * should be stored or streamed. It is a comma separated list of valid ARM + * locations including the 'global' location. + * @member {array} categories the categories of the logs. These categories + * are created as is convenient to the user. Some values are: 'Write', + * 'Delete', and/or 'Action.' + * @member {object} retentionPolicy the retention policy for the events in + * the log. + * @member {boolean} [retentionPolicy.enabled] a value indicating whether the + * retention policy is enabled. + * @member {number} [retentionPolicy.days] the number of days for the + * retention in days. A value of 0 will retain the events indefinitely. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of LogProfileResource + * + * @returns {object} metadata of LogProfileResource + * + */ + mapper() { + return { + required: false, + serializedName: 'LogProfileResource', + type: { + name: 'Composite', + className: 'LogProfileResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + storageAccountId: { + required: false, + serializedName: 'properties.storageAccountId', + type: { + name: 'String' + } + }, + serviceBusRuleId: { + required: false, + serializedName: 'properties.serviceBusRuleId', + type: { + name: 'String' + } + }, + locations: { + required: true, + serializedName: 'properties.locations', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + categories: { + required: true, + serializedName: 'properties.categories', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + retentionPolicy: { + required: true, + serializedName: 'properties.retentionPolicy', + type: { + name: 'Composite', + className: 'RetentionPolicy' + } + } + } + } + }; + } +} + +module.exports = LogProfileResource; diff --git a/lib/services/monitor/lib/models/logProfileResourcePatch.js b/lib/services/monitor/lib/models/logProfileResourcePatch.js new file mode 100644 index 0000000000..f9b2822b45 --- /dev/null +++ b/lib/services/monitor/lib/models/logProfileResourcePatch.js @@ -0,0 +1,129 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The log profile resource for patch operations. + * + */ +class LogProfileResourcePatch { + /** + * Create a LogProfileResourcePatch. + * @member {object} [tags] Resource tags + * @member {string} [storageAccountId] the resource id of the storage account + * to which you would like to send the Activity Log. + * @member {string} [serviceBusRuleId] The service bus rule ID of the service + * bus namespace in which you would like to have Event Hubs created for + * streaming the Activity Log. The rule ID is of the format: '{service bus + * resource ID}/authorizationrules/{key name}'. + * @member {array} locations List of regions for which Activity Log events + * should be stored or streamed. It is a comma separated list of valid ARM + * locations including the 'global' location. + * @member {array} categories the categories of the logs. These categories + * are created as is convenient to the user. Some values are: 'Write', + * 'Delete', and/or 'Action.' + * @member {object} retentionPolicy the retention policy for the events in + * the log. + * @member {boolean} [retentionPolicy.enabled] a value indicating whether the + * retention policy is enabled. + * @member {number} [retentionPolicy.days] the number of days for the + * retention in days. A value of 0 will retain the events indefinitely. + */ + constructor() { + } + + /** + * Defines the metadata of LogProfileResourcePatch + * + * @returns {object} metadata of LogProfileResourcePatch + * + */ + mapper() { + return { + required: false, + serializedName: 'LogProfileResourcePatch', + type: { + name: 'Composite', + className: 'LogProfileResourcePatch', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + storageAccountId: { + required: false, + serializedName: 'properties.storageAccountId', + type: { + name: 'String' + } + }, + serviceBusRuleId: { + required: false, + serializedName: 'properties.serviceBusRuleId', + type: { + name: 'String' + } + }, + locations: { + required: true, + serializedName: 'properties.locations', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + categories: { + required: true, + serializedName: 'properties.categories', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + retentionPolicy: { + required: true, + serializedName: 'properties.retentionPolicy', + type: { + name: 'Composite', + className: 'RetentionPolicy' + } + } + } + } + }; + } +} + +module.exports = LogProfileResourcePatch; diff --git a/lib/services/monitor/lib/models/logSettings.js b/lib/services/monitor/lib/models/logSettings.js new file mode 100644 index 0000000000..de7aa7b6c6 --- /dev/null +++ b/lib/services/monitor/lib/models/logSettings.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Part of MultiTenantDiagnosticSettings. Specifies the settings for a + * particular log. + * + */ +class LogSettings { + /** + * Create a LogSettings. + * @member {string} [category] Name of a Diagnostic Log category for a + * resource type this setting is applied to. To obtain the list of Diagnostic + * Log categories for a resource, first perform a GET diagnostic settings + * operation. + * @member {boolean} enabled a value indicating whether this log is enabled. + * @member {object} [retentionPolicy] the retention policy for this log. + * @member {boolean} [retentionPolicy.enabled] a value indicating whether the + * retention policy is enabled. + * @member {number} [retentionPolicy.days] the number of days for the + * retention in days. A value of 0 will retain the events indefinitely. + */ + constructor() { + } + + /** + * Defines the metadata of LogSettings + * + * @returns {object} metadata of LogSettings + * + */ + mapper() { + return { + required: false, + serializedName: 'LogSettings', + type: { + name: 'Composite', + className: 'LogSettings', + modelProperties: { + category: { + required: false, + serializedName: 'category', + type: { + name: 'String' + } + }, + enabled: { + required: true, + serializedName: 'enabled', + type: { + name: 'Boolean' + } + }, + retentionPolicy: { + required: false, + serializedName: 'retentionPolicy', + type: { + name: 'Composite', + className: 'RetentionPolicy' + } + } + } + } + }; + } +} + +module.exports = LogSettings; diff --git a/lib/services/monitor/lib/models/managementEventAggregationCondition.js b/lib/services/monitor/lib/models/managementEventAggregationCondition.js new file mode 100644 index 0000000000..29aa3f55f9 --- /dev/null +++ b/lib/services/monitor/lib/models/managementEventAggregationCondition.js @@ -0,0 +1,73 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * How the data that is collected should be combined over time. + * + */ +class ManagementEventAggregationCondition { + /** + * Create a ManagementEventAggregationCondition. + * @member {string} [operator] the condition operator. Possible values + * include: 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + * 'LessThanOrEqual' + * @member {number} [threshold] The threshold value that activates the alert. + * @member {moment.duration} [windowSize] the period of time (in ISO 8601 + * duration format) that is used to monitor alert activity based on the + * threshold. If specified then it must be between 5 minutes and 1 day. + */ + constructor() { + } + + /** + * Defines the metadata of ManagementEventAggregationCondition + * + * @returns {object} metadata of ManagementEventAggregationCondition + * + */ + mapper() { + return { + required: false, + serializedName: 'ManagementEventAggregationCondition', + type: { + name: 'Composite', + className: 'ManagementEventAggregationCondition', + modelProperties: { + operator: { + required: false, + serializedName: 'operator', + type: { + name: 'Enum', + allowedValues: [ 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' ] + } + }, + threshold: { + required: false, + serializedName: 'threshold', + type: { + name: 'Number' + } + }, + windowSize: { + required: false, + serializedName: 'windowSize', + type: { + name: 'TimeSpan' + } + } + } + } + }; + } +} + +module.exports = ManagementEventAggregationCondition; diff --git a/lib/services/monitor/lib/models/managementEventRuleCondition.js b/lib/services/monitor/lib/models/managementEventRuleCondition.js new file mode 100644 index 0000000000..d06bfc5742 --- /dev/null +++ b/lib/services/monitor/lib/models/managementEventRuleCondition.js @@ -0,0 +1,94 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A management event rule condition. + * + * @extends models['RuleCondition'] + */ +class ManagementEventRuleCondition extends models['RuleCondition'] { + /** + * Create a ManagementEventRuleCondition. + * @member {object} [aggregation] How the data that is collected should be + * combined over time and when the alert is activated. Note that for + * management event alerts aggregation is optional – if it is not provided + * then any event will cause the alert to activate. + * @member {string} [aggregation.operator] the condition operator. Possible + * values include: 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + * 'LessThanOrEqual' + * @member {number} [aggregation.threshold] The threshold value that + * activates the alert. + * @member {moment.duration} [aggregation.windowSize] the period of time (in + * ISO 8601 duration format) that is used to monitor alert activity based on + * the threshold. If specified then it must be between 5 minutes and 1 day. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ManagementEventRuleCondition + * + * @returns {object} metadata of ManagementEventRuleCondition + * + */ + mapper() { + return { + required: false, + serializedName: 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleCondition', + className: 'ManagementEventRuleCondition', + modelProperties: { + dataSource: { + required: false, + serializedName: 'dataSource', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleDataSource', + className: 'RuleDataSource' + } + }, + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + aggregation: { + required: false, + serializedName: 'aggregation', + type: { + name: 'Composite', + className: 'ManagementEventAggregationCondition' + } + } + } + } + }; + } +} + +module.exports = ManagementEventRuleCondition; diff --git a/lib/services/monitor/lib/models/metricAlertCriteria.js b/lib/services/monitor/lib/models/metricAlertCriteria.js new file mode 100644 index 0000000000..1a423dbb2d --- /dev/null +++ b/lib/services/monitor/lib/models/metricAlertCriteria.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The rule criteria that defines the conditions of the alert rule. + * + */ +class MetricAlertCriteria { + /** + * Create a MetricAlertCriteria. + * @member {string} odatatype Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of MetricAlertCriteria + * + * @returns {object} metadata of MetricAlertCriteria + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricAlertCriteria', + type: { + name: 'Composite', + additionalProperties: { + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'ObjectElementType', + type: { + name: 'Object' + } + } + } + }, + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'MetricAlertCriteria', + className: 'MetricAlertCriteria', + modelProperties: { + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = MetricAlertCriteria; diff --git a/lib/services/monitor/lib/models/metricAlertResource.js b/lib/services/monitor/lib/models/metricAlertResource.js new file mode 100644 index 0000000000..c21174220c --- /dev/null +++ b/lib/services/monitor/lib/models/metricAlertResource.js @@ -0,0 +1,208 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The metric alert resource. + * + * @extends models['Resource'] + */ +class MetricAlertResource extends models['Resource'] { + /** + * Create a MetricAlertResource. + * @member {string} description the description of the metric alert that will + * be included in the alert email. + * @member {number} severity Alert severity {0, 1, 2, 3, 4} + * @member {boolean} enabled the flag that indicates whether the metric alert + * is enabled. + * @member {array} [scopes] the list of resource id's that this metric alert + * is scoped to. + * @member {moment.duration} evaluationFrequency how often the metric alert + * is evaluated represented in ISO 8601 duration format. + * @member {moment.duration} windowSize the period of time (in ISO 8601 + * duration format) that is used to monitor alert activity based on the + * threshold. + * @member {object} criteria defines the specific alert criteria information. + * @member {string} [criteria.odatatype] Polymorphic Discriminator + * @member {array} [actions] the array of actions that are performed when the + * alert rule becomes active, and when an alert condition is resolved. + * @member {date} [lastUpdatedTime] Last time the rule was updated in ISO8601 + * format. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of MetricAlertResource + * + * @returns {object} metadata of MetricAlertResource + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricAlertResource', + type: { + name: 'Composite', + className: 'MetricAlertResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + description: { + required: true, + serializedName: 'properties.description', + type: { + name: 'String' + } + }, + severity: { + required: true, + serializedName: 'properties.severity', + type: { + name: 'Number' + } + }, + enabled: { + required: true, + serializedName: 'properties.enabled', + type: { + name: 'Boolean' + } + }, + scopes: { + required: false, + serializedName: 'properties.scopes', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + evaluationFrequency: { + required: true, + serializedName: 'properties.evaluationFrequency', + type: { + name: 'TimeSpan' + } + }, + windowSize: { + required: true, + serializedName: 'properties.windowSize', + type: { + name: 'TimeSpan' + } + }, + criteria: { + required: true, + serializedName: 'properties.criteria', + type: { + name: 'Composite', + additionalProperties: { + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'ObjectElementType', + type: { + name: 'Object' + } + } + } + }, + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'MetricAlertCriteria', + className: 'MetricAlertCriteria' + } + }, + actions: { + required: false, + serializedName: 'properties.actions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + className: 'Action' + } + } + } + }, + lastUpdatedTime: { + required: false, + readOnly: true, + serializedName: 'properties.lastUpdatedTime', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = MetricAlertResource; diff --git a/lib/services/monitor/lib/models/metricAlertResourceCollection.js b/lib/services/monitor/lib/models/metricAlertResourceCollection.js new file mode 100644 index 0000000000..4e54250e8c --- /dev/null +++ b/lib/services/monitor/lib/models/metricAlertResourceCollection.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Represents a collection of alert rule resources. + */ +class MetricAlertResourceCollection extends Array { + /** + * Create a MetricAlertResourceCollection. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of MetricAlertResourceCollection + * + * @returns {object} metadata of MetricAlertResourceCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricAlertResourceCollection', + type: { + name: 'Composite', + className: 'MetricAlertResourceCollection', + modelProperties: { + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'MetricAlertResourceElementType', + type: { + name: 'Composite', + className: 'MetricAlertResource' + } + } + } + } + } + } + }; + } +} + +module.exports = MetricAlertResourceCollection; diff --git a/lib/services/monitor/lib/models/metricAlertResourcePatch.js b/lib/services/monitor/lib/models/metricAlertResourcePatch.js new file mode 100644 index 0000000000..1832373f2d --- /dev/null +++ b/lib/services/monitor/lib/models/metricAlertResourcePatch.js @@ -0,0 +1,176 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The metric alert resource for patch operations. + * + */ +class MetricAlertResourcePatch { + /** + * Create a MetricAlertResourcePatch. + * @member {object} [tags] Resource tags + * @member {string} description the description of the metric alert that will + * be included in the alert email. + * @member {number} severity Alert severity {0, 1, 2, 3, 4} + * @member {boolean} enabled the flag that indicates whether the metric alert + * is enabled. + * @member {array} [scopes] the list of resource id's that this metric alert + * is scoped to. + * @member {moment.duration} evaluationFrequency how often the metric alert + * is evaluated represented in ISO 8601 duration format. + * @member {moment.duration} windowSize the period of time (in ISO 8601 + * duration format) that is used to monitor alert activity based on the + * threshold. + * @member {object} criteria defines the specific alert criteria information. + * @member {string} [criteria.odatatype] Polymorphic Discriminator + * @member {array} [actions] the array of actions that are performed when the + * alert rule becomes active, and when an alert condition is resolved. + * @member {date} [lastUpdatedTime] Last time the rule was updated in ISO8601 + * format. + */ + constructor() { + } + + /** + * Defines the metadata of MetricAlertResourcePatch + * + * @returns {object} metadata of MetricAlertResourcePatch + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricAlertResourcePatch', + type: { + name: 'Composite', + className: 'MetricAlertResourcePatch', + modelProperties: { + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + description: { + required: true, + serializedName: 'properties.description', + type: { + name: 'String' + } + }, + severity: { + required: true, + serializedName: 'properties.severity', + type: { + name: 'Number' + } + }, + enabled: { + required: true, + serializedName: 'properties.enabled', + type: { + name: 'Boolean' + } + }, + scopes: { + required: false, + serializedName: 'properties.scopes', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + evaluationFrequency: { + required: true, + serializedName: 'properties.evaluationFrequency', + type: { + name: 'TimeSpan' + } + }, + windowSize: { + required: true, + serializedName: 'properties.windowSize', + type: { + name: 'TimeSpan' + } + }, + criteria: { + required: true, + serializedName: 'properties.criteria', + type: { + name: 'Composite', + additionalProperties: { + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'ObjectElementType', + type: { + name: 'Object' + } + } + } + }, + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'MetricAlertCriteria', + className: 'MetricAlertCriteria' + } + }, + actions: { + required: false, + serializedName: 'properties.actions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + className: 'Action' + } + } + } + }, + lastUpdatedTime: { + required: false, + readOnly: true, + serializedName: 'properties.lastUpdatedTime', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = MetricAlertResourcePatch; diff --git a/lib/services/monitor/lib/models/metricAlertSingleResourceMultipleMetricCriteria.js b/lib/services/monitor/lib/models/metricAlertSingleResourceMultipleMetricCriteria.js new file mode 100644 index 0000000000..99a72bf055 --- /dev/null +++ b/lib/services/monitor/lib/models/metricAlertSingleResourceMultipleMetricCriteria.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Specifies the metric alert criteria for a single resource that has multiple + * metric criteria. + * + * @extends models['MetricAlertCriteria'] + */ +class MetricAlertSingleResourceMultipleMetricCriteria extends models['MetricAlertCriteria'] { + /** + * Create a MetricAlertSingleResourceMultipleMetricCriteria. + * @member {array} [allOf] The list of metric criteria for this 'all of' + * operation. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of MetricAlertSingleResourceMultipleMetricCriteria + * + * @returns {object} metadata of MetricAlertSingleResourceMultipleMetricCriteria + * + */ + mapper() { + return { + required: false, + serializedName: 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'MetricAlertCriteria', + className: 'MetricAlertSingleResourceMultipleMetricCriteria', + modelProperties: { + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + allOf: { + required: false, + serializedName: 'allOf', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'MetricCriteriaElementType', + type: { + name: 'Composite', + className: 'MetricCriteria' + } + } + } + } + } + } + }; + } +} + +module.exports = MetricAlertSingleResourceMultipleMetricCriteria; diff --git a/lib/services/monitor/lib/models/metricAlertStatus.js b/lib/services/monitor/lib/models/metricAlertStatus.js new file mode 100644 index 0000000000..6df29691be --- /dev/null +++ b/lib/services/monitor/lib/models/metricAlertStatus.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An alert status. + * + */ +class MetricAlertStatus { + /** + * Create a MetricAlertStatus. + * @member {string} [name] The status name. + * @member {string} [id] The alert rule arm id. + * @member {string} [type] The extended resource type name. + * @member {object} [properties] The alert status properties of the metric + * alert status. + * @member {object} [properties.dimensions] + * @member {string} [properties.status] status value + * @member {date} [properties.timestamp] UTC time when the status was + * checked. + */ + constructor() { + } + + /** + * Defines the metadata of MetricAlertStatus + * + * @returns {object} metadata of MetricAlertStatus + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricAlertStatus', + type: { + name: 'Composite', + className: 'MetricAlertStatus', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + id: { + required: false, + serializedName: 'id', + type: { + name: 'String' + } + }, + type: { + required: false, + serializedName: 'type', + type: { + name: 'String' + } + }, + properties: { + required: false, + serializedName: 'properties', + type: { + name: 'Composite', + className: 'MetricAlertStatusProperties' + } + } + } + } + }; + } +} + +module.exports = MetricAlertStatus; diff --git a/lib/services/monitor/lib/models/metricAlertStatusCollection.js b/lib/services/monitor/lib/models/metricAlertStatusCollection.js new file mode 100644 index 0000000000..e3679d730b --- /dev/null +++ b/lib/services/monitor/lib/models/metricAlertStatusCollection.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Represents a collection of alert rule resources. + * + */ +class MetricAlertStatusCollection { + /** + * Create a MetricAlertStatusCollection. + * @member {array} [value] the values for the alert rule resources. + */ + constructor() { + } + + /** + * Defines the metadata of MetricAlertStatusCollection + * + * @returns {object} metadata of MetricAlertStatusCollection + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricAlertStatusCollection', + type: { + name: 'Composite', + className: 'MetricAlertStatusCollection', + modelProperties: { + value: { + required: false, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'MetricAlertStatusElementType', + type: { + name: 'Composite', + className: 'MetricAlertStatus' + } + } + } + } + } + } + }; + } +} + +module.exports = MetricAlertStatusCollection; diff --git a/lib/services/monitor/lib/models/metricAlertStatusProperties.js b/lib/services/monitor/lib/models/metricAlertStatusProperties.js new file mode 100644 index 0000000000..b9581c6cda --- /dev/null +++ b/lib/services/monitor/lib/models/metricAlertStatusProperties.js @@ -0,0 +1,75 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An alert status properties. + * + */ +class MetricAlertStatusProperties { + /** + * Create a MetricAlertStatusProperties. + * @member {object} [dimensions] + * @member {string} [status] status value + * @member {date} [timestamp] UTC time when the status was checked. + */ + constructor() { + } + + /** + * Defines the metadata of MetricAlertStatusProperties + * + * @returns {object} metadata of MetricAlertStatusProperties + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricAlertStatusProperties', + type: { + name: 'Composite', + className: 'MetricAlertStatusProperties', + modelProperties: { + dimensions: { + required: false, + serializedName: 'dimensions', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + status: { + required: false, + serializedName: 'status', + type: { + name: 'String' + } + }, + timestamp: { + required: false, + serializedName: 'timestamp', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = MetricAlertStatusProperties; diff --git a/lib/services/monitor/lib/models/metricCriteria.js b/lib/services/monitor/lib/models/metricCriteria.js new file mode 100644 index 0000000000..19192dc18a --- /dev/null +++ b/lib/services/monitor/lib/models/metricCriteria.js @@ -0,0 +1,110 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Class representing a MetricCriteria. + */ +class MetricCriteria { + /** + * Create a MetricCriteria. + * @member {string} name Name of the criteria. + * @member {string} metricName Name of the metric. + * @member {string} [metricNamespace] Namespace of the metric. + * @member {object} operator the criteria operator. + * @member {object} timeAggregation the criteria time aggregation types. + * @member {number} threshold the criteria threshold value that activates the + * alert. + * @member {array} [dimensions] List of dimension conditions. + */ + constructor() { + } + + /** + * Defines the metadata of MetricCriteria + * + * @returns {object} metadata of MetricCriteria + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricCriteria', + type: { + name: 'Composite', + className: 'MetricCriteria', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + metricName: { + required: true, + serializedName: 'metricName', + type: { + name: 'String' + } + }, + metricNamespace: { + required: false, + serializedName: 'metricNamespace', + type: { + name: 'String' + } + }, + operator: { + required: true, + serializedName: 'operator', + type: { + name: 'Object' + } + }, + timeAggregation: { + required: true, + serializedName: 'timeAggregation', + type: { + name: 'Object' + } + }, + threshold: { + required: true, + serializedName: 'threshold', + type: { + name: 'Number' + } + }, + dimensions: { + required: false, + serializedName: 'dimensions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'MetricDimensionElementType', + type: { + name: 'Composite', + className: 'MetricDimension' + } + } + } + } + } + } + }; + } +} + +module.exports = MetricCriteria; diff --git a/lib/services/monitor/lib/models/metricDefinition.js b/lib/services/monitor/lib/models/metricDefinition.js index 45c43724f6..06e73cee86 100644 --- a/lib/services/monitor/lib/models/metricDefinition.js +++ b/lib/services/monitor/lib/models/metricDefinition.js @@ -23,6 +23,7 @@ class MetricDefinition { * dimension is required. * @member {string} [resourceId] the resource identifier of the resource that * emitted the metric. + * @member {string} [namespace] the namespace the metric blongs to. * @member {object} [name] the name and the display name of the metric, i.e. * it is a localizable string. * @member {string} [name.value] the invariant value. @@ -33,6 +34,8 @@ class MetricDefinition { * @member {string} [primaryAggregationType] the primary aggregation type * value defining how to use the values for display. Possible values include: * 'None', 'Average', 'Count', 'Minimum', 'Maximum', 'Total' + * @member {array} [supportedAggregationTypes] the collection of what + * aggregation types are supported. * @member {array} [metricAvailabilities] the collection of what aggregation * intervals are available to be queried. * @member {string} [id] the resource identifier of the metric definition. @@ -70,6 +73,13 @@ class MetricDefinition { name: 'String' } }, + namespace: { + required: false, + serializedName: 'namespace', + type: { + name: 'String' + } + }, name: { required: false, serializedName: 'name', @@ -94,6 +104,21 @@ class MetricDefinition { allowedValues: [ 'None', 'Average', 'Count', 'Minimum', 'Maximum', 'Total' ] } }, + supportedAggregationTypes: { + required: false, + serializedName: 'supportedAggregationTypes', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'AggregationTypeElementType', + type: { + name: 'Enum', + allowedValues: [ 'None', 'Average', 'Count', 'Minimum', 'Maximum', 'Total' ] + } + } + } + }, metricAvailabilities: { required: false, serializedName: 'metricAvailabilities', diff --git a/lib/services/monitor/lib/models/metricDimension.js b/lib/services/monitor/lib/models/metricDimension.js new file mode 100644 index 0000000000..4805da9870 --- /dev/null +++ b/lib/services/monitor/lib/models/metricDimension.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Class representing a MetricDimension. + */ +class MetricDimension { + /** + * Create a MetricDimension. + * @member {string} name Name of the dimension. + * @member {string} operator the dimension operator. + * @member {array} values list of dimension values. + */ + constructor() { + } + + /** + * Defines the metadata of MetricDimension + * + * @returns {object} metadata of MetricDimension + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricDimension', + type: { + name: 'Composite', + className: 'MetricDimension', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + operator: { + required: true, + serializedName: 'operator', + type: { + name: 'String' + } + }, + values: { + required: true, + serializedName: 'values', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = MetricDimension; diff --git a/lib/services/monitor/lib/models/metricSettings.js b/lib/services/monitor/lib/models/metricSettings.js new file mode 100644 index 0000000000..bdde9809ff --- /dev/null +++ b/lib/services/monitor/lib/models/metricSettings.js @@ -0,0 +1,89 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Part of MultiTenantDiagnosticSettings. Specifies the settings for a + * particular metric. + * + */ +class MetricSettings { + /** + * Create a MetricSettings. + * @member {moment.duration} [timeGrain] the timegrain of the metric in + * ISO8601 format. + * @member {string} [category] Name of a Diagnostic Metric category for a + * resource type this setting is applied to. To obtain the list of Diagnostic + * metric categories for a resource, first perform a GET diagnostic settings + * operation. + * @member {boolean} enabled a value indicating whether this category is + * enabled. + * @member {object} [retentionPolicy] the retention policy for this category. + * @member {boolean} [retentionPolicy.enabled] a value indicating whether the + * retention policy is enabled. + * @member {number} [retentionPolicy.days] the number of days for the + * retention in days. A value of 0 will retain the events indefinitely. + */ + constructor() { + } + + /** + * Defines the metadata of MetricSettings + * + * @returns {object} metadata of MetricSettings + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricSettings', + type: { + name: 'Composite', + className: 'MetricSettings', + modelProperties: { + timeGrain: { + required: false, + serializedName: 'timeGrain', + type: { + name: 'TimeSpan' + } + }, + category: { + required: false, + serializedName: 'category', + type: { + name: 'String' + } + }, + enabled: { + required: true, + serializedName: 'enabled', + type: { + name: 'Boolean' + } + }, + retentionPolicy: { + required: false, + serializedName: 'retentionPolicy', + type: { + name: 'Composite', + className: 'RetentionPolicy' + } + } + } + } + }; + } +} + +module.exports = MetricSettings; diff --git a/lib/services/monitor/lib/models/metricTrigger.js b/lib/services/monitor/lib/models/metricTrigger.js new file mode 100644 index 0000000000..09e76603e5 --- /dev/null +++ b/lib/services/monitor/lib/models/metricTrigger.js @@ -0,0 +1,125 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The trigger that results in a scaling action. + * + */ +class MetricTrigger { + /** + * Create a MetricTrigger. + * @member {string} metricName the name of the metric that defines what the + * rule monitors. + * @member {string} metricResourceUri the resource identifier of the resource + * the rule monitors. + * @member {moment.duration} timeGrain the granularity of metrics the rule + * monitors. Must be one of the predefined values returned from metric + * definitions for the metric. Must be between 12 hours and 1 minute. + * @member {string} statistic the metric statistic type. How the metrics from + * multiple instances are combined. Possible values include: 'Average', + * 'Min', 'Max', 'Sum' + * @member {moment.duration} timeWindow the range of time in which instance + * data is collected. This value must be greater than the delay in metric + * collection, which can vary from resource-to-resource. Must be between 12 + * hours and 5 minutes. + * @member {string} timeAggregation time aggregation type. How the data that + * is collected should be combined over time. The default value is Average. + * Possible values include: 'Average', 'Minimum', 'Maximum', 'Total', 'Count' + * @member {string} operator the operator that is used to compare the metric + * data and the threshold. Possible values include: 'Equals', 'NotEquals', + * 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' + * @member {number} threshold the threshold of the metric that triggers the + * scale action. + */ + constructor() { + } + + /** + * Defines the metadata of MetricTrigger + * + * @returns {object} metadata of MetricTrigger + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricTrigger', + type: { + name: 'Composite', + className: 'MetricTrigger', + modelProperties: { + metricName: { + required: true, + serializedName: 'metricName', + type: { + name: 'String' + } + }, + metricResourceUri: { + required: true, + serializedName: 'metricResourceUri', + type: { + name: 'String' + } + }, + timeGrain: { + required: true, + serializedName: 'timeGrain', + type: { + name: 'TimeSpan' + } + }, + statistic: { + required: true, + serializedName: 'statistic', + type: { + name: 'Enum', + allowedValues: [ 'Average', 'Min', 'Max', 'Sum' ] + } + }, + timeWindow: { + required: true, + serializedName: 'timeWindow', + type: { + name: 'TimeSpan' + } + }, + timeAggregation: { + required: true, + serializedName: 'timeAggregation', + type: { + name: 'Enum', + allowedValues: [ 'Average', 'Minimum', 'Maximum', 'Total', 'Count' ] + } + }, + operator: { + required: true, + serializedName: 'operator', + type: { + name: 'Enum', + allowedValues: [ 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' ] + } + }, + threshold: { + required: true, + serializedName: 'threshold', + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = MetricTrigger; diff --git a/lib/services/monitor/lib/models/operation.js b/lib/services/monitor/lib/models/operation.js new file mode 100644 index 0000000000..83a27ddcc0 --- /dev/null +++ b/lib/services/monitor/lib/models/operation.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Microsoft Insights API operation definition. + * + */ +class Operation { + /** + * Create a Operation. + * @member {string} [name] Operation name: {provider}/{resource}/{operation} + * @member {object} [display] Display metadata associated with the operation. + * @member {string} [display.provider] Service provider: Microsoft.Insights + * @member {string} [display.resource] Resource on which the operation is + * performed: AlertRules, Autoscale, etc. + * @member {string} [display.operation] Operation type: Read, write, delete, + * etc. + */ + constructor() { + } + + /** + * Defines the metadata of Operation + * + * @returns {object} metadata of Operation + * + */ + mapper() { + return { + required: false, + serializedName: 'Operation', + type: { + name: 'Composite', + className: 'Operation', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + display: { + required: false, + serializedName: 'display', + type: { + name: 'Composite', + className: 'OperationDisplay' + } + } + } + } + }; + } +} + +module.exports = Operation; diff --git a/lib/services/monitor/lib/models/operationDisplay.js b/lib/services/monitor/lib/models/operationDisplay.js new file mode 100644 index 0000000000..8e414a0a13 --- /dev/null +++ b/lib/services/monitor/lib/models/operationDisplay.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Display metadata associated with the operation. + * + */ +class OperationDisplay { + /** + * Create a OperationDisplay. + * @member {string} [provider] Service provider: Microsoft.Insights + * @member {string} [resource] Resource on which the operation is performed: + * AlertRules, Autoscale, etc. + * @member {string} [operation] Operation type: Read, write, delete, etc. + */ + constructor() { + } + + /** + * Defines the metadata of OperationDisplay + * + * @returns {object} metadata of OperationDisplay + * + */ + mapper() { + return { + required: false, + serializedName: 'Operation_display', + type: { + name: 'Composite', + className: 'OperationDisplay', + modelProperties: { + provider: { + required: false, + serializedName: 'provider', + type: { + name: 'String' + } + }, + resource: { + required: false, + serializedName: 'resource', + type: { + name: 'String' + } + }, + operation: { + required: false, + serializedName: 'operation', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationDisplay; diff --git a/lib/services/monitor/lib/models/operationListResult.js b/lib/services/monitor/lib/models/operationListResult.js new file mode 100644 index 0000000000..cad3161962 --- /dev/null +++ b/lib/services/monitor/lib/models/operationListResult.js @@ -0,0 +1,73 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Result of the request to list Microsoft.Insights operations. It contains a + * list of operations and a URL link to get the next set of results. + * + */ +class OperationListResult { + /** + * Create a OperationListResult. + * @member {array} [value] List of operations supported by the + * Microsoft.Insights provider. + * @member {string} [nextLink] URL to get the next set of operation list + * results if there are any. + */ + constructor() { + } + + /** + * Defines the metadata of OperationListResult + * + * @returns {object} metadata of OperationListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationListResult', + type: { + name: 'Composite', + className: 'OperationListResult', + modelProperties: { + value: { + required: false, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'OperationElementType', + type: { + name: 'Composite', + className: 'Operation' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationListResult; diff --git a/lib/services/monitor/lib/models/proxyOnlyResource.js b/lib/services/monitor/lib/models/proxyOnlyResource.js new file mode 100644 index 0000000000..768abba9af --- /dev/null +++ b/lib/services/monitor/lib/models/proxyOnlyResource.js @@ -0,0 +1,75 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A proxy only azure resource object + * + * @extends models['BaseResource'] + */ +class ProxyOnlyResource extends models['BaseResource'] { + /** + * Create a ProxyOnlyResource. + * @member {string} [id] Azure resource Id + * @member {string} [name] Azure resource name + * @member {string} [type] Azure resource type + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ProxyOnlyResource + * + * @returns {object} metadata of ProxyOnlyResource + * + */ + mapper() { + return { + required: false, + serializedName: 'ProxyOnlyResource', + type: { + name: 'Composite', + className: 'ProxyOnlyResource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ProxyOnlyResource; diff --git a/lib/services/monitor/lib/models/recurrence.js b/lib/services/monitor/lib/models/recurrence.js new file mode 100644 index 0000000000..cb2dddd1d5 --- /dev/null +++ b/lib/services/monitor/lib/models/recurrence.js @@ -0,0 +1,114 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The repeating times at which this profile begins. This element is not used + * if the FixedDate element is used. + * + */ +class Recurrence { + /** + * Create a Recurrence. + * @member {string} frequency the recurrence frequency. How often the + * schedule profile should take effect. This value must be Week, meaning each + * week will have the same set of profiles. Possible values include: 'None', + * 'Second', 'Minute', 'Hour', 'Day', 'Week', 'Month', 'Year' + * @member {object} schedule the scheduling constraints for when the profile + * begins. + * @member {string} [schedule.timeZone] the timezone for the hours of the + * profile. Some examples of valid timezones are: Dateline Standard Time, + * UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard + * Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain + * Standard Time (Mexico), Mountain Standard Time, Central America Standard + * Time, Central Standard Time, Central Standard Time (Mexico), Canada + * Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US + * Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, + * Atlantic Standard Time, Central Brazilian Standard Time, SA Western + * Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. + * South America Standard Time, Argentina Standard Time, SA Eastern Standard + * Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard + * Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde + * Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich + * Standard Time, W. Europe Standard Time, Central Europe Standard Time, + * Romance Standard Time, Central European Standard Time, W. Central Africa + * Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard + * Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, + * E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, + * Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, + * Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus + * Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + * Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia + * Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus + * Standard Time, Afghanistan Standard Time, West Asia Standard Time, + * Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + * Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, + * Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard + * Time, SE Asia Standard Time, North Asia Standard Time, China Standard + * Time, North Asia East Standard Time, Singapore Standard Time, W. Australia + * Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo + * Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia + * Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS + * Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, + * Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + * Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard + * Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard + * Time, Samoa Standard Time, Line Islands Standard Time + * @member {array} [schedule.days] the collection of days that the profile + * takes effect on. Possible values are Sunday through Saturday. + * @member {array} [schedule.hours] A collection of hours that the profile + * takes effect on. Values supported are 0 to 23 on the 24-hour clock (AM/PM + * times are not supported). + * @member {array} [schedule.minutes] A collection of minutes at which the + * profile takes effect at. + */ + constructor() { + } + + /** + * Defines the metadata of Recurrence + * + * @returns {object} metadata of Recurrence + * + */ + mapper() { + return { + required: false, + serializedName: 'Recurrence', + type: { + name: 'Composite', + className: 'Recurrence', + modelProperties: { + frequency: { + required: true, + serializedName: 'frequency', + type: { + name: 'Enum', + allowedValues: [ 'None', 'Second', 'Minute', 'Hour', 'Day', 'Week', 'Month', 'Year' ] + } + }, + schedule: { + required: true, + serializedName: 'schedule', + type: { + name: 'Composite', + className: 'RecurrentSchedule' + } + } + } + } + }; + } +} + +module.exports = Recurrence; diff --git a/lib/services/monitor/lib/models/recurrentSchedule.js b/lib/services/monitor/lib/models/recurrentSchedule.js new file mode 100644 index 0000000000..dec886f658 --- /dev/null +++ b/lib/services/monitor/lib/models/recurrentSchedule.js @@ -0,0 +1,138 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The scheduling constraints for when the profile begins. + * + */ +class RecurrentSchedule { + /** + * Create a RecurrentSchedule. + * @member {string} timeZone the timezone for the hours of the profile. Some + * examples of valid timezones are: Dateline Standard Time, UTC-11, Hawaiian + * Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), + * Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time + * (Mexico), Mountain Standard Time, Central America Standard Time, Central + * Standard Time, Central Standard Time (Mexico), Canada Central Standard + * Time, SA Pacific Standard Time, Eastern Standard Time, US Eastern Standard + * Time, Venezuela Standard Time, Paraguay Standard Time, Atlantic Standard + * Time, Central Brazilian Standard Time, SA Western Standard Time, Pacific + * SA Standard Time, Newfoundland Standard Time, E. South America Standard + * Time, Argentina Standard Time, SA Eastern Standard Time, Greenland + * Standard Time, Montevideo Standard Time, Bahia Standard Time, UTC-02, + * Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde Standard + * Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard + * Time, W. Europe Standard Time, Central Europe Standard Time, Romance + * Standard Time, Central European Standard Time, W. Central Africa Standard + * Time, Namibia Standard Time, Jordan Standard Time, GTB Standard Time, + * Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. + * Europe Standard Time, South Africa Standard Time, FLE Standard Time, + * Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, + * Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus + * Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + * Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia + * Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus + * Standard Time, Afghanistan Standard Time, West Asia Standard Time, + * Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + * Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, + * Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard + * Time, SE Asia Standard Time, North Asia Standard Time, China Standard + * Time, North Asia East Standard Time, Singapore Standard Time, W. Australia + * Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo + * Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia + * Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS + * Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, + * Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + * Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard + * Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard + * Time, Samoa Standard Time, Line Islands Standard Time + * @member {array} days the collection of days that the profile takes effect + * on. Possible values are Sunday through Saturday. + * @member {array} hours A collection of hours that the profile takes effect + * on. Values supported are 0 to 23 on the 24-hour clock (AM/PM times are not + * supported). + * @member {array} minutes A collection of minutes at which the profile takes + * effect at. + */ + constructor() { + } + + /** + * Defines the metadata of RecurrentSchedule + * + * @returns {object} metadata of RecurrentSchedule + * + */ + mapper() { + return { + required: false, + serializedName: 'RecurrentSchedule', + type: { + name: 'Composite', + className: 'RecurrentSchedule', + modelProperties: { + timeZone: { + required: true, + serializedName: 'timeZone', + type: { + name: 'String' + } + }, + days: { + required: true, + serializedName: 'days', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + hours: { + required: true, + serializedName: 'hours', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'NumberElementType', + type: { + name: 'Number' + } + } + } + }, + minutes: { + required: true, + serializedName: 'minutes', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'NumberElementType', + type: { + name: 'Number' + } + } + } + } + } + } + }; + } +} + +module.exports = RecurrentSchedule; diff --git a/lib/services/monitor/lib/models/resource.js b/lib/services/monitor/lib/models/resource.js new file mode 100644 index 0000000000..429ae3a958 --- /dev/null +++ b/lib/services/monitor/lib/models/resource.js @@ -0,0 +1,98 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * An azure resource object + * + * @extends models['BaseResource'] + */ +class Resource extends models['BaseResource'] { + /** + * Create a Resource. + * @member {string} [id] Azure resource Id + * @member {string} [name] Azure resource name + * @member {string} [type] Azure resource type + * @member {string} location Resource location + * @member {object} [tags] Resource tags + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Resource + * + * @returns {object} metadata of Resource + * + */ + mapper() { + return { + required: false, + serializedName: 'Resource', + type: { + name: 'Composite', + className: 'Resource', + modelProperties: { + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = Resource; diff --git a/lib/services/monitor/lib/models/response.js b/lib/services/monitor/lib/models/response.js index fbe36d1619..20e0c9cbb3 100644 --- a/lib/services/monitor/lib/models/response.js +++ b/lib/services/monitor/lib/models/response.js @@ -29,6 +29,9 @@ class Response { * the metric data was returned in. This may be adjusted in the future and * returned back from what was originally requested. This is not present if * a metadata request was made. + * @member {string} [namespace] The namespace of the metrics been queried + * @member {string} [resourceregion] The region of the resource been queried + * for metrics. * @member {array} value the value of the collection. */ constructor() { @@ -72,6 +75,20 @@ class Response { name: 'TimeSpan' } }, + namespace: { + required: false, + serializedName: 'namespace', + type: { + name: 'String' + } + }, + resourceregion: { + required: false, + serializedName: 'resourceregion', + type: { + name: 'String' + } + }, value: { required: true, serializedName: 'value', diff --git a/lib/services/monitor/lib/models/retentionPolicy.js b/lib/services/monitor/lib/models/retentionPolicy.js new file mode 100644 index 0000000000..1ae39bed86 --- /dev/null +++ b/lib/services/monitor/lib/models/retentionPolicy.js @@ -0,0 +1,65 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Specifies the retention policy for the log. + * + */ +class RetentionPolicy { + /** + * Create a RetentionPolicy. + * @member {boolean} enabled a value indicating whether the retention policy + * is enabled. + * @member {number} days the number of days for the retention in days. A + * value of 0 will retain the events indefinitely. + */ + constructor() { + } + + /** + * Defines the metadata of RetentionPolicy + * + * @returns {object} metadata of RetentionPolicy + * + */ + mapper() { + return { + required: false, + serializedName: 'RetentionPolicy', + type: { + name: 'Composite', + className: 'RetentionPolicy', + modelProperties: { + enabled: { + required: true, + serializedName: 'enabled', + type: { + name: 'Boolean' + } + }, + days: { + required: true, + serializedName: 'days', + constraints: { + InclusiveMinimum: 0 + }, + type: { + name: 'Number' + } + } + } + } + }; + } +} + +module.exports = RetentionPolicy; diff --git a/lib/services/monitor/lib/models/ruleAction.js b/lib/services/monitor/lib/models/ruleAction.js new file mode 100644 index 0000000000..8cc7f75b03 --- /dev/null +++ b/lib/services/monitor/lib/models/ruleAction.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The action that is performed when the alert rule becomes active, and when an + * alert condition is resolved. + * + */ +class RuleAction { + /** + * Create a RuleAction. + * @member {string} odatatype Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of RuleAction + * + * @returns {object} metadata of RuleAction + * + */ + mapper() { + return { + required: false, + serializedName: 'RuleAction', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleAction', + className: 'RuleAction', + modelProperties: { + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = RuleAction; diff --git a/lib/services/monitor/lib/models/ruleCondition.js b/lib/services/monitor/lib/models/ruleCondition.js new file mode 100644 index 0000000000..5b43f85397 --- /dev/null +++ b/lib/services/monitor/lib/models/ruleCondition.js @@ -0,0 +1,80 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The condition that results in the alert rule being activated. + * + */ +class RuleCondition { + /** + * Create a RuleCondition. + * @member {object} [dataSource] the resource from which the rule collects + * its data. For this type dataSource will always be of type + * RuleMetricDataSource. + * @member {string} [dataSource.resourceUri] the resource identifier of the + * resource the rule monitors. **NOTE**: this property cannot be updated for + * an existing rule. + * @member {string} [dataSource.odatatype] Polymorphic Discriminator + * @member {string} odatatype Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of RuleCondition + * + * @returns {object} metadata of RuleCondition + * + */ + mapper() { + return { + required: false, + serializedName: 'RuleCondition', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleCondition', + className: 'RuleCondition', + modelProperties: { + dataSource: { + required: false, + serializedName: 'dataSource', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleDataSource', + className: 'RuleDataSource' + } + }, + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = RuleCondition; diff --git a/lib/services/monitor/lib/models/ruleDataSource.js b/lib/services/monitor/lib/models/ruleDataSource.js new file mode 100644 index 0000000000..f106206ee3 --- /dev/null +++ b/lib/services/monitor/lib/models/ruleDataSource.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The resource from which the rule collects its data. + * + */ +class RuleDataSource { + /** + * Create a RuleDataSource. + * @member {string} [resourceUri] the resource identifier of the resource the + * rule monitors. **NOTE**: this property cannot be updated for an existing + * rule. + * @member {string} odatatype Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of RuleDataSource + * + * @returns {object} metadata of RuleDataSource + * + */ + mapper() { + return { + required: false, + serializedName: 'RuleDataSource', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleDataSource', + className: 'RuleDataSource', + modelProperties: { + resourceUri: { + required: false, + serializedName: 'resourceUri', + type: { + name: 'String' + } + }, + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = RuleDataSource; diff --git a/lib/services/monitor/lib/models/ruleEmailAction.js b/lib/services/monitor/lib/models/ruleEmailAction.js new file mode 100644 index 0000000000..7a5a3b4e66 --- /dev/null +++ b/lib/services/monitor/lib/models/ruleEmailAction.js @@ -0,0 +1,88 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Specifies the action to send email when the rule condition is evaluated. The + * discriminator is always RuleEmailAction in this case. + * + * @extends models['RuleAction'] + */ +class RuleEmailAction extends models['RuleAction'] { + /** + * Create a RuleEmailAction. + * @member {boolean} [sendToServiceOwners] Whether the administrators + * (service and co-administrators) of the service should be notified when the + * alert is activated. + * @member {array} [customEmails] the list of administrator's custom email + * addresses to notify of the activation of the alert. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of RuleEmailAction + * + * @returns {object} metadata of RuleEmailAction + * + */ + mapper() { + return { + required: false, + serializedName: 'Microsoft.Azure.Management.Insights.Models.RuleEmailAction', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleAction', + className: 'RuleEmailAction', + modelProperties: { + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + sendToServiceOwners: { + required: false, + serializedName: 'sendToServiceOwners', + type: { + name: 'Boolean' + } + }, + customEmails: { + required: false, + serializedName: 'customEmails', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = RuleEmailAction; diff --git a/lib/services/monitor/lib/models/ruleManagementEventClaimsDataSource.js b/lib/services/monitor/lib/models/ruleManagementEventClaimsDataSource.js new file mode 100644 index 0000000000..a8a5de752c --- /dev/null +++ b/lib/services/monitor/lib/models/ruleManagementEventClaimsDataSource.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The claims for a rule management event data source. + * + */ +class RuleManagementEventClaimsDataSource { + /** + * Create a RuleManagementEventClaimsDataSource. + * @member {string} [emailAddress] the email address. + */ + constructor() { + } + + /** + * Defines the metadata of RuleManagementEventClaimsDataSource + * + * @returns {object} metadata of RuleManagementEventClaimsDataSource + * + */ + mapper() { + return { + required: false, + serializedName: 'RuleManagementEventClaimsDataSource', + type: { + name: 'Composite', + className: 'RuleManagementEventClaimsDataSource', + modelProperties: { + emailAddress: { + required: false, + serializedName: 'emailAddress', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = RuleManagementEventClaimsDataSource; diff --git a/lib/services/monitor/lib/models/ruleManagementEventDataSource.js b/lib/services/monitor/lib/models/ruleManagementEventDataSource.js new file mode 100644 index 0000000000..b981085f6d --- /dev/null +++ b/lib/services/monitor/lib/models/ruleManagementEventDataSource.js @@ -0,0 +1,145 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A rule management event data source. The discriminator fields is always + * RuleManagementEventDataSource in this case. + * + * @extends models['RuleDataSource'] + */ +class RuleManagementEventDataSource extends models['RuleDataSource'] { + /** + * Create a RuleManagementEventDataSource. + * @member {string} [eventName] the event name. + * @member {string} [eventSource] the event source. + * @member {string} [level] the level. + * @member {string} [operationName] The name of the operation that should be + * checked for. If no name is provided, any operation will match. + * @member {string} [resourceGroupName] the resource group name. + * @member {string} [resourceProviderName] the resource provider name. + * @member {string} [status] The status of the operation that should be + * checked for. If no status is provided, any status will match. + * @member {string} [subStatus] the substatus. + * @member {object} [claims] the claims. + * @member {string} [claims.emailAddress] the email address. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of RuleManagementEventDataSource + * + * @returns {object} metadata of RuleManagementEventDataSource + * + */ + mapper() { + return { + required: false, + serializedName: 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleDataSource', + className: 'RuleManagementEventDataSource', + modelProperties: { + resourceUri: { + required: false, + serializedName: 'resourceUri', + type: { + name: 'String' + } + }, + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + eventName: { + required: false, + serializedName: 'eventName', + type: { + name: 'String' + } + }, + eventSource: { + required: false, + serializedName: 'eventSource', + type: { + name: 'String' + } + }, + level: { + required: false, + serializedName: 'level', + type: { + name: 'String' + } + }, + operationName: { + required: false, + serializedName: 'operationName', + type: { + name: 'String' + } + }, + resourceGroupName: { + required: false, + serializedName: 'resourceGroupName', + type: { + name: 'String' + } + }, + resourceProviderName: { + required: false, + serializedName: 'resourceProviderName', + type: { + name: 'String' + } + }, + status: { + required: false, + serializedName: 'status', + type: { + name: 'String' + } + }, + subStatus: { + required: false, + serializedName: 'subStatus', + type: { + name: 'String' + } + }, + claims: { + required: false, + serializedName: 'claims', + type: { + name: 'Composite', + className: 'RuleManagementEventClaimsDataSource' + } + } + } + } + }; + } +} + +module.exports = RuleManagementEventDataSource; diff --git a/lib/services/monitor/lib/models/ruleMetricDataSource.js b/lib/services/monitor/lib/models/ruleMetricDataSource.js new file mode 100644 index 0000000000..abf2f6aae1 --- /dev/null +++ b/lib/services/monitor/lib/models/ruleMetricDataSource.js @@ -0,0 +1,78 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A rule metric data source. The discriminator value is always + * RuleMetricDataSource in this case. + * + * @extends models['RuleDataSource'] + */ +class RuleMetricDataSource extends models['RuleDataSource'] { + /** + * Create a RuleMetricDataSource. + * @member {string} [metricName] the name of the metric that defines what the + * rule monitors. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of RuleMetricDataSource + * + * @returns {object} metadata of RuleMetricDataSource + * + */ + mapper() { + return { + required: false, + serializedName: 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleDataSource', + className: 'RuleMetricDataSource', + modelProperties: { + resourceUri: { + required: false, + serializedName: 'resourceUri', + type: { + name: 'String' + } + }, + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + metricName: { + required: false, + serializedName: 'metricName', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = RuleMetricDataSource; diff --git a/lib/services/monitor/lib/models/ruleWebhookAction.js b/lib/services/monitor/lib/models/ruleWebhookAction.js new file mode 100644 index 0000000000..58cf335564 --- /dev/null +++ b/lib/services/monitor/lib/models/ruleWebhookAction.js @@ -0,0 +1,88 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Specifies the action to post to service when the rule condition is + * evaluated. The discriminator is always RuleWebhookAction in this case. + * + * @extends models['RuleAction'] + */ +class RuleWebhookAction extends models['RuleAction'] { + /** + * Create a RuleWebhookAction. + * @member {string} [serviceUri] the service uri to Post the notification + * when the alert activates or resolves. + * @member {object} [properties] the dictionary of custom properties to + * include with the post operation. These data are appended to the webhook + * payload. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of RuleWebhookAction + * + * @returns {object} metadata of RuleWebhookAction + * + */ + mapper() { + return { + required: false, + serializedName: 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleAction', + className: 'RuleWebhookAction', + modelProperties: { + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + serviceUri: { + required: false, + serializedName: 'serviceUri', + type: { + name: 'String' + } + }, + properties: { + required: false, + serializedName: 'properties', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = RuleWebhookAction; diff --git a/lib/services/monitor/lib/models/scaleAction.js b/lib/services/monitor/lib/models/scaleAction.js new file mode 100644 index 0000000000..e07a8a5d27 --- /dev/null +++ b/lib/services/monitor/lib/models/scaleAction.js @@ -0,0 +1,87 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The parameters for the scaling action. + * + */ +class ScaleAction { + /** + * Create a ScaleAction. + * @member {string} direction the scale direction. Whether the scaling action + * increases or decreases the number of instances. Possible values include: + * 'None', 'Increase', 'Decrease' + * @member {string} type the type of action that should occur when the scale + * rule fires. Possible values include: 'ChangeCount', 'PercentChangeCount', + * 'ExactCount' + * @member {string} [value] the number of instances that are involved in the + * scaling action. This value must be 1 or greater. The default value is 1. + * Default value: '1' . + * @member {moment.duration} cooldown the amount of time to wait since the + * last scaling action before this action occurs. It must be between 1 week + * and 1 minute in ISO 8601 format. + */ + constructor() { + } + + /** + * Defines the metadata of ScaleAction + * + * @returns {object} metadata of ScaleAction + * + */ + mapper() { + return { + required: false, + serializedName: 'ScaleAction', + type: { + name: 'Composite', + className: 'ScaleAction', + modelProperties: { + direction: { + required: true, + serializedName: 'direction', + type: { + name: 'Enum', + allowedValues: [ 'None', 'Increase', 'Decrease' ] + } + }, + type: { + required: true, + serializedName: 'type', + type: { + name: 'Enum', + allowedValues: [ 'ChangeCount', 'PercentChangeCount', 'ExactCount' ] + } + }, + value: { + required: false, + serializedName: 'value', + defaultValue: '1', + type: { + name: 'String' + } + }, + cooldown: { + required: true, + serializedName: 'cooldown', + type: { + name: 'TimeSpan' + } + } + } + } + }; + } +} + +module.exports = ScaleAction; diff --git a/lib/services/monitor/lib/models/scaleCapacity.js b/lib/services/monitor/lib/models/scaleCapacity.js new file mode 100644 index 0000000000..841ec3393c --- /dev/null +++ b/lib/services/monitor/lib/models/scaleCapacity.js @@ -0,0 +1,72 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The number of instances that can be used during this profile. + * + */ +class ScaleCapacity { + /** + * Create a ScaleCapacity. + * @member {string} minimum the minimum number of instances for the resource. + * @member {string} maximum the maximum number of instances for the resource. + * The actual maximum number of instances is limited by the cores that are + * available in the subscription. + * @member {string} default the number of instances that will be set if + * metrics are not available for evaluation. The default is only used if the + * current instance count is lower than the default. + */ + constructor() { + } + + /** + * Defines the metadata of ScaleCapacity + * + * @returns {object} metadata of ScaleCapacity + * + */ + mapper() { + return { + required: false, + serializedName: 'ScaleCapacity', + type: { + name: 'Composite', + className: 'ScaleCapacity', + modelProperties: { + minimum: { + required: true, + serializedName: 'minimum', + type: { + name: 'String' + } + }, + maximum: { + required: true, + serializedName: 'maximum', + type: { + name: 'String' + } + }, + default: { + required: true, + serializedName: 'default', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ScaleCapacity; diff --git a/lib/services/monitor/lib/models/scaleRule.js b/lib/services/monitor/lib/models/scaleRule.js new file mode 100644 index 0000000000..0836d498c2 --- /dev/null +++ b/lib/services/monitor/lib/models/scaleRule.js @@ -0,0 +1,102 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A rule that provide the triggers and parameters for the scaling action. + * + */ +class ScaleRule { + /** + * Create a ScaleRule. + * @member {object} metricTrigger the trigger that results in a scaling + * action. + * @member {string} [metricTrigger.metricName] the name of the metric that + * defines what the rule monitors. + * @member {string} [metricTrigger.metricResourceUri] the resource identifier + * of the resource the rule monitors. + * @member {moment.duration} [metricTrigger.timeGrain] the granularity of + * metrics the rule monitors. Must be one of the predefined values returned + * from metric definitions for the metric. Must be between 12 hours and 1 + * minute. + * @member {string} [metricTrigger.statistic] the metric statistic type. How + * the metrics from multiple instances are combined. Possible values include: + * 'Average', 'Min', 'Max', 'Sum' + * @member {moment.duration} [metricTrigger.timeWindow] the range of time in + * which instance data is collected. This value must be greater than the + * delay in metric collection, which can vary from resource-to-resource. Must + * be between 12 hours and 5 minutes. + * @member {string} [metricTrigger.timeAggregation] time aggregation type. + * How the data that is collected should be combined over time. The default + * value is Average. Possible values include: 'Average', 'Minimum', + * 'Maximum', 'Total', 'Count' + * @member {string} [metricTrigger.operator] the operator that is used to + * compare the metric data and the threshold. Possible values include: + * 'Equals', 'NotEquals', 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', + * 'LessThanOrEqual' + * @member {number} [metricTrigger.threshold] the threshold of the metric + * that triggers the scale action. + * @member {object} scaleAction the parameters for the scaling action. + * @member {string} [scaleAction.direction] the scale direction. Whether the + * scaling action increases or decreases the number of instances. Possible + * values include: 'None', 'Increase', 'Decrease' + * @member {string} [scaleAction.type] the type of action that should occur + * when the scale rule fires. Possible values include: 'ChangeCount', + * 'PercentChangeCount', 'ExactCount' + * @member {string} [scaleAction.value] the number of instances that are + * involved in the scaling action. This value must be 1 or greater. The + * default value is 1. + * @member {moment.duration} [scaleAction.cooldown] the amount of time to + * wait since the last scaling action before this action occurs. It must be + * between 1 week and 1 minute in ISO 8601 format. + */ + constructor() { + } + + /** + * Defines the metadata of ScaleRule + * + * @returns {object} metadata of ScaleRule + * + */ + mapper() { + return { + required: false, + serializedName: 'ScaleRule', + type: { + name: 'Composite', + className: 'ScaleRule', + modelProperties: { + metricTrigger: { + required: true, + serializedName: 'metricTrigger', + type: { + name: 'Composite', + className: 'MetricTrigger' + } + }, + scaleAction: { + required: true, + serializedName: 'scaleAction', + type: { + name: 'Composite', + className: 'ScaleAction' + } + } + } + } + }; + } +} + +module.exports = ScaleRule; diff --git a/lib/services/monitor/lib/models/smsReceiver.js b/lib/services/monitor/lib/models/smsReceiver.js new file mode 100644 index 0000000000..9579690c9e --- /dev/null +++ b/lib/services/monitor/lib/models/smsReceiver.js @@ -0,0 +1,80 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * An SMS receiver. + * + */ +class SmsReceiver { + /** + * Create a SmsReceiver. + * @member {string} name The name of the SMS receiver. Names must be unique + * across all receivers within an action group. + * @member {string} countryCode The country code of the SMS receiver. + * @member {string} phoneNumber The phone number of the SMS receiver. + * @member {string} [status] The status of the receiver. Possible values + * include: 'NotSpecified', 'Enabled', 'Disabled' + */ + constructor() { + } + + /** + * Defines the metadata of SmsReceiver + * + * @returns {object} metadata of SmsReceiver + * + */ + mapper() { + return { + required: false, + serializedName: 'SmsReceiver', + type: { + name: 'Composite', + className: 'SmsReceiver', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + countryCode: { + required: true, + serializedName: 'countryCode', + type: { + name: 'String' + } + }, + phoneNumber: { + required: true, + serializedName: 'phoneNumber', + type: { + name: 'String' + } + }, + status: { + required: false, + readOnly: true, + serializedName: 'status', + type: { + name: 'Enum', + allowedValues: [ 'NotSpecified', 'Enabled', 'Disabled' ] + } + } + } + } + }; + } +} + +module.exports = SmsReceiver; diff --git a/lib/services/monitor/lib/models/thresholdRuleCondition.js b/lib/services/monitor/lib/models/thresholdRuleCondition.js new file mode 100644 index 0000000000..899822bb45 --- /dev/null +++ b/lib/services/monitor/lib/models/thresholdRuleCondition.js @@ -0,0 +1,115 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * A rule condition based on a metric crossing a threshold. + * + * @extends models['RuleCondition'] + */ +class ThresholdRuleCondition extends models['RuleCondition'] { + /** + * Create a ThresholdRuleCondition. + * @member {string} operator the operator used to compare the data and the + * threshold. Possible values include: 'GreaterThan', 'GreaterThanOrEqual', + * 'LessThan', 'LessThanOrEqual' + * @member {number} threshold the threshold value that activates the alert. + * @member {moment.duration} [windowSize] the period of time (in ISO 8601 + * duration format) that is used to monitor alert activity based on the + * threshold. If specified then it must be between 5 minutes and 1 day. + * @member {string} [timeAggregation] the time aggregation operator. How the + * data that are collected should be combined over time. The default value is + * the PrimaryAggregationType of the Metric. Possible values include: + * 'Average', 'Minimum', 'Maximum', 'Total', 'Last' + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ThresholdRuleCondition + * + * @returns {object} metadata of ThresholdRuleCondition + * + */ + mapper() { + return { + required: false, + serializedName: 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleCondition', + className: 'ThresholdRuleCondition', + modelProperties: { + dataSource: { + required: false, + serializedName: 'dataSource', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: 'odata.type', + clientName: 'odatatype' + }, + uberParent: 'RuleDataSource', + className: 'RuleDataSource' + } + }, + odatatype: { + required: true, + serializedName: 'odata\\.type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + operator: { + required: true, + serializedName: 'operator', + type: { + name: 'Enum', + allowedValues: [ 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual' ] + } + }, + threshold: { + required: true, + serializedName: 'threshold', + type: { + name: 'Number' + } + }, + windowSize: { + required: false, + serializedName: 'windowSize', + type: { + name: 'TimeSpan' + } + }, + timeAggregation: { + required: false, + serializedName: 'timeAggregation', + type: { + name: 'Enum', + allowedValues: [ 'Average', 'Minimum', 'Maximum', 'Total', 'Last' ] + } + } + } + } + }; + } +} + +module.exports = ThresholdRuleCondition; diff --git a/lib/services/monitor/lib/models/timeSeriesInformation.js b/lib/services/monitor/lib/models/timeSeriesInformation.js new file mode 100644 index 0000000000..f4d8ac5464 --- /dev/null +++ b/lib/services/monitor/lib/models/timeSeriesInformation.js @@ -0,0 +1,90 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * The time series info needed for calculating the baseline. + * + */ +class TimeSeriesInformation { + /** + * Create a TimeSeriesInformation. + * @member {array} sensitivities the list of sensitivities for calculating + * the baseline. + * @member {array} values The metric values to calculate the baseline. + * @member {array} [timestamps] the array of timestamps of the baselines. + */ + constructor() { + } + + /** + * Defines the metadata of TimeSeriesInformation + * + * @returns {object} metadata of TimeSeriesInformation + * + */ + mapper() { + return { + required: false, + serializedName: 'TimeSeriesInformation', + type: { + name: 'Composite', + className: 'TimeSeriesInformation', + modelProperties: { + sensitivities: { + required: true, + serializedName: 'sensitivities', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + values: { + required: true, + serializedName: 'values', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'NumberElementType', + type: { + name: 'Number' + } + } + } + }, + timestamps: { + required: false, + serializedName: 'timestamps', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'DateElementType', + type: { + name: 'DateTime' + } + } + } + } + } + } + }; + } +} + +module.exports = TimeSeriesInformation; diff --git a/lib/services/monitor/lib/models/timeWindow.js b/lib/services/monitor/lib/models/timeWindow.js new file mode 100644 index 0000000000..c072fd288a --- /dev/null +++ b/lib/services/monitor/lib/models/timeWindow.js @@ -0,0 +1,105 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A specific date-time for the profile. + * + */ +class TimeWindow { + /** + * Create a TimeWindow. + * @member {string} [timeZone] the timezone of the start and end times for + * the profile. Some examples of valid timezones are: Dateline Standard Time, + * UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard + * Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain + * Standard Time (Mexico), Mountain Standard Time, Central America Standard + * Time, Central Standard Time, Central Standard Time (Mexico), Canada + * Central Standard Time, SA Pacific Standard Time, Eastern Standard Time, US + * Eastern Standard Time, Venezuela Standard Time, Paraguay Standard Time, + * Atlantic Standard Time, Central Brazilian Standard Time, SA Western + * Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. + * South America Standard Time, Argentina Standard Time, SA Eastern Standard + * Time, Greenland Standard Time, Montevideo Standard Time, Bahia Standard + * Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde + * Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich + * Standard Time, W. Europe Standard Time, Central Europe Standard Time, + * Romance Standard Time, Central European Standard Time, W. Central Africa + * Standard Time, Namibia Standard Time, Jordan Standard Time, GTB Standard + * Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, + * E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, + * Turkey Standard Time, Israel Standard Time, Kaliningrad Standard Time, + * Libya Standard Time, Arabic Standard Time, Arab Standard Time, Belarus + * Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + * Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia + * Time Zone 3, Mauritius Standard Time, Georgian Standard Time, Caucasus + * Standard Time, Afghanistan Standard Time, West Asia Standard Time, + * Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + * Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, + * Bangladesh Standard Time, N. Central Asia Standard Time, Myanmar Standard + * Time, SE Asia Standard Time, North Asia Standard Time, China Standard + * Time, North Asia East Standard Time, Singapore Standard Time, W. Australia + * Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo + * Standard Time, Korea Standard Time, Yakutsk Standard Time, Cen. Australia + * Standard Time, AUS Central Standard Time, E. Australia Standard Time, AUS + * Eastern Standard Time, West Pacific Standard Time, Tasmania Standard Time, + * Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + * Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard + * Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard + * Time, Samoa Standard Time, Line Islands Standard Time + * @member {date} start the start time for the profile in ISO 8601 format. + * @member {date} end the end time for the profile in ISO 8601 format. + */ + constructor() { + } + + /** + * Defines the metadata of TimeWindow + * + * @returns {object} metadata of TimeWindow + * + */ + mapper() { + return { + required: false, + serializedName: 'TimeWindow', + type: { + name: 'Composite', + className: 'TimeWindow', + modelProperties: { + timeZone: { + required: false, + serializedName: 'timeZone', + type: { + name: 'String' + } + }, + start: { + required: true, + serializedName: 'start', + type: { + name: 'DateTime' + } + }, + end: { + required: true, + serializedName: 'end', + type: { + name: 'DateTime' + } + } + } + } + }; + } +} + +module.exports = TimeWindow; diff --git a/lib/services/monitor/lib/models/webhookNotification.js b/lib/services/monitor/lib/models/webhookNotification.js new file mode 100644 index 0000000000..bc05f4b1a1 --- /dev/null +++ b/lib/services/monitor/lib/models/webhookNotification.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Webhook notification of an autoscale event. + * + */ +class WebhookNotification { + /** + * Create a WebhookNotification. + * @member {string} [serviceUri] the service address to receive the + * notification. + * @member {object} [properties] a property bag of settings. This value can + * be empty. + */ + constructor() { + } + + /** + * Defines the metadata of WebhookNotification + * + * @returns {object} metadata of WebhookNotification + * + */ + mapper() { + return { + required: false, + serializedName: 'WebhookNotification', + type: { + name: 'Composite', + className: 'WebhookNotification', + modelProperties: { + serviceUri: { + required: false, + serializedName: 'serviceUri', + type: { + name: 'String' + } + }, + properties: { + required: false, + serializedName: 'properties', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = WebhookNotification; diff --git a/lib/services/monitor/lib/models/webhookReceiver.js b/lib/services/monitor/lib/models/webhookReceiver.js new file mode 100644 index 0000000000..bfaf7cd202 --- /dev/null +++ b/lib/services/monitor/lib/models/webhookReceiver.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * A webhook receiver. + * + */ +class WebhookReceiver { + /** + * Create a WebhookReceiver. + * @member {string} name The name of the webhook receiver. Names must be + * unique across all receivers within an action group. + * @member {string} serviceUri The URI where webhooks should be sent. + */ + constructor() { + } + + /** + * Defines the metadata of WebhookReceiver + * + * @returns {object} metadata of WebhookReceiver + * + */ + mapper() { + return { + required: false, + serializedName: 'WebhookReceiver', + type: { + name: 'Composite', + className: 'WebhookReceiver', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + serviceUri: { + required: true, + serializedName: 'serviceUri', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = WebhookReceiver; diff --git a/lib/services/monitor/lib/monitorManagementClient.d.ts b/lib/services/monitor/lib/monitorManagementClient.d.ts new file mode 100644 index 0000000000..9c64e133dc --- /dev/null +++ b/lib/services/monitor/lib/monitorManagementClient.d.ts @@ -0,0 +1,76 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import { ServiceClientCredentials } from 'ms-rest'; +import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; +import * as models from "./models"; +import * as operations from "./operations"; + +export default class MonitorManagementClient extends AzureServiceClient { + /** + * Initializes a new instance of the MonitorManagementClient class. + * @constructor + * + * @class + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * + * @param {string} subscriptionId - The Azure subscription Id. + * + * @param {string} [baseUri] - The base URI of the service. + * + * @param {object} [options] - The parameter options + * + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * + * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. + * + * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + */ + constructor(credentials: ServiceClientCredentials, subscriptionId: string, baseUri?: string, options?: AzureServiceClientOptions); + + credentials: ServiceClientCredentials; + + subscriptionId: string; + + acceptLanguage: string; + + longRunningOperationRetryTimeout: number; + + generateClientRequestId: boolean; + + // Operation groups + autoscaleSettings: operations.AutoscaleSettings; + operations: operations.Operations; + alertRuleIncidents: operations.AlertRuleIncidents; + alertRules: operations.AlertRules; + logProfiles: operations.LogProfiles; + diagnosticSettingsOperations: operations.DiagnosticSettingsOperations; + diagnosticSettingsCategoryOperations: operations.DiagnosticSettingsCategoryOperations; + actionGroups: operations.ActionGroups; + activityLogAlerts: operations.ActivityLogAlerts; + activityLogs: operations.ActivityLogs; + eventCategories: operations.EventCategories; + tenantActivityLogs: operations.TenantActivityLogs; + metricDefinitions: operations.MetricDefinitions; + metrics: operations.Metrics; + metricBaseline: operations.MetricBaseline; + metricAlerts: operations.MetricAlerts; + metricAlertsStatus: operations.MetricAlertsStatus; +} + +export { MonitorManagementClient, models as MonitorManagementModels }; diff --git a/lib/services/monitor/lib/monitorManagementClient.js b/lib/services/monitor/lib/monitorManagementClient.js new file mode 100644 index 0000000000..356cd3c461 --- /dev/null +++ b/lib/services/monitor/lib/monitorManagementClient.js @@ -0,0 +1,100 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const ServiceClient = msRestAzure.AzureServiceClient; + +const models = require('./models'); +const operations = require('./operations'); + + +/** Class representing a MonitorManagementClient. */ +class MonitorManagementClient extends ServiceClient { + /** + * Create a MonitorManagementClient. + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * @param {string} subscriptionId - The Azure subscription Id. + * @param {string} [baseUri] - The base URI of the service. + * @param {object} [options] - The parameter options + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. + * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + */ + constructor(credentials, subscriptionId, baseUri, options) { + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + if (subscriptionId === null || subscriptionId === undefined) { + throw new Error('\'subscriptionId\' cannot be null.'); + } + + if (!options) options = {}; + + super(credentials, options); + + this.acceptLanguage = 'en-US'; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.baseUri = baseUri; + if (!this.baseUri) { + this.baseUri = 'https://management.azure.com'; + } + this.credentials = credentials; + this.subscriptionId = subscriptionId; + + let packageInfo = this.getPackageJsonInfo(__dirname); + this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); + if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + this.acceptLanguage = options.acceptLanguage; + } + if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; + } + if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { + this.generateClientRequestId = options.generateClientRequestId; + } + this.autoscaleSettings = new operations.AutoscaleSettings(this); + this.operations = new operations.Operations(this); + this.alertRuleIncidents = new operations.AlertRuleIncidents(this); + this.alertRules = new operations.AlertRules(this); + this.logProfiles = new operations.LogProfiles(this); + this.diagnosticSettingsOperations = new operations.DiagnosticSettingsOperations(this); + this.diagnosticSettingsCategoryOperations = new operations.DiagnosticSettingsCategoryOperations(this); + this.actionGroups = new operations.ActionGroups(this); + this.activityLogAlerts = new operations.ActivityLogAlerts(this); + this.activityLogs = new operations.ActivityLogs(this); + this.eventCategories = new operations.EventCategories(this); + this.tenantActivityLogs = new operations.TenantActivityLogs(this); + this.metricDefinitions = new operations.MetricDefinitions(this); + this.metrics = new operations.Metrics(this); + this.metricBaseline = new operations.MetricBaseline(this); + this.metricAlerts = new operations.MetricAlerts(this); + this.metricAlertsStatus = new operations.MetricAlertsStatus(this); + this.models = models; + msRest.addSerializationMixin(this); + } + +} + +module.exports = MonitorManagementClient; +module.exports['default'] = MonitorManagementClient; +module.exports.MonitorManagementClient = MonitorManagementClient; +module.exports.MonitorManagementModels = models; diff --git a/lib/services/monitor/lib/operations/actionGroups.js b/lib/services/monitor/lib/operations/actionGroups.js new file mode 100644 index 0000000000..ec5e0913c4 --- /dev/null +++ b/lib/services/monitor/lib/operations/actionGroups.js @@ -0,0 +1,1783 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Create a new action group or update an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} actionGroup The action group to create or use for the + * update. + * + * @param {string} actionGroup.groupShortName The short name of the action + * group. This will be used in SMS messages. + * + * @param {boolean} actionGroup.enabled Indicates whether this action group is + * enabled. If an action group is not enabled, then none of its receivers will + * receive communications. + * + * @param {array} [actionGroup.emailReceivers] The list of email receivers that + * are part of this action group. + * + * @param {array} [actionGroup.smsReceivers] The list of SMS receivers that are + * part of this action group. + * + * @param {array} [actionGroup.webhookReceivers] The list of webhook receivers + * that are part of this action group. + * + * @param {array} [actionGroup.itsmReceivers] The list of ITSM receivers that + * are part of this action group. + * + * @param {array} [actionGroup.azureAppPushReceivers] The list of AzureAppPush + * receivers that are part of this action group. + * + * @param {array} [actionGroup.automationRunbookReceivers] The list of + * AutomationRunbook receivers that are part of this action group. + * + * @param {string} actionGroup.location Resource location + * + * @param {object} [actionGroup.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, actionGroupName, actionGroup, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (actionGroupName === null || actionGroupName === undefined || typeof actionGroupName.valueOf() !== 'string') { + throw new Error('actionGroupName cannot be null or undefined and it must be of type string.'); + } + if (actionGroup === null || actionGroup === undefined) { + throw new Error('actionGroup cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{actionGroupName}', encodeURIComponent(actionGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (actionGroup !== null && actionGroup !== undefined) { + let requestModelMapper = new client.models['ActionGroupResource']().mapper(); + requestModel = client.serialize(requestModelMapper, actionGroup, 'actionGroup'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(actionGroup, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActionGroupResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActionGroupResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get an action group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, actionGroupName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (actionGroupName === null || actionGroupName === undefined || typeof actionGroupName.valueOf() !== 'string') { + throw new Error('actionGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{actionGroupName}', encodeURIComponent(actionGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActionGroupResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete an action group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, actionGroupName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (actionGroupName === null || actionGroupName === undefined || typeof actionGroupName.valueOf() !== 'string') { + throw new Error('actionGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{actionGroupName}', encodeURIComponent(actionGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Updates an existing action group's tags. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} actionGroupPatch Parameters supplied to the operation. + * + * @param {object} [actionGroupPatch.tags] Resource tags + * + * @param {boolean} [actionGroupPatch.enabled] Indicates whether this action + * group is enabled. If an action group is not enabled, then none of its + * actions will be activated. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(resourceGroupName, actionGroupName, actionGroupPatch, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (actionGroupName === null || actionGroupName === undefined || typeof actionGroupName.valueOf() !== 'string') { + throw new Error('actionGroupName cannot be null or undefined and it must be of type string.'); + } + if (actionGroupPatch === null || actionGroupPatch === undefined) { + throw new Error('actionGroupPatch cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{actionGroupName}', encodeURIComponent(actionGroupName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (actionGroupPatch !== null && actionGroupPatch !== undefined) { + let requestModelMapper = new client.models['ActionGroupPatchBody']().mapper(); + requestModel = client.serialize(requestModelMapper, actionGroupPatch, 'actionGroupPatch'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(actionGroupPatch, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActionGroupResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get a list of all action groups in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupList} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listBySubscriptionId(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActionGroupList']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get a list of all action groups in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupList} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroup(resourceGroupName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActionGroupList']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Enable a receiver in an action group. This changes the receiver's status + * from Disabled to Enabled. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {string} receiverName The name of the receiver to resubscribe. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _enableReceiver(resourceGroupName, actionGroupName, receiverName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (actionGroupName === null || actionGroupName === undefined || typeof actionGroupName.valueOf() !== 'string') { + throw new Error('actionGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (receiverName === null || receiverName === undefined || typeof receiverName.valueOf() !== 'string') { + throw new Error('receiverName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + let enableRequest; + if (receiverName !== null && receiverName !== undefined) { + enableRequest = new client.models['EnableRequest'](); + enableRequest.receiverName = receiverName; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{actionGroupName}', encodeURIComponent(actionGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (enableRequest !== null && enableRequest !== undefined) { + let requestModelMapper = new client.models['EnableRequest']().mapper(); + requestModel = client.serialize(requestModelMapper, enableRequest, 'enableRequest'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(enableRequest, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 409) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ActionGroups. */ +class ActionGroups { + /** + * Create a ActionGroups. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._createOrUpdate = _createOrUpdate; + this._get = _get; + this._deleteMethod = _deleteMethod; + this._update = _update; + this._listBySubscriptionId = _listBySubscriptionId; + this._listByResourceGroup = _listByResourceGroup; + this._enableReceiver = _enableReceiver; + } + + /** + * Create a new action group or update an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} actionGroup The action group to create or use for the + * update. + * + * @param {string} actionGroup.groupShortName The short name of the action + * group. This will be used in SMS messages. + * + * @param {boolean} actionGroup.enabled Indicates whether this action group is + * enabled. If an action group is not enabled, then none of its receivers will + * receive communications. + * + * @param {array} [actionGroup.emailReceivers] The list of email receivers that + * are part of this action group. + * + * @param {array} [actionGroup.smsReceivers] The list of SMS receivers that are + * part of this action group. + * + * @param {array} [actionGroup.webhookReceivers] The list of webhook receivers + * that are part of this action group. + * + * @param {array} [actionGroup.itsmReceivers] The list of ITSM receivers that + * are part of this action group. + * + * @param {array} [actionGroup.azureAppPushReceivers] The list of AzureAppPush + * receivers that are part of this action group. + * + * @param {array} [actionGroup.automationRunbookReceivers] The list of + * AutomationRunbook receivers that are part of this action group. + * + * @param {string} actionGroup.location Resource location + * + * @param {object} [actionGroup.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, actionGroupName, actionGroup, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, actionGroupName, actionGroup, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create a new action group or update an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} actionGroup The action group to create or use for the + * update. + * + * @param {string} actionGroup.groupShortName The short name of the action + * group. This will be used in SMS messages. + * + * @param {boolean} actionGroup.enabled Indicates whether this action group is + * enabled. If an action group is not enabled, then none of its receivers will + * receive communications. + * + * @param {array} [actionGroup.emailReceivers] The list of email receivers that + * are part of this action group. + * + * @param {array} [actionGroup.smsReceivers] The list of SMS receivers that are + * part of this action group. + * + * @param {array} [actionGroup.webhookReceivers] The list of webhook receivers + * that are part of this action group. + * + * @param {array} [actionGroup.itsmReceivers] The list of ITSM receivers that + * are part of this action group. + * + * @param {array} [actionGroup.azureAppPushReceivers] The list of AzureAppPush + * receivers that are part of this action group. + * + * @param {array} [actionGroup.automationRunbookReceivers] The list of + * AutomationRunbook receivers that are part of this action group. + * + * @param {string} actionGroup.location Resource location + * + * @param {object} [actionGroup.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ActionGroupResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, actionGroupName, actionGroup, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, actionGroupName, actionGroup, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, actionGroupName, actionGroup, options, optionalCallback); + } + } + + /** + * Get an action group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, actionGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, actionGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get an action group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ActionGroupResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, actionGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, actionGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, actionGroupName, options, optionalCallback); + } + } + + /** + * Delete an action group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, actionGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, actionGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete an action group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, actionGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, actionGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, actionGroupName, options, optionalCallback); + } + } + + /** + * Updates an existing action group's tags. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} actionGroupPatch Parameters supplied to the operation. + * + * @param {object} [actionGroupPatch.tags] Resource tags + * + * @param {boolean} [actionGroupPatch.enabled] Indicates whether this action + * group is enabled. If an action group is not enabled, then none of its + * actions will be activated. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, actionGroupName, actionGroupPatch, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, actionGroupName, actionGroupPatch, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates an existing action group's tags. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} actionGroupPatch Parameters supplied to the operation. + * + * @param {object} [actionGroupPatch.tags] Resource tags + * + * @param {boolean} [actionGroupPatch.enabled] Indicates whether this action + * group is enabled. If an action group is not enabled, then none of its + * actions will be activated. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ActionGroupResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName, actionGroupName, actionGroupPatch, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, actionGroupName, actionGroupPatch, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, actionGroupName, actionGroupPatch, options, optionalCallback); + } + } + + /** + * Get a list of all action groups in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listBySubscriptionIdWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listBySubscriptionId(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get a list of all action groups in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ActionGroupList} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupList} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscriptionId(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listBySubscriptionId(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listBySubscriptionId(options, optionalCallback); + } + } + + /** + * Get a list of all action groups in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get a list of all action groups in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ActionGroupList} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupList} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); + } + } + + /** + * Enable a receiver in an action group. This changes the receiver's status + * from Disabled to Enabled. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {string} receiverName The name of the receiver to resubscribe. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + enableReceiverWithHttpOperationResponse(resourceGroupName, actionGroupName, receiverName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._enableReceiver(resourceGroupName, actionGroupName, receiverName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Enable a receiver in an action group. This changes the receiver's status + * from Disabled to Enabled. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {string} receiverName The name of the receiver to resubscribe. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + enableReceiver(resourceGroupName, actionGroupName, receiverName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._enableReceiver(resourceGroupName, actionGroupName, receiverName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._enableReceiver(resourceGroupName, actionGroupName, receiverName, options, optionalCallback); + } + } + +} + +module.exports = ActionGroups; diff --git a/lib/services/monitor/lib/operations/activityLogAlerts.js b/lib/services/monitor/lib/operations/activityLogAlerts.js new file mode 100644 index 0000000000..bc6417b698 --- /dev/null +++ b/lib/services/monitor/lib/operations/activityLogAlerts.js @@ -0,0 +1,1543 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Create a new activity log alert or update an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} activityLogAlert The activity log alert to create or use for + * the update. + * + * @param {array} activityLogAlert.scopes A list of resourceIds that will be + * used as prefixes. The alert will only apply to activityLogs with resourceIds + * that fall under one of these prefixes. This list must include at least one + * item. + * + * @param {boolean} [activityLogAlert.enabled] Indicates whether this activity + * log alert is enabled. If an activity log alert is not enabled, then none of + * its actions will be activated. + * + * @param {object} activityLogAlert.condition The condition that will cause + * this alert to activate. + * + * @param {array} activityLogAlert.condition.allOf The list of activity log + * alert conditions. + * + * @param {object} activityLogAlert.actions The actions that will activate when + * the condition is met. + * + * @param {array} [activityLogAlert.actions.actionGroups] The list of activity + * log alerts. + * + * @param {string} [activityLogAlert.description] A description of this + * activity log alert. + * + * @param {string} activityLogAlert.location Resource location + * + * @param {object} [activityLogAlert.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, activityLogAlertName, activityLogAlert, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (activityLogAlertName === null || activityLogAlertName === undefined || typeof activityLogAlertName.valueOf() !== 'string') { + throw new Error('activityLogAlertName cannot be null or undefined and it must be of type string.'); + } + if (activityLogAlert === null || activityLogAlert === undefined) { + throw new Error('activityLogAlert cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{activityLogAlertName}', encodeURIComponent(activityLogAlertName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (activityLogAlert !== null && activityLogAlert !== undefined) { + let requestModelMapper = new client.models['ActivityLogAlertResource']().mapper(); + requestModel = client.serialize(requestModelMapper, activityLogAlert, 'activityLogAlert'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(activityLogAlert, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActivityLogAlertResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActivityLogAlertResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get an activity log alert. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, activityLogAlertName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (activityLogAlertName === null || activityLogAlertName === undefined || typeof activityLogAlertName.valueOf() !== 'string') { + throw new Error('activityLogAlertName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{activityLogAlertName}', encodeURIComponent(activityLogAlertName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActivityLogAlertResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete an activity log alert. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, activityLogAlertName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (activityLogAlertName === null || activityLogAlertName === undefined || typeof activityLogAlertName.valueOf() !== 'string') { + throw new Error('activityLogAlertName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{activityLogAlertName}', encodeURIComponent(activityLogAlertName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Updates an existing ActivityLogAlertResource's tags. To update other fields + * use the CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} activityLogAlertPatch Parameters supplied to the operation. + * + * @param {object} [activityLogAlertPatch.tags] Resource tags + * + * @param {boolean} [activityLogAlertPatch.enabled] Indicates whether this + * activity log alert is enabled. If an activity log alert is not enabled, then + * none of its actions will be activated. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(resourceGroupName, activityLogAlertName, activityLogAlertPatch, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (activityLogAlertName === null || activityLogAlertName === undefined || typeof activityLogAlertName.valueOf() !== 'string') { + throw new Error('activityLogAlertName cannot be null or undefined and it must be of type string.'); + } + if (activityLogAlertPatch === null || activityLogAlertPatch === undefined) { + throw new Error('activityLogAlertPatch cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{activityLogAlertName}', encodeURIComponent(activityLogAlertName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (activityLogAlertPatch !== null && activityLogAlertPatch !== undefined) { + let requestModelMapper = new client.models['ActivityLogAlertPatchBody']().mapper(); + requestModel = client.serialize(requestModelMapper, activityLogAlertPatch, 'activityLogAlertPatch'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(activityLogAlertPatch, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActivityLogAlertResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get a list of all activity log alerts in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertList} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listBySubscriptionId(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActivityLogAlertList']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Get a list of all activity log alerts in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertList} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroup(resourceGroupName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-04-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['ActivityLogAlertList']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a ActivityLogAlerts. */ +class ActivityLogAlerts { + /** + * Create a ActivityLogAlerts. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._createOrUpdate = _createOrUpdate; + this._get = _get; + this._deleteMethod = _deleteMethod; + this._update = _update; + this._listBySubscriptionId = _listBySubscriptionId; + this._listByResourceGroup = _listByResourceGroup; + } + + /** + * Create a new activity log alert or update an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} activityLogAlert The activity log alert to create or use for + * the update. + * + * @param {array} activityLogAlert.scopes A list of resourceIds that will be + * used as prefixes. The alert will only apply to activityLogs with resourceIds + * that fall under one of these prefixes. This list must include at least one + * item. + * + * @param {boolean} [activityLogAlert.enabled] Indicates whether this activity + * log alert is enabled. If an activity log alert is not enabled, then none of + * its actions will be activated. + * + * @param {object} activityLogAlert.condition The condition that will cause + * this alert to activate. + * + * @param {array} activityLogAlert.condition.allOf The list of activity log + * alert conditions. + * + * @param {object} activityLogAlert.actions The actions that will activate when + * the condition is met. + * + * @param {array} [activityLogAlert.actions.actionGroups] The list of activity + * log alerts. + * + * @param {string} [activityLogAlert.description] A description of this + * activity log alert. + * + * @param {string} activityLogAlert.location Resource location + * + * @param {object} [activityLogAlert.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, activityLogAlertName, activityLogAlert, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, activityLogAlertName, activityLogAlert, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create a new activity log alert or update an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} activityLogAlert The activity log alert to create or use for + * the update. + * + * @param {array} activityLogAlert.scopes A list of resourceIds that will be + * used as prefixes. The alert will only apply to activityLogs with resourceIds + * that fall under one of these prefixes. This list must include at least one + * item. + * + * @param {boolean} [activityLogAlert.enabled] Indicates whether this activity + * log alert is enabled. If an activity log alert is not enabled, then none of + * its actions will be activated. + * + * @param {object} activityLogAlert.condition The condition that will cause + * this alert to activate. + * + * @param {array} activityLogAlert.condition.allOf The list of activity log + * alert conditions. + * + * @param {object} activityLogAlert.actions The actions that will activate when + * the condition is met. + * + * @param {array} [activityLogAlert.actions.actionGroups] The list of activity + * log alerts. + * + * @param {string} [activityLogAlert.description] A description of this + * activity log alert. + * + * @param {string} activityLogAlert.location Resource location + * + * @param {object} [activityLogAlert.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ActivityLogAlertResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, activityLogAlertName, activityLogAlert, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, activityLogAlertName, activityLogAlert, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, activityLogAlertName, activityLogAlert, options, optionalCallback); + } + } + + /** + * Get an activity log alert. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, activityLogAlertName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, activityLogAlertName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get an activity log alert. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ActivityLogAlertResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, activityLogAlertName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, activityLogAlertName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, activityLogAlertName, options, optionalCallback); + } + } + + /** + * Delete an activity log alert. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, activityLogAlertName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, activityLogAlertName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete an activity log alert. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, activityLogAlertName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, activityLogAlertName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, activityLogAlertName, options, optionalCallback); + } + } + + /** + * Updates an existing ActivityLogAlertResource's tags. To update other fields + * use the CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} activityLogAlertPatch Parameters supplied to the operation. + * + * @param {object} [activityLogAlertPatch.tags] Resource tags + * + * @param {boolean} [activityLogAlertPatch.enabled] Indicates whether this + * activity log alert is enabled. If an activity log alert is not enabled, then + * none of its actions will be activated. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, activityLogAlertName, activityLogAlertPatch, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, activityLogAlertName, activityLogAlertPatch, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates an existing ActivityLogAlertResource's tags. To update other fields + * use the CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} activityLogAlertPatch Parameters supplied to the operation. + * + * @param {object} [activityLogAlertPatch.tags] Resource tags + * + * @param {boolean} [activityLogAlertPatch.enabled] Indicates whether this + * activity log alert is enabled. If an activity log alert is not enabled, then + * none of its actions will be activated. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ActivityLogAlertResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName, activityLogAlertName, activityLogAlertPatch, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, activityLogAlertName, activityLogAlertPatch, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, activityLogAlertName, activityLogAlertPatch, options, optionalCallback); + } + } + + /** + * Get a list of all activity log alerts in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listBySubscriptionIdWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listBySubscriptionId(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get a list of all activity log alerts in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ActivityLogAlertList} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertList} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscriptionId(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listBySubscriptionId(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listBySubscriptionId(options, optionalCallback); + } + } + + /** + * Get a list of all activity log alerts in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get a list of all activity log alerts in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {ActivityLogAlertList} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertList} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); + } + } + +} + +module.exports = ActivityLogAlerts; diff --git a/lib/services/monitor/lib/operations/activityLogs.js b/lib/services/monitor/lib/operations/activityLogs.js index f34b62a7e5..7128d017ab 100644 --- a/lib/services/monitor/lib/operations/activityLogs.js +++ b/lib/services/monitor/lib/operations/activityLogs.js @@ -318,7 +318,7 @@ function _listNext(nextPageLink, options, callback) { class ActivityLogs { /** * Create a ActivityLogs. - * @param {MonitorClient} client Reference to the service client. + * @param {MonitorManagementClient} client Reference to the service client. */ constructor(client) { this.client = client; diff --git a/lib/services/monitor/lib/operations/alertRuleIncidents.js b/lib/services/monitor/lib/operations/alertRuleIncidents.js new file mode 100644 index 0000000000..fac095135e --- /dev/null +++ b/lib/services/monitor/lib/operations/alertRuleIncidents.js @@ -0,0 +1,500 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets an incident associated to an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {string} incidentName The name of the incident to retrieve. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Incident} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, ruleName, incidentName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (incidentName === null || incidentName === undefined || typeof incidentName.valueOf() !== 'string') { + throw new Error('incidentName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + requestUrl = requestUrl.replace('{incidentName}', encodeURIComponent(incidentName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Incident']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets a list of incidents associated to an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IncidentListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByAlertRule(resourceGroupName, ruleName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['IncidentListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a AlertRuleIncidents. */ +class AlertRuleIncidents { + /** + * Create a AlertRuleIncidents. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._listByAlertRule = _listByAlertRule; + } + + /** + * Gets an incident associated to an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {string} incidentName The name of the incident to retrieve. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, ruleName, incidentName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, ruleName, incidentName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets an incident associated to an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {string} incidentName The name of the incident to retrieve. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Incident} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Incident} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, ruleName, incidentName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, ruleName, incidentName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, ruleName, incidentName, options, optionalCallback); + } + } + + /** + * Gets a list of incidents associated to an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByAlertRuleWithHttpOperationResponse(resourceGroupName, ruleName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByAlertRule(resourceGroupName, ruleName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets a list of incidents associated to an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {IncidentListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link IncidentListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByAlertRule(resourceGroupName, ruleName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByAlertRule(resourceGroupName, ruleName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByAlertRule(resourceGroupName, ruleName, options, optionalCallback); + } + } + +} + +module.exports = AlertRuleIncidents; diff --git a/lib/services/monitor/lib/operations/alertRules.js b/lib/services/monitor/lib/operations/alertRules.js new file mode 100644 index 0000000000..3676f74c97 --- /dev/null +++ b/lib/services/monitor/lib/operations/alertRules.js @@ -0,0 +1,1423 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Creates or updates an alert rule. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} parameters.alertRuleResourceName the name of the alert rule. + * + * @param {string} [parameters.description] the description of the alert rule + * that will be included in the alert email. + * + * @param {boolean} parameters.isEnabled the flag that indicates whether the + * alert rule is enabled. + * + * @param {object} parameters.condition the condition that results in the alert + * rule being activated. + * + * @param {object} [parameters.condition.dataSource] the resource from which + * the rule collects its data. For this type dataSource will always be of type + * RuleMetricDataSource. + * + * @param {string} [parameters.condition.dataSource.resourceUri] the resource + * identifier of the resource the rule monitors. **NOTE**: this property cannot + * be updated for an existing rule. + * + * @param {string} parameters.condition.dataSource.odatatype Polymorphic + * Discriminator + * + * @param {string} parameters.condition.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, ruleName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['AlertRuleResource']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AlertRuleResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AlertRuleResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, ruleName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, ruleName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AlertRuleResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Updates an existing AlertRuleResource. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} alertRulesResource Parameters supplied to the operation. + * + * @param {object} [alertRulesResource.tags] Resource tags + * + * @param {string} alertRulesResource.name the name of the alert rule. + * + * @param {string} [alertRulesResource.description] the description of the + * alert rule that will be included in the alert email. + * + * @param {boolean} alertRulesResource.isEnabled the flag that indicates + * whether the alert rule is enabled. + * + * @param {object} alertRulesResource.condition the condition that results in + * the alert rule being activated. + * + * @param {object} [alertRulesResource.condition.dataSource] the resource from + * which the rule collects its data. For this type dataSource will always be of + * type RuleMetricDataSource. + * + * @param {string} [alertRulesResource.condition.dataSource.resourceUri] the + * resource identifier of the resource the rule monitors. **NOTE**: this + * property cannot be updated for an existing rule. + * + * @param {string} alertRulesResource.condition.dataSource.odatatype + * Polymorphic Discriminator + * + * @param {string} alertRulesResource.condition.odatatype Polymorphic + * Discriminator + * + * @param {array} [alertRulesResource.actions] the array of actions that are + * performed when the alert rule becomes active, and when an alert condition is + * resolved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(resourceGroupName, ruleName, alertRulesResource, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (alertRulesResource === null || alertRulesResource === undefined) { + throw new Error('alertRulesResource cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (alertRulesResource !== null && alertRulesResource !== undefined) { + let requestModelMapper = new client.models['AlertRuleResourcePatch']().mapper(); + requestModel = client.serialize(requestModelMapper, alertRulesResource, 'alertRulesResource'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(alertRulesResource, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AlertRuleResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AlertRuleResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * List the alert rules within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroup(resourceGroupName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AlertRuleResourceCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a AlertRules. */ +class AlertRules { + /** + * Create a AlertRules. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + this._get = _get; + this._update = _update; + this._listByResourceGroup = _listByResourceGroup; + } + + /** + * Creates or updates an alert rule. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} parameters.alertRuleResourceName the name of the alert rule. + * + * @param {string} [parameters.description] the description of the alert rule + * that will be included in the alert email. + * + * @param {boolean} parameters.isEnabled the flag that indicates whether the + * alert rule is enabled. + * + * @param {object} parameters.condition the condition that results in the alert + * rule being activated. + * + * @param {object} [parameters.condition.dataSource] the resource from which + * the rule collects its data. For this type dataSource will always be of type + * RuleMetricDataSource. + * + * @param {string} [parameters.condition.dataSource.resourceUri] the resource + * identifier of the resource the rule monitors. **NOTE**: this property cannot + * be updated for an existing rule. + * + * @param {string} parameters.condition.dataSource.odatatype Polymorphic + * Discriminator + * + * @param {string} parameters.condition.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, ruleName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, ruleName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates an alert rule. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} parameters.alertRuleResourceName the name of the alert rule. + * + * @param {string} [parameters.description] the description of the alert rule + * that will be included in the alert email. + * + * @param {boolean} parameters.isEnabled the flag that indicates whether the + * alert rule is enabled. + * + * @param {object} parameters.condition the condition that results in the alert + * rule being activated. + * + * @param {object} [parameters.condition.dataSource] the resource from which + * the rule collects its data. For this type dataSource will always be of type + * RuleMetricDataSource. + * + * @param {string} [parameters.condition.dataSource.resourceUri] the resource + * identifier of the resource the rule monitors. **NOTE**: this property cannot + * be updated for an existing rule. + * + * @param {string} parameters.condition.dataSource.odatatype Polymorphic + * Discriminator + * + * @param {string} parameters.condition.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {AlertRuleResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, ruleName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, ruleName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, ruleName, parameters, options, optionalCallback); + } + } + + /** + * Deletes an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, ruleName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, ruleName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, ruleName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, ruleName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, ruleName, options, optionalCallback); + } + } + + /** + * Gets an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, ruleName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, ruleName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {AlertRuleResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, ruleName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, ruleName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, ruleName, options, optionalCallback); + } + } + + /** + * Updates an existing AlertRuleResource. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} alertRulesResource Parameters supplied to the operation. + * + * @param {object} [alertRulesResource.tags] Resource tags + * + * @param {string} alertRulesResource.name the name of the alert rule. + * + * @param {string} [alertRulesResource.description] the description of the + * alert rule that will be included in the alert email. + * + * @param {boolean} alertRulesResource.isEnabled the flag that indicates + * whether the alert rule is enabled. + * + * @param {object} alertRulesResource.condition the condition that results in + * the alert rule being activated. + * + * @param {object} [alertRulesResource.condition.dataSource] the resource from + * which the rule collects its data. For this type dataSource will always be of + * type RuleMetricDataSource. + * + * @param {string} [alertRulesResource.condition.dataSource.resourceUri] the + * resource identifier of the resource the rule monitors. **NOTE**: this + * property cannot be updated for an existing rule. + * + * @param {string} alertRulesResource.condition.dataSource.odatatype + * Polymorphic Discriminator + * + * @param {string} alertRulesResource.condition.odatatype Polymorphic + * Discriminator + * + * @param {array} [alertRulesResource.actions] the array of actions that are + * performed when the alert rule becomes active, and when an alert condition is + * resolved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, ruleName, alertRulesResource, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, ruleName, alertRulesResource, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates an existing AlertRuleResource. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} alertRulesResource Parameters supplied to the operation. + * + * @param {object} [alertRulesResource.tags] Resource tags + * + * @param {string} alertRulesResource.name the name of the alert rule. + * + * @param {string} [alertRulesResource.description] the description of the + * alert rule that will be included in the alert email. + * + * @param {boolean} alertRulesResource.isEnabled the flag that indicates + * whether the alert rule is enabled. + * + * @param {object} alertRulesResource.condition the condition that results in + * the alert rule being activated. + * + * @param {object} [alertRulesResource.condition.dataSource] the resource from + * which the rule collects its data. For this type dataSource will always be of + * type RuleMetricDataSource. + * + * @param {string} [alertRulesResource.condition.dataSource.resourceUri] the + * resource identifier of the resource the rule monitors. **NOTE**: this + * property cannot be updated for an existing rule. + * + * @param {string} alertRulesResource.condition.dataSource.odatatype + * Polymorphic Discriminator + * + * @param {string} alertRulesResource.condition.odatatype Polymorphic + * Discriminator + * + * @param {array} [alertRulesResource.actions] the array of actions that are + * performed when the alert rule becomes active, and when an alert condition is + * resolved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {AlertRuleResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName, ruleName, alertRulesResource, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, ruleName, alertRulesResource, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, ruleName, alertRulesResource, options, optionalCallback); + } + } + + /** + * List the alert rules within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List the alert rules within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {AlertRuleResourceCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); + } + } + +} + +module.exports = AlertRules; diff --git a/lib/services/monitor/lib/operations/autoscaleSettings.js b/lib/services/monitor/lib/operations/autoscaleSettings.js new file mode 100644 index 0000000000..a65507da16 --- /dev/null +++ b/lib/services/monitor/lib/operations/autoscaleSettings.js @@ -0,0 +1,1561 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists the autoscale settings for a resource group + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroup(resourceGroupName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2015-04-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AutoscaleSettingResourceCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates or updates an autoscale setting. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {array} parameters.profiles the collection of automatic scaling + * profiles that specify different scaling parameters for different time + * periods. A maximum of 20 profiles can be specified. + * + * @param {array} [parameters.notifications] the collection of notifications. + * + * @param {boolean} [parameters.enabled] the enabled flag. Specifies whether + * automatic scaling is enabled for the resource. The default value is 'true'. + * + * @param {string} [parameters.autoscaleSettingResourceName] the name of the + * autoscale setting. + * + * @param {string} [parameters.targetResourceUri] the resource identifier of + * the resource that the autoscale setting should be added to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, autoscaleSettingName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2015-04-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (autoscaleSettingName === null || autoscaleSettingName === undefined || typeof autoscaleSettingName.valueOf() !== 'string') { + throw new Error('autoscaleSettingName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{autoscaleSettingName}', encodeURIComponent(autoscaleSettingName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['AutoscaleSettingResource']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 201) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AutoscaleSettingResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + // Deserialize Response + if (statusCode === 201) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AutoscaleSettingResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes and autoscale setting + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, autoscaleSettingName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2015-04-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (autoscaleSettingName === null || autoscaleSettingName === undefined || typeof autoscaleSettingName.valueOf() !== 'string') { + throw new Error('autoscaleSettingName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{autoscaleSettingName}', encodeURIComponent(autoscaleSettingName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets an autoscale setting + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, autoscaleSettingName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2015-04-01'; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (autoscaleSettingName === null || autoscaleSettingName === undefined || typeof autoscaleSettingName.valueOf() !== 'string') { + throw new Error('autoscaleSettingName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{autoscaleSettingName}', encodeURIComponent(autoscaleSettingName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AutoscaleSettingResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Updates an existing AutoscaleSettingsResource. To update other fields use + * the CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} autoscaleSettingResource Parameters supplied to the + * operation. + * + * @param {object} [autoscaleSettingResource.tags] Resource tags + * + * @param {array} autoscaleSettingResource.profiles the collection of automatic + * scaling profiles that specify different scaling parameters for different + * time periods. A maximum of 20 profiles can be specified. + * + * @param {array} [autoscaleSettingResource.notifications] the collection of + * notifications. + * + * @param {boolean} [autoscaleSettingResource.enabled] the enabled flag. + * Specifies whether automatic scaling is enabled for the resource. The default + * value is 'true'. + * + * @param {string} [autoscaleSettingResource.name] the name of the autoscale + * setting. + * + * @param {string} [autoscaleSettingResource.targetResourceUri] the resource + * identifier of the resource that the autoscale setting should be added to. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(resourceGroupName, autoscaleSettingName, autoscaleSettingResource, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2015-04-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (autoscaleSettingName === null || autoscaleSettingName === undefined || typeof autoscaleSettingName.valueOf() !== 'string') { + throw new Error('autoscaleSettingName cannot be null or undefined and it must be of type string.'); + } + if (autoscaleSettingResource === null || autoscaleSettingResource === undefined) { + throw new Error('autoscaleSettingResource cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/autoscalesettings/{autoscaleSettingName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{autoscaleSettingName}', encodeURIComponent(autoscaleSettingName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (autoscaleSettingResource !== null && autoscaleSettingResource !== undefined) { + let requestModelMapper = new client.models['AutoscaleSettingResourcePatch']().mapper(); + requestModel = client.serialize(requestModelMapper, autoscaleSettingResource, 'autoscaleSettingResource'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(autoscaleSettingResource, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AutoscaleSettingResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the autoscale settings for a resource group + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroupNext(nextPageLink, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + // Validate + try { + if (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['AutoscaleSettingResourceCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a AutoscaleSettings. */ +class AutoscaleSettings { + /** + * Create a AutoscaleSettings. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listByResourceGroup = _listByResourceGroup; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + this._get = _get; + this._update = _update; + this._listByResourceGroupNext = _listByResourceGroupNext; + } + + /** + * Lists the autoscale settings for a resource group + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the autoscale settings for a resource group + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {AutoscaleSettingResourceCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); + } + } + + /** + * Creates or updates an autoscale setting. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {array} parameters.profiles the collection of automatic scaling + * profiles that specify different scaling parameters for different time + * periods. A maximum of 20 profiles can be specified. + * + * @param {array} [parameters.notifications] the collection of notifications. + * + * @param {boolean} [parameters.enabled] the enabled flag. Specifies whether + * automatic scaling is enabled for the resource. The default value is 'true'. + * + * @param {string} [parameters.autoscaleSettingResourceName] the name of the + * autoscale setting. + * + * @param {string} [parameters.targetResourceUri] the resource identifier of + * the resource that the autoscale setting should be added to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, autoscaleSettingName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, autoscaleSettingName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates an autoscale setting. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {array} parameters.profiles the collection of automatic scaling + * profiles that specify different scaling parameters for different time + * periods. A maximum of 20 profiles can be specified. + * + * @param {array} [parameters.notifications] the collection of notifications. + * + * @param {boolean} [parameters.enabled] the enabled flag. Specifies whether + * automatic scaling is enabled for the resource. The default value is 'true'. + * + * @param {string} [parameters.autoscaleSettingResourceName] the name of the + * autoscale setting. + * + * @param {string} [parameters.targetResourceUri] the resource identifier of + * the resource that the autoscale setting should be added to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {AutoscaleSettingResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, autoscaleSettingName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, autoscaleSettingName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, autoscaleSettingName, parameters, options, optionalCallback); + } + } + + /** + * Deletes and autoscale setting + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, autoscaleSettingName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, autoscaleSettingName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes and autoscale setting + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, autoscaleSettingName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, autoscaleSettingName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, autoscaleSettingName, options, optionalCallback); + } + } + + /** + * Gets an autoscale setting + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, autoscaleSettingName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, autoscaleSettingName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets an autoscale setting + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {AutoscaleSettingResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, autoscaleSettingName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, autoscaleSettingName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, autoscaleSettingName, options, optionalCallback); + } + } + + /** + * Updates an existing AutoscaleSettingsResource. To update other fields use + * the CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} autoscaleSettingResource Parameters supplied to the + * operation. + * + * @param {object} [autoscaleSettingResource.tags] Resource tags + * + * @param {array} autoscaleSettingResource.profiles the collection of automatic + * scaling profiles that specify different scaling parameters for different + * time periods. A maximum of 20 profiles can be specified. + * + * @param {array} [autoscaleSettingResource.notifications] the collection of + * notifications. + * + * @param {boolean} [autoscaleSettingResource.enabled] the enabled flag. + * Specifies whether automatic scaling is enabled for the resource. The default + * value is 'true'. + * + * @param {string} [autoscaleSettingResource.name] the name of the autoscale + * setting. + * + * @param {string} [autoscaleSettingResource.targetResourceUri] the resource + * identifier of the resource that the autoscale setting should be added to. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, autoscaleSettingName, autoscaleSettingResource, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, autoscaleSettingName, autoscaleSettingResource, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates an existing AutoscaleSettingsResource. To update other fields use + * the CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. + * + * @param {object} autoscaleSettingResource Parameters supplied to the + * operation. + * + * @param {object} [autoscaleSettingResource.tags] Resource tags + * + * @param {array} autoscaleSettingResource.profiles the collection of automatic + * scaling profiles that specify different scaling parameters for different + * time periods. A maximum of 20 profiles can be specified. + * + * @param {array} [autoscaleSettingResource.notifications] the collection of + * notifications. + * + * @param {boolean} [autoscaleSettingResource.enabled] the enabled flag. + * Specifies whether automatic scaling is enabled for the resource. The default + * value is 'true'. + * + * @param {string} [autoscaleSettingResource.name] the name of the autoscale + * setting. + * + * @param {string} [autoscaleSettingResource.targetResourceUri] the resource + * identifier of the resource that the autoscale setting should be added to. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {AutoscaleSettingResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName, autoscaleSettingName, autoscaleSettingResource, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, autoscaleSettingName, autoscaleSettingResource, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, autoscaleSettingName, autoscaleSettingResource, options, optionalCallback); + } + } + + /** + * Lists the autoscale settings for a resource group + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the autoscale settings for a resource group + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {AutoscaleSettingResourceCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroupNext(nextPageLink, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroupNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = AutoscaleSettings; diff --git a/lib/services/monitor/lib/operations/diagnosticSettingsCategoryOperations.js b/lib/services/monitor/lib/operations/diagnosticSettingsCategoryOperations.js new file mode 100644 index 0000000000..551dd62984 --- /dev/null +++ b/lib/services/monitor/lib/operations/diagnosticSettingsCategoryOperations.js @@ -0,0 +1,479 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the diagnostic settings category for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsCategoryResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceUri, name, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-05-01-preview'; + // Validate + try { + if (resourceUri === null || resourceUri === undefined || typeof resourceUri.valueOf() !== 'string') { + throw new Error('resourceUri cannot be null or undefined and it must be of type string.'); + } + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{resourceUri}/providers/microsoft.insights/diagnosticSettingsCategories/{name}'; + requestUrl = requestUrl.replace('{resourceUri}', resourceUri); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DiagnosticSettingsCategoryResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Lists the diagnostic settings categories for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link + * DiagnosticSettingsCategoryResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(resourceUri, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-05-01-preview'; + // Validate + try { + if (resourceUri === null || resourceUri === undefined || typeof resourceUri.valueOf() !== 'string') { + throw new Error('resourceUri cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{resourceUri}/providers/microsoft.insights/diagnosticSettingsCategories'; + requestUrl = requestUrl.replace('{resourceUri}', resourceUri); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DiagnosticSettingsCategoryResourceCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a DiagnosticSettingsCategoryOperations. */ +class DiagnosticSettingsCategoryOperations { + /** + * Create a DiagnosticSettingsCategoryOperations. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._list = _list; + } + + /** + * Gets the diagnostic settings category for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceUri, name, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceUri, name, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the diagnostic settings category for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {DiagnosticSettingsCategoryResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsCategoryResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceUri, name, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceUri, name, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceUri, name, options, optionalCallback); + } + } + + /** + * Lists the diagnostic settings categories for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(resourceUri, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(resourceUri, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the diagnostic settings categories for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {DiagnosticSettingsCategoryResourceCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link + * DiagnosticSettingsCategoryResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(resourceUri, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(resourceUri, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(resourceUri, options, optionalCallback); + } + } + +} + +module.exports = DiagnosticSettingsCategoryOperations; diff --git a/lib/services/monitor/lib/operations/diagnosticSettingsOperations.js b/lib/services/monitor/lib/operations/diagnosticSettingsOperations.js new file mode 100644 index 0000000000..be6f0864d9 --- /dev/null +++ b/lib/services/monitor/lib/operations/diagnosticSettingsOperations.js @@ -0,0 +1,991 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Gets the active diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceUri, name, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-05-01-preview'; + // Validate + try { + if (resourceUri === null || resourceUri === undefined || typeof resourceUri.valueOf() !== 'string') { + throw new Error('resourceUri cannot be null or undefined and it must be of type string.'); + } + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}'; + requestUrl = requestUrl.replace('{resourceUri}', resourceUri); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DiagnosticSettingsResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Creates or updates diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {string} [parameters.storageAccountId] The resource ID of the storage + * account to which you would like to send Diagnostic Logs. + * + * @param {string} [parameters.eventHubAuthorizationRuleId] The resource Id for + * the event hub authorization rule. + * + * @param {string} [parameters.eventHubName] The name of the event hub. If none + * is specified, the default event hub will be selected. + * + * @param {array} [parameters.metrics] the list of metric settings. + * + * @param {array} [parameters.logs] the list of logs settings. + * + * @param {string} [parameters.workspaceId] The workspace ID (resource ID of a + * Log Analytics workspace) for a Log Analytics workspace to which you would + * like to send Diagnostic Logs. Example: + * /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceUri, parameters, name, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-05-01-preview'; + // Validate + try { + if (resourceUri === null || resourceUri === undefined || typeof resourceUri.valueOf() !== 'string') { + throw new Error('resourceUri cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}'; + requestUrl = requestUrl.replace('{resourceUri}', resourceUri); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['DiagnosticSettingsResource']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DiagnosticSettingsResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Deletes existing diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceUri, name, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-05-01-preview'; + // Validate + try { + if (resourceUri === null || resourceUri === undefined || typeof resourceUri.valueOf() !== 'string') { + throw new Error('resourceUri cannot be null or undefined and it must be of type string.'); + } + if (name === null || name === undefined || typeof name.valueOf() !== 'string') { + throw new Error('name cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{resourceUri}/providers/microsoft.insights/diagnosticSettings/{name}'; + requestUrl = requestUrl.replace('{resourceUri}', resourceUri); + requestUrl = requestUrl.replace('{name}', encodeURIComponent(name)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets the active diagnostic settings list for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsResourceCollection} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(resourceUri, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-05-01-preview'; + // Validate + try { + if (resourceUri === null || resourceUri === undefined || typeof resourceUri.valueOf() !== 'string') { + throw new Error('resourceUri cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{resourceUri}/providers/microsoft.insights/diagnosticSettings'; + requestUrl = requestUrl.replace('{resourceUri}', resourceUri); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['DiagnosticSettingsResourceCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a DiagnosticSettingsOperations. */ +class DiagnosticSettingsOperations { + /** + * Create a DiagnosticSettingsOperations. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._deleteMethod = _deleteMethod; + this._list = _list; + } + + /** + * Gets the active diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceUri, name, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceUri, name, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the active diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {DiagnosticSettingsResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceUri, name, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceUri, name, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceUri, name, options, optionalCallback); + } + } + + /** + * Creates or updates diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {string} [parameters.storageAccountId] The resource ID of the storage + * account to which you would like to send Diagnostic Logs. + * + * @param {string} [parameters.eventHubAuthorizationRuleId] The resource Id for + * the event hub authorization rule. + * + * @param {string} [parameters.eventHubName] The name of the event hub. If none + * is specified, the default event hub will be selected. + * + * @param {array} [parameters.metrics] the list of metric settings. + * + * @param {array} [parameters.logs] the list of logs settings. + * + * @param {string} [parameters.workspaceId] The workspace ID (resource ID of a + * Log Analytics workspace) for a Log Analytics workspace to which you would + * like to send Diagnostic Logs. Example: + * /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceUri, parameters, name, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceUri, parameters, name, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Creates or updates diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {string} [parameters.storageAccountId] The resource ID of the storage + * account to which you would like to send Diagnostic Logs. + * + * @param {string} [parameters.eventHubAuthorizationRuleId] The resource Id for + * the event hub authorization rule. + * + * @param {string} [parameters.eventHubName] The name of the event hub. If none + * is specified, the default event hub will be selected. + * + * @param {array} [parameters.metrics] the list of metric settings. + * + * @param {array} [parameters.logs] the list of logs settings. + * + * @param {string} [parameters.workspaceId] The workspace ID (resource ID of a + * Log Analytics workspace) for a Log Analytics workspace to which you would + * like to send Diagnostic Logs. Example: + * /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {DiagnosticSettingsResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsResource} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceUri, parameters, name, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceUri, parameters, name, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceUri, parameters, name, options, optionalCallback); + } + } + + /** + * Deletes existing diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceUri, name, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceUri, name, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes existing diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceUri, name, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceUri, name, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceUri, name, options, optionalCallback); + } + } + + /** + * Gets the active diagnostic settings list for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(resourceUri, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(resourceUri, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the active diagnostic settings list for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {DiagnosticSettingsResourceCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsResourceCollection} for + * more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(resourceUri, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(resourceUri, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(resourceUri, options, optionalCallback); + } + } + +} + +module.exports = DiagnosticSettingsOperations; diff --git a/lib/services/monitor/lib/operations/eventCategories.js b/lib/services/monitor/lib/operations/eventCategories.js index e61b6a7823..b9705aa81a 100644 --- a/lib/services/monitor/lib/operations/eventCategories.js +++ b/lib/services/monitor/lib/operations/eventCategories.js @@ -149,7 +149,7 @@ function _list(options, callback) { class EventCategories { /** * Create a EventCategories. - * @param {MonitorClient} client Reference to the service client. + * @param {MonitorManagementClient} client Reference to the service client. */ constructor(client) { this.client = client; diff --git a/lib/services/monitor/lib/operations/index.d.ts b/lib/services/monitor/lib/operations/index.d.ts index 70bc006478..e3c9bb1680 100644 --- a/lib/services/monitor/lib/operations/index.d.ts +++ b/lib/services/monitor/lib/operations/index.d.ts @@ -15,54 +15,38 @@ import * as models from '../models'; /** * @class - * UsageMetrics + * AutoscaleSettings * __NOTE__: An instance of this class is automatically created for an - * instance of the MonitorClient. + * instance of the MonitorManagementClient. */ -export interface UsageMetrics { +export interface AutoscaleSettings { /** - * The List operation lists the usage metrics for the resource.
**WARNING**: - * This operation will be *deprecated* in the next release. + * Lists the autoscale settings for a resource group * - * @param {string} resourceUri The identifier of the resource. - * - * @param {string} apiVersion Client Api Version. NOTE: This is not a client - * property, it must be explicit in the call and there is no default value. + * @param {string} resourceGroupName The name of the resource group. * * @param {object} [options] Optional Parameters. * - * @param {string} [options.filter] The filter to apply on the - * operation.
**WARNING**: $filter not documented since the operation will - * be deprecated in the next release. - * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(resourceUri: string, apiVersion: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * The List operation lists the usage metrics for the resource.
**WARNING**: - * This operation will be *deprecated* in the next release. - * - * @param {string} resourceUri The identifier of the resource. + * Lists the autoscale settings for a resource group * - * @param {string} apiVersion Client Api Version. NOTE: This is not a client - * property, it must be explicit in the call and there is no default value. + * @param {string} resourceGroupName The name of the resource group. * * @param {object} [options] Optional Parameters. * - * @param {string} [options.filter] The filter to apply on the - * operation.
**WARNING**: $filter not documented since the operation will - * be deprecated in the next release. - * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -73,7 +57,7 @@ export interface UsageMetrics { * * {Promise} A promise is returned. * - * @resolve {UsageMetricCollection} - The deserialized result object. + * @resolve {AutoscaleSettingResourceCollection} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -81,99 +65,89 @@ export interface UsageMetrics { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {UsageMetricCollection} [result] - The deserialized result object if an error did not occur. - * See {@link UsageMetricCollection} for more information. + * {AutoscaleSettingResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResourceCollection} for more + * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - list(resourceUri: string, apiVersion: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - list(resourceUri: string, apiVersion: string, callback: ServiceCallback): void; - list(resourceUri: string, apiVersion: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * ActivityLogs - * __NOTE__: An instance of this class is automatically created for an - * instance of the MonitorClient. - */ -export interface ActivityLogs { + listByResourceGroup(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Provides the list of records from the activity logs. + * Creates or updates an autoscale setting. * - * @param {object} [options] Optional Parameters. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} [options.filter] Reduces the set of data collected.
The - * **$filter** argument is very restricted and allows only the following - * patterns.
- *List events for a resource group*: $filter=eventTimestamp ge - * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - * '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq - * 'resourceGroupName'.
- *List events for resource*: $filter=eventTimestamp - * ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - * '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.
- *List - * events for a subscription in a time range*: $filter=eventTimestamp ge - * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - * '2014-07-20T04:36:37.6407898Z'.
- *List events for a resource provider*: - * $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp - * le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq - * 'resourceProviderName'.
- *List events for a correlation Id*: - * $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp - * le '2014-07-20T04:36:37.6407898Z' and correlationId eq - * 'correlationID'.

**NOTE**: No other syntax is allowed. + * @param {string} autoscaleSettingName The autoscale setting name. * - * @param {string} [options.select] Used to fetch events with only the given - * properties.
The **$select** argument is a comma separated list of - * property names to be returned. Possible values are: *authorization*, - * *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, - * *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, - * *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, - * *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* + * @param {object} parameters Parameters supplied to the operation. + * + * @param {array} parameters.profiles the collection of automatic scaling + * profiles that specify different scaling parameters for different time + * periods. A maximum of 20 profiles can be specified. + * + * @param {array} [parameters.notifications] the collection of notifications. + * + * @param {boolean} [parameters.enabled] the enabled flag. Specifies whether + * automatic scaling is enabled for the resource. The default value is 'true'. + * + * @param {string} [parameters.autoscaleSettingResourceName] the name of the + * autoscale setting. + * + * @param {string} [parameters.targetResourceUri] the resource identifier of + * the resource that the autoscale setting should be added to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(options?: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, autoscaleSettingName: string, parameters: models.AutoscaleSettingResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Provides the list of records from the activity logs. + * Creates or updates an autoscale setting. * - * @param {object} [options] Optional Parameters. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} [options.filter] Reduces the set of data collected.
The - * **$filter** argument is very restricted and allows only the following - * patterns.
- *List events for a resource group*: $filter=eventTimestamp ge - * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - * '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq - * 'resourceGroupName'.
- *List events for resource*: $filter=eventTimestamp - * ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - * '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.
- *List - * events for a subscription in a time range*: $filter=eventTimestamp ge - * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - * '2014-07-20T04:36:37.6407898Z'.
- *List events for a resource provider*: - * $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp - * le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq - * 'resourceProviderName'.
- *List events for a correlation Id*: - * $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp - * le '2014-07-20T04:36:37.6407898Z' and correlationId eq - * 'correlationID'.

**NOTE**: No other syntax is allowed. + * @param {string} autoscaleSettingName The autoscale setting name. * - * @param {string} [options.select] Used to fetch events with only the given - * properties.
The **$select** argument is a comma separated list of - * property names to be returned. Possible values are: *authorization*, - * *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, - * *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, - * *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, - * *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* + * @param {object} parameters Parameters supplied to the operation. + * + * @param {array} parameters.profiles the collection of automatic scaling + * profiles that specify different scaling parameters for different time + * periods. A maximum of 20 profiles can be specified. + * + * @param {array} [parameters.notifications] the collection of notifications. + * + * @param {boolean} [parameters.enabled] the enabled flag. Specifies whether + * automatic scaling is enabled for the resource. The default value is 'true'. + * + * @param {string} [parameters.autoscaleSettingResourceName] the name of the + * autoscale setting. + * + * @param {string} [parameters.targetResourceUri] the resource identifier of + * the resource that the autoscale setting should be added to. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -185,7 +159,7 @@ export interface ActivityLogs { * * {Promise} A promise is returned. * - * @resolve {EventDataCollection} - The deserialized result object. + * @resolve {AutoscaleSettingResource} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -193,23 +167,25 @@ export interface ActivityLogs { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {EventDataCollection} [result] - The deserialized result object if an error did not occur. - * See {@link EventDataCollection} for more information. + * {AutoscaleSettingResource} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResource} for more + * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - list(options?: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, autoscaleSettingName: string, parameters: models.AutoscaleSettingResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, autoscaleSettingName: string, parameters: models.AutoscaleSettingResource, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, autoscaleSettingName: string, parameters: models.AutoscaleSettingResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Provides the list of records from the activity logs. + * Deletes and autoscale setting * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. * * @param {object} [options] Optional Parameters. * @@ -218,17 +194,18 @@ export interface ActivityLogs { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + deleteMethodWithHttpOperationResponse(resourceGroupName: string, autoscaleSettingName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Provides the list of records from the activity logs. + * Deletes and autoscale setting * - * @param {string} nextPageLink The NextLink from the previous successful call - * to List operation. + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. * * @param {object} [options] Optional Parameters. * @@ -242,7 +219,7 @@ export interface ActivityLogs { * * {Promise} A promise is returned. * - * @resolve {EventDataCollection} - The deserialized result object. + * @resolve {null} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -250,31 +227,23 @@ export interface ActivityLogs { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {EventDataCollection} [result] - The deserialized result object if an error did not occur. - * See {@link EventDataCollection} for more information. + * {null} [result] - The deserialized result object if an error did not occur. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listNext(nextPageLink: string, callback: ServiceCallback): void; - listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * EventCategories - * __NOTE__: An instance of this class is automatically created for an - * instance of the MonitorClient. - */ -export interface EventCategories { + deleteMethod(resourceGroupName: string, autoscaleSettingName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, autoscaleSettingName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, autoscaleSettingName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Get the list of available event categories supported in the Activity Logs - * Service.
The current list includes the following: Administrative, - * Security, ServiceHealth, Alert, Recommendation, Policy. + * Gets an autoscale setting + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. * * @param {object} [options] Optional Parameters. * @@ -283,16 +252,18 @@ export interface EventCategories { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + getWithHttpOperationResponse(resourceGroupName: string, autoscaleSettingName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Get the list of available event categories supported in the Activity Logs - * Service.
The current list includes the following: Administrative, - * Security, ServiceHealth, Alert, Recommendation, Policy. + * Gets an autoscale setting + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} autoscaleSettingName The autoscale setting name. * * @param {object} [options] Optional Parameters. * @@ -306,7 +277,7 @@ export interface EventCategories { * * {Promise} A promise is returned. * - * @resolve {EventCategoryCollection} - The deserialized result object. + * @resolve {AutoscaleSettingResource} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -314,108 +285,93 @@ export interface EventCategories { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {EventCategoryCollection} [result] - The deserialized result object if an error did not occur. - * See {@link EventCategoryCollection} for more + * {AutoscaleSettingResource} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResource} for more * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; -} - -/** - * @class - * TenantActivityLogs - * __NOTE__: An instance of this class is automatically created for an - * instance of the MonitorClient. - */ -export interface TenantActivityLogs { + get(resourceGroupName: string, autoscaleSettingName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, autoscaleSettingName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, autoscaleSettingName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets the Activity Logs for the Tenant.
Everything that is applicable to - * the API to get the Activity Logs for the subscription is applicable to this - * API (the parameters, $filter, etc.).
One thing to point out here is that - * this API does *not* retrieve the logs at the individual subscription of the - * tenant but only surfaces the logs that were generated at the tenant level. + * Updates an existing AutoscaleSettingsResource. To update other fields use + * the CreateOrUpdate method. * - * @param {object} [options] Optional Parameters. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} [options.filter] Reduces the set of data collected.
The - * **$filter** is very restricted and allows only the following patterns.
- - * List events for a resource group: $filter=eventTimestamp ge '' - * and eventTimestamp le '' and eventChannels eq 'Admin, Operation' - * and resourceGroupName eq ''.
- List events for - * resource: $filter=eventTimestamp ge '' and eventTimestamp le - * '' and eventChannels eq 'Admin, Operation' and resourceUri eq - * ''.
- List events for a subscription: $filter=eventTimestamp - * ge '' and eventTimestamp le '' and eventChannels eq - * 'Admin, Operation'.
- List events for a resource provider: - * $filter=eventTimestamp ge '' and eventTimestamp le '' - * and eventChannels eq 'Admin, Operation' and resourceProvider eq - * ''.
- List events for a correlation Id: - * api-version=2014-04-01&$filter=eventTimestamp ge - * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - * '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - * correlationId eq ''.
**NOTE**: No other syntax is allowed. + * @param {string} autoscaleSettingName The autoscale setting name. * - * @param {string} [options.select] Used to fetch events with only the given - * properties.
The **$select** argument is a comma separated list of - * property names to be returned. Possible values are: *authorization*, - * *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, - * *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, - * *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, - * *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* + * @param {object} autoscaleSettingResource Parameters supplied to the + * operation. + * + * @param {object} [autoscaleSettingResource.tags] Resource tags + * + * @param {array} autoscaleSettingResource.profiles the collection of automatic + * scaling profiles that specify different scaling parameters for different + * time periods. A maximum of 20 profiles can be specified. + * + * @param {array} [autoscaleSettingResource.notifications] the collection of + * notifications. + * + * @param {boolean} [autoscaleSettingResource.enabled] the enabled flag. + * Specifies whether automatic scaling is enabled for the resource. The default + * value is 'true'. + * + * @param {string} [autoscaleSettingResource.name] the name of the autoscale + * setting. + * + * @param {string} [autoscaleSettingResource.targetResourceUri] the resource + * identifier of the resource that the autoscale setting should be added to. + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(options?: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + updateWithHttpOperationResponse(resourceGroupName: string, autoscaleSettingName: string, autoscaleSettingResource: models.AutoscaleSettingResourcePatch, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets the Activity Logs for the Tenant.
Everything that is applicable to - * the API to get the Activity Logs for the subscription is applicable to this - * API (the parameters, $filter, etc.).
One thing to point out here is that - * this API does *not* retrieve the logs at the individual subscription of the - * tenant but only surfaces the logs that were generated at the tenant level. + * Updates an existing AutoscaleSettingsResource. To update other fields use + * the CreateOrUpdate method. * - * @param {object} [options] Optional Parameters. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} [options.filter] Reduces the set of data collected.
The - * **$filter** is very restricted and allows only the following patterns.
- - * List events for a resource group: $filter=eventTimestamp ge '' - * and eventTimestamp le '' and eventChannels eq 'Admin, Operation' - * and resourceGroupName eq ''.
- List events for - * resource: $filter=eventTimestamp ge '' and eventTimestamp le - * '' and eventChannels eq 'Admin, Operation' and resourceUri eq - * ''.
- List events for a subscription: $filter=eventTimestamp - * ge '' and eventTimestamp le '' and eventChannels eq - * 'Admin, Operation'.
- List events for a resource provider: - * $filter=eventTimestamp ge '' and eventTimestamp le '' - * and eventChannels eq 'Admin, Operation' and resourceProvider eq - * ''.
- List events for a correlation Id: - * api-version=2014-04-01&$filter=eventTimestamp ge - * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le - * '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and - * correlationId eq ''.
**NOTE**: No other syntax is allowed. + * @param {string} autoscaleSettingName The autoscale setting name. * - * @param {string} [options.select] Used to fetch events with only the given - * properties.
The **$select** argument is a comma separated list of - * property names to be returned. Possible values are: *authorization*, - * *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, - * *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, - * *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, - * *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* + * @param {object} autoscaleSettingResource Parameters supplied to the + * operation. + * + * @param {object} [autoscaleSettingResource.tags] Resource tags + * + * @param {array} autoscaleSettingResource.profiles the collection of automatic + * scaling profiles that specify different scaling parameters for different + * time periods. A maximum of 20 profiles can be specified. + * + * @param {array} [autoscaleSettingResource.notifications] the collection of + * notifications. + * + * @param {boolean} [autoscaleSettingResource.enabled] the enabled flag. + * Specifies whether automatic scaling is enabled for the resource. The default + * value is 'true'. + * + * @param {string} [autoscaleSettingResource.name] the name of the autoscale + * setting. + * + * @param {string} [autoscaleSettingResource.targetResourceUri] the resource + * identifier of the resource that the autoscale setting should be added to. + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -427,7 +383,7 @@ export interface TenantActivityLogs { * * {Promise} A promise is returned. * - * @resolve {EventDataCollection} - The deserialized result object. + * @resolve {AutoscaleSettingResource} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -435,24 +391,21 @@ export interface TenantActivityLogs { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {EventDataCollection} [result] - The deserialized result object if an error did not occur. - * See {@link EventDataCollection} for more information. + * {AutoscaleSettingResource} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResource} for more + * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - list(options?: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - list(callback: ServiceCallback): void; - list(options: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + update(resourceGroupName: string, autoscaleSettingName: string, autoscaleSettingResource: models.AutoscaleSettingResourcePatch, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, autoscaleSettingName: string, autoscaleSettingResource: models.AutoscaleSettingResourcePatch, callback: ServiceCallback): void; + update(resourceGroupName: string, autoscaleSettingName: string, autoscaleSettingResource: models.AutoscaleSettingResourcePatch, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** - * Gets the Activity Logs for the Tenant.
Everything that is applicable to - * the API to get the Activity Logs for the subscription is applicable to this - * API (the parameters, $filter, etc.).
One thing to point out here is that - * this API does *not* retrieve the logs at the individual subscription of the - * tenant but only surfaces the logs that were generated at the tenant level. + * Lists the autoscale settings for a resource group * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -464,18 +417,14 @@ export interface TenantActivityLogs { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listByResourceGroupNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Gets the Activity Logs for the Tenant.
Everything that is applicable to - * the API to get the Activity Logs for the subscription is applicable to this - * API (the parameters, $filter, etc.).
One thing to point out here is that - * this API does *not* retrieve the logs at the individual subscription of the - * tenant but only surfaces the logs that were generated at the tenant level. + * Lists the autoscale settings for a resource group * * @param {string} nextPageLink The NextLink from the previous successful call * to List operation. @@ -492,7 +441,7 @@ export interface TenantActivityLogs { * * {Promise} A promise is returned. * - * @resolve {EventDataCollection} - The deserialized result object. + * @resolve {AutoscaleSettingResourceCollection} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -500,31 +449,30 @@ export interface TenantActivityLogs { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {EventDataCollection} [result] - The deserialized result object if an error did not occur. - * See {@link EventDataCollection} for more information. + * {AutoscaleSettingResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link AutoscaleSettingResourceCollection} for more + * information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - listNext(nextPageLink: string, callback: ServiceCallback): void; - listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + listByResourceGroupNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroupNext(nextPageLink: string, callback: ServiceCallback): void; + listByResourceGroupNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** * @class - * MetricDefinitions + * Operations * __NOTE__: An instance of this class is automatically created for an - * instance of the MonitorClient. + * instance of the MonitorManagementClient. */ -export interface MetricDefinitions { +export interface Operations { /** - * Lists the metric definitions for the resource. - * - * @param {string} resourceUri The identifier of the resource. + * Lists all of the available operations from Microsoft.Insights provider. * * @param {object} [options] Optional Parameters. * @@ -533,16 +481,14 @@ export interface MetricDefinitions { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(resourceUri: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * Lists the metric definitions for the resource. - * - * @param {string} resourceUri The identifier of the resource. + * Lists all of the available operations from Microsoft.Insights provider. * * @param {object} [options] Optional Parameters. * @@ -556,7 +502,7 @@ export interface MetricDefinitions { * * {Promise} A promise is returned. * - * @resolve {MetricDefinitionCollection} - The deserialized result object. + * @resolve {OperationListResult} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -564,122 +510,252 @@ export interface MetricDefinitions { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {MetricDefinitionCollection} [result] - The deserialized result object if an error did not occur. - * See {@link MetricDefinitionCollection} for more - * information. + * {OperationListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - list(resourceUri: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - list(resourceUri: string, callback: ServiceCallback): void; - list(resourceUri: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } /** * @class - * Metrics + * AlertRuleIncidents * __NOTE__: An instance of this class is automatically created for an - * instance of the MonitorClient. + * instance of the MonitorManagementClient. */ -export interface Metrics { +export interface AlertRuleIncidents { /** - * **Lists the metric values for a resource**. + * Gets an incident associated to an alert rule * - * @param {string} resourceUri The identifier of the resource. + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {string} incidentName The name of the incident to retrieve. * * @param {object} [options] Optional Parameters. * - * @param {string} [options.timespan] The timespan of the query. It is a string - * with the following format 'startDateTime_ISO/endDateTime_ISO'. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of - * the query. + * @returns {Promise} A promise is returned * - * @param {string} [options.metric] The name of the metric to retrieve. + * @resolve {HttpOperationResponse} - The deserialized result object. * - * @param {string} [options.aggregation] The list of aggregation types (comma - * separated) to retrieve. + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, ruleName: string, incidentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets an incident associated to an alert rule * - * @param {number} [options.top] The maximum number of records to retrieve. - * Valid only if $filter is specified. - * Defaults to 10. + * @param {string} resourceGroupName The name of the resource group. * - * @param {string} [options.orderby] The aggregation to use for sorting results - * and the direction of the sort. - * Only one order can be specified. - * Examples: sum asc. + * @param {string} ruleName The name of the rule. * - * @param {string} [options.filter] The **$filter** is used to reduce the set - * of metric data returned.
Example:
Metric contains metadata A, B and - * C.
- Return all time series of C where A = a1 and B = b1 or - * b2
**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- - * Invalid variant:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = - * ‘b2’**
This is invalid because the logical or operator cannot separate - * two different metadata names.
- Return all time series where A = a1, B = - * b1 and C = c1:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- - * Return all time series where A = a1
**$filter=A eq ‘a1’ and B eq ‘*’ and - * C eq ‘*’**. + * @param {string} incidentName The name of the incident to retrieve. * - * @param {string} [options.resultType] Reduces the set of data collected. The - * syntax allowed depends on the operation. See the operation's description for - * details. Possible values include: 'Data', 'Metadata' + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Incident} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Incident} [result] - The deserialized result object if an error did not occur. + * See {@link Incident} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, ruleName: string, incidentName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, ruleName: string, incidentName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, ruleName: string, incidentName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets a list of incidents associated to an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - listWithHttpOperationResponse(resourceUri: string, options?: { timespan? : string, interval? : moment.Duration, metric? : string, aggregation? : string, top? : number, orderby? : string, filter? : string, resultType? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + listByAlertRuleWithHttpOperationResponse(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** - * **Lists the metric values for a resource**. + * Gets a list of incidents associated to an alert rule * - * @param {string} resourceUri The identifier of the resource. + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. * * @param {object} [options] Optional Parameters. * - * @param {string} [options.timespan] The timespan of the query. It is a string - * with the following format 'startDateTime_ISO/endDateTime_ISO'. + * @param {object} [options.customHeaders] Headers that will be added to the + * request * - * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of - * the query. + * @param {ServiceCallback} [optionalCallback] - The optional callback. * - * @param {string} [options.metric] The name of the metric to retrieve. + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. * - * @param {string} [options.aggregation] The list of aggregation types (comma - * separated) to retrieve. + * {Promise} A promise is returned. * - * @param {number} [options.top] The maximum number of records to retrieve. - * Valid only if $filter is specified. - * Defaults to 10. + * @resolve {IncidentListResult} - The deserialized result object. * - * @param {string} [options.orderby] The aggregation to use for sorting results - * and the direction of the sort. - * Only one order can be specified. - * Examples: sum asc. + * @reject {Error|ServiceError} - The error object. * - * @param {string} [options.filter] The **$filter** is used to reduce the set - * of metric data returned.
Example:
Metric contains metadata A, B and - * C.
- Return all time series of C where A = a1 and B = b1 or - * b2
**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- - * Invalid variant:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = - * ‘b2’**
This is invalid because the logical or operator cannot separate - * two different metadata names.
- Return all time series where A = a1, B = - * b1 and C = c1:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- - * Return all time series where A = a1
**$filter=A eq ‘a1’ and B eq ‘*’ and - * C eq ‘*’**. + * {ServiceCallback} optionalCallback(err, result, request, response) * - * @param {string} [options.resultType] Reduces the set of data collected. The - * syntax allowed depends on the operation. See the operation's description for - * details. Possible values include: 'Data', 'Metadata' + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {IncidentListResult} [result] - The deserialized result object if an error did not occur. + * See {@link IncidentListResult} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByAlertRule(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByAlertRule(resourceGroupName: string, ruleName: string, callback: ServiceCallback): void; + listByAlertRule(resourceGroupName: string, ruleName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * AlertRules + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface AlertRules { + + + /** + * Creates or updates an alert rule. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} parameters.alertRuleResourceName the name of the alert rule. + * + * @param {string} [parameters.description] the description of the alert rule + * that will be included in the alert email. + * + * @param {boolean} parameters.isEnabled the flag that indicates whether the + * alert rule is enabled. + * + * @param {object} parameters.condition the condition that results in the alert + * rule being activated. + * + * @param {object} [parameters.condition.dataSource] the resource from which + * the rule collects its data. For this type dataSource will always be of type + * RuleMetricDataSource. + * + * @param {string} [parameters.condition.dataSource.resourceUri] the resource + * identifier of the resource the rule monitors. **NOTE**: this property cannot + * be updated for an existing rule. + * + * @param {string} parameters.condition.dataSource.odatatype Polymorphic + * Discriminator + * + * @param {string} parameters.condition.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, ruleName: string, parameters: models.AlertRuleResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates an alert rule. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} parameters.alertRuleResourceName the name of the alert rule. + * + * @param {string} [parameters.description] the description of the alert rule + * that will be included in the alert email. + * + * @param {boolean} parameters.isEnabled the flag that indicates whether the + * alert rule is enabled. + * + * @param {object} parameters.condition the condition that results in the alert + * rule being activated. + * + * @param {object} [parameters.condition.dataSource] the resource from which + * the rule collects its data. For this type dataSource will always be of type + * RuleMetricDataSource. + * + * @param {string} [parameters.condition.dataSource.resourceUri] the resource + * identifier of the resource the rule monitors. **NOTE**: this property cannot + * be updated for an existing rule. + * + * @param {string} parameters.condition.dataSource.odatatype Polymorphic + * Discriminator + * + * @param {string} parameters.condition.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request @@ -691,7 +767,7 @@ export interface Metrics { * * {Promise} A promise is returned. * - * @resolve {Response} - The deserialized result object. + * @resolve {AlertRuleResource} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -699,14 +775,3492 @@ export interface Metrics { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {Response} [result] - The deserialized result object if an error did not occur. - * See {@link Response} for more information. + * {AlertRuleResource} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResource} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - list(resourceUri: string, options?: { timespan? : string, interval? : moment.Duration, metric? : string, aggregation? : string, top? : number, orderby? : string, filter? : string, resultType? : string, customHeaders? : { [headerName: string]: string; } }): Promise; - list(resourceUri: string, callback: ServiceCallback): void; - list(resourceUri: string, options: { timespan? : string, interval? : moment.Duration, metric? : string, aggregation? : string, top? : number, orderby? : string, filter? : string, resultType? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, ruleName: string, parameters: models.AlertRuleResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, ruleName: string, parameters: models.AlertRuleResource, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, ruleName: string, parameters: models.AlertRuleResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, ruleName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, ruleName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets an alert rule + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {AlertRuleResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {AlertRuleResource} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, ruleName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, ruleName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates an existing AlertRuleResource. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} alertRulesResource Parameters supplied to the operation. + * + * @param {object} [alertRulesResource.tags] Resource tags + * + * @param {string} alertRulesResource.name the name of the alert rule. + * + * @param {string} [alertRulesResource.description] the description of the + * alert rule that will be included in the alert email. + * + * @param {boolean} alertRulesResource.isEnabled the flag that indicates + * whether the alert rule is enabled. + * + * @param {object} alertRulesResource.condition the condition that results in + * the alert rule being activated. + * + * @param {object} [alertRulesResource.condition.dataSource] the resource from + * which the rule collects its data. For this type dataSource will always be of + * type RuleMetricDataSource. + * + * @param {string} [alertRulesResource.condition.dataSource.resourceUri] the + * resource identifier of the resource the rule monitors. **NOTE**: this + * property cannot be updated for an existing rule. + * + * @param {string} alertRulesResource.condition.dataSource.odatatype + * Polymorphic Discriminator + * + * @param {string} alertRulesResource.condition.odatatype Polymorphic + * Discriminator + * + * @param {array} [alertRulesResource.actions] the array of actions that are + * performed when the alert rule becomes active, and when an alert condition is + * resolved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, ruleName: string, alertRulesResource: models.AlertRuleResourcePatch, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates an existing AlertRuleResource. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} alertRulesResource Parameters supplied to the operation. + * + * @param {object} [alertRulesResource.tags] Resource tags + * + * @param {string} alertRulesResource.name the name of the alert rule. + * + * @param {string} [alertRulesResource.description] the description of the + * alert rule that will be included in the alert email. + * + * @param {boolean} alertRulesResource.isEnabled the flag that indicates + * whether the alert rule is enabled. + * + * @param {object} alertRulesResource.condition the condition that results in + * the alert rule being activated. + * + * @param {object} [alertRulesResource.condition.dataSource] the resource from + * which the rule collects its data. For this type dataSource will always be of + * type RuleMetricDataSource. + * + * @param {string} [alertRulesResource.condition.dataSource.resourceUri] the + * resource identifier of the resource the rule monitors. **NOTE**: this + * property cannot be updated for an existing rule. + * + * @param {string} alertRulesResource.condition.dataSource.odatatype + * Polymorphic Discriminator + * + * @param {string} alertRulesResource.condition.odatatype Polymorphic + * Discriminator + * + * @param {array} [alertRulesResource.actions] the array of actions that are + * performed when the alert rule becomes active, and when an alert condition is + * resolved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {AlertRuleResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {AlertRuleResource} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, ruleName: string, alertRulesResource: models.AlertRuleResourcePatch, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, ruleName: string, alertRulesResource: models.AlertRuleResourcePatch, callback: ServiceCallback): void; + update(resourceGroupName: string, ruleName: string, alertRulesResource: models.AlertRuleResourcePatch, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List the alert rules within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List the alert rules within a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {AlertRuleResourceCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {AlertRuleResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link AlertRuleResourceCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * LogProfiles + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface LogProfiles { + + + /** + * Deletes the log profile. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(logProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes the log profile. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(logProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(logProfileName: string, callback: ServiceCallback): void; + deleteMethod(logProfileName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the log profile. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(logProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the log profile. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LogProfileResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {LogProfileResource} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(logProfileName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(logProfileName: string, callback: ServiceCallback): void; + get(logProfileName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Create or update a log profile in Azure Monitoring REST API. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {string} [parameters.storageAccountId] the resource id of the storage + * account to which you would like to send the Activity Log. + * + * @param {string} [parameters.serviceBusRuleId] The service bus rule ID of the + * service bus namespace in which you would like to have Event Hubs created for + * streaming the Activity Log. The rule ID is of the format: '{service bus + * resource ID}/authorizationrules/{key name}'. + * + * @param {array} parameters.locations List of regions for which Activity Log + * events should be stored or streamed. It is a comma separated list of valid + * ARM locations including the 'global' location. + * + * @param {array} parameters.categories the categories of the logs. These + * categories are created as is convenient to the user. Some values are: + * 'Write', 'Delete', and/or 'Action.' + * + * @param {object} parameters.retentionPolicy the retention policy for the + * events in the log. + * + * @param {boolean} parameters.retentionPolicy.enabled a value indicating + * whether the retention policy is enabled. + * + * @param {number} parameters.retentionPolicy.days the number of days for the + * retention in days. A value of 0 will retain the events indefinitely. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(logProfileName: string, parameters: models.LogProfileResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create or update a log profile in Azure Monitoring REST API. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {string} [parameters.storageAccountId] the resource id of the storage + * account to which you would like to send the Activity Log. + * + * @param {string} [parameters.serviceBusRuleId] The service bus rule ID of the + * service bus namespace in which you would like to have Event Hubs created for + * streaming the Activity Log. The rule ID is of the format: '{service bus + * resource ID}/authorizationrules/{key name}'. + * + * @param {array} parameters.locations List of regions for which Activity Log + * events should be stored or streamed. It is a comma separated list of valid + * ARM locations including the 'global' location. + * + * @param {array} parameters.categories the categories of the logs. These + * categories are created as is convenient to the user. Some values are: + * 'Write', 'Delete', and/or 'Action.' + * + * @param {object} parameters.retentionPolicy the retention policy for the + * events in the log. + * + * @param {boolean} parameters.retentionPolicy.enabled a value indicating + * whether the retention policy is enabled. + * + * @param {number} parameters.retentionPolicy.days the number of days for the + * retention in days. A value of 0 will retain the events indefinitely. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LogProfileResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {LogProfileResource} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(logProfileName: string, parameters: models.LogProfileResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(logProfileName: string, parameters: models.LogProfileResource, callback: ServiceCallback): void; + createOrUpdate(logProfileName: string, parameters: models.LogProfileResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates an existing LogProfilesResource. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} logProfilesResource Parameters supplied to the operation. + * + * @param {object} [logProfilesResource.tags] Resource tags + * + * @param {string} [logProfilesResource.storageAccountId] the resource id of + * the storage account to which you would like to send the Activity Log. + * + * @param {string} [logProfilesResource.serviceBusRuleId] The service bus rule + * ID of the service bus namespace in which you would like to have Event Hubs + * created for streaming the Activity Log. The rule ID is of the format: + * '{service bus resource ID}/authorizationrules/{key name}'. + * + * @param {array} logProfilesResource.locations List of regions for which + * Activity Log events should be stored or streamed. It is a comma separated + * list of valid ARM locations including the 'global' location. + * + * @param {array} logProfilesResource.categories the categories of the logs. + * These categories are created as is convenient to the user. Some values are: + * 'Write', 'Delete', and/or 'Action.' + * + * @param {object} logProfilesResource.retentionPolicy the retention policy for + * the events in the log. + * + * @param {boolean} logProfilesResource.retentionPolicy.enabled a value + * indicating whether the retention policy is enabled. + * + * @param {number} logProfilesResource.retentionPolicy.days the number of days + * for the retention in days. A value of 0 will retain the events indefinitely. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(logProfileName: string, logProfilesResource: models.LogProfileResourcePatch, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates an existing LogProfilesResource. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} logProfilesResource Parameters supplied to the operation. + * + * @param {object} [logProfilesResource.tags] Resource tags + * + * @param {string} [logProfilesResource.storageAccountId] the resource id of + * the storage account to which you would like to send the Activity Log. + * + * @param {string} [logProfilesResource.serviceBusRuleId] The service bus rule + * ID of the service bus namespace in which you would like to have Event Hubs + * created for streaming the Activity Log. The rule ID is of the format: + * '{service bus resource ID}/authorizationrules/{key name}'. + * + * @param {array} logProfilesResource.locations List of regions for which + * Activity Log events should be stored or streamed. It is a comma separated + * list of valid ARM locations including the 'global' location. + * + * @param {array} logProfilesResource.categories the categories of the logs. + * These categories are created as is convenient to the user. Some values are: + * 'Write', 'Delete', and/or 'Action.' + * + * @param {object} logProfilesResource.retentionPolicy the retention policy for + * the events in the log. + * + * @param {boolean} logProfilesResource.retentionPolicy.enabled a value + * indicating whether the retention policy is enabled. + * + * @param {number} logProfilesResource.retentionPolicy.days the number of days + * for the retention in days. A value of 0 will retain the events indefinitely. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LogProfileResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {LogProfileResource} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(logProfileName: string, logProfilesResource: models.LogProfileResourcePatch, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(logProfileName: string, logProfilesResource: models.LogProfileResourcePatch, callback: ServiceCallback): void; + update(logProfileName: string, logProfilesResource: models.LogProfileResourcePatch, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List the log profiles. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List the log profiles. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {LogProfileCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {LogProfileCollection} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileCollection} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * DiagnosticSettingsOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface DiagnosticSettingsOperations { + + + /** + * Gets the active diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceUri: string, name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the active diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {DiagnosticSettingsResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {DiagnosticSettingsResource} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsResource} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceUri: string, name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceUri: string, name: string, callback: ServiceCallback): void; + get(resourceUri: string, name: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Creates or updates diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {string} [parameters.storageAccountId] The resource ID of the storage + * account to which you would like to send Diagnostic Logs. + * + * @param {string} [parameters.eventHubAuthorizationRuleId] The resource Id for + * the event hub authorization rule. + * + * @param {string} [parameters.eventHubName] The name of the event hub. If none + * is specified, the default event hub will be selected. + * + * @param {array} [parameters.metrics] the list of metric settings. + * + * @param {array} [parameters.logs] the list of logs settings. + * + * @param {string} [parameters.workspaceId] The workspace ID (resource ID of a + * Log Analytics workspace) for a Log Analytics workspace to which you would + * like to send Diagnostic Logs. Example: + * /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceUri: string, parameters: models.DiagnosticSettingsResource, name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Creates or updates diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {string} [parameters.storageAccountId] The resource ID of the storage + * account to which you would like to send Diagnostic Logs. + * + * @param {string} [parameters.eventHubAuthorizationRuleId] The resource Id for + * the event hub authorization rule. + * + * @param {string} [parameters.eventHubName] The name of the event hub. If none + * is specified, the default event hub will be selected. + * + * @param {array} [parameters.metrics] the list of metric settings. + * + * @param {array} [parameters.logs] the list of logs settings. + * + * @param {string} [parameters.workspaceId] The workspace ID (resource ID of a + * Log Analytics workspace) for a Log Analytics workspace to which you would + * like to send Diagnostic Logs. Example: + * /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2 + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {DiagnosticSettingsResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {DiagnosticSettingsResource} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsResource} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceUri: string, parameters: models.DiagnosticSettingsResource, name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceUri: string, parameters: models.DiagnosticSettingsResource, name: string, callback: ServiceCallback): void; + createOrUpdate(resourceUri: string, parameters: models.DiagnosticSettingsResource, name: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes existing diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceUri: string, name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes existing diagnostic settings for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceUri: string, name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceUri: string, name: string, callback: ServiceCallback): void; + deleteMethod(resourceUri: string, name: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the active diagnostic settings list for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(resourceUri: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the active diagnostic settings list for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {DiagnosticSettingsResourceCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {DiagnosticSettingsResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsResourceCollection} for + * more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(resourceUri: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(resourceUri: string, callback: ServiceCallback): void; + list(resourceUri: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * DiagnosticSettingsCategoryOperations + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface DiagnosticSettingsCategoryOperations { + + + /** + * Gets the diagnostic settings category for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceUri: string, name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the diagnostic settings category for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {string} name The name of the diagnostic setting. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {DiagnosticSettingsCategoryResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {DiagnosticSettingsCategoryResource} [result] - The deserialized result object if an error did not occur. + * See {@link DiagnosticSettingsCategoryResource} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceUri: string, name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceUri: string, name: string, callback: ServiceCallback): void; + get(resourceUri: string, name: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the diagnostic settings categories for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(resourceUri: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the diagnostic settings categories for the specified resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {DiagnosticSettingsCategoryResourceCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {DiagnosticSettingsCategoryResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link + * DiagnosticSettingsCategoryResourceCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(resourceUri: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(resourceUri: string, callback: ServiceCallback): void; + list(resourceUri: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ActionGroups + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface ActionGroups { + + + /** + * Create a new action group or update an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} actionGroup The action group to create or use for the + * update. + * + * @param {string} actionGroup.groupShortName The short name of the action + * group. This will be used in SMS messages. + * + * @param {boolean} actionGroup.enabled Indicates whether this action group is + * enabled. If an action group is not enabled, then none of its receivers will + * receive communications. + * + * @param {array} [actionGroup.emailReceivers] The list of email receivers that + * are part of this action group. + * + * @param {array} [actionGroup.smsReceivers] The list of SMS receivers that are + * part of this action group. + * + * @param {array} [actionGroup.webhookReceivers] The list of webhook receivers + * that are part of this action group. + * + * @param {array} [actionGroup.itsmReceivers] The list of ITSM receivers that + * are part of this action group. + * + * @param {array} [actionGroup.azureAppPushReceivers] The list of AzureAppPush + * receivers that are part of this action group. + * + * @param {array} [actionGroup.automationRunbookReceivers] The list of + * AutomationRunbook receivers that are part of this action group. + * + * @param {string} actionGroup.location Resource location + * + * @param {object} [actionGroup.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, actionGroupName: string, actionGroup: models.ActionGroupResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create a new action group or update an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} actionGroup The action group to create or use for the + * update. + * + * @param {string} actionGroup.groupShortName The short name of the action + * group. This will be used in SMS messages. + * + * @param {boolean} actionGroup.enabled Indicates whether this action group is + * enabled. If an action group is not enabled, then none of its receivers will + * receive communications. + * + * @param {array} [actionGroup.emailReceivers] The list of email receivers that + * are part of this action group. + * + * @param {array} [actionGroup.smsReceivers] The list of SMS receivers that are + * part of this action group. + * + * @param {array} [actionGroup.webhookReceivers] The list of webhook receivers + * that are part of this action group. + * + * @param {array} [actionGroup.itsmReceivers] The list of ITSM receivers that + * are part of this action group. + * + * @param {array} [actionGroup.azureAppPushReceivers] The list of AzureAppPush + * receivers that are part of this action group. + * + * @param {array} [actionGroup.automationRunbookReceivers] The list of + * AutomationRunbook receivers that are part of this action group. + * + * @param {string} actionGroup.location Resource location + * + * @param {object} [actionGroup.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ActionGroupResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ActionGroupResource} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, actionGroupName: string, actionGroup: models.ActionGroupResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, actionGroupName: string, actionGroup: models.ActionGroupResource, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, actionGroupName: string, actionGroup: models.ActionGroupResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get an action group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, actionGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get an action group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ActionGroupResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ActionGroupResource} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, actionGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, actionGroupName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, actionGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete an action group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, actionGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete an action group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, actionGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, actionGroupName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, actionGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates an existing action group's tags. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} actionGroupPatch Parameters supplied to the operation. + * + * @param {object} [actionGroupPatch.tags] Resource tags + * + * @param {boolean} [actionGroupPatch.enabled] Indicates whether this action + * group is enabled. If an action group is not enabled, then none of its + * actions will be activated. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, actionGroupName: string, actionGroupPatch: models.ActionGroupPatchBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates an existing action group's tags. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {object} actionGroupPatch Parameters supplied to the operation. + * + * @param {object} [actionGroupPatch.tags] Resource tags + * + * @param {boolean} [actionGroupPatch.enabled] Indicates whether this action + * group is enabled. If an action group is not enabled, then none of its + * actions will be activated. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ActionGroupResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ActionGroupResource} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, actionGroupName: string, actionGroupPatch: models.ActionGroupPatchBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, actionGroupName: string, actionGroupPatch: models.ActionGroupPatchBody, callback: ServiceCallback): void; + update(resourceGroupName: string, actionGroupName: string, actionGroupPatch: models.ActionGroupPatchBody, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get a list of all action groups in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listBySubscriptionIdWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get a list of all action groups in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ActionGroupList} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ActionGroupList} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupList} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscriptionId(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listBySubscriptionId(callback: ServiceCallback): void; + listBySubscriptionId(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get a list of all action groups in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get a list of all action groups in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ActionGroupList} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ActionGroupList} [result] - The deserialized result object if an error did not occur. + * See {@link ActionGroupList} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Enable a receiver in an action group. This changes the receiver's status + * from Disabled to Enabled. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {string} receiverName The name of the receiver to resubscribe. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + enableReceiverWithHttpOperationResponse(resourceGroupName: string, actionGroupName: string, receiverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Enable a receiver in an action group. This changes the receiver's status + * from Disabled to Enabled. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} actionGroupName The name of the action group. + * + * @param {string} receiverName The name of the receiver to resubscribe. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + enableReceiver(resourceGroupName: string, actionGroupName: string, receiverName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + enableReceiver(resourceGroupName: string, actionGroupName: string, receiverName: string, callback: ServiceCallback): void; + enableReceiver(resourceGroupName: string, actionGroupName: string, receiverName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ActivityLogAlerts + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface ActivityLogAlerts { + + + /** + * Create a new activity log alert or update an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} activityLogAlert The activity log alert to create or use for + * the update. + * + * @param {array} activityLogAlert.scopes A list of resourceIds that will be + * used as prefixes. The alert will only apply to activityLogs with resourceIds + * that fall under one of these prefixes. This list must include at least one + * item. + * + * @param {boolean} [activityLogAlert.enabled] Indicates whether this activity + * log alert is enabled. If an activity log alert is not enabled, then none of + * its actions will be activated. + * + * @param {object} activityLogAlert.condition The condition that will cause + * this alert to activate. + * + * @param {array} activityLogAlert.condition.allOf The list of activity log + * alert conditions. + * + * @param {object} activityLogAlert.actions The actions that will activate when + * the condition is met. + * + * @param {array} [activityLogAlert.actions.actionGroups] The list of activity + * log alerts. + * + * @param {string} [activityLogAlert.description] A description of this + * activity log alert. + * + * @param {string} activityLogAlert.location Resource location + * + * @param {object} [activityLogAlert.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, activityLogAlertName: string, activityLogAlert: models.ActivityLogAlertResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create a new activity log alert or update an existing one. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} activityLogAlert The activity log alert to create or use for + * the update. + * + * @param {array} activityLogAlert.scopes A list of resourceIds that will be + * used as prefixes. The alert will only apply to activityLogs with resourceIds + * that fall under one of these prefixes. This list must include at least one + * item. + * + * @param {boolean} [activityLogAlert.enabled] Indicates whether this activity + * log alert is enabled. If an activity log alert is not enabled, then none of + * its actions will be activated. + * + * @param {object} activityLogAlert.condition The condition that will cause + * this alert to activate. + * + * @param {array} activityLogAlert.condition.allOf The list of activity log + * alert conditions. + * + * @param {object} activityLogAlert.actions The actions that will activate when + * the condition is met. + * + * @param {array} [activityLogAlert.actions.actionGroups] The list of activity + * log alerts. + * + * @param {string} [activityLogAlert.description] A description of this + * activity log alert. + * + * @param {string} activityLogAlert.location Resource location + * + * @param {object} [activityLogAlert.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ActivityLogAlertResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ActivityLogAlertResource} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertResource} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, activityLogAlertName: string, activityLogAlert: models.ActivityLogAlertResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, activityLogAlertName: string, activityLogAlert: models.ActivityLogAlertResource, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, activityLogAlertName: string, activityLogAlert: models.ActivityLogAlertResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get an activity log alert. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, activityLogAlertName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get an activity log alert. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ActivityLogAlertResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ActivityLogAlertResource} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertResource} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, activityLogAlertName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, activityLogAlertName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, activityLogAlertName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete an activity log alert. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, activityLogAlertName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete an activity log alert. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, activityLogAlertName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, activityLogAlertName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, activityLogAlertName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates an existing ActivityLogAlertResource's tags. To update other fields + * use the CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} activityLogAlertPatch Parameters supplied to the operation. + * + * @param {object} [activityLogAlertPatch.tags] Resource tags + * + * @param {boolean} [activityLogAlertPatch.enabled] Indicates whether this + * activity log alert is enabled. If an activity log alert is not enabled, then + * none of its actions will be activated. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, activityLogAlertName: string, activityLogAlertPatch: models.ActivityLogAlertPatchBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates an existing ActivityLogAlertResource's tags. To update other fields + * use the CreateOrUpdate method. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} activityLogAlertName The name of the activity log alert. + * + * @param {object} activityLogAlertPatch Parameters supplied to the operation. + * + * @param {object} [activityLogAlertPatch.tags] Resource tags + * + * @param {boolean} [activityLogAlertPatch.enabled] Indicates whether this + * activity log alert is enabled. If an activity log alert is not enabled, then + * none of its actions will be activated. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ActivityLogAlertResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ActivityLogAlertResource} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertResource} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, activityLogAlertName: string, activityLogAlertPatch: models.ActivityLogAlertPatchBody, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, activityLogAlertName: string, activityLogAlertPatch: models.ActivityLogAlertPatchBody, callback: ServiceCallback): void; + update(resourceGroupName: string, activityLogAlertName: string, activityLogAlertPatch: models.ActivityLogAlertPatchBody, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get a list of all activity log alerts in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listBySubscriptionIdWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get a list of all activity log alerts in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ActivityLogAlertList} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ActivityLogAlertList} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertList} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscriptionId(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listBySubscriptionId(callback: ServiceCallback): void; + listBySubscriptionId(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get a list of all activity log alerts in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get a list of all activity log alerts in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {ActivityLogAlertList} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {ActivityLogAlertList} [result] - The deserialized result object if an error did not occur. + * See {@link ActivityLogAlertList} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * ActivityLogs + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface ActivityLogs { + + + /** + * Provides the list of records from the activity logs. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Reduces the set of data collected.
The + * **$filter** argument is very restricted and allows only the following + * patterns.
- *List events for a resource group*: $filter=eventTimestamp ge + * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + * '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq + * 'resourceGroupName'.
- *List events for resource*: $filter=eventTimestamp + * ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + * '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.
- *List + * events for a subscription in a time range*: $filter=eventTimestamp ge + * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + * '2014-07-20T04:36:37.6407898Z'.
- *List events for a resource provider*: + * $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp + * le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq + * 'resourceProviderName'.
- *List events for a correlation Id*: + * $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp + * le '2014-07-20T04:36:37.6407898Z' and correlationId eq + * 'correlationID'.

**NOTE**: No other syntax is allowed. + * + * @param {string} [options.select] Used to fetch events with only the given + * properties.
The **$select** argument is a comma separated list of + * property names to be returned. Possible values are: *authorization*, + * *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, + * *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, + * *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, + * *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Provides the list of records from the activity logs. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Reduces the set of data collected.
The + * **$filter** argument is very restricted and allows only the following + * patterns.
- *List events for a resource group*: $filter=eventTimestamp ge + * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + * '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq + * 'resourceGroupName'.
- *List events for resource*: $filter=eventTimestamp + * ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + * '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'.
- *List + * events for a subscription in a time range*: $filter=eventTimestamp ge + * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + * '2014-07-20T04:36:37.6407898Z'.
- *List events for a resource provider*: + * $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp + * le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq + * 'resourceProviderName'.
- *List events for a correlation Id*: + * $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp + * le '2014-07-20T04:36:37.6407898Z' and correlationId eq + * 'correlationID'.

**NOTE**: No other syntax is allowed. + * + * @param {string} [options.select] Used to fetch events with only the given + * properties.
The **$select** argument is a comma separated list of + * property names to be returned. Possible values are: *authorization*, + * *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, + * *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, + * *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, + * *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {EventDataCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {EventDataCollection} [result] - The deserialized result object if an error did not occur. + * See {@link EventDataCollection} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Provides the list of records from the activity logs. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Provides the list of records from the activity logs. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {EventDataCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {EventDataCollection} [result] - The deserialized result object if an error did not occur. + * See {@link EventDataCollection} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * EventCategories + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface EventCategories { + + + /** + * Get the list of available event categories supported in the Activity Logs + * Service.
The current list includes the following: Administrative, + * Security, ServiceHealth, Alert, Recommendation, Policy. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get the list of available event categories supported in the Activity Logs + * Service.
The current list includes the following: Administrative, + * Security, ServiceHealth, Alert, Recommendation, Policy. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {EventCategoryCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {EventCategoryCollection} [result] - The deserialized result object if an error did not occur. + * See {@link EventCategoryCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * TenantActivityLogs + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface TenantActivityLogs { + + + /** + * Gets the Activity Logs for the Tenant.
Everything that is applicable to + * the API to get the Activity Logs for the subscription is applicable to this + * API (the parameters, $filter, etc.).
One thing to point out here is that + * this API does *not* retrieve the logs at the individual subscription of the + * tenant but only surfaces the logs that were generated at the tenant level. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Reduces the set of data collected.
The + * **$filter** is very restricted and allows only the following patterns.
- + * List events for a resource group: $filter=eventTimestamp ge '' + * and eventTimestamp le '' and eventChannels eq 'Admin, Operation' + * and resourceGroupName eq ''.
- List events for + * resource: $filter=eventTimestamp ge '' and eventTimestamp le + * '' and eventChannels eq 'Admin, Operation' and resourceUri eq + * ''.
- List events for a subscription: $filter=eventTimestamp + * ge '' and eventTimestamp le '' and eventChannels eq + * 'Admin, Operation'.
- List events for a resource provider: + * $filter=eventTimestamp ge '' and eventTimestamp le '' + * and eventChannels eq 'Admin, Operation' and resourceProvider eq + * ''.
- List events for a correlation Id: + * api-version=2014-04-01&$filter=eventTimestamp ge + * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + * '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and + * correlationId eq ''.
**NOTE**: No other syntax is allowed. + * + * @param {string} [options.select] Used to fetch events with only the given + * properties.
The **$select** argument is a comma separated list of + * property names to be returned. Possible values are: *authorization*, + * *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, + * *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, + * *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, + * *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(options?: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the Activity Logs for the Tenant.
Everything that is applicable to + * the API to get the Activity Logs for the subscription is applicable to this + * API (the parameters, $filter, etc.).
One thing to point out here is that + * this API does *not* retrieve the logs at the individual subscription of the + * tenant but only surfaces the logs that were generated at the tenant level. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] Reduces the set of data collected.
The + * **$filter** is very restricted and allows only the following patterns.
- + * List events for a resource group: $filter=eventTimestamp ge '' + * and eventTimestamp le '' and eventChannels eq 'Admin, Operation' + * and resourceGroupName eq ''.
- List events for + * resource: $filter=eventTimestamp ge '' and eventTimestamp le + * '' and eventChannels eq 'Admin, Operation' and resourceUri eq + * ''.
- List events for a subscription: $filter=eventTimestamp + * ge '' and eventTimestamp le '' and eventChannels eq + * 'Admin, Operation'.
- List events for a resource provider: + * $filter=eventTimestamp ge '' and eventTimestamp le '' + * and eventChannels eq 'Admin, Operation' and resourceProvider eq + * ''.
- List events for a correlation Id: + * api-version=2014-04-01&$filter=eventTimestamp ge + * '2014-07-16T04:36:37.6407898Z' and eventTimestamp le + * '2014-07-20T04:36:37.6407898Z' and eventChannels eq 'Admin, Operation' and + * correlationId eq ''.
**NOTE**: No other syntax is allowed. + * + * @param {string} [options.select] Used to fetch events with only the given + * properties.
The **$select** argument is a comma separated list of + * property names to be returned. Possible values are: *authorization*, + * *claims*, *correlationId*, *description*, *eventDataId*, *eventName*, + * *eventTimestamp*, *httpRequest*, *level*, *operationId*, *operationName*, + * *properties*, *resourceGroupName*, *resourceProviderName*, *resourceId*, + * *status*, *submissionTimestamp*, *subStatus*, *subscriptionId* + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {EventDataCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {EventDataCollection} [result] - The deserialized result object if an error did not occur. + * See {@link EventDataCollection} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(options?: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { filter? : string, select? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Gets the Activity Logs for the Tenant.
Everything that is applicable to + * the API to get the Activity Logs for the subscription is applicable to this + * API (the parameters, $filter, etc.).
One thing to point out here is that + * this API does *not* retrieve the logs at the individual subscription of the + * tenant but only surfaces the logs that were generated at the tenant level. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Gets the Activity Logs for the Tenant.
Everything that is applicable to + * the API to get the Activity Logs for the subscription is applicable to this + * API (the parameters, $filter, etc.).
One thing to point out here is that + * this API does *not* retrieve the logs at the individual subscription of the + * tenant but only surfaces the logs that were generated at the tenant level. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {EventDataCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {EventDataCollection} [result] - The deserialized result object if an error did not occur. + * See {@link EventDataCollection} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * MetricDefinitions + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface MetricDefinitions { + + + /** + * Lists the metric definitions for the resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.metricnamespace] Metric namespace to query metric + * definitions for. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(resourceUri: string, options?: { metricnamespace? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the metric definitions for the resource. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.metricnamespace] Metric namespace to query metric + * definitions for. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MetricDefinitionCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MetricDefinitionCollection} [result] - The deserialized result object if an error did not occur. + * See {@link MetricDefinitionCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(resourceUri: string, options?: { metricnamespace? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(resourceUri: string, callback: ServiceCallback): void; + list(resourceUri: string, options: { metricnamespace? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Metrics + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface Metrics { + + + /** + * **Lists the metric values for a resource**. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.timespan] The timespan of the query. It is a string + * with the following format 'startDateTime_ISO/endDateTime_ISO'. + * + * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of + * the query. + * + * @param {string} [options.metricnames] The names of the metrics (comma + * separated) to retrieve. + * + * @param {string} [options.aggregation] The list of aggregation types (comma + * separated) to retrieve. + * + * @param {number} [options.top] The maximum number of records to retrieve. + * Valid only if $filter is specified. + * Defaults to 10. + * + * @param {string} [options.orderby] The aggregation to use for sorting results + * and the direction of the sort. + * Only one order can be specified. + * Examples: sum asc. + * + * @param {string} [options.filter] The **$filter** is used to reduce the set + * of metric data returned.
Example:
Metric contains metadata A, B and + * C.
- Return all time series of C where A = a1 and B = b1 or + * b2
**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- + * Invalid variant:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = + * ‘b2’**
This is invalid because the logical or operator cannot separate + * two different metadata names.
- Return all time series where A = a1, B = + * b1 and C = c1:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- + * Return all time series where A = a1
**$filter=A eq ‘a1’ and B eq ‘*’ and + * C eq ‘*’**. + * + * @param {string} [options.resultType] Reduces the set of data collected. The + * syntax allowed depends on the operation. See the operation's description for + * details. Possible values include: 'Data', 'Metadata' + * + * @param {string} [options.metricnamespace] Metric namespace to query metric + * definitions for. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(resourceUri: string, options?: { timespan? : string, interval? : moment.Duration, metricnames? : string, aggregation? : string, top? : number, orderby? : string, filter? : string, resultType? : string, metricnamespace? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * **Lists the metric values for a resource**. + * + * @param {string} resourceUri The identifier of the resource. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.timespan] The timespan of the query. It is a string + * with the following format 'startDateTime_ISO/endDateTime_ISO'. + * + * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of + * the query. + * + * @param {string} [options.metricnames] The names of the metrics (comma + * separated) to retrieve. + * + * @param {string} [options.aggregation] The list of aggregation types (comma + * separated) to retrieve. + * + * @param {number} [options.top] The maximum number of records to retrieve. + * Valid only if $filter is specified. + * Defaults to 10. + * + * @param {string} [options.orderby] The aggregation to use for sorting results + * and the direction of the sort. + * Only one order can be specified. + * Examples: sum asc. + * + * @param {string} [options.filter] The **$filter** is used to reduce the set + * of metric data returned.
Example:
Metric contains metadata A, B and + * C.
- Return all time series of C where A = a1 and B = b1 or + * b2
**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- + * Invalid variant:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = + * ‘b2’**
This is invalid because the logical or operator cannot separate + * two different metadata names.
- Return all time series where A = a1, B = + * b1 and C = c1:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- + * Return all time series where A = a1
**$filter=A eq ‘a1’ and B eq ‘*’ and + * C eq ‘*’**. + * + * @param {string} [options.resultType] Reduces the set of data collected. The + * syntax allowed depends on the operation. See the operation's description for + * details. Possible values include: 'Data', 'Metadata' + * + * @param {string} [options.metricnamespace] Metric namespace to query metric + * definitions for. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Response} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Response} [result] - The deserialized result object if an error did not occur. + * See {@link Response} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(resourceUri: string, options?: { timespan? : string, interval? : moment.Duration, metricnames? : string, aggregation? : string, top? : number, orderby? : string, filter? : string, resultType? : string, metricnamespace? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + list(resourceUri: string, callback: ServiceCallback): void; + list(resourceUri: string, options: { timespan? : string, interval? : moment.Duration, metricnames? : string, aggregation? : string, top? : number, orderby? : string, filter? : string, resultType? : string, metricnamespace? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * MetricBaseline + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface MetricBaseline { + + + /** + * **Gets the baseline values for a specific metric**. + * + * @param {string} resourceUri The identifier of the resource. It has the + * following structure: + * subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. + * For example: + * subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 + * + * @param {string} metricName The name of the metric to retrieve the baseline + * for. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.timespan] The timespan of the query. It is a string + * with the following format 'startDateTime_ISO/endDateTime_ISO'. + * + * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of + * the query. + * + * @param {string} [options.aggregation] The aggregation type of the metric to + * retrieve the baseline for. + * + * @param {string} [options.sensitivities] The list of sensitivities (comma + * separated) to retrieve. + * + * @param {string} [options.resultType] Allows retrieving only metadata of the + * baseline. On data request all information is retrieved. Possible values + * include: 'Data', 'Metadata' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceUri: string, metricName: string, options?: { timespan? : string, interval? : moment.Duration, aggregation? : string, sensitivities? : string, resultType? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * **Gets the baseline values for a specific metric**. + * + * @param {string} resourceUri The identifier of the resource. It has the + * following structure: + * subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. + * For example: + * subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 + * + * @param {string} metricName The name of the metric to retrieve the baseline + * for. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.timespan] The timespan of the query. It is a string + * with the following format 'startDateTime_ISO/endDateTime_ISO'. + * + * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of + * the query. + * + * @param {string} [options.aggregation] The aggregation type of the metric to + * retrieve the baseline for. + * + * @param {string} [options.sensitivities] The list of sensitivities (comma + * separated) to retrieve. + * + * @param {string} [options.resultType] Allows retrieving only metadata of the + * baseline. On data request all information is retrieved. Possible values + * include: 'Data', 'Metadata' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {BaselineResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {BaselineResponse} [result] - The deserialized result object if an error did not occur. + * See {@link BaselineResponse} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceUri: string, metricName: string, options?: { timespan? : string, interval? : moment.Duration, aggregation? : string, sensitivities? : string, resultType? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceUri: string, metricName: string, callback: ServiceCallback): void; + get(resourceUri: string, metricName: string, options: { timespan? : string, interval? : moment.Duration, aggregation? : string, sensitivities? : string, resultType? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * **Lists the baseline values for a resource**. + * + * @param {string} resourceUri The identifier of the resource. It has the + * following structure: + * subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. + * For example: + * subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 + * + * @param {object} timeSeriesInformation Information that need to be specified + * to calculate a baseline on a time series. + * + * @param {array} timeSeriesInformation.sensitivities the list of sensitivities + * for calculating the baseline. + * + * @param {array} timeSeriesInformation.values The metric values to calculate + * the baseline. + * + * @param {array} [timeSeriesInformation.timestamps] the array of timestamps of + * the baselines. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + calculateBaselineWithHttpOperationResponse(resourceUri: string, timeSeriesInformation: models.TimeSeriesInformation, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * **Lists the baseline values for a resource**. + * + * @param {string} resourceUri The identifier of the resource. It has the + * following structure: + * subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. + * For example: + * subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 + * + * @param {object} timeSeriesInformation Information that need to be specified + * to calculate a baseline on a time series. + * + * @param {array} timeSeriesInformation.sensitivities the list of sensitivities + * for calculating the baseline. + * + * @param {array} timeSeriesInformation.values The metric values to calculate + * the baseline. + * + * @param {array} [timeSeriesInformation.timestamps] the array of timestamps of + * the baselines. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {CalculateBaselineResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {CalculateBaselineResponse} [result] - The deserialized result object if an error did not occur. + * See {@link CalculateBaselineResponse} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + calculateBaseline(resourceUri: string, timeSeriesInformation: models.TimeSeriesInformation, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + calculateBaseline(resourceUri: string, timeSeriesInformation: models.TimeSeriesInformation, callback: ServiceCallback): void; + calculateBaseline(resourceUri: string, timeSeriesInformation: models.TimeSeriesInformation, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * MetricAlerts + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface MetricAlerts { + + + /** + * Retrieve alert rule definitions in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listBySubscriptionWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve alert rule definitions in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MetricAlertResourceCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MetricAlertResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResourceCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscription(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listBySubscription(callback: ServiceCallback): void; + listBySubscription(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve alert rule defintions in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve alert rule defintions in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MetricAlertResourceCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MetricAlertResourceCollection} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResourceCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve an alert rule definiton. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve an alert rule definiton. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MetricAlertResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MetricAlertResource} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + get(resourceGroupName: string, ruleName: string, callback: ServiceCallback): void; + get(resourceGroupName: string, ruleName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Create or update an metric alert definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} parameters.description the description of the metric alert + * that will be included in the alert email. + * + * @param {number} parameters.severity Alert severity {0, 1, 2, 3, 4} + * + * @param {boolean} parameters.enabled the flag that indicates whether the + * metric alert is enabled. + * + * @param {array} [parameters.scopes] the list of resource id's that this + * metric alert is scoped to. + * + * @param {moment.duration} parameters.evaluationFrequency how often the metric + * alert is evaluated represented in ISO 8601 duration format. + * + * @param {moment.duration} parameters.windowSize the period of time (in ISO + * 8601 duration format) that is used to monitor alert activity based on the + * threshold. + * + * @param {object} parameters.criteria defines the specific alert criteria + * information. + * + * @param {string} parameters.criteria.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName: string, ruleName: string, parameters: models.MetricAlertResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create or update an metric alert definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} parameters.description the description of the metric alert + * that will be included in the alert email. + * + * @param {number} parameters.severity Alert severity {0, 1, 2, 3, 4} + * + * @param {boolean} parameters.enabled the flag that indicates whether the + * metric alert is enabled. + * + * @param {array} [parameters.scopes] the list of resource id's that this + * metric alert is scoped to. + * + * @param {moment.duration} parameters.evaluationFrequency how often the metric + * alert is evaluated represented in ISO 8601 duration format. + * + * @param {moment.duration} parameters.windowSize the period of time (in ISO + * 8601 duration format) that is used to monitor alert activity based on the + * threshold. + * + * @param {object} parameters.criteria defines the specific alert criteria + * information. + * + * @param {string} parameters.criteria.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MetricAlertResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MetricAlertResource} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName: string, ruleName: string, parameters: models.MetricAlertResource, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + createOrUpdate(resourceGroupName: string, ruleName: string, parameters: models.MetricAlertResource, callback: ServiceCallback): void; + createOrUpdate(resourceGroupName: string, ruleName: string, parameters: models.MetricAlertResource, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Update an metric alert definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to update. + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} parameters.description the description of the metric alert + * that will be included in the alert email. + * + * @param {number} parameters.severity Alert severity {0, 1, 2, 3, 4} + * + * @param {boolean} parameters.enabled the flag that indicates whether the + * metric alert is enabled. + * + * @param {array} [parameters.scopes] the list of resource id's that this + * metric alert is scoped to. + * + * @param {moment.duration} parameters.evaluationFrequency how often the metric + * alert is evaluated represented in ISO 8601 duration format. + * + * @param {moment.duration} parameters.windowSize the period of time (in ISO + * 8601 duration format) that is used to monitor alert activity based on the + * threshold. + * + * @param {object} parameters.criteria defines the specific alert criteria + * information. + * + * @param {string} parameters.criteria.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName: string, ruleName: string, parameters: models.MetricAlertResourcePatch, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Update an metric alert definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to update. + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} parameters.description the description of the metric alert + * that will be included in the alert email. + * + * @param {number} parameters.severity Alert severity {0, 1, 2, 3, 4} + * + * @param {boolean} parameters.enabled the flag that indicates whether the + * metric alert is enabled. + * + * @param {array} [parameters.scopes] the list of resource id's that this + * metric alert is scoped to. + * + * @param {moment.duration} parameters.evaluationFrequency how often the metric + * alert is evaluated represented in ISO 8601 duration format. + * + * @param {moment.duration} parameters.windowSize the period of time (in ISO + * 8601 duration format) that is used to monitor alert activity based on the + * threshold. + * + * @param {object} parameters.criteria defines the specific alert criteria + * information. + * + * @param {string} parameters.criteria.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MetricAlertResource} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MetricAlertResource} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResource} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName: string, ruleName: string, parameters: models.MetricAlertResourcePatch, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, ruleName: string, parameters: models.MetricAlertResourcePatch, callback: ServiceCallback): void; + update(resourceGroupName: string, ruleName: string, parameters: models.MetricAlertResourcePatch, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Delete an alert rule defitiniton. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Delete an alert rule defitiniton. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, ruleName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, ruleName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * MetricAlertsStatus + * __NOTE__: An instance of this class is automatically created for an + * instance of the MonitorManagementClient. + */ +export interface MetricAlertsStatus { + + + /** + * Retrieve an alert rule status. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listWithHttpOperationResponse(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve an alert rule status. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MetricAlertStatusCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MetricAlertStatusCollection} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertStatusCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + list(resourceGroupName: string, ruleName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(resourceGroupName: string, ruleName: string, callback: ServiceCallback): void; + list(resourceGroupName: string, ruleName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Retrieve an alert rule status. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {string} statusName The name of the status. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + listByNameWithHttpOperationResponse(resourceGroupName: string, ruleName: string, statusName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Retrieve an alert rule status. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {string} statusName The name of the status. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {MetricAlertStatusCollection} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {MetricAlertStatusCollection} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertStatusCollection} for more + * information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + listByName(resourceGroupName: string, ruleName: string, statusName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByName(resourceGroupName: string, ruleName: string, statusName: string, callback: ServiceCallback): void; + listByName(resourceGroupName: string, ruleName: string, statusName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } diff --git a/lib/services/monitor/lib/operations/index.js b/lib/services/monitor/lib/operations/index.js index ae8f0ebb29..56d8f5aa1b 100644 --- a/lib/services/monitor/lib/operations/index.js +++ b/lib/services/monitor/lib/operations/index.js @@ -14,9 +14,20 @@ 'use strict'; -exports.UsageMetrics = require('./usageMetrics'); +exports.AutoscaleSettings = require('./autoscaleSettings'); +exports.Operations = require('./operations'); +exports.AlertRuleIncidents = require('./alertRuleIncidents'); +exports.AlertRules = require('./alertRules'); +exports.LogProfiles = require('./logProfiles'); +exports.DiagnosticSettingsOperations = require('./diagnosticSettingsOperations'); +exports.DiagnosticSettingsCategoryOperations = require('./diagnosticSettingsCategoryOperations'); +exports.ActionGroups = require('./actionGroups'); +exports.ActivityLogAlerts = require('./activityLogAlerts'); exports.ActivityLogs = require('./activityLogs'); exports.EventCategories = require('./eventCategories'); exports.TenantActivityLogs = require('./tenantActivityLogs'); exports.MetricDefinitions = require('./metricDefinitions'); exports.Metrics = require('./metrics'); +exports.MetricBaseline = require('./metricBaseline'); +exports.MetricAlerts = require('./metricAlerts'); +exports.MetricAlertsStatus = require('./metricAlertsStatus'); diff --git a/lib/services/monitor/lib/operations/logProfiles.js b/lib/services/monitor/lib/operations/logProfiles.js new file mode 100644 index 0000000000..8c61a074e5 --- /dev/null +++ b/lib/services/monitor/lib/operations/logProfiles.js @@ -0,0 +1,1319 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Deletes the log profile. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(logProfileName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (logProfileName === null || logProfileName === undefined || typeof logProfileName.valueOf() !== 'string') { + throw new Error('logProfileName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}'; + requestUrl = requestUrl.replace('{logProfileName}', encodeURIComponent(logProfileName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Gets the log profile. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(logProfileName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (logProfileName === null || logProfileName === undefined || typeof logProfileName.valueOf() !== 'string') { + throw new Error('logProfileName cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}'; + requestUrl = requestUrl.replace('{logProfileName}', encodeURIComponent(logProfileName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['LogProfileResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Create or update a log profile in Azure Monitoring REST API. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {string} [parameters.storageAccountId] the resource id of the storage + * account to which you would like to send the Activity Log. + * + * @param {string} [parameters.serviceBusRuleId] The service bus rule ID of the + * service bus namespace in which you would like to have Event Hubs created for + * streaming the Activity Log. The rule ID is of the format: '{service bus + * resource ID}/authorizationrules/{key name}'. + * + * @param {array} parameters.locations List of regions for which Activity Log + * events should be stored or streamed. It is a comma separated list of valid + * ARM locations including the 'global' location. + * + * @param {array} parameters.categories the categories of the logs. These + * categories are created as is convenient to the user. Some values are: + * 'Write', 'Delete', and/or 'Action.' + * + * @param {object} parameters.retentionPolicy the retention policy for the + * events in the log. + * + * @param {boolean} parameters.retentionPolicy.enabled a value indicating + * whether the retention policy is enabled. + * + * @param {number} parameters.retentionPolicy.days the number of days for the + * retention in days. A value of 0 will retain the events indefinitely. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(logProfileName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (logProfileName === null || logProfileName === undefined || typeof logProfileName.valueOf() !== 'string') { + throw new Error('logProfileName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}'; + requestUrl = requestUrl.replace('{logProfileName}', encodeURIComponent(logProfileName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['LogProfileResource']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['LogProfileResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Updates an existing LogProfilesResource. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} logProfilesResource Parameters supplied to the operation. + * + * @param {object} [logProfilesResource.tags] Resource tags + * + * @param {string} [logProfilesResource.storageAccountId] the resource id of + * the storage account to which you would like to send the Activity Log. + * + * @param {string} [logProfilesResource.serviceBusRuleId] The service bus rule + * ID of the service bus namespace in which you would like to have Event Hubs + * created for streaming the Activity Log. The rule ID is of the format: + * '{service bus resource ID}/authorizationrules/{key name}'. + * + * @param {array} logProfilesResource.locations List of regions for which + * Activity Log events should be stored or streamed. It is a comma separated + * list of valid ARM locations including the 'global' location. + * + * @param {array} logProfilesResource.categories the categories of the logs. + * These categories are created as is convenient to the user. Some values are: + * 'Write', 'Delete', and/or 'Action.' + * + * @param {object} logProfilesResource.retentionPolicy the retention policy for + * the events in the log. + * + * @param {boolean} logProfilesResource.retentionPolicy.enabled a value + * indicating whether the retention policy is enabled. + * + * @param {number} logProfilesResource.retentionPolicy.days the number of days + * for the retention in days. A value of 0 will retain the events indefinitely. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(logProfileName, logProfilesResource, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (logProfileName === null || logProfileName === undefined || typeof logProfileName.valueOf() !== 'string') { + throw new Error('logProfileName cannot be null or undefined and it must be of type string.'); + } + if (logProfilesResource === null || logProfilesResource === undefined) { + throw new Error('logProfilesResource cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles/{logProfileName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{logProfileName}', encodeURIComponent(logProfileName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (logProfilesResource !== null && logProfilesResource !== undefined) { + let requestModelMapper = new client.models['LogProfileResourcePatch']().mapper(); + requestModel = client.serialize(requestModelMapper, logProfilesResource, 'logProfilesResource'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(logProfilesResource, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['LogProfileResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * List the log profiles. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileCollection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2016-03-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/microsoft.insights/logprofiles'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['LogProfileCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a LogProfiles. */ +class LogProfiles { + /** + * Create a LogProfiles. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._deleteMethod = _deleteMethod; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._update = _update; + this._list = _list; + } + + /** + * Deletes the log profile. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(logProfileName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(logProfileName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes the log profile. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(logProfileName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(logProfileName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(logProfileName, options, optionalCallback); + } + } + + /** + * Gets the log profile. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(logProfileName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(logProfileName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Gets the log profile. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {LogProfileResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(logProfileName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(logProfileName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(logProfileName, options, optionalCallback); + } + } + + /** + * Create or update a log profile in Azure Monitoring REST API. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {string} [parameters.storageAccountId] the resource id of the storage + * account to which you would like to send the Activity Log. + * + * @param {string} [parameters.serviceBusRuleId] The service bus rule ID of the + * service bus namespace in which you would like to have Event Hubs created for + * streaming the Activity Log. The rule ID is of the format: '{service bus + * resource ID}/authorizationrules/{key name}'. + * + * @param {array} parameters.locations List of regions for which Activity Log + * events should be stored or streamed. It is a comma separated list of valid + * ARM locations including the 'global' location. + * + * @param {array} parameters.categories the categories of the logs. These + * categories are created as is convenient to the user. Some values are: + * 'Write', 'Delete', and/or 'Action.' + * + * @param {object} parameters.retentionPolicy the retention policy for the + * events in the log. + * + * @param {boolean} parameters.retentionPolicy.enabled a value indicating + * whether the retention policy is enabled. + * + * @param {number} parameters.retentionPolicy.days the number of days for the + * retention in days. A value of 0 will retain the events indefinitely. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(logProfileName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(logProfileName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create or update a log profile in Azure Monitoring REST API. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} parameters Parameters supplied to the operation. + * + * @param {string} [parameters.storageAccountId] the resource id of the storage + * account to which you would like to send the Activity Log. + * + * @param {string} [parameters.serviceBusRuleId] The service bus rule ID of the + * service bus namespace in which you would like to have Event Hubs created for + * streaming the Activity Log. The rule ID is of the format: '{service bus + * resource ID}/authorizationrules/{key name}'. + * + * @param {array} parameters.locations List of regions for which Activity Log + * events should be stored or streamed. It is a comma separated list of valid + * ARM locations including the 'global' location. + * + * @param {array} parameters.categories the categories of the logs. These + * categories are created as is convenient to the user. Some values are: + * 'Write', 'Delete', and/or 'Action.' + * + * @param {object} parameters.retentionPolicy the retention policy for the + * events in the log. + * + * @param {boolean} parameters.retentionPolicy.enabled a value indicating + * whether the retention policy is enabled. + * + * @param {number} parameters.retentionPolicy.days the number of days for the + * retention in days. A value of 0 will retain the events indefinitely. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {LogProfileResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(logProfileName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(logProfileName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(logProfileName, parameters, options, optionalCallback); + } + } + + /** + * Updates an existing LogProfilesResource. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} logProfilesResource Parameters supplied to the operation. + * + * @param {object} [logProfilesResource.tags] Resource tags + * + * @param {string} [logProfilesResource.storageAccountId] the resource id of + * the storage account to which you would like to send the Activity Log. + * + * @param {string} [logProfilesResource.serviceBusRuleId] The service bus rule + * ID of the service bus namespace in which you would like to have Event Hubs + * created for streaming the Activity Log. The rule ID is of the format: + * '{service bus resource ID}/authorizationrules/{key name}'. + * + * @param {array} logProfilesResource.locations List of regions for which + * Activity Log events should be stored or streamed. It is a comma separated + * list of valid ARM locations including the 'global' location. + * + * @param {array} logProfilesResource.categories the categories of the logs. + * These categories are created as is convenient to the user. Some values are: + * 'Write', 'Delete', and/or 'Action.' + * + * @param {object} logProfilesResource.retentionPolicy the retention policy for + * the events in the log. + * + * @param {boolean} logProfilesResource.retentionPolicy.enabled a value + * indicating whether the retention policy is enabled. + * + * @param {number} logProfilesResource.retentionPolicy.days the number of days + * for the retention in days. A value of 0 will retain the events indefinitely. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(logProfileName, logProfilesResource, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(logProfileName, logProfilesResource, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates an existing LogProfilesResource. To update other fields use the + * CreateOrUpdate method. + * + * @param {string} logProfileName The name of the log profile. + * + * @param {object} logProfilesResource Parameters supplied to the operation. + * + * @param {object} [logProfilesResource.tags] Resource tags + * + * @param {string} [logProfilesResource.storageAccountId] the resource id of + * the storage account to which you would like to send the Activity Log. + * + * @param {string} [logProfilesResource.serviceBusRuleId] The service bus rule + * ID of the service bus namespace in which you would like to have Event Hubs + * created for streaming the Activity Log. The rule ID is of the format: + * '{service bus resource ID}/authorizationrules/{key name}'. + * + * @param {array} logProfilesResource.locations List of regions for which + * Activity Log events should be stored or streamed. It is a comma separated + * list of valid ARM locations including the 'global' location. + * + * @param {array} logProfilesResource.categories the categories of the logs. + * These categories are created as is convenient to the user. Some values are: + * 'Write', 'Delete', and/or 'Action.' + * + * @param {object} logProfilesResource.retentionPolicy the retention policy for + * the events in the log. + * + * @param {boolean} logProfilesResource.retentionPolicy.enabled a value + * indicating whether the retention policy is enabled. + * + * @param {number} logProfilesResource.retentionPolicy.days the number of days + * for the retention in days. A value of 0 will retain the events indefinitely. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {LogProfileResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(logProfileName, logProfilesResource, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(logProfileName, logProfilesResource, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(logProfileName, logProfilesResource, options, optionalCallback); + } + } + + /** + * List the log profiles. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List the log profiles. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {LogProfileCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link LogProfileCollection} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + +} + +module.exports = LogProfiles; diff --git a/lib/services/monitor/lib/operations/metricAlerts.js b/lib/services/monitor/lib/operations/metricAlerts.js new file mode 100644 index 0000000000..d8cdf644dc --- /dev/null +++ b/lib/services/monitor/lib/operations/metricAlerts.js @@ -0,0 +1,1590 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; +const moment = require('moment'); + +/** + * Retrieve alert rule definitions in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listBySubscription(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2018-03-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.Insight/metricAlerts'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MetricAlertResourceCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Retrieve alert rule defintions in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByResourceGroup(resourceGroupName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2018-03-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MetricAlertResourceCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Retrieve an alert rule definiton. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceGroupName, ruleName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2018-03-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MetricAlertResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Create or update an metric alert definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} parameters.description the description of the metric alert + * that will be included in the alert email. + * + * @param {number} parameters.severity Alert severity {0, 1, 2, 3, 4} + * + * @param {boolean} parameters.enabled the flag that indicates whether the + * metric alert is enabled. + * + * @param {array} [parameters.scopes] the list of resource id's that this + * metric alert is scoped to. + * + * @param {moment.duration} parameters.evaluationFrequency how often the metric + * alert is evaluated represented in ISO 8601 duration format. + * + * @param {moment.duration} parameters.windowSize the period of time (in ISO + * 8601 duration format) that is used to monitor alert activity based on the + * threshold. + * + * @param {object} parameters.criteria defines the specific alert criteria + * information. + * + * @param {string} parameters.criteria.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _createOrUpdate(resourceGroupName, ruleName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2018-03-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PUT'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['MetricAlertResource']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MetricAlertResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Update an metric alert definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to update. + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} parameters.description the description of the metric alert + * that will be included in the alert email. + * + * @param {number} parameters.severity Alert severity {0, 1, 2, 3, 4} + * + * @param {boolean} parameters.enabled the flag that indicates whether the + * metric alert is enabled. + * + * @param {array} [parameters.scopes] the list of resource id's that this + * metric alert is scoped to. + * + * @param {moment.duration} parameters.evaluationFrequency how often the metric + * alert is evaluated represented in ISO 8601 duration format. + * + * @param {moment.duration} parameters.windowSize the period of time (in ISO + * 8601 duration format) that is used to monitor alert activity based on the + * threshold. + * + * @param {object} parameters.criteria defines the specific alert criteria + * information. + * + * @param {string} parameters.criteria.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _update(resourceGroupName, ruleName, parameters, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2018-03-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'PATCH'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['MetricAlertResourcePatch']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MetricAlertResource']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Delete an alert rule defitiniton. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _deleteMethod(resourceGroupName, ruleName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2018-03-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'DELETE'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && statusCode !== 204) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a MetricAlerts. */ +class MetricAlerts { + /** + * Create a MetricAlerts. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._listBySubscription = _listBySubscription; + this._listByResourceGroup = _listByResourceGroup; + this._get = _get; + this._createOrUpdate = _createOrUpdate; + this._update = _update; + this._deleteMethod = _deleteMethod; + } + + /** + * Retrieve alert rule definitions in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listBySubscriptionWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listBySubscription(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve alert rule definitions in a subscription. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MetricAlertResourceCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listBySubscription(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listBySubscription(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listBySubscription(options, optionalCallback); + } + } + + /** + * Retrieve alert rule defintions in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve alert rule defintions in a resource group. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MetricAlertResourceCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResourceCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByResourceGroup(resourceGroupName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); + } + } + + /** + * Retrieve an alert rule definiton. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceGroupName, ruleName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceGroupName, ruleName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve an alert rule definiton. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MetricAlertResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceGroupName, ruleName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceGroupName, ruleName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceGroupName, ruleName, options, optionalCallback); + } + } + + /** + * Create or update an metric alert definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} parameters.description the description of the metric alert + * that will be included in the alert email. + * + * @param {number} parameters.severity Alert severity {0, 1, 2, 3, 4} + * + * @param {boolean} parameters.enabled the flag that indicates whether the + * metric alert is enabled. + * + * @param {array} [parameters.scopes] the list of resource id's that this + * metric alert is scoped to. + * + * @param {moment.duration} parameters.evaluationFrequency how often the metric + * alert is evaluated represented in ISO 8601 duration format. + * + * @param {moment.duration} parameters.windowSize the period of time (in ISO + * 8601 duration format) that is used to monitor alert activity based on the + * threshold. + * + * @param {object} parameters.criteria defines the specific alert criteria + * information. + * + * @param {string} parameters.criteria.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + createOrUpdateWithHttpOperationResponse(resourceGroupName, ruleName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, ruleName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create or update an metric alert definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to create or update. + * + * @param {string} parameters.description the description of the metric alert + * that will be included in the alert email. + * + * @param {number} parameters.severity Alert severity {0, 1, 2, 3, 4} + * + * @param {boolean} parameters.enabled the flag that indicates whether the + * metric alert is enabled. + * + * @param {array} [parameters.scopes] the list of resource id's that this + * metric alert is scoped to. + * + * @param {moment.duration} parameters.evaluationFrequency how often the metric + * alert is evaluated represented in ISO 8601 duration format. + * + * @param {moment.duration} parameters.windowSize the period of time (in ISO + * 8601 duration format) that is used to monitor alert activity based on the + * threshold. + * + * @param {object} parameters.criteria defines the specific alert criteria + * information. + * + * @param {string} parameters.criteria.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {string} parameters.location Resource location + * + * @param {object} [parameters.tags] Resource tags + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MetricAlertResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + createOrUpdate(resourceGroupName, ruleName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._createOrUpdate(resourceGroupName, ruleName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._createOrUpdate(resourceGroupName, ruleName, parameters, options, optionalCallback); + } + } + + /** + * Update an metric alert definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to update. + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} parameters.description the description of the metric alert + * that will be included in the alert email. + * + * @param {number} parameters.severity Alert severity {0, 1, 2, 3, 4} + * + * @param {boolean} parameters.enabled the flag that indicates whether the + * metric alert is enabled. + * + * @param {array} [parameters.scopes] the list of resource id's that this + * metric alert is scoped to. + * + * @param {moment.duration} parameters.evaluationFrequency how often the metric + * alert is evaluated represented in ISO 8601 duration format. + * + * @param {moment.duration} parameters.windowSize the period of time (in ISO + * 8601 duration format) that is used to monitor alert activity based on the + * threshold. + * + * @param {object} parameters.criteria defines the specific alert criteria + * information. + * + * @param {string} parameters.criteria.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + updateWithHttpOperationResponse(resourceGroupName, ruleName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, ruleName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Update an metric alert definition. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} parameters The parameters of the rule to update. + * + * @param {object} [parameters.tags] Resource tags + * + * @param {string} parameters.description the description of the metric alert + * that will be included in the alert email. + * + * @param {number} parameters.severity Alert severity {0, 1, 2, 3, 4} + * + * @param {boolean} parameters.enabled the flag that indicates whether the + * metric alert is enabled. + * + * @param {array} [parameters.scopes] the list of resource id's that this + * metric alert is scoped to. + * + * @param {moment.duration} parameters.evaluationFrequency how often the metric + * alert is evaluated represented in ISO 8601 duration format. + * + * @param {moment.duration} parameters.windowSize the period of time (in ISO + * 8601 duration format) that is used to monitor alert activity based on the + * threshold. + * + * @param {object} parameters.criteria defines the specific alert criteria + * information. + * + * @param {string} parameters.criteria.odatatype Polymorphic Discriminator + * + * @param {array} [parameters.actions] the array of actions that are performed + * when the alert rule becomes active, and when an alert condition is resolved. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MetricAlertResource} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertResource} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + update(resourceGroupName, ruleName, parameters, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._update(resourceGroupName, ruleName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, ruleName, parameters, options, optionalCallback); + } + } + + /** + * Delete an alert rule defitiniton. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, ruleName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, ruleName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Delete an alert rule defitiniton. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {null} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + deleteMethod(resourceGroupName, ruleName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, ruleName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, ruleName, options, optionalCallback); + } + } + +} + +module.exports = MetricAlerts; diff --git a/lib/services/monitor/lib/operations/metricAlertsStatus.js b/lib/services/monitor/lib/operations/metricAlertsStatus.js new file mode 100644 index 0000000000..7bd81a8494 --- /dev/null +++ b/lib/services/monitor/lib/operations/metricAlertsStatus.js @@ -0,0 +1,505 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Retrieve an alert rule status. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertStatusCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(resourceGroupName, ruleName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2018-03-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}/status'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MetricAlertStatusCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Retrieve an alert rule status. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {string} statusName The name of the status. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertStatusCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _listByName(resourceGroupName, ruleName, statusName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2018-03-01'; + // Validate + try { + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (ruleName === null || ruleName === undefined || typeof ruleName.valueOf() !== 'string') { + throw new Error('ruleName cannot be null or undefined and it must be of type string.'); + } + if (statusName === null || statusName === undefined || typeof statusName.valueOf() !== 'string') { + throw new Error('statusName cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}/status/{statusName}'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{ruleName}', encodeURIComponent(ruleName)); + requestUrl = requestUrl.replace('{statusName}', encodeURIComponent(statusName)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['MetricAlertStatusCollection']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a MetricAlertsStatus. */ +class MetricAlertsStatus { + /** + * Create a MetricAlertsStatus. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listByName = _listByName; + } + + /** + * Retrieve an alert rule status. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(resourceGroupName, ruleName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(resourceGroupName, ruleName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve an alert rule status. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MetricAlertStatusCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertStatusCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(resourceGroupName, ruleName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(resourceGroupName, ruleName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(resourceGroupName, ruleName, options, optionalCallback); + } + } + + /** + * Retrieve an alert rule status. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {string} statusName The name of the status. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listByNameWithHttpOperationResponse(resourceGroupName, ruleName, statusName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByName(resourceGroupName, ruleName, statusName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Retrieve an alert rule status. + * + * @param {string} resourceGroupName The name of the resource group. + * + * @param {string} ruleName The name of the rule. + * + * @param {string} statusName The name of the status. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {MetricAlertStatusCollection} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link MetricAlertStatusCollection} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + listByName(resourceGroupName, ruleName, statusName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._listByName(resourceGroupName, ruleName, statusName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByName(resourceGroupName, ruleName, statusName, options, optionalCallback); + } + } + +} + +module.exports = MetricAlertsStatus; diff --git a/lib/services/monitor/lib/operations/metricBaseline.js b/lib/services/monitor/lib/operations/metricBaseline.js new file mode 100644 index 0000000000..365ca4990c --- /dev/null +++ b/lib/services/monitor/lib/operations/metricBaseline.js @@ -0,0 +1,642 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; +const moment = require('moment'); + +/** + * **Gets the baseline values for a specific metric**. + * + * @param {string} resourceUri The identifier of the resource. It has the + * following structure: + * subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. + * For example: + * subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 + * + * @param {string} metricName The name of the metric to retrieve the baseline + * for. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.timespan] The timespan of the query. It is a string + * with the following format 'startDateTime_ISO/endDateTime_ISO'. + * + * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of + * the query. + * + * @param {string} [options.aggregation] The aggregation type of the metric to + * retrieve the baseline for. + * + * @param {string} [options.sensitivities] The list of sensitivities (comma + * separated) to retrieve. + * + * @param {string} [options.resultType] Allows retrieving only metadata of the + * baseline. On data request all information is retrieved. Possible values + * include: 'Data', 'Metadata' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link BaselineResponse} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _get(resourceUri, metricName, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let timespan = (options && options.timespan !== undefined) ? options.timespan : undefined; + let interval = (options && options.interval !== undefined) ? options.interval : undefined; + let aggregation = (options && options.aggregation !== undefined) ? options.aggregation : undefined; + let sensitivities = (options && options.sensitivities !== undefined) ? options.sensitivities : undefined; + let resultType = (options && options.resultType !== undefined) ? options.resultType : undefined; + let apiVersion = '2017-11-01-preview'; + // Validate + try { + if (resourceUri === null || resourceUri === undefined || typeof resourceUri.valueOf() !== 'string') { + throw new Error('resourceUri cannot be null or undefined and it must be of type string.'); + } + if (metricName === null || metricName === undefined || typeof metricName.valueOf() !== 'string') { + throw new Error('metricName cannot be null or undefined and it must be of type string.'); + } + if (timespan !== null && timespan !== undefined && typeof timespan.valueOf() !== 'string') { + throw new Error('timespan must be of type string.'); + } + if(interval && !moment.isDuration(interval)) { + throw new Error('interval must be of type moment.duration.'); + } + if (aggregation !== null && aggregation !== undefined && typeof aggregation.valueOf() !== 'string') { + throw new Error('aggregation must be of type string.'); + } + if (sensitivities !== null && sensitivities !== undefined && typeof sensitivities.valueOf() !== 'string') { + throw new Error('sensitivities must be of type string.'); + } + if (resultType) { + let allowedValues = [ 'Data', 'Metadata' ]; + if (!allowedValues.some( function(item) { return item === resultType; })) { + throw new Error(resultType + ' is not a valid value. The valid values are: ' + allowedValues); + } + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{resourceUri}/providers/microsoft.insights/baseline/{metricName}'; + requestUrl = requestUrl.replace('{resourceUri}', resourceUri); + requestUrl = requestUrl.replace('{metricName}', encodeURIComponent(metricName)); + let queryParameters = []; + if (timespan !== null && timespan !== undefined) { + queryParameters.push('timespan=' + encodeURIComponent(timespan)); + } + if (interval !== null && interval !== undefined) { + queryParameters.push('interval=' + encodeURIComponent(interval.toISOString())); + } + if (aggregation !== null && aggregation !== undefined) { + queryParameters.push('aggregation=' + encodeURIComponent(aggregation)); + } + if (sensitivities !== null && sensitivities !== undefined) { + queryParameters.push('sensitivities=' + encodeURIComponent(sensitivities)); + } + if (resultType !== null && resultType !== undefined) { + queryParameters.push('resultType=' + encodeURIComponent(resultType)); + } + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['BaselineResponse']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * **Lists the baseline values for a resource**. + * + * @param {string} resourceUri The identifier of the resource. It has the + * following structure: + * subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. + * For example: + * subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 + * + * @param {object} timeSeriesInformation Information that need to be specified + * to calculate a baseline on a time series. + * + * @param {array} timeSeriesInformation.sensitivities the list of sensitivities + * for calculating the baseline. + * + * @param {array} timeSeriesInformation.values The metric values to calculate + * the baseline. + * + * @param {array} [timeSeriesInformation.timestamps] the array of timestamps of + * the baselines. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CalculateBaselineResponse} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _calculateBaseline(resourceUri, timeSeriesInformation, options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2017-11-01-preview'; + // Validate + try { + if (resourceUri === null || resourceUri === undefined || typeof resourceUri.valueOf() !== 'string') { + throw new Error('resourceUri cannot be null or undefined and it must be of type string.'); + } + if (timeSeriesInformation === null || timeSeriesInformation === undefined) { + throw new Error('timeSeriesInformation cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + '{resourceUri}/providers/microsoft.insights/calculatebaseline'; + requestUrl = requestUrl.replace('{resourceUri}', resourceUri); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + // Serialize Request + let requestContent = null; + let requestModel = null; + try { + if (timeSeriesInformation !== null && timeSeriesInformation !== undefined) { + let requestModelMapper = new client.models['TimeSeriesInformation']().mapper(); + requestModel = client.serialize(requestModelMapper, timeSeriesInformation, 'timeSeriesInformation'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(timeSeriesInformation, null, 2)}.`); + return callback(serializationError); + } + httpRequest.body = requestContent; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['CalculateBaselineResponse']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a MetricBaseline. */ +class MetricBaseline { + /** + * Create a MetricBaseline. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._get = _get; + this._calculateBaseline = _calculateBaseline; + } + + /** + * **Gets the baseline values for a specific metric**. + * + * @param {string} resourceUri The identifier of the resource. It has the + * following structure: + * subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. + * For example: + * subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 + * + * @param {string} metricName The name of the metric to retrieve the baseline + * for. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.timespan] The timespan of the query. It is a string + * with the following format 'startDateTime_ISO/endDateTime_ISO'. + * + * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of + * the query. + * + * @param {string} [options.aggregation] The aggregation type of the metric to + * retrieve the baseline for. + * + * @param {string} [options.sensitivities] The list of sensitivities (comma + * separated) to retrieve. + * + * @param {string} [options.resultType] Allows retrieving only metadata of the + * baseline. On data request all information is retrieved. Possible values + * include: 'Data', 'Metadata' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + getWithHttpOperationResponse(resourceUri, metricName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._get(resourceUri, metricName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * **Gets the baseline values for a specific metric**. + * + * @param {string} resourceUri The identifier of the resource. It has the + * following structure: + * subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. + * For example: + * subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 + * + * @param {string} metricName The name of the metric to retrieve the baseline + * for. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.timespan] The timespan of the query. It is a string + * with the following format 'startDateTime_ISO/endDateTime_ISO'. + * + * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of + * the query. + * + * @param {string} [options.aggregation] The aggregation type of the metric to + * retrieve the baseline for. + * + * @param {string} [options.sensitivities] The list of sensitivities (comma + * separated) to retrieve. + * + * @param {string} [options.resultType] Allows retrieving only metadata of the + * baseline. On data request all information is retrieved. Possible values + * include: 'Data', 'Metadata' + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {BaselineResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link BaselineResponse} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + get(resourceUri, metricName, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._get(resourceUri, metricName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._get(resourceUri, metricName, options, optionalCallback); + } + } + + /** + * **Lists the baseline values for a resource**. + * + * @param {string} resourceUri The identifier of the resource. It has the + * following structure: + * subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. + * For example: + * subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 + * + * @param {object} timeSeriesInformation Information that need to be specified + * to calculate a baseline on a time series. + * + * @param {array} timeSeriesInformation.sensitivities the list of sensitivities + * for calculating the baseline. + * + * @param {array} timeSeriesInformation.values The metric values to calculate + * the baseline. + * + * @param {array} [timeSeriesInformation.timestamps] the array of timestamps of + * the baselines. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + calculateBaselineWithHttpOperationResponse(resourceUri, timeSeriesInformation, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._calculateBaseline(resourceUri, timeSeriesInformation, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * **Lists the baseline values for a resource**. + * + * @param {string} resourceUri The identifier of the resource. It has the + * following structure: + * subscriptions/{subscriptionName}/resourceGroups/{resourceGroupName}/providers/{providerName}/{resourceName}. + * For example: + * subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 + * + * @param {object} timeSeriesInformation Information that need to be specified + * to calculate a baseline on a time series. + * + * @param {array} timeSeriesInformation.sensitivities the list of sensitivities + * for calculating the baseline. + * + * @param {array} timeSeriesInformation.values The metric values to calculate + * the baseline. + * + * @param {array} [timeSeriesInformation.timestamps] the array of timestamps of + * the baselines. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {CalculateBaselineResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link CalculateBaselineResponse} for more + * information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + calculateBaseline(resourceUri, timeSeriesInformation, options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._calculateBaseline(resourceUri, timeSeriesInformation, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._calculateBaseline(resourceUri, timeSeriesInformation, options, optionalCallback); + } + } + +} + +module.exports = MetricBaseline; diff --git a/lib/services/monitor/lib/operations/metricDefinitions.js b/lib/services/monitor/lib/operations/metricDefinitions.js index f65c84ab53..f3d1817183 100644 --- a/lib/services/monitor/lib/operations/metricDefinitions.js +++ b/lib/services/monitor/lib/operations/metricDefinitions.js @@ -21,6 +21,9 @@ const WebResource = msRest.WebResource; * * @param {object} [options] Optional Parameters. * + * @param {string} [options.metricnamespace] Metric namespace to query metric + * definitions for. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -48,12 +51,16 @@ function _list(resourceUri, options, callback) { if (!callback) { throw new Error('callback cannot be null.'); } - let apiVersion = '2017-05-01-preview'; + let metricnamespace = (options && options.metricnamespace !== undefined) ? options.metricnamespace : undefined; + let apiVersion = '2018-01-01'; // Validate try { if (resourceUri === null || resourceUri === undefined || typeof resourceUri.valueOf() !== 'string') { throw new Error('resourceUri cannot be null or undefined and it must be of type string.'); } + if (metricnamespace !== null && metricnamespace !== undefined && typeof metricnamespace.valueOf() !== 'string') { + throw new Error('metricnamespace must be of type string.'); + } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } @@ -67,6 +74,9 @@ function _list(resourceUri, options, callback) { requestUrl = requestUrl.replace('{resourceUri}', resourceUri); let queryParameters = []; queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (metricnamespace !== null && metricnamespace !== undefined) { + queryParameters.push('metricnamespace=' + encodeURIComponent(metricnamespace)); + } if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -153,7 +163,7 @@ function _list(resourceUri, options, callback) { class MetricDefinitions { /** * Create a MetricDefinitions. - * @param {MonitorClient} client Reference to the service client. + * @param {MonitorManagementClient} client Reference to the service client. */ constructor(client) { this.client = client; @@ -167,6 +177,9 @@ class MetricDefinitions { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.metricnamespace] Metric namespace to query metric + * definitions for. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -197,6 +210,9 @@ class MetricDefinitions { * * @param {object} [options] Optional Parameters. * + * @param {string} [options.metricnamespace] Metric namespace to query metric + * definitions for. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * diff --git a/lib/services/monitor/lib/operations/metrics.js b/lib/services/monitor/lib/operations/metrics.js index c8e29d8bad..02d0aa5489 100644 --- a/lib/services/monitor/lib/operations/metrics.js +++ b/lib/services/monitor/lib/operations/metrics.js @@ -28,7 +28,8 @@ const moment = require('moment'); * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of * the query. * - * @param {string} [options.metric] The name of the metric to retrieve. + * @param {string} [options.metricnames] The names of the metrics (comma + * separated) to retrieve. * * @param {string} [options.aggregation] The list of aggregation types (comma * separated) to retrieve. @@ -57,6 +58,9 @@ const moment = require('moment'); * syntax allowed depends on the operation. See the operation's description for * details. Possible values include: 'Data', 'Metadata' * + * @param {string} [options.metricnamespace] Metric namespace to query metric + * definitions for. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -85,13 +89,14 @@ function _list(resourceUri, options, callback) { } let timespan = (options && options.timespan !== undefined) ? options.timespan : undefined; let interval = (options && options.interval !== undefined) ? options.interval : undefined; - let metric = (options && options.metric !== undefined) ? options.metric : undefined; + let metricnames = (options && options.metricnames !== undefined) ? options.metricnames : undefined; let aggregation = (options && options.aggregation !== undefined) ? options.aggregation : undefined; let top = (options && options.top !== undefined) ? options.top : undefined; let orderby = (options && options.orderby !== undefined) ? options.orderby : undefined; let filter = (options && options.filter !== undefined) ? options.filter : undefined; let resultType = (options && options.resultType !== undefined) ? options.resultType : undefined; - let apiVersion = '2017-05-01-preview'; + let metricnamespace = (options && options.metricnamespace !== undefined) ? options.metricnamespace : undefined; + let apiVersion = '2018-01-01'; // Validate try { if (resourceUri === null || resourceUri === undefined || typeof resourceUri.valueOf() !== 'string') { @@ -103,8 +108,8 @@ function _list(resourceUri, options, callback) { if(interval && !moment.isDuration(interval)) { throw new Error('interval must be of type moment.duration.'); } - if (metric !== null && metric !== undefined && typeof metric.valueOf() !== 'string') { - throw new Error('metric must be of type string.'); + if (metricnames !== null && metricnames !== undefined && typeof metricnames.valueOf() !== 'string') { + throw new Error('metricnames must be of type string.'); } if (aggregation !== null && aggregation !== undefined && typeof aggregation.valueOf() !== 'string') { throw new Error('aggregation must be of type string.'); @@ -124,6 +129,9 @@ function _list(resourceUri, options, callback) { throw new Error(resultType + ' is not a valid value. The valid values are: ' + allowedValues); } } + if (metricnamespace !== null && metricnamespace !== undefined && typeof metricnamespace.valueOf() !== 'string') { + throw new Error('metricnamespace must be of type string.'); + } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); } @@ -142,17 +150,17 @@ function _list(resourceUri, options, callback) { if (interval !== null && interval !== undefined) { queryParameters.push('interval=' + encodeURIComponent(interval.toISOString())); } - if (metric !== null && metric !== undefined) { - queryParameters.push('metric=' + encodeURIComponent(metric)); + if (metricnames !== null && metricnames !== undefined) { + queryParameters.push('metricnames=' + encodeURIComponent(metricnames)); } if (aggregation !== null && aggregation !== undefined) { queryParameters.push('aggregation=' + encodeURIComponent(aggregation)); } if (top !== null && top !== undefined) { - queryParameters.push('$top=' + encodeURIComponent(top.toString())); + queryParameters.push('top=' + encodeURIComponent(top.toString())); } if (orderby !== null && orderby !== undefined) { - queryParameters.push('$orderby=' + encodeURIComponent(orderby)); + queryParameters.push('orderby=' + encodeURIComponent(orderby)); } if (filter !== null && filter !== undefined) { queryParameters.push('$filter=' + encodeURIComponent(filter)); @@ -161,6 +169,9 @@ function _list(resourceUri, options, callback) { queryParameters.push('resultType=' + encodeURIComponent(resultType)); } queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (metricnamespace !== null && metricnamespace !== undefined) { + queryParameters.push('metricnamespace=' + encodeURIComponent(metricnamespace)); + } if (queryParameters.length > 0) { requestUrl += '?' + queryParameters.join('&'); } @@ -247,7 +258,7 @@ function _list(resourceUri, options, callback) { class Metrics { /** * Create a Metrics. - * @param {MonitorClient} client Reference to the service client. + * @param {MonitorManagementClient} client Reference to the service client. */ constructor(client) { this.client = client; @@ -267,7 +278,8 @@ class Metrics { * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of * the query. * - * @param {string} [options.metric] The name of the metric to retrieve. + * @param {string} [options.metricnames] The names of the metrics (comma + * separated) to retrieve. * * @param {string} [options.aggregation] The list of aggregation types (comma * separated) to retrieve. @@ -296,6 +308,9 @@ class Metrics { * syntax allowed depends on the operation. See the operation's description for * details. Possible values include: 'Data', 'Metadata' * + * @param {string} [options.metricnamespace] Metric namespace to query metric + * definitions for. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * @@ -332,7 +347,8 @@ class Metrics { * @param {moment.duration} [options.interval] The interval (i.e. timegrain) of * the query. * - * @param {string} [options.metric] The name of the metric to retrieve. + * @param {string} [options.metricnames] The names of the metrics (comma + * separated) to retrieve. * * @param {string} [options.aggregation] The list of aggregation types (comma * separated) to retrieve. @@ -361,6 +377,9 @@ class Metrics { * syntax allowed depends on the operation. See the operation's description for * details. Possible values include: 'Data', 'Metadata' * + * @param {string} [options.metricnamespace] Metric namespace to query metric + * definitions for. + * * @param {object} [options.customHeaders] Headers that will be added to the * request * diff --git a/lib/services/monitor/lib/operations/operations.js b/lib/services/monitor/lib/operations/operations.js new file mode 100644 index 0000000000..664c03afa7 --- /dev/null +++ b/lib/services/monitor/lib/operations/operations.js @@ -0,0 +1,235 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all of the available operations from Microsoft.Insights provider. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _list(options, callback) { + /* jshint validthis: true */ + let client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let apiVersion = '2015-04-01'; + // Validate + try { + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'providers/microsoft.insights/operations'; + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['OperationListResult']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a Operations. */ +class Operations { + /** + * Create a Operations. + * @param {MonitorManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Lists all of the available operations from Microsoft.Insights provider. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all of the available operations from Microsoft.Insights provider. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {OperationListResult} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link OperationListResult} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + list(options, optionalCallback) { + let client = this.client; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + +} + +module.exports = Operations; diff --git a/lib/services/monitor/lib/operations/tenantActivityLogs.js b/lib/services/monitor/lib/operations/tenantActivityLogs.js index e1ecbe1561..7e523153c9 100644 --- a/lib/services/monitor/lib/operations/tenantActivityLogs.js +++ b/lib/services/monitor/lib/operations/tenantActivityLogs.js @@ -322,7 +322,7 @@ function _listNext(nextPageLink, options, callback) { class TenantActivityLogs { /** * Create a TenantActivityLogs. - * @param {MonitorClient} client Reference to the service client. + * @param {MonitorManagementClient} client Reference to the service client. */ constructor(client) { this.client = client;