Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨Source Amazon Ads: Add filter for Marketplace ID #29233

Merged
merged 24 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9485a20
add marketplace id filter
archangelic Aug 8, 2023
914c962
update docs
archangelic Aug 8, 2023
b38b166
fix filter
archangelic Aug 8, 2023
61345de
update docs to include note about filters
archangelic Aug 8, 2023
cdd7041
clarify usage in spec
archangelic Aug 8, 2023
d0a2524
add logic to check for filter errors
archangelic Aug 16, 2023
434d3a8
Merge remote-tracking branch 'origin' into mal/amazon-ads-marketplace…
archangelic Aug 16, 2023
57b7c77
Merge remote-tracking branch 'origin' into mal/amazon-ads-marketplace…
archangelic Aug 22, 2023
5706b79
unit test for choose profile
marcosmarxm Aug 22, 2023
ce46390
add more unit tests, fix method
archangelic Aug 23, 2023
13cbe9a
fix formatting
archangelic Aug 23, 2023
f45cb4d
add one more unit test
archangelic Aug 23, 2023
2750173
Merge branch 'master' into mal/amazon-ads-marketplace-filter
archangelic Aug 23, 2023
9843c5c
fix formatting
archangelic Aug 23, 2023
7e893cc
add mock profile for test_check
archangelic Aug 23, 2023
cc4568e
add more unit tests
archangelic Aug 23, 2023
636e77c
fix formatting
archangelic Aug 23, 2023
2c6c892
make changes to filtering and check
archangelic Aug 23, 2023
fde7e5f
Merge branch 'master' into mal/amazon-ads-marketplace-filter
archangelic Aug 23, 2023
e2d91dc
remove else statement
archangelic Aug 25, 2023
a72f495
Merge branch 'master' into mal/amazon-ads-marketplace-filter
marcosmarxm Aug 29, 2023
07b2d94
bump connector version
marcosmarxm Aug 29, 2023
5929a06
Automated Commit - Formatting Changes
marcosmarxm Aug 29, 2023
86a8a26
Merge branch 'master' into mal/amazon-ads-marketplace-filter
marcosmarxm Aug 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]


