def get_campaigns(accounts): if project.verbose: print 'DCM Campaigns' for account_id in accounts: is_superuser, profile_id = get_profile_for_api(project.task['auth'], account_id) kwargs = { 'profileId':profile_id, 'accountId':account_id } if is_superuser else { 'profileId':profile_id } for campaign in API_DCM("user", iterate=True, internal=is_superuser).campaigns().list(**kwargs).execute(): if long(campaign['accountId']) in accounts: yield [ campaign['accountId'], campaign.get('subaccountId'), campaign['advertiserId'], campaign.get('advertiserGroupId'), campaign['id'], campaign['name'], campaign['archived'], campaign['startDate'], campaign['endDate'], campaign.get('comment', ''), epoch_to_datetime(campaign['createInfo']['time'], 1000), epoch_to_datetime(campaign['lastModifiedInfo']['time'], 1000), campaign.get('externalId'), campaign['defaultLandingPageId'], campaign['adBlockingConfiguration']['enabled'], campaign['adBlockingConfiguration']['overrideClickThroughUrl'], campaign['adBlockingConfiguration'].get('clickThroughUrl'), campaign['adBlockingConfiguration'].get('creativeBundleId'), campaign['nielsenOcrEnabled'], ]
def get_reports(accounts): if project.verbose: print('DCM Reports') for account_id in accounts: is_superuser, profile_id = get_profile_for_api(project.task['auth'], account_id) kwargs = { 'profileId': profile_id, 'accountId': account_id, 'scope': 'ALL' } if is_superuser else { 'profileId': profile_id, 'scope': 'ALL' } for report in API_DCM( 'user', iterate=True, internal=is_superuser).reports().list(**kwargs).execute(): if int(report['accountId']) in accounts: for delivery in report.get('delivery', {}).get('recipients', []): REPORT_DELIVERIES.append(( report['ownerProfileId'], report['accountId'], report.get('subaccountId'), report['id'], report['delivery']['emailOwner'], report['delivery'].get('emailOwnerDeliveryType'), report['delivery'].get('message', ''), delivery['email'], delivery['deliveryType'], )) yield [ report['ownerProfileId'], report['accountId'], report.get('subaccountId'), report['id'], report['name'], report['type'], report.get('format'), epoch_to_datetime(report.get('lastModifiedTime'), 1000), report.get('criteria', {}).get('startDate'), report.get('criteria', {}).get('endDate'), report.get('criteria', {}).get('relativeDateRange'), report.get('schedule', {}).get('active'), report.get('schedule', {}).get('startDate'), report.get('schedule', {}).get('expirationDate'), report.get('schedule', {}).get('runsOnDayOfMonth'), report.get('schedule', {}).get('repeats'), report.get('schedule', {}).get('every'), ','.join( report.get('schedule', {}).get('repeatsOnWeekDays', [])), ]