Runs the example.

@param adManagerServices 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.
356993
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the LabelService.
    LabelServiceInterface labelService =
        adManagerServices.get(session, LabelServiceInterface.class);

    // Create a competitive exclusion label.
    Label competitiveExclusionLabel = new Label();
    competitiveExclusionLabel.setName(
        "Car company label #" + new Random().nextInt(Integer.MAX_VALUE));
    competitiveExclusionLabel.setTypes(new LabelType[] {LabelType.COMPETITIVE_EXCLUSION});

    // Create an ad unit frequency cap label.
    Label adUnitFrequencyCapLabel = new Label();
    adUnitFrequencyCapLabel.setName(
        "Don't run too often label #" + new Random().nextInt(Integer.MAX_VALUE));
    adUnitFrequencyCapLabel.setTypes(new LabelType[] {LabelType.AD_UNIT_FREQUENCY_CAP});

    // Create the labels on the server.
    Label[] labels =
        labelService.createLabels(new Label[] {competitiveExclusionLabel, adUnitFrequencyCapLabel});

    for (Label createdLabel : labels) {
      System.out.printf("A label with ID %d and name '%s' was created.%n",
          createdLabel.getId(), createdLabel.getName());
    }
  }
87298
static ProductPartitionTreeImpl createAdGroupTree(AdWordsServicesInterface services,
      AdWordsSession session, Long adGroupId) throws ApiException, RemoteException {
    // Get the AdGroupCriterionService.
    AdGroupCriterionServiceInterface criterionService =
        services.get(session, AdGroupCriterionServiceInterface.class);

    SelectorBuilder selectorBuilder = new SelectorBuilder()
        .fields(REQUIRED_SELECTOR_FIELD_ENUMS.toArray(
            new AdGroupCriterionField[REQUIRED_SELECTOR_FIELD_ENUMS.size()]))
        .equals(AdGroupCriterionField.AdGroupId, adGroupId.toString())
        .equals(AdGroupCriterionField.CriteriaType, "PRODUCT_PARTITION")
        .in(
            AdGroupCriterionField.Status,
            UserStatus.ENABLED.getValue(),
            UserStatus.PAUSED.getValue())
        .limit(PAGE_SIZE);

    AdGroupCriterionPage adGroupCriterionPage;

    // A multimap from each product partition ID to its direct children.
    ListMultimap<Long, AdGroupCriterion> parentIdMap = LinkedListMultimap.create();
    int offset = 0;
    do {
      // Get the next page of results.
      adGroupCriterionPage = criterionService.get(selectorBuilder.build());

      if (adGroupCriterionPage != null && adGroupCriterionPage.getEntries() != null) {
        for (AdGroupCriterion adGroupCriterion : adGroupCriterionPage.getEntries()) {
          ProductPartition partition = (ProductPartition) adGroupCriterion.getCriterion();
          parentIdMap.put(partition.getParentCriterionId(), adGroupCriterion);
        }
        offset += adGroupCriterionPage.getEntries().length;
        selectorBuilder.increaseOffsetBy(PAGE_SIZE);
      }
    } while (offset < adGroupCriterionPage.getTotalNumEntries());

    // Construct the ProductPartitionTree from the parentIdMap.
    if (!parentIdMap.containsKey(null)) {
      Preconditions.checkState(parentIdMap.isEmpty(),
          "No root criterion found in the tree but the tree is not empty");
      return createEmptyAdGroupTree(adGroupId,
          getAdGroupBiddingStrategyConfiguration(services, session, adGroupId));
    }

    return createNonEmptyAdGroupTree(adGroupId, parentIdMap);
  }
