use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.
the class GetActiveCreativeWrappers 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 {
CreativeWrapperServiceInterface creativeWrapperService = adManagerServices.get(session, CreativeWrapperServiceInterface.class);
// Create a statement to select creative wrappers.
StatementBuilder statementBuilder = new StatementBuilder().where("status = :status").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("status", CreativeWrapperStatus.ACTIVE.toString());
// Retrieve a small amount of creative wrappers at a time, paging through
// until all creative wrappers have been retrieved.
int totalResultSetSize = 0;
do {
CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
// Print out some information for each creative wrapper.
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (CreativeWrapper creativeWrapper : page.getResults()) {
System.out.printf("%d) Creative wrapper with ID %d and label ID %d was found.%n", i++, creativeWrapper.getId(), creativeWrapper.getLabelId());
}
}
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 UpdateCreativeWrappers method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param creativeWrapperId the ID of the creative wrapper 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 creativeWrapperId) throws RemoteException {
// Get the CreativeWrapperService.
CreativeWrapperServiceInterface creativeWrapperService = adManagerServices.get(session, CreativeWrapperServiceInterface.class);
// Create a statement to only select a single creative wrapper by ID.
StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", creativeWrapperId);
// Get the creative wrapper.
CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.toStatement());
CreativeWrapper creativeWrapper = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
// Update the creative wrapper ordering.
creativeWrapper.setOrdering(CreativeWrapperOrdering.OUTER);
// Update the creative wrapper on the server.
CreativeWrapper[] creativeWrappers = creativeWrapperService.updateCreativeWrappers(new CreativeWrapper[] { creativeWrapper });
for (CreativeWrapper updatedCreativeWrapper : creativeWrappers) {
System.out.printf("Creative wrapper with ID %d and wrapping order '%s' was updated.%n", updatedCreativeWrapper.getId(), updatedCreativeWrapper.getOrdering());
}
}
use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.
the class GetCustomFieldsForLineItems 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 {
CustomFieldServiceInterface customFieldService = adManagerServices.get(session, CustomFieldServiceInterface.class);
// Create a statement to select custom fields.
StatementBuilder statementBuilder = new StatementBuilder().where("entityType = :entityType").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("entityType", CustomFieldEntityType.LINE_ITEM.toString());
// Retrieve a small amount of custom fields at a time, paging through
// until all custom fields have been retrieved.
int totalResultSetSize = 0;
do {
CustomFieldPage page = customFieldService.getCustomFieldsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
// Print out some information for each custom field.
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (CustomField customField : page.getResults()) {
System.out.printf("%d) Custom field with ID %d and name '%s' was found.%n", i++, customField.getId(), customField.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 GetAllCdnConfigurations 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 {
CdnConfigurationServiceInterface cdnConfigurationService = adManagerServices.get(session, CdnConfigurationServiceInterface.class);
// Create a statement to select CDN configurations.
int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT;
StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(pageSize);
// Retrieve a small amount of CDN configurations at a time, paging through until all
// CDN configurations have been retrieved.
int totalResultSetSize = 0;
do {
CdnConfigurationPage page = cdnConfigurationService.getCdnConfigurationsByStatement(statementBuilder.toStatement());
// Print out some information for each CDN configuration.
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (CdnConfiguration cdnConfiguration : page.getResults()) {
System.out.printf("%d) CDN configuration with ID %d and name '%s' was found.%n", i++, cdnConfiguration.getId(), cdnConfiguration.getName());
}
}
statementBuilder.increaseOffsetBy(pageSize);
} 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 GetAllCmsMetadataValues 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 CmsMetadataService.
CmsMetadataServiceInterface cmsMetadataService = adManagerServices.get(session, CmsMetadataServiceInterface.class);
// Create a statement to select all CMS metadata values.
StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get CMS metadata values by statement.
CmsMetadataValuePage page = cmsMetadataService.getCmsMetadataValuesByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (CmsMetadataValue cmsMetadataValue : page.getResults()) {
System.out.printf("%d) CMS metadata value with ID %d and name '%s' associated with the " + "CmsMetadataKey with ID %d and name '%s' was found.%n", i++, cmsMetadataValue.getCmsMetadataValueId(), cmsMetadataValue.getValueName(), cmsMetadataValue.getKey().getId(), cmsMetadataValue.getKey().getName());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Aggregations