Runs the example.

@param adWordsServices the services factory.
@param session the session.
@throws ApiException if the API request failed with one or more service errors.
@throws RemoteException if the API request failed due to other errors.
357134
public static void runExample(
      AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException {
    // Get the ConversionTrackerService.
    ConversionTrackerServiceInterface service =
        adWordsServices.get(session, ConversionTrackerServiceInterface.class);

    List<ConversionTracker> conversionTrackers = new ArrayList<>();

    // Create an AdWords conversion tracker.
    AdWordsConversionTracker adWordsConversionTracker = new AdWordsConversionTracker();
    adWordsConversionTracker.setName("Earth to Mars Cruises Conversion # "
        + System.currentTimeMillis());
    adWordsConversionTracker.setCategory(ConversionTrackerCategory.DEFAULT);

    // You can optionally provide these field(s).
    adWordsConversionTracker.setStatus(ConversionTrackerStatus.ENABLED);
    adWordsConversionTracker.setViewthroughLookbackWindow(15);
    adWordsConversionTracker.setDefaultRevenueValue(1d);
    adWordsConversionTracker.setAlwaysUseDefaultRevenueValue(Boolean.TRUE);
    conversionTrackers.add(adWordsConversionTracker);

    // Create an upload conversion for offline conversion imports.
    UploadConversion uploadConversion = new UploadConversion();
    // Set an appropriate category. This field is optional, and will be set to
    // DEFAULT if not mentioned.
    uploadConversion.setCategory(ConversionTrackerCategory.LEAD);
    uploadConversion.setName("Upload Conversion #" + System.currentTimeMillis());
    uploadConversion.setViewthroughLookbackWindow(30);
    uploadConversion.setCtcLookbackWindow(90);

    // Optional: Set the default currency code to use for conversions
    // that do not specify a conversion currency. This must be an ISO 4217
    // 3-character currency code such as "EUR" or "USD".
    // If this field is not set on this UploadConversion, AdWords will use
    // the account's currency.
    uploadConversion.setDefaultRevenueCurrencyCode("EUR");

    // Optional: Set the default revenue value to use for conversions
    // that do not specify a conversion value. Note that this value
    // should NOT be in micros.
    uploadConversion.setDefaultRevenueValue(2.50);
    // Optional: To upload fractional conversion credits, mark the upload conversion
    // as externally attributed. See
    // https://developers.google.com/adwords/api/docs/guides/conversion-tracking#importing_externally_attributed_conversions
    // to learn more about importing externally attributed conversions.

    // uploadConversion.setIsExternallyAttributed(true);

    conversionTrackers.add(uploadConversion);

    // Create operations.
    List<ConversionTrackerOperation> operations =
        conversionTrackers.stream()
            .map(
                conversionTracker -> {
                  ConversionTrackerOperation operation = new ConversionTrackerOperation();
                  operation.setOperator(Operator.ADD);
                  operation.setOperand(conversionTracker);
                  return operation;
                })
            .collect(Collectors.toList());

    // Add the conversions.
    ConversionTrackerReturnValue result =
        service.mutate(operations.toArray(new ConversionTrackerOperation[operations.size()]));

    // Display conversion.
    for (ConversionTracker conversionTracker : result.getValue()) {
      System.out.printf(
          "Conversion with ID %d, name '%s', status '%s', " + "category '%s' was added.%n",
          conversionTracker.getId(),
          conversionTracker.getName(),
          conversionTracker.getStatus(),
          conversionTracker.getCategory());
      if (conversionTracker instanceof AdWordsConversionTracker) {
        System.out.printf(
            "Google global site tag:%n%s%n%n", conversionTracker.getGoogleGlobalSiteTag());
        System.out.printf(
            "Google event snippet:%n%s%n%n", conversionTracker.getGoogleEventSnippet());
      }
    }
  }
60581
public static void runExample(
      AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException {
    // Get the ConstantDataService.
    ConstantDataServiceInterface constantDataService =
        adWordsServices.get(session, ConstantDataServiceInterface.class);

    // Get all carriers.
    Carrier[] carriers = constantDataService.getCarrierCriterion();

    // Display results.
    for (Carrier carrier : carriers) {
      System.out.printf("Carrier with name '%s', ID %d, and country code '%s' was found.%n",
          carrier.getName(), carrier.getId(), carrier.getCountryCode());
    }

    // Get all languages.
    Language[] languages = constantDataService.getLanguageCriterion();

    // Display results.
    for (Language language : languages) {
      System.out.printf("Language with name '%s' and ID %d was found.%n", language.getName(),
          language.getId());
    }
  }
1125779
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the ReportService.
    ReportServiceInterface reportService =
        adManagerServices.get(session, ReportServiceInterface.class);

    // Create report query.
    ReportQuery reportQuery = new ReportQuery();
    reportQuery.setDimensions(new Dimension[] {Dimension.DATE, Dimension.ORDER_ID});
    reportQuery.setColumns(new Column[] {Column.AD_SERVER_IMPRESSIONS});

    // Set the dynamic date range type or a custom start and end date.
    reportQuery.setDateRangeType(DateRangeType.LAST_WEEK);

    // Create report job.
    ReportJob reportJob = new ReportJob();
    reportJob.setReportQuery(reportQuery);

    // Run report job.
    reportJob = reportService.runReportJob(reportJob);

    // Create report downloader.
    final ReportDownloader reportDownloader =
        new ReportDownloader(reportService, reportJob.getId());

    reportDownloader.whenReportReady(
        new ReportCallback() {
          @Override
          public void onSuccess() {
            try {
              // Change to your file location.
              File file = File.createTempFile("async-report-", ".csv.gz");

              System.out.printf("Downloading report to %s ...", file.toString());

              // Download the report.
              ReportDownloadOptions options = new ReportDownloadOptions();
              options.setExportFormat(ExportFormat.CSV_DUMP);
              options.setUseGzipCompression(true);
              URL url = reportDownloader.getDownloadUrl(options);
              Resources.asByteSource(url).copyTo(Files.asByteSink(file));

              System.out.println("done.");
            } catch (IOException e) {
              System.err.println("Failed to write report.");
            }
          }

          @Override
          public void onInterruption() {
            System.err.println("Report download interupted.");
          }

          @Override
          public void onFailure() {
            System.err.println("Report download failed.");
          }

          @Override
          public void onException(Exception e) {
            System.err.println("Report download failed.");
            e.printStackTrace();
          }
        });
  }
66192
public static void runExample(AdWordsServicesInterface adWordsServices,
      AdWordsSession session) throws RemoteException {
    // Get the AdGroupBidModifierService.
    AdGroupBidModifierServiceInterface adGroupBidModifierService =
        adWordsServices.get(session, AdGroupBidModifierServiceInterface.class);

    // Create selector.
    Selector selector = new SelectorBuilder()
        .fields(
            AdGroupBidModifierField.CampaignId,
            AdGroupBidModifierField.AdGroupId,
            AdGroupBidModifierField.BidModifier,
            AdGroupBidModifierField.Id)
        .offset(0)
        .limit(PAGE_SIZE)
        .build();

    AdGroupBidModifierPage page = adGroupBidModifierService.get(selector);
    if (page.getEntries() != null) {
      for (AdGroupBidModifier bidModifierResult : page.getEntries()) {
        String bidModifierValue =
            bidModifierResult.getBidModifier() != null
                ? bidModifierResult.getBidModifier().toString()
                : "unset";
        System.out.printf("Campaign ID %d, AdGroup ID %d, Criterion ID %d, "
            + "has ad group level modifier: %s%n",
            bidModifierResult.getCampaignId(),
            bidModifierResult.getAdGroupId(),
            bidModifierResult.getCriterion().getId(),
            bidModifierValue);
      }
    } else {
      System.out.println("No ad group level bid modifiers were found.");
    }
  }
1250649
private static List<Feed> getFeeds(
      AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException {
    FeedServiceInterface feedService = adWordsServices.get(session, FeedServiceInterface.class);
    String query = "SELECT Id, Name, Attributes WHERE Origin = 'USER' AND FeedStatus = 'ENABLED'";

    List<Feed> feeds = new ArrayList<>();
    int offset = 0;
    FeedPage feedPage;

    do {
      String pageQuery = String.format(query + " LIMIT %d, %d", offset, PAGE_SIZE);
      feedPage = feedService.query(pageQuery);
      if (feedPage.getEntries() != null) {
        feeds.addAll(Arrays.asList(feedPage.getEntries()));
      }
      offset += PAGE_SIZE;
    } while (offset < feedPage.getTotalNumEntries());

    return feeds;
  }
282768
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the CompanyService.
    CompanyServiceInterface companyService =
        adManagerServices.get(session, CompanyServiceInterface.class);

    // Create an advertiser.
    Company advertiser = new Company();
    advertiser.setName("Advertiser #" + new Random().nextInt(Integer.MAX_VALUE));
    advertiser.setType(CompanyType.ADVERTISER);

    // Create an agency.
    Company agency = new Company();
    agency.setName("Agency #" + new Random().nextInt(Integer.MAX_VALUE));
    agency.setType(CompanyType.AGENCY);

    // Create the companies on the server.
    Company[] companies = companyService.createCompanies(new Company[] {advertiser, agency});

    for (Company createdCompany : companies) {
      System.out.printf(
          "A company with ID %d, name '%s', and type '%s' was created.%n",
          createdCompany.getId(), createdCompany.getName(), createdCompany.getType());
    }
  }
288735
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session)
      throws RemoteException {
    // Get the CampaignService.
    CampaignServiceInterface campaignService =
        adWordsServices.get(session, CampaignServiceInterface.class);

    // Get the CustomerSyncService.
    CustomerSyncServiceInterface customerSyncService =
        adWordsServices.get(session, CustomerSyncServiceInterface.class);

    // Get a list of all campaign IDs.
    List<Long> campaignIds = new ArrayList<>();
    Selector selector = new SelectorBuilder()
        .fields(CampaignField.Id)
        .build();
    CampaignPage campaigns = campaignService.get(selector);
    if (campaigns.getEntries() != null) {
      Arrays.stream(campaigns.getEntries()).forEach(campaign -> campaignIds.add(campaign.getId()));
    }

    // Create date time range for the past 24 hours.
    DateTimeRange dateTimeRange = new DateTimeRange();
    dateTimeRange.setMin(new SimpleDateFormat("yyyyMMdd HHmmss").format(new Date(System
        .currentTimeMillis() - 1000L * 60 * 60 * 24)));
    dateTimeRange.setMax(new SimpleDateFormat("yyyyMMdd HHmmss").format(new Date()));

    // Create selector.
    CustomerSyncSelector customerSyncSelector = new CustomerSyncSelector();
    customerSyncSelector.setDateTimeRange(dateTimeRange);
    customerSyncSelector
        .setCampaignIds(ArrayUtils.toPrimitive(campaignIds.toArray(new Long[] {})));

    // Get all account changes for campaign.
    CustomerChangeData accountChanges = customerSyncService.get(customerSyncSelector);

    // Display changes.
    if (accountChanges != null && accountChanges.getChangedCampaigns() != null) {
      System.out.printf("Most recent change: %s%n", accountChanges.getLastChangeTimestamp());
      for (CampaignChangeData campaignChanges : accountChanges.getChangedCampaigns()) {
        System.out.printf("Campaign with ID %d was changed:%n", campaignChanges.getCampaignId());
        System.out.printf("\tCampaign changed status: '%s'%n", 
            campaignChanges.getCampaignChangeStatus());
        if (!ChangeStatus.NEW.equals(campaignChanges.getCampaignChangeStatus())) {
          System.out.printf("\tAdded campaign criteria: %s%n",
              getFormattedList(campaignChanges.getAddedCampaignCriteria()));
          System.out.printf("\tRemoved campaign criteria: %s%n",
              getFormattedList(campaignChanges.getRemovedCampaignCriteria()));

          if (campaignChanges.getChangedAdGroups() != null) {
            for (AdGroupChangeData adGroupChanges : campaignChanges.getChangedAdGroups()) {
              System.out.printf("\tAd group with ID %d was changed:%n",
                  adGroupChanges.getAdGroupId());
              System.out.printf("\t\tAd group changed status: %s%n",
                  adGroupChanges.getAdGroupChangeStatus());
              if (!ChangeStatus.NEW.equals(adGroupChanges.getAdGroupChangeStatus())) {
                System.out.printf("\t\tAds changed: %s%n",
                    getFormattedList(adGroupChanges.getChangedAds()));
                System.out.printf("\t\tCriteria changed: %s%n",
                    getFormattedList(adGroupChanges.getChangedCriteria()));
                System.out.printf("\t\tCriteria removed: %s%n",
                    getFormattedList(adGroupChanges.getRemovedCriteria()));
              }
            }
          }
        }
        System.out.println("");
      }
    } else {
      System.out.println("No account changes were found.");
    }
  }
418097
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the ContentService.
    ContentServiceInterface contentService =
        adManagerServices.get(session, ContentServiceInterface.class);

    // Create a statement to get all content.
    StatementBuilder statementBuilder =
        new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

    // Default for total result set size.
    int totalResultSetSize = 0;

    do {
      // Get content by statement.
      ContentPage page = contentService.getContentByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (Content content : page.getResults()) {
          System.out.printf(
              "%d) Content with ID %d and name '%s' was found.%n",
              i++, content.getId(), content.getName());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }
297110
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the PlacementService.
    PlacementServiceInterface placementService =
        adManagerServices.get(session, PlacementServiceInterface.class);

    // Get all ad units.
    List<AdUnit> adUnits = getAllAdUnits(adManagerServices, session);

    // Partition ad units by their size.
    Set<String> mediumSquareAdUnitIds = Sets.newHashSet();
    Set<String> skyscraperAdUnitIds = Sets.newHashSet();
    Set<String> bannerAdUnitIds = Sets.newHashSet();

    for (AdUnit adUnit : adUnits) {
      if (adUnit.getParentId() != null && adUnit.getAdUnitSizes() != null) {
        for (AdUnitSize adUnitSize : adUnit.getAdUnitSizes()) {
          Size size = adUnitSize.getSize();
          if (size.getWidth() == 300 && size.getHeight() == 250) {
            mediumSquareAdUnitIds.add(adUnit.getId());
          } else if (size.getWidth() == 120 && size.getHeight() == 600) {
            skyscraperAdUnitIds.add(adUnit.getId());
          } else if (size.getWidth() == 468 && size.getHeight() == 60) {
            bannerAdUnitIds.add(adUnit.getId());
          }
        }
      }
    }

    List<Placement> placementsToCreate = new ArrayList<>();

    // Only create placements with one or more ad unit.
    if (!mediumSquareAdUnitIds.isEmpty()) {
      // Create medium square placement.
      Placement mediumSquareAdUnitPlacement = new Placement();
      mediumSquareAdUnitPlacement.setName(
          "Medium Square AdUnit Placement #" + new Random().nextInt(Integer.MAX_VALUE));
      mediumSquareAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 300x250");
      mediumSquareAdUnitPlacement.setTargetedAdUnitIds(
          mediumSquareAdUnitIds.toArray(new String[] {}));

      placementsToCreate.add(mediumSquareAdUnitPlacement);
    }

    if (!skyscraperAdUnitIds.isEmpty()) {
      // Create skyscraper placement.
      Placement skyscraperAdUnitPlacement = new Placement();
      skyscraperAdUnitPlacement.setName(
          "Skyscraper AdUnit Placement #" + new Random().nextInt(Integer.MAX_VALUE));
      skyscraperAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 120x600");
      skyscraperAdUnitPlacement.setTargetedAdUnitIds(skyscraperAdUnitIds.toArray(new String[] {}));
      placementsToCreate.add(skyscraperAdUnitPlacement);
    }

    if (!bannerAdUnitIds.isEmpty()) {
      // Create banner placement.
      Placement bannerAdUnitPlacement = new Placement();
      bannerAdUnitPlacement.setName(
          "Banner AdUnit Placement #" + new Random().nextInt(Integer.MAX_VALUE));
      bannerAdUnitPlacement.setDescription(
          "Contains ad units that can hold creatives of size 468x60");
      bannerAdUnitPlacement.setTargetedAdUnitIds(bannerAdUnitIds.toArray(new String[] {}));
      placementsToCreate.add(bannerAdUnitPlacement);
    }

    if (!placementsToCreate.isEmpty()) {
      // Create the placements on the server.
      Placement[] placements =
          placementService.createPlacements(placementsToCreate.toArray(new Placement[] {}));

      for (Placement createdPlacement : placements) {
        System.out.printf(
            "A placement with ID %d, name '%s', and containing ad units [%s] was created.%n",
            createdPlacement.getId(),
            createdPlacement.getName(),
            Joiner.on(", ").join(createdPlacement.getTargetedAdUnitIds()));
      }
    } else {
      System.out.println("No placements were created.");
    }
  }
482759
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the CdnConfigurationService.
    CdnConfigurationServiceInterface cdnConfigurationService =
        adManagerServices.get(session, CdnConfigurationServiceInterface.class);

    // Make CDN configuration objects.
    // Only LIVE_STREAM_SOURCE_CONTENT is currently supported by the API.
    // Basic example with no security policies.
    CdnConfiguration cdnConfigurationWithoutSecurityPolicy = new CdnConfiguration();

    SecurityPolicySettings noSecurityPolicy = new SecurityPolicySettings();
    noSecurityPolicy.setSecurityPolicyType(SecurityPolicyType.NONE);
    MediaLocationSettings mediaLocationSettings = new MediaLocationSettings();
    mediaLocationSettings.setUrlPrefix("example.google.com");
    mediaLocationSettings.setSecurityPolicy(noSecurityPolicy);

    SourceContentConfiguration sourceContentConfigWithNoSecurityPolicy =
        new SourceContentConfiguration();
    sourceContentConfigWithNoSecurityPolicy.setIngestSettings(mediaLocationSettings);
    sourceContentConfigWithNoSecurityPolicy.setDefaultDeliverySettings(mediaLocationSettings);

    cdnConfigurationWithoutSecurityPolicy.setName("ApiConfig1");
    cdnConfigurationWithoutSecurityPolicy.setCdnConfigurationType(
        CdnConfigurationType.LIVE_STREAM_SOURCE_CONTENT);
    cdnConfigurationWithoutSecurityPolicy.setSourceContentConfiguration(
        sourceContentConfigWithNoSecurityPolicy);

    // Complex example with security policies.
    CdnConfiguration cdnConfigurationWithSecurityPolicy = new CdnConfiguration();

    SecurityPolicySettings ingestSecurityPolicySettings = new SecurityPolicySettings();
    ingestSecurityPolicySettings.setSecurityPolicyType(SecurityPolicyType.AKAMAI);
    ingestSecurityPolicySettings.setDisableServerSideUrlSigning(false);
    ingestSecurityPolicySettings.setTokenAuthenticationKey("abc123");

    MediaLocationSettings ingestSettings = new MediaLocationSettings();
    ingestSettings.setUrlPrefix("example.google.com");
    ingestSettings.setSecurityPolicy(ingestSecurityPolicySettings);

    SecurityPolicySettings deliverySecurityPolicySettings = new SecurityPolicySettings();
    deliverySecurityPolicySettings.setSecurityPolicyType(SecurityPolicyType.AKAMAI);
    deliverySecurityPolicySettings.setDisableServerSideUrlSigning(false);
    deliverySecurityPolicySettings.setOriginForwardingType(OriginForwardingType.CONVENTIONAL);
    deliverySecurityPolicySettings.setOriginPathPrefix("/path/to/my/origin");

    MediaLocationSettings deliverySettings = new MediaLocationSettings();
    deliverySettings.setUrlPrefix("example.google.com");
    deliverySettings.setSecurityPolicy(deliverySecurityPolicySettings);

    SourceContentConfiguration sourceContentConfigurationWithSecurityPolicy =
        new SourceContentConfiguration();
    sourceContentConfigurationWithSecurityPolicy.setIngestSettings(ingestSettings);
    sourceContentConfigurationWithSecurityPolicy.setDefaultDeliverySettings(deliverySettings);

    cdnConfigurationWithSecurityPolicy.setName("ApiConfig2");
    cdnConfigurationWithSecurityPolicy.setCdnConfigurationType(
        CdnConfigurationType.LIVE_STREAM_SOURCE_CONTENT);
    cdnConfigurationWithSecurityPolicy.setSourceContentConfiguration(
        sourceContentConfigurationWithSecurityPolicy);

    // Create the cdnConfigurations on the server.
    CdnConfiguration[] cdnConfigurations =
        cdnConfigurationService.createCdnConfigurations(
            new CdnConfiguration[] {
              cdnConfigurationWithoutSecurityPolicy, cdnConfigurationWithSecurityPolicy
            });

    for (CdnConfiguration createdCdnConfiguration : cdnConfigurations) {
      System.out.printf(
          "A CDN configuration with ID %d and name '%s' was created.%n",
          createdCdnConfiguration.getId(), createdCdnConfiguration.getName());
    }
  }
1038961
public static void runExample(
      AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException {
    // Get the CampaignService.
    CampaignCriterionServiceInterface campaignCriterionService =
        adWordsServices.get(session, CampaignCriterionServiceInterface.class);

    int offset = 0;

    // Create selector.
    SelectorBuilder builder = new SelectorBuilder();
    Selector selector = builder
        .fields(
            CampaignCriterionField.CampaignId,
            CampaignCriterionField.Id,
            CampaignCriterionField.CriteriaType,
            CampaignCriterionField.PlatformName,
            CampaignCriterionField.LanguageName,
            CampaignCriterionField.LocationName,
            CampaignCriterionField.KeywordText)
        .in(CampaignCriterionField.CriteriaType, "KEYWORD", "LANGUAGE", "LOCATION", "PLATFORM")
        .offset(0)
        .limit(PAGE_SIZE)
        .build();

    CampaignCriterionPage page = null;
    do {
      page = campaignCriterionService.get(selector);

      if (page.getEntries() != null) {
        // Display campaigns.
        for (CampaignCriterion campaignCriterion : page.getEntries()) {
          System.out.printf("Campaign criterion with campaign ID %d, criterion ID %d, "
              + "and type '%s' was found.%n", campaignCriterion.getCampaignId(), campaignCriterion
              .getCriterion().getId(), campaignCriterion.getCriterion().getCriterionType());
        }
      } else {
        System.out.println("No campaign criteria were found.");
      }
      offset += PAGE_SIZE;
      selector = builder.increaseOffsetBy(PAGE_SIZE).build();
    } while (offset < page.getTotalNumEntries());
  }
1031982
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the TeamService.
    TeamServiceInterface teamService = adManagerServices.get(session, TeamServiceInterface.class);

    // Create a read/write team.
    Team readWriteTeam = new Team();
    readWriteTeam.setName("Read/write team #" + new Random().nextInt(Integer.MAX_VALUE));
    readWriteTeam.setTeamAccessType(TeamAccessType.READ_WRITE);
    readWriteTeam.setHasAllCompanies(false);
    readWriteTeam.setHasAllInventory(false);

    // Create a read-only team.
    Team readOnlyTeam = new Team();
    readOnlyTeam.setName("Read-only team #" + new Random().nextInt(Integer.MAX_VALUE));
    readOnlyTeam.setTeamAccessType(TeamAccessType.READ_ONLY);
    readOnlyTeam.setHasAllCompanies(false);
    readOnlyTeam.setHasAllInventory(false);

    // Create the teams on the server.
    Team[] teams = teamService.createTeams(new Team[] {readWriteTeam, readOnlyTeam});

    for (Team createdTeam : teams) {
      System.out.printf(
          "A team with ID %d and name '%s' was created.%n",
          createdTeam.getId(), createdTeam.getName());
    }
  }
476505
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the ExchangeRateService.
    ExchangeRateServiceInterface exchangeRateService =
        adManagerServices.get(session, ExchangeRateServiceInterface.class);

    // Create an exchange rate.
    ExchangeRate exchangeRate = new ExchangeRate();

    // Set the currency code.
    exchangeRate.setCurrencyCode("AUD");

    // Set the direction of the conversion (from the network currency).
    exchangeRate.setDirection(ExchangeRateDirection.FROM_NETWORK);

    // Set the conversion value as 1.5 (this value is multiplied by 10,000,000,000)
    exchangeRate.setExchangeRate(15000000000L);

    // Do not refresh exchange rate from Google data. Update manually only.
    exchangeRate.setRefreshRate(ExchangeRateRefreshRate.FIXED);

    // Create the exchange rate on the server.
    ExchangeRate[] exchangeRates =
        exchangeRateService.createExchangeRates(new ExchangeRate[] {exchangeRate});

    for (ExchangeRate createdExchangeRate : exchangeRates) {
      System.out.printf(
          "An exchange rate with ID %d, currency code '%s',"
              + " direction '%s', and exchange rate %.2f was created.%n",
          createdExchangeRate.getId(),
          createdExchangeRate.getCurrencyCode(),
          createdExchangeRate.getDirection().getValue(),
          (createdExchangeRate.getExchangeRate() / 10000000000f));
    }
  }
