/// <summary> /// Execute the cmdlet /// </summary> public override void ExecuteCmdlet() { if (!(this.SendEmailToSubscriptionAdministrator || this.SendEmailToSubscriptionCoAdministrators) && ((this.Webhooks == null || this.Webhooks.Length < 1) && (this.CustomEmails == null || this.CustomEmails.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 EmailNotification { CustomEmails = this.CustomEmails, SendToSubscriptionAdministrator = this.SendEmailToSubscriptionAdministrator, SendToSubscriptionCoAdministrators = this.SendEmailToSubscriptionCoAdministrators, }; var notification = new AutoscaleNotification { Email = emailNotification, Webhooks = this.Webhooks }; WriteObject(notification); }
public void AddAutoscaleSettingCommandParametersProcessing() { var spec = this.CreateCompleteSpec(location: "East US", name: "SettingName", profiles: null); var autoscaleRules = new List<ScaleRule> { this.CreateAutoscaleRule("IncommingReq") }; var autoscaleProfile = new List<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.SettingSpec = spec; cmdlet.ResourceGroup = 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.AutoscaleProfiles = autoscaleProfile; cmdlet.ExecuteCmdlet(); // Add-AutoscaleSetting -Location <String> -Name <String> -ResourceGroup <String> [-DisableSetting [<SwitchParameter>]] [-AutoscaleProfiles <List[AutoscaleProfile]>] -TargetResourceId <String> [-Profile <AzureSMProfile>] [<CommonParameters>] cmdlet.SettingSpec = null; cmdlet.Name = "SettingName"; cmdlet.Location = "East US"; cmdlet.ResourceGroup = Utilities.ResourceGroup; cmdlet.TargetResourceId = Utilities.ResourceUri; cmdlet.ExecuteCmdlet(); var eMailNotification = new EmailNotification { CustomEmails = null, }; var notification = new AutoscaleNotification { Email = eMailNotification, Webhooks = null }; cmdlet.Notifications = new List<AutoscaleNotification> { notification }; cmdlet.ExecuteCmdlet(); }
/// <summary> /// Initializes a new instance of the AutoscaleNotification class. /// </summary> /// <param name="email">the email notification.</param> /// <param name="webhooks">the collection of webhook /// notifications.</param> public AutoscaleNotification(EmailNotification email = default(EmailNotification), System.Collections.Generic.IList <WebhookNotification> webhooks = default(System.Collections.Generic.IList <WebhookNotification>)) { Email = email; Webhooks = webhooks; }