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 all 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 @@ -4,8 +4,8 @@ acceptance_tests:
spec:
tests:
- spec_path: "source_amazon_seller_partner/spec.json"
backward_compatibility_tests_config:
disable_for_version: "2.0.1"
deployment_mode: "cloud"
- spec_path: "integration_tests/spec_oss.json"
connection:
tests:
- config_path: "secrets/config.json"
Expand All @@ -16,11 +16,7 @@ acceptance_tests:
timeout_seconds: 60
discovery:
tests:
- config_path:
"secrets/config.json"
# refactored `spec`, but `app_id` is required for `1.2.0`
backward_compatibility_tests_config:
disable_for_version: "1.2.0"
- config_path: "secrets/config.json"
basic_read:
tests:
- config_path: "secrets/config.json"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
{
"documentationUrl": "https://docs.airbyte.com/integrations/sources/amazon-seller-partner",
"changelogUrl": "https://docs.airbyte.com/integrations/sources/amazon-seller-partner",
"connectionSpecification": {
"title": "Amazon Seller Partner Spec",
"type": "object",
"required": [
"aws_environment",
"region",
"account_type",
"lwa_app_id",
"lwa_client_secret",
"refresh_token"
],
"additionalProperties": true,
"properties": {
"auth_type": {
"title": "Auth Type",
"const": "oauth2.0",
"order": 0,
"type": "string"
},
"aws_environment": {
"title": "AWS Environment",
"description": "Select the AWS Environment.",
"enum": ["PRODUCTION", "SANDBOX"],
"default": "PRODUCTION",
"type": "string",
"order": 1
},
"region": {
"title": "AWS Region",
"description": "Select the AWS Region.",
"enum": [
"AE",
"AU",
"BE",
"BR",
"CA",
"DE",
"EG",
"ES",
"FR",
"GB",
"IN",
"IT",
"JP",
"MX",
"NL",
"PL",
"SA",
"SE",
"SG",
"TR",
"UK",
"US"
],
"default": "US",
"type": "string",
"order": 2
},
"account_type": {
"title": "AWS Seller Partner Account Type",
"description": "Type of the Account you're going to authorize the Airbyte application by",
"enum": ["Seller", "Vendor"],
"default": "Seller",
"type": "string",
"order": 3
},
"lwa_app_id": {
"title": "LWA Client Id",
"description": "Your Login with Amazon Client ID.",
"order": 4,
"airbyte_secret": true,
"type": "string"
},
"lwa_client_secret": {
"title": "LWA Client Secret",
"description": "Your Login with Amazon Client Secret.",
"airbyte_secret": true,
"order": 5,
"type": "string"
},
"refresh_token": {
"title": "Refresh Token",
"description": "The Refresh Token obtained via OAuth flow authorization.",
"airbyte_secret": true,
"order": 6,
"type": "string"
},
"replication_start_date": {
"title": "Start Date",
"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.",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$",
"examples": ["2017-01-25T00:00:00Z"],
"order": 7,
"type": "string",
"format": "date-time"
},
"replication_end_date": {
"title": "End Date",
"description": "UTC date and time in the format 2017-01-25T00:00:00Z. Any data after this date will not be replicated.",
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$|^$",
"examples": ["2017-01-25T00:00:00Z"],
"order": 8,
"type": "string",
"format": "date-time"
},
"period_in_days": {
"title": "Period In Days",
"type": "integer",
"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.",
"default": 90,
"minimum": 1,
"order": 9
},
"report_options_list": {
"title": "Report Options",
"description": "Additional information passed to reports. This varies by report type.",
"order": 10,
"type": "array",
"items": {
"type": "object",
"title": "Report Options",
"required": ["stream_name", "options_list"],
"properties": {
"stream_name": {
"title": "Stream Name",
"type": "string",
"order": 0,
"enum": [
"GET_AFN_INVENTORY_DATA",
"GET_AFN_INVENTORY_DATA_BY_COUNTRY",
"GET_AMAZON_FULFILLED_SHIPMENTS_DATA_GENERAL",
"GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA",
"GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA",
"GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_PROMOTION_DATA",
"GET_FBA_FULFILLMENT_CUSTOMER_SHIPMENT_REPLACEMENT_DATA",
"GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA",
"GET_FBA_FULFILLMENT_REMOVAL_SHIPMENT_DETAIL_DATA",
"GET_FBA_INVENTORY_PLANNING_DATA",
"GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA",
"GET_FBA_REIMBURSEMENTS_DATA",
"GET_FBA_SNS_FORECAST_DATA",
"GET_FBA_SNS_PERFORMANCE_DATA",
"GET_FBA_STORAGE_FEE_CHARGES_DATA",
"GET_FLAT_FILE_ACTIONABLE_ORDER_DATA_SHIPPING",
"GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL",
"GET_FLAT_FILE_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",
"GET_FLAT_FILE_ARCHIVED_ORDERS_DATA_BY_ORDER_DATE",
"GET_FLAT_FILE_OPEN_LISTINGS_DATA",
"GET_FLAT_FILE_RETURNS_DATA_BY_RETURN_DATE",
"GET_LEDGER_DETAIL_VIEW_DATA",
"GET_LEDGER_SUMMARY_VIEW_DATA",
"GET_MERCHANT_CANCELLED_LISTINGS_DATA",
"GET_MERCHANT_LISTINGS_ALL_DATA",
"GET_MERCHANT_LISTINGS_DATA",
"GET_MERCHANT_LISTINGS_DATA_BACK_COMPAT",
"GET_MERCHANT_LISTINGS_INACTIVE_DATA",
"GET_MERCHANTS_LISTINGS_FYP_REPORT",
"GET_ORDER_REPORT_DATA_SHIPPING",
"GET_RESTOCK_INVENTORY_RECOMMENDATIONS_REPORT",
"GET_SELLER_FEEDBACK_DATA",
"GET_STRANDED_INVENTORY_UI_DATA",
"GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE",
"GET_XML_ALL_ORDERS_DATA_BY_ORDER_DATE_GENERAL",
"GET_XML_BROWSE_TREE_DATA",
"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"
]
},
"options_list": {
"title": "List of options",
"description": "List of options",
"type": "array",
"items": {
"type": "object",
"required": ["option_name", "option_value"],
"properties": {
"option_name": {
"title": "Name",
"type": "string",
"order": 0
},
"option_value": {
"title": "Value",
"type": "string",
"order": 1
}
}
}
}
}
}
}
}
},
"advanced_auth": {
"auth_flow_type": "oauth2.0",
"predicate_key": ["auth_type"],
"predicate_value": "oauth2.0",
"oauth_config_specification": {
"oauth_user_input_from_connector_config_specification": {
"type": "object",
"properties": {
"region": {
"type": "string",
"path_in_connector_config": ["region"]
},
"account_type": {
"type": "string",
"path_in_connector_config": ["account_type"]
}
}
},
"complete_oauth_output_specification": {
"type": "object",
"additionalProperties": false,
"properties": {
"refresh_token": {
"type": "string",
"path_in_connector_config": ["refresh_token"]
}
}
},
"complete_oauth_server_input_specification": {
"type": "object",
"additionalProperties": false,
"properties": {
"lwa_app_id": {
"type": "string"
},
"lwa_client_secret": {
"type": "string"
}
}
},
"complete_oauth_server_output_specification": {
"type": "object",
"additionalProperties": false,
"properties": {
"lwa_app_id": {
"type": "string",
"path_in_connector_config": ["lwa_app_id"]
},
"lwa_client_secret": {
"type": "string",
"path_in_connector_config": ["lwa_client_secret"]
}
}
}
}
}
}
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
Loading
Loading