* @param campaignId the id of the parent campaign
* @return the ID of the created ad group
*/
public long createAdGroup(long campaignId) throws Exception {
// Get the AdGroupService.
AdGroupServiceInterface adGroupService;
adGroupService = user.getService(AdWordsService.V201008.ADGROUP_SERVICE);
// Create ad group.
AdGroup adGroup = new AdGroup();
adGroup.setName("Earth to Mars Cruises #" + System.currentTimeMillis());
adGroup.setStatus(AdGroupStatus.ENABLED);
adGroup.setCampaignId(campaignId);
// Create ad group bid.
ManualCPCAdGroupBids adGroupBids = new ManualCPCAdGroupBids();
adGroupBids.setKeywordMaxCpc(new Bid(new Money(null, 10000000L)));
adGroup.setBids(adGroupBids);
// Create operations.
AdGroupOperation operation = new AdGroupOperation();
operation.setOperand(adGroup);
operation.setOperator(Operator.ADD);
AdGroupOperation[] operations = new AdGroupOperation[] {operation};
// Add ad group and return AdGroup ID.
return adGroupService.mutate(operations).getValue()[0].getId();
}