use of com.google.api.ads.admanager.axis.v202205.UpdateResult in project googleads-java-lib by googleads.
the class DeleteCustomTargetingValues method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param customTargetingValueId the ID of the custom targeting value to delete.
* @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 customTargetingValueId) throws RemoteException {
// Get the CustomTargetingService.
CustomTargetingServiceInterface customTargetingService = adManagerServices.get(session, CustomTargetingServiceInterface.class);
// Create a statement to select custom targeting value.
StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", customTargetingValueId);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get custom targeting values by statement.
CustomTargetingValuePage page = customTargetingService.getCustomTargetingValuesByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (CustomTargetingValue customTargetingValue : page.getResults()) {
System.out.printf("%d) Custom targeting value with ID %d" + " will be deleted.%n", i++, customTargetingValue.getId());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of custom targeting values to be deleted: %d%n", totalResultSetSize);
if (totalResultSetSize > 0) {
// Remove limit and offset from statement.
statementBuilder.removeLimitAndOffset();
// Create action.
com.google.api.ads.admanager.axis.v202108.DeleteCustomTargetingValues action = new com.google.api.ads.admanager.axis.v202108.DeleteCustomTargetingValues();
// Perform action.
UpdateResult result = customTargetingService.performCustomTargetingValueAction(action, statementBuilder.toStatement());
if (result != null && result.getNumChanges() > 0) {
System.out.printf("Number of custom targeting values deleted: %d%n", result.getNumChanges());
} else {
System.out.println("No custom targeting values deleted.");
}
}
}
use of com.google.api.ads.admanager.axis.v202205.UpdateResult in project googleads-java-lib by googleads.
the class DeactivateLabels method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param labelId the ID of the label to deactivate.
* @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 select a label.
StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", labelId);
// 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 will be deactivated.%n", i++, label.getId());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of labels to be deactivated: %d%n", totalResultSetSize);
if (totalResultSetSize > 0) {
// Remove limit and offset from statement.
statementBuilder.removeLimitAndOffset();
// Create action.
com.google.api.ads.admanager.axis.v202108.DeactivateLabels action = new com.google.api.ads.admanager.axis.v202108.DeactivateLabels();
// Perform action.
UpdateResult result = labelService.performLabelAction(action, statementBuilder.toStatement());
if (result != null && result.getNumChanges() > 0) {
System.out.printf("Number of labels deactivated: %d%n", result.getNumChanges());
} else {
System.out.println("No labels were deactivated.");
}
}
}
use of com.google.api.ads.admanager.axis.v202205.UpdateResult in project googleads-java-lib by googleads.
the class ApproveOrders method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param orderId the ID of the order to approve.
* @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 orderId) throws RemoteException {
// Get the OrderService.
OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
// Create a statement to select an order.
StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", orderId);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get orders by statement.
OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (Order order : page.getResults()) {
System.out.printf("%d) Order with ID %d will be approved.%n", i++, order.getId());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of orders to be approved: %d%n", totalResultSetSize);
if (totalResultSetSize > 0) {
// Remove limit and offset from statement.
statementBuilder.removeLimitAndOffset();
// Create action.
com.google.api.ads.admanager.axis.v202108.ApproveOrders action = new com.google.api.ads.admanager.axis.v202108.ApproveOrders();
// Perform action.
UpdateResult result = orderService.performOrderAction(action, statementBuilder.toStatement());
if (result != null && result.getNumChanges() > 0) {
System.out.printf("Number of orders approved: %d%n", result.getNumChanges());
} else {
System.out.println("No orders were approved.");
}
}
}
use of com.google.api.ads.admanager.axis.v202205.UpdateResult in project googleads-java-lib by googleads.
the class ArchiveProposalLineItems method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param proposalLineItemId the ID of the proposal line item to archive.
* @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 proposalLineItemId) throws RemoteException {
// Get the ProposalLineItemService.
ProposalLineItemServiceInterface proposalLineItemService = adManagerServices.get(session, ProposalLineItemServiceInterface.class);
// Create a statement to select a proposal line item.
StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", proposalLineItemId);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get proposal line items by statement.
ProposalLineItemPage page = proposalLineItemService.getProposalLineItemsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (ProposalLineItem proposalLineItem : page.getResults()) {
System.out.printf("%d) Proposal line item with ID %d will be archived.%n", i++, proposalLineItem.getId());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of proposal line items to be archived: %d%n", totalResultSetSize);
if (totalResultSetSize > 0) {
// Remove limit and offset from statement.
statementBuilder.removeLimitAndOffset();
// Create action.
com.google.api.ads.admanager.axis.v202108.ArchiveProposalLineItems action = new com.google.api.ads.admanager.axis.v202108.ArchiveProposalLineItems();
// Perform action.
UpdateResult result = proposalLineItemService.performProposalLineItemAction(action, statementBuilder.toStatement());
if (result != null && result.getNumChanges() > 0) {
System.out.printf("Number of proposal line items archived: %d%n", result.getNumChanges());
} else {
System.out.println("No proposal line items were archived.");
}
}
}
use of com.google.api.ads.admanager.axis.v202205.UpdateResult in project googleads-java-lib by googleads.
the class PauseLineItems method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param lineItemId the ID of the line item 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.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long lineItemId) throws RemoteException {
// Get the LineItemService.
LineItemServiceInterface lineItemService = adManagerServices.get(session, LineItemServiceInterface.class);
// Create a statement to select a line item.
StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", lineItemId);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get line items by statement.
LineItemPage page = lineItemService.getLineItemsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (LineItem lineItem : page.getResults()) {
System.out.printf("%d) Line item with ID %d will be paused.%n", i++, lineItem.getId());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of line items to be paused: %d%n", totalResultSetSize);
if (totalResultSetSize > 0) {
// Remove limit and offset from statement.
statementBuilder.removeLimitAndOffset();
// Create action.
com.google.api.ads.admanager.axis.v202108.PauseLineItems action = new com.google.api.ads.admanager.axis.v202108.PauseLineItems();
// Perform action.
UpdateResult result = lineItemService.performLineItemAction(action, statementBuilder.toStatement());
if (result != null && result.getNumChanges() > 0) {
System.out.printf("Number of line items paused: %d%n", result.getNumChanges());
} else {
System.out.println("No line items were paused.");
}
}
}
Aggregations