Example #1
0
 internal ManagedHsmProperties(Guid?tenantId, IList <string> initialAdminObjectIds, Uri hsmUri, bool?enableSoftDelete, int?softDeleteRetentionInDays, bool?enablePurgeProtection, CreateMode?createMode, string statusMessage, ProvisioningState?provisioningState, MhsmNetworkRuleSet networkAcls, IReadOnlyList <MhsmPrivateEndpointConnectionItem> privateEndpointConnections, PublicNetworkAccess?publicNetworkAccess, DateTimeOffset?scheduledPurgeDate)
 {
     TenantId = tenantId;
     InitialAdminObjectIds = initialAdminObjectIds;
     HsmUri                     = hsmUri;
     EnableSoftDelete           = enableSoftDelete;
     SoftDeleteRetentionInDays  = softDeleteRetentionInDays;
     EnablePurgeProtection      = enablePurgeProtection;
     CreateMode                 = createMode;
     StatusMessage              = statusMessage;
     ProvisioningState          = provisioningState;
     NetworkAcls                = networkAcls;
     PrivateEndpointConnections = privateEndpointConnections;
     PublicNetworkAccess        = publicNetworkAccess;
     ScheduledPurgeDate         = scheduledPurgeDate;
 }
Example #2
0
        internal static ManagedHsmProperties DeserializeManagedHsmProperties(JsonElement element)
        {
            Optional <Guid>               tenantId = default;
            Optional <IList <string> >    initialAdminObjectIds = default;
            Optional <Uri>                hsmUri                    = default;
            Optional <bool>               enableSoftDelete          = default;
            Optional <int>                softDeleteRetentionInDays = default;
            Optional <bool>               enablePurgeProtection     = default;
            Optional <CreateMode>         createMode                = default;
            Optional <string>             statusMessage             = default;
            Optional <ProvisioningState>  provisioningState         = default;
            Optional <MhsmNetworkRuleSet> networkAcls               = default;
            Optional <IReadOnlyList <MhsmPrivateEndpointConnectionItem> > privateEndpointConnections = default;
            Optional <PublicNetworkAccess> publicNetworkAccess = default;
            Optional <DateTimeOffset>      scheduledPurgeDate  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("tenantId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    tenantId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("initialAdminObjectIds"))
                {
                    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());
                    }
                    initialAdminObjectIds = array;
                    continue;
                }
                if (property.NameEquals("hsmUri"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        hsmUri = null;
                        continue;
                    }
                    hsmUri = new Uri(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("enableSoftDelete"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    enableSoftDelete = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("softDeleteRetentionInDays"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    softDeleteRetentionInDays = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("enablePurgeProtection"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    enablePurgeProtection = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("createMode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createMode = property.Value.GetString().ToCreateMode();
                    continue;
                }
                if (property.NameEquals("statusMessage"))
                {
                    statusMessage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new ProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("networkAcls"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    networkAcls = MhsmNetworkRuleSet.DeserializeMhsmNetworkRuleSet(property.Value);
                    continue;
                }
                if (property.NameEquals("privateEndpointConnections"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <MhsmPrivateEndpointConnectionItem> array = new List <MhsmPrivateEndpointConnectionItem>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MhsmPrivateEndpointConnectionItem.DeserializeMhsmPrivateEndpointConnectionItem(item));
                    }
                    privateEndpointConnections = array;
                    continue;
                }
                if (property.NameEquals("publicNetworkAccess"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    publicNetworkAccess = new PublicNetworkAccess(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("scheduledPurgeDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    scheduledPurgeDate = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return(new ManagedHsmProperties(Optional.ToNullable(tenantId), Optional.ToList(initialAdminObjectIds), hsmUri.Value, Optional.ToNullable(enableSoftDelete), Optional.ToNullable(softDeleteRetentionInDays), Optional.ToNullable(enablePurgeProtection), Optional.ToNullable(createMode), statusMessage.Value, Optional.ToNullable(provisioningState), networkAcls.Value, Optional.ToList(privateEndpointConnections), Optional.ToNullable(publicNetworkAccess), Optional.ToNullable(scheduledPurgeDate)));
        }