public static void runExample(AdWordsServices adWordsServices,
AdWordsSession session, Long campaignId, String videoId)
throws Exception {
// Get the VideoAdService
VideoAdServiceInterface videoAdService =
adWordsServices.get(session, VideoAdServiceInterface.class);
// Create a new VideoAd.
VideoAd videoAd = new VideoAd();
videoAd.setCampaignId(campaignId);
videoAd.setName("Video ad #" + System.currentTimeMillis());
videoAd.setStatus(VideoAdStatus.PAUSED);
VideoAdDisplayFormat_VideoAdStatusMapEntry trueViewStatus =
new VideoAdDisplayFormat_VideoAdStatusMapEntry(
VideoAdDisplayFormat.TRUE_VIEW_IN_STREAM,
VideoAdStatus.ENABLED);
videoAd.setStatusByFormat(
new VideoAdDisplayFormat_VideoAdStatusMapEntry[] {trueViewStatus});
videoAd.setHeadline("Best headline");
videoAd.setDestinationUrl("http://www.example.com");
videoAd.setDisplayUrl("www.example.com");
videoAd.setDescription1("My favorite line 1");
videoAd.setDescription2("My favorite line 2");
videoAd.setVideoId(videoId);
VideoAdOperation operation = new VideoAdOperation();
operation.setOperand(videoAd);
operation.setOperator(Operator.ADD);
VideoAdOperation[] operations = new VideoAdOperation[] {operation};
VideoAdReturnValue result = videoAdService.mutate(operations);
for (VideoAd videoAdResult : result.getValue()) {
System.out.printf("Video ad with campaign id %d, "
+ "video ad id %d, and name '%s' was added.%n",
videoAdResult.getCampaignId(),