Fetches asset groups in an account.
Typical usage:
var assetGroupIterator = campaign.assetGroups()
.withCondition("asset_group.name CONTAINS 'my asset group'")
.get();
Methods:
get()
Fetches the requested asset groups and returns an iterator.
Return values:
orderBy(orderBy)
Specifies the ordering of the resulting entities.
orderBy
parameter can have one of the following forms:
orderBy("asset.id ASC")
- orders results by asset.id, in
ascending order.
orderBy("asset.name DESC")
- orders results by
asset.name, in descending order.
See AssetGroupSelector.withCondition(String)
for enumeration of columns that can be used.
orderBy()
may be called multiple times. Consider the
following example:
selector = selector.orderBy("asset.name ASC").orderBy("asset.id DESC");
The results will be ordered by asset.name in ascending order. Results
with equal asset.name values will be ordered by asset.id in descending
order.
Arguments:
Name | Type | Description |
orderBy |
String |
Ordering to apply. |
Return values:
withCondition(condition)
Adds the specified condition to the selector in order to narrow down the
results.
Multiple conditions may be added to the same selector:
selector = selector.withCondition("asset_group.status = "PAUSED")
.withCondition("asset_group.name CONTAINS 's'");
All specified conditions are
AND
-ed together. The above
example will retrieve asset groups that are paused AND have a name
containing 's'.
The parameter to be passed into this method must be of the following
form:
"COLUMN_NAME OPERATOR VALUE"
Operators
The operator that can be used in a condition depends on the type of column.
- For
Integer
and Long
columns (e.g.
metrics.impressions, metrics.clicks):
< <= > >= = !=
- For
Double
columns (e.g. metrics.ctr):
< >
- For
String
columns (e.g. Name):
= != (NOT) (LIKE | CONTAINS | REGEXP_MATCH)
- For
Enumeration
columns (ones that can only take one
value from a predefined list, such as Status):
= != IN () NOT IN ()
- For
StringSet
columns (e.g. LabelNames):
CONTAINS ALL () CONTAINS ANY () CONTAINS NONE ()
Conditions using
IN
,
NOT IN
,
CONTAINS
ALL
,
CONTAINS ANY
and
CONTAINS NONE
operators look as follows:
withCondition("ColumnName IN (Value1, Value2)")
Columns
All column names are case-sensitive, and so are all values of enumerated
columns (such as Type).
Column |
Type |
Example |
Asset attributes
|
asset_group.name |
String |
withCondition("asset_group.name REGEXP_MATCH '.*shoes.*'") |
asset_group.final_urls |
String[] |
withCondition("asset_group.final_urls CONTAINS 'https://www.example.com'") |
asset_group.final_mobile_urls |
String[] |
withCondition("asset_group.final_mobile_urls DOES_NOT_CONTAIN 'https://www.example.com'") |
asset_group.status |
Enumeration: ENABLED , PAUSED ,
REMOVED
|
withCondition("asset_group.status = 'PAUSED'") |
Arguments:
Name | Type | Description |
condition |
String |
Condition to add to the selector. |
Return values:
withIds(ids)
Restricts this selector to return only asset groups with the
given
asset group IDs.
var assetGroupIds = ['12345', '23456', '34567'];
selector = selector.withIds(assetGroupIds);
The resulting selector can be further refined by applying additional
conditions to it. The ID-based condition will then be AND-ed together with
all the other conditions, including any other ID-based conditions. So, for
instance, the following selector:
campaign.assetGroups()
.withIds(['12345', '23456', '34567'])
.withIds(['34567', '45678', '56789']);
will only get the asset group with ID
34567
, since it
would be the only
asset group that satisfies both ID conditions.
The selector can only support up to 10,000 IDs. If more than 10,000 IDs
are specified, the corresponding get() call will fail with a runtime error.
Arguments:
Name | Type | Description |
ids |
Object[] |
Array of asset group IDs. |
Return values:
withLimit(limit)
Specifies limit for the selector to use. For instance,
withLimit(50)
returns only the first 50 entities.
Arguments:
Name | Type | Description |
limit |
int |
How many entities to return. |
Return values:
withResourceNames(resourceNames)
Restricts this selector to return only asset groups with the
given Google Ads API resource names.
const assetGroupResourceNames = [
'customers/1234567890/assetGroups/111',
'customers/1234567890/assetGroups/222',
'customers/1234567890/assetGroups/333',
];
selector = selector.withResourceNames(assetGroupResourceNames);
The resulting selector can be further refined by applying additional
conditions to it. The resource name condition will then be AND-ed together
with all the other conditions.
The selector can only support up to 10,000 resource names. If more than
10,000 resource names are specified, the corresponding get() call will fail
with a runtime error.
Arguments:
Name | Type | Description |
resourceNames |
String[] |
Array of asset group resource names. |
Return values: