// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the LabelService.
LabelServiceInterface labelService = user.getService(DfpService.V201311.LABEL_SERVICE);
// Create statement text to select active labels.
Statement filterStatement = new StatementBuilder("WHERE isActive = :isActive LIMIT 500")
.putValue("isActive", true).toStatement();
// Get the labels by statement.
LabelPage page =
labelService.getLabelsByStatement(filterStatement);
if (page.getResults() != null) {
Label[] labels = page.getResults();
// Update each local label object by updating its description.
for (Label label : labels) {
label.setDescription("These labels are updated.");
}
// Update the labels on the server.
labels = labelService.updateLabels(labels);
if (labels != null) {
for (Label label : labels) {
System.out.println("A label with ID \"" + label.getId()
+ "\" and name \"" + label.getName() + "\" was updated.");