< Summary

Class:Azure.ResourceManager.Compute.Models.Snapshot
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\Snapshot.cs
C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\Snapshot.Serialization.cs
Covered lines:146
Uncovered lines:46
Coverable lines:192
Total lines:411
Line coverage:76% (146 of 192)
Covered branches:93
Total branches:118
Branch coverage:78.8% (93 of 118)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-0%0%
.ctor(...)-100%100%
get_ManagedBy()-100%100%
get_Sku()-100%100%
get_TimeCreated()-100%100%
get_OsType()-100%100%
get_HyperVGeneration()-100%100%
get_CreationData()-100%100%
get_DiskSizeGB()-100%100%
get_DiskSizeBytes()-100%100%
get_UniqueId()-100%100%
get_EncryptionSettingsCollection()-100%100%
get_ProvisioningState()-100%100%
get_Incremental()-100%100%
get_Encryption()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-49.21%55.56%
DeserializeSnapshot(...)-89.69%91.25%

File(s)

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\Snapshot.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;
 9using System.Collections.Generic;
 10
 11namespace Azure.ResourceManager.Compute.Models
 12{
 13    /// <summary> Snapshot resource. </summary>
 14    public partial class Snapshot : Resource
 15    {
 16        /// <summary> Initializes a new instance of Snapshot. </summary>
 17        /// <param name="location"> Resource location. </param>
 018        public Snapshot(string location) : base(location)
 19        {
 020            if (location == null)
 21            {
 022                throw new ArgumentNullException(nameof(location));
 23            }
 024        }
 25
 26        /// <summary> Initializes a new instance of Snapshot. </summary>
 27        /// <param name="id"> Resource Id. </param>
 28        /// <param name="name"> Resource name. </param>
 29        /// <param name="type"> Resource type. </param>
 30        /// <param name="location"> Resource location. </param>
 31        /// <param name="tags"> Resource tags. </param>
 32        /// <param name="managedBy"> Unused. Always Null. </param>
 33        /// <param name="sku"> The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. </param>
 34        /// <param name="timeCreated"> The time when the disk was created. </param>
 35        /// <param name="osType"> The Operating System type. </param>
 36        /// <param name="hyperVGeneration"> The hypervisor generation of the Virtual Machine. Applicable to OS disks onl
 37        /// <param name="creationData"> Disk source information. CreationData information cannot be changed after the di
 38        /// <param name="diskSizeGB"> If creationData.createOption is Empty, this field is mandatory and it indicates th
 39        /// <param name="diskSizeBytes"> The size of the disk in bytes. This field is read only. </param>
 40        /// <param name="uniqueId"> Unique Guid identifying the resource. </param>
 41        /// <param name="encryptionSettingsCollection"> Encryption settings collection used be Azure Disk Encryption, ca
 42        /// <param name="provisioningState"> The disk provisioning state. </param>
 43        /// <param name="incremental"> Whether a snapshot is incremental. Incremental snapshots on the same disk occupy 
 44        /// <param name="encryption"> Encryption property can be used to encrypt data at rest with customer managed keys
 11245        internal Snapshot(string id, string name, string type, string location, IDictionary<string, string> tags, string
 46        {
 11247            ManagedBy = managedBy;
 11248            Sku = sku;
 11249            TimeCreated = timeCreated;
 11250            OsType = osType;
 11251            HyperVGeneration = hyperVGeneration;
 11252            CreationData = creationData;
 11253            DiskSizeGB = diskSizeGB;
 11254            DiskSizeBytes = diskSizeBytes;
 11255            UniqueId = uniqueId;
 11256            EncryptionSettingsCollection = encryptionSettingsCollection;
 11257            ProvisioningState = provisioningState;
 11258            Incremental = incremental;
 11259            Encryption = encryption;
 11260        }
 61
 62        /// <summary> Unused. Always Null. </summary>
 8863        public string ManagedBy { get; }
 64        /// <summary> The snapshots sku name. Can be Standard_LRS, Premium_LRS, or Standard_ZRS. </summary>
 31265        public SnapshotSku Sku { get; set; }
 66        /// <summary> The time when the disk was created. </summary>
 4867        public DateTimeOffset? TimeCreated { get; }
 68        /// <summary> The Operating System type. </summary>
 20069        public OperatingSystemTypes? OsType { get; set; }
 70        /// <summary> The hypervisor generation of the Virtual Machine. Applicable to OS disks only. </summary>
 16071        public HyperVGeneration? HyperVGeneration { get; set; }
 72        /// <summary> Disk source information. CreationData information cannot be changed after the disk has been create
 35273        public CreationData CreationData { get; set; }
 74        /// <summary> If creationData.createOption is Empty, this field is mandatory and it indicates the size of the di
 20075        public int? DiskSizeGB { get; set; }
 76        /// <summary> The size of the disk in bytes. This field is read only. </summary>
 4877        public long? DiskSizeBytes { get; }
 78        /// <summary> Unique Guid identifying the resource. </summary>
 4879        public string UniqueId { get; }
 80        /// <summary> Encryption settings collection used be Azure Disk Encryption, can contain multiple encryption sett
 16081        public EncryptionSettingsCollection EncryptionSettingsCollection { get; set; }
 82        /// <summary> The disk provisioning state. </summary>
 8883        public string ProvisioningState { get; }
 84        /// <summary> Whether a snapshot is incremental. Incremental snapshots on the same disk occupy less space than f
 24885        public bool? Incremental { get; set; }
 86        /// <summary> Encryption property can be used to encrypt data at rest with customer managed keys or platform man
 16087        public Encryption Encryption { get; set; }
 88    }
 89}

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\Snapshot.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;
 9using System.Collections.Generic;
 10using System.Text.Json;
 11using Azure.Core;
 12
 13namespace Azure.ResourceManager.Compute.Models
 14{
 15    public partial class Snapshot : IUtf8JsonSerializable
 16    {
 17        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 18        {
 4819            writer.WriteStartObject();
 4820            if (ManagedBy != null)
 21            {
 022                writer.WritePropertyName("managedBy");
 023                writer.WriteStringValue(ManagedBy);
 24            }
 4825            if (Sku != null)
 26            {
 4827                writer.WritePropertyName("sku");
 4828                writer.WriteObjectValue(Sku);
 29            }
 4830            if (Id != null)
 31            {
 032                writer.WritePropertyName("id");
 033                writer.WriteStringValue(Id);
 34            }
 4835            if (Name != null)
 36            {
 037                writer.WritePropertyName("name");
 038                writer.WriteStringValue(Name);
 39            }
 4840            if (Type != null)
 41            {
 042                writer.WritePropertyName("type");
 043                writer.WriteStringValue(Type);
 44            }
 4845            writer.WritePropertyName("location");
 4846            writer.WriteStringValue(Location);
 4847            if (Tags != null)
 48            {
 049                writer.WritePropertyName("tags");
 050                writer.WriteStartObject();
 051                foreach (var item in Tags)
 52                {
 053                    writer.WritePropertyName(item.Key);
 054                    writer.WriteStringValue(item.Value);
 55                }
 056                writer.WriteEndObject();
 57            }
 4858            writer.WritePropertyName("properties");
 4859            writer.WriteStartObject();
 4860            if (TimeCreated != null)
 61            {
 062                writer.WritePropertyName("timeCreated");
 063                writer.WriteStringValue(TimeCreated.Value, "O");
 64            }
 4865            if (OsType != null)
 66            {
 067                writer.WritePropertyName("osType");
 068                writer.WriteStringValue(OsType.Value.ToSerialString());
 69            }
 4870            if (HyperVGeneration != null)
 71            {
 072                writer.WritePropertyName("hyperVGeneration");
 073                writer.WriteStringValue(HyperVGeneration.Value.ToString());
 74            }
 4875            if (CreationData != null)
 76            {
 4877                writer.WritePropertyName("creationData");
 4878                writer.WriteObjectValue(CreationData);
 79            }
 4880            if (DiskSizeGB != null)
 81            {
 082                writer.WritePropertyName("diskSizeGB");
 083                writer.WriteNumberValue(DiskSizeGB.Value);
 84            }
 4885            if (DiskSizeBytes != null)
 86            {
 087                writer.WritePropertyName("diskSizeBytes");
 088                writer.WriteNumberValue(DiskSizeBytes.Value);
 89            }
 4890            if (UniqueId != null)
 91            {
 092                writer.WritePropertyName("uniqueId");
 093                writer.WriteStringValue(UniqueId);
 94            }
 4895            if (EncryptionSettingsCollection != null)
 96            {
 097                writer.WritePropertyName("encryptionSettingsCollection");
 098                writer.WriteObjectValue(EncryptionSettingsCollection);
 99            }
 48100            if (ProvisioningState != null)
 101            {
 0102                writer.WritePropertyName("provisioningState");
 0103                writer.WriteStringValue(ProvisioningState);
 104            }
 48105            if (Incremental != null)
 106            {
 48107                writer.WritePropertyName("incremental");
 48108                writer.WriteBooleanValue(Incremental.Value);
 109            }
 48110            if (Encryption != null)
 111            {
 0112                writer.WritePropertyName("encryption");
 0113                writer.WriteObjectValue(Encryption);
 114            }
 48115            writer.WriteEndObject();
 48116            writer.WriteEndObject();
 48117        }
 118
 119        internal static Snapshot DeserializeSnapshot(JsonElement element)
 120        {
 88121            string managedBy = default;
 88122            SnapshotSku sku = default;
 88123            string id = default;
 88124            string name = default;
 88125            string type = default;
 88126            string location = default;
 88127            IDictionary<string, string> tags = default;
 88128            DateTimeOffset? timeCreated = default;
 88129            OperatingSystemTypes? osType = default;
 88130            HyperVGeneration? hyperVGeneration = default;
 88131            CreationData creationData = default;
 88132            int? diskSizeGB = default;
 88133            long? diskSizeBytes = default;
 88134            string uniqueId = default;
 88135            EncryptionSettingsCollection encryptionSettingsCollection = default;
 88136            string provisioningState = default;
 88137            bool? incremental = default;
 88138            Encryption encryption = default;
 1264139            foreach (var property in element.EnumerateObject())
 140            {
 544141                if (property.NameEquals("managedBy"))
 142                {
 0143                    if (property.Value.ValueKind == JsonValueKind.Null)
 144                    {
 145                        continue;
 146                    }
 0147                    managedBy = property.Value.GetString();
 0148                    continue;
 149                }
 544150                if (property.NameEquals("sku"))
 151                {
 88152                    if (property.Value.ValueKind == JsonValueKind.Null)
 153                    {
 154                        continue;
 155                    }
 88156                    sku = SnapshotSku.DeserializeSnapshotSku(property.Value);
 88157                    continue;
 158                }
 456159                if (property.NameEquals("id"))
 160                {
 88161                    if (property.Value.ValueKind == JsonValueKind.Null)
 162                    {
 163                        continue;
 164                    }
 88165                    id = property.Value.GetString();
 88166                    continue;
 167                }
 368168                if (property.NameEquals("name"))
 169                {
 88170                    if (property.Value.ValueKind == JsonValueKind.Null)
 171                    {
 172                        continue;
 173                    }
 88174                    name = property.Value.GetString();
 88175                    continue;
 176                }
 280177                if (property.NameEquals("type"))
 178                {
 88179                    if (property.Value.ValueKind == JsonValueKind.Null)
 180                    {
 181                        continue;
 182                    }
 88183                    type = property.Value.GetString();
 88184                    continue;
 185                }
 192186                if (property.NameEquals("location"))
 187                {
 88188                    location = property.Value.GetString();
 88189                    continue;
 190                }
 104191                if (property.NameEquals("tags"))
 192                {
 16193                    if (property.Value.ValueKind == JsonValueKind.Null)
 194                    {
 195                        continue;
 196                    }
 16197                    Dictionary<string, string> dictionary = new Dictionary<string, string>();
 64198                    foreach (var property0 in property.Value.EnumerateObject())
 199                    {
 16200                        if (property0.Value.ValueKind == JsonValueKind.Null)
 201                        {
 0202                            dictionary.Add(property0.Name, null);
 203                        }
 204                        else
 205                        {
 16206                            dictionary.Add(property0.Name, property0.Value.GetString());
 207                        }
 208                    }
 16209                    tags = dictionary;
 16210                    continue;
 211                }
 88212                if (property.NameEquals("properties"))
 213                {
 1936214                    foreach (var property0 in property.Value.EnumerateObject())
 215                    {
 880216                        if (property0.NameEquals("timeCreated"))
 217                        {
 88218                            if (property0.Value.ValueKind == JsonValueKind.Null)
 219                            {
 220                                continue;
 221                            }
 88222                            timeCreated = property0.Value.GetDateTimeOffset("O");
 88223                            continue;
 224                        }
 792225                        if (property0.NameEquals("osType"))
 226                        {
 88227                            if (property0.Value.ValueKind == JsonValueKind.Null)
 228                            {
 229                                continue;
 230                            }
 88231                            osType = property0.Value.GetString().ToOperatingSystemTypes();
 88232                            continue;
 233                        }
 704234                        if (property0.NameEquals("hyperVGeneration"))
 235                        {
 0236                            if (property0.Value.ValueKind == JsonValueKind.Null)
 237                            {
 238                                continue;
 239                            }
 0240                            hyperVGeneration = new HyperVGeneration(property0.Value.GetString());
 0241                            continue;
 242                        }
 704243                        if (property0.NameEquals("creationData"))
 244                        {
 88245                            if (property0.Value.ValueKind == JsonValueKind.Null)
 246                            {
 247                                continue;
 248                            }
 88249                            creationData = CreationData.DeserializeCreationData(property0.Value);
 88250                            continue;
 251                        }
 616252                        if (property0.NameEquals("diskSizeGB"))
 253                        {
 88254                            if (property0.Value.ValueKind == JsonValueKind.Null)
 255                            {
 256                                continue;
 257                            }
 88258                            diskSizeGB = property0.Value.GetInt32();
 88259                            continue;
 260                        }
 528261                        if (property0.NameEquals("diskSizeBytes"))
 262                        {
 88263                            if (property0.Value.ValueKind == JsonValueKind.Null)
 264                            {
 265                                continue;
 266                            }
 88267                            diskSizeBytes = property0.Value.GetInt64();
 88268                            continue;
 269                        }
 440270                        if (property0.NameEquals("uniqueId"))
 271                        {
 88272                            if (property0.Value.ValueKind == JsonValueKind.Null)
 273                            {
 274                                continue;
 275                            }
 88276                            uniqueId = property0.Value.GetString();
 88277                            continue;
 278                        }
 352279                        if (property0.NameEquals("encryptionSettingsCollection"))
 280                        {
 0281                            if (property0.Value.ValueKind == JsonValueKind.Null)
 282                            {
 283                                continue;
 284                            }
 0285                            encryptionSettingsCollection = EncryptionSettingsCollection.DeserializeEncryptionSettingsCol
 0286                            continue;
 287                        }
 352288                        if (property0.NameEquals("provisioningState"))
 289                        {
 88290                            if (property0.Value.ValueKind == JsonValueKind.Null)
 291                            {
 292                                continue;
 293                            }
 88294                            provisioningState = property0.Value.GetString();
 88295                            continue;
 296                        }
 264297                        if (property0.NameEquals("incremental"))
 298                        {
 88299                            if (property0.Value.ValueKind == JsonValueKind.Null)
 300                            {
 301                                continue;
 302                            }
 88303                            incremental = property0.Value.GetBoolean();
 88304                            continue;
 305                        }
 176306                        if (property0.NameEquals("encryption"))
 307                        {
 88308                            if (property0.Value.ValueKind == JsonValueKind.Null)
 309                            {
 310                                continue;
 311                            }
 88312                            encryption = Encryption.DeserializeEncryption(property0.Value);
 313                            continue;
 314                        }
 315                    }
 316                    continue;
 317                }
 318            }
 88319            return new Snapshot(id, name, type, location, tags, managedBy, sku, timeCreated, osType, hyperVGeneration, c
 320        }
 321    }
 322}