625278
private static void createAdsWithCustomizations(AdWordsServicesInterface adWordsServices,
      AdWordsSession session, List<Long> adGroupIds, String feedName) throws RemoteException {
    // Get the AdGroupAdService.
    AdGroupAdServiceInterface adGroupAdService =
        adWordsServices.get(session, AdGroupAdServiceInterface.class);

    ExpandedTextAd textAd = new ExpandedTextAd();
    textAd.setHeadlinePart1(String.format("Luxury Cruise to {=%s.Name}", feedName));
    textAd.setHeadlinePart2(String.format("Only {=%s.Price}", feedName));
    textAd.setDescription(String.format("Offer ends in {=countdown(%s.Date)}!", feedName));
    textAd.setFinalUrls(new String[] {"http://www.example.com"});

    // We add the same ad to both ad groups. When they serve, they will show different values, since
    // they match different feed items.
    List<AdGroupAdOperation> adGroupAdOperations = new ArrayList<>();
    for (Long adGroupId : adGroupIds) {
      AdGroupAd adGroupAd = new AdGroupAd();
      adGroupAd.setAdGroupId(adGroupId);
      adGroupAd.setAd(textAd);

      AdGroupAdOperation adGroupAdOperation = new AdGroupAdOperation();
      adGroupAdOperation.setOperand(adGroupAd);
      adGroupAdOperation.setOperator(Operator.ADD);

      adGroupAdOperations.add(adGroupAdOperation);
    }

    AdGroupAdReturnValue adGroupAdReturnValue = adGroupAdService.mutate(
        adGroupAdOperations.toArray(new AdGroupAdOperation[adGroupAdOperations.size()]));

    for (AdGroupAd addedAd : adGroupAdReturnValue.getValue()) {
      System.out.printf("Created an ad with ID %d, type '%s' and status '%s'.%n",
          addedAd.getAd().getId(), addedAd.getAd().getAdType(), addedAd.getStatus());
    }
  }
74477
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the CustomTargetingService.
    CustomTargetingServiceInterface customTargetingService =
        adManagerServices.get(session, CustomTargetingServiceInterface.class);

    // Get all custom targeting keys.
    List<Long> customTargetingKeyIds = getAllCustomTargetingKeyIds(adManagerServices, session);

    // Create a statement to get all custom targeting values for a custom
    // targeting key.
    StatementBuilder statementBuilder =
        new StatementBuilder()
            .where("customTargetingKeyId = :customTargetingKeyId")
            .orderBy("id ASC")
            .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);

    int totalResultsCounter = 0;

    for (Long customTargetingKeyId : customTargetingKeyIds) {
      // Set the custom targeting key ID to select from.
      statementBuilder.withBindVariableValue("customTargetingKeyId", customTargetingKeyId);

      // Default for total result set size and offset.
      int totalResultSetSize = 0;
      statementBuilder.offset(0);

      do {
        // Get custom targeting values by statement.
        CustomTargetingValuePage page =
            customTargetingService.getCustomTargetingValuesByStatement(
                statementBuilder.toStatement());

        if (page.getResults() != null) {
          totalResultSetSize = page.getTotalResultSetSize();
          for (CustomTargetingValue customTargetingValue : page.getResults()) {
            System.out.printf(
                "%d) Custom targeting value with ID %d, belonging to key "
                    + "with ID %d, name '%s' and display name '%s' was found.%n",
                totalResultsCounter++,
                customTargetingValue.getId(),
                customTargetingValue.getCustomTargetingKeyId(),
                customTargetingValue.getName(),
                customTargetingValue.getDisplayName());
          }
        }

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

    System.out.printf("Number of results found: %d%n", totalResultsCounter);
  }
277575
@SuppressWarnings("unchecked") /* See constructor comments. */
  public void setHttpHeaders(Object soapClient, AdManagerSession adManagerSession) {
    Map<String, String> headersMap = Maps.newHashMap();
    soapClientHandler.putAllHttpHeaders(soapClient, headersMap);
  }
204595
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the UserService.
    UserServiceInterface userService = adManagerServices.get(session, UserServiceInterface.class);

    // Get the current user.
    User user = userService.getCurrentUser();

    System.out.printf(
        "User with ID %d, name '%s', email '%s', and role '%s' is the current user.%n",
        user.getId(), user.getName(), user.getEmail(), user.getRoleName());
  }
