private DateTime GetLastHighWatermark(WatermarkKeyedCollection importState, string key)
        {
            if (importState == null)
            {
                throw new WarningNoWatermarkException("No watermark was available to perform a delta import");
            }

            if (!importState.Contains(key))
            {
                throw new WarningNoWatermarkException("No watermark was available to perform a delta import for the group object type");
            }

            string value = importState[key].Value;
            long   ticks = long.Parse(value);

            return(new DateTime(ticks));
        }
        private IAsyncEnumerable <IUser> GetUserEnumerable(bool inDelta, WatermarkKeyedCollection importState, IOktaClient client, ImportContext context)
        {
            IAsyncEnumerable <IUser> users;

            if (inDelta)
            {
                if (importState == null)
                {
                    throw new WarningNoWatermarkException("No watermark was available to perform a delta import");
                }

                if (!importState.Contains("users"))
                {
                    throw new WarningNoWatermarkException("No watermark was available to perform a delta import for the user object type");
                }

                string   value = importState["users"].Value;
                long     ticks = long.Parse(value);
                DateTime dt    = new DateTime(ticks);

                string filter = $"(lastUpdated gt \"{dt.ToSmartString()}Z\")";

                if (context.ConfigParameters[ConfigParameterNames.UserDeprovisioningAction].Value == "Delete")
                {
                    filter += " and(status eq \"LOCKED_OUT\" or status eq \"RECOVERY\" or status eq \"STAGED\" or status eq \"PROVISIONED\" or status eq \"ACTIVE\" or status eq \"PASSWORD_EXPIRED\" or status eq \"DEPROVISIONED\" or status eq \"SUSPENDED\")";
                }

                users = client.Users.ListUsers(null, null, OktaMAConfigSection.Configuration.UserListPageSize, filter);
            }
            else
            {
                string filter = null;

                if (context.ConfigParameters[ConfigParameterNames.UserDeprovisioningAction].Value == "Delete")
                {
                    filter = "(status eq \"LOCKED_OUT\" or status eq \"RECOVERY\" or status eq \"STAGED\" or status eq \"PROVISIONED\" or status eq \"ACTIVE\" or status eq \"PASSWORD_EXPIRED\" or status eq \"DEPROVISIONED\" or status eq \"SUSPENDED\")";
                }

                users = client.Users.ListUsers(null, null, OktaMAConfigSection.Configuration.UserListPageSize, filter);
            }

            return(users);
        }