internal static ServicePrincipal DeserializeServicePrincipal(JsonElement element)
        {
            Optional <bool> accountEnabled = default;
            Optional <IReadOnlyList <string> > alternativeNames = default;
            Optional <string> appDisplayName                                    = default;
            Optional <string> appId                                             = default;
            Optional <string> appOwnerTenantId                                  = default;
            Optional <bool>   appRoleAssignmentRequired                         = default;
            Optional <IReadOnlyList <AppRole> > appRoles                        = default;
            Optional <string> displayName                                       = default;
            Optional <string> errorUrl                                          = default;
            Optional <string> homepage                                          = default;
            Optional <IReadOnlyList <KeyCredential> > keyCredentials            = default;
            Optional <string> logoutUrl                                         = default;
            Optional <IReadOnlyList <OAuth2Permission> >   oauth2Permissions    = default;
            Optional <IReadOnlyList <PasswordCredential> > passwordCredentials  = default;
            Optional <string> preferredTokenSigningKeyThumbprint                = default;
            Optional <string> publisherName                                     = default;
            Optional <IReadOnlyList <string> > replyUrls                        = default;
            Optional <string> samlMetadataUrl                                   = default;
            Optional <IReadOnlyList <string> > servicePrincipalNames            = default;
            Optional <string> servicePrincipalType                              = default;
            Optional <IReadOnlyList <string> > tags                             = default;
            Optional <string>                    objectId                       = default;
            string                               objectType                     = default;
            Optional <DateTimeOffset?>           deletionTimestamp              = default;
            IReadOnlyDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>          additionalPropertiesDictionary = new Dictionary <string, object>();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("accountEnabled"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    accountEnabled = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("alternativeNames"))
                {
                    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());
                    }
                    alternativeNames = array;
                    continue;
                }
                if (property.NameEquals("appDisplayName"))
                {
                    appDisplayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("appId"))
                {
                    appId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("appOwnerTenantId"))
                {
                    appOwnerTenantId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("appRoleAssignmentRequired"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    appRoleAssignmentRequired = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("appRoles"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <AppRole> array = new List <AppRole>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(AppRole.DeserializeAppRole(item));
                    }
                    appRoles = array;
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("errorUrl"))
                {
                    errorUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("homepage"))
                {
                    homepage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("keyCredentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <KeyCredential> array = new List <KeyCredential>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(KeyCredential.DeserializeKeyCredential(item));
                    }
                    keyCredentials = array;
                    continue;
                }
                if (property.NameEquals("logoutUrl"))
                {
                    logoutUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("oauth2Permissions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <OAuth2Permission> array = new List <OAuth2Permission>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(OAuth2Permission.DeserializeOAuth2Permission(item));
                    }
                    oauth2Permissions = array;
                    continue;
                }
                if (property.NameEquals("passwordCredentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <PasswordCredential> array = new List <PasswordCredential>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(PasswordCredential.DeserializePasswordCredential(item));
                    }
                    passwordCredentials = array;
                    continue;
                }
                if (property.NameEquals("preferredTokenSigningKeyThumbprint"))
                {
                    preferredTokenSigningKeyThumbprint = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("publisherName"))
                {
                    publisherName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("replyUrls"))
                {
                    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());
                    }
                    replyUrls = array;
                    continue;
                }
                if (property.NameEquals("samlMetadataUrl"))
                {
                    samlMetadataUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("servicePrincipalNames"))
                {
                    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());
                    }
                    servicePrincipalNames = array;
                    continue;
                }
                if (property.NameEquals("servicePrincipalType"))
                {
                    servicePrincipalType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    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());
                    }
                    tags = array;
                    continue;
                }
                if (property.NameEquals("objectId"))
                {
                    objectId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("objectType"))
                {
                    objectType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("deletionTimestamp"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        deletionTimestamp = null;
                        continue;
                    }
                    deletionTimestamp = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new ServicePrincipal(objectId.Value, objectType, Optional.ToNullable(deletionTimestamp), additionalProperties, Optional.ToNullable(accountEnabled), Optional.ToList(alternativeNames), appDisplayName.Value, appId.Value, appOwnerTenantId.Value, Optional.ToNullable(appRoleAssignmentRequired), Optional.ToList(appRoles), displayName.Value, errorUrl.Value, homepage.Value, Optional.ToList(keyCredentials), logoutUrl.Value, Optional.ToList(oauth2Permissions), Optional.ToList(passwordCredentials), preferredTokenSigningKeyThumbprint.Value, publisherName.Value, Optional.ToList(replyUrls), samlMetadataUrl.Value, Optional.ToList(servicePrincipalNames), servicePrincipalType.Value, Optional.ToList(tags)));
        }