LABEL io.airbyte.version=3.0.0
LABEL io.airbyte.version=3.0.1
LABEL io.airbyte.name=airbyte/source-amazon-ads
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,22 @@
},
"profiles": {
"title": "Profile IDs",
"description": "Profile IDs you want to fetch data for. See <a href=\"https://advertising.amazon.com/API/docs/en-us/concepts/authorization/profiles\">docs</a> for more details.",
"description": "Profile IDs you want to fetch data for. See <a href=\"https://advertising.amazon.com/API/docs/en-us/concepts/authorization/profiles\">docs</a> for more details. Note: If Profile IDs are also selected, profiles will be filtered if they meet either criteria.",
"order": 6,
"type": "array",
"items": {
"type": "integer"
}
},
"marketplace_ids": {
"title": "Marketplace IDs",
"description": "Marketplace IDs you want to fetch data for. Note: If Profile IDs are also selected, profiles will be filtered if they meet either criteria.",
"order": 7,
"type": "array",
"items": {
"type": "string"
}
},
"state_filter": {
"title": "State Filter",
"description": "Reflects the state of the Display, Product, and Brand Campaign streams as enabled, paused, or archived. If you do not populate this field, it will be ignored completely.",
Expand All @@ -63,14 +72,14 @@
},
"type": "array",
"uniqueItems": true,
"order": 7
"order": 8
},
"look_back_window": {
"title": "Look Back Window",
"description": "The amount of days to go back in time to get the updated data from Amazon Ads",
"default": 3,
"examples": [3, 10],
"order": 8,
"order": 9,
"type": "integer"
},
"report_record_types": {
Expand All @@ -91,7 +100,7 @@
},
"type": "array",
"uniqueItems": true,
"order": 9
"order": 10
}
},
"required": ["client_id", "client_secret", "refresh_token"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: c6b0a29e-1da9-4512-9002-7bfd0cba2246
dockerImageTag: 3.0.0
dockerImageTag: 3.0.1
dockerRepository: airbyte/source-amazon-ads
githubIssueLabel: source-amazon-ads
icon: amazonads.svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def check_connection(self, logger: logging.Logger, config: Mapping[str, Any]) ->
# It doesnt support pagination so there is no sense of reading single
# record, it would fetch all the data anyway.
Profiles(config, authenticator=self._make_authenticator(config)).get_all_profiles()
archangelic marked this conversation as resolved.
Show resolved Hide resolved

return True, None

def streams(self, config: Mapping[str, Any]) -> List[Stream]:
Expand Down Expand Up @@ -140,6 +141,16 @@ def _make_authenticator(config: Mapping[str, Any]):

@staticmethod
def _choose_profiles(config: Mapping[str, Any], profiles: List[Profile]):
if not config.get("profiles"):
filtered_profiles = []
if config.get("profiles"):
for profile in list(filter(lambda profile: profile.profileId in config["profiles"], profiles)):
filtered_profiles.append(profile)
if config.get("marketplace_ids"):
for profile in list(filter(lambda profile: profile.profileId in config["marketplace_ids"], profiles)):
archangelic marked this conversation as resolved.
Show resolved Hide resolved
if profile not in filtered_profiles:
filtered_profiles.append(profile)

if config.get("profiles") or config.get("marketplace_ids"):
return filtered_profiles
else:
return profiles
return list(filter(lambda profile: profile.profileId in config["profiles"], profiles))
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ connectionSpecification:
profiles:
title: Profile IDs
description:
Profile IDs you want to fetch data for. See <a href="https://advertising.amazon.com/API/docs/en-us/concepts/authorization/profiles">docs</a>
for more details.
'Profile IDs you want to fetch data for. See <a href="https://advertising.amazon.com/API/docs/en-us/concepts/authorization/profiles">docs</a> for more details. Note: If Profile IDs are also selected, profiles will be filtered if they meet either criteria.'
order: 6
type: array
items:
type: integer
marketplace_ids:
title: Marketplace IDs
description: "Marketplace IDs you want to fetch data for. Note: If Profile IDs are also selected, profiles will be filtered if they meet either criteria."
order: 7
type: array
items:
type: string
state_filter:
title: State Filter
description: Reflects the state of the Display, Product, and Brand Campaign streams as enabled, paused, or archived. If you do not populate this field, it will be ignored completely.
Expand All @@ -76,7 +82,7 @@ connectionSpecification:
- archived
type: array
uniqueItems: true
order: 7
order: 8
look_back_window:
title: "Look Back Window"
description: "The amount of days to go back in time to get the updated data from Amazon Ads"
Expand All @@ -85,7 +91,7 @@ connectionSpecification:
- 10
type: "integer"
default: 3
order: 8
order: 9
report_record_types:
title: Report Record Types
description:
Expand All @@ -107,7 +113,7 @@ connectionSpecification:
- targets
type: array
uniqueItems: true
order: 9
order: 10
required:
- client_id
- client_secret
Expand Down
2 changes: 2 additions & 0 deletions docs/integrations/sources/amazon-ads.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This page contains the setup guide and reference information for the Amazon Ads
* Region
* Start Date (Optional)
* Profile IDs (Optional)
* Marketplace IDs (Optional)
archangelic marked this conversation as resolved.
Show resolved Hide resolved

## Setup guide
### Step 1: Set up Amazon Ads
Expand Down Expand Up @@ -103,6 +104,7 @@ Information about expected report generation waiting time you may find [here](ht

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------|
| 3.0.1 | 2023-08-08 | [29233](https://github.com/airbytehq/airbyte/pull/29233) | Add filter for Marketplace IDs |
| 3.0.0 | 2023-07-24 | [27868](https://github.com/airbytehq/airbyte/pull/27868) | Fix attribution report stream schemas |
| 2.3.1 | 2023-07-11 | [28155](https://github.com/airbytehq/airbyte/pull/28155) | Bugfix: validation error when record values are missing |
| 2.3.0 | 2023-07-06 | [28002](https://github.com/airbytehq/airbyte/pull/28002) | Add sponsored_product_ad_group_suggested_keywords, sponsored_product_ad_group_bid_recommendations streams |
Expand Down