Beispiel #1
0
 internal DiskData(ResourceIdentifier id, string name, ResourceType type, IDictionary <string, string> tags, AzureLocation location, string managedBy, IReadOnlyList <string> managedByExtended, DiskSku sku, IList <string> zones, ExtendedLocation extendedLocation, DateTimeOffset?timeCreated, OperatingSystemTypes?osType, HyperVGeneration?hyperVGeneration, PurchasePlanAutoGenerated purchasePlan, CreationData creationData, int?diskSizeGB, long?diskSizeBytes, string uniqueId, EncryptionSettingsCollection encryptionSettingsCollection, string provisioningState, long?diskIopsReadWrite, long?diskMBpsReadWrite, long?diskIopsReadOnly, long?diskMBpsReadOnly, DiskState?diskState, Encryption encryption, int?maxShares, IReadOnlyList <ShareInfoElement> shareInfo, NetworkAccessPolicy?networkAccessPolicy, string diskAccessId, string tier, bool?burstingEnabled, PropertyUpdatesInProgress propertyUpdatesInProgress, bool?supportsHibernation, DiskSecurityProfile securityProfile) : base(id, name, type, tags, location)
 {
     ManagedBy         = managedBy;
     ManagedByExtended = managedByExtended;
     Sku                          = sku;
     Zones                        = zones;
     ExtendedLocation             = extendedLocation;
     TimeCreated                  = timeCreated;
     OsType                       = osType;
     HyperVGeneration             = hyperVGeneration;
     PurchasePlan                 = purchasePlan;
     CreationData                 = creationData;
     DiskSizeGB                   = diskSizeGB;
     DiskSizeBytes                = diskSizeBytes;
     UniqueId                     = uniqueId;
     EncryptionSettingsCollection = encryptionSettingsCollection;
     ProvisioningState            = provisioningState;
     DiskIopsReadWrite            = diskIopsReadWrite;
     DiskMBpsReadWrite            = diskMBpsReadWrite;
     DiskIopsReadOnly             = diskIopsReadOnly;
     DiskMBpsReadOnly             = diskMBpsReadOnly;
     DiskState                    = diskState;
     Encryption                   = encryption;
     MaxShares                    = maxShares;
     ShareInfo                    = shareInfo;
     NetworkAccessPolicy          = networkAccessPolicy;
     DiskAccessId                 = diskAccessId;
     Tier                         = tier;
     BurstingEnabled              = burstingEnabled;
     PropertyUpdatesInProgress    = propertyUpdatesInProgress;
     SupportsHibernation          = supportsHibernation;
     SecurityProfile              = securityProfile;
 }
Beispiel #2
0
        private void Run()
        {
            // EncryptionSettings
            EncryptionSettings vEncryptionSettings = null;

            // Sku
            DiskSku vSku = null;

            if (this.MyInvocation.BoundParameters.ContainsKey("EncryptionSettingsEnabled"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new EncryptionSettings();
                }
                vEncryptionSettings.Enabled = this.EncryptionSettingsEnabled;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("DiskEncryptionKey"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new EncryptionSettings();
                }
                vEncryptionSettings.DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("KeyEncryptionKey"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new EncryptionSettings();
                }
                vEncryptionSettings.KeyEncryptionKey = this.KeyEncryptionKey;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SkuName"))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            var vDiskUpdate = new PSDiskUpdate
            {
                OsType            = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB        = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.MyInvocation.BoundParameters.ContainsKey("DiskIOPSReadWrite") ? this.DiskIOPSReadWrite : (int?)null,
                DiskMBpsReadWrite = this.MyInvocation.BoundParameters.ContainsKey("DiskMBpsReadWrite") ? this.DiskMBpsReadWrite : (int?)null,
                Tags = this.MyInvocation.BoundParameters.ContainsKey("Tag") ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                EncryptionSettings = vEncryptionSettings,
                Sku = vSku,
            };

            WriteObject(vDiskUpdate);
        }
        private PSDisk CreateDiskConfig(long fixedSizeLength)
        {
            // Sku
            DiskSku vSku = null;

            // CreationData
            CreationData vCreationData = null;

            if (this.IsParameterBound(c => c.DiskSku))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.DiskSku;
            }

            vCreationData = new CreationData();
            vCreationData.CreateOption    = "upload";
            vCreationData.UploadSizeBytes = fixedSizeLength;

            var vDisk = new PSDisk
            {
                Zones             = this.IsParameterBound(c => c.DiskZone) ? this.DiskZone : null,
                OsType            = this.IsParameterBound(c => c.DiskOsType) ? this.DiskOsType : OperatingSystemTypes.Windows,
                HyperVGeneration  = this.IsParameterBound(c => c.DiskHyperVGeneration) ? this.DiskHyperVGeneration : null,
                DiskSizeGB        = null,
                DiskIOPSReadWrite = null,
                DiskMBpsReadWrite = null,
                DiskIOPSReadOnly  = null,
                DiskMBpsReadOnly  = null,
                MaxShares         = null,
                Location          = this.IsParameterBound(c => c.Location) ? this.Location : null,
                Tags         = null,
                Sku          = vSku,
                CreationData = vCreationData,
                EncryptionSettingsCollection = null,
                Encryption          = null,
                NetworkAccessPolicy = null,
                DiskAccessId        = null,
                DataAccessAuthMode  = this.IsParameterBound(c => c.DataAccessAuthMode) ? this.DataAccessAuthMode : null
            };

            return(vDisk);
        }
Beispiel #4
0
 internal ManagedDiskData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, ResourceIdentifier managedBy, IReadOnlyList <ResourceIdentifier> managedByExtended, DiskSku sku, IList <string> zones, ExtendedLocation extendedLocation, DateTimeOffset?timeCreated, OperatingSystemTypes?osType, HyperVGeneration?hyperVGeneration, DiskPurchasePlan purchasePlan, SupportedCapabilities supportedCapabilities, DiskCreationData creationData, int?diskSizeGB, long?diskSizeBytes, string uniqueId, EncryptionSettingsGroup encryptionSettingsGroup, string provisioningState, long?diskIopsReadWrite, long?diskMBpsReadWrite, long?diskIopsReadOnly, long?diskMBpsReadOnly, DiskState?diskState, DiskEncryption encryption, int?maxShares, IReadOnlyList <ShareInfoElement> shareInfo, NetworkAccessPolicy?networkAccessPolicy, ResourceIdentifier diskAccessId, string tier, bool?burstingEnabled, PropertyUpdatesInProgress propertyUpdatesInProgress, bool?supportsHibernation, DiskSecurityProfile securityProfile, float?completionPercent, PublicNetworkAccess?publicNetworkAccess, DataAccessAuthMode?dataAccessAuthMode) : base(id, name, resourceType, systemData, tags, location)
 {
     ManagedBy         = managedBy;
     ManagedByExtended = managedByExtended;
     Sku                       = sku;
     Zones                     = zones;
     ExtendedLocation          = extendedLocation;
     TimeCreated               = timeCreated;
     OSType                    = osType;
     HyperVGeneration          = hyperVGeneration;
     PurchasePlan              = purchasePlan;
     SupportedCapabilities     = supportedCapabilities;
     CreationData              = creationData;
     DiskSizeGB                = diskSizeGB;
     DiskSizeBytes             = diskSizeBytes;
     UniqueId                  = uniqueId;
     EncryptionSettingsGroup   = encryptionSettingsGroup;
     ProvisioningState         = provisioningState;
     DiskIopsReadWrite         = diskIopsReadWrite;
     DiskMBpsReadWrite         = diskMBpsReadWrite;
     DiskIopsReadOnly          = diskIopsReadOnly;
     DiskMBpsReadOnly          = diskMBpsReadOnly;
     DiskState                 = diskState;
     Encryption                = encryption;
     MaxShares                 = maxShares;
     ShareInfo                 = shareInfo;
     NetworkAccessPolicy       = networkAccessPolicy;
     DiskAccessId              = diskAccessId;
     Tier                      = tier;
     BurstingEnabled           = burstingEnabled;
     PropertyUpdatesInProgress = propertyUpdatesInProgress;
     SupportsHibernation       = supportsHibernation;
     SecurityProfile           = securityProfile;
     CompletionPercent         = completionPercent;
     PublicNetworkAccess       = publicNetworkAccess;
     DataAccessAuthMode        = dataAccessAuthMode;
 }
Beispiel #5
0
        public void DiskPoolCrud()
        {
            using var context = MockContext.Start(this.GetType());
            string resourceGroupName = TestUtilities.GenerateName("sdk-dcrud-rg");
            string diskPoolName      = TestUtilities.GenerateName("sdk-diskpool");
            string diskName          = TestUtilities.GenerateName("sdk-test-disk");
            string location          = "eastus";

            CreateResourceGroup(context, location, resourceGroupName);

            try
            {
                using var testBase = new StoragePoolTestBase(context);
                var client = testBase.StoragePoolClient;

                var vnetName         = "sdk-vnet";
                var subnetName       = "sdk-subnet";
                var diskName1        = "sdk-disk";
                var diskName2        = "sdk-disk-2";
                var availabilityZone = "2";

                // create vnet and subnet
                var networkClient = context.GetServiceClient <NetworkManagementClient>();
                var vnet          = new VirtualNetwork()
                {
                    Location     = location,
                    AddressSpace = new AddressSpace()
                    {
                        AddressPrefixes = new[] { "10.0.0.0/16" }
                    },
                    Subnets = new[]
                    {
                        new Subnet()
                        {
                            Name          = subnetName,
                            AddressPrefix = "10.0.0.0/24",
                            Delegations   = new Delegation[1]
                            {
                                new Delegation()
                                {
                                    Name        = "diskpool-delegation",
                                    ServiceName = "Microsoft.StoragePool/diskPools",
                                },
                            },
                        },
                    },
                };
                networkClient.VirtualNetworks.CreateOrUpdate(resourceGroupName, vnetName, vnet);
                var subnet = networkClient.Subnets.Get(resourceGroupName, vnetName, subnetName);

                var computeClient = context.GetServiceClient <ComputeManagementClient>();

                // create disk 1
                var sku = new DiskSku();
                sku.Name = DiskStorageAccountTypes.PremiumLRS;
                var disk1 = new ManagedDisk()
                {
                    Location     = location,
                    Sku          = sku,
                    Zones        = new[] { availabilityZone },
                    DiskSizeGB   = 256,
                    CreationData = new CreationData(DiskCreateOption.Empty),
                    MaxShares    = 2,
                };
                computeClient.Disks.CreateOrUpdate(resourceGroupName, diskName1, disk1);
                disk1 = computeClient.Disks.Get(resourceGroupName, diskName1);

                // create disk pool
                var diskPoolSku = new DiskPoolSku("Standard", "Standard");
                var diskPool    = new DiskPoolCreate(diskPoolSku, subnet.Id, location, new[] { availabilityZone });
                client.DiskPools.CreateOrUpdate(resourceGroupName, diskPoolName, diskPool);

                // assert that create succeeded
                var createdDiskPool = client.DiskPools.Get(resourceGroupName, diskPoolName);
                Assert.NotNull(createdDiskPool);
                Assert.Equal("Succeeded", createdDiskPool.ProvisioningState);


                // update disk pool -- add disk
                diskPool.Disks = new Disk[] { new Disk(disk1.Id) };
                client.DiskPools.CreateOrUpdate(resourceGroupName, diskPoolName, diskPool);

                // assert that create succeeded
                var updatedDiskPool = client.DiskPools.Get(resourceGroupName, diskPoolName);
                Assert.NotNull(updatedDiskPool);
                Assert.Equal("Succeeded", updatedDiskPool.ProvisioningState);

                // delete disk pool
                client.DiskPools.Delete(resourceGroupName, diskPoolName);
            }
            finally
            {
                DeleteResourceGroup(context, resourceGroupName);
            }
        }
        private void Run()
        {
            // Sku
            DiskSku vSku = null;

            // CreationData
            CreationData vCreationData = null;

            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // Encryption
            Encryption vEncryption = null;

            if (this.IsParameterBound(c => c.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.IsParameterBound(c => c.CreateOption))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.CreateOption = this.CreateOption;
            }

            if (this.IsParameterBound(c => c.StorageAccountId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.StorageAccountId = this.StorageAccountId;
            }

            if (this.IsParameterBound(c => c.ImageReference))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.ImageReference = this.ImageReference;
            }

            if (this.IsParameterBound(c => c.GalleryImageReference))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.GalleryImageReference = this.GalleryImageReference;
            }

            if (this.IsParameterBound(c => c.SourceUri))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceUri = this.SourceUri;
            }

            if (this.IsParameterBound(c => c.SourceResourceId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceResourceId = this.SourceResourceId;
            }

            if (this.IsParameterBound(c => c.UploadSizeInBytes))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.UploadSizeBytes = this.UploadSizeInBytes;
            }

            if (this.IsParameterBound(c => c.EncryptionSettingsEnabled))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.IsParameterBound(c => c.KeyEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionSetId))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.DiskEncryptionSetId = this.DiskEncryptionSetId;
            }

            if (this.IsParameterBound(c => c.EncryptionType))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.Type = this.EncryptionType;
            }

            var vDisk = new PSDisk
            {
                Zones             = this.IsParameterBound(c => c.Zone) ? this.Zone : null,
                OsType            = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                HyperVGeneration  = this.IsParameterBound(c => c.HyperVGeneration) ? this.HyperVGeneration : null,
                DiskSizeGB        = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.IsParameterBound(c => c.DiskIOPSReadWrite) ? this.DiskIOPSReadWrite : (long?)null,
                DiskMBpsReadWrite = this.IsParameterBound(c => c.DiskMBpsReadWrite) ? this.DiskMBpsReadWrite : (long?)null,
                DiskIOPSReadOnly  = this.IsParameterBound(c => c.DiskIOPSReadOnly) ? this.DiskIOPSReadOnly : (long?)null,
                DiskMBpsReadOnly  = this.IsParameterBound(c => c.DiskMBpsReadOnly) ? this.DiskMBpsReadOnly : (long?)null,
                MaxShares         = this.IsParameterBound(c => c.MaxSharesCount) ? this.MaxSharesCount : (int?)null,
                Location          = this.IsParameterBound(c => c.Location) ? this.Location : null,
                Tags         = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                Sku          = vSku,
                CreationData = vCreationData,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Encryption = vEncryption,
            };

            WriteObject(vDisk);
        }
        internal static DiskData DeserializeDiskData(JsonElement element)
        {
            Optional <string> managedBy = default;
            Optional <IReadOnlyList <string> > managedByExtended = default;
            Optional <DiskSku>           sku                                          = default;
            Optional <IList <string> >   zones                                        = default;
            Optional <ExtendedLocation>  extendedLocation                             = default;
            IDictionary <string, string> tags                                         = default;
            AzureLocation                                location                     = default;
            ResourceIdentifier                           id                           = default;
            string                                       name                         = default;
            ResourceType                                 type                         = default;
            Optional <DateTimeOffset>                    timeCreated                  = default;
            Optional <OperatingSystemTypes>              osType                       = default;
            Optional <HyperVGeneration>                  hyperVGeneration             = default;
            Optional <DiskPurchasePlan>                  purchasePlan                 = default;
            Optional <SupportedCapabilities>             supportedCapabilities        = default;
            Optional <CreationData>                      creationData                 = default;
            Optional <int>                               diskSizeGB                   = default;
            Optional <long>                              diskSizeBytes                = default;
            Optional <string>                            uniqueId                     = default;
            Optional <EncryptionSettingsCollection>      encryptionSettingsCollection = default;
            Optional <string>                            provisioningState            = default;
            Optional <long>                              diskIOPSReadWrite            = default;
            Optional <long>                              diskMBpsReadWrite            = default;
            Optional <long>                              diskIOPSReadOnly             = default;
            Optional <long>                              diskMBpsReadOnly             = default;
            Optional <DiskState>                         diskState                    = default;
            Optional <Encryption>                        encryption                   = default;
            Optional <int>                               maxShares                    = default;
            Optional <IReadOnlyList <ShareInfoElement> > shareInfo                    = default;
            Optional <NetworkAccessPolicy>               networkAccessPolicy          = default;
            Optional <string>                            diskAccessId                 = default;
            Optional <string>                            tier                         = default;
            Optional <bool>                              burstingEnabled              = default;
            Optional <PropertyUpdatesInProgress>         propertyUpdatesInProgress    = default;
            Optional <bool>                              supportsHibernation          = default;
            Optional <DiskSecurityProfile>               securityProfile              = default;
            Optional <float>                             completionPercent            = default;
            Optional <PublicNetworkAccess>               publicNetworkAccess          = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("managedBy"))
                {
                    managedBy = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("managedByExtended"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    managedByExtended = array;
                    continue;
                }
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = DiskSku.DeserializeDiskSku(property.Value);
                    continue;
                }
                if (property.NameEquals("zones"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    zones = array;
                    continue;
                }
                if (property.NameEquals("extendedLocation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    extendedLocation = ExtendedLocation.DeserializeExtendedLocation(property.Value);
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("timeCreated"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            timeCreated = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("osType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            osType = property0.Value.GetString().ToOperatingSystemTypes();
                            continue;
                        }
                        if (property0.NameEquals("hyperVGeneration"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            hyperVGeneration = new HyperVGeneration(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("purchasePlan"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            purchasePlan = DiskPurchasePlan.DeserializeDiskPurchasePlan(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("supportedCapabilities"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            supportedCapabilities = SupportedCapabilities.DeserializeSupportedCapabilities(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("creationData"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            creationData = CreationData.DeserializeCreationData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("diskSizeGB"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            diskSizeGB = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("diskSizeBytes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            diskSizeBytes = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("uniqueId"))
                        {
                            uniqueId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("encryptionSettingsCollection"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            encryptionSettingsCollection = EncryptionSettingsCollection.DeserializeEncryptionSettingsCollection(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            provisioningState = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("diskIOPSReadWrite"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            diskIOPSReadWrite = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("diskMBpsReadWrite"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            diskMBpsReadWrite = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("diskIOPSReadOnly"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            diskIOPSReadOnly = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("diskMBpsReadOnly"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            diskMBpsReadOnly = property0.Value.GetInt64();
                            continue;
                        }
                        if (property0.NameEquals("diskState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            diskState = new DiskState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("encryption"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            encryption = Encryption.DeserializeEncryption(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("maxShares"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            maxShares = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("shareInfo"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ShareInfoElement> array = new List <ShareInfoElement>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ShareInfoElement.DeserializeShareInfoElement(item));
                            }
                            shareInfo = array;
                            continue;
                        }
                        if (property0.NameEquals("networkAccessPolicy"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            networkAccessPolicy = new NetworkAccessPolicy(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("diskAccessId"))
                        {
                            diskAccessId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("tier"))
                        {
                            tier = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("burstingEnabled"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            burstingEnabled = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("propertyUpdatesInProgress"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            propertyUpdatesInProgress = PropertyUpdatesInProgress.DeserializePropertyUpdatesInProgress(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("supportsHibernation"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            supportsHibernation = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("securityProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            securityProfile = DiskSecurityProfile.DeserializeDiskSecurityProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("completionPercent"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            completionPercent = property0.Value.GetSingle();
                            continue;
                        }
                        if (property0.NameEquals("publicNetworkAccess"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            publicNetworkAccess = new PublicNetworkAccess(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new DiskData(id, name, type, tags, location, managedBy.Value, Optional.ToList(managedByExtended), sku.Value, Optional.ToList(zones), extendedLocation.Value, Optional.ToNullable(timeCreated), Optional.ToNullable(osType), Optional.ToNullable(hyperVGeneration), purchasePlan.Value, supportedCapabilities.Value, creationData.Value, Optional.ToNullable(diskSizeGB), Optional.ToNullable(diskSizeBytes), uniqueId.Value, encryptionSettingsCollection.Value, provisioningState.Value, Optional.ToNullable(diskIOPSReadWrite), Optional.ToNullable(diskMBpsReadWrite), Optional.ToNullable(diskIOPSReadOnly), Optional.ToNullable(diskMBpsReadOnly), Optional.ToNullable(diskState), encryption.Value, Optional.ToNullable(maxShares), Optional.ToList(shareInfo), Optional.ToNullable(networkAccessPolicy), diskAccessId.Value, tier.Value, Optional.ToNullable(burstingEnabled), propertyUpdatesInProgress.Value, Optional.ToNullable(supportsHibernation), securityProfile.Value, Optional.ToNullable(completionPercent), Optional.ToNullable(publicNetworkAccess)));
        }
        private void Run()
        {
            // Sku
            DiskSku vSku = null;

            // CreationData
            CreationData vCreationData = null;

            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            if (this.IsParameterBound(c => c.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.IsParameterBound(c => c.CreateOption))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.CreateOption = this.CreateOption;
            }

            if (this.IsParameterBound(c => c.StorageAccountId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.StorageAccountId = this.StorageAccountId;
            }

            if (this.IsParameterBound(c => c.ImageReference))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.ImageReference = this.ImageReference;
            }

            if (this.IsParameterBound(c => c.SourceUri))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceUri = this.SourceUri;
            }

            if (this.IsParameterBound(c => c.SourceResourceId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceResourceId = this.SourceResourceId;
            }

            if (this.IsParameterBound(c => c.UploadSizeInBytes))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.UploadSizeBytes = this.UploadSizeInBytes;
            }

            if (this.IsParameterBound(c => c.EncryptionSettingsEnabled))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.IsParameterBound(c => c.KeyEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            var vDisk = new PSDisk
            {
                Zones             = this.IsParameterBound(c => c.Zone) ? this.Zone : null,
                OsType            = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                HyperVGeneration  = this.IsParameterBound(c => c.HyperVGeneration) ? this.HyperVGeneration : null,
                DiskSizeGB        = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.IsParameterBound(c => c.DiskIOPSReadWrite) ? this.DiskIOPSReadWrite : (int?)null,
                DiskMBpsReadWrite = this.IsParameterBound(c => c.DiskMBpsReadWrite) ? this.DiskMBpsReadWrite : (int?)null,
                Location          = this.IsParameterBound(c => c.Location) ? this.Location : null,
                Tags         = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                Sku          = vSku,
                CreationData = vCreationData,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
            };

            // this is to hide the breaking change for upload
            if ("upload".Equals(vDisk.CreationData?.CreateOption?.ToLowerInvariant()) && vDisk.CreationData?.UploadSizeBytes == null)
            {
                if (vDisk.DiskSizeGB != null)
                {
                    vDisk.CreationData.UploadSizeBytes = (long)vDisk.DiskSizeGB * 1073741824 + 512;  // multiplying 1GB and then add the size of footer (512 bytes)
                    vDisk.DiskSizeGB = null;
                }
            }

            WriteObject(vDisk);
        }
        private void Run()
        {
            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // EncryptionSettingsCollection
            EncryptionSettingsElement vEncryptionSettingsElement = null;

            // Encryption
            Encryption vEncryption = null;

            // Sku
            DiskSku vSku = null;

            // SupportedCapabilities
            SupportedCapabilities vSupportedCapabilities = null;

            if (this.IsParameterBound(c => c.EncryptionSettingsEnabled))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsElement == null)
                {
                    vEncryptionSettingsElement = new EncryptionSettingsElement();
                    vEncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettingsElement);
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.IsParameterBound(c => c.KeyEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsElement == null)
                {
                    vEncryptionSettingsElement = new EncryptionSettingsElement();
                    vEncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettingsElement);
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionSetId))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.DiskEncryptionSetId = this.DiskEncryptionSetId;
            }

            if (this.IsParameterBound(c => c.EncryptionType))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.Type = this.EncryptionType;
            }

            if (this.IsParameterBound(c => c.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.IsParameterBound(c => c.AcceleratedNetwork))
            {
                if (vSupportedCapabilities == null)
                {
                    vSupportedCapabilities = new SupportedCapabilities();
                }
                vSupportedCapabilities.AcceleratedNetwork = AcceleratedNetwork;
            }

            if (this.IsParameterBound(c => c.Architecture))
            {
                if (vSupportedCapabilities == null)
                {
                    vSupportedCapabilities = new SupportedCapabilities();
                }
                vSupportedCapabilities.Architecture = this.Architecture;
            }

            var vDiskUpdate = new PSDiskUpdate
            {
                OsType            = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB        = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.IsParameterBound(c => c.DiskIOPSReadWrite) ? this.DiskIOPSReadWrite : (int?)null,
                DiskMBpsReadWrite = this.IsParameterBound(c => c.DiskMBpsReadWrite) ? this.DiskMBpsReadWrite : (int?)null,
                DiskIOPSReadOnly  = this.IsParameterBound(c => c.DiskIOPSReadOnly) ? this.DiskIOPSReadOnly : null,
                DiskMBpsReadOnly  = this.IsParameterBound(c => c.DiskMBpsReadOnly) ? this.DiskMBpsReadOnly : null,
                MaxShares         = this.IsParameterBound(c => c.MaxSharesCount) ? this.MaxSharesCount : null,
                Tags = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                NetworkAccessPolicy          = this.IsParameterBound(c => c.NetworkAccessPolicy) ? this.NetworkAccessPolicy: null,
                DiskAccessId                 = this.IsParameterBound(c => c.DiskAccessId) ? this.DiskAccessId: null,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Encryption            = vEncryption,
                Sku                   = vSku,
                Tier                  = this.IsParameterBound(c => c.Tier) ? this.Tier : null,
                BurstingEnabled       = this.IsParameterBound(c => c.BurstingEnabled) ? this.BurstingEnabled : null,
                PurchasePlan          = this.IsParameterBound(c => c.PurchasePlan) ? this.PurchasePlan : null,
                SupportsHibernation   = this.IsParameterBound(c => c.SupportsHibernation) ? SupportsHibernation : null,
                SupportedCapabilities = vSupportedCapabilities,
                PublicNetworkAccess   = this.IsParameterBound(c => c.PublicNetworkAccess) ? PublicNetworkAccess : null,
                DataAccessAuthMode    = this.IsParameterBound(c => c.DataAccessAuthMode) ? DataAccessAuthMode : null
            };

            WriteObject(vDiskUpdate);
        }
Beispiel #10
0
        private void Run()
        {
            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // EncryptionSettingsCollection
            EncryptionSettingsElement vEncryptionSettingsElement = null;

            // Encryption
            Encryption vEncryption = null;

            // Sku
            DiskSku vSku = null;

            if (this.IsParameterBound(c => c.EncryptionSettingsEnabled))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsElement == null)
                {
                    vEncryptionSettingsElement = new EncryptionSettingsElement();
                    vEncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettingsElement);
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.IsParameterBound(c => c.KeyEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsElement == null)
                {
                    vEncryptionSettingsElement = new EncryptionSettingsElement();
                    vEncryptionSettingsCollection.EncryptionSettings.Add(vEncryptionSettingsElement);
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionSetId))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.DiskEncryptionSetId = this.DiskEncryptionSetId;
            }

            if (this.IsParameterBound(c => c.EncryptionType))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.Type = this.EncryptionType;
            }

            if (this.IsParameterBound(c => c.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            var vDiskUpdate = new PSDiskUpdate
            {
                OsType            = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB        = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.IsParameterBound(c => c.DiskIOPSReadWrite) ? this.DiskIOPSReadWrite : (int?)null,
                DiskMBpsReadWrite = this.IsParameterBound(c => c.DiskMBpsReadWrite) ? this.DiskMBpsReadWrite : (int?)null,
                DiskIOPSReadOnly  = this.IsParameterBound(c => c.DiskIOPSReadOnly) ? this.DiskIOPSReadOnly : null,
                DiskMBpsReadOnly  = this.IsParameterBound(c => c.DiskMBpsReadOnly) ? this.DiskMBpsReadOnly : null,
                MaxShares         = this.IsParameterBound(c => c.MaxSharesCount) ? this.MaxSharesCount : null,
                Tags = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                NetworkAccessPolicy          = this.IsParameterBound(c => c.NetworkAccessPolicy) ? this.NetworkAccessPolicy: null,
                DiskAccessId                 = this.IsParameterBound(c => c.DiskAccessId) ? this.DiskAccessId: null,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Encryption = vEncryption,
                Sku        = vSku,
                Tier       = this.IsParameterBound(c => c.Tier) ? this.Tier : null,
            };

            WriteObject(vDiskUpdate);
        }
        private void Run()
        {
            // Sku
            DiskSku vSku = null;

            // CreationData
            CreationData vCreationData = null;

            // EncryptionSettingsCollection
            EncryptionSettingsCollection vEncryptionSettingsCollection = null;

            // Encryption
            Encryption vEncryption = null;

            // ExtendedLocation
            ExtendedLocation vExtendedLocation = null;

            // SupportedCapabilities
            SupportedCapabilities vSupportedCapabilities = null;

            if (this.IsParameterBound(c => c.SkuName))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.IsParameterBound(c => c.CreateOption))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.CreateOption = this.CreateOption;
            }

            if (this.IsParameterBound(c => c.StorageAccountId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.StorageAccountId = this.StorageAccountId;
            }

            if (this.IsParameterBound(c => c.ImageReference))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.ImageReference = this.ImageReference;
            }

            if (this.IsParameterBound(c => c.GalleryImageReference))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.GalleryImageReference = this.GalleryImageReference;
            }

            if (this.IsParameterBound(c => c.SourceUri))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceUri = this.SourceUri;
            }

            if (this.IsParameterBound(c => c.SourceResourceId))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceResourceId = this.SourceResourceId;
            }

            if (this.IsParameterBound(c => c.UploadSizeInBytes))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.UploadSizeBytes = this.UploadSizeInBytes;
            }

            if (this.IsParameterBound(c => c.LogicalSectorSize))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.LogicalSectorSize = this.LogicalSectorSize;
            }

            if (this.IsParameterBound(c => c.EncryptionSettingsEnabled))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }
                vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.IsParameterBound(c => c.KeyEncryptionKey))
            {
                if (vEncryptionSettingsCollection == null)
                {
                    vEncryptionSettingsCollection = new EncryptionSettingsCollection();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings == null)
                {
                    vEncryptionSettingsCollection.EncryptionSettings = new List <EncryptionSettingsElement>();
                }

                if (vEncryptionSettingsCollection.EncryptionSettings.Count == 0)
                {
                    vEncryptionSettingsCollection.EncryptionSettings.Add(new EncryptionSettingsElement());
                }

                vEncryptionSettingsCollection.EncryptionSettings[0].KeyEncryptionKey = this.KeyEncryptionKey;
            }

            if (this.IsParameterBound(c => c.DiskEncryptionSetId))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.DiskEncryptionSetId = this.DiskEncryptionSetId;
            }

            if (this.IsParameterBound(c => c.EncryptionType))
            {
                if (vEncryption == null)
                {
                    vEncryption = new Encryption();
                }
                vEncryption.Type = this.EncryptionType;
            }

            if (this.IsParameterBound(c => c.EdgeZone))
            {
                vExtendedLocation = new ExtendedLocation {
                    Name = this.EdgeZone, Type = ExtendedLocationTypes.EdgeZone
                };
            }

            if (this.IsParameterBound(c => c.AcceleratedNetwork))
            {
                if (vSupportedCapabilities == null)
                {
                    vSupportedCapabilities = new SupportedCapabilities();
                }
                vSupportedCapabilities.AcceleratedNetwork = AcceleratedNetwork;
            }

            var vDisk = new PSDisk
            {
                Zones             = this.IsParameterBound(c => c.Zone) ? this.Zone : null,
                OsType            = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null,
                HyperVGeneration  = this.IsParameterBound(c => c.HyperVGeneration) ? this.HyperVGeneration : null,
                DiskSizeGB        = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.IsParameterBound(c => c.DiskIOPSReadWrite) ? this.DiskIOPSReadWrite : (long?)null,
                DiskMBpsReadWrite = this.IsParameterBound(c => c.DiskMBpsReadWrite) ? this.DiskMBpsReadWrite : (long?)null,
                DiskIOPSReadOnly  = this.IsParameterBound(c => c.DiskIOPSReadOnly) ? this.DiskIOPSReadOnly : (long?)null,
                DiskMBpsReadOnly  = this.IsParameterBound(c => c.DiskMBpsReadOnly) ? this.DiskMBpsReadOnly : (long?)null,
                MaxShares         = this.IsParameterBound(c => c.MaxSharesCount) ? this.MaxSharesCount : (int?)null,
                Location          = this.IsParameterBound(c => c.Location) ? this.Location : null,
                ExtendedLocation  = vExtendedLocation,
                Tags         = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                Sku          = vSku,
                CreationData = vCreationData,
                EncryptionSettingsCollection = vEncryptionSettingsCollection,
                Encryption          = vEncryption,
                NetworkAccessPolicy = this.IsParameterBound(c => c.NetworkAccessPolicy) ? this.NetworkAccessPolicy : null,
                DiskAccessId        = this.IsParameterBound(c => c.DiskAccessId) ? this.DiskAccessId : null,
                Tier                  = this.IsParameterBound(c => c.Tier) ? this.Tier : null,
                BurstingEnabled       = this.IsParameterBound(c => c.BurstingEnabled) ? this.BurstingEnabled : null,
                PurchasePlan          = this.IsParameterBound(c => c.PurchasePlan) ? this.PurchasePlan : null,
                SupportsHibernation   = this.IsParameterBound(c => c.SupportsHibernation) ? SupportsHibernation : null,
                SupportedCapabilities = vSupportedCapabilities,
                PublicNetworkAccess   = this.IsParameterBound(c => c.PublicNetworkAccess) ? PublicNetworkAccess : null
            };

            WriteObject(vDisk);
        }
        private void Run()
        {
            // Sku
            DiskSku vSku = null;

            // CreationData
            CreationData vCreationData = null;

            // EncryptionSettings
            EncryptionSettings vEncryptionSettings = null;

            if (this.MyInvocation.BoundParameters.ContainsKey("SkuName"))
            {
                if (vSku == null)
                {
                    vSku = new DiskSku();
                }
                vSku.Name = this.SkuName;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("CreateOption"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.CreateOption = this.CreateOption;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("StorageAccountId"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.StorageAccountId = this.StorageAccountId;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("ImageReference"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.ImageReference = this.ImageReference;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SourceUri"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceUri = this.SourceUri;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("SourceResourceId"))
            {
                if (vCreationData == null)
                {
                    vCreationData = new CreationData();
                }
                vCreationData.SourceResourceId = this.SourceResourceId;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("EncryptionSettingsEnabled"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new EncryptionSettings();
                }
                vEncryptionSettings.Enabled = this.EncryptionSettingsEnabled;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("DiskEncryptionKey"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new EncryptionSettings();
                }
                vEncryptionSettings.DiskEncryptionKey = this.DiskEncryptionKey;
            }

            if (this.MyInvocation.BoundParameters.ContainsKey("KeyEncryptionKey"))
            {
                if (vEncryptionSettings == null)
                {
                    vEncryptionSettings = new EncryptionSettings();
                }
                vEncryptionSettings.KeyEncryptionKey = this.KeyEncryptionKey;
            }

            var vDisk = new PSDisk
            {
                Zones             = this.MyInvocation.BoundParameters.ContainsKey("Zone") ? this.Zone : null,
                OsType            = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null,
                DiskSizeGB        = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?)null,
                DiskIOPSReadWrite = this.MyInvocation.BoundParameters.ContainsKey("DiskIOPSReadWrite") ? this.DiskIOPSReadWrite : (int?)null,
                DiskMBpsReadWrite = this.MyInvocation.BoundParameters.ContainsKey("DiskMBpsReadWrite") ? this.DiskMBpsReadWrite : (int?)null,
                Location          = this.MyInvocation.BoundParameters.ContainsKey("Location") ? this.Location : null,
                Tags               = this.MyInvocation.BoundParameters.ContainsKey("Tag") ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null,
                Sku                = vSku,
                CreationData       = vCreationData,
                EncryptionSettings = vEncryptionSettings,
            };

            WriteObject(vDisk);
        }