code: public static void runExample(
        AdManagerServices adManagerServices, AdManagerSession session, long productTemplateId)
        throws RemoteException {
      // Get the ProductTemplateService.
      ProductTemplateServiceInterface productTemplateService =
          adManagerServices.get(session, ProductTemplateServiceInterface.class);
  
      // Create a statement to select a product template by ID.
      StatementBuilder statementBuilder =
          new StatementBuilder()
              .where("id = :id")
              .orderBy("id ASC")
              .limit(1)
              .withBindVariableValue("id", productTemplateId);
  
      // Get the product template.
      ProductTemplatePage page =
          productTemplateService.getProductTemplatesByStatement(statementBuilder.toStatement());
  
      ProductTemplate productTemplate = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
  
      // Add geo targeting for Canada to the product template.
      Location countryLocation = new Location();
      countryLocation.setId(2124L);
  
      Targeting productTemplateTargeting = productTemplate.getBuiltInTargeting();
      GeoTargeting geoTargeting = productTemplateTargeting.getGeoTargeting();
  
      List<Location> existingTargetedLocations = new ArrayList<>();
  
      if (geoTargeting != null) {
        if (geoTargeting.getTargetedLocations() != null) {
          existingTargetedLocations =
              new ArrayList<>(Arrays.asList(geoTargeting.getTargetedLocations()));
        }
      } else {
        geoTargeting = new GeoTargeting();
      }
  
      existingTargetedLocations.add(countryLocation);
      geoTargeting.setTargetedLocations(existingTargetedLocations.toArray(new Location[] {}));
  
      productTemplateTargeting.setGeoTargeting(geoTargeting);
      productTemplate.setBuiltInTargeting(productTemplateTargeting);
  
      // Update the product template on the server.
      ProductTemplate[] productTemplates =
          productTemplateService.updateProductTemplates(new ProductTemplate[] {productTemplate});
  
      for (ProductTemplate updatedProductTemplate : productTemplates) {
        System.out.printf(
            "Product template with ID %d and name '%s' was updated.%n",
            updatedProductTemplate.getId(), updatedProductTemplate.getName());
      }
    }
docs: Runs the example.
  
  @param adManagerServices the services factory.
  @param session the session.
  @param productTemplateId the ID of the product template to update.
  @throws ApiException if the API request failed with one or more service errors.
  @throws RemoteException if the API request failed due to other errors.