amazon-ads-api-v1 0.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ads_api/__init__.py +25 -0
- ads_api/base.py +208 -0
- ads_api/client/__init__.py +103 -0
- ads_api/client/v0/__init__.py +132 -0
- ads_api/client/v0/accounts/__init__.py +77 -0
- ads_api/client/v0/accounts/advertising_accounts.py +96 -0
- ads_api/client/v0/accounts/dsp_advertisers.py +79 -0
- ads_api/client/v0/accounts/manager_accounts.py +144 -0
- ads_api/client/v0/accounts/profiles.py +111 -0
- ads_api/client/v0/accounts/terms_token.py +64 -0
- ads_api/client/v0/accounts/test_accounts.py +57 -0
- ads_api/client/v0/accounts/user_invitations.py +158 -0
- ads_api/client/v0/accounts/user_permissions.py +169 -0
- ads_api/client/v0/ads_data_manager/__init__.py +61 -0
- ads_api/client/v0/ads_data_manager/audiences.py +120 -0
- ads_api/client/v0/ads_data_manager/data_rooms.py +62 -0
- ads_api/client/v0/ads_data_manager/datasets.py +154 -0
- ads_api/client/v0/ads_data_manager/identity_deletion.py +42 -0
- ads_api/client/v0/ads_data_manager/sharing_rules.py +73 -0
- ads_api/client/v0/ads_data_manager/terms.py +55 -0
- ads_api/client/v0/discovery/__init__.py +29 -0
- ads_api/client/v0/discovery/locations.py +65 -0
- ads_api/client/v0/discovery/targetable_entities.py +77 -0
- ads_api/client/v0/exports/__init__.py +5 -0
- ads_api/client/v0/exports/exports.py +180 -0
- ads_api/client/v0/portfolios/__init__.py +5 -0
- ads_api/client/v0/portfolios/portfolios.py +131 -0
- ads_api/client/v0/products/__init__.py +29 -0
- ads_api/client/v0/products/product_eligibility.py +64 -0
- ads_api/client/v0/products/product_metadata.py +43 -0
- ads_api/client/v0/reporting/__init__.py +69 -0
- ads_api/client/v0/reporting/brand_benchmarks.py +103 -0
- ads_api/client/v0/reporting/brand_metrics.py +97 -0
- ads_api/client/v0/reporting/mmm_brand_group_overrides.py +57 -0
- ads_api/client/v0/reporting/mmm_brand_groups.py +91 -0
- ads_api/client/v0/reporting/mmm_reports.py +74 -0
- ads_api/client/v0/reporting/reports.py +84 -0
- ads_api/client/v0/reporting/store_insights.py +85 -0
- ads_api/client/v0/sb_v4/__init__.py +109 -0
- ads_api/client/v0/sb_v4/ad_creatives.py +198 -0
- ads_api/client/v0/sb_v4/ad_groups.py +143 -0
- ads_api/client/v0/sb_v4/ads.py +407 -0
- ads_api/client/v0/sb_v4/budget_rules.py +207 -0
- ads_api/client/v0/sb_v4/budget_usage.py +47 -0
- ads_api/client/v0/sb_v4/campaigns.py +143 -0
- ads_api/client/v0/sb_v4/forecasts.py +47 -0
- ads_api/client/v0/sb_v4/insights.py +64 -0
- ads_api/client/v0/sb_v4/optimization_rules.py +182 -0
- ads_api/client/v0/sb_v4/product_targeting_categories.py +162 -0
- ads_api/client/v0/sb_v4/recommendations.py +129 -0
- ads_api/client/v0/sb_v4/v3_campaign_migration.py +135 -0
- ads_api/client/v0/sd/__init__.py +157 -0
- ads_api/client/v0/sd/ad_groups.py +318 -0
- ads_api/client/v0/sd/bid_recommendations.py +50 -0
- ads_api/client/v0/sd/brand_safety_list.py +149 -0
- ads_api/client/v0/sd/budget_recommendations.py +47 -0
- ads_api/client/v0/sd/budget_rules.py +207 -0
- ads_api/client/v0/sd/budget_usage.py +47 -0
- ads_api/client/v0/sd/campaigns.py +318 -0
- ads_api/client/v0/sd/creatives.py +188 -0
- ads_api/client/v0/sd/forecasts.py +45 -0
- ads_api/client/v0/sd/headline_recommendations.py +47 -0
- ads_api/client/v0/sd/locations_beta.py +113 -0
- ads_api/client/v0/sd/negative_targeting.py +331 -0
- ads_api/client/v0/sd/optimization_rules_beta.py +222 -0
- ads_api/client/v0/sd/product_ads.py +322 -0
- ads_api/client/v0/sd/reports.py +83 -0
- ads_api/client/v0/sd/snapshots.py +71 -0
- ads_api/client/v0/sd/targeting.py +322 -0
- ads_api/client/v0/sd/targeting_recommendations.py +69 -0
- ads_api/client/v0/sp_v3/__init__.py +209 -0
- ads_api/client/v0/sp_v3/ad_groups.py +155 -0
- ads_api/client/v0/sp_v3/budget_recommendation_new_campaigns.py +50 -0
- ads_api/client/v0/sp_v3/budget_recommendations_and_missed_opportunities.py +47 -0
- ads_api/client/v0/sp_v3/budget_rules.py +251 -0
- ads_api/client/v0/sp_v3/budget_rules_recommendation.py +63 -0
- ads_api/client/v0/sp_v3/budget_usage.py +47 -0
- ads_api/client/v0/sp_v3/campaign_negative_keywords.py +207 -0
- ads_api/client/v0/sp_v3/campaign_negative_targeting_clauses.py +209 -0
- ads_api/client/v0/sp_v3/campaign_optimization_rules.py +190 -0
- ads_api/client/v0/sp_v3/campaigns.py +155 -0
- ads_api/client/v0/sp_v3/consolidated_recommendations.py +102 -0
- ads_api/client/v0/sp_v3/keyword_group_targeting_recommendations.py +50 -0
- ads_api/client/v0/sp_v3/keyword_targets.py +63 -0
- ads_api/client/v0/sp_v3/keywords.py +155 -0
- ads_api/client/v0/sp_v3/multi_country_theme_based_bid_recommendations.py +42 -0
- ads_api/client/v0/sp_v3/negative_keywords.py +167 -0
- ads_api/client/v0/sp_v3/negative_targeting_clauses.py +207 -0
- ads_api/client/v0/sp_v3/optimization_rules.py +179 -0
- ads_api/client/v0/sp_v3/product_ads.py +158 -0
- ads_api/client/v0/sp_v3/product_recommendation_service.py +47 -0
- ads_api/client/v0/sp_v3/product_targeting.py +628 -0
- ads_api/client/v0/sp_v3/target_promotion_groups.py +203 -0
- ads_api/client/v0/sp_v3/targeting_clauses.py +167 -0
- ads_api/client/v0/sp_v3/theme_based_bid_recommendations.py +43 -0
- ads_api/client/v1/__init__.py +163 -0
- ads_api/client/v1/advertiser_accounts.py +82 -0
- ads_api/client/v1/brand_store_edition_publish_versions.py +61 -0
- ads_api/client/v1/brand_store_editions.py +64 -0
- ads_api/client/v1/brand_store_pages.py +37 -0
- ads_api/client/v1/brand_stores.py +35 -0
- ads_api/client/v1/dsp/__init__.py +181 -0
- ads_api/client/v1/dsp/ad_associations.py +97 -0
- ads_api/client/v1/dsp/ad_groups.py +70 -0
- ads_api/client/v1/dsp/ads.py +64 -0
- ads_api/client/v1/dsp/campaign_forecasts.py +39 -0
- ads_api/client/v1/dsp/campaigns.py +70 -0
- ads_api/client/v1/dsp/commitment_spends.py +39 -0
- ads_api/client/v1/dsp/commitments.py +126 -0
- ads_api/client/v1/dsp/deal_preferences.py +69 -0
- ads_api/client/v1/dsp/geo_locations.py +37 -0
- ads_api/client/v1/dsp/location_indexes.py +107 -0
- ads_api/client/v1/dsp/supplier_ad_product_prices.py +39 -0
- ads_api/client/v1/dsp/supplier_ad_products.py +39 -0
- ads_api/client/v1/dsp/supplier_proposal_destinations.py +42 -0
- ads_api/client/v1/dsp/supplier_proposals.py +82 -0
- ads_api/client/v1/dsp/supplier_proposed_deal_forecasts.py +39 -0
- ads_api/client/v1/dsp/supplier_proposed_deal_historical_versions.py +44 -0
- ads_api/client/v1/dsp/supplier_proposed_deal_revisions.py +60 -0
- ads_api/client/v1/dsp/supplier_proposed_deals.py +82 -0
- ads_api/client/v1/dsp/supplier_publishers.py +39 -0
- ads_api/client/v1/dsp/supplier_target_items.py +39 -0
- ads_api/client/v1/dsp/targets.py +68 -0
- ads_api/client/v1/manager_accounts.py +78 -0
- ads_api/client/v1/reports.py +65 -0
- ads_api/client/v1/sb/__init__.py +109 -0
- ads_api/client/v1/sb/ad_extensions.py +78 -0
- ads_api/client/v1/sb/ad_groups.py +85 -0
- ads_api/client/v1/sb/ads.py +79 -0
- ads_api/client/v1/sb/advertising_deal_targets.py +82 -0
- ads_api/client/v1/sb/advertising_deals.py +103 -0
- ads_api/client/v1/sb/branded_keywords_pricings.py +39 -0
- ads_api/client/v1/sb/campaigns.py +87 -0
- ads_api/client/v1/sb/keyword_reservation_validations.py +39 -0
- ads_api/client/v1/sb/recommendation_types.py +39 -0
- ads_api/client/v1/sb/recommendations.py +37 -0
- ads_api/client/v1/sb/reserved_target_pricings.py +39 -0
- ads_api/client/v1/sb/targets.py +85 -0
- ads_api/client/v1/sd/__init__.py +45 -0
- ads_api/client/v1/sd/ad_groups.py +85 -0
- ads_api/client/v1/sd/ads.py +79 -0
- ads_api/client/v1/sd/campaigns.py +87 -0
- ads_api/client/v1/sd/targets.py +85 -0
- ads_api/client/v1/selling_accounts.py +39 -0
- ads_api/client/v1/sp/__init__.py +53 -0
- ads_api/client/v1/sp/ad_extensions.py +78 -0
- ads_api/client/v1/sp/ad_groups.py +85 -0
- ads_api/client/v1/sp/ads.py +79 -0
- ads_api/client/v1/sp/campaigns.py +87 -0
- ads_api/client/v1/sp/targets.py +85 -0
- ads_api/client/v1/sp_global/__init__.py +53 -0
- ads_api/client/v1/sp_global/ad_extensions.py +82 -0
- ads_api/client/v1/sp_global/ad_groups.py +95 -0
- ads_api/client/v1/sp_global/ads.py +85 -0
- ads_api/client/v1/sp_global/campaigns.py +95 -0
- ads_api/client/v1/sp_global/targets.py +87 -0
- ads_api/client/v1/st/__init__.py +45 -0
- ads_api/client/v1/st/ad_groups.py +68 -0
- ads_api/client/v1/st/ads.py +79 -0
- ads_api/client/v1/st/campaigns.py +70 -0
- ads_api/client/v1/st/targets.py +85 -0
- ads_api/config/__init__.py +1 -0
- ads_api/config/region.py +18 -0
- ads_api/config/settings.py +102 -0
- ads_api/config/token_cache.py +137 -0
- ads_api/config/token_manager.py +152 -0
- ads_api/errors.py +160 -0
- ads_api/models/__init__.py +1 -0
- ads_api/models/_core/__init__.py +0 -0
- ads_api/models/_core/base.py +13 -0
- ads_api/models/_core/lenient_enum.py +23 -0
- ads_api/models/v0/__init__.py +0 -0
- ads_api/models/v0/_shared.py +1690 -0
- ads_api/models/v0/accounts/__init__.py +0 -0
- ads_api/models/v0/accounts/advertising_accounts.py +178 -0
- ads_api/models/v0/accounts/dsp_advertisers.py +74 -0
- ads_api/models/v0/accounts/manager_accounts.py +148 -0
- ads_api/models/v0/accounts/profiles.py +348 -0
- ads_api/models/v0/accounts/terms_token.py +54 -0
- ads_api/models/v0/accounts/test_accounts.py +47 -0
- ads_api/models/v0/accounts/user_invitations.py +214 -0
- ads_api/models/v0/accounts/user_permissions.py +257 -0
- ads_api/models/v0/ads_data_manager/__init__.py +0 -0
- ads_api/models/v0/ads_data_manager/audiences.py +303 -0
- ads_api/models/v0/ads_data_manager/data_rooms.py +52 -0
- ads_api/models/v0/ads_data_manager/datasets.py +169 -0
- ads_api/models/v0/ads_data_manager/identity_deletion.py +39 -0
- ads_api/models/v0/ads_data_manager/sharing_rules.py +574 -0
- ads_api/models/v0/ads_data_manager/terms.py +31 -0
- ads_api/models/v0/discovery/__init__.py +0 -0
- ads_api/models/v0/discovery/locations.py +26 -0
- ads_api/models/v0/discovery/targetable_entities.py +193 -0
- ads_api/models/v0/exports/__init__.py +0 -0
- ads_api/models/v0/exports/exports.py +112 -0
- ads_api/models/v0/portfolios/__init__.py +0 -0
- ads_api/models/v0/portfolios/portfolios.py +533 -0
- ads_api/models/v0/products/__init__.py +0 -0
- ads_api/models/v0/products/product_eligibility.py +311 -0
- ads_api/models/v0/products/product_metadata.py +148 -0
- ads_api/models/v0/reporting/__init__.py +0 -0
- ads_api/models/v0/reporting/brand_benchmarks.py +34 -0
- ads_api/models/v0/reporting/brand_metrics.py +141 -0
- ads_api/models/v0/reporting/mmm_brand_group_overrides.py +3 -0
- ads_api/models/v0/reporting/mmm_brand_groups.py +3 -0
- ads_api/models/v0/reporting/mmm_reports.py +79 -0
- ads_api/models/v0/reporting/reports.py +128 -0
- ads_api/models/v0/reporting/store_insights.py +539 -0
- ads_api/models/v0/sb_v4/__init__.py +0 -0
- ads_api/models/v0/sb_v4/ad_creatives.py +508 -0
- ads_api/models/v0/sb_v4/ad_groups.py +245 -0
- ads_api/models/v0/sb_v4/ads.py +750 -0
- ads_api/models/v0/sb_v4/budget_rules.py +249 -0
- ads_api/models/v0/sb_v4/budget_usage.py +17 -0
- ads_api/models/v0/sb_v4/campaigns.py +577 -0
- ads_api/models/v0/sb_v4/forecasts.py +225 -0
- ads_api/models/v0/sb_v4/insights.py +119 -0
- ads_api/models/v0/sb_v4/optimization_rules.py +224 -0
- ads_api/models/v0/sb_v4/product_targeting_categories.py +187 -0
- ads_api/models/v0/sb_v4/recommendations.py +198 -0
- ads_api/models/v0/sb_v4/v3_campaign_migration.py +137 -0
- ads_api/models/v0/sd/__init__.py +0 -0
- ads_api/models/v0/sd/ad_groups.py +207 -0
- ads_api/models/v0/sd/bid_recommendations.py +314 -0
- ads_api/models/v0/sd/brand_safety_list.py +139 -0
- ads_api/models/v0/sd/budget_recommendations.py +87 -0
- ads_api/models/v0/sd/budget_rules.py +245 -0
- ads_api/models/v0/sd/budget_usage.py +17 -0
- ads_api/models/v0/sd/campaigns.py +230 -0
- ads_api/models/v0/sd/creatives.py +471 -0
- ads_api/models/v0/sd/forecasts.py +414 -0
- ads_api/models/v0/sd/headline_recommendations.py +48 -0
- ads_api/models/v0/sd/locations_beta.py +100 -0
- ads_api/models/v0/sd/negative_targeting.py +133 -0
- ads_api/models/v0/sd/optimization_rules_beta.py +134 -0
- ads_api/models/v0/sd/product_ads.py +158 -0
- ads_api/models/v0/sd/reports.py +76 -0
- ads_api/models/v0/sd/snapshots.py +50 -0
- ads_api/models/v0/sd/targeting.py +368 -0
- ads_api/models/v0/sd/targeting_recommendations.py +651 -0
- ads_api/models/v0/sp_v3/__init__.py +0 -0
- ads_api/models/v0/sp_v3/ad_groups.py +341 -0
- ads_api/models/v0/sp_v3/budget_recommendation_new_campaigns.py +149 -0
- ads_api/models/v0/sp_v3/budget_recommendations_and_missed_opportunities.py +95 -0
- ads_api/models/v0/sp_v3/budget_rules.py +405 -0
- ads_api/models/v0/sp_v3/budget_rules_recommendation.py +66 -0
- ads_api/models/v0/sp_v3/budget_usage.py +49 -0
- ads_api/models/v0/sp_v3/campaign_negative_keywords.py +246 -0
- ads_api/models/v0/sp_v3/campaign_negative_targeting_clauses.py +262 -0
- ads_api/models/v0/sp_v3/campaign_optimization_rules.py +247 -0
- ads_api/models/v0/sp_v3/campaigns.py +681 -0
- ads_api/models/v0/sp_v3/consolidated_recommendations.py +264 -0
- ads_api/models/v0/sp_v3/keyword_group_targeting_recommendations.py +53 -0
- ads_api/models/v0/sp_v3/keyword_targets.py +169 -0
- ads_api/models/v0/sp_v3/keywords.py +291 -0
- ads_api/models/v0/sp_v3/multi_country_theme_based_bid_recommendations.py +93 -0
- ads_api/models/v0/sp_v3/negative_keywords.py +263 -0
- ads_api/models/v0/sp_v3/negative_targeting_clauses.py +263 -0
- ads_api/models/v0/sp_v3/optimization_rules.py +611 -0
- ads_api/models/v0/sp_v3/product_ads.py +514 -0
- ads_api/models/v0/sp_v3/product_recommendation_service.py +86 -0
- ads_api/models/v0/sp_v3/product_targeting.py +336 -0
- ads_api/models/v0/sp_v3/target_promotion_groups.py +853 -0
- ads_api/models/v0/sp_v3/targeting_clauses.py +449 -0
- ads_api/models/v0/sp_v3/theme_based_bid_recommendations.py +154 -0
- ads_api/models/v1/__init__.py +0 -0
- ads_api/models/v1/_shared/__init__.py +0 -0
- ads_api/models/v1/_shared/dsp.py +3210 -0
- ads_api/models/v1/_shared/general.py +755 -0
- ads_api/models/v1/_shared/sb.py +381 -0
- ads_api/models/v1/_shared/sd.py +319 -0
- ads_api/models/v1/_shared/sp.py +399 -0
- ads_api/models/v1/_shared/sp_global.py +429 -0
- ads_api/models/v1/_shared/st.py +257 -0
- ads_api/models/v1/ad_associations/__init__.py +0 -0
- ads_api/models/v1/ad_associations/dsp.py +123 -0
- ads_api/models/v1/ad_extensions/__init__.py +0 -0
- ads_api/models/v1/ad_extensions/sb.py +204 -0
- ads_api/models/v1/ad_extensions/sp.py +254 -0
- ads_api/models/v1/ad_extensions/sp_global.py +220 -0
- ads_api/models/v1/ad_groups/__init__.py +0 -0
- ads_api/models/v1/ad_groups/dsp.py +543 -0
- ads_api/models/v1/ad_groups/sb.py +173 -0
- ads_api/models/v1/ad_groups/sd.py +265 -0
- ads_api/models/v1/ad_groups/sp.py +234 -0
- ads_api/models/v1/ad_groups/sp_global.py +333 -0
- ads_api/models/v1/ad_groups/st.py +199 -0
- ads_api/models/v1/ads/__init__.py +0 -0
- ads_api/models/v1/ads/dsp.py +2069 -0
- ads_api/models/v1/ads/sb.py +1037 -0
- ads_api/models/v1/ads/sd.py +418 -0
- ads_api/models/v1/ads/sp.py +318 -0
- ads_api/models/v1/ads/sp_global.py +339 -0
- ads_api/models/v1/ads/st.py +293 -0
- ads_api/models/v1/advertiser_accounts/__init__.py +0 -0
- ads_api/models/v1/advertiser_accounts/general.py +262 -0
- ads_api/models/v1/advertising_deal_targets/__init__.py +0 -0
- ads_api/models/v1/advertising_deal_targets/sb.py +105 -0
- ads_api/models/v1/advertising_deals/__init__.py +0 -0
- ads_api/models/v1/advertising_deals/sb.py +158 -0
- ads_api/models/v1/brand_store_edition_publish_versions/__init__.py +0 -0
- ads_api/models/v1/brand_store_edition_publish_versions/general.py +124 -0
- ads_api/models/v1/brand_store_editions/__init__.py +0 -0
- ads_api/models/v1/brand_store_editions/general.py +31 -0
- ads_api/models/v1/brand_store_pages/__init__.py +0 -0
- ads_api/models/v1/brand_store_pages/general.py +1666 -0
- ads_api/models/v1/brand_stores/__init__.py +0 -0
- ads_api/models/v1/brand_stores/general.py +49 -0
- ads_api/models/v1/branded_keywords_pricings/__init__.py +0 -0
- ads_api/models/v1/branded_keywords_pricings/sb.py +94 -0
- ads_api/models/v1/campaign_forecasts/__init__.py +0 -0
- ads_api/models/v1/campaign_forecasts/dsp.py +2938 -0
- ads_api/models/v1/campaigns/__init__.py +0 -0
- ads_api/models/v1/campaigns/dsp.py +561 -0
- ads_api/models/v1/campaigns/sb.py +561 -0
- ads_api/models/v1/campaigns/sd.py +323 -0
- ads_api/models/v1/campaigns/sp.py +563 -0
- ads_api/models/v1/campaigns/sp_global.py +561 -0
- ads_api/models/v1/campaigns/st.py +226 -0
- ads_api/models/v1/commitment_spends/__init__.py +0 -0
- ads_api/models/v1/commitment_spends/dsp.py +109 -0
- ads_api/models/v1/commitments/__init__.py +0 -0
- ads_api/models/v1/commitments/dsp.py +194 -0
- ads_api/models/v1/deal_preferences/__init__.py +0 -0
- ads_api/models/v1/deal_preferences/dsp.py +106 -0
- ads_api/models/v1/geo_locations/__init__.py +0 -0
- ads_api/models/v1/geo_locations/dsp.py +163 -0
- ads_api/models/v1/keyword_reservation_validations/__init__.py +0 -0
- ads_api/models/v1/keyword_reservation_validations/sb.py +56 -0
- ads_api/models/v1/location_indexes/__init__.py +0 -0
- ads_api/models/v1/location_indexes/dsp.py +211 -0
- ads_api/models/v1/manager_accounts/__init__.py +0 -0
- ads_api/models/v1/manager_accounts/general.py +131 -0
- ads_api/models/v1/recommendation_types/__init__.py +0 -0
- ads_api/models/v1/recommendation_types/sb.py +27 -0
- ads_api/models/v1/recommendations/__init__.py +0 -0
- ads_api/models/v1/recommendations/sb.py +146 -0
- ads_api/models/v1/reports/__init__.py +0 -0
- ads_api/models/v1/reports/general.py +371 -0
- ads_api/models/v1/reserved_target_pricings/__init__.py +0 -0
- ads_api/models/v1/reserved_target_pricings/sb.py +46 -0
- ads_api/models/v1/selling_accounts/__init__.py +0 -0
- ads_api/models/v1/selling_accounts/general.py +88 -0
- ads_api/models/v1/supplier_ad_product_prices/__init__.py +0 -0
- ads_api/models/v1/supplier_ad_product_prices/dsp.py +704 -0
- ads_api/models/v1/supplier_ad_products/__init__.py +0 -0
- ads_api/models/v1/supplier_ad_products/dsp.py +744 -0
- ads_api/models/v1/supplier_proposal_destinations/__init__.py +0 -0
- ads_api/models/v1/supplier_proposal_destinations/dsp.py +79 -0
- ads_api/models/v1/supplier_proposals/__init__.py +0 -0
- ads_api/models/v1/supplier_proposals/dsp.py +360 -0
- ads_api/models/v1/supplier_proposed_deal_forecasts/__init__.py +0 -0
- ads_api/models/v1/supplier_proposed_deal_forecasts/dsp.py +792 -0
- ads_api/models/v1/supplier_proposed_deal_historical_versions/__init__.py +0 -0
- ads_api/models/v1/supplier_proposed_deal_historical_versions/dsp.py +608 -0
- ads_api/models/v1/supplier_proposed_deal_revisions/__init__.py +0 -0
- ads_api/models/v1/supplier_proposed_deal_revisions/dsp.py +1171 -0
- ads_api/models/v1/supplier_proposed_deals/__init__.py +0 -0
- ads_api/models/v1/supplier_proposed_deals/dsp.py +1075 -0
- ads_api/models/v1/supplier_publishers/__init__.py +0 -0
- ads_api/models/v1/supplier_publishers/dsp.py +701 -0
- ads_api/models/v1/supplier_target_items/__init__.py +0 -0
- ads_api/models/v1/supplier_target_items/dsp.py +132 -0
- ads_api/models/v1/targets/__init__.py +0 -0
- ads_api/models/v1/targets/dsp.py +1573 -0
- ads_api/models/v1/targets/sb.py +480 -0
- ads_api/models/v1/targets/sd.py +580 -0
- ads_api/models/v1/targets/sp.py +587 -0
- ads_api/models/v1/targets/sp_global.py +715 -0
- ads_api/models/v1/targets/st.py +230 -0
- amazon_ads_api_v1-0.11.0.dist-info/METADATA +164 -0
- amazon_ads_api_v1-0.11.0.dist-info/RECORD +372 -0
- amazon_ads_api_v1-0.11.0.dist-info/WHEEL +4 -0
ads_api/__init__.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Amazon Ads API package (Synchronous)."""
|
|
2
|
+
|
|
3
|
+
from ads_api.base import ClientContext
|
|
4
|
+
from ads_api.client import AdsClient
|
|
5
|
+
from ads_api.client.v0 import AdsClientV0
|
|
6
|
+
from ads_api.client.v1 import AdsClientV1
|
|
7
|
+
from ads_api.config.region import Region
|
|
8
|
+
from ads_api.config.settings import AmazonAdsConfig
|
|
9
|
+
from ads_api.config.token_cache import BaseTokenCache, FileTokenCache, RedisTokenCache
|
|
10
|
+
from ads_api.config.token_manager import TokenCredentials, TokenManager
|
|
11
|
+
|
|
12
|
+
__all__ = [
|
|
13
|
+
"AdsClient",
|
|
14
|
+
"AdsClientV0",
|
|
15
|
+
"AdsClientV1",
|
|
16
|
+
"AmazonAdsConfig",
|
|
17
|
+
"BaseTokenCache",
|
|
18
|
+
"ClientContext",
|
|
19
|
+
"FileTokenCache",
|
|
20
|
+
"RedisTokenCache",
|
|
21
|
+
"Region",
|
|
22
|
+
"TokenCredentials",
|
|
23
|
+
"TokenManager",
|
|
24
|
+
]
|
|
25
|
+
__version__ = "0.11.0"
|
ads_api/base.py
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"""Shared HTTP session and base resource class (Synchronous)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import email.utils
|
|
6
|
+
import logging
|
|
7
|
+
import random
|
|
8
|
+
import time
|
|
9
|
+
from collections.abc import Sequence
|
|
10
|
+
from datetime import UTC, datetime
|
|
11
|
+
from typing import Any, Literal, cast, overload
|
|
12
|
+
|
|
13
|
+
import httpx
|
|
14
|
+
from pydantic import BaseModel, TypeAdapter, ValidationError
|
|
15
|
+
|
|
16
|
+
from ads_api.config.settings import AmazonAdsConfig
|
|
17
|
+
from ads_api.errors import raise_for_status
|
|
18
|
+
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
type ResponseMode = Literal["dict", "pydantic", "raw"]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _parse_retry_after(resp: httpx.Response | None, fallback_seconds: float, max_wait: float = 60.0) -> float:
|
|
25
|
+
"""Parse the Retry-After header as seconds or HTTP-Date with fallback."""
|
|
26
|
+
if resp is None:
|
|
27
|
+
return fallback_seconds
|
|
28
|
+
headers = getattr(resp, "headers", None)
|
|
29
|
+
if headers is None:
|
|
30
|
+
return fallback_seconds
|
|
31
|
+
raw = headers.get("Retry-After")
|
|
32
|
+
if not raw:
|
|
33
|
+
return fallback_seconds
|
|
34
|
+
try:
|
|
35
|
+
seconds = float(raw)
|
|
36
|
+
if seconds >= 0:
|
|
37
|
+
return min(seconds + random.uniform(0, 0.5), max_wait)
|
|
38
|
+
except (ValueError, TypeError):
|
|
39
|
+
pass
|
|
40
|
+
try:
|
|
41
|
+
target_dt = email.utils.parsedate_to_datetime(str(raw))
|
|
42
|
+
now_dt = datetime.now(UTC)
|
|
43
|
+
delta = (target_dt - now_dt).total_seconds()
|
|
44
|
+
if delta > 0:
|
|
45
|
+
return min(delta + random.uniform(0, 0.5), max_wait)
|
|
46
|
+
except Exception:
|
|
47
|
+
pass
|
|
48
|
+
return fallback_seconds
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ClientContext:
|
|
52
|
+
"""Shared HTTP state for all resource instances."""
|
|
53
|
+
|
|
54
|
+
__slots__ = ("config", "_client")
|
|
55
|
+
|
|
56
|
+
def __init__(self, config: AmazonAdsConfig) -> None:
|
|
57
|
+
self.config: AmazonAdsConfig = config
|
|
58
|
+
self._client: httpx.Client | None = None
|
|
59
|
+
|
|
60
|
+
def get_client(self) -> httpx.Client:
|
|
61
|
+
if self._client is None:
|
|
62
|
+
self._client = httpx.Client(base_url=self.config.base_url, timeout=httpx.Timeout(self.config.timeout))
|
|
63
|
+
return self._client
|
|
64
|
+
|
|
65
|
+
def close(self) -> None:
|
|
66
|
+
if self._client is not None:
|
|
67
|
+
self._client.close()
|
|
68
|
+
self._client = None
|
|
69
|
+
if self.config._token_manager is not None:
|
|
70
|
+
self.config._token_manager.close()
|
|
71
|
+
|
|
72
|
+
def __enter__(self) -> ClientContext:
|
|
73
|
+
return self
|
|
74
|
+
|
|
75
|
+
def __exit__(self, *args: Any) -> None:
|
|
76
|
+
self.close()
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class BaseResource:
|
|
80
|
+
"""HTTP helpers shared by generated resource classes."""
|
|
81
|
+
|
|
82
|
+
__slots__ = ("_ctx", "exclude_unset", "exclude_none")
|
|
83
|
+
|
|
84
|
+
def __init__(self, ctx: ClientContext, exclude_unset: bool = True, exclude_none: bool = True) -> None:
|
|
85
|
+
self._ctx: ClientContext = ctx
|
|
86
|
+
self.exclude_unset = exclude_unset
|
|
87
|
+
self.exclude_none = exclude_none
|
|
88
|
+
|
|
89
|
+
@overload
|
|
90
|
+
def dump_json(self, body: None) -> dict[str, Any]: ...
|
|
91
|
+
@overload
|
|
92
|
+
def dump_json(self, body: BaseModel) -> dict[str, Any]: ...
|
|
93
|
+
@overload
|
|
94
|
+
def dump_json(self, body: Sequence[BaseModel]) -> list[Any]: ...
|
|
95
|
+
def dump_json(self, body: BaseModel | Sequence[BaseModel] | None) -> dict[str, Any] | list[Any]:
|
|
96
|
+
"""Serialize a request body. ``None`` becomes ``{}`` so optional OpenAPI bodies omit fields."""
|
|
97
|
+
if isinstance(body, BaseModel):
|
|
98
|
+
return body.model_dump(mode="json", exclude_unset=self.exclude_unset, exclude_none=self.exclude_none)
|
|
99
|
+
if body is None:
|
|
100
|
+
return {}
|
|
101
|
+
return [
|
|
102
|
+
item.model_dump(mode="json", exclude_unset=self.exclude_unset, exclude_none=self.exclude_none)
|
|
103
|
+
for item in body
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
def _request(
|
|
107
|
+
self,
|
|
108
|
+
method: str,
|
|
109
|
+
path: str,
|
|
110
|
+
*,
|
|
111
|
+
params: dict[str, Any] | None = None,
|
|
112
|
+
json: dict[str, Any] | list[Any] | None = None,
|
|
113
|
+
headers: dict[str, Any] | None = None,
|
|
114
|
+
) -> httpx.Response:
|
|
115
|
+
client = self._ctx.get_client()
|
|
116
|
+
if self._ctx.config._token_manager is not None:
|
|
117
|
+
token: str = self._ctx.config.refresh_access_token()
|
|
118
|
+
else:
|
|
119
|
+
token = self._ctx.config.access_token or ""
|
|
120
|
+
headers = {
|
|
121
|
+
"Authorization": f"Bearer {token}",
|
|
122
|
+
"Accept": "application/json",
|
|
123
|
+
"Amazon-Ads-ClientId": self._ctx.config.client_id,
|
|
124
|
+
"Amazon-Advertising-API-ClientId": self._ctx.config.client_id,
|
|
125
|
+
**(headers or {}),
|
|
126
|
+
}
|
|
127
|
+
if self._ctx.config.profile_id is not None:
|
|
128
|
+
headers["Amazon-Advertising-API-Scope"] = self._ctx.config.profile_id
|
|
129
|
+
if self._ctx.config.account_id is not None:
|
|
130
|
+
headers["Amazon-Ads-AccountId"] = self._ctx.config.account_id
|
|
131
|
+
for attempt in range(self._ctx.config.max_retries):
|
|
132
|
+
try:
|
|
133
|
+
resp = client.request(
|
|
134
|
+
method=method,
|
|
135
|
+
url=path,
|
|
136
|
+
params=params,
|
|
137
|
+
json=json,
|
|
138
|
+
headers=headers,
|
|
139
|
+
)
|
|
140
|
+
if resp.is_error:
|
|
141
|
+
if resp.status_code == 401 and self._ctx.config._token_manager is not None and attempt == 0:
|
|
142
|
+
token = self._ctx.config.refresh_access_token(force=True)
|
|
143
|
+
headers["Authorization"] = f"Bearer {token}"
|
|
144
|
+
continue
|
|
145
|
+
if resp.status_code in (429, 503, 504) and attempt < self._ctx.config.max_retries - 1:
|
|
146
|
+
fallback = 2**attempt + random.uniform(0, 1)
|
|
147
|
+
wait_time = _parse_retry_after(resp, fallback_seconds=fallback)
|
|
148
|
+
logger.warning("Rate limit exceeded, retrying in %.2f seconds %s", wait_time, resp.status_code)
|
|
149
|
+
time.sleep(wait_time)
|
|
150
|
+
continue
|
|
151
|
+
logger.error("%s %s", resp.status_code, resp.text)
|
|
152
|
+
raise_for_status(resp)
|
|
153
|
+
return resp
|
|
154
|
+
except (httpx.ConnectError, httpx.TimeoutException, httpx.RemoteProtocolError):
|
|
155
|
+
if attempt < self._ctx.config.max_retries - 1:
|
|
156
|
+
time.sleep(2**attempt + random.uniform(0, 1))
|
|
157
|
+
continue
|
|
158
|
+
raise
|
|
159
|
+
raise RuntimeError("Retry loop exited unexpectedly")
|
|
160
|
+
|
|
161
|
+
@overload
|
|
162
|
+
def _response[T: BaseModel](
|
|
163
|
+
self, model_cls: type[T], resp: httpx.Response, *, mode: Literal["dict"] = "dict"
|
|
164
|
+
) -> dict[str, Any]: ...
|
|
165
|
+
@overload
|
|
166
|
+
def _response[T: BaseModel](self, model_cls: type[T], resp: httpx.Response, *, mode: Literal["pydantic"]) -> T: ...
|
|
167
|
+
@overload
|
|
168
|
+
def _response[T: BaseModel](
|
|
169
|
+
self, model_cls: type[T], resp: httpx.Response, *, mode: Literal["raw"]
|
|
170
|
+
) -> httpx.Response: ...
|
|
171
|
+
def _response[T: BaseModel](
|
|
172
|
+
self, model_cls: type[T], resp: httpx.Response, *, mode: ResponseMode = "dict"
|
|
173
|
+
) -> T | dict[str, Any] | httpx.Response:
|
|
174
|
+
if mode == "raw":
|
|
175
|
+
return resp
|
|
176
|
+
if mode == "dict":
|
|
177
|
+
return cast(dict[str, Any], resp.json())
|
|
178
|
+
try:
|
|
179
|
+
return model_cls.model_validate_json(resp.text)
|
|
180
|
+
except ValidationError:
|
|
181
|
+
logger.error("Failed to parse response as %s: %s", model_cls.__name__, resp.text)
|
|
182
|
+
raise
|
|
183
|
+
|
|
184
|
+
@overload
|
|
185
|
+
def _response_list[T: BaseModel](
|
|
186
|
+
self, model_cls: type[T], resp: httpx.Response, *, mode: Literal["dict"] = "dict"
|
|
187
|
+
) -> list[dict[str, Any]]: ...
|
|
188
|
+
@overload
|
|
189
|
+
def _response_list[T: BaseModel](
|
|
190
|
+
self, model_cls: type[T], resp: httpx.Response, *, mode: Literal["pydantic"]
|
|
191
|
+
) -> list[T]: ...
|
|
192
|
+
@overload
|
|
193
|
+
def _response_list[T: BaseModel](
|
|
194
|
+
self, model_cls: type[T], resp: httpx.Response, *, mode: Literal["raw"]
|
|
195
|
+
) -> httpx.Response: ...
|
|
196
|
+
def _response_list[T: BaseModel](
|
|
197
|
+
self, model_cls: type[T], resp: httpx.Response, *, mode: ResponseMode = "dict"
|
|
198
|
+
) -> list[T] | list[dict[str, Any]] | httpx.Response:
|
|
199
|
+
if mode == "raw":
|
|
200
|
+
return resp
|
|
201
|
+
if mode == "dict":
|
|
202
|
+
return cast(list[dict[str, Any]], resp.json())
|
|
203
|
+
try:
|
|
204
|
+
list_type: Any = list[model_cls] # type: ignore[valid-type]
|
|
205
|
+
return TypeAdapter[list[T]](list_type).validate_json(resp.text)
|
|
206
|
+
except ValidationError:
|
|
207
|
+
logger.error("Failed to parse response list as %s: %s", model_cls.__name__, resp.text)
|
|
208
|
+
raise
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"""Amazon Ads API synchronous clients."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, overload
|
|
6
|
+
|
|
7
|
+
from ads_api.base import ClientContext
|
|
8
|
+
from ads_api.client.v0 import AdsClientV0
|
|
9
|
+
from ads_api.client.v1 import AdsClientV1
|
|
10
|
+
from ads_api.config.settings import AmazonAdsConfig
|
|
11
|
+
from ads_api.errors import MissingConfigError
|
|
12
|
+
|
|
13
|
+
__all__ = ["AdsClient", "AdsClientV0", "AdsClientV1"]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AdsClient:
|
|
17
|
+
"""Unified synchronous client for Amazon Ads API v0 and v1.
|
|
18
|
+
|
|
19
|
+
v0 and v1 share one HTTP session and token. Use the version clients
|
|
20
|
+
directly when you only need one API generation:
|
|
21
|
+
|
|
22
|
+
with AdsClient(config) as ads:
|
|
23
|
+
ads.v0.accounts.profiles.list_profiles()
|
|
24
|
+
ads.v1.sp.campaigns.create_campaign(body)
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
@overload
|
|
28
|
+
def __init__(self, config: AmazonAdsConfig) -> None: ...
|
|
29
|
+
|
|
30
|
+
@overload
|
|
31
|
+
def __init__(self, *, ctx: ClientContext) -> None: ...
|
|
32
|
+
|
|
33
|
+
def __init__(self, config: AmazonAdsConfig | None = None, *, ctx: ClientContext | None = None) -> None:
|
|
34
|
+
if ctx is not None:
|
|
35
|
+
self._ctx = ctx
|
|
36
|
+
self._owns_ctx = False
|
|
37
|
+
elif config is not None:
|
|
38
|
+
self._ctx = ClientContext(config)
|
|
39
|
+
self._owns_ctx = True
|
|
40
|
+
else:
|
|
41
|
+
raise MissingConfigError()
|
|
42
|
+
self.__v0: AdsClientV0 | None = None
|
|
43
|
+
self.__v1: AdsClientV1 | None = None
|
|
44
|
+
|
|
45
|
+
def __enter__(self) -> AdsClient:
|
|
46
|
+
return self
|
|
47
|
+
|
|
48
|
+
def __exit__(self, *args: Any) -> None:
|
|
49
|
+
self.close()
|
|
50
|
+
|
|
51
|
+
def close(self) -> None:
|
|
52
|
+
if self._owns_ctx:
|
|
53
|
+
self._ctx.close()
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def config(self) -> AmazonAdsConfig:
|
|
57
|
+
return self._ctx.config
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def context(self) -> ClientContext:
|
|
61
|
+
return self._ctx
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def account_id(self) -> str | None:
|
|
65
|
+
"""Get the advertiser account ID bound to this client."""
|
|
66
|
+
return self._ctx.config.account_id
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def profile_id(self) -> str | None:
|
|
70
|
+
"""Get the profile ID bound to this client."""
|
|
71
|
+
return self._ctx.config.profile_id
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def account_type(self) -> str | None:
|
|
75
|
+
"""Get the account type bound to this client (e.g. 'seller' or 'vendor')."""
|
|
76
|
+
return self._ctx.config.account_type
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def is_seller(self) -> bool:
|
|
80
|
+
"""Whether the bound account is a seller account."""
|
|
81
|
+
return self._ctx.config.account_type == "seller"
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def is_vendor(self) -> bool:
|
|
85
|
+
"""Whether the bound account is a vendor account."""
|
|
86
|
+
return self._ctx.config.account_type == "vendor"
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def is_agency(self) -> bool:
|
|
90
|
+
"""Whether the bound account is an agency account."""
|
|
91
|
+
return self._ctx.config.account_type == "agency"
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def v0(self) -> AdsClientV0:
|
|
95
|
+
if self.__v0 is None:
|
|
96
|
+
self.__v0 = AdsClientV0(ctx=self._ctx)
|
|
97
|
+
return self.__v0
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def v1(self) -> AdsClientV1:
|
|
101
|
+
if self.__v1 is None:
|
|
102
|
+
self.__v1 = AdsClientV1(ctx=self._ctx)
|
|
103
|
+
return self.__v1
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""Amazon Ads API v0 synchronous client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, overload
|
|
6
|
+
|
|
7
|
+
from ads_api.base import ClientContext
|
|
8
|
+
from ads_api.client.v0.accounts import Accounts
|
|
9
|
+
from ads_api.client.v0.ads_data_manager import AdsDataManager
|
|
10
|
+
from ads_api.client.v0.discovery import Discovery
|
|
11
|
+
from ads_api.client.v0.exports import Exports
|
|
12
|
+
from ads_api.client.v0.portfolios import Portfolios
|
|
13
|
+
from ads_api.client.v0.products import Products
|
|
14
|
+
from ads_api.client.v0.reporting import Reporting
|
|
15
|
+
from ads_api.client.v0.sb_v4 import SBV4
|
|
16
|
+
from ads_api.client.v0.sd import SD
|
|
17
|
+
from ads_api.client.v0.sp_v3 import SPV3
|
|
18
|
+
from ads_api.config.settings import AmazonAdsConfig
|
|
19
|
+
from ads_api.errors import MissingConfigError
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class AdsClientV0:
|
|
23
|
+
"""Synchronous client for Amazon Ads API v0.
|
|
24
|
+
|
|
25
|
+
with AdsClientV0(config) as ads:
|
|
26
|
+
ads.accounts.profiles.list_profiles()
|
|
27
|
+
ads.reporting.reports.create_async_report(body)
|
|
28
|
+
ads.portfolios.list_portfolios(body)
|
|
29
|
+
ads.sp_v3.campaigns.create_sponsored_products_campaigns(body)
|
|
30
|
+
ads.sd.campaigns.list_campaigns()
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
@overload
|
|
34
|
+
def __init__(self, config: AmazonAdsConfig) -> None: ...
|
|
35
|
+
|
|
36
|
+
@overload
|
|
37
|
+
def __init__(self, *, ctx: ClientContext) -> None: ...
|
|
38
|
+
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
config: AmazonAdsConfig | None = None,
|
|
42
|
+
*,
|
|
43
|
+
ctx: ClientContext | None = None,
|
|
44
|
+
) -> None:
|
|
45
|
+
if ctx is not None:
|
|
46
|
+
self._ctx = ctx
|
|
47
|
+
self._owns_ctx = False
|
|
48
|
+
elif config is not None:
|
|
49
|
+
self._ctx = ClientContext(config)
|
|
50
|
+
self._owns_ctx = True
|
|
51
|
+
else:
|
|
52
|
+
raise MissingConfigError()
|
|
53
|
+
self.__accounts: Accounts | None = None
|
|
54
|
+
self.__reporting: Reporting | None = None
|
|
55
|
+
self.__ads_data_manager: AdsDataManager | None = None
|
|
56
|
+
self.__exports: Exports | None = None
|
|
57
|
+
self.__discovery: Discovery | None = None
|
|
58
|
+
self.__portfolios: Portfolios | None = None
|
|
59
|
+
self.__products: Products | None = None
|
|
60
|
+
self.__sp_v3: SPV3 | None = None
|
|
61
|
+
self.__sb_v4: SBV4 | None = None
|
|
62
|
+
self.__sd: SD | None = None
|
|
63
|
+
|
|
64
|
+
def __enter__(self) -> AdsClientV0:
|
|
65
|
+
return self
|
|
66
|
+
|
|
67
|
+
def __exit__(self, *args: Any) -> None:
|
|
68
|
+
self.close()
|
|
69
|
+
|
|
70
|
+
def close(self) -> None:
|
|
71
|
+
if self._owns_ctx:
|
|
72
|
+
self._ctx.close()
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def accounts(self) -> Accounts:
|
|
76
|
+
if self.__accounts is None:
|
|
77
|
+
self.__accounts = Accounts(self._ctx)
|
|
78
|
+
return self.__accounts
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def reporting(self) -> Reporting:
|
|
82
|
+
if self.__reporting is None:
|
|
83
|
+
self.__reporting = Reporting(self._ctx)
|
|
84
|
+
return self.__reporting
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def ads_data_manager(self) -> AdsDataManager:
|
|
88
|
+
if self.__ads_data_manager is None:
|
|
89
|
+
self.__ads_data_manager = AdsDataManager(self._ctx)
|
|
90
|
+
return self.__ads_data_manager
|
|
91
|
+
|
|
92
|
+
@property
|
|
93
|
+
def exports(self) -> Exports:
|
|
94
|
+
if self.__exports is None:
|
|
95
|
+
self.__exports = Exports(self._ctx)
|
|
96
|
+
return self.__exports
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def discovery(self) -> Discovery:
|
|
100
|
+
if self.__discovery is None:
|
|
101
|
+
self.__discovery = Discovery(self._ctx)
|
|
102
|
+
return self.__discovery
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def portfolios(self) -> Portfolios:
|
|
106
|
+
if self.__portfolios is None:
|
|
107
|
+
self.__portfolios = Portfolios(self._ctx)
|
|
108
|
+
return self.__portfolios
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def products(self) -> Products:
|
|
112
|
+
if self.__products is None:
|
|
113
|
+
self.__products = Products(self._ctx)
|
|
114
|
+
return self.__products
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def sp_v3(self) -> SPV3:
|
|
118
|
+
if self.__sp_v3 is None:
|
|
119
|
+
self.__sp_v3 = SPV3(self._ctx)
|
|
120
|
+
return self.__sp_v3
|
|
121
|
+
|
|
122
|
+
@property
|
|
123
|
+
def sb_v4(self) -> SBV4:
|
|
124
|
+
if self.__sb_v4 is None:
|
|
125
|
+
self.__sb_v4 = SBV4(self._ctx)
|
|
126
|
+
return self.__sb_v4
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def sd(self) -> SD:
|
|
130
|
+
if self.__sd is None:
|
|
131
|
+
self.__sd = SD(self._ctx)
|
|
132
|
+
return self.__sd
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Accounts resource namespace — v0 Accounts APIs."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from ads_api.base import ClientContext
|
|
6
|
+
|
|
7
|
+
from .advertising_accounts import AdvertisingAccounts
|
|
8
|
+
from .dsp_advertisers import DSPAdvertisers
|
|
9
|
+
from .manager_accounts import ManagerAccounts
|
|
10
|
+
from .profiles import Profiles
|
|
11
|
+
from .terms_token import TermsToken
|
|
12
|
+
from .test_accounts import TestAccounts
|
|
13
|
+
from .user_invitations import UserInvitations
|
|
14
|
+
from .user_permissions import UserPermissions
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Accounts:
|
|
18
|
+
"""Lazy Accounts resources."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, ctx: ClientContext) -> None:
|
|
21
|
+
self._ctx = ctx
|
|
22
|
+
self.__advertising_accounts: AdvertisingAccounts | None = None
|
|
23
|
+
self.__dsp_advertisers: DSPAdvertisers | None = None
|
|
24
|
+
self.__manager_accounts: ManagerAccounts | None = None
|
|
25
|
+
self.__profiles: Profiles | None = None
|
|
26
|
+
self.__terms_token: TermsToken | None = None
|
|
27
|
+
self.__test_accounts: TestAccounts | None = None
|
|
28
|
+
self.__user_invitations: UserInvitations | None = None
|
|
29
|
+
self.__user_permissions: UserPermissions | None = None
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def advertising_accounts(self) -> AdvertisingAccounts:
|
|
33
|
+
if self.__advertising_accounts is None:
|
|
34
|
+
self.__advertising_accounts = AdvertisingAccounts(self._ctx)
|
|
35
|
+
return self.__advertising_accounts
|
|
36
|
+
|
|
37
|
+
@property
|
|
38
|
+
def dsp_advertisers(self) -> DSPAdvertisers:
|
|
39
|
+
if self.__dsp_advertisers is None:
|
|
40
|
+
self.__dsp_advertisers = DSPAdvertisers(self._ctx)
|
|
41
|
+
return self.__dsp_advertisers
|
|
42
|
+
|
|
43
|
+
@property
|
|
44
|
+
def manager_accounts(self) -> ManagerAccounts:
|
|
45
|
+
if self.__manager_accounts is None:
|
|
46
|
+
self.__manager_accounts = ManagerAccounts(self._ctx)
|
|
47
|
+
return self.__manager_accounts
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def profiles(self) -> Profiles:
|
|
51
|
+
if self.__profiles is None:
|
|
52
|
+
self.__profiles = Profiles(self._ctx)
|
|
53
|
+
return self.__profiles
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def terms_token(self) -> TermsToken:
|
|
57
|
+
if self.__terms_token is None:
|
|
58
|
+
self.__terms_token = TermsToken(self._ctx)
|
|
59
|
+
return self.__terms_token
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def test_accounts(self) -> TestAccounts:
|
|
63
|
+
if self.__test_accounts is None:
|
|
64
|
+
self.__test_accounts = TestAccounts(self._ctx)
|
|
65
|
+
return self.__test_accounts
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def user_invitations(self) -> UserInvitations:
|
|
69
|
+
if self.__user_invitations is None:
|
|
70
|
+
self.__user_invitations = UserInvitations(self._ctx)
|
|
71
|
+
return self.__user_invitations
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def user_permissions(self) -> UserPermissions:
|
|
75
|
+
if self.__user_permissions is None:
|
|
76
|
+
self.__user_permissions = UserPermissions(self._ctx)
|
|
77
|
+
return self.__user_permissions
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""AdvertisingAccounts resource operations.
|
|
2
|
+
|
|
3
|
+
Generated from OpenAPI spec (tag: Account).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from typing import Any, Literal, overload
|
|
9
|
+
|
|
10
|
+
import httpx
|
|
11
|
+
|
|
12
|
+
from ads_api.base import BaseResource
|
|
13
|
+
from ads_api.models.v0.accounts.advertising_accounts import (
|
|
14
|
+
GetAccountResponseContent,
|
|
15
|
+
ListAdsAccountsRequestContent,
|
|
16
|
+
ListAdsAccountsResponseContent,
|
|
17
|
+
RegisterAdsAccountRequestContent,
|
|
18
|
+
RegisterAdsAccountResponseContent,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class AdvertisingAccounts(BaseResource):
|
|
23
|
+
|
|
24
|
+
@overload
|
|
25
|
+
def get_account(self, advertising_account_id: str, *, mode: Literal["dict"] = "dict") -> dict[str, Any]: ...
|
|
26
|
+
@overload
|
|
27
|
+
def get_account(self, advertising_account_id: str, *, mode: Literal["pydantic"]) -> GetAccountResponseContent: ...
|
|
28
|
+
@overload
|
|
29
|
+
def get_account(self, advertising_account_id: str, *, mode: Literal["raw"]) -> httpx.Response: ...
|
|
30
|
+
def get_account(
|
|
31
|
+
self, advertising_account_id: str, *, mode: Literal["pydantic", "dict", "raw"] = "dict"
|
|
32
|
+
) -> GetAccountResponseContent | dict[str, Any] | httpx.Response:
|
|
33
|
+
"""Request attributes of a given advertising account."""
|
|
34
|
+
|
|
35
|
+
resp = self._request(
|
|
36
|
+
"GET",
|
|
37
|
+
f"/adsAccounts/{advertising_account_id}",
|
|
38
|
+
headers={"Accept": "application/vnd.accountresource.v1+json"},
|
|
39
|
+
)
|
|
40
|
+
return self._response(GetAccountResponseContent, resp, mode=mode)
|
|
41
|
+
|
|
42
|
+
@overload
|
|
43
|
+
def list_ads_accounts(
|
|
44
|
+
self, body: ListAdsAccountsRequestContent | None = None, *, mode: Literal["dict"] = "dict"
|
|
45
|
+
) -> dict[str, Any]: ...
|
|
46
|
+
@overload
|
|
47
|
+
def list_ads_accounts(
|
|
48
|
+
self, body: ListAdsAccountsRequestContent | None = None, *, mode: Literal["pydantic"]
|
|
49
|
+
) -> ListAdsAccountsResponseContent: ...
|
|
50
|
+
@overload
|
|
51
|
+
def list_ads_accounts(
|
|
52
|
+
self, body: ListAdsAccountsRequestContent | None = None, *, mode: Literal["raw"]
|
|
53
|
+
) -> httpx.Response: ...
|
|
54
|
+
def list_ads_accounts(
|
|
55
|
+
self, body: ListAdsAccountsRequestContent | None = None, *, mode: Literal["pydantic", "dict", "raw"] = "dict"
|
|
56
|
+
) -> ListAdsAccountsResponseContent | dict[str, Any] | httpx.Response:
|
|
57
|
+
"""List all advertising accounts for the user associated with the access token."""
|
|
58
|
+
|
|
59
|
+
resp = self._request(
|
|
60
|
+
"POST",
|
|
61
|
+
"/adsAccounts/list",
|
|
62
|
+
json=self.dump_json(body),
|
|
63
|
+
headers={
|
|
64
|
+
"Content-Type": "application/vnd.listaccountsresource.v1+json",
|
|
65
|
+
"Accept": "application/vnd.listaccountsresource.v1+json",
|
|
66
|
+
},
|
|
67
|
+
)
|
|
68
|
+
return self._response(ListAdsAccountsResponseContent, resp, mode=mode)
|
|
69
|
+
|
|
70
|
+
@overload
|
|
71
|
+
def register_ads_account(
|
|
72
|
+
self, body: RegisterAdsAccountRequestContent | None = None, *, mode: Literal["dict"] = "dict"
|
|
73
|
+
) -> dict[str, Any]: ...
|
|
74
|
+
@overload
|
|
75
|
+
def register_ads_account(
|
|
76
|
+
self, body: RegisterAdsAccountRequestContent | None = None, *, mode: Literal["pydantic"]
|
|
77
|
+
) -> RegisterAdsAccountResponseContent: ...
|
|
78
|
+
@overload
|
|
79
|
+
def register_ads_account(
|
|
80
|
+
self, body: RegisterAdsAccountRequestContent | None = None, *, mode: Literal["raw"]
|
|
81
|
+
) -> httpx.Response: ...
|
|
82
|
+
def register_ads_account(
|
|
83
|
+
self, body: RegisterAdsAccountRequestContent | None = None, *, mode: Literal["pydantic", "dict", "raw"] = "dict"
|
|
84
|
+
) -> RegisterAdsAccountResponseContent | dict[str, Any] | httpx.Response:
|
|
85
|
+
"""Create a new advertising account tied to a specific Amazon vendor, seller or author, or to a business who does not sell on Amazon."""
|
|
86
|
+
|
|
87
|
+
resp = self._request(
|
|
88
|
+
"POST",
|
|
89
|
+
"/adsAccounts",
|
|
90
|
+
json=self.dump_json(body),
|
|
91
|
+
headers={
|
|
92
|
+
"Content-Type": "application/vnd.registeradsaccountresource.v1+json",
|
|
93
|
+
"Accept": "application/vnd.registeradsaccountresource.v1+json",
|
|
94
|
+
},
|
|
95
|
+
)
|
|
96
|
+
return self._response(RegisterAdsAccountResponseContent, resp, mode=mode)
|