Search in sources :

Example 16 with LabelPage

use of com.google.api.ads.admanager.axis.v202205.LabelPage in project googleads-java-lib by googleads.

the class GetActiveLabels method runExample.

/**
 * 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.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    LabelServiceInterface labelService = adManagerServices.get(session, LabelServiceInterface.class);
    // Create a statement to select labels.
    StatementBuilder statementBuilder = new StatementBuilder().where("isActive = :isActive").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("isActive", true);
    // Retrieve a small amount of labels at a time, paging through
    // until all labels have been retrieved.
    int totalResultSetSize = 0;
    do {
        LabelPage page = labelService.getLabelsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each label.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Label label : page.getResults()) {
                System.out.printf("%d) Label with ID %d and name '%s' was found.%n", i++, label.getId(), label.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : LabelPage(com.google.api.ads.admanager.axis.v202205.LabelPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) LabelServiceInterface(com.google.api.ads.admanager.axis.v202205.LabelServiceInterface) Label(com.google.api.ads.admanager.axis.v202205.Label)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)4 Label (com.google.api.ads.admanager.axis.v202108.Label)4 LabelPage (com.google.api.ads.admanager.axis.v202108.LabelPage)4 LabelServiceInterface (com.google.api.ads.admanager.axis.v202108.LabelServiceInterface)4 Label (com.google.api.ads.admanager.axis.v202111.Label)4 LabelPage (com.google.api.ads.admanager.axis.v202111.LabelPage)4 LabelServiceInterface (com.google.api.ads.admanager.axis.v202111.LabelServiceInterface)4 Label (com.google.api.ads.admanager.axis.v202202.Label)4 LabelPage (com.google.api.ads.admanager.axis.v202202.LabelPage)4 LabelServiceInterface (com.google.api.ads.admanager.axis.v202202.LabelServiceInterface)4 Label (com.google.api.ads.admanager.axis.v202205.Label)4 LabelPage (com.google.api.ads.admanager.axis.v202205.LabelPage)4 LabelServiceInterface (com.google.api.ads.admanager.axis.v202205.LabelServiceInterface)4 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)1 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)1 UpdateResult (com.google.api.ads.admanager.axis.v202202.UpdateResult)1 UpdateResult (com.google.api.ads.admanager.axis.v202205.UpdateResult)1