1266100
private static AdGroup createAdGroup(
      AdWordsServicesInterface adWordsServices, AdWordsSession session, Campaign campaign)
      throws RemoteException {
    // Get the AdGroupService.
    AdGroupServiceInterface adGroupService =
        adWordsServices.get(session, AdGroupServiceInterface.class);

    // Create ad group.
    AdGroup adGroup = new AdGroup();
    adGroup.setCampaignId(campaign.getId());
    adGroup.setName("Ad Group #" + System.currentTimeMillis());

    // Required: Set the ad group type to SHOPPING_SHOWCASE_ADS.
    adGroup.setAdGroupType(AdGroupType.SHOPPING_SHOWCASE_ADS);

    // Required: Set the ad group's bidding strategy configuration.
    // Note: Showcase ads require that the campaign has a ManualCpc BiddingStrategyConfiguration.
    BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();

    // Optional: Set the bids.
    Money bidAmount = new Money();
    bidAmount.setMicroAmount(100000L);
    CpcBid cpcBid = new CpcBid();
    cpcBid.setBid(bidAmount);
    biddingStrategyConfiguration.setBids(new Bids[] {cpcBid});

    adGroup.setBiddingStrategyConfiguration(biddingStrategyConfiguration);

    // Create operation.
    AdGroupOperation adGroupOperation = new AdGroupOperation();
    adGroupOperation.setOperand(adGroup);
    adGroupOperation.setOperator(Operator.ADD);

    // Make the mutate request.
    AdGroupReturnValue adGroupAddResult =
        adGroupService.mutate(new AdGroupOperation[] {adGroupOperation});

    return adGroupAddResult.getValue(0);
  }
592624
@Override
    public void addMBeanServers(Set<MBeanServerConnection> servers) {
        try {
            /*
			 * this.mbeanServer = AdminServiceFactory.getMBeanFactory().getMBeanServer();
			 */
            Class adminServiceClass = ClassUtil.classForName("com.ibm.websphere.management.AdminServiceFactory",getClass().getClassLoader());
            if (adminServiceClass != null) {
                Method getMBeanFactoryMethod = adminServiceClass.getMethod("getMBeanFactory", new Class[0]);
                Object mbeanFactory = getMBeanFactoryMethod.invoke(null);
                if (mbeanFactory != null) {
                    Method getMBeanServerMethod = mbeanFactory.getClass().getMethod("getMBeanServer", new Class[0]);
                    servers.add((MBeanServer) getMBeanServerMethod.invoke(mbeanFactory));
                }
            }
        }
        catch (InvocationTargetException ex) {
            // CNFE should be earlier
            throw new IllegalArgumentException(INTERNAL_ERROR_MSG,ex);
        } catch (IllegalAccessException ex) {
            throw new IllegalArgumentException(INTERNAL_ERROR_MSG,ex);
        } catch (NoSuchMethodException ex) {
            throw new IllegalArgumentException(INTERNAL_ERROR_MSG,ex);
        }
    }
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();
          }
        });
  }
659238
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    OrderServiceInterface orderService =
        adManagerServices.get(session, OrderServiceInterface.class);

    // Create a statement to select orders.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("status = :status and startDateTime >= :now and startDateTime <= :soon")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("status", OrderStatus.APPROVED.toString())
        .withBindVariableValue("now", DateTimes.toDateTime(Instant.now(), "America/New_York"))
        .withBindVariableValue("soon", DateTimes.toDateTime(Instant.now().plus(
            Duration.standardDays(5L)), "America/New_York"));

    // Retrieve a small amount of orders at a time, paging through
    // until all orders have been retrieved.
    int totalResultSetSize = 0;
    do {
      OrderPage page =
          orderService.getOrdersByStatement(statementBuilder.toStatement());

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

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

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }
1273930
@Override
    public void setRemoteServices(RemoteServices remoteServices) {
        final String methodName = "setRemoteServices(remoteServices)";
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, methodName + " cacheName=" + cacheName + " ERROR because it should not be called");
        }
    }
462345
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session)
      throws RemoteException {
    // Get the constant data service.
    ConstantDataServiceInterface constantDataService =
        adWordsServices.get(session, ConstantDataServiceInterface.class);
    
    Selector selector = new SelectorBuilder()
      .equals(ConstantDataField.Country, "US")
      .build();
    
    ProductBiddingCategoryData[] results =
        constantDataService.getProductBiddingCategoryData(selector);
    
    // List of top level category nodes.
    List<CategoryNode> rootCategories = new ArrayList<>();
    // Map of category ID to category node for all categories found in the results.
    Map<Long, CategoryNode> biddingCategories = Maps.newHashMap();
    
    for (ProductBiddingCategoryData productBiddingCategoryData : results) {
      Long id = productBiddingCategoryData.getDimensionValue().getValue();
      String name = productBiddingCategoryData.getDisplayValue(0).getValue();
      CategoryNode node = biddingCategories.get(id);
      if (node == null) {
        node = new CategoryNode(id, name);
        biddingCategories.put(id, node);
      } else if (node.name == null) {
        // Ensure that the name attribute for the node is set. Name will be null for nodes added
        // to biddingCategories as a result of being a parentNode below.
        node.name = name;
      }

      if (productBiddingCategoryData.getParentDimensionValue() != null
          && productBiddingCategoryData.getParentDimensionValue().getValue() != null) {
        Long parentId = productBiddingCategoryData.getParentDimensionValue().getValue();
        CategoryNode parentNode = biddingCategories.get(parentId);
        if (parentNode == null) {
          parentNode = new CategoryNode(parentId);
          biddingCategories.put(parentId, parentNode);
        }
        parentNode.children.add(node);
      } else {
        rootCategories.add(node);
      }
    }
    displayCategories(rootCategories, "");
  }
300318
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    ProposalServiceInterface proposalService =
        adManagerServices.get(session, ProposalServiceInterface.class);

    // Create a statement to select proposals.
    StatementBuilder statementBuilder = new StatementBuilder()
        .where("status = :status")
        .orderBy("id ASC")
        .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
        .withBindVariableValue("status", ProposalStatus.PENDING_APPROVAL.toString());

    // Retrieve a small amount of proposals at a time, paging through
    // until all proposals have been retrieved.
    int totalResultSetSize = 0;
    do {
      ProposalPage page =
          proposalService.getProposalsByStatement(statementBuilder.toStatement());

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

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

    System.out.printf("Number of results found: %d%n", totalResultSetSize);
  }
