public static void runExample(
      Dfareporting reporting,
      long profileId,
      String adName,
      long campaignId,
      long creativeId,
      long placementId)
      throws Exception {
    // Retrieve the campaign.
    Campaign campaign = reporting.campaigns().get(profileId, campaignId).execute();

    // Create a click-through URL.
    ClickThroughUrl clickThroughUrl = new ClickThroughUrl();
    clickThroughUrl.setDefaultLandingPage(true);

    // Create a creative assignment.
    CreativeAssignment creativeAssignment = new CreativeAssignment();
    creativeAssignment.setActive(true);
    creativeAssignment.setCreativeId(creativeId);
    creativeAssignment.setClickThroughUrl(clickThroughUrl);

    // Create a placement assignment.
    PlacementAssignment placementAssignment = new PlacementAssignment();
    placementAssignment.setActive(true);
    placementAssignment.setPlacementId(placementId);

    // Create a creative rotation.
    CreativeRotation creativeRotation = new CreativeRotation();
    creativeRotation.setCreativeAssignments(ImmutableList.of(creativeAssignment));

    // Create a delivery schedule.
    DeliverySchedule deliverySchedule = new DeliverySchedule();
    deliverySchedule.setImpressionRatio(1L);
    deliverySchedule.setPriority("AD_PRIORITY_01");

    DateTime startDate = new DateTime(new Date());
    DateTime endDate = campaign.getEndDate();

    // Create a rotation group.
    Ad rotationGroup = new Ad();
    rotationGroup.setActive(true);
    rotationGroup.setCampaignId(campaignId);
    rotationGroup.setCreativeRotation(creativeRotation);
    rotationGroup.setDeliverySchedule(deliverySchedule);
    rotationGroup.setStartTime(startDate);
    rotationGroup.setEndTime(endDate);
    rotationGroup.setName(adName);
    rotationGroup.setPlacementAssignments(ImmutableList.of(placementAssignment));
    rotationGroup.setType("AD_SERVING_STANDARD_AD");

    // Insert the rotation group.
    Ad result = reporting.ads().insert(profileId, rotationGroup).execute();

    // Display the new ad ID.
    System.out.printf("Ad with ID %d was created.%n", result.getId());
  }
  public static void runExample(Dfareporting reporting, long profileId, long reportId)
      throws Exception {
    // Delete the report.
    reporting.reports().delete(profileId, reportId).execute();

    // Display the new report ID.
    System.out.printf("Report with ID %d was successfully deleted.%n", reportId);
  }
  public static void runExample(
      Dfareporting reporting,
      long profileId,
      String creativeGroupName,
      int groupNumber,
      long advertiserId)
      throws Exception {
    // Create the creative group.
    CreativeGroup creativeGroup = new CreativeGroup();
    creativeGroup.setName(creativeGroupName);
    creativeGroup.setGroupNumber(groupNumber);
    creativeGroup.setAdvertiserId(advertiserId);

    // Insert the creative group.
    CreativeGroup result = reporting.creativeGroups().insert(profileId, creativeGroup).execute();

    // Display the new creative group ID.
    System.out.printf("Creative group with ID %d was created.%n", result.getId());
  }