Exemplo n.º 1
0
        internal static StorageSku DeserializeStorageSku(JsonElement element)
        {
            StorageSkuName            name = default;
            Optional <StorageSkuTier> tier = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = new StorageSkuName(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("tier"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    tier = property.Value.GetString().ToStorageSkuTier();
                    continue;
                }
            }
            return(new StorageSku(name, Optional.ToNullable(tier)));
        }
 internal StorageSkuInformation(StorageSkuName name)
 {
     Name         = name;
     Locations    = new ChangeTrackingList <string>();
     Capabilities = new ChangeTrackingList <SKUCapability>();
     Restrictions = new ChangeTrackingList <Restriction>();
 }
 internal StorageSkuInformation(StorageSkuName name, StorageSkuTier?tier, string resourceType, StorageKind?kind, IReadOnlyList <string> locations, IReadOnlyList <SKUCapability> capabilities, IReadOnlyList <Restriction> restrictions)
 {
     Name         = name;
     Tier         = tier;
     ResourceType = resourceType;
     Kind         = kind;
     Locations    = locations;
     Capabilities = capabilities;
     Restrictions = restrictions;
 }
Exemplo n.º 4
0
        internal static StorageAccountSkuConversionStatus DeserializeStorageAccountSkuConversionStatus(JsonElement element)
        {
            Optional <SkuConversionStatus> skuConversionStatus = default;
            Optional <StorageSkuName>      targetSkuName       = default;
            Optional <string> startTime = default;
            Optional <string> endTime   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("skuConversionStatus"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    skuConversionStatus = new SkuConversionStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("targetSkuName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    targetSkuName = new StorageSkuName(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    startTime = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    endTime = property.Value.GetString();
                    continue;
                }
            }
            return(new StorageAccountSkuConversionStatus(Optional.ToNullable(skuConversionStatus), Optional.ToNullable(targetSkuName), startTime.Value, endTime.Value));
        }
        internal static StorageSkuInformation DeserializeStorageSkuInformation(JsonElement element)
        {
            StorageSkuName                            name         = default;
            Optional <StorageSkuTier>                 tier         = default;
            Optional <string>                         resourceType = default;
            Optional <StorageKind>                    kind         = default;
            Optional <IReadOnlyList <string> >        locations    = default;
            Optional <IReadOnlyList <SKUCapability> > capabilities = default;
            Optional <IReadOnlyList <Restriction> >   restrictions = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = new StorageSkuName(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("tier"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    tier = property.Value.GetString().ToStorageSkuTier();
                    continue;
                }
                if (property.NameEquals("resourceType"))
                {
                    resourceType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    kind = new StorageKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("locations"))
                {
                    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());
                    }
                    locations = array;
                    continue;
                }
                if (property.NameEquals("capabilities"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <SKUCapability> array = new List <SKUCapability>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(SKUCapability.DeserializeSKUCapability(item));
                    }
                    capabilities = array;
                    continue;
                }
                if (property.NameEquals("restrictions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <Restriction> array = new List <Restriction>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Restriction.DeserializeRestriction(item));
                    }
                    restrictions = array;
                    continue;
                }
            }
            return(new StorageSkuInformation(name, Optional.ToNullable(tier), resourceType.Value, Optional.ToNullable(kind), Optional.ToList(locations), Optional.ToList(capabilities), Optional.ToList(restrictions)));
        }