コード例 #1
0
        internal static PurchaseRequestContent DeserializePurchaseRequestContent(JsonElement element)
        {
            Optional <ReservationsSkuName>  sku                  = default;
            Optional <AzureLocation>        location             = default;
            Optional <ReservedResourceType> reservedResourceType = default;
            Optional <string>                 billingScopeId     = default;
            Optional <ReservationTerm>        term               = default;
            Optional <ReservationBillingPlan> billingPlan        = default;
            Optional <int>              quantity                 = default;
            Optional <string>           displayName              = default;
            Optional <AppliedScopeType> appliedScopeType         = default;
            Optional <IList <string> >  appliedScopes            = default;
            Optional <bool>             renew = default;
            Optional <PurchaseRequestPropertiesReservedResourceProperties> reservedResourceProperties = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = ReservationsSkuName.DeserializeReservationsSkuName(property.Value);
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    location = new AzureLocation(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("reservedResourceType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            reservedResourceType = new ReservedResourceType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("billingScopeId"))
                        {
                            billingScopeId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("term"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            term = new ReservationTerm(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("billingPlan"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            billingPlan = new ReservationBillingPlan(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("quantity"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            quantity = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("displayName"))
                        {
                            displayName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("appliedScopeType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            appliedScopeType = new AppliedScopeType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("appliedScopes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <string> array = new List <string>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(item.GetString());
                            }
                            appliedScopes = array;
                            continue;
                        }
                        if (property0.NameEquals("renew"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            renew = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("reservedResourceProperties"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            reservedResourceProperties = PurchaseRequestPropertiesReservedResourceProperties.DeserializePurchaseRequestPropertiesReservedResourceProperties(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new PurchaseRequestContent(sku.Value, Optional.ToNullable(location), Optional.ToNullable(reservedResourceType), billingScopeId.Value, Optional.ToNullable(term), Optional.ToNullable(billingPlan), Optional.ToNullable(quantity), displayName.Value, Optional.ToNullable(appliedScopeType), Optional.ToList(appliedScopes), Optional.ToNullable(renew), reservedResourceProperties.Value));
        }
コード例 #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));
        }