< Summary

Class:Azure.ResourceManager.Storage.Models.ImmutabilityPolicy
Assembly:Azure.ResourceManager.Storage
File(s):C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\ImmutabilityPolicy.cs
C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\ImmutabilityPolicy.Serialization.cs
Covered lines:65
Uncovered lines:10
Coverable lines:75
Total lines:184
Line coverage:86.6% (65 of 75)
Covered branches:43
Total branches:48
Branch coverage:89.5% (43 of 48)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_ImmutabilityPeriodSinceCreationInDays()-100%100%
get_State()-100%100%
get_AllowProtectedAppendWrites()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-62.96%64.29%
DeserializeImmutabilityPolicy(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\ImmutabilityPolicy.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
 8namespace Azure.ResourceManager.Storage.Models
 9{
 10    /// <summary> The ImmutabilityPolicy property of a blob container, including Id, resource name, resource type, Etag.
 11    public partial class ImmutabilityPolicy : AzureEntityResource
 12    {
 13        /// <summary> Initializes a new instance of ImmutabilityPolicy. </summary>
 2414        public ImmutabilityPolicy()
 15        {
 2416        }
 17
 18        /// <summary> Initializes a new instance of ImmutabilityPolicy. </summary>
 19        /// <param name="id"> Fully qualified resource Id for the resource. Ex - /subscriptions/{subscriptionId}/resourc
 20        /// <param name="name"> The name of the resource. </param>
 21        /// <param name="type"> The type of the resource. Ex- Microsoft.Compute/virtualMachines or Microsoft.Storage/sto
 22        /// <param name="etag"> Resource Etag. </param>
 23        /// <param name="immutabilityPeriodSinceCreationInDays"> The immutability period for the blobs in the container 
 24        /// <param name="state"> The ImmutabilityPolicy state of a blob container, possible values include: Locked and U
 25        /// <param name="allowProtectedAppendWrites"> This property can only be changed for unlocked time-based retentio
 6426        internal ImmutabilityPolicy(string id, string name, string type, string etag, int? immutabilityPeriodSinceCreati
 27        {
 6428            ImmutabilityPeriodSinceCreationInDays = immutabilityPeriodSinceCreationInDays;
 6429            State = state;
 6430            AllowProtectedAppendWrites = allowProtectedAppendWrites;
 6431        }
 32
 33        /// <summary> The immutability period for the blobs in the container since the policy creation, in days. </summa
 24834        public int? ImmutabilityPeriodSinceCreationInDays { get; set; }
 35        /// <summary> The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. </
 10436        public ImmutabilityPolicyState? State { get; }
 37        /// <summary> This property can only be changed for unlocked time-based retention policies. When enabled, new bl
 13238        public bool? AllowProtectedAppendWrites { get; set; }
 39    }
 40}

C:\Git\azure-sdk-for-net\sdk\storage\Azure.ResourceManager.Storage\src\Generated\Models\ImmutabilityPolicy.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.Text.Json;
 9using Azure.Core;
 10
 11namespace Azure.ResourceManager.Storage.Models
 12{
 13    public partial class ImmutabilityPolicy : IUtf8JsonSerializable
 14    {
 15        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 16        {
 4017            writer.WriteStartObject();
 4018            if (Etag != null)
 19            {
 020                writer.WritePropertyName("etag");
 021                writer.WriteStringValue(Etag);
 22            }
 4023            if (Id != null)
 24            {
 025                writer.WritePropertyName("id");
 026                writer.WriteStringValue(Id);
 27            }
 4028            if (Name != null)
 29            {
 030                writer.WritePropertyName("name");
 031                writer.WriteStringValue(Name);
 32            }
 4033            if (Type != null)
 34            {
 035                writer.WritePropertyName("type");
 036                writer.WriteStringValue(Type);
 37            }
 4038            writer.WritePropertyName("properties");
 4039            writer.WriteStartObject();
 4040            if (ImmutabilityPeriodSinceCreationInDays != null)
 41            {
 4042                writer.WritePropertyName("immutabilityPeriodSinceCreationInDays");
 4043                writer.WriteNumberValue(ImmutabilityPeriodSinceCreationInDays.Value);
 44            }
 4045            if (State != null)
 46            {
 047                writer.WritePropertyName("state");
 048                writer.WriteStringValue(State.Value.ToString());
 49            }
 4050            if (AllowProtectedAppendWrites != null)
 51            {
 852                writer.WritePropertyName("allowProtectedAppendWrites");
 853                writer.WriteBooleanValue(AllowProtectedAppendWrites.Value);
 54            }
 4055            writer.WriteEndObject();
 4056            writer.WriteEndObject();
 4057        }
 58
 59        internal static ImmutabilityPolicy DeserializeImmutabilityPolicy(JsonElement element)
 60        {
 6461            string etag = default;
 6462            string id = default;
 6463            string name = default;
 6464            string type = default;
 6465            int? immutabilityPeriodSinceCreationInDays = default;
 6466            ImmutabilityPolicyState? state = default;
 6467            bool? allowProtectedAppendWrites = default;
 76868            foreach (var property in element.EnumerateObject())
 69            {
 32070                if (property.NameEquals("etag"))
 71                {
 6472                    if (property.Value.ValueKind == JsonValueKind.Null)
 73                    {
 74                        continue;
 75                    }
 6476                    etag = property.Value.GetString();
 6477                    continue;
 78                }
 25679                if (property.NameEquals("id"))
 80                {
 6481                    if (property.Value.ValueKind == JsonValueKind.Null)
 82                    {
 83                        continue;
 84                    }
 6485                    id = property.Value.GetString();
 6486                    continue;
 87                }
 19288                if (property.NameEquals("name"))
 89                {
 6490                    if (property.Value.ValueKind == JsonValueKind.Null)
 91                    {
 92                        continue;
 93                    }
 6494                    name = property.Value.GetString();
 6495                    continue;
 96                }
 12897                if (property.NameEquals("type"))
 98                {
 6499                    if (property.Value.ValueKind == JsonValueKind.Null)
 100                    {
 101                        continue;
 102                    }
 64103                    type = property.Value.GetString();
 64104                    continue;
 105                }
 64106                if (property.NameEquals("properties"))
 107                {
 408108                    foreach (var property0 in property.Value.EnumerateObject())
 109                    {
 140110                        if (property0.NameEquals("immutabilityPeriodSinceCreationInDays"))
 111                        {
 64112                            if (property0.Value.ValueKind == JsonValueKind.Null)
 113                            {
 114                                continue;
 115                            }
 64116                            immutabilityPeriodSinceCreationInDays = property0.Value.GetInt32();
 64117                            continue;
 118                        }
 76119                        if (property0.NameEquals("state"))
 120                        {
 64121                            if (property0.Value.ValueKind == JsonValueKind.Null)
 122                            {
 123                                continue;
 124                            }
 64125                            state = new ImmutabilityPolicyState(property0.Value.GetString());
 64126                            continue;
 127                        }
 12128                        if (property0.NameEquals("allowProtectedAppendWrites"))
 129                        {
 12130                            if (property0.Value.ValueKind == JsonValueKind.Null)
 131                            {
 132                                continue;
 133                            }
 12134                            allowProtectedAppendWrites = property0.Value.GetBoolean();
 135                            continue;
 136                        }
 137                    }
 138                    continue;
 139                }
 140            }
 64141            return new ImmutabilityPolicy(id, name, type, etag, immutabilityPeriodSinceCreationInDays, state, allowProte
 142        }
 143    }
 144}