/// <summary>
 /// Initializes a new instance of the PSAutomationRunbookReceiver class.
 /// </summary>
 /// <param name="receiver">The receiver to wrap.</param>
 public PSAutomationRunbookReceiver(AutomationRunbookReceiver receiver)
 {
     this.Name = receiver.Name;
     this.AutomationAccountId  = receiver.AutomationAccountId;
     this.RunbookName          = receiver.RunbookName;
     this.WebhookResourceId    = receiver.WebhookResourceId;
     this.IsGlobalRunbook      = receiver.IsGlobalRunbook;
     this.UseCommonAlertSchema = receiver.UseCommonAlertSchema.HasValue ? receiver.UseCommonAlertSchema.Value : false;
     this.ServiceUri           = receiver.ServiceUri;
 }
 private static void AreEqual(AutomationRunbookReceiver exp, AutomationRunbookReceiver act)
 {
     if (exp != null)
     {
         Assert.Equal(exp.AutomationAccountId, act.AutomationAccountId);
         Assert.Equal(exp.IsGlobalRunbook, act.IsGlobalRunbook);
         Assert.Equal(exp.Name, act.Name);
         Assert.Equal(exp.RunbookName, act.RunbookName);
         Assert.Equal(exp.ServiceUri, act.ServiceUri);
     }
 }
        ///GENMHASH:4CDF7BECCD0844E46C921F74A59882A2:AE1E8ADC0D1A19DBCA7A107CCDE71569
        public ActionGroupImpl WithAutomationRunbook(string automationAccountId, string runbookName, string webhookResourceId, bool isGlobalRunbook)
        {
            this.WithoutAutomationRunbook();

            var compositeKey = this.actionReceiverPrefix + runBookSuffix;
            var arr          = new AutomationRunbookReceiver
            {
                Name = compositeKey,
                AutomationAccountId = automationAccountId,
                RunbookName         = runbookName,
                WebhookResourceId   = webhookResourceId,
                IsGlobalRunbook     = isGlobalRunbook
            };

            this.runBookReceivers[compositeKey] = arr;
            return(this);
        }
Example #4
0
        internal static ActionGroupData DeserializeActionGroupData(JsonElement element)
        {
            Optional <string>            kind     = default;
            Optional <string>            identity = default;
            IDictionary <string, string> tags     = default;
            AzureLocation      location           = default;
            ResourceIdentifier id             = default;
            string             name           = default;
            ResourceType       type           = default;
            SystemData         systemData     = default;
            Optional <string>  groupShortName = default;
            Optional <bool>    enabled        = default;
            Optional <IList <EmailReceiver> >             emailReceivers             = default;
            Optional <IList <SmsReceiver> >               smsReceivers               = default;
            Optional <IList <WebhookReceiver> >           webhookReceivers           = default;
            Optional <IList <ItsmReceiver> >              itsmReceivers              = default;
            Optional <IList <AzureAppPushReceiver> >      azureAppPushReceivers      = default;
            Optional <IList <AutomationRunbookReceiver> > automationRunbookReceivers = default;
            Optional <IList <VoiceReceiver> >             voiceReceivers             = default;
            Optional <IList <LogicAppReceiver> >          logicAppReceivers          = default;
            Optional <IList <AzureFunctionReceiver> >     azureFunctionReceivers     = default;
            Optional <IList <ArmRoleReceiver> >           armRoleReceivers           = default;
            Optional <IList <EventHubReceiver> >          eventHubReceivers          = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("identity"))
                {
                    identity = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("groupShortName"))
                        {
                            groupShortName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("enabled"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            enabled = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("emailReceivers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <EmailReceiver> array = new List <EmailReceiver>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(EmailReceiver.DeserializeEmailReceiver(item));
                            }
                            emailReceivers = array;
                            continue;
                        }
                        if (property0.NameEquals("smsReceivers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <SmsReceiver> array = new List <SmsReceiver>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(SmsReceiver.DeserializeSmsReceiver(item));
                            }
                            smsReceivers = array;
                            continue;
                        }
                        if (property0.NameEquals("webhookReceivers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <WebhookReceiver> array = new List <WebhookReceiver>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(WebhookReceiver.DeserializeWebhookReceiver(item));
                            }
                            webhookReceivers = array;
                            continue;
                        }
                        if (property0.NameEquals("itsmReceivers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ItsmReceiver> array = new List <ItsmReceiver>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ItsmReceiver.DeserializeItsmReceiver(item));
                            }
                            itsmReceivers = array;
                            continue;
                        }
                        if (property0.NameEquals("azureAppPushReceivers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <AzureAppPushReceiver> array = new List <AzureAppPushReceiver>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(AzureAppPushReceiver.DeserializeAzureAppPushReceiver(item));
                            }
                            azureAppPushReceivers = array;
                            continue;
                        }
                        if (property0.NameEquals("automationRunbookReceivers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <AutomationRunbookReceiver> array = new List <AutomationRunbookReceiver>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(AutomationRunbookReceiver.DeserializeAutomationRunbookReceiver(item));
                            }
                            automationRunbookReceivers = array;
                            continue;
                        }
                        if (property0.NameEquals("voiceReceivers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <VoiceReceiver> array = new List <VoiceReceiver>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(VoiceReceiver.DeserializeVoiceReceiver(item));
                            }
                            voiceReceivers = array;
                            continue;
                        }
                        if (property0.NameEquals("logicAppReceivers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <LogicAppReceiver> array = new List <LogicAppReceiver>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(LogicAppReceiver.DeserializeLogicAppReceiver(item));
                            }
                            logicAppReceivers = array;
                            continue;
                        }
                        if (property0.NameEquals("azureFunctionReceivers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <AzureFunctionReceiver> array = new List <AzureFunctionReceiver>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(AzureFunctionReceiver.DeserializeAzureFunctionReceiver(item));
                            }
                            azureFunctionReceivers = array;
                            continue;
                        }
                        if (property0.NameEquals("armRoleReceivers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ArmRoleReceiver> array = new List <ArmRoleReceiver>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ArmRoleReceiver.DeserializeArmRoleReceiver(item));
                            }
                            armRoleReceivers = array;
                            continue;
                        }
                        if (property0.NameEquals("eventHubReceivers"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <EventHubReceiver> array = new List <EventHubReceiver>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(EventHubReceiver.DeserializeEventHubReceiver(item));
                            }
                            eventHubReceivers = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ActionGroupData(id, name, type, systemData, tags, location, kind.Value, identity.Value, groupShortName.Value, Optional.ToNullable(enabled), Optional.ToList(emailReceivers), Optional.ToList(smsReceivers), Optional.ToList(webhookReceivers), Optional.ToList(itsmReceivers), Optional.ToList(azureAppPushReceivers), Optional.ToList(automationRunbookReceivers), Optional.ToList(voiceReceivers), Optional.ToList(logicAppReceivers), Optional.ToList(azureFunctionReceivers), Optional.ToList(armRoleReceivers), Optional.ToList(eventHubReceivers)));
        }