lib/users.js
function count (client) {
  return function count (realm) {
    return new Promise((resolve, reject) => {
      const req = {
        auth: {
          bearer: privates.get(client).accessToken
        },
        json: true,
        url: `${client.baseUrl}/admin/realms/${realm}/users/count`
      };

      request(req, (err, resp, body) => {
        if (err) {
          return reject(err);
        }

        if (resp.statusCode !== 200) {
          return reject(body);
        }

        return resolve(body);
      });
    });
  };
}
function count (client) {
  return function count (realm) {
    return new Promise((resolve, reject) => {
      const req = {
        auth: {
          bearer: privates.get(client).accessToken
        },
        json: true,
        url: `${client.baseUrl}/admin/realms/${realm}/users/count`
      };

      request(req, (err, resp, body) => {
        if (err) {
          return reject(err);
        }

        if (resp.statusCode !== 200) {
          return reject(body);
        }

        return resolve(body);
      });
    });
  };
}
function count ( client ) { return function count ( realm ) { return new Promise ( ( resolve , reject ) => { const req = { auth : { bearer : privates . get ( client ) . accessToken } , json : true , url : ` ${ client . baseUrl } ${ realm } ` } ; request ( req , ( err , resp , body ) => { if ( err ) { return reject ( err ) ; } if ( resp . statusCode !== 200 ) { return reject ( body ) ; } return resolve ( body ) ; } ) ; } ) ; } ; }
A function to get the number of users in a realm.
@param {string} realmName - The name of the realm(not the realmID) - ex: master
@returns {Promise} A promise that will resolve with an integer - the number of users in the realm
@example
keycloakAdminClient(settings)
.then((client) => {
client.users.count(realmName)
.then((numberOfUsers) => {
console.log(numberOfUsers) // integer
})
})
A function to get the number of users in a realm .