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 - Update Deprecated Streams #36169

Merged
merged 37 commits into from
Mar 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
67ff440
Add fields to schemas
pnilan Mar 13, 2024
dc3d1af
Updates QL to 400, bumps connector version to 0.4.2
pnilan Mar 13, 2024
e2b8e83
Bumps connector version to 0.4.2
pnilan Mar 13, 2024
4196164
Chore: format code
pnilan Mar 13, 2024
f94f8b1
Modifies custom transformation component to remove field that begin w…
pnilan Mar 13, 2024
f7f9799
Update PR number
pnilan Mar 13, 2024
4cd661f
Updates CustomFieldTransformation for succinctness, per recommendation
pnilan Mar 14, 2024
37fe815
Updates changelog to reflect explicit changes
pnilan Mar 14, 2024
dbf02d0
SponsoredBrandsCampaign V4 update first pass
pnilan Mar 14, 2024
8609aa4
SponsoredProductsCampaigns first pass
pnilan Mar 14, 2024
7ce011d
Updated SponsoredBrandsAdGroups
pnilan Mar 14, 2024
8a8102a
Cleans up SponsoredProductsV3 and SponsoredBrandsV4 classes
pnilan Mar 14, 2024
c07fee7
Merge branch 'master' into pnilan/source-amazon-ads-issue-2440
pnilan Mar 15, 2024
be747de
Updated `SponsoredProductTargetings`, `SponsoredProductAds`, `Sponsor…
pnilan Mar 15, 2024
d7a8266
Updated `SponsoredProductAdGroupWithSlicesABC` and `SponsoredProductA…
pnilan Mar 18, 2024
36415cf
Updated mock server tests for SponsoredBrands streams. Updated releva…
pnilan Mar 19, 2024
34d27ef
Update unit tests to handle state filter correctly
pnilan Mar 19, 2024
89a2c84
Update SponsoredBrand and SponsoredProduct state filter
pnilan Mar 19, 2024
b540b43
Updated configured catalog and expected records for new schemas
pnilan Mar 19, 2024
4194c90
Update sponsored product suggested keywords max count per request to …
pnilan Mar 19, 2024
85c7a57
Update changelog to reflect major version bump. update pyproject, met…
pnilan Mar 20, 2024
4d0afb1
Update `SponsoredProductAdGroupBidRecommendations` to include default…
pnilan Mar 20, 2024
5607012
chore: format code
pnilan Mar 20, 2024
9fc5763
Updated amazon-ads.md to provide additional context on theme-based bi…
pnilan Mar 20, 2024
b6950d4
chore: format code
pnilan Mar 20, 2024
2c78b21
Merge branch 'master' into pnilan/source-amazon-ads-issue-2440
pnilan Mar 20, 2024
3a828ee
Update CDK version
pnilan Mar 20, 2024
c1134b0
Updates changelog to reflect cdk update
pnilan Mar 20, 2024
13015d7
Removes redundant stream from configured catalog
pnilan Mar 20, 2024
e27daf6
Merge branch 'master' into pnilan/source-amazon-ads-issue-2440
pnilan Mar 21, 2024
ceb2c5f
Update Keywords models to be specific to Sponsored Products
pnilan Mar 25, 2024
1faa114
Updated sponsored product keywords model naming
pnilan Mar 25, 2024
25d52d6
Update schema fields datatype
pnilan Mar 25, 2024
853c998
Update amazon-ads-migration.md and metadata to reflect breaking changes
pnilan Mar 25, 2024
041d2e3
Update incorrect datatype for campaignId and adGroupId, and adId to "…
pnilan Mar 25, 2024
89bf1f0
Update SponsoredProductAdGroupsSuggestedKeywords schema for schema va…
pnilan Mar 25, 2024
548ebd3
chore: format code
pnilan Mar 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
SponsoredBrandsCampaign V4 update first pass
  • Loading branch information
pnilan committed Mar 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit dbf02d0de98e13bd30b68aa011776bdd6e48bbd7
Original file line number Diff line number Diff line change
@@ -25,6 +25,23 @@ class Creative(CatalogModel):
asins: List[str]
shouldOptimizeAsins: bool

class BrandsCampaignV4(CatalogModel):
campaignId: str
name: str
tags: Dict[str, str]
budget: Decimal
budgetType: str
startDate: str
endDate: str
state: str
brandEntityId: str
portfolioId: str
ruleBasedBudget: Optional[dict]
bidding: Optional[dict]
productLocation: Optional[str]
costType: Optional[str]
smartDefault: Optional[List[str]]
extendedData: Optional[dict]

class BrandsCampaign(CatalogModel):
campaignId: Decimal
Original file line number Diff line number Diff line change
@@ -1,10 +1,70 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from typing import Mapping, Any, MutableMapping

from source_amazon_ads.schemas import BrandsAdGroup, BrandsCampaign
from requests import Response

from source_amazon_ads.schemas import BrandsAdGroup, BrandsCampaign, BrandsCampaignV4
from source_amazon_ads.streams.common import SubProfilesStream

class SponsoredBrandsCampaignsV4(SubProfilesStream):
"""
This stream corresponds to Amazon Ads API - Sponsored Brands Campaigns v4
https://advertising.amazon.com/API/docs/en-us/sponsored-brands/3-0/openapi/prod#tag/Campaigns/operation/ListSponsoredBrandsCampaigns
"""

primary_key = "campaignId"
data_field = "campaigns"
state_filter = None
model = BrandsCampaignV4

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# state filter?
self.state_filter = kwargs.get("config", {}).get("state_filter", None)

def path(self, **kwargs) -> str:
return "sb/v4/campaigns/list"

@property
def http_method(self, **kwargs) -> str:
return "POST"

def request_headers(self, profile_id: str = None, *args, **kwargs) -> MutableMapping[str, Any]:
headers = super().request_headers(*args, **kwargs)
headers["Accept"] = "application/vnd.sbcampaignresource.v4+json"
headers["Content-Type"] = "application/vnd.sbcampaignresource.v4+json"
return headers

def request_body_json(self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None) -> Mapping[str, Any]:
request_body = {}
if self.state_filter:
request_body["stateFilter"] = {
"include": self.state_filter
}
request_body["maxResults"] = self.page_size
request_body["nextToken"] = next_page_token

# tbd if included
# request_body["campaignIdFilter"] = {
# "include": []
# }
# request_body["portfolioIdFilter"] = {
# "include": []
# }
# request_body["includeExtendedDataFields"] = True
# request_body["nameFilter"] = {
# "queryTermMatchType": "EXACT_MATCH",
# "include": []
# }

return request_body

def next_page_token(self, response: Response) -> str:
if not response:
return None
return response.json().get("nextToken", None)

class SponsoredBrandsCampaigns(SubProfilesStream):
"""
@@ -20,7 +80,7 @@ def __init__(self, *args, **kwargs):
state_filter = None
model = BrandsCampaign

def path(self, **kvargs) -> str:
def path(self, **kwargs) -> str:
return "sb/campaigns"

def request_params(self, *args, **kwargs):
@@ -39,7 +99,7 @@ class SponsoredBrandsAdGroups(SubProfilesStream):
primary_key = "adGroupId"
model = BrandsAdGroup

def path(self, **kvargs) -> str:
def path(self, **kwargs) -> str:
return "sb/adGroups"


@@ -52,5 +112,5 @@ class SponsoredBrandsKeywords(SubProfilesStream):
primary_key = "adGroupId"
model = BrandsAdGroup

def path(self, **kvargs) -> str:
def path(self, **kwargs) -> str:
return "sb/keywords"