operations = [
{
'operator': 'ADD',
'operand': {
'campaignId': campaign_id,
'name': adgroup_hash['name'],
'status': adgroup_hash['status'],
'biddingStrategyConfiguration': {
'bids': [
{
'xsi_type': 'CpcBid',
'bid': {
'microAmount': 1111111111
}
}
]
}
}
}
]
adgroups = self.adgroup_service.mutate(operations)
Here is how I get an adroup:
def get_adroups(self,campaign_id):
# Construct selector and get all ad groups.
offset = 0
selector = {
'fields': ['Id', 'Name', 'Status'],
'predicates': [
{
'field': 'CampaignId',
'operator': 'EQUALS',
'values': [campaign_id]
}
],
'paging': {
'startIndex': str(offset),
'numberResults': str(self.PAGE_SIZE)
}
}
page = self.adgroup_service.get(selector)
total_num_entries = page['totalNumEntries']
#print('total_num_entries:',total_num_entries)
meta = {}
for entry in page['entries']:
meta[entry['name']] = entry
return meta
|
||||||