Skip to content

Commit

Permalink
✨ Source Bing Ads: Add new streams Labels, App install ads, `Keyw…
Browse files Browse the repository at this point in the history
…ords`, `Campaign Labels`, `App install Ad Labels`, `Ad Group Label` (#31952)

Co-authored-by: artem1205 <[email protected]>
  • Loading branch information
artem1205 and artem1205 authored Oct 31, 2023
1 parent 7c7acad commit c68636e
Show file tree
Hide file tree
Showing 16 changed files with 528 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ acceptance_tests:
bypass_reason: "Empty report; hourly data fetched is limited to 180 days"
- name: account_impression_performance_report_hourly
bypass_reason: "Empty report; hourly data fetched is limited to 180 days"
- name: app_install_ads
bypass_reason: "Can not populate; new campaign with link to app needed; feature is not available yet"
- name: app_install_ad_labels
bypass_reason: "Can not populate; depends on stream app_install_ads"
timeout_seconds: 3600
full_refresh:
tests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,66 @@
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "labels",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["Modified Time"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "app_install_ads",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "app_install_ad_labels",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "campaign_labels",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "keyword_labels",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
},
{
"stream": {
"name": "ad_group_labels",
"json_schema": {},
"supported_sync_modes": ["incremental", "full_refresh"]
},
"sync_mode": "incremental",
"cursor_field": ["TimePeriod"],
"destination_sync_mode": "append"
}
]
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 47f25999-dd5e-4636-8c39-e7cea2453331
dockerImageTag: 1.4.0
dockerImageTag: 1.5.0
dockerRepository: airbyte/source-bing-ads
documentationUrl: https://docs.airbyte.com/integrations/sources/bing-ads
githubIssueLabel: source-bing-ads
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-bing-ads/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from setuptools import find_packages, setup

MAIN_REQUIREMENTS = ["airbyte-cdk", "bingads~=13.0.13", "urllib3<2.0"]
MAIN_REQUIREMENTS = ["airbyte-cdk", "bingads~=13.0.13", "urllib3<2.0", "pandas"]

