// Create ad group criterion with updated bid.
Criterion criterion = new Criterion();
criterion.setId(criterionId);
BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();
biddableAdGroupCriterion.setAdGroupId(adGroupId);
biddableAdGroupCriterion.setCriterion(criterion);
// Create operations.
AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
operation.setOperand(biddableAdGroupCriterion);
operation.setOperator(Operator.SET);
AdGroupCriterionOperation[] operations = new AdGroupCriterionOperation[] {operation};
// Update ad group criteria.
AdGroupCriterionReturnValue result = adGroupCriterionService.mutate(operations);
// Display ad group criteria.
if (result != null && result.getValue() != null) {
for (AdGroupCriterion adGroupCriterionResult : result.getValue()) {
if (adGroupCriterionResult instanceof BiddableAdGroupCriterion) {
biddableAdGroupCriterion = (BiddableAdGroupCriterion) adGroupCriterionResult;
System.out.println("Ad group criterion with ad group id \""
+ biddableAdGroupCriterion.getAdGroupId() + "\", criterion id \""
+ biddableAdGroupCriterion.getCriterion().getId() + "\", type \""
+ biddableAdGroupCriterion.getCriterion().getCriterionType() + "\""
+ " was updated.");
}
}
} else {
System.out.println("No ad group criteria were updated.");