Created
December 19, 2017 23:01
-
-
Save allenmichael/4ce464329243c4e5cfcd2e3af3731f13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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