788807
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    CreativeTemplateServiceInterface creativeTemplateService =
        adManagerServices.get(session, CreativeTemplateServiceInterface.class);

    // Create a statement to select creative templates.
    StatementBuilder statementBuilder =
        new StatementBuilder()
            .where("type = :type")
            .orderBy("id ASC")
            .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
            .withBindVariableValue("type", CreativeTemplateType.SYSTEM_DEFINED.toString());

    // Retrieve a small amount of creative templates at a time, paging through
    // until all creative templates have been retrieved.
    int totalResultSetSize = 0;
    do {
      CreativeTemplatePage page =
          creativeTemplateService.getCreativeTemplatesByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        // Print out some information for each creative template.
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (CreativeTemplate creativeTemplate : page.getResults()) {
          System.out.printf(
              "%d) Creative template with ID %d and name '%s' was found.%n",
              i++, creativeTemplate.getId(), creativeTemplate.getName());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }
282322
@VisibleForTesting
  void setAuthenticationHeaders(Object soapClient, Map<String, Object> headerElements,
      AdWordsSession adWordsSession) throws AuthenticationException {
    authorizationHeaderHandler.setAuthorization(soapClient, adWordsSession);
  }
1110127
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the PlacementService.
    PlacementServiceInterface placementService =
        adManagerServices.get(session, PlacementServiceInterface.class);

    // Create a statement to get all placements.
    StatementBuilder statementBuilder = new StatementBuilder()
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

    // Default for total result set size.
    int totalResultSetSize = 0;

    do {
      // Get placements by statement.
      PlacementPage page =
          placementService.getPlacementsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (Placement placement : page.getResults()) {
          System.out.printf(
              "%d) Placement with ID %d and name '%s' was found.%n", i++,
              placement.getId(), placement.getName());
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }
1330642
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the LineItemCreativeAssociationService.
    LineItemCreativeAssociationServiceInterface licaService =
        adManagerServices.get(session, LineItemCreativeAssociationServiceInterface.class);

    // Create a statement to get all LICAs.
    StatementBuilder statementBuilder = new StatementBuilder()
        .orderBy("lineItemId ASC, creativeId ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

    // Default for total result set size.
    int totalResultSetSize = 0;

    do {
      // Get LICAs by statement.
      LineItemCreativeAssociationPage page =
          licaService.getLineItemCreativeAssociationsByStatement(statementBuilder.toStatement());

      if (page.getResults() != null) {
        totalResultSetSize = page.getTotalResultSetSize();
        int i = page.getStartIndex();
        for (LineItemCreativeAssociation lica : page.getResults()) {
          if (lica.getCreativeSetId() != null) {
            System.out.printf(
                "%d) LICA with line item ID %d and creative set ID %d was found.%n", i++,
                lica.getLineItemId(), lica.getCreativeSetId());
          } else {
            System.out.printf(
                "%d) LICA with line item ID %d and creative ID %d was found.%n", i++,
                lica.getLineItemId(), lica.getCreativeId());
          }
        }
      }

      statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }