public static void runExample(
AdWordsServices adWordsServices, AdWordsSession session,
Long campaignId, Long targetingGroupId) throws Exception {
// Get the VideoTargetingGroupService.
VideoTargetingGroupServiceInterface videoTargetingGroupService =
adWordsServices.get(session, VideoTargetingGroupServiceInterface.class);
TargetingGroup targetingGroup = new TargetingGroup();
targetingGroup.setId(targetingGroupId);
targetingGroup.setCampaignId(campaignId);
Money amount = new Money();
amount.setMicroAmount(200000L);
VideoBid videoBid = new VideoBid();
videoBid.setAmount(amount);
VideoAdDisplayFormat_VideoBidMapEntry trueViewBid =
new VideoAdDisplayFormat_VideoBidMapEntry();
trueViewBid.setKey(VideoAdDisplayFormat.TRUE_VIEW_IN_DISPLAY);
trueViewBid.setValue(videoBid);
targetingGroup.setBidsByFormat(
new BidsByFormat(new VideoAdDisplayFormat_VideoBidMapEntry[] {trueViewBid}));
TargetingGroupOperation operation = new TargetingGroupOperation();
operation.setOperator(Operator.SET);
operation.setOperand(targetingGroup);
TargetingGroupReturnValue result =
videoTargetingGroupService.mutate(new TargetingGroupOperation[] {operation});
for (TargetingGroup targetingGroupResult : result.getValue()) {
System.out.printf("Targeting group with campaign id %d, "
+ "and targeting group id %d was updated.%n",
targetingGroupResult.getCampaignId(),