// Create ad group criterion with updated bid.
Criterion criterion = new Criterion();
criterion.setId(criterionId);
BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();
biddableAdGroupCriterion.setAdGroupId(adGroupId);
biddableAdGroupCriterion.setCriterion(criterion);
BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration();
CpcBid cpcBid = new CpcBid();
cpcBid.setBid(new Money(null, 1000000L));
biddingConfig.setBids(new Bids[] {cpcBid});
biddableAdGroupCriterion.setBiddingStrategyConfiguration(biddingConfig);
// 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;
CpcBid bid =
(CpcBid) biddableAdGroupCriterion.getBiddingStrategyConfiguration().getBids(0);
System.out.println("Ad group criterion with ad group id \""
+ biddableAdGroupCriterion.getAdGroupId() + "\", criterion id \""
+ biddableAdGroupCriterion.getCriterion().getId() + "\", type \""
+ biddableAdGroupCriterion.getCriterion().getCriterionType()
+ "\" was updated. Current bids are \"" + bid.getBid().getMicroAmount() + "\".");
}
}
} else {
System.out.println("No ad group criteria were updated.");