Beispiel #2
0
        internal static Application DeserializeApplication(JsonElement element)
        {
            Optional <string> appId                                                        = default;
            Optional <bool>   allowGuestsSignIn                                            = default;
            Optional <bool>   allowPassthroughUsers                                        = default;
            Optional <string> appLogoUrl                                                   = default;
            Optional <IReadOnlyList <AppRole> > appRoles                                   = default;
            Optional <IReadOnlyList <string> >  appPermissions                             = default;
            Optional <bool>   availableToOtherTenants                                      = default;
            Optional <string> displayName                                                  = default;
            Optional <string> errorUrl                                                     = default;
            Optional <GroupMembershipClaimTypes> groupMembershipClaims                     = default;
            Optional <string> homepage                                                     = default;
            Optional <IReadOnlyList <string> > identifierUris                              = default;
            Optional <InformationalUrl>        informationalUrls                           = default;
            Optional <bool> isDeviceOnlyAuthSupported                                      = default;
            Optional <IReadOnlyList <KeyCredential> > keyCredentials                       = default;
            Optional <IReadOnlyList <string> >        knownClientApplications              = default;
            Optional <string> logoutUrl                                                    = default;
            Optional <bool>   oauth2AllowImplicitFlow                                      = default;
            Optional <bool>   oauth2AllowUrlPathMatching                                   = default;
            Optional <IReadOnlyList <OAuth2Permission> > oauth2Permissions                 = default;
            Optional <bool> oauth2RequirePostResponse                                      = default;
            Optional <IReadOnlyList <string> >                   orgRestrictions           = default;
            Optional <OptionalClaims>                            optionalClaims            = default;
            Optional <IReadOnlyList <PasswordCredential> >       passwordCredentials       = default;
            Optional <IReadOnlyList <PreAuthorizedApplication> > preAuthorizedApplications = default;
            Optional <bool>   publicClient                                                 = default;
            Optional <string> publisherDomain                                              = default;
            Optional <IReadOnlyList <string> > replyUrls                                   = default;
            Optional <IReadOnlyList <RequiredResourceAccess> > requiredResourceAccess      = default;
            Optional <string>                    samlMetadataUrl                           = default;
            Optional <string>                    signInAudience                            = default;
            Optional <string>                    wwwHomepage                               = default;
            Optional <string>                    objectId                                  = default;
            Optional <string>                    objectType                                = default;
            Optional <DateTimeOffset>            deletionTimestamp                         = default;
            IReadOnlyDictionary <string, object> additionalProperties                      = default;
            Dictionary <string, object>          additionalPropertiesDictionary            = new Dictionary <string, object>();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("appId"))
                {
                    appId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("allowGuestsSignIn"))
                {
                    allowGuestsSignIn = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("allowPassthroughUsers"))
                {
                    allowPassthroughUsers = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("appLogoUrl"))
                {
                    appLogoUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("appRoles"))
                {
                    List <AppRole> array = new List <AppRole>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(AppRole.DeserializeAppRole(item));
                    }
                    appRoles = array;
                    continue;
                }
                if (property.NameEquals("appPermissions"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    appPermissions = array;
                    continue;
                }
                if (property.NameEquals("availableToOtherTenants"))
                {
                    availableToOtherTenants = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("errorUrl"))
                {
                    errorUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("groupMembershipClaims"))
                {
                    groupMembershipClaims = new GroupMembershipClaimTypes(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("homepage"))
                {
                    homepage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("identifierUris"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    identifierUris = array;
                    continue;
                }
                if (property.NameEquals("informationalUrls"))
                {
                    informationalUrls = InformationalUrl.DeserializeInformationalUrl(property.Value);
                    continue;
                }
                if (property.NameEquals("isDeviceOnlyAuthSupported"))
                {
                    isDeviceOnlyAuthSupported = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("keyCredentials"))
                {
                    List <KeyCredential> array = new List <KeyCredential>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(KeyCredential.DeserializeKeyCredential(item));
                    }
                    keyCredentials = array;
                    continue;
                }
                if (property.NameEquals("knownClientApplications"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    knownClientApplications = array;
                    continue;
                }
                if (property.NameEquals("logoutUrl"))
                {
                    logoutUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("oauth2AllowImplicitFlow"))
                {
                    oauth2AllowImplicitFlow = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("oauth2AllowUrlPathMatching"))
                {
                    oauth2AllowUrlPathMatching = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("oauth2Permissions"))
                {
                    List <OAuth2Permission> array = new List <OAuth2Permission>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(OAuth2Permission.DeserializeOAuth2Permission(item));
                    }
                    oauth2Permissions = array;
                    continue;
                }
                if (property.NameEquals("oauth2RequirePostResponse"))
                {
                    oauth2RequirePostResponse = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("orgRestrictions"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    orgRestrictions = array;
                    continue;
                }
                if (property.NameEquals("optionalClaims"))
                {
                    optionalClaims = OptionalClaims.DeserializeOptionalClaims(property.Value);
                    continue;
                }
                if (property.NameEquals("passwordCredentials"))
                {
                    List <PasswordCredential> array = new List <PasswordCredential>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(PasswordCredential.DeserializePasswordCredential(item));
                    }
                    passwordCredentials = array;
                    continue;
                }
                if (property.NameEquals("preAuthorizedApplications"))
                {
                    List <PreAuthorizedApplication> array = new List <PreAuthorizedApplication>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(PreAuthorizedApplication.DeserializePreAuthorizedApplication(item));
                    }
                    preAuthorizedApplications = array;
                    continue;
                }
                if (property.NameEquals("publicClient"))
                {
                    publicClient = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("publisherDomain"))
                {
                    publisherDomain = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("replyUrls"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    replyUrls = array;
                    continue;
                }
                if (property.NameEquals("requiredResourceAccess"))
                {
                    List <RequiredResourceAccess> array = new List <RequiredResourceAccess>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(Models.RequiredResourceAccess.DeserializeRequiredResourceAccess(item));
                    }
                    requiredResourceAccess = array;
                    continue;
                }
                if (property.NameEquals("samlMetadataUrl"))
                {
                    samlMetadataUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("signInAudience"))
                {
                    signInAudience = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("wwwHomepage"))
                {
                    wwwHomepage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("objectId"))
                {
                    objectId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("objectType"))
                {
                    objectType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("deletionTimestamp"))
                {
                    deletionTimestamp = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new Application(objectId.Value, objectType.Value, Optional.ToNullable(deletionTimestamp), additionalProperties, appId.Value, Optional.ToNullable(allowGuestsSignIn), Optional.ToNullable(allowPassthroughUsers), appLogoUrl.Value, Optional.ToList(appRoles), Optional.ToList(appPermissions), Optional.ToNullable(availableToOtherTenants), displayName.Value, errorUrl.Value, Optional.ToNullable(groupMembershipClaims), homepage.Value, Optional.ToList(identifierUris), informationalUrls.Value, Optional.ToNullable(isDeviceOnlyAuthSupported), Optional.ToList(keyCredentials), Optional.ToList(knownClientApplications), logoutUrl.Value, Optional.ToNullable(oauth2AllowImplicitFlow), Optional.ToNullable(oauth2AllowUrlPathMatching), Optional.ToList(oauth2Permissions), Optional.ToNullable(oauth2RequirePostResponse), Optional.ToList(orgRestrictions), optionalClaims.Value, Optional.ToList(passwordCredentials), Optional.ToList(preAuthorizedApplications), Optional.ToNullable(publicClient), publisherDomain.Value, Optional.ToList(replyUrls), Optional.ToList(requiredResourceAccess), samlMetadataUrl.Value, signInAudience.Value, wwwHomepage.Value));
        }