TEST_REQUIREMENTS = [
"requests-mock~=1.9.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#

import os
import socket
import ssl
import sys
import uuid
from datetime import datetime, timedelta, timezone
from functools import lru_cache
from typing import Any, Iterator, Mapping, Optional, Union
from typing import Any, Iterator, List, Mapping, Optional, Union
from urllib.error import URLError

import backoff
Expand All @@ -19,10 +20,14 @@
from bingads.exceptions import OAuthTokenRequestException
from bingads.service_client import ServiceClient
from bingads.util import errorcode_of_exception
from bingads.v13.bulk import BulkServiceManager, DownloadParameters
from bingads.v13.reporting.exceptions import ReportingDownloadException
from bingads.v13.reporting.reporting_service_manager import ReportingServiceManager
from suds import WebFault, sudsobject

FILE_TYPE = "Csv"
TIMEOUT_IN_MILLISECONDS = 3_600_000


class Client:
api_version: int = 13
Expand Down Expand Up @@ -54,7 +59,6 @@ def __init__(
refresh_token: str = None,
**kwargs: Mapping[str, Any],
) -> None:
self.authorization_data: Mapping[str, AuthorizationData] = {}
self.refresh_token = refresh_token
self.developer_token = developer_token

Expand Down Expand Up @@ -236,3 +240,35 @@ def asdict(cls, suds_object: sudsobject.Object) -> Mapping[str, Any]:
else:
result[field] = val
return result

def _bulk_service_manager(self, customer_id: Optional[str] = None, account_id: Optional[str] = None):
return BulkServiceManager(
authorization_data=self._get_auth_data(customer_id, account_id),
poll_interval_in_milliseconds=5000,
environment=self.environment,
)

def get_bulk_entity(
self,
download_entities: List[str],
data_scope: List[str],
customer_id: Optional[str] = None,
account_id: Optional[str] = None,
start_date: Optional[str] = None,
) -> str:
"""
Return path with zipped csv archive
"""
download_parameters = DownloadParameters(
# campaign_ids=None,
data_scope=data_scope,
download_entities=download_entities,
file_type=FILE_TYPE,
last_sync_time_in_utc=start_date,
result_file_directory=os.getcwd(),
result_file_name=str(uuid.uuid4()),
overwrite_result_file=True, # Set this value true if you want to overwrite the same file.
timeout_in_milliseconds=TIMEOUT_IN_MILLISECONDS, # You may optionally cancel the download after a specified time interval.
)
bulk_service_manager = self._bulk_service_manager(customer_id=customer_id, account_id=account_id)
return bulk_service_manager.download_file(download_parameters)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"Account Id": {
"type": ["null", "integer"]
},
"Ad Group": {
"type": ["null", "string"]
},
"Campaign": {
"type": ["null", "string"]
},
"Client Id": {
"type": ["null", "string"]
},
"Id": {
"type": ["null", "integer"]
},
"Parent Id": {
"type": ["null", "integer"]
},
"Modified Time": {
"type": ["null", "string"]
},
"Status": {
"type": ["null", "string"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"Account Id": {
"type": ["null", "integer"]
},
"Client Id": {
"type": ["null", "string"]
},
"Id": {
"type": ["null", "integer"]
},
"Parent Id": {
"type": ["null", "integer"]
},
"Modified Time": {
"type": ["null", "string"]
},
"Status": {
"type": ["null", "string"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"Ad Group": {
"type": ["null", "string"]
},
"App Id": {
"type": ["null", "integer"]
},
"Campaign": {
"type": ["null", "string"]
},
"Client Id": {
"type": ["null", "integer"]
},
"Custom Parameter": {
"type": ["null", "string"]
},
"Device Preference": {
"type": ["null", "string"]
},
"Editorial Appeal Status": {
"type": ["null", "string"]
},
"Editorial Location": {
"type": ["null", "string"]
},
"Editorial Reason Code": {
"type": ["null", "string"]
},
"Editorial Status": {
"type": ["null", "string"]
},
"Editorial Term": {
"type": ["null", "string"]
},
"Final Url": {
"type": ["null", "string"]
},
"Final Url Suffix": {
"type": ["null", "string"]
},
"Id": {
"type": ["null", "integer"]
},
"Modified Time": {
"type": ["null", "string"]
},
"Parent Id": {
"type": ["null", "integer"]
},
"Publisher Countries": {
"type": ["null", "string"]
},
"Status": {
"type": ["null", "string"]
},
"Text": {
"type": ["null", "string"]
},
"Title": {
"type": ["null", "string"]
},
"Tracking Template": {
"type": ["null", "string"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"Account Id": {
"type": ["null", "integer"]
},
"Campaign": {
"type": ["null", "string"]
},
"Client Id": {
"type": ["null", "string"]
},
"Id": {
"type": ["null", "integer"]
},
"Parent Id": {
"type": ["null", "integer"]
},
"Modified Time": {
"type": ["null", "string"]
},
"Status": {
"type": ["null", "string"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"Account Id": {
"type": ["null", "integer"]
},
"Client Id": {
"type": ["null", "string"]
},
"Id": {
"type": ["null", "integer"]
},
"Parent Id": {
"type": ["null", "integer"]
},
"Modified Time": {
"type": ["null", "string"]
},
"Status": {
"type": ["null", "string"]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"Account Id": {
"type": ["null", "integer"]
},
"Color": {
"type": ["null", "string"]
},
"Client Id": {
"type": ["null", "string"]
},
"Description": {
"type": ["null", "string"]
},
"Id": {
"type": ["null", "integer"]
},
"Label": {
"type": ["null", "string"]
},
"Modified Time": {
"type": ["null", "string"]
},
"Status": {
"type": ["null", "string"]
}
}
}
Loading

0 comments on commit c68636e

Please sign in to comment.