use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.
the class StatementBuilder method toStatement.
/**
* Gets the {@link Statement} representing the state of this statement builder.
*
* @return the {@link Statement}
*/
public Statement toStatement() {
Statement statement = new Statement();
statement.setQuery(queryBuilder.buildQuery());
statement.getValues().addAll(Maps.toList(queryBuilder.getBindVariableMap(), StringValueMapEntry.class));
return statement;
}
use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.
the class StatementBuilder method toStatement.
/**
* Gets the {@link Statement} representing the state of this statement builder.
*
* @return the {@link Statement}
*/
public Statement toStatement() {
Statement statement = new Statement();
statement.setQuery(queryBuilder.buildQuery());
statement.getValues().addAll(Maps.toList(queryBuilder.getBindVariableMap(), StringValueMapEntry.class));
return statement;
}
use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.
the class StatementBuilder method toStatement.
/**
* Gets the {@link Statement} representing the state of this statement builder.
*
* @return the {@link Statement}
*/
public Statement toStatement() {
Statement statement = new Statement();
statement.setQuery(queryBuilder.buildQuery());
statement.getValues().addAll(Maps.toList(queryBuilder.getBindVariableMap(), StringValueMapEntry.class));
return statement;
}
use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.
the class GetAllLabels 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 {
// Get the LabelService.
LabelServiceInterface labelService = adManagerServices.get(session, LabelServiceInterface.class);
// Create a statement to select all labels.
StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get labels by statement.
LabelPage page = labelService.getLabelsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
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);
}
use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.
the class UpdateLabels method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param labelId the ID of the label 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.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long labelId) throws RemoteException {
// Get the LabelService.
LabelServiceInterface labelService = adManagerServices.get(session, LabelServiceInterface.class);
// Create a statement to only select a single label by ID.
StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", labelId);
// Get the label.
LabelPage page = labelService.getLabelsByStatement(statementBuilder.toStatement());
Label label = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
// Update the label description.
label.setDescription("New label description");
// Update the label on the server.
Label[] labels = labelService.updateLabels(new Label[] { label });
for (Label updatedLabel : labels) {
System.out.printf("Label with ID %d and name '%s' was updated.%n", updatedLabel.getId(), updatedLabel.getName());
}
}
Aggregations