use of com.google.api.ads.admanager.axis.v202205.UpdateResult in project googleads-java-lib by googleads.
the class DeactivateLicas method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param lineItemId the ID of the line item to deactivate LICAs for.
* @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 LineItemCreativeAssociationService.
LineItemCreativeAssociationServiceInterface licaService = adManagerServices.get(session, LineItemCreativeAssociationServiceInterface.class);
// Create a statement to select all LICAs for a line item.
StatementBuilder statementBuilder = new StatementBuilder().where("WHERE lineItemId = :lineItemId").orderBy("lineItemId ASC, creativeId ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("lineItemId", lineItemId);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get LICAs by statement.
LineItemCreativeAssociationPage page = licaService.getLineItemCreativeAssociationsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (LineItemCreativeAssociation lica : page.getResults()) {
if (lica.getCreativeSetId() != null) {
System.out.printf("%d) LICA with line item ID %d and creative " + "set ID %d will be deactivated.%n", i++, lica.getLineItemId(), lica.getCreativeSetId());
} else {
System.out.printf("%d) LICA with line item ID %d and creative ID %d will be deactivated.%n", i++, lica.getLineItemId(), lica.getCreativeId());
}
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of LICAs to be deactivated: %d%n", totalResultSetSize);
if (totalResultSetSize > 0) {
// Remove limit and offset from statement.
statementBuilder.removeLimitAndOffset();
// Create action.
DeactivateLineItemCreativeAssociations action = new DeactivateLineItemCreativeAssociations();
// Perform action.
UpdateResult result = licaService.performLineItemCreativeAssociationAction(action, statementBuilder.toStatement());
if (result != null && result.getNumChanges() > 0) {
System.out.printf("Number of LICAs deactivated: %d%n", result.getNumChanges());
} else {
System.out.println("No LICAs were deactivated.");
}
}
}
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.v202111.DeleteCustomTargetingValues action = new com.google.api.ads.admanager.axis.v202111.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 PopulateFirstPartyAudienceSegments method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param audienceSegmentId the ID of the first party audience segment to populate.
* @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 audienceSegmentId) throws RemoteException {
// Get the AudienceSegmentService.
AudienceSegmentServiceInterface audienceSegmentService = adManagerServices.get(session, AudienceSegmentServiceInterface.class);
// Create a statement to only select a specified first party audience
// segment.
StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :audienceSegmentId and type = :type").orderBy("id ASC").limit(1).withBindVariableValue("audienceSegmentId", audienceSegmentId).withBindVariableValue("type", "FIRST_PARTY");
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get audience segments by statement.
AudienceSegmentPage page = audienceSegmentService.getAudienceSegmentsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (AudienceSegment audienceSegment : page.getResults()) {
System.out.printf("%d) Audience segment with ID %d and name '%s' will be populated.%n", i++, audienceSegment.getId(), audienceSegment.getName());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of audience segments to be populated: %d%n", totalResultSetSize);
if (totalResultSetSize > 0) {
// Remove limit and offset from statement.
statementBuilder.removeLimitAndOffset();
// Create action.
PopulateAudienceSegments action = new PopulateAudienceSegments();
// Perform action.
UpdateResult result = audienceSegmentService.performAudienceSegmentAction(action, statementBuilder.toStatement());
if (result != null && result.getNumChanges() > 0) {
System.out.printf("Number of audience segments populated: %d%n", result.getNumChanges());
} else {
System.out.println("No audience segments were populated.");
}
}
}
use of com.google.api.ads.admanager.axis.v202205.UpdateResult in project googleads-java-lib by googleads.
the class DeactivatePlacements method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param placementId the ID of the placement 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 placementId) throws RemoteException {
// Get the PlacementService.
PlacementServiceInterface placementService = adManagerServices.get(session, PlacementServiceInterface.class);
// Create a statement to select a placement.
StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", placementId);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get placements by statement.
PlacementPage page = placementService.getPlacementsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (Placement placement : page.getResults()) {
System.out.printf("%d) Placement with ID %d will be deactivated.%n", i++, placement.getId());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of placements 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.DeactivatePlacements action = new com.google.api.ads.admanager.axis.v202108.DeactivatePlacements();
// Perform action.
UpdateResult result = placementService.performPlacementAction(action, statementBuilder.toStatement());
if (result != null && result.getNumChanges() > 0) {
System.out.printf("Number of placements deactivated: %d%n", result.getNumChanges());
} else {
System.out.println("No placements were deactivated.");
}
}
}
use of com.google.api.ads.admanager.axis.v202205.UpdateResult in project googleads-java-lib by googleads.
the class SubmitSiteForApproval method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param siteId the ID of the site to submit for approval.
* @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 siteId) throws RemoteException {
// Get the SiteService.
SiteServiceInterface siteService = adManagerServices.get(session, SiteServiceInterface.class);
// Create a statement to select a site.
StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", siteId);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get sites by statement.
SitePage page = siteService.getSitesByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (Site site : page.getResults()) {
System.out.printf("%d) Site with ID %d will be submitted for approval.%n", i++, site.getId());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of sites to be submitted: %d%n", totalResultSetSize);
if (totalResultSetSize > 0) {
// Remove limit and offset from statement.
statementBuilder.removeLimitAndOffset();
// Create action.
com.google.api.ads.admanager.axis.v202108.SubmitSiteForApproval action = new com.google.api.ads.admanager.axis.v202108.SubmitSiteForApproval();
// Perform action.
UpdateResult result = siteService.performSiteAction(action, statementBuilder.toStatement());
if (result != null && result.getNumChanges() > 0) {
System.out.printf("Number of sites submitted: %d%n", result.getNumChanges());
} else {
System.out.println("No sites were submitted.");
}
}
}
Aggregations