286139
public static void runExample(
      AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException {
    // Get the CampaignService.
    CampaignServiceInterface campaignService =
        adWordsServices.get(session, CampaignServiceInterface.class);

    ServiceQuery serviceQuery =
        new ServiceQuery.Builder()
            .fields(CampaignField.Id, CampaignField.Name, CampaignField.Status)
            .orderBy(CampaignField.Name)
            .limit(0, PAGE_SIZE)
            .build();

    CampaignPage page = null;
    do {
      serviceQuery.nextPage(page);
      // Get all campaigns.
      page = campaignService.query(serviceQuery.toString());

      // Display campaigns.
      if (page.getEntries() != null) {
        for (Campaign campaign : page.getEntries()) {
          System.out.printf("Campaign with name '%s' and ID %d was found.%n", campaign.getName(),
              campaign.getId());
        }
      } else {
        System.out.println("No campaigns were found.");
      }
    } while (serviceQuery.hasNext(page));
  }
1156878
@Override
	public void run()
    {
        log.info("Starting remote administration thread ...");

        try
        {
            LocalQueue inputQueue = engine.getLocalQueue(FFMQConstants.ADM_REQUEST_QUEUE);
            LocalQueue outputQueue = engine.getLocalQueue(FFMQConstants.ADM_REPLY_QUEUE);
            
            conn = new LocalQueueConnection(engine, null, null);
            session = conn.createQueueSession(true, Session.SESSION_TRANSACTED);
            receiver = session.createReceiver(inputQueue);
            sender = session.createSender(outputQueue);

            conn.start();

            // Flush input queue on startup
            inputQueue.purge(null);
            outputQueue.purge(null);
            
            // Enter listening loop
            notifyStartup();
            while (!stopRequired)
            {
                Message message = receiver.receive();
                if (message == null)
                    break; // Interrupted
                log.debug("Received message " + message);

                try
                {
                    // Process the command
                    String errorMsg = process(message);
    
                    // Build response message
                    Message response = session.createMessage();
                    response.setJMSCorrelationID(message.getJMSMessageID());
                    if (errorMsg != null)
                        response.setStringProperty(FFMQAdminConstants.ADM_HEADER_ERRMSG, errorMsg);
                    
                    sender.send(response,DeliveryMode.NON_PERSISTENT,Message.DEFAULT_PRIORITY,Message.DEFAULT_TIME_TO_LIVE);
                }
                catch (JMSException e)
                {
                    log.error("Cannot process admin command",e);
                }
                finally
                {
                    session.commit();
                }
            }
            
            log.debug("Remote administration thread has stopped");
        }
        catch (Throwable e)
        {
            log.fatal("Administration thread failed", e);
            notifyStartup();
        }
        finally
        {
            try
            {
                if (sender != null)
                    sender.close();
            }
            catch (JMSException e)
            {
            	ErrorTools.log(e, log);
            }

            try
            {
                if (receiver != null)
                    receiver.close();
            }
            catch (JMSException e)
            {
            	ErrorTools.log(e, log);
            }

            try
            {
                if (session != null)
                    session.close();
            }
            catch (JMSException e)
            {
            	ErrorTools.log(e, log);
            }

            try
            {
                if (conn != null)
                    conn.close();
            }
            catch (JMSException e)
            {
            	ErrorTools.log(e, log);
            }
        }
    }
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);
  }
