Search in sources :

Example 11 with UpdateResult

use of com.google.api.ads.admanager.axis.v202108.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.");
        }
    }
}
Also used : AudienceSegmentPage(com.google.api.ads.admanager.axis.v202108.AudienceSegmentPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) PopulateAudienceSegments(com.google.api.ads.admanager.axis.v202108.PopulateAudienceSegments) AudienceSegment(com.google.api.ads.admanager.axis.v202108.AudienceSegment) AudienceSegmentServiceInterface(com.google.api.ads.admanager.axis.v202108.AudienceSegmentServiceInterface) UpdateResult(com.google.api.ads.admanager.axis.v202108.UpdateResult)

Example 12 with UpdateResult

use of com.google.api.ads.admanager.axis.v202108.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.");
        }
    }
}
Also used : LineItemCreativeAssociation(com.google.api.ads.admanager.axis.v202202.LineItemCreativeAssociation) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) LineItemCreativeAssociationPage(com.google.api.ads.admanager.axis.v202202.LineItemCreativeAssociationPage) DeactivateLineItemCreativeAssociations(com.google.api.ads.admanager.axis.v202202.DeactivateLineItemCreativeAssociations) LineItemCreativeAssociationServiceInterface(com.google.api.ads.admanager.axis.v202202.LineItemCreativeAssociationServiceInterface) UpdateResult(com.google.api.ads.admanager.axis.v202202.UpdateResult)

Example 13 with UpdateResult

use of com.google.api.ads.admanager.axis.v202108.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.v202202.DeactivatePlacements action = new com.google.api.ads.admanager.axis.v202202.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.");
        }
    }
}
Also used : PlacementPage(com.google.api.ads.admanager.axis.v202202.PlacementPage) Placement(com.google.api.ads.admanager.axis.v202202.Placement) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) PlacementServiceInterface(com.google.api.ads.admanager.axis.v202202.PlacementServiceInterface) UpdateResult(com.google.api.ads.admanager.axis.v202202.UpdateResult)

Example 14 with UpdateResult

use of com.google.api.ads.admanager.axis.v202108.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.v202202.ArchiveProposalLineItems action = new com.google.api.ads.admanager.axis.v202202.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.");
        }
    }
}
Also used : ProposalLineItemPage(com.google.api.ads.admanager.axis.v202202.ProposalLineItemPage) ProposalLineItem(com.google.api.ads.admanager.axis.v202202.ProposalLineItem) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) UpdateResult(com.google.api.ads.admanager.axis.v202202.UpdateResult) ProposalLineItemServiceInterface(com.google.api.ads.admanager.axis.v202202.ProposalLineItemServiceInterface)

Example 15 with UpdateResult

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

the class RequestBuyerAcceptance method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalId the proposal ID to send.
 * @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 proposalId) throws RemoteException {
    // Get the ProposalService.
    ProposalServiceInterface proposalService = adManagerServices.get(session, ProposalServiceInterface.class);
    // Create a statement to only select a single proposal by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", proposalId);
    // Retrieve a small amount of proposals at a time, paging through until all
    // proposals have been retrieved.
    int totalResultSetSize = 0;
    do {
        ProposalPage page = proposalService.getProposalsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each proposal.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Proposal proposal : page.getResults()) {
                System.out.printf("%d) Proposal with ID %d and name '%s' will be sent to Marketplace for buyer " + "acceptance.%n", i++, proposal.getId(), proposal.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of proposals to be sent to Marketplace for buyer acceptance: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202202.RequestBuyerAcceptance action = new com.google.api.ads.admanager.axis.v202202.RequestBuyerAcceptance();
        // Perform action.
        UpdateResult result = proposalService.performProposalAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of proposals that were sent to Marketplace for buyer acceptance: %d%n", result.getNumChanges());
        } else {
            System.out.println("No proposals were sent to Marketplace for buyer acceptance.");
        }
    }
}
Also used : ProposalServiceInterface(com.google.api.ads.admanager.axis.v202202.ProposalServiceInterface) ProposalPage(com.google.api.ads.admanager.axis.v202202.ProposalPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) Proposal(com.google.api.ads.admanager.axis.v202202.Proposal) UpdateResult(com.google.api.ads.admanager.axis.v202202.UpdateResult)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)18 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)18 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)18 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)18 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)18 UpdateResult (com.google.api.ads.admanager.axis.v202202.UpdateResult)18 UpdateResult (org.apache.ignite.internal.processors.query.h2.UpdateResult)6 SQLException (java.sql.SQLException)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202108.CustomTargetingServiceInterface)2 LineItemCreativeAssociationServiceInterface (com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociationServiceInterface)2 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202202.CustomTargetingServiceInterface)2 HashSet (java.util.HashSet)2 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)2 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)2 DmlStatementsProcessor (org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor)2 AdUnit (com.google.api.ads.admanager.axis.v202108.AdUnit)1 AdUnitPage (com.google.api.ads.admanager.axis.v202108.AdUnitPage)1 AudienceSegment (com.google.api.ads.admanager.axis.v202108.AudienceSegment)1 AudienceSegmentPage (com.google.api.ads.admanager.axis.v202108.AudienceSegmentPage)1