internal static PurchaseRequestPropertiesReservedResourceProperties DeserializePurchaseRequestPropertiesReservedResourceProperties(JsonElement element)
        {
            Optional <InstanceFlexibility> instanceFlexibility = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("instanceFlexibility"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    instanceFlexibility = new InstanceFlexibility(property.Value.GetString());
                    continue;
                }
            }
            return(new PurchaseRequestPropertiesReservedResourceProperties(Optional.ToNullable(instanceFlexibility)));
        }
示例#2
0
        internal static ReservationsProperties DeserializeReservationsProperties(JsonElement element)
        {
            Optional <ReservedResourceType> reservedResourceType = default;
            Optional <InstanceFlexibility>  instanceFlexibility  = default;
            Optional <string> displayName = default;
            Optional <IReadOnlyList <string> > appliedScopes                          = default;
            Optional <AppliedScopeType>        appliedScopeType                       = default;
            Optional <bool>                              archived                     = default;
            Optional <string>                            capabilities                 = default;
            Optional <int>                               quantity                     = default;
            Optional <ProvisioningState>                 provisioningState            = default;
            Optional <DateTimeOffset>                    effectiveDateTime            = default;
            Optional <DateTimeOffset>                    benefitStartTime             = default;
            Optional <DateTimeOffset>                    lastUpdatedDateTime          = default;
            Optional <DateTimeOffset>                    expiryDate                   = default;
            Optional <string>                            skuDescription               = default;
            Optional <ExtendedStatusInfo>                extendedStatusInfo           = default;
            Optional <ReservationBillingPlan>            billingPlan                  = default;
            Optional <string>                            displayProvisioningState     = default;
            Optional <string>                            provisioningSubState         = default;
            Optional <DateTimeOffset>                    purchaseDate                 = default;
            Optional <ReservationSplitProperties>        splitProperties              = default;
            Optional <ReservationMergeProperties>        mergeProperties              = default;
            Optional <string>                            billingScopeId               = default;
            Optional <bool>                              renew                        = default;
            Optional <string>                            renewSource                  = default;
            Optional <string>                            renewDestination             = default;
            Optional <RenewPropertiesResponse>           renewProperties              = default;
            Optional <ReservationTerm>                   term                         = default;
            Optional <string>                            userFriendlyAppliedScopeType = default;
            Optional <string>                            userFriendlyRenewState       = default;
            Optional <ReservationsPropertiesUtilization> utilization                  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("reservedResourceType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    reservedResourceType = new ReservedResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("instanceFlexibility"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    instanceFlexibility = new InstanceFlexibility(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("appliedScopes"))
                {
                    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());
                    }
                    appliedScopes = array;
                    continue;
                }
                if (property.NameEquals("appliedScopeType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    appliedScopeType = new AppliedScopeType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("archived"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    archived = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("capabilities"))
                {
                    capabilities = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("quantity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    quantity = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new ProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("effectiveDateTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    effectiveDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("benefitStartTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    benefitStartTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("lastUpdatedDateTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    lastUpdatedDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("expiryDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    expiryDate = property.Value.GetDateTimeOffset("D");
                    continue;
                }
                if (property.NameEquals("skuDescription"))
                {
                    skuDescription = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("extendedStatusInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    extendedStatusInfo = ExtendedStatusInfo.DeserializeExtendedStatusInfo(property.Value);
                    continue;
                }
                if (property.NameEquals("billingPlan"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    billingPlan = new ReservationBillingPlan(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("displayProvisioningState"))
                {
                    displayProvisioningState = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("provisioningSubState"))
                {
                    provisioningSubState = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("purchaseDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    purchaseDate = property.Value.GetDateTimeOffset("D");
                    continue;
                }
                if (property.NameEquals("splitProperties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    splitProperties = ReservationSplitProperties.DeserializeReservationSplitProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("mergeProperties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    mergeProperties = ReservationMergeProperties.DeserializeReservationMergeProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("billingScopeId"))
                {
                    billingScopeId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("renew"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    renew = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("renewSource"))
                {
                    renewSource = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("renewDestination"))
                {
                    renewDestination = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("renewProperties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    renewProperties = RenewPropertiesResponse.DeserializeRenewPropertiesResponse(property.Value);
                    continue;
                }
                if (property.NameEquals("term"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    term = new ReservationTerm(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("userFriendlyAppliedScopeType"))
                {
                    userFriendlyAppliedScopeType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("userFriendlyRenewState"))
                {
                    userFriendlyRenewState = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("utilization"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    utilization = ReservationsPropertiesUtilization.DeserializeReservationsPropertiesUtilization(property.Value);
                    continue;
                }
            }
            return(new ReservationsProperties(Optional.ToNullable(reservedResourceType), Optional.ToNullable(instanceFlexibility), displayName.Value, Optional.ToList(appliedScopes), Optional.ToNullable(appliedScopeType), Optional.ToNullable(archived), capabilities.Value, Optional.ToNullable(quantity), Optional.ToNullable(provisioningState), Optional.ToNullable(effectiveDateTime), Optional.ToNullable(benefitStartTime), Optional.ToNullable(lastUpdatedDateTime), Optional.ToNullable(expiryDate), skuDescription.Value, extendedStatusInfo.Value, Optional.ToNullable(billingPlan), displayProvisioningState.Value, provisioningSubState.Value, Optional.ToNullable(purchaseDate), splitProperties.Value, mergeProperties.Value, billingScopeId.Value, Optional.ToNullable(renew), renewSource.Value, renewDestination.Value, renewProperties.Value, Optional.ToNullable(term), userFriendlyAppliedScopeType.Value, userFriendlyRenewState.Value, utilization.Value));
        }