6297
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
      throws RemoteException {
    // Get the NativeStyleService.
    NativeStyleServiceInterface nativeStyleService =
        adManagerServices.get(session, NativeStyleServiceInterface.class);

    String htmlSnippet =
            "<div id=\"adunit\" style=\"overflow: hidden;\">\n"
            + "  <img src='[%Thirdpartyimpressiontracker%]' style='display:none'>\n"
            + "  <div class='attribution'>Ad</div>\n"
            + "  <div class='image'>\n"
            + "    <a class='image-link' "
            + "href='%%CLICK_URL_UNESC%%[%Thirdpartyclicktracker%]%%DEST_URL%%' target='_top'>"
            + "<img src=\"[%Image%]\"></a>\n"
            + "  </div>\n"
            + "  <div class='app-icon'><img src=\"[%Appicon%]\"/></div>\n"
            + "  <div class='title'>\n"
            + "    <a class='title-link' "
            + "href='%%CLICK_URL_UNESC%%[%Thirdpartyclicktracker%]%%DEST_URL%%' "
            + "target='_top'>[%Headline%]</a>\n"
            + "  </div>\n"
            + "  <div class='reviews'></div>\n"
            + "  <div class='body'>\n"
            + "    <a class='body-link' "
            + "href='%%CLICK_URL_UNESC%%[%Thirdpartyclicktracker%]%%DEST_URL%%' "
            + "target='_top'>[%Body%]</a>\n"
            + "  </div>\n"
            + "  <div class='price'>[%Price%]</div>\n"
            + "  <div class='button'>\n"
            + "    <a class='button-link' "
            + "href='%%CLICK_URL_UNESC%%[%Thirdpartyclicktracker%]%%DEST_URL%%' "
            + "target='_top'>[%Calltoaction%]</a>\n"
            + "  </div>\n"
            + "</div>\n";

    String cssSnippet =
        "body {"
            + "    background-color: rgba(255, 255, 255, 1);"
            + "    font-family: \"Roboto-Regular\", sans-serif;"
            + "    font-weight: normal;"
            + "    font-size: 12px;"
            + "    line-height: 14px;"
            + "}"
            + ".attribution {"
            + "    background-color: rgba(236, 182, 0, 1);"
            + "    color: rgba(255, 255, 255, 1);"
            + "    font-size: 13px;"
            + "    display: table;"
            + "    margin: 4px 8px;"
            + "    padding: 0 3px;"
            + "    border-radius: 2px;"
            + "}"
            + ".image {"
            + "    text-align: center;"
            + "    margin: 8px;"
            + "}"
            + ".image img,"
            + ".image-link {"
            + "    width: 100%;"
            + "}"
            + ".app-icon {"
            + "    float: left;"
            + "    margin: 0 8px 4px 8px;"
            + "    height: 40px;"
            + "    width: 40px;"
            + "    background-color: transparent;"
            + "}"
            + ".app-icon img {"
            + "    height: 100%;"
            + "    width: 100%;"
            + "    border-radius: 20%;"
            + "}"
            + ".title {"
            + "    font-weight: bold;"
            + "    font-size: 14px;"
            + "    line-height: 20px;"
            + "    margin: 8px 8px 4px 8px;"
            + "}"
            + ".title a {"
            + "    color: rgba(112, 112, 112, 1);"
            + "    text-decoration: none;"
            + "}"
            + ".reviews {"
            + "    float: left;"
            + "}"
            + ".reviews svg {"
            + "    fill: rgba(0, 0, 0, 0.7);"
            + "}"
            + ".body {"
            + "    clear: left;"
            + "    margin: 8px;"
            + "}"
            + ".body a {"
            + "    color: rgba(110, 110, 110, 1);"
            + "    text-decoration: none;"
            + "}"
            + ".price {"
            + "    display: none;"
            + "}"
            + ".button {"
            + "    font-size: 14px;"
            + "    font-weight: bold;"
            + "    float: right;"
            + "    margin: 0px 16px 16px 0px;"
            + "    white-space: nowrap;"
            + "}"
            + ".button a {"
            + "    color: #2196F3;"
            + "    text-decoration: none;"
            + "}"
            + ".button svg {"
            + "    display: none;"
            + "}";

    // This is the creative template ID for the system-defined native app
    // install ad format, which we will create the native style from. Use
    // CreativeTemplateService.getCreativeTemplatesByStatement() and
    // CreativeTemplate.isNativeEligible to get other native ad formats
    // available in your network.
    long nativeAppInstallTemplateId = 10004400L;

    // Set the size for the native style.
    Size size = new Size();
    size.setWidth(300);
    size.setHeight(250);
    size.setIsAspectRatio(false);

    // Create a style for native app install ads.
    NativeStyle nativeStyle = new NativeStyle();
    nativeStyle.setName("Native style #" + new Random().nextInt(Integer.MAX_VALUE));
    nativeStyle.setCreativeTemplateId(nativeAppInstallTemplateId);
    nativeStyle.setSize(size);
    nativeStyle.setHtmlSnippet(htmlSnippet);
    nativeStyle.setCssSnippet(cssSnippet);

    // Create the native style on the server.
    NativeStyle[] nativeStyles =
        nativeStyleService.createNativeStyles(new NativeStyle[] {nativeStyle});

    for (NativeStyle createdNativeStyle : nativeStyles) {
      System.out.printf(
          "A native style with ID %d and name '%s' was created.%n",
          createdNativeStyle.getId(), createdNativeStyle.getName());
    }
  }