Skip to content

Commit 1e79e92

Browse files
author
Anton Karpets
authored
šŸ›Source Amazon Seller Partner: hide OSS-only streams in report options config (#38078)
1 parent 5fe60b7 commit 1e79e92

File tree

8 files changed

+325
-34
lines changed

8 files changed

+325
-34
lines changed

ā€Žairbyte-integrations/connectors/source-amazon-seller-partner/acceptance-test-config.yml

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ acceptance_tests:
44
spec:
55
tests:
66
- spec_path: "source_amazon_seller_partner/spec.json"
7-
backward_compatibility_tests_config:
8-
disable_for_version: "2.0.1"
7+
deployment_mode: "cloud"
8+
- spec_path: "integration_tests/spec_oss.json"
99
connection:
1010
tests:
1111
- config_path: "secrets/config.json"
@@ -16,11 +16,7 @@ acceptance_tests:
1616
timeout_seconds: 60
1717
discovery:
1818
tests:
19-
- config_path:
20-
"secrets/config.json"
21-
# refactored `spec`, but `app_id` is required for `1.2.0`
22-
backward_compatibility_tests_config:
23-
disable_for_version: "1.2.0"
19+
- config_path: "secrets/config.json"
2420
basic_read:
2521
tests:
2622
- config_path: "secrets/config.json"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
{
2+
"documentationUrl": "https://docs.airbyte.com/integrations/sources/amazon-seller-partner",
3+
"changelogUrl": "https://docs.airbyte.com/integrations/sources/amazon-seller-partner",
4+
"connectionSpecification": {
5+
"title": "Amazon Seller Partner Spec",
6+
"type": "object",
7+
"required": [
8+
"aws_environment",
9+
"region",
10+
"account_type",
11+
"lwa_app_id",
12+
"lwa_client_secret",
13+
"refresh_token"
14+
],
15+
"additionalProperties": true,
16+
"properties": {
17+
"auth_type": {
18+
"title": "Auth Type",
19+
"const": "oauth2.0",
20+
"order": 0,
21+
"type": "string"
22+
},
23+
"aws_environment": {
24+
"title": "AWS Environment",
25+
"description": "Select the AWS Environment.",
26+
"enum": ["PRODUCTION", "SANDBOX"],
27+
"default": "PRODUCTION",
28+
"type": "string",
29+
"order": 1
30+
},
31+
"region": {
32+
"title": "AWS Region",
33+
"description": "Select the AWS Region.",
34+
"enum": [
35+
"AE",
36+
"AU",
37+
"BE",
38+
"BR",
39+
"CA",
40+
"DE",
41+
"EG",
42+
"ES",
43+
"FR",
44+
"GB",
45+
"IN",
46+
"IT",
47+
"JP",
48+
"MX",
49+
"NL",
50+
"PL",
51+
"SA",
52+
"SE",
53+
"SG",
54+
"TR",
55+
"UK",
56+
"US"
57+
],
58+
"default": "US",
59+
"type": "string",
60+
"order": 2
61+
},
62+
"account_type": {
63+
"title": "AWS Seller Partner Account Type",
64+
"description": "Type of the Account you're going to authorize the Airbyte application by",
65+
"enum": ["Seller", "Vendor"],
66+
"default": "Seller",
67+
"type": "string",
68+
"order": 3
69+
},
70+
"lwa_app_id": {
71+
"title": "LWA Client Id",
72+
"description": "Your Login with Amazon Client ID.",
73+
"order": 4,
74+
"airbyte_secret": true,
75+
"type": "string"
76+
},
77+
"lwa_client_secret": {
78+
"title": "LWA Client Secret",
79+
"description": "Your Login with Amazon Client Secret.",
80+
"airbyte_secret": true,
81+
"order": 5,
82+
"type": "string"
83+
},
84+
"refresh_token": {
85+
"title": "Refresh Token",
86+
"description": "The Refresh Token obtained via OAuth flow authorization.",
87+
"airbyte_secret": true,
88+
"order": 6,
89+
"type": "string"
90+
},
91+
"replication_start_date": {
92+
"title": "Start Date",
93+
"description": "UTC date and time in the format 2017-01-25T00:00:00Z. Any data before this date will not be replicated. If start date is not provided, the date 2 years ago from today will be used.",
94+
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$",
95+
"examples": ["2017-01-25T00:00:00Z"],
96+
"order": 7,
97+
"type": "string",
98+
"format": "date-time"
99+
},
100+
"replication_end_date": {
101+
"title": "End Date",
102+
"description": "UTC date and time in the format 2017-01-25T00:00:00Z. Any data after this date will not be replicated.",
103+
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$|^$",
104+
"examples": ["2017-01-25T00:00:00Z"],
105+
"order": 8,
106+
"type": "string",
107+
"format": "date-time"
108+
},
109+
"period_in_days": {
110+
"title": "Period In Days",
111+
"type": "integer",
112+
"description": "For syncs spanning a large date range, this option is used to request data in a smaller fixed window to improve sync reliability. This time window can be configured granularly by day.",
113+
"default": 90,
114+
"minimum": 1,
115+
"order": 9
116+
},
117+
"report_options_list": {
118+
"title": "Report Options",
119+
"description": "Additional information passed to reports. This varies by report type.",
120+
"order": 10,
121+
"type": "array",
122+
"items": {
123+
"type": "object",
124+
"title": "Report Options",
125+
"required": ["stream_name", "options_list"],
126+
"properties": {
127+
"stream_name": {
128+
"title": "Stream Name",
129+
"type": "string",
130+
"order": 0,
131+
"enum": [
132+
"GET_AFN_INVENTORY_DATA",
133+
"GET_AFN_INVENTORY_DATA_BY_COUNTRY",
134+
"GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL",
135+
"GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA",
136+
"GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA",
137+
"GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_PROMOTION_DATA",
138+
"GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_REPLACEMENT_DATA",
139+
"GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA",
140+
"GET_FBA_FULFILLMENT_REMOVAL_SHIPMENT_DETAIL_DATA",
141+
"GET_FBA_INVENTORY_PLANNING_DATA",
142+
"GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA",
143+
"GET_FBA_REIMBURSEMENTS_DATA",
144+
"GET_FBA_SNS_FORECAST_DATA",
145+
"GET_FBA_SNS_PERFORMANCE_DATA",
146+
"GET_FBA_STORAGE_FEE_CHARGES_DATA",
147+
"GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_SHIPPING",
148+
"GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL",
149+
"GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",
150+
"GET_FLAT_FILE_ARCHIVED_ORDERS_DATA_BY_ORDER_DATE",
151+
"GET_FLAT_FILE_OPEN_LISTINGS_DATA",
152+
"GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE",
153+
"GET_LEDGER_DETAIL_VIEW_DATA",
154+
"GET_LEDGER_SUMMARY_VIEW_DATA",
155+
"GET_MERCHANT_CANCELLED_LISTINGS_DATA",
156+
"GET_MERCHANT_LISTINGS_ALL_DATA",
157+
"GET_MERCHANT_LISTINGS_DATA",
158+
"GET_MERCHANT_LISTINGS_DATA_BACK_COMPAT",
159+
"GET_MERCHANT_LISTINGS_INACTIVE_DATA",
160+
"GET_MERCHANTS_LISTINGS_FYP_REPORT",
161+
"GET_ORDER_REPORT_DATA_SHIPPING",
162+
"GET_RESTOCK_INVENTORY_RECOMMENDATIONS_REPORT",
163+
"GET_SELLER_FEEDBACK_DATA",
164+
"GET_STRANDED_INVENTORY_UI_DATA",
165+
"GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE",
166+
"GET_XML_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",
167+
"GET_XML_BROWSE_TREE_DATA",
168+
"GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT",
169+
"GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT",
170+
"GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT",
171+
"GET_SALES_AND_TRAFFIC_REPORT",
172+
"GET_VENDOR_SALES_REPORT",
173+
"GET_VENDOR_INVENTORY_REPORT",
174+
"GET_VENDOR_NET_PURE_PRODUCT_MARGIN_REPORT",
175+
"GET_VENDOR_TRAFFIC_REPORT"
176+
]
177+
},
178+
"options_list": {
179+
"title": "List of options",
180+
"description": "List of options",
181+
"type": "array",
182+
"items": {
183+
"type": "object",
184+
"required": ["option_name", "option_value"],
185+
"properties": {
186+
"option_name": {
187+
"title": "Name",
188+
"type": "string",
189+
"order": 0
190+
},
191+
"option_value": {
192+
"title": "Value",
193+
"type": "string",
194+
"order": 1
195+
}
196+
}
197+
}
198+
}
199+
}
200+
}
201+
}
202+
}
203+
},
204+
"advanced_auth": {
205+
"auth_flow_type": "oauth2.0",
206+
"predicate_key": ["auth_type"],
207+
"predicate_value": "oauth2.0",
208+
"oauth_config_specification": {
209+
"oauth_user_input_from_connector_config_specification": {
210+
"type": "object",
211+
"properties": {
212+
"region": {
213+
"type": "string",
214+
"path_in_connector_config": ["region"]
215+
},
216+
"account_type": {
217+
"type": "string",
218+
"path_in_connector_config": ["account_type"]
219+
}
220+
}
221+
},
222+
"complete_oauth_output_specification": {
223+
"type": "object",
224+
"additionalProperties": false,
225+
"properties": {
226+
"refresh_token": {
227+
"type": "string",
228+
"path_in_connector_config": ["refresh_token"]
229+
}
230+
}
231+
},
232+
"complete_oauth_server_input_specification": {
233+
"type": "object",
234+
"additionalProperties": false,
235+
"properties": {
236+
"lwa_app_id": {
237+
"type": "string"
238+
},
239+
"lwa_client_secret": {
240+
"type": "string"
241+
}
242+
}
243+
},
244+
"complete_oauth_server_output_specification": {
245+
"type": "object",
246+
"additionalProperties": false,
247+
"properties": {
248+
"lwa_app_id": {
249+
"type": "string",
250+
"path_in_connector_config": ["lwa_app_id"]
251+
},
252+
"lwa_client_secret": {
253+
"type": "string",
254+
"path_in_connector_config": ["lwa_client_secret"]
255+
}
256+
}
257+
}
258+
}
259+
}
260+
}

ā€Žairbyte-integrations/connectors/source-amazon-seller-partner/metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ data:
1515
connectorSubtype: api
1616
connectorType: source
1717
definitionId: e55879a8-0ef8-4557-abcf-ab34c53ec460
18-
dockerImageTag: 4.2.2
18+
dockerImageTag: 4.2.3
1919
dockerRepository: airbyte/source-amazon-seller-partner
2020
documentationUrl: https://docs.airbyte.com/integrations/sources/amazon-seller-partner
2121
githubIssueLabel: source-amazon-seller-partner

ā€Žairbyte-integrations/connectors/source-amazon-seller-partner/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["poetry-core>=1.0.0"]
33
build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
6-
version = "4.2.2"
6+
version = "4.2.3"
77
name = "source-amazon-seller-partner"
88
description = "Source implementation for Amazon Seller Partner."
99
authors = ["Airbyte <[email protected]>"]

ā€Žairbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/source.py

+23-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
33
#
44

5-
6-
from os import getenv
5+
from logging import Logger
76
from typing import Any, List, Mapping, Optional, Tuple
87

98
import pendulum
109
from airbyte_cdk.logger import AirbyteLogger
1110
from airbyte_cdk.models import SyncMode
1211
from airbyte_cdk.sources import AbstractSource
1312
from airbyte_cdk.sources.streams import Stream
14-
from airbyte_cdk.utils import AirbyteTracedException
13+
from airbyte_cdk.utils import AirbyteTracedException, is_cloud_environment
14+
from airbyte_protocol.models import ConnectorSpecification
1515
from requests import HTTPError
1616
from source_amazon_seller_partner.auth import AWSAuthenticator
1717
from source_amazon_seller_partner.constants import get_marketplaces
@@ -190,7 +190,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
190190
]
191191

192192
# TODO: Remove after Brand Analytics will be enabled in CLOUD: https://github.com/airbytehq/airbyte/issues/32353
193-
if getenv("DEPLOYMENT_MODE", "").upper() != "CLOUD":
193+
if not is_cloud_environment():
194194
brand_analytics_reports = [
195195
BrandAnalyticsMarketBasketReports,
196196
BrandAnalyticsSearchTermsReports,
@@ -208,6 +208,25 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
208208
streams.append(stream(**stream_kwargs, report_options=self.get_stream_report_options_list(stream.name, config)))
209209
return streams
210210

211+
def spec(self, logger: Logger) -> ConnectorSpecification:
212+
spec = super().spec(logger)
213+
if not is_cloud_environment():
214+
oss_only_streams = [
215+
"GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT",
216+
"GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT",
217+
"GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT",
218+
"GET_SALES_AND_TRAFFIC_REPORT",
219+
"GET_VENDOR_SALES_REPORT",
220+
"GET_VENDOR_INVENTORY_REPORT",
221+
"GET_VENDOR_NET_PURE_PRODUCT_MARGIN_REPORT",
222+
"GET_VENDOR_TRAFFIC_REPORT",
223+
]
224+
spec.connectionSpecification["properties"]["report_options_list"]["items"]["properties"]["stream_name"]["enum"].extend(
225+
oss_only_streams
226+
)
227+
228+
return spec
229+
211230
@staticmethod
212231
def validate_replication_dates(config: Mapping[str, Any]) -> None:
213232
if (

ā€Žairbyte-integrations/connectors/source-amazon-seller-partner/source_amazon_seller_partner/spec.json

-8
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@
132132
"GET_AFN_INVENTORY_DATA",
133133
"GET_AFN_INVENTORY_DATA_BY_COUNTRY",
134134
"GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL",
135-
"GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT",
136-
"GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT",
137-
"GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT",
138135
"GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA",
139136
"GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA",
140137
"GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_PROMOTION_DATA",
@@ -163,14 +160,9 @@
163160
"GET_MERCHANTS_LISTINGS_FYP_REPORT",
164161
"GET_ORDER_REPORT_DATA_SHIPPING",
165162
"GET_RESTOCK_INVENTORY_RECOMMENDATIONS_REPORT",
166-
"GET_SALES_AND_TRAFFIC_REPORT",
167163
"GET_SELLER_FEEDBACK_DATA",
168164
"GET_STRANDED_INVENTORY_UI_DATA",
169165
"GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE",
170-
"GET_VENDOR_INVENTORY_REPORT",
171-
"GET_VENDOR_NET_PURE_PRODUCT_MARGIN_REPORT",
172-
"GET_VENDOR_TRAFFIC_REPORT",
173-
"GET_VENDOR_SALES_REPORT",
174166
"GET_XML_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",
175167
"GET_XML_BROWSE_TREE_DATA"
176168
]

0 commit comments

Comments
Ā (0)