< Summary

Class:Azure.ResourceManager.Resources.Models.PolicyAssignment
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyAssignment.cs
C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyAssignment.Serialization.cs
Covered lines:137
Uncovered lines:33
Coverable lines:170
Total lines:367
Line coverage:80.5% (137 of 170)
Covered branches:81
Total branches:102
Branch coverage:79.4% (81 of 102)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_Id()-100%100%
get_Type()-100%100%
get_Name()-100%100%
get_Sku()-100%100%
get_Location()-100%100%
get_Identity()-100%100%
get_DisplayName()-100%100%
get_PolicyDefinitionId()-100%100%
get_Scope()-100%100%
get_NotScopes()-100%100%
get_Parameters()-100%100%
get_Description()-100%100%
get_Metadata()-100%100%
get_EnforcementMode()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-69.09%71.88%
DeserializePolicyAssignment(...)-80.72%82.86%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyAssignment.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.Resources.Models
 11{
 12    /// <summary> The policy assignment. </summary>
 13    public partial class PolicyAssignment
 14    {
 15        /// <summary> Initializes a new instance of PolicyAssignment. </summary>
 2416        public PolicyAssignment()
 17        {
 2418        }
 19
 20        /// <summary> Initializes a new instance of PolicyAssignment. </summary>
 21        /// <param name="id"> The ID of the policy assignment. </param>
 22        /// <param name="type"> The type of the policy assignment. </param>
 23        /// <param name="name"> The name of the policy assignment. </param>
 24        /// <param name="sku"> The policy sku. This property is optional, obsolete, and will be ignored. </param>
 25        /// <param name="location"> The location of the policy assignment. Only required when utilizing managed identity
 26        /// <param name="identity"> The managed identity associated with the policy assignment. </param>
 27        /// <param name="displayName"> The display name of the policy assignment. </param>
 28        /// <param name="policyDefinitionId"> The ID of the policy definition or policy set definition being assigned. <
 29        /// <param name="scope"> The scope for the policy assignment. </param>
 30        /// <param name="notScopes"> The policy&apos;s excluded scopes. </param>
 31        /// <param name="parameters"> The parameter values for the assigned policy rule. The keys are the parameter name
 32        /// <param name="description"> This message will be part of response in case of policy violation. </param>
 33        /// <param name="metadata"> The policy assignment metadata. Metadata is an open ended object and is typically a 
 34        /// <param name="enforcementMode"> The policy assignment enforcement mode. Possible values are Default and DoNot
 8835        internal PolicyAssignment(string id, string type, string name, PolicySku sku, string location, IdentityAutoGener
 36        {
 8837            Id = id;
 8838            Type = type;
 8839            Name = name;
 8840            Sku = sku;
 8841            Location = location;
 8842            Identity = identity;
 8843            DisplayName = displayName;
 8844            PolicyDefinitionId = policyDefinitionId;
 8845            Scope = scope;
 8846            NotScopes = notScopes;
 8847            Parameters = parameters;
 8848            Description = description;
 8849            Metadata = metadata;
 8850            EnforcementMode = enforcementMode;
 8851        }
 52
 53        /// <summary> The ID of the policy assignment. </summary>
 5654        public string Id { get; }
 55        /// <summary> The type of the policy assignment. </summary>
 4856        public string Type { get; }
 57        /// <summary> The name of the policy assignment. </summary>
 9258        public string Name { get; }
 59        /// <summary> The policy sku. This property is optional, obsolete, and will be ignored. </summary>
 26060        public PolicySku Sku { get; set; }
 61        /// <summary> The location of the policy assignment. Only required when utilizing managed identity. </summary>
 18062        public string Location { get; set; }
 63        /// <summary> The managed identity associated with the policy assignment. </summary>
 23664        public IdentityAutoGenerated Identity { get; set; }
 65        /// <summary> The display name of the policy assignment. </summary>
 23266        public string DisplayName { get; set; }
 67        /// <summary> The ID of the policy definition or policy set definition being assigned. </summary>
 21668        public string PolicyDefinitionId { get; set; }
 69        /// <summary> The scope for the policy assignment. </summary>
 15270        public string Scope { get; set; }
 71        /// <summary> The policy&apos;s excluded scopes. </summary>
 14072        public IList<string> NotScopes { get; set; }
 73        /// <summary> The parameter values for the assigned policy rule. The keys are the parameter names. </summary>
 17274        public IDictionary<string, ParameterValuesValue> Parameters { get; set; }
 75        /// <summary> This message will be part of response in case of policy violation. </summary>
 18476        public string Description { get; set; }
 77        /// <summary> The policy assignment metadata. Metadata is an open ended object and is typically a collection of 
 16878        public object Metadata { get; set; }
 79        /// <summary> The policy assignment enforcement mode. Possible values are Default and DoNotEnforce. </summary>
 17280        public EnforcementMode? EnforcementMode { get; set; }
 81    }
 82}

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyAssignment.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.Resources.Models
 13{
 14    public partial class PolicyAssignment : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 3218            writer.WriteStartObject();
 3219            if (Id != null)
 20            {
 021                writer.WritePropertyName("id");
 022                writer.WriteStringValue(Id);
 23            }
 3224            if (Type != null)
 25            {
 026                writer.WritePropertyName("type");
 027                writer.WriteStringValue(Type);
 28            }
 3229            if (Name != null)
 30            {
 031                writer.WritePropertyName("name");
 032                writer.WriteStringValue(Name);
 33            }
 3234            if (Sku != null)
 35            {
 3236                writer.WritePropertyName("sku");
 3237                writer.WriteObjectValue(Sku);
 38            }
 3239            if (Location != null)
 40            {
 841                writer.WritePropertyName("location");
 842                writer.WriteStringValue(Location);
 43            }
 3244            if (Identity != null)
 45            {
 846                writer.WritePropertyName("identity");
 847                writer.WriteObjectValue(Identity);
 48            }
 3249            writer.WritePropertyName("properties");
 3250            writer.WriteStartObject();
 3251            if (DisplayName != null)
 52            {
 3253                writer.WritePropertyName("displayName");
 3254                writer.WriteStringValue(DisplayName);
 55            }
 3256            if (PolicyDefinitionId != null)
 57            {
 2858                writer.WritePropertyName("policyDefinitionId");
 2859                writer.WriteStringValue(PolicyDefinitionId);
 60            }
 3261            if (Scope != null)
 62            {
 863                writer.WritePropertyName("scope");
 864                writer.WriteStringValue(Scope);
 65            }
 3266            if (NotScopes != null)
 67            {
 068                writer.WritePropertyName("notScopes");
 069                writer.WriteStartArray();
 070                foreach (var item in NotScopes)
 71                {
 072                    writer.WriteStringValue(item);
 73                }
 074                writer.WriteEndArray();
 75            }
 3276            if (Parameters != null)
 77            {
 078                writer.WritePropertyName("parameters");
 079                writer.WriteStartObject();
 080                foreach (var item in Parameters)
 81                {
 082                    writer.WritePropertyName(item.Key);
 083                    writer.WriteObjectValue(item.Value);
 84                }
 085                writer.WriteEndObject();
 86            }
 3287            if (Description != null)
 88            {
 889                writer.WritePropertyName("description");
 890                writer.WriteStringValue(Description);
 91            }
 3292            if (Metadata != null)
 93            {
 894                writer.WritePropertyName("metadata");
 895                writer.WriteObjectValue(Metadata);
 96            }
 3297            if (EnforcementMode != null)
 98            {
 899                writer.WritePropertyName("enforcementMode");
 8100                writer.WriteStringValue(EnforcementMode.Value.ToString());
 101            }
 32102            writer.WriteEndObject();
 32103            writer.WriteEndObject();
 32104        }
 105
 106        internal static PolicyAssignment DeserializePolicyAssignment(JsonElement element)
 107        {
 88108            string id = default;
 88109            string type = default;
 88110            string name = default;
 88111            PolicySku sku = default;
 88112            string location = default;
 88113            IdentityAutoGenerated identity = default;
 88114            string displayName = default;
 88115            string policyDefinitionId = default;
 88116            string scope = default;
 88117            IList<string> notScopes = default;
 88118            IDictionary<string, ParameterValuesValue> parameters = default;
 88119            string description = default;
 88120            object metadata = default;
 88121            EnforcementMode? enforcementMode = default;
 1152122            foreach (var property in element.EnumerateObject())
 123            {
 488124                if (property.NameEquals("id"))
 125                {
 88126                    if (property.Value.ValueKind == JsonValueKind.Null)
 127                    {
 128                        continue;
 129                    }
 88130                    id = property.Value.GetString();
 88131                    continue;
 132                }
 400133                if (property.NameEquals("type"))
 134                {
 88135                    if (property.Value.ValueKind == JsonValueKind.Null)
 136                    {
 137                        continue;
 138                    }
 88139                    type = property.Value.GetString();
 88140                    continue;
 141                }
 312142                if (property.NameEquals("name"))
 143                {
 88144                    if (property.Value.ValueKind == JsonValueKind.Null)
 145                    {
 146                        continue;
 147                    }
 88148                    name = property.Value.GetString();
 88149                    continue;
 150                }
 224151                if (property.NameEquals("sku"))
 152                {
 88153                    if (property.Value.ValueKind == JsonValueKind.Null)
 154                    {
 155                        continue;
 156                    }
 88157                    sku = PolicySku.DeserializePolicySku(property.Value);
 88158                    continue;
 159                }
 136160                if (property.NameEquals("location"))
 161                {
 24162                    if (property.Value.ValueKind == JsonValueKind.Null)
 163                    {
 164                        continue;
 165                    }
 24166                    location = property.Value.GetString();
 24167                    continue;
 168                }
 112169                if (property.NameEquals("identity"))
 170                {
 24171                    if (property.Value.ValueKind == JsonValueKind.Null)
 172                    {
 173                        continue;
 174                    }
 24175                    identity = IdentityAutoGenerated.DeserializeIdentityAutoGenerated(property.Value);
 24176                    continue;
 177                }
 88178                if (property.NameEquals("properties"))
 179                {
 1064180                    foreach (var property0 in property.Value.EnumerateObject())
 181                    {
 444182                        if (property0.NameEquals("displayName"))
 183                        {
 68184                            if (property0.Value.ValueKind == JsonValueKind.Null)
 185                            {
 186                                continue;
 187                            }
 68188                            displayName = property0.Value.GetString();
 68189                            continue;
 190                        }
 376191                        if (property0.NameEquals("policyDefinitionId"))
 192                        {
 88193                            if (property0.Value.ValueKind == JsonValueKind.Null)
 194                            {
 195                                continue;
 196                            }
 88197                            policyDefinitionId = property0.Value.GetString();
 88198                            continue;
 199                        }
 288200                        if (property0.NameEquals("scope"))
 201                        {
 88202                            if (property0.Value.ValueKind == JsonValueKind.Null)
 203                            {
 204                                continue;
 205                            }
 88206                            scope = property0.Value.GetString();
 88207                            continue;
 208                        }
 200209                        if (property0.NameEquals("notScopes"))
 210                        {
 0211                            if (property0.Value.ValueKind == JsonValueKind.Null)
 212                            {
 213                                continue;
 214                            }
 0215                            List<string> array = new List<string>();
 0216                            foreach (var item in property0.Value.EnumerateArray())
 217                            {
 0218                                if (item.ValueKind == JsonValueKind.Null)
 219                                {
 0220                                    array.Add(null);
 221                                }
 222                                else
 223                                {
 0224                                    array.Add(item.GetString());
 225                                }
 226                            }
 0227                            notScopes = array;
 0228                            continue;
 229                        }
 200230                        if (property0.NameEquals("parameters"))
 231                        {
 0232                            if (property0.Value.ValueKind == JsonValueKind.Null)
 233                            {
 234                                continue;
 235                            }
 0236                            Dictionary<string, ParameterValuesValue> dictionary = new Dictionary<string, ParameterValues
 0237                            foreach (var property1 in property0.Value.EnumerateObject())
 238                            {
 0239                                if (property1.Value.ValueKind == JsonValueKind.Null)
 240                                {
 0241                                    dictionary.Add(property1.Name, null);
 242                                }
 243                                else
 244                                {
 0245                                    dictionary.Add(property1.Name, ParameterValuesValue.DeserializeParameterValuesValue(
 246                                }
 247                            }
 0248                            parameters = dictionary;
 0249                            continue;
 250                        }
 200251                        if (property0.NameEquals("description"))
 252                        {
 24253                            if (property0.Value.ValueKind == JsonValueKind.Null)
 254                            {
 255                                continue;
 256                            }
 24257                            description = property0.Value.GetString();
 24258                            continue;
 259                        }
 176260                        if (property0.NameEquals("metadata"))
 261                        {
 88262                            if (property0.Value.ValueKind == JsonValueKind.Null)
 263                            {
 264                                continue;
 265                            }
 88266                            metadata = property0.Value.GetObject();
 88267                            continue;
 268                        }
 88269                        if (property0.NameEquals("enforcementMode"))
 270                        {
 88271                            if (property0.Value.ValueKind == JsonValueKind.Null)
 272                            {
 273                                continue;
 274                            }
 88275                            enforcementMode = new EnforcementMode(property0.Value.GetString());
 276                            continue;
 277                        }
 278                    }
 279                    continue;
 280                }
 281            }
 88282            return new PolicyAssignment(id, type, name, sku, location, identity, displayName, policyDefinitionId, scope,
 283        }
 284    }
 285}