// Set RichMedia ad type
thirdPartyRedirectAd.setRichMediaAdType(RichMediaAdRichMediaAdType.fromValue("STANDARD"));
// Create ad group ad.
AdGroupAd adGroupAd = new AdGroupAd();
adGroupAd.setAdGroupId(adGroupId);
adGroupAd.setAd(thirdPartyRedirectAd);
// Create operations.
AdGroupAdOperation adGroupAdOperation = new AdGroupAdOperation();
adGroupAdOperation.setOperand(adGroupAd);
adGroupAdOperation.setOperator(Operator.ADD);
// Create In Stream ad.
ThirdPartyRedirectAd inStreamAd = new ThirdPartyRedirectAd();
inStreamAd.setName("Cruise to Mars #" + System.currentTimeMillis());
inStreamAd.setUrl("http://www.example.com");
inStreamAd.setSourceUrl("http://www.example.com");
inStreamAd.setAdDuration(15000);
inStreamAd.setUrl(
"http://ad.doubleclick.net/pfadx/N270.126913.6102203221521/B3876671.21;dcadv=2215309;sz=0x0;ord=%5btimestamp%5d;dcmt=text/xml");
inStreamAd.setCertifiedVendorFormatId(303L);
inStreamAd.setRichMediaAdType(RichMediaAdRichMediaAdType.fromValue("IN_STREAM_VIDEO"));
// Create ad group ad.
AdGroupAd adGroupAd2 = new AdGroupAd();
adGroupAd2.setAdGroupId(adGroupId);
adGroupAd2.setAd(inStreamAd);
// Create operations.
AdGroupAdOperation adGroupAdOperation2 = new AdGroupAdOperation();
adGroupAdOperation2.setOperand(adGroupAd2);
adGroupAdOperation2.setOperator(Operator.ADD);