Beispiel #3
0
        internal static ServicePrincipal DeserializeServicePrincipal(JsonElement element)
        {
            bool?accountEnabled = default;
            IReadOnlyList <string> alternativeNames = default;
            string appDisplayName                                               = default;
            string appId                                                        = default;
            string appOwnerTenantId                                             = default;
            bool?  appRoleAssignmentRequired                                    = default;
            IReadOnlyList <AppRole> appRoles                                    = default;
            string displayName                                                  = default;
            string errorUrl                                                     = default;
            string homepage                                                     = default;
            IReadOnlyList <KeyCredential> keyCredentials                        = default;
            string logoutUrl                                                    = default;
            IReadOnlyList <OAuth2Permission>   oauth2Permissions                = default;
            IReadOnlyList <PasswordCredential> passwordCredentials              = default;
            string preferredTokenSigningKeyThumbprint                           = default;
            string publisherName                                                = default;
            IReadOnlyList <string> replyUrls                                    = default;
            string samlMetadataUrl                                              = default;
            IReadOnlyList <string> servicePrincipalNames                        = default;
            string servicePrincipalType                                         = default;
            IReadOnlyList <string> tags                                         = default;
            string         objectId                                             = default;
            string         objectType                                           = default;
            DateTimeOffset?deletionTimestamp                                    = default;
            IReadOnlyDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>          additionalPropertiesDictionary = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("accountEnabled"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    accountEnabled = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("alternativeNames"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    alternativeNames = array;
                    continue;
                }
                if (property.NameEquals("appDisplayName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    appDisplayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("appId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    appId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("appOwnerTenantId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    appOwnerTenantId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("appRoleAssignmentRequired"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    appRoleAssignmentRequired = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("appRoles"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <AppRole> array = new List <AppRole>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(AppRole.DeserializeAppRole(item));
                        }
                    }
                    appRoles = array;
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("errorUrl"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    errorUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("homepage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    homepage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("keyCredentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <KeyCredential> array = new List <KeyCredential>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(KeyCredential.DeserializeKeyCredential(item));
                        }
                    }
                    keyCredentials = array;
                    continue;
                }
                if (property.NameEquals("logoutUrl"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    logoutUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("oauth2Permissions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <OAuth2Permission> array = new List <OAuth2Permission>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(OAuth2Permission.DeserializeOAuth2Permission(item));
                        }
                    }
                    oauth2Permissions = array;
                    continue;
                }
                if (property.NameEquals("passwordCredentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <PasswordCredential> array = new List <PasswordCredential>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(PasswordCredential.DeserializePasswordCredential(item));
                        }
                    }
                    passwordCredentials = array;
                    continue;
                }
                if (property.NameEquals("preferredTokenSigningKeyThumbprint"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    preferredTokenSigningKeyThumbprint = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("publisherName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    publisherName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("replyUrls"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    replyUrls = array;
                    continue;
                }
                if (property.NameEquals("samlMetadataUrl"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    samlMetadataUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("servicePrincipalNames"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    servicePrincipalNames = array;
                    continue;
                }
                if (property.NameEquals("servicePrincipalType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    servicePrincipalType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    tags = array;
                    continue;
                }
                if (property.NameEquals("objectId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    objectId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("objectType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    objectType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("deletionTimestamp"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    deletionTimestamp = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                additionalPropertiesDictionary ??= new Dictionary <string, object>();
                if (property.Value.ValueKind == JsonValueKind.Null)
                {
                    additionalPropertiesDictionary.Add(property.Name, null);
                }
                else
                {
                    additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
                }
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new ServicePrincipal(objectId, objectType, deletionTimestamp, additionalProperties, accountEnabled, alternativeNames, appDisplayName, appId, appOwnerTenantId, appRoleAssignmentRequired, appRoles, displayName, errorUrl, homepage, keyCredentials, logoutUrl, oauth2Permissions, passwordCredentials, preferredTokenSigningKeyThumbprint, publisherName, replyUrls, samlMetadataUrl, servicePrincipalNames, servicePrincipalType, tags));
        }
Beispiel #4
0
        internal static Application DeserializeApplication(JsonElement element)
        {
            string appId                                                        = default;
            bool?  allowGuestsSignIn                                            = default;
            bool?  allowPassthroughUsers                                        = default;
            string appLogoUrl                                                   = default;
            IReadOnlyList <AppRole> appRoles                                    = default;
            IReadOnlyList <string>  appPermissions                              = default;
            bool?  availableToOtherTenants                                      = default;
            string displayName                                                  = default;
            string errorUrl                                                     = default;
            GroupMembershipClaimTypes?groupMembershipClaims                     = default;
            string homepage                                                     = default;
            IReadOnlyList <string> identifierUris                               = default;
            InformationalUrl       informationalUrls                            = default;
            bool?isDeviceOnlyAuthSupported                                      = default;
            IReadOnlyList <KeyCredential> keyCredentials                        = default;
            IReadOnlyList <string>        knownClientApplications               = default;
            string logoutUrl                                                    = default;
            bool?  oauth2AllowImplicitFlow                                      = default;
            bool?  oauth2AllowUrlPathMatching                                   = default;
            IReadOnlyList <OAuth2Permission> oauth2Permissions                  = default;
            bool?oauth2RequirePostResponse                                      = default;
            IReadOnlyList <string>                   orgRestrictions            = default;
            OptionalClaims                           optionalClaims             = default;
            IReadOnlyList <PasswordCredential>       passwordCredentials        = default;
            IReadOnlyList <PreAuthorizedApplication> preAuthorizedApplications  = default;
            bool?  publicClient                                                 = default;
            string publisherDomain                                              = default;
            IReadOnlyList <string> replyUrls                                    = default;
            IReadOnlyList <RequiredResourceAccess> requiredResourceAccess       = default;
            string         samlMetadataUrl                                      = default;
            string         signInAudience                                       = default;
            string         wwwHomepage                                          = default;
            string         objectId                                             = default;
            string         objectType                                           = default;
            DateTimeOffset?deletionTimestamp                                    = default;
            IReadOnlyDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>          additionalPropertiesDictionary = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("appId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    appId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("allowGuestsSignIn"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    allowGuestsSignIn = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("allowPassthroughUsers"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    allowPassthroughUsers = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("appLogoUrl"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    appLogoUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("appRoles"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <AppRole> array = new List <AppRole>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(AppRole.DeserializeAppRole(item));
                        }
                    }
                    appRoles = array;
                    continue;
                }
                if (property.NameEquals("appPermissions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    appPermissions = array;
                    continue;
                }
                if (property.NameEquals("availableToOtherTenants"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    availableToOtherTenants = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("errorUrl"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    errorUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("groupMembershipClaims"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    groupMembershipClaims = new GroupMembershipClaimTypes(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("homepage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    homepage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("identifierUris"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    identifierUris = array;
                    continue;
                }
                if (property.NameEquals("informationalUrls"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    informationalUrls = InformationalUrl.DeserializeInformationalUrl(property.Value);
                    continue;
                }
                if (property.NameEquals("isDeviceOnlyAuthSupported"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    isDeviceOnlyAuthSupported = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("keyCredentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <KeyCredential> array = new List <KeyCredential>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(KeyCredential.DeserializeKeyCredential(item));
                        }
                    }
                    keyCredentials = array;
                    continue;
                }
                if (property.NameEquals("knownClientApplications"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    knownClientApplications = array;
                    continue;
                }
                if (property.NameEquals("logoutUrl"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    logoutUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("oauth2AllowImplicitFlow"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    oauth2AllowImplicitFlow = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("oauth2AllowUrlPathMatching"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    oauth2AllowUrlPathMatching = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("oauth2Permissions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <OAuth2Permission> array = new List <OAuth2Permission>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(OAuth2Permission.DeserializeOAuth2Permission(item));
                        }
                    }
                    oauth2Permissions = array;
                    continue;
                }
                if (property.NameEquals("oauth2RequirePostResponse"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    oauth2RequirePostResponse = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("orgRestrictions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    orgRestrictions = array;
                    continue;
                }
                if (property.NameEquals("optionalClaims"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    optionalClaims = OptionalClaims.DeserializeOptionalClaims(property.Value);
                    continue;
                }
                if (property.NameEquals("passwordCredentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <PasswordCredential> array = new List <PasswordCredential>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(PasswordCredential.DeserializePasswordCredential(item));
                        }
                    }
                    passwordCredentials = array;
                    continue;
                }
                if (property.NameEquals("preAuthorizedApplications"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <PreAuthorizedApplication> array = new List <PreAuthorizedApplication>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(PreAuthorizedApplication.DeserializePreAuthorizedApplication(item));
                        }
                    }
                    preAuthorizedApplications = array;
                    continue;
                }
                if (property.NameEquals("publicClient"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    publicClient = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("publisherDomain"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    publisherDomain = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("replyUrls"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetString());
                        }
                    }
                    replyUrls = array;
                    continue;
                }
                if (property.NameEquals("requiredResourceAccess"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <RequiredResourceAccess> array = new List <RequiredResourceAccess>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(Models.RequiredResourceAccess.DeserializeRequiredResourceAccess(item));
                        }
                    }
                    requiredResourceAccess = array;
                    continue;
                }
                if (property.NameEquals("samlMetadataUrl"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    samlMetadataUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("signInAudience"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    signInAudience = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("wwwHomepage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    wwwHomepage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("objectId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    objectId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("objectType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    objectType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("deletionTimestamp"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    deletionTimestamp = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                additionalPropertiesDictionary ??= new Dictionary <string, object>();
                if (property.Value.ValueKind == JsonValueKind.Null)
                {
                    additionalPropertiesDictionary.Add(property.Name, null);
                }
                else
                {
                    additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
                }
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new Application(objectId, objectType, deletionTimestamp, additionalProperties, appId, allowGuestsSignIn, allowPassthroughUsers, appLogoUrl, appRoles, appPermissions, availableToOtherTenants, displayName, errorUrl, groupMembershipClaims, homepage, identifierUris, informationalUrls, isDeviceOnlyAuthSupported, keyCredentials, knownClientApplications, logoutUrl, oauth2AllowImplicitFlow, oauth2AllowUrlPathMatching, oauth2Permissions, oauth2RequirePostResponse, orgRestrictions, optionalClaims, passwordCredentials, preAuthorizedApplications, publicClient, publisherDomain, replyUrls, requiredResourceAccess, samlMetadataUrl, signInAudience, wwwHomepage));
        }