static public AutoscaleNotification ConvertNamespace(Management.Monitor.Management.Models.AutoscaleNotification inputObject) { if (inputObject == null) { return(null); } AutoscaleNotification notification = new AutoscaleNotification( email: inputObject.Email, webhooks: inputObject.Webhooks?.Select(e => e as WebhookNotification).ToList()); return(notification); }
/// <summary> /// Execute the cmdlet /// </summary> public override void ExecuteCmdlet() { if (!(this.SendEmailToSubscriptionAdministrator || this.SendEmailToSubscriptionCoAdministrator) && ((this.Webhook == null || this.Webhook.Length < 1) && (this.CustomEmail == null || this.CustomEmail.Length < 1))) { throw new ArgumentException("At least one Webhook or one CustomeEmail must be present, or the notification must be sent to the admin or co-admin"); } var emailNotification = new Management.Monitor.Management.Models.EmailNotification { CustomEmails = this.CustomEmail, SendToSubscriptionAdministrator = this.SendEmailToSubscriptionAdministrator, SendToSubscriptionCoAdministrators = this.SendEmailToSubscriptionCoAdministrator, }; var notification = new Management.Monitor.Management.Models.AutoscaleNotification { Email = emailNotification, Webhooks = this.Webhook }; WriteObject(notification); }
public void AddAutoscaleSettingCommandParametersProcessing() { var spec = this.CreateCompleteSpec(location: "East US", name: "SettingName", profiles: null); var autoscaleRules = new List <Management.Monitor.Management.Models.ScaleRule> { this.CreateAutoscaleRule("IncommingReq") }; var autoscaleProfile = new List <Management.Monitor.Management.Models.AutoscaleProfile> { this.CreateAutoscaleProfile(autoscaleRules: autoscaleRules, fixedDate: true) }; // Testing with a complete spec as parameter (Update semantics) // Add-AutoscaleSetting -SettingSpec <AutoscaleSettingResource> -ResourceGroup <String> [-DisableSetting [<SwitchParameter>]] [-AutoscaleProfiles <List[AutoscaleProfile]>] [-Profile <AzureSMProfile>] [<CommonParameters>] // Add-AutoscaleSetting -SettingSpec $spec -ResourceGroup $Utilities.ResourceGroup // A NOP cmdlet.InputObject = spec; cmdlet.ResourceGroupName = Utilities.ResourceGroup; cmdlet.ExecuteCmdlet(); Assert.Equal(Utilities.ResourceGroup, this.resourceGroup); Assert.Equal("SettingName", this.settingName); Assert.NotNull(this.createOrUpdatePrms); // Add-AutoscaleSetting -SettingSpec <AutoscaleSettingResource> -ResourceGroup <String> [-DisableSetting [<SwitchParameter>]] [-AutoscaleProfiles <List[AutoscaleProfile]>] [-Profile <AzureSMProfile>] [<CommonParameters>] // Add-AutoscaleSetting -SettingSpec $spec -ResourceGroup $Utilities.ResourceGroup -DisableSetting // Disable the setting cmdlet.DisableSetting = true; cmdlet.ExecuteCmdlet(); Assert.Equal(Utilities.ResourceGroup, this.resourceGroup); Assert.Equal("SettingName", this.settingName); Assert.NotNull(this.createOrUpdatePrms); // Add-AutoscaleSetting -SettingSpec <AutoscaleSettingResource> -ResourceGroup <String> [-DisableSetting [<SwitchParameter>]] [-AutoscaleProfiles <List[AutoscaleProfile]>] [-Profile <AzureSMProfile>] [<CommonParameters>] // Adding a profile cmdlet.AutoscaleProfile = autoscaleProfile; cmdlet.ExecuteCmdlet(); // Add-AutoscaleSetting -Location <String> -Name <String> -ResourceGroup <String> [-DisableSetting [<SwitchParameter>]] [-AutoscaleProfiles <List[AutoscaleProfile]>] -TargetResourceId <String> [-Profile <AzureSMProfile>] [<CommonParameters>] cmdlet.InputObject = null; cmdlet.Name = "SettingName"; cmdlet.Location = "East US"; cmdlet.ResourceGroupName = Utilities.ResourceGroup; cmdlet.TargetResourceId = Utilities.ResourceUri; cmdlet.ExecuteCmdlet(); var eMailNotification = new Management.Monitor.Management.Models.EmailNotification { CustomEmails = null, }; var notification = new Management.Monitor.Management.Models.AutoscaleNotification { Email = eMailNotification, Webhooks = null }; cmdlet.Notification = new List <Management.Monitor.Management.Models.AutoscaleNotification> { notification }; cmdlet.ExecuteCmdlet(); }