// Create ad group criterion with updated bid.
Criterion criterion = new Placement();
criterion.setId(placementId);
BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();
biddableAdGroupCriterion.setAdGroupId(adGroupId);
biddableAdGroupCriterion.setCriterion(criterion);
// Create bids.
BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
CpmBid bid = new CpmBid();
bid.setBid(new Money(null, 10000000L));
biddingStrategyConfiguration.setBids(new Bids[] {bid});
biddableAdGroupCriterion.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
// 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.
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()
+ "\", and bid \""
+ ((CpmBid) biddableAdGroupCriterion.getBiddingStrategyConfiguration().getBids()[0])
.getBid().getMicroAmount() + "\" was updated.");
}
}
}