code: private static void createExpandedDSA(
        AdWordsServicesInterface adWordsServices, AdWordsSession session, AdGroup adGroup)
        throws ApiException, RemoteException {
      // Get the AdGroupAdService.
      AdGroupAdServiceInterface adGroupAdService =
          adWordsServices.get(session, AdGroupAdServiceInterface.class);
  
      // Create the expanded Dynamic Search Ad. This ad will have its headline and final URL
      // auto-generated at serving time according to domain name specific information provided
      // by DynamicSearchAdsSetting at the campaign level.
      ExpandedDynamicSearchAd expandedDSA = new ExpandedDynamicSearchAd();
      // Set the ad description.
      expandedDSA.setDescription("Buy your tickets now!");
      expandedDSA.setDescription2("Discount ends soon");
  
      // Create the ad group ad.
      AdGroupAd adGroupAd = new AdGroupAd();
      adGroupAd.setAdGroupId(adGroup.getId());
      adGroupAd.setAd(expandedDSA);
  
      // Optional: Set the status.
      adGroupAd.setStatus(AdGroupAdStatus.PAUSED);
  
      // Create the operation.
      AdGroupAdOperation operation = new AdGroupAdOperation();
      operation.setOperator(Operator.ADD);
      operation.setOperand(adGroupAd);
  
      // Create the ad.
      AdGroupAd newAdGroupAd =
          adGroupAdService.mutate(new AdGroupAdOperation[] {operation}).getValue(0);
      ExpandedDynamicSearchAd newExpandedDSA = (ExpandedDynamicSearchAd) newAdGroupAd.getAd();
      System.out.printf(
          "Expanded Dynamic Search Ad with ID %d and description '%s' and description 2 '%s' was "
              + "added.%n",
          newExpandedDSA.getId(), newExpandedDSA.getDescription(), newExpandedDSA.getDescription2());
    }
docs: Creates the expanded Dynamic Search Ad.