Skip to content

🐛Source Amazon Seller Partner: hide OSS-only streams in report options config #38078

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

Merged
merged 3 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: e55879a8-0ef8-4557-abcf-ab34c53ec460
dockerImageTag: 4.2.2
dockerImageTag: 4.2.3
dockerRepository: airbyte/source-amazon-seller-partner
documentationUrl: https://docs.airbyte.com/integrations/sources/amazon-seller-partner
githubIssueLabel: source-amazon-seller-partner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
version = "4.2.2"
version = "4.2.3"
name = "source-amazon-seller-partner"
description = "Source implementation for Amazon Seller Partner."
authors = ["Airbyte <[email protected]>"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#


from os import getenv
from logging import Logger
from typing import Any, List, Mapping, Optional, Tuple

import pendulum
from airbyte_cdk.logger import AirbyteLogger
from airbyte_cdk.models import SyncMode
from airbyte_cdk.sources import AbstractSource
from airbyte_cdk.sources.streams import Stream
from airbyte_cdk.utils import AirbyteTracedException
from airbyte_cdk.utils import AirbyteTracedException, is_cloud_environment
from airbyte_protocol.models import ConnectorSpecification
from requests import HTTPError
from source_amazon_seller_partner.auth import AWSAuthenticator
from source_amazon_seller_partner.constants import get_marketplaces
Expand Down Expand Up @@ -190,7 +190,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
]

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

def spec(self, logger: Logger) -> ConnectorSpecification:
spec = super().spec(logger)
if not is_cloud_environment():
oss_only_streams = [
"GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT",
"GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT",
"GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT",
"GET_SALES_AND_TRAFFIC_REPORT",
"GET_VENDOR_SALES_REPORT",
"GET_VENDOR_INVENTORY_REPORT",
"GET_VENDOR_NET_PURE_PRODUCT_MARGIN_REPORT",
"GET_VENDOR_TRAFFIC_REPORT",
]
spec.connectionSpecification["properties"]["report_options_list"]["items"]["properties"]["stream_name"]["enum"].extend(
oss_only_streams
)

return spec

@staticmethod
def validate_replication_dates(config: Mapping[str, Any]) -> None:
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@
"GET_AFN_INVENTORY_DATA",
"GET_AFN_INVENTORY_DATA_BY_COUNTRY",
"GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL",
"GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT",
"GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT",
"GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT",
"GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA",
"GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA",
"GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_PROMOTION_DATA",
Expand Down Expand Up @@ -163,14 +160,9 @@
"GET_MERCHANTS_LISTINGS_FYP_REPORT",
"GET_ORDER_REPORT_DATA_SHIPPING",
"GET_RESTOCK_INVENTORY_RECOMMENDATIONS_REPORT",
"GET_SALES_AND_TRAFFIC_REPORT",
"GET_SELLER_FEEDBACK_DATA",
"GET_STRANDED_INVENTORY_UI_DATA",
"GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE",
"GET_VENDOR_INVENTORY_REPORT",
"GET_VENDOR_NET_PURE_PRODUCT_MARGIN_REPORT",
"GET_VENDOR_TRAFFIC_REPORT",
"GET_VENDOR_SALES_REPORT",
"GET_XML_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",
"GET_XML_BROWSE_TREE_DATA"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ def test_streams(connector_config_without_start_date):
assert isinstance(stream, Stream)


def test_streams_connector_config_without_start_date(connector_config_without_start_date):
for stream in SourceAmazonSellerPartner().streams(connector_config_without_start_date):
assert isinstance(stream, Stream)
@pytest.mark.parametrize(("deployment_mode", "expected_streams_count"), (("cloud", 44), ("oss", 53)))
def test_streams_count(deployment_mode, expected_streams_count, connector_config_without_start_date, monkeypatch):
monkeypatch.setenv("DEPLOYMENT_MODE", deployment_mode)
streams = SourceAmazonSellerPartner().streams(connector_config_without_start_date)
assert len(streams) == expected_streams_count


@pytest.mark.parametrize(
Expand All @@ -177,3 +179,22 @@ def test_replication_dates_validation(config, should_raise):
assert e.value.message == "End Date should be greater than or equal to Start Date"
else:
assert SourceAmazonSellerPartner().validate_replication_dates(config) is None


@pytest.mark.parametrize(("deployment_mode", "common_streams_count"), (("cloud", 0), ("oss", 8)))
def test_spec(deployment_mode, common_streams_count, monkeypatch):
monkeypatch.setenv("DEPLOYMENT_MODE", deployment_mode)
oss_only_streams = {
"GET_BRAND_ANALYTICS_MARKET_BASKET_REPORT",
"GET_BRAND_ANALYTICS_SEARCH_TERMS_REPORT",
"GET_BRAND_ANALYTICS_REPEAT_PURCHASE_REPORT",
"GET_SALES_AND_TRAFFIC_REPORT",
"GET_VENDOR_SALES_REPORT",
"GET_VENDOR_INVENTORY_REPORT",
"GET_VENDOR_NET_PURE_PRODUCT_MARGIN_REPORT",
"GET_VENDOR_TRAFFIC_REPORT",
}
streams_with_report_options = SourceAmazonSellerPartner().spec(
logger
).connectionSpecification["properties"]["report_options_list"]["items"]["properties"]["stream_name"]["enum"]
assert len(set(streams_with_report_options).intersection(oss_only_streams)) == common_streams_count
23 changes: 13 additions & 10 deletions docs/integrations/sources/amazon-seller-partner.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ The Amazon Seller Partner source connector supports the following [sync modes](h

- [Active Listings Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-inventory) \(incremental\)
- [All Listings Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-inventory) \(incremental\)
- [Amazon Search Terms Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#brand-analytics-reports) \(only available in OSS, incremental\)
- [Browse Tree Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-browse-tree) \(incremental\)
- [Canceled Listings Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-inventory) \(incremental\)
- [FBA Amazon Fulfilled Inventory Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-fba#fba-inventory-reports) \(incremental\)
Expand Down Expand Up @@ -120,27 +119,30 @@ The Amazon Seller Partner source connector supports the following [sync modes](h
- [Inventory Ledger Report - Detailed View](https://developer-docs.amazon.com/sp-api/docs/report-type-values-fba#fba-inventory-reports) \(incremental\)
- [Inventory Ledger Report - Summary View](https://developer-docs.amazon.com/sp-api/docs/report-type-values-fba#fba-inventory-reports) \(incremental\)
- [Inventory Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-inventory) \(incremental\)
- [Market Basket Analysis Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#brand-analytics-reports) \(only available in OSS, incremental\)
- [Net Pure Product Margin Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#vendor-retail-analytics-reports) \(incremental\)
- [Open Listings Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-inventory) \(incremental\)
- [Orders](https://developer-docs.amazon.com/sp-api/docs/orders-api-v0-reference) \(incremental\)
- [Order Items](https://developer-docs.amazon.com/sp-api/docs/orders-api-v0-reference#getorderitems) \(incremental\)
- [Rapid Retail Analytics Inventory Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#vendor-retail-analytics-reports) \(incremental\)
- [Repeat Purchase](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#brand-analytics-reports) \(only available in OSS, incremental\)
- [Restock Inventory Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-fba#fba-inventory-reports) \(incremental\)
- [Sales and Traffic Business Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#seller-retail-analytics-reports) \(incremental\)
- [Scheduled XML Order Report (Shipping)](https://developer-docs.amazon.com/sp-api/docs/report-type-values-order#order-reports) \(incremental\)
- [Subscribe and Save Forecast Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-fba#fba-subscribe-and-save-reports) \(incremental\)
- [Subscribe and Save Performance Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-fba#fba-subscribe-and-save-reports) \(incremental\)
- [Suppressed Listings Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-inventory) \(incremental\)
- [Unshipped Orders Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-order#order-reports) \(incremental\)
- [Vendor Direct Fulfillment Shipping](https://developer-docs.amazon.com/sp-api/docs/vendor-direct-fulfillment-shipping-api-v1-reference) \(incremental\)
- [Vendor Inventory Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#vendor-retail-analytics-reports) \(incremental\)
- [Vendor Forecasting Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#vendor-retail-analytics-reports) \(full-refresh\)
- [Vendor Orders](https://developer-docs.amazon.com/sp-api/docs/vendor-orders-api-v1-reference#get-vendorordersv1purchaseorders) \(incremental\)
- [Vendor Sales Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#vendor-retail-analytics-reports) \(incremental\)
- [Vendor Traffic Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#vendor-retail-analytics-reports) \(incremental\)
- [XML Orders By Order Date Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-order#order-tracking-reports) \(incremental\)
<!-- env:oss -->
- [Amazon Search Terms Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#brand-analytics-reports) \(only available in OSS, incremental\)
- [Market Basket Analysis Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#brand-analytics-reports) \(only available in OSS, incremental\)
- [Net Pure Product Margin Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#vendor-retail-analytics-reports) \(only available in OSS, incremental\)
- [Rapid Retail Analytics Inventory Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#vendor-retail-analytics-reports) \(only available in OSS, incremental\)
- [Repeat Purchase](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#brand-analytics-reports) \(only available in OSS, incremental\)
- [Sales and Traffic Business Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#seller-retail-analytics-reports) \(only available in OSS, incremental\)
- [Vendor Inventory Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#vendor-retail-analytics-reports) \(only available in OSS, incremental\)
- [Vendor Sales Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#vendor-retail-analytics-reports) \(only available in OSS, incremental\)
- [Vendor Traffic Report](https://developer-docs.amazon.com/sp-api/docs/report-type-values-analytics#vendor-retail-analytics-reports) \(only available in OSS, incremental\)
<!-- /env:oss -->

## Report options

Expand Down Expand Up @@ -172,7 +174,8 @@ Information about rate limits you may find [here](https://developer-docs.amazon.
## Changelog

| Version | Date | Pull Request | Subject |
| :------ | :--------- | :-------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|:--------|:-----------|:----------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 4.2.3 | 2024-05-09 | [#38078](https://github.com/airbytehq/airbyte/pull/38078) | Hide OSS-only streams in report options config for cloud users |
| 4.2.2 | 2024-04-24 | [#36630](https://github.com/airbytehq/airbyte/pull/36630) | Schema descriptions and CDK 0.80.0 |
| 4.2.1 | 2024-04-08 | [#36895](https://github.com/airbytehq/airbyte/pull/36895) | Fix `reportPeriod` day query params |
| 4.2.0 | 2024-03-19 | [#36267](https://github.com/airbytehq/airbyte/pull/36267) | Pin airbyte-cdk version to `^0` |
Expand Down
Loading