예제 #1
0
 internal ReservationsProperties(ReservedResourceType?reservedResourceType, InstanceFlexibility?instanceFlexibility, string displayName, IReadOnlyList <string> appliedScopes, AppliedScopeType?appliedScopeType, bool?archived, string capabilities, int?quantity, ProvisioningState?provisioningState, DateTimeOffset?effectiveOn, DateTimeOffset?benefitStartOn, DateTimeOffset?lastUpdatedOn, DateTimeOffset?expiryOn, string skuDescription, ExtendedStatusInfo extendedStatusInfo, ReservationBillingPlan?billingPlan, string displayProvisioningState, string provisioningSubState, DateTimeOffset?purchaseOn, ReservationSplitProperties splitProperties, ReservationMergeProperties mergeProperties, string billingScopeId, bool?renew, string renewSource, string renewDestination, RenewPropertiesResponse renewProperties, ReservationTerm?term, string userFriendlyAppliedScopeType, string userFriendlyRenewState, ReservationsPropertiesUtilization utilization)
 {
     ReservedResourceType     = reservedResourceType;
     InstanceFlexibility      = instanceFlexibility;
     DisplayName              = displayName;
     AppliedScopes            = appliedScopes;
     AppliedScopeType         = appliedScopeType;
     Archived                 = archived;
     Capabilities             = capabilities;
     Quantity                 = quantity;
     ProvisioningState        = provisioningState;
     EffectiveOn              = effectiveOn;
     BenefitStartOn           = benefitStartOn;
     LastUpdatedOn            = lastUpdatedOn;
     ExpiryOn                 = expiryOn;
     SkuDescription           = skuDescription;
     ExtendedStatusInfo       = extendedStatusInfo;
     BillingPlan              = billingPlan;
     DisplayProvisioningState = displayProvisioningState;
     ProvisioningSubState     = provisioningSubState;
     PurchaseOn               = purchaseOn;
     SplitProperties          = splitProperties;
     MergeProperties          = mergeProperties;
     BillingScopeId           = billingScopeId;
     Renew                        = renew;
     RenewSource                  = renewSource;
     RenewDestination             = renewDestination;
     RenewProperties              = renewProperties;
     Term                         = term;
     UserFriendlyAppliedScopeType = userFriendlyAppliedScopeType;
     UserFriendlyRenewState       = userFriendlyRenewState;
     Utilization                  = utilization;
 }
예제 #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));
        }