}
public static void runExample(
AdWordsServices adWordsServices, AdWordsSession session, Long campaignId) throws Exception {
// Get the VideoCampaignService.
VideoCampaignServiceInterface videoCampaignService =
adWordsServices.get(session, VideoCampaignServiceInterface.class);
// Set min date time to be January 1st of the current year.
String minDateTime = new DateTime().toString("yyyy0101");
// Set max date time to the current date.
String maxDateTime = new DateTime().toString("yyyyMMdd");
// Create selector.
StatsSelector statsSelector = new StatsSelector();
statsSelector.setDateRange(new DateRange(minDateTime, maxDateTime));
statsSelector.setSegmentationDimensions(
new SegmentationDimension[] {SegmentationDimension.DATE_MONTH});
statsSelector.setMetrics(
new Metric[] {Metric.VIEWS, Metric.COST, Metric.AVERAGE_CPV});
statsSelector.setSummaryTypes(
new VideoEntityStatsSummaryType[] {VideoEntityStatsSummaryType.ALL});
statsSelector.setSegmentedSummaryType(VideoEntityStatsSummaryType.ALL);
int offset = 0;
VideoCampaignSelector selector = new VideoCampaignSelector();
selector.setStatsSelector(statsSelector);
selector.setIds(new long[] {campaignId});
selector.setPaging(new Paging(offset, PAGE_SIZE));
VideoCampaignPage page;
do {
// Get all campaigns.
page = videoCampaignService.get(selector);
// Display campaigns.
if (page.getEntries() != null) {
for (VideoCampaign videoCampaign : page.getEntries()) {
System.out.printf("Campaign id %d, name '%s' and status '%s'%n",