Skip to content

Instantly share code, notes, and snippets.

@allenmichael
Created December 19, 2017 23:01
Show Gist options
  • Save allenmichael/4ce464329243c4e5cfcd2e3af3731f13 to your computer and use it in GitHub Desktop.
Save allenmichael/4ce464329243c4e5cfcd2e3af3731f13 to your computer and use it in GitHub Desktop.
package com.box;
import com.box.sdk.BoxConfig;
import com.box.sdk.BoxDeveloperEditionAPIConnection;
import com.box.sdk.BoxUser;
import java.io.BufferedReader;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicInteger;
public class GetAllUsers {
public static void main(String[] args) throws Exception {
Path configPath = Paths.get("config.json");
try (BufferedReader reader = Files.newBufferedReader(configPath, Charset.forName("UTF-8"))) {
BoxConfig boxConfig = BoxConfig.readFrom(reader);
BoxDeveloperEditionAPIConnection serviceAccountClient = BoxDeveloperEditionAPIConnection
.getAppEnterpriseConnection(boxConfig);
Iterable<BoxUser.Info> users = BoxUser.getAllEnterpriseUsers(serviceAccountClient);
AtomicInteger counter = new AtomicInteger(0);
users.forEach((user) -> {
counter.addAndGet(1);
});
System.out.println(counter);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment