< Summary

Class:Azure.ResourceManager.Resources.Models.PolicyDefinition
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyDefinition.cs
C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyDefinition.Serialization.cs
Covered lines:113
Uncovered lines:9
Coverable lines:122
Total lines:274
Line coverage:92.6% (113 of 122)
Covered branches:67
Total branches:72
Branch coverage:93% (67 of 72)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_Id()-100%100%
get_Name()-100%100%
get_Type()-100%100%
get_PolicyType()-100%100%
get_Mode()-100%100%
get_DisplayName()-100%100%
get_Description()-100%100%
get_PolicyRule()-100%100%
get_Metadata()-100%100%
get_Parameters()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-80%81.82%
DeserializePolicyDefinition(...)-98.28%98%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyDefinition.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 definition. </summary>
 13    public partial class PolicyDefinition
 14    {
 15        /// <summary> Initializes a new instance of PolicyDefinition. </summary>
 5616        public PolicyDefinition()
 17        {
 5618        }
 19
 20        /// <summary> Initializes a new instance of PolicyDefinition. </summary>
 21        /// <param name="id"> The ID of the policy definition. </param>
 22        /// <param name="name"> The name of the policy definition. </param>
 23        /// <param name="type"> The type of the resource (Microsoft.Authorization/policyDefinitions). </param>
 24        /// <param name="policyType"> The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, 
 25        /// <param name="mode"> The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. </p
 26        /// <param name="displayName"> The display name of the policy definition. </param>
 27        /// <param name="description"> The policy definition description. </param>
 28        /// <param name="policyRule"> The policy rule. </param>
 29        /// <param name="metadata"> The policy definition metadata.  Metadata is an open ended object and is typically a
 30        /// <param name="parameters"> The parameter definitions for parameters used in the policy rule. The keys are the
 8153231        internal PolicyDefinition(string id, string name, string type, PolicyType? policyType, string mode, string displ
 32        {
 8153233            Id = id;
 8153234            Name = name;
 8153235            Type = type;
 8153236            PolicyType = policyType;
 8153237            Mode = mode;
 8153238            DisplayName = displayName;
 8153239            Description = description;
 8153240            PolicyRule = policyRule;
 8153241            Metadata = metadata;
 8153242            Parameters = parameters;
 8153243        }
 44
 45        /// <summary> The ID of the policy definition. </summary>
 3632446        public string Id { get; }
 47        /// <summary> The name of the policy definition. </summary>
 10826448        public string Name { get; }
 49        /// <summary> The type of the resource (Microsoft.Authorization/policyDefinitions). </summary>
 4951250        public string Type { get; }
 51        /// <summary> The type of policy definition. Possible values are NotSpecified, BuiltIn, Custom, and Static. </su
 12363252        public PolicyType? PolicyType { get; set; }
 53        /// <summary> The policy definition mode. Some examples are All, Indexed, Microsoft.KeyVault.Data. </summary>
 15428054        public string Mode { get; set; }
 55        /// <summary> The display name of the policy definition. </summary>
 11800056        public string DisplayName { get; set; }
 57        /// <summary> The policy definition description. </summary>
 11782458        public string Description { get; set; }
 59        /// <summary> The policy rule. </summary>
 11798060        public object PolicyRule { get; set; }
 61        /// <summary> The policy definition metadata.  Metadata is an open ended object and is typically a collection of
 9138462        public object Metadata { get; set; }
 63        /// <summary> The parameter definitions for parameters used in the policy rule. The keys are the parameter names
 9144064        public IDictionary<string, ParameterDefinitionsValue> Parameters { get; set; }
 65    }
 66}

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyDefinition.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 PolicyDefinition : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 6818            writer.WriteStartObject();
 6819            if (Id != null)
 20            {
 021                writer.WritePropertyName("id");
 022                writer.WriteStringValue(Id);
 23            }
 6824            if (Name != null)
 25            {
 026                writer.WritePropertyName("name");
 027                writer.WriteStringValue(Name);
 28            }
 6829            if (Type != null)
 30            {
 031                writer.WritePropertyName("type");
 032                writer.WriteStringValue(Type);
 33            }
 6834            writer.WritePropertyName("properties");
 6835            writer.WriteStartObject();
 6836            if (PolicyType != null)
 37            {
 038                writer.WritePropertyName("policyType");
 039                writer.WriteStringValue(PolicyType.Value.ToString());
 40            }
 6841            if (Mode != null)
 42            {
 1643                writer.WritePropertyName("mode");
 1644                writer.WriteStringValue(Mode);
 45            }
 6846            if (DisplayName != null)
 47            {
 6848                writer.WritePropertyName("displayName");
 6849                writer.WriteStringValue(DisplayName);
 50            }
 6851            if (Description != null)
 52            {
 453                writer.WritePropertyName("description");
 454                writer.WriteStringValue(Description);
 55            }
 6856            if (PolicyRule != null)
 57            {
 6458                writer.WritePropertyName("policyRule");
 6459                writer.WriteObjectValue(PolicyRule);
 60            }
 6861            if (Metadata != null)
 62            {
 463                writer.WritePropertyName("metadata");
 464                writer.WriteObjectValue(Metadata);
 65            }
 6866            if (Parameters != null)
 67            {
 1268                writer.WritePropertyName("parameters");
 1269                writer.WriteStartObject();
 4870                foreach (var item in Parameters)
 71                {
 1272                    writer.WritePropertyName(item.Key);
 1273                    writer.WriteObjectValue(item.Value);
 74                }
 1275                writer.WriteEndObject();
 76            }
 6877            writer.WriteEndObject();
 6878            writer.WriteEndObject();
 6879        }
 80
 81        internal static PolicyDefinition DeserializePolicyDefinition(JsonElement element)
 82        {
 8153283            string id = default;
 8153284            string name = default;
 8153285            string type = default;
 8153286            PolicyType? policyType = default;
 8153287            string mode = default;
 8153288            string displayName = default;
 8153289            string description = default;
 8153290            object policyRule = default;
 8153291            object metadata = default;
 8153292            IDictionary<string, ParameterDefinitionsValue> parameters = default;
 81532093            foreach (var property in element.EnumerateObject())
 94            {
 32612895                if (property.NameEquals("id"))
 96                {
 8153297                    if (property.Value.ValueKind == JsonValueKind.Null)
 98                    {
 99                        continue;
 100                    }
 81532101                    id = property.Value.GetString();
 81532102                    continue;
 103                }
 244596104                if (property.NameEquals("name"))
 105                {
 81532106                    if (property.Value.ValueKind == JsonValueKind.Null)
 107                    {
 108                        continue;
 109                    }
 81532110                    name = property.Value.GetString();
 81532111                    continue;
 112                }
 163064113                if (property.NameEquals("type"))
 114                {
 81532115                    if (property.Value.ValueKind == JsonValueKind.Null)
 116                    {
 117                        continue;
 118                    }
 81532119                    type = property.Value.GetString();
 81532120                    continue;
 121                }
 81532122                if (property.NameEquals("properties"))
 123                {
 1198120124                    foreach (var property0 in property.Value.EnumerateObject())
 125                    {
 517528126                        if (property0.NameEquals("policyType"))
 127                        {
 81532128                            if (property0.Value.ValueKind == JsonValueKind.Null)
 129                            {
 130                                continue;
 131                            }
 81532132                            policyType = new PolicyType(property0.Value.GetString());
 81532133                            continue;
 134                        }
 435996135                        if (property0.NameEquals("mode"))
 136                        {
 81532137                            if (property0.Value.ValueKind == JsonValueKind.Null)
 138                            {
 139                                continue;
 140                            }
 81532141                            mode = property0.Value.GetString();
 81532142                            continue;
 143                        }
 354464144                        if (property0.NameEquals("displayName"))
 145                        {
 81444146                            if (property0.Value.ValueKind == JsonValueKind.Null)
 147                            {
 148                                continue;
 149                            }
 81444150                            displayName = property0.Value.GetString();
 81444151                            continue;
 152                        }
 273020153                        if (property0.NameEquals("description"))
 154                        {
 81368155                            if (property0.Value.ValueKind == JsonValueKind.Null)
 156                            {
 157                                continue;
 158                            }
 81368159                            description = property0.Value.GetString();
 81368160                            continue;
 161                        }
 191652162                        if (property0.NameEquals("policyRule"))
 163                        {
 81532164                            if (property0.Value.ValueKind == JsonValueKind.Null)
 165                            {
 166                                continue;
 167                            }
 81532168                            policyRule = property0.Value.GetObject();
 81532169                            continue;
 170                        }
 110120171                        if (property0.NameEquals("metadata"))
 172                        {
 81532173                            if (property0.Value.ValueKind == JsonValueKind.Null)
 174                            {
 175                                continue;
 176                            }
 81532177                            metadata = property0.Value.GetObject();
 81532178                            continue;
 179                        }
 28588180                        if (property0.NameEquals("parameters"))
 181                        {
 28588182                            if (property0.Value.ValueKind == JsonValueKind.Null)
 183                            {
 184                                continue;
 185                            }
 28588186                            Dictionary<string, ParameterDefinitionsValue> dictionary = new Dictionary<string, ParameterD
 149392187                            foreach (var property1 in property0.Value.EnumerateObject())
 188                            {
 46108189                                if (property1.Value.ValueKind == JsonValueKind.Null)
 190                                {
 0191                                    dictionary.Add(property1.Name, null);
 192                                }
 193                                else
 194                                {
 46108195                                    dictionary.Add(property1.Name, ParameterDefinitionsValue.DeserializeParameterDefinit
 196                                }
 197                            }
 28588198                            parameters = dictionary;
 199                            continue;
 200                        }
 201                    }
 202                    continue;
 203                }
 204            }
 81532205            return new PolicyDefinition(id, name, type, policyType, mode, displayName, description, policyRule, metadata
 206        }
 207    }
 208}