code: public static void runExample(
        AdWordsServicesInterface adWordsServices, AdWordsSession session, Long adGroupId, Long adId)
        throws RemoteException {
      // Get the AdGroupAdService.
      AdGroupAdServiceInterface adGroupAdService =
          adWordsServices.get(session, AdGroupAdServiceInterface.class);
  
      // Create ad with updated status.
      Ad ad = new Ad();
      ad.setId(adId);
  
      AdGroupAd adGroupAd = new AdGroupAd();
      adGroupAd.setAdGroupId(adGroupId);
      adGroupAd.setAd(ad);
      adGroupAd.setStatus(AdGroupAdStatus.PAUSED);
  
      // Create operations.
      AdGroupAdOperation operation = new AdGroupAdOperation();
      operation.setOperand(adGroupAd);
      operation.setOperator(Operator.SET);
  
      AdGroupAdOperation[] operations = new AdGroupAdOperation[] {operation};
  
      // Update ad.
      AdGroupAdReturnValue result = adGroupAdService.mutate(operations);
  
      // Display ads.
      for (AdGroupAd adGroupAdResult : result.getValue()) {
        System.out.printf("Ad with ID %d, type '%s', and status '%s' was updated.%n",
            adGroupAdResult.getAd().getId(), adGroupAdResult.getAd().getAdType(), 
            adGroupAdResult.getStatus());
      }
    }
docs: Runs the example.
  
  @param adWordsServices the services factory.
  @param session the session.
  @param adGroupId the ID of the ad group for the ad.
  @param adId the ID of the ad to pause.
  @throws ApiException if the API request failed with one or more service errors.
  @throws RemoteException if the API request failed due to other errors.