// Get the SuggestedAdUnitService.
SuggestedAdUnitServiceInterface suggestedAdUnitService =
user.getService(DfpService.V201306.SUGGESTED_AD_UNIT_SERVICE);
// Set defaults for page and filterStatement.
SuggestedAdUnitPage page = new SuggestedAdUnitPage();
Statement filterStatement = new Statement();
int offset = 0;
do {
// Create a statement to get all suggested ad units.
filterStatement.setQuery("LIMIT 500 OFFSET " + offset);
// Get suggested ad units by statement.
page = suggestedAdUnitService.getSuggestedAdUnitsByStatement(filterStatement);
if (page.getResults() != null) {
int i = page.getStartIndex();
for (SuggestedAdUnit suggestedAdUnit : page.getResults()) {
System.out.println(i + ") Suggested ad unit with ID \"" + suggestedAdUnit.getId()
+ "\", and number of requests \"" + suggestedAdUnit.getNumRequests()
+ "\" was found.");
i++;
}
}
offset += 500;
} while (offset < page.getTotalResultSetSize());
System.out.println("Number of results found: " + page.getTotalResultSetSize());
} catch (Exception e) {
e.printStackTrace();
}
}