// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the InventoryService.
InventoryServiceInterface inventoryService =
user.getService(DfpService.V201208.INVENTORY_SERVICE);
// Get the NetworkService.
NetworkServiceInterface networkService =
user.getService(DfpService.V201208.NETWORK_SERVICE);
// Get the effective root ad unit ID of the network.
String effectiveRootAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();
// Create a statement to select the children of the effective root ad
// unit.
Statement filterStatement = new StatementBuilder("WHERE parentId = :id LIMIT 500")
.putValue("id", effectiveRootAdUnitId).toStatement();
// Get ad units by statement.
AdUnitPage page = inventoryService.getAdUnitsByStatement(filterStatement);
if (page.getResults() != null) {
int i = page.getStartIndex();
for (AdUnit adUnit : page.getResults()) {
System.out.println(i + ") Ad unit with ID \"" + adUnit.getId()