< Summary

Class:Azure.ResourceManager.Network.Models.SecurityRule
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\SecurityRule.cs
C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\SecurityRule.Serialization.cs
Covered lines:205
Uncovered lines:44
Coverable lines:249
Total lines:526
Line coverage:82.3% (205 of 249)
Covered branches:126
Total branches:156
Branch coverage:80.7% (126 of 156)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_Name()-100%100%
get_Etag()-100%100%
get_Description()-100%100%
get_Protocol()-100%100%
get_SourcePortRange()-100%100%
get_DestinationPortRange()-100%100%
get_SourceAddressPrefix()-100%100%
get_SourceAddressPrefixes()-100%100%
get_SourceApplicationSecurityGroups()-100%100%
get_DestinationAddressPrefix()-100%100%
get_DestinationAddressPrefixes()-100%100%
get_DestinationApplicationSecurityGroups()-100%100%
get_SourcePortRanges()-100%100%
get_DestinationPortRanges()-100%100%
get_Access()-100%100%
get_Priority()-100%100%
get_Direction()-100%100%
get_ProvisioningState()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-77.78%80%
DeserializeSecurityRule(...)-79.69%81.13%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\SecurityRule.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System.Collections.Generic;
 9
 10namespace Azure.ResourceManager.Network.Models
 11{
 12    /// <summary> Network security rule. </summary>
 13    public partial class SecurityRule : SubResource
 14    {
 15        /// <summary> Initializes a new instance of SecurityRule. </summary>
 2016        public SecurityRule()
 17        {
 2018        }
 19
 20        /// <summary> Initializes a new instance of SecurityRule. </summary>
 21        /// <param name="id"> Resource ID. </param>
 22        /// <param name="name"> The name of the resource that is unique within a resource group. This name can be used t
 23        /// <param name="etag"> A unique read-only string that changes whenever the resource is updated. </param>
 24        /// <param name="description"> A description for this rule. Restricted to 140 chars. </param>
 25        /// <param name="protocol"> Network protocol this rule applies to. </param>
 26        /// <param name="sourcePortRange"> The source port or range. Integer or range between 0 and 65535. Asterisk &apo
 27        /// <param name="destinationPortRange"> The destination port or range. Integer or range between 0 and 65535. Ast
 28        /// <param name="sourceAddressPrefix"> The CIDR or source IP range. Asterisk &apos;*&apos; can also be used to m
 29        /// <param name="sourceAddressPrefixes"> The CIDR or source IP ranges. </param>
 30        /// <param name="sourceApplicationSecurityGroups"> The application security group specified as source. </param>
 31        /// <param name="destinationAddressPrefix"> The destination address prefix. CIDR or destination IP range. Asteri
 32        /// <param name="destinationAddressPrefixes"> The destination address prefixes. CIDR or destination IP ranges. <
 33        /// <param name="destinationApplicationSecurityGroups"> The application security group specified as destination.
 34        /// <param name="sourcePortRanges"> The source port ranges. </param>
 35        /// <param name="destinationPortRanges"> The destination port ranges. </param>
 36        /// <param name="access"> The network traffic is allowed or denied. </param>
 37        /// <param name="priority"> The priority of the rule. The value can be between 100 and 4096. The priority number
 38        /// <param name="direction"> The direction of the rule. The direction specifies if rule will be evaluated on inc
 39        /// <param name="provisioningState"> The provisioning state of the security rule resource. </param>
 278840        internal SecurityRule(string id, string name, string etag, string description, SecurityRuleProtocol? protocol, s
 41        {
 278842            Name = name;
 278843            Etag = etag;
 278844            Description = description;
 278845            Protocol = protocol;
 278846            SourcePortRange = sourcePortRange;
 278847            DestinationPortRange = destinationPortRange;
 278848            SourceAddressPrefix = sourceAddressPrefix;
 278849            SourceAddressPrefixes = sourceAddressPrefixes;
 278850            SourceApplicationSecurityGroups = sourceApplicationSecurityGroups;
 278851            DestinationAddressPrefix = destinationAddressPrefix;
 278852            DestinationAddressPrefixes = destinationAddressPrefixes;
 278853            DestinationApplicationSecurityGroups = destinationApplicationSecurityGroups;
 278854            SourcePortRanges = sourcePortRanges;
 278855            DestinationPortRanges = destinationPortRanges;
 278856            Access = access;
 278857            Priority = priority;
 278858            Direction = direction;
 278859            ProvisioningState = provisioningState;
 278860        }
 61
 62        /// <summary> The name of the resource that is unique within a resource group. This name can be used to access t
 316463        public string Name { get; set; }
 64        /// <summary> A unique read-only string that changes whenever the resource is updated. </summary>
 19265        public string Etag { get; }
 66        /// <summary> A description for this rule. Restricted to 140 chars. </summary>
 306467        public string Description { get; set; }
 68        /// <summary> Network protocol this rule applies to. </summary>
 306469        public SecurityRuleProtocol? Protocol { get; set; }
 70        /// <summary> The source port or range. Integer or range between 0 and 65535. Asterisk &apos;*&apos; can also be
 306471        public string SourcePortRange { get; set; }
 72        /// <summary> The destination port or range. Integer or range between 0 and 65535. Asterisk &apos;*&apos; can al
 306473        public string DestinationPortRange { get; set; }
 74        /// <summary> The CIDR or source IP range. Asterisk &apos;*&apos; can also be used to match all source IPs. Defa
 306475        public string SourceAddressPrefix { get; set; }
 76        /// <summary> The CIDR or source IP ranges. </summary>
 294877        public IList<string> SourceAddressPrefixes { get; set; }
 78        /// <summary> The application security group specified as source. </summary>
 289279        public IList<ApplicationSecurityGroup> SourceApplicationSecurityGroups { get; set; }
 80        /// <summary> The destination address prefix. CIDR or destination IP range. Asterisk &apos;*&apos; can also be u
 306481        public string DestinationAddressPrefix { get; set; }
 82        /// <summary> The destination address prefixes. CIDR or destination IP ranges. </summary>
 294883        public IList<string> DestinationAddressPrefixes { get; set; }
 84        /// <summary> The application security group specified as destination. </summary>
 289285        public IList<ApplicationSecurityGroup> DestinationApplicationSecurityGroups { get; set; }
 86        /// <summary> The source port ranges. </summary>
 294887        public IList<string> SourcePortRanges { get; set; }
 88        /// <summary> The destination port ranges. </summary>
 294889        public IList<string> DestinationPortRanges { get; set; }
 90        /// <summary> The network traffic is allowed or denied. </summary>
 306491        public SecurityRuleAccess? Access { get; set; }
 92        /// <summary> The priority of the rule. The value can be between 100 and 4096. The priority number must be uniqu
 303293        public int? Priority { get; set; }
 94        /// <summary> The direction of the rule. The direction specifies if rule will be evaluated on incoming or outgoi
 306495        public SecurityRuleDirection? Direction { get; set; }
 96        /// <summary> The provisioning state of the security rule resource. </summary>
 21297        public ProvisioningState? ProvisioningState { get; }
 98    }
 99}

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\SecurityRule.Serialization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System.Collections.Generic;
 9using System.Text.Json;
 10using Azure.Core;
 11
 12namespace Azure.ResourceManager.Network.Models
 13{
 14    public partial class SecurityRule : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 10418            writer.WriteStartObject();
 10419            if (Name != null)
 20            {
 10421                writer.WritePropertyName("name");
 10422                writer.WriteStringValue(Name);
 23            }
 10424            if (Etag != null)
 25            {
 5626                writer.WritePropertyName("etag");
 5627                writer.WriteStringValue(Etag);
 28            }
 10429            if (Id != null)
 30            {
 5631                writer.WritePropertyName("id");
 5632                writer.WriteStringValue(Id);
 33            }
 10434            writer.WritePropertyName("properties");
 10435            writer.WriteStartObject();
 10436            if (Description != null)
 37            {
 10438                writer.WritePropertyName("description");
 10439                writer.WriteStringValue(Description);
 40            }
 10441            if (Protocol != null)
 42            {
 10443                writer.WritePropertyName("protocol");
 10444                writer.WriteStringValue(Protocol.Value.ToString());
 45            }
 10446            if (SourcePortRange != null)
 47            {
 10448                writer.WritePropertyName("sourcePortRange");
 10449                writer.WriteStringValue(SourcePortRange);
 50            }
 10451            if (DestinationPortRange != null)
 52            {
 10453                writer.WritePropertyName("destinationPortRange");
 10454                writer.WriteStringValue(DestinationPortRange);
 55            }
 10456            if (SourceAddressPrefix != null)
 57            {
 10458                writer.WritePropertyName("sourceAddressPrefix");
 10459                writer.WriteStringValue(SourceAddressPrefix);
 60            }
 10461            if (SourceAddressPrefixes != null)
 62            {
 5663                writer.WritePropertyName("sourceAddressPrefixes");
 5664                writer.WriteStartArray();
 065                foreach (var item in SourceAddressPrefixes)
 66                {
 067                    writer.WriteStringValue(item);
 68                }
 5669                writer.WriteEndArray();
 70            }
 10471            if (SourceApplicationSecurityGroups != null)
 72            {
 073                writer.WritePropertyName("sourceApplicationSecurityGroups");
 074                writer.WriteStartArray();
 075                foreach (var item in SourceApplicationSecurityGroups)
 76                {
 077                    writer.WriteObjectValue(item);
 78                }
 079                writer.WriteEndArray();
 80            }
 10481            if (DestinationAddressPrefix != null)
 82            {
 10483                writer.WritePropertyName("destinationAddressPrefix");
 10484                writer.WriteStringValue(DestinationAddressPrefix);
 85            }
 10486            if (DestinationAddressPrefixes != null)
 87            {
 5688                writer.WritePropertyName("destinationAddressPrefixes");
 5689                writer.WriteStartArray();
 090                foreach (var item in DestinationAddressPrefixes)
 91                {
 092                    writer.WriteStringValue(item);
 93                }
 5694                writer.WriteEndArray();
 95            }
 10496            if (DestinationApplicationSecurityGroups != null)
 97            {
 098                writer.WritePropertyName("destinationApplicationSecurityGroups");
 099                writer.WriteStartArray();
 0100                foreach (var item in DestinationApplicationSecurityGroups)
 101                {
 0102                    writer.WriteObjectValue(item);
 103                }
 0104                writer.WriteEndArray();
 105            }
 104106            if (SourcePortRanges != null)
 107            {
 56108                writer.WritePropertyName("sourcePortRanges");
 56109                writer.WriteStartArray();
 0110                foreach (var item in SourcePortRanges)
 111                {
 0112                    writer.WriteStringValue(item);
 113                }
 56114                writer.WriteEndArray();
 115            }
 104116            if (DestinationPortRanges != null)
 117            {
 56118                writer.WritePropertyName("destinationPortRanges");
 56119                writer.WriteStartArray();
 0120                foreach (var item in DestinationPortRanges)
 121                {
 0122                    writer.WriteStringValue(item);
 123                }
 56124                writer.WriteEndArray();
 125            }
 104126            if (Access != null)
 127            {
 104128                writer.WritePropertyName("access");
 104129                writer.WriteStringValue(Access.Value.ToString());
 130            }
 104131            if (Priority != null)
 132            {
 104133                writer.WritePropertyName("priority");
 104134                writer.WriteNumberValue(Priority.Value);
 135            }
 104136            if (Direction != null)
 137            {
 104138                writer.WritePropertyName("direction");
 104139                writer.WriteStringValue(Direction.Value.ToString());
 140            }
 104141            if (ProvisioningState != null)
 142            {
 56143                writer.WritePropertyName("provisioningState");
 56144                writer.WriteStringValue(ProvisioningState.Value.ToString());
 145            }
 104146            writer.WriteEndObject();
 104147            writer.WriteEndObject();
 104148        }
 149
 150        internal static SecurityRule DeserializeSecurityRule(JsonElement element)
 151        {
 2788152            string name = default;
 2788153            string etag = default;
 2788154            string id = default;
 2788155            string description = default;
 2788156            SecurityRuleProtocol? protocol = default;
 2788157            string sourcePortRange = default;
 2788158            string destinationPortRange = default;
 2788159            string sourceAddressPrefix = default;
 2788160            IList<string> sourceAddressPrefixes = default;
 2788161            IList<ApplicationSecurityGroup> sourceApplicationSecurityGroups = default;
 2788162            string destinationAddressPrefix = default;
 2788163            IList<string> destinationAddressPrefixes = default;
 2788164            IList<ApplicationSecurityGroup> destinationApplicationSecurityGroups = default;
 2788165            IList<string> sourcePortRanges = default;
 2788166            IList<string> destinationPortRanges = default;
 2788167            SecurityRuleAccess? access = default;
 2788168            int? priority = default;
 2788169            SecurityRuleDirection? direction = default;
 2788170            ProvisioningState? provisioningState = default;
 33456171            foreach (var property in element.EnumerateObject())
 172            {
 13940173                if (property.NameEquals("name"))
 174                {
 2788175                    if (property.Value.ValueKind == JsonValueKind.Null)
 176                    {
 177                        continue;
 178                    }
 2788179                    name = property.Value.GetString();
 2788180                    continue;
 181                }
 11152182                if (property.NameEquals("etag"))
 183                {
 2788184                    if (property.Value.ValueKind == JsonValueKind.Null)
 185                    {
 186                        continue;
 187                    }
 2788188                    etag = property.Value.GetString();
 2788189                    continue;
 190                }
 8364191                if (property.NameEquals("id"))
 192                {
 2788193                    if (property.Value.ValueKind == JsonValueKind.Null)
 194                    {
 195                        continue;
 196                    }
 2788197                    id = property.Value.GetString();
 2788198                    continue;
 199                }
 5576200                if (property.NameEquals("properties"))
 201                {
 78760202                    foreach (var property0 in property.Value.EnumerateObject())
 203                    {
 36592204                        if (property0.NameEquals("description"))
 205                        {
 1684206                            if (property0.Value.ValueKind == JsonValueKind.Null)
 207                            {
 208                                continue;
 209                            }
 1684210                            description = property0.Value.GetString();
 1684211                            continue;
 212                        }
 34908213                        if (property0.NameEquals("protocol"))
 214                        {
 2788215                            if (property0.Value.ValueKind == JsonValueKind.Null)
 216                            {
 217                                continue;
 218                            }
 2788219                            protocol = new SecurityRuleProtocol(property0.Value.GetString());
 2788220                            continue;
 221                        }
 32120222                        if (property0.NameEquals("sourcePortRange"))
 223                        {
 2788224                            if (property0.Value.ValueKind == JsonValueKind.Null)
 225                            {
 226                                continue;
 227                            }
 2788228                            sourcePortRange = property0.Value.GetString();
 2788229                            continue;
 230                        }
 29332231                        if (property0.NameEquals("destinationPortRange"))
 232                        {
 1708233                            if (property0.Value.ValueKind == JsonValueKind.Null)
 234                            {
 235                                continue;
 236                            }
 1708237                            destinationPortRange = property0.Value.GetString();
 1708238                            continue;
 239                        }
 27624240                        if (property0.NameEquals("sourceAddressPrefix"))
 241                        {
 2532242                            if (property0.Value.ValueKind == JsonValueKind.Null)
 243                            {
 244                                continue;
 245                            }
 2532246                            sourceAddressPrefix = property0.Value.GetString();
 2532247                            continue;
 248                        }
 25092249                        if (property0.NameEquals("sourceAddressPrefixes"))
 250                        {
 2788251                            if (property0.Value.ValueKind == JsonValueKind.Null)
 252                            {
 253                                continue;
 254                            }
 2788255                            List<string> array = new List<string>();
 26840256                            foreach (var item in property0.Value.EnumerateArray())
 257                            {
 10632258                                if (item.ValueKind == JsonValueKind.Null)
 259                                {
 0260                                    array.Add(null);
 261                                }
 262                                else
 263                                {
 10632264                                    array.Add(item.GetString());
 265                                }
 266                            }
 2788267                            sourceAddressPrefixes = array;
 2788268                            continue;
 269                        }
 22304270                        if (property0.NameEquals("sourceApplicationSecurityGroups"))
 271                        {
 0272                            if (property0.Value.ValueKind == JsonValueKind.Null)
 273                            {
 274                                continue;
 275                            }
 0276                            List<ApplicationSecurityGroup> array = new List<ApplicationSecurityGroup>();
 0277                            foreach (var item in property0.Value.EnumerateArray())
 278                            {
 0279                                if (item.ValueKind == JsonValueKind.Null)
 280                                {
 0281                                    array.Add(null);
 282                                }
 283                                else
 284                                {
 0285                                    array.Add(ApplicationSecurityGroup.DeserializeApplicationSecurityGroup(item));
 286                                }
 287                            }
 0288                            sourceApplicationSecurityGroups = array;
 0289                            continue;
 290                        }
 22304291                        if (property0.NameEquals("destinationAddressPrefix"))
 292                        {
 2788293                            if (property0.Value.ValueKind == JsonValueKind.Null)
 294                            {
 295                                continue;
 296                            }
 2788297                            destinationAddressPrefix = property0.Value.GetString();
 2788298                            continue;
 299                        }
 19516300                        if (property0.NameEquals("destinationAddressPrefixes"))
 301                        {
 2788302                            if (property0.Value.ValueKind == JsonValueKind.Null)
 303                            {
 304                                continue;
 305                            }
 2788306                            List<string> array = new List<string>();
 0307                            foreach (var item in property0.Value.EnumerateArray())
 308                            {
 0309                                if (item.ValueKind == JsonValueKind.Null)
 310                                {
 0311                                    array.Add(null);
 312                                }
 313                                else
 314                                {
 0315                                    array.Add(item.GetString());
 316                                }
 317                            }
 2788318                            destinationAddressPrefixes = array;
 2788319                            continue;
 320                        }
 16728321                        if (property0.NameEquals("destinationApplicationSecurityGroups"))
 322                        {
 0323                            if (property0.Value.ValueKind == JsonValueKind.Null)
 324                            {
 325                                continue;
 326                            }
 0327                            List<ApplicationSecurityGroup> array = new List<ApplicationSecurityGroup>();
 0328                            foreach (var item in property0.Value.EnumerateArray())
 329                            {
 0330                                if (item.ValueKind == JsonValueKind.Null)
 331                                {
 0332                                    array.Add(null);
 333                                }
 334                                else
 335                                {
 0336                                    array.Add(ApplicationSecurityGroup.DeserializeApplicationSecurityGroup(item));
 337                                }
 338                            }
 0339                            destinationApplicationSecurityGroups = array;
 0340                            continue;
 341                        }
 16728342                        if (property0.NameEquals("sourcePortRanges"))
 343                        {
 2788344                            if (property0.Value.ValueKind == JsonValueKind.Null)
 345                            {
 346                                continue;
 347                            }
 2788348                            List<string> array = new List<string>();
 0349                            foreach (var item in property0.Value.EnumerateArray())
 350                            {
 0351                                if (item.ValueKind == JsonValueKind.Null)
 352                                {
 0353                                    array.Add(null);
 354                                }
 355                                else
 356                                {
 0357                                    array.Add(item.GetString());
 358                                }
 359                            }
 2788360                            sourcePortRanges = array;
 2788361                            continue;
 362                        }
 13940363                        if (property0.NameEquals("destinationPortRanges"))
 364                        {
 2788365                            if (property0.Value.ValueKind == JsonValueKind.Null)
 366                            {
 367                                continue;
 368                            }
 2788369                            List<string> array = new List<string>();
 36072370                            foreach (var item in property0.Value.EnumerateArray())
 371                            {
 15248372                                if (item.ValueKind == JsonValueKind.Null)
 373                                {
 0374                                    array.Add(null);
 375                                }
 376                                else
 377                                {
 15248378                                    array.Add(item.GetString());
 379                                }
 380                            }
 2788381                            destinationPortRanges = array;
 2788382                            continue;
 383                        }
 11152384                        if (property0.NameEquals("access"))
 385                        {
 2788386                            if (property0.Value.ValueKind == JsonValueKind.Null)
 387                            {
 388                                continue;
 389                            }
 2788390                            access = new SecurityRuleAccess(property0.Value.GetString());
 2788391                            continue;
 392                        }
 8364393                        if (property0.NameEquals("priority"))
 394                        {
 2788395                            if (property0.Value.ValueKind == JsonValueKind.Null)
 396                            {
 397                                continue;
 398                            }
 2788399                            priority = property0.Value.GetInt32();
 2788400                            continue;
 401                        }
 5576402                        if (property0.NameEquals("direction"))
 403                        {
 2788404                            if (property0.Value.ValueKind == JsonValueKind.Null)
 405                            {
 406                                continue;
 407                            }
 2788408                            direction = new SecurityRuleDirection(property0.Value.GetString());
 2788409                            continue;
 410                        }
 2788411                        if (property0.NameEquals("provisioningState"))
 412                        {
 2788413                            if (property0.Value.ValueKind == JsonValueKind.Null)
 414                            {
 415                                continue;
 416                            }
 2788417                            provisioningState = new ProvisioningState(property0.Value.GetString());
 418                            continue;
 419                        }
 420                    }
 421                    continue;
 422                }
 423            }
 2788424            return new SecurityRule(id, name, etag, description, protocol, sourcePortRange, destinationPortRange, source
 425        }
 426    }
 427}