internal SnapshotData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, string managedBy, SnapshotSku sku, ExtendedLocation extendedLocation, DateTimeOffset?timeCreated, OperatingSystemTypes?osType, HyperVGeneration?hyperVGeneration, DiskPurchasePlan purchasePlan, SupportedCapabilities supportedCapabilities, DiskCreationData creationData, int?diskSizeGB, long?diskSizeBytes, DiskState?diskState, string uniqueId, EncryptionSettingsGroup encryptionSettingsGroup, string provisioningState, bool?incremental, DiskEncryption encryption, NetworkAccessPolicy?networkAccessPolicy, ResourceIdentifier diskAccessId, DiskSecurityProfile securityProfile, bool?supportsHibernation, PublicNetworkAccess?publicNetworkAccess, float?completionPercent, CopyCompletionError copyCompletionError, DataAccessAuthMode?dataAccessAuthMode) : base(id, name, resourceType, systemData, tags, location) { ManagedBy = managedBy; Sku = sku; ExtendedLocation = extendedLocation; TimeCreated = timeCreated; OSType = osType; HyperVGeneration = hyperVGeneration; PurchasePlan = purchasePlan; SupportedCapabilities = supportedCapabilities; CreationData = creationData; DiskSizeGB = diskSizeGB; DiskSizeBytes = diskSizeBytes; DiskState = diskState; UniqueId = uniqueId; EncryptionSettingsGroup = encryptionSettingsGroup; ProvisioningState = provisioningState; Incremental = incremental; Encryption = encryption; NetworkAccessPolicy = networkAccessPolicy; DiskAccessId = diskAccessId; SecurityProfile = securityProfile; SupportsHibernation = supportsHibernation; PublicNetworkAccess = publicNetworkAccess; CompletionPercent = completionPercent; CopyCompletionError = copyCompletionError; DataAccessAuthMode = dataAccessAuthMode; }
private void Run() { // EncryptionSettings EncryptionSettings vEncryptionSettings = null; // Sku SnapshotSku 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 SnapshotSku(); } vSku.Name = this.SkuName; } var vSnapshotUpdate = new PSSnapshotUpdate { OsType = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null, DiskSizeGB = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (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 = new DiskSku { Name = vSku.Name.ToString() } }; WriteObject(vSnapshotUpdate); }
///GENMHASH:9E43D8BC283E297FB09F74B50D967B51:82D76CF0DAD29D42162C63B7BC7F03C3 public SnapshotImpl WithSku(SnapshotSkuType sku) { SnapshotSku snapshotSku = new SnapshotSku { Name = sku.AccountType }; Inner.Sku = snapshotSku; return(this); }
///GENMHASH:26BC80239F0CCAAB14CDBC15A85351B8:5C4E68981DCB985DABC30CE2B145CC62 public SnapshotImpl WithSku(DiskSkuTypes sku) { SnapshotSku snapshotSku = new SnapshotSku { Name = SnapshotStorageAccountTypes.Parse(sku.AccountType.ToString()) }; Inner.Sku = snapshotSku; return(this); }
/// <summary> /// Parses a value into a snapshot SKU type and creates a new SnapshotSkuType instance if not found among /// the existing ones. /// </summary> /// <param name="snapshotSku">a snapshot SKU type name</param> /// <returns>the parsed or created snapshot SKU type</returns> public static SnapshotSkuType FromSnapshotSku(SnapshotSku snapshotSku) { if (snapshotSku == null || snapshotSku.Name == null) { return(null); } else { return(FromStorageAccountType(snapshotSku.Name)); } }
internal SnapshotData(ResourceIdentifier id, string name, ResourceType type, IDictionary <string, string> tags, Location location, string managedBy, SnapshotSku sku, ExtendedLocation extendedLocation, DateTimeOffset?timeCreated, OperatingSystemTypes?osType, HyperVGeneration?hyperVGeneration, PurchasePlanAutoGenerated purchasePlan, CreationData creationData, int?diskSizeGB, long?diskSizeBytes, DiskState?diskState, string uniqueId, EncryptionSettingsCollection encryptionSettingsCollection, string provisioningState, bool?incremental, Encryption encryption, NetworkAccessPolicy?networkAccessPolicy, string diskAccessId, bool?supportsHibernation) : base(id, name, type, tags, location) { ManagedBy = managedBy; Sku = sku; ExtendedLocation = extendedLocation; TimeCreated = timeCreated; OsType = osType; HyperVGeneration = hyperVGeneration; PurchasePlan = purchasePlan; CreationData = creationData; DiskSizeGB = diskSizeGB; DiskSizeBytes = diskSizeBytes; DiskState = diskState; UniqueId = uniqueId; EncryptionSettingsCollection = encryptionSettingsCollection; ProvisioningState = provisioningState; Incremental = incremental; Encryption = encryption; NetworkAccessPolicy = networkAccessPolicy; DiskAccessId = diskAccessId; SupportsHibernation = supportsHibernation; }
private void Run() { // Sku SnapshotSku vSku = null; // CreationData CreationData vCreationData = null; // EncryptionSettingsCollection EncryptionSettingsCollection vEncryptionSettingsCollection = null; if (this.IsParameterBound(c => c.SkuName)) { if (vSku == null) { vSku = new SnapshotSku(); } 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.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 vSnapshot = new PSSnapshot { 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, 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, }; WriteObject(vSnapshot); }
internal static SnapshotData DeserializeSnapshotData(JsonElement element) { Optional <string> managedBy = default; Optional <SnapshotSku> sku = default; Optional <ExtendedLocation> extendedLocation = default; IDictionary <string, string> tags = default; AzureLocation location = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = 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 <DiskState> diskState = default; Optional <string> uniqueId = default; Optional <EncryptionSettingsCollection> encryptionSettingsCollection = default; Optional <string> provisioningState = default; Optional <bool> incremental = default; Optional <Encryption> encryption = default; Optional <NetworkAccessPolicy> networkAccessPolicy = default; Optional <string> diskAccessId = default; Optional <DiskSecurityProfile> securityProfile = default; Optional <bool> supportsHibernation = default; Optional <PublicNetworkAccess> publicNetworkAccess = default; Optional <float> completionPercent = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("managedBy")) { managedBy = property.Value.GetString(); continue; } if (property.NameEquals("sku")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } sku = SnapshotSku.DeserializeSnapshotSku(property.Value); 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("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); 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("diskState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } diskState = new DiskState(property0.Value.GetString()); 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("incremental")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } incremental = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("encryption")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } encryption = Encryption.DeserializeEncryption(property0.Value); 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("securityProfile")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } securityProfile = DiskSecurityProfile.DeserializeDiskSecurityProfile(property0.Value); continue; } if (property0.NameEquals("supportsHibernation")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } supportsHibernation = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("publicNetworkAccess")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } publicNetworkAccess = new PublicNetworkAccess(property0.Value.GetString()); continue; } if (property0.NameEquals("completionPercent")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } completionPercent = property0.Value.GetSingle(); continue; } } continue; } } return(new SnapshotData(id, name, type, systemData, tags, location, managedBy.Value, sku.Value, extendedLocation.Value, Optional.ToNullable(timeCreated), Optional.ToNullable(osType), Optional.ToNullable(hyperVGeneration), purchasePlan.Value, supportedCapabilities.Value, creationData.Value, Optional.ToNullable(diskSizeGB), Optional.ToNullable(diskSizeBytes), Optional.ToNullable(diskState), uniqueId.Value, encryptionSettingsCollection.Value, provisioningState.Value, Optional.ToNullable(incremental), encryption.Value, Optional.ToNullable(networkAccessPolicy), diskAccessId.Value, securityProfile.Value, Optional.ToNullable(supportsHibernation), Optional.ToNullable(publicNetworkAccess), Optional.ToNullable(completionPercent))); }
private void Run() { // Sku SnapshotSku 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 SnapshotSku(); } 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.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 vSnapshot = new PSSnapshot { 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, Incremental = this.Incremental.IsPresent, 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, 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(vSnapshot); }
private void Run() { // EncryptionSettingsCollection EncryptionSettingsCollection vEncryptionSettingsCollection = null; // Sku SnapshotSku vSku = null; if (this.MyInvocation.BoundParameters.ContainsKey("EncryptionSettingsEnabled")) { if (vEncryptionSettingsCollection == null) { vEncryptionSettingsCollection = new EncryptionSettingsCollection(); } vEncryptionSettingsCollection.Enabled = (bool)this.EncryptionSettingsEnabled; } if (this.MyInvocation.BoundParameters.ContainsKey("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.MyInvocation.BoundParameters.ContainsKey("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.MyInvocation.BoundParameters.ContainsKey("SkuName")) { if (vSku == null) { vSku = new SnapshotSku(); } vSku.Name = this.SkuName; } var vSnapshotUpdate = new PSSnapshotUpdate { OsType = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null, DiskSizeGB = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (int?)null, Tags = this.MyInvocation.BoundParameters.ContainsKey("Tag") ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null, EncryptionSettingsCollection = vEncryptionSettingsCollection, Sku = vSku, }; WriteObject(vSnapshotUpdate); }
private void Run() { // EncryptionSettingsCollection EncryptionSettingsCollection vEncryptionSettingsCollection = null; // Encryption Encryption vEncryption = null; // Sku SnapshotSku vSku = null; 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 (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.SkuName)) { if (vSku == null) { vSku = new SnapshotSku(); } vSku.Name = this.SkuName; } if (this.IsParameterBound(c => c.Architecture)) { if (vSupportedCapabilities == null) { vSupportedCapabilities = new SupportedCapabilities(); } vSupportedCapabilities.Architecture = this.Architecture; } var vSnapshotUpdate = new PSSnapshotUpdate { OsType = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null, DiskSizeGB = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null, Tags = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null, EncryptionSettingsCollection = vEncryptionSettingsCollection, Encryption = vEncryption, Sku = vSku, SupportsHibernation = this.IsParameterBound(c => c.SupportsHibernation) ? SupportsHibernation : null, PublicNetworkAccess = this.IsParameterBound(c => c.PublicNetworkAccess) ? PublicNetworkAccess : null, DataAccessAuthMode = this.IsParameterBound(c => c.DataAccessAuthMode) ? DataAccessAuthMode : null, SupportedCapabilities = vSupportedCapabilities }; WriteObject(vSnapshotUpdate); }
private void Run() { // EncryptionSettingsCollection EncryptionSettingsCollection vEncryptionSettingsCollection = null; // Encryption Encryption vEncryption = null; // Sku SnapshotSku 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 (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.SkuName)) { if (vSku == null) { vSku = new SnapshotSku(); } vSku.Name = this.SkuName; } var vSnapshotUpdate = new PSSnapshotUpdate { OsType = this.IsParameterBound(c => c.OsType) ? this.OsType : (OperatingSystemTypes?)null, DiskSizeGB = this.IsParameterBound(c => c.DiskSizeGB) ? this.DiskSizeGB : (int?)null, Tags = this.IsParameterBound(c => c.Tag) ? this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value) : null, EncryptionSettingsCollection = vEncryptionSettingsCollection, Encryption = vEncryption, Sku = vSku, }; WriteObject(vSnapshotUpdate); }
private void Run() { // Sku SnapshotSku vSku = null; // CreationData CreationData vCreationData = null; // EncryptionSettings EncryptionSettings vEncryptionSettings = null; if (this.MyInvocation.BoundParameters.ContainsKey("SkuName")) { if (vSku == null) { vSku = new SnapshotSku(); } 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 vSnapshot = new PSSnapshot { OsType = this.MyInvocation.BoundParameters.ContainsKey("OsType") ? this.OsType : (OperatingSystemTypes?)null, DiskSizeGB = this.MyInvocation.BoundParameters.ContainsKey("DiskSizeGB") ? this.DiskSizeGB : (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(vSnapshot); }