python-amazon-ad-api 2.3.0__py3-none-any.whl → 2.4.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.
- ad_api/api/__init__.py +76 -0
- ad_api/api/campaign_diagnostics.py +1 -1
- ad_api/api/dsp_ad_group_and_campaign.py +139 -0
- ad_api/api/dsp_audience_create.py +53 -0
- ad_api/api/dsp_bid_adjustments.py +193 -0
- ad_api/api/dsp_campaign_flights.py +119 -0
- ad_api/api/dsp_campaign_insights.py +59 -0
- ad_api/api/dsp_combined_audiences.py +83 -0
- ad_api/api/dsp_conversion_tracking_products.py +92 -0
- ad_api/api/dsp_conversions.py +442 -0
- ad_api/api/dsp_creatives.py +114 -0
- ad_api/api/dsp_deal_permissions.py +170 -0
- ad_api/api/dsp_deal_proposals.py +440 -0
- ad_api/api/dsp_deals.py +204 -0
- ad_api/api/dsp_deals_management.py +66 -0
- ad_api/api/dsp_discovery_advertised_product_categories.py +35 -0
- ad_api/api/dsp_discovery_apps.py +36 -0
- ad_api/api/dsp_discovery_domain_lists.py +36 -0
- ad_api/api/dsp_discovery_geo_locations.py +42 -0
- ad_api/api/dsp_discovery_iab_content.py +37 -0
- ad_api/api/dsp_discovery_inventory_source_exchanges.py +36 -0
- ad_api/api/dsp_discovery_products.py +102 -0
- ad_api/api/dsp_discovery_third_party_target_segments.py +36 -0
- ad_api/api/dsp_frequency_associations.py +138 -0
- ad_api/api/dsp_frequency_groups.py +112 -0
- ad_api/api/dsp_frequency_insights.py +85 -0
- ad_api/api/dsp_guidance.py +111 -0
- ad_api/api/dsp_inherited_settings.py +133 -0
- ad_api/api/dsp_inventory_groups.py +209 -0
- ad_api/api/dsp_measurement.py +693 -0
- ad_api/api/dsp_seats.py +43 -0
- ad_api/api/dsp_target_kpi_recommendations.py +44 -0
- ad_api/api/dsp_targeting.py +98 -0
- ad_api/api/forecast.py +130 -0
- ad_api/api/hashed_records.py +39 -0
- ad_api/api/historic_reach.py +148 -0
- ad_api/api/locations.py +57 -0
- ad_api/api/plan_management.py +1268 -0
- ad_api/api/record_management.py +121 -0
- ad_api/api/targetable_entities.py +89 -0
- ad_api/version.py +1 -1
- {python_amazon_ad_api-2.3.0.dist-info → python_amazon_ad_api-2.4.0.dist-info}/METADATA +1 -1
- {python_amazon_ad_api-2.3.0.dist-info → python_amazon_ad_api-2.4.0.dist-info}/RECORD +46 -8
- {python_amazon_ad_api-2.3.0.dist-info → python_amazon_ad_api-2.4.0.dist-info}/WHEEL +0 -0
- {python_amazon_ad_api-2.3.0.dist-info → python_amazon_ad_api-2.4.0.dist-info}/licenses/LICENSE +0 -0
- {python_amazon_ad_api-2.3.0.dist-info → python_amazon_ad_api-2.4.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""Frequency groups /frequencyGroups/v1.
|
|
2
|
+
|
|
3
|
+
Contract: D16GFMApiFrequencyGroupV1 3.0, the *Frequency groups* entry at the first
|
|
4
|
+
level of *Amazon DSP*. Four operations over three paths: create, list, read and
|
|
5
|
+
patch. The read and the patch share ``/frequencyGroups/v1/{frequencyGroupId}``,
|
|
6
|
+
which is why the vendor tree counts the entry once.
|
|
7
|
+
|
|
8
|
+
Plain ``application/json`` throughout: no ``vnd`` type and no version to build.
|
|
9
|
+
|
|
10
|
+
Headers are all optional except the client id: ``Amazon-Advertising-API-Scope``,
|
|
11
|
+
``Amazon-Ads-AccountId`` and, on the list only,
|
|
12
|
+
``Amazon-Ads-Manager-AccountId``. The three the client knows are declared, so
|
|
13
|
+
``selector`` decides which travels.
|
|
14
|
+
|
|
15
|
+
Success codes differ per operation: ``201`` on create, ``200`` on list and read,
|
|
16
|
+
and ``204`` on patch, which returns no body.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class DspFrequencyGroups(Client):
|
|
23
|
+
r"""Frequency groups - /frequencyGroups/v1
|
|
24
|
+
|
|
25
|
+
Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-frequency-group
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
@sp_endpoint('/frequencyGroups/v1', method='POST',
|
|
29
|
+
headers=['Amazon-Advertising-API-Scope',
|
|
30
|
+
'Amazon-Ads-AccountId'])
|
|
31
|
+
def create_frequency_group(self, **kwargs) -> ApiResponse:
|
|
32
|
+
r"""
|
|
33
|
+
Creates a frequency group.
|
|
34
|
+
|
|
35
|
+
Request Body [Required]
|
|
36
|
+
The frequency group the contract publishes: its caps and the
|
|
37
|
+
entities it applies to.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
ApiResponse, ``201`` created.
|
|
41
|
+
"""
|
|
42
|
+
headers = {'Accept': 'application/json',
|
|
43
|
+
'Content-Type': 'application/json'}
|
|
44
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
45
|
+
return self._request(fill_query_params(kwargs.pop('path')),
|
|
46
|
+
data=body, params=kwargs, headers=headers)
|
|
47
|
+
|
|
48
|
+
@sp_endpoint('/frequencyGroups/v1/list', method='POST',
|
|
49
|
+
headers=['Amazon-Advertising-API-Scope',
|
|
50
|
+
'Amazon-Ads-AccountId',
|
|
51
|
+
'Amazon-Advertising-API-Manager-Account'])
|
|
52
|
+
def list_frequency_groups(self, **kwargs) -> ApiResponse:
|
|
53
|
+
r"""
|
|
54
|
+
Lists the frequency groups. Read only, ``POST`` because the filters go in
|
|
55
|
+
the body.
|
|
56
|
+
|
|
57
|
+
Request Body
|
|
58
|
+
The filter body the contract publishes, or empty for all.
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
ApiResponse, ``200``, with the list and its pagination.
|
|
62
|
+
|
|
63
|
+
Note
|
|
64
|
+
This is the only route of the family that also accepts
|
|
65
|
+
``Amazon-Ads-Manager-AccountId``.
|
|
66
|
+
"""
|
|
67
|
+
headers = {'Accept': 'application/json',
|
|
68
|
+
'Content-Type': 'application/json'}
|
|
69
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
70
|
+
return self._request(fill_query_params(kwargs.pop('path')),
|
|
71
|
+
data=body, params=kwargs, headers=headers)
|
|
72
|
+
|
|
73
|
+
@sp_endpoint('/frequencyGroups/v1/{}', method='GET',
|
|
74
|
+
headers=['Amazon-Advertising-API-Scope',
|
|
75
|
+
'Amazon-Ads-AccountId'])
|
|
76
|
+
def get_frequency_group(self, frequencyGroupId, **kwargs) -> ApiResponse:
|
|
77
|
+
r"""
|
|
78
|
+
Reads one frequency group. Read only.
|
|
79
|
+
|
|
80
|
+
Path Parameters
|
|
81
|
+
|
|
82
|
+
- ``frequencyGroupId`` (str): the group. [required]
|
|
83
|
+
|
|
84
|
+
Returns
|
|
85
|
+
ApiResponse, ``200``.
|
|
86
|
+
"""
|
|
87
|
+
headers = {'Accept': 'application/json'}
|
|
88
|
+
return self._request(fill_query_params(kwargs.pop('path'), frequencyGroupId),
|
|
89
|
+
params=kwargs, headers=headers)
|
|
90
|
+
|
|
91
|
+
@sp_endpoint('/frequencyGroups/v1/{}', method='PATCH',
|
|
92
|
+
headers=['Amazon-Advertising-API-Scope',
|
|
93
|
+
'Amazon-Ads-AccountId'])
|
|
94
|
+
def update_frequency_group(self, frequencyGroupId, **kwargs) -> ApiResponse:
|
|
95
|
+
r"""
|
|
96
|
+
Updates a frequency group. A ``PATCH`` on the same path the read uses.
|
|
97
|
+
|
|
98
|
+
Path Parameters
|
|
99
|
+
|
|
100
|
+
- ``frequencyGroupId`` (str): the group. [required]
|
|
101
|
+
|
|
102
|
+
Request Body [Required]
|
|
103
|
+
The fields to change.
|
|
104
|
+
|
|
105
|
+
Returns
|
|
106
|
+
ApiResponse, **204**, with **no body**. Do not read the payload here.
|
|
107
|
+
"""
|
|
108
|
+
headers = {'Accept': 'application/json',
|
|
109
|
+
'Content-Type': 'application/json'}
|
|
110
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
111
|
+
return self._request(fill_query_params(kwargs.pop('path'), frequencyGroupId),
|
|
112
|
+
data=body, params=kwargs, headers=headers)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""Frequency insights /dsp/v1.
|
|
2
|
+
|
|
3
|
+
Contract: D16GDspApiActionableInsights 3.0, the *Frequency Savings Insight* entry
|
|
4
|
+
at the first level of *Amazon DSP*. Two read routes, both ``POST`` because the
|
|
5
|
+
body carries the filters, and each with its **own** media type:
|
|
6
|
+
|
|
7
|
+
- ``/dsp/v1/frequencyDistributionInsights/list``
|
|
8
|
+
``application/vnd.dspFrequencyDistributionInsight.v<n>+json``
|
|
9
|
+
- ``/dsp/v1/frequencySavingsInsights/list``
|
|
10
|
+
``application/vnd.dspFrequencySavingsInsight.v<n>+json``
|
|
11
|
+
|
|
12
|
+
They are not interchangeable: the first counts unique users per frequency band,
|
|
13
|
+
the second says what an adjusted frequency would have saved.
|
|
14
|
+
|
|
15
|
+
Headers: ``Amazon-Advertising-API-ClientId``, ``Amazon-Advertising-API-Scope``
|
|
16
|
+
and ``Amazon-Advertising-AccountId``, all required. The client knows the third as
|
|
17
|
+
``Amazon-Ads-AccountId``, so that is the one declared. Success is **200**.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class DspFrequencyInsights(Client):
|
|
24
|
+
r"""Frequency insights - /dsp/v1
|
|
25
|
+
|
|
26
|
+
Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-freq-insight
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
@sp_endpoint('/dsp/v1/frequencyDistributionInsights/list', method='POST',
|
|
30
|
+
headers=['Amazon-Advertising-API-Scope',
|
|
31
|
+
'Amazon-Ads-AccountId'])
|
|
32
|
+
def list_frequency_distribution_insights(self, version: str = "1", **kwargs) -> ApiResponse:
|
|
33
|
+
r"""
|
|
34
|
+
Lists the frequency distribution insights: how many unique users saw the
|
|
35
|
+
ads once, twice, and so on up to ten or more. Read only.
|
|
36
|
+
|
|
37
|
+
Request Body [Required]
|
|
38
|
+
| **filters** (object): what to measure, as the contract publishes.
|
|
39
|
+
|
|
40
|
+
Request Body [Optional]
|
|
41
|
+
| **maxResults** (int): page size.
|
|
42
|
+
| **nextToken** (str): token from a previous answer.
|
|
43
|
+
|
|
44
|
+
Keyword Args
|
|
45
|
+
|
|
46
|
+
- ``version`` (str): media type version. Defaults to ``1``. [optional]
|
|
47
|
+
|
|
48
|
+
Returns
|
|
49
|
+
ApiResponse, ``200``, with the distribution.
|
|
50
|
+
"""
|
|
51
|
+
media_type = ('application/vnd.dspFrequencyDistributionInsight.v'
|
|
52
|
+
+ version + '+json')
|
|
53
|
+
headers = {'Accept': media_type, 'Content-Type': media_type}
|
|
54
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
55
|
+
return self._request(fill_query_params(kwargs.pop('path')),
|
|
56
|
+
data=body, params=kwargs, headers=headers)
|
|
57
|
+
|
|
58
|
+
@sp_endpoint('/dsp/v1/frequencySavingsInsights/list', method='POST',
|
|
59
|
+
headers=['Amazon-Advertising-API-Scope',
|
|
60
|
+
'Amazon-Ads-AccountId'])
|
|
61
|
+
def list_frequency_savings_insights(self, version: str = "1", **kwargs) -> ApiResponse:
|
|
62
|
+
r"""
|
|
63
|
+
Lists the frequency savings insights: what a different frequency cap would
|
|
64
|
+
have cost or saved. Read only.
|
|
65
|
+
|
|
66
|
+
Request Body [Required]
|
|
67
|
+
| **filters** (object): what to measure, as the contract publishes.
|
|
68
|
+
|
|
69
|
+
Request Body [Optional]
|
|
70
|
+
| **maxResults** (int): page size.
|
|
71
|
+
| **nextToken** (str): token from a previous answer.
|
|
72
|
+
|
|
73
|
+
Keyword Args
|
|
74
|
+
|
|
75
|
+
- ``version`` (str): media type version. Defaults to ``1``. [optional]
|
|
76
|
+
|
|
77
|
+
Returns
|
|
78
|
+
ApiResponse, ``200``, with the savings.
|
|
79
|
+
"""
|
|
80
|
+
media_type = ('application/vnd.dspFrequencySavingsInsight.v'
|
|
81
|
+
+ version + '+json')
|
|
82
|
+
headers = {'Accept': media_type, 'Content-Type': media_type}
|
|
83
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
84
|
+
return self._request(fill_query_params(kwargs.pop('path')),
|
|
85
|
+
data=body, params=kwargs, headers=headers)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"""Guidance /dsp/v1/guidance.
|
|
2
|
+
|
|
3
|
+
Contract: DSP Guidance 3.0, the *Guidance* entry at the first level of
|
|
4
|
+
*Amazon DSP*. Three read routes, one per scope: ad groups, advertisers and
|
|
5
|
+
campaigns.
|
|
6
|
+
|
|
7
|
+
Each route has its own request media type naming the scope, and all three share
|
|
8
|
+
one response type. The version appears twice in the name, as V1 and as .v1.0,
|
|
9
|
+
and both come from the one ``version`` argument.
|
|
10
|
+
|
|
11
|
+
Headers: Amazon-Advertising-API-ClientId and Amazon-Ads-AccountId are required,
|
|
12
|
+
and Amazon-Advertising-API-Scope and Accept-Language are optional. The language
|
|
13
|
+
goes through accept_language=.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DspGuidance(Client):
|
|
20
|
+
r"""Guidance - /dsp/v1/guidance
|
|
21
|
+
|
|
22
|
+
Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-guidance
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
@sp_endpoint("/dsp/v1/guidance/adGroups/list", method="POST",
|
|
26
|
+
headers=["Amazon-Advertising-API-Scope",
|
|
27
|
+
"Amazon-Ads-AccountId"])
|
|
28
|
+
def list_ad_group_guidance(self, version: str = "1.0", **kwargs) -> ApiResponse:
|
|
29
|
+
r"""
|
|
30
|
+
Lists the guidance for ad groups. Read only, POST because the filter goes
|
|
31
|
+
in the body.
|
|
32
|
+
|
|
33
|
+
Keyword Args
|
|
34
|
+
|
|
35
|
+
- ``version`` (str): the version, ``1.0``. It appears twice in the
|
|
36
|
+
media type, as ``V1`` and as ``.v1.0``. [optional]
|
|
37
|
+
- ``accept_language`` (str): the ``Accept-Language`` header. [optional]
|
|
38
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
39
|
+
|
|
40
|
+
Returns
|
|
41
|
+
ApiResponse, ``200``.
|
|
42
|
+
"""
|
|
43
|
+
media_type = ("application/vnd.dspRecommendationsListAdGroupGuidanceV"
|
|
44
|
+
+ version.split(".")[0] + "Request.v" + version + "+json")
|
|
45
|
+
accept = ("application/vnd.dspRecommendationsListGuidanceV"
|
|
46
|
+
+ version.split(".")[0] + "Response.v" + version + "+json")
|
|
47
|
+
headers = {"Accept": accept, "Content-Type": media_type}
|
|
48
|
+
language = kwargs.pop("accept_language", None)
|
|
49
|
+
if language:
|
|
50
|
+
headers["Accept-Language"] = language
|
|
51
|
+
body = Utils.convert_body(kwargs.pop("body"), False)
|
|
52
|
+
return self._request(fill_query_params(kwargs.pop("path")),
|
|
53
|
+
data=body, params=kwargs, headers=headers)
|
|
54
|
+
|
|
55
|
+
@sp_endpoint("/dsp/v1/guidance/advertisers/list", method="POST",
|
|
56
|
+
headers=["Amazon-Advertising-API-Scope",
|
|
57
|
+
"Amazon-Ads-AccountId"])
|
|
58
|
+
def list_advertiser_guidance(self, version: str = "1.0", **kwargs) -> ApiResponse:
|
|
59
|
+
r"""
|
|
60
|
+
Lists the guidance for advertisers. Read only.
|
|
61
|
+
|
|
62
|
+
Keyword Args
|
|
63
|
+
|
|
64
|
+
- ``version`` (str): the version, ``1.0``. It appears twice in the
|
|
65
|
+
media type, as ``V1`` and as ``.v1.0``. [optional]
|
|
66
|
+
- ``accept_language`` (str): the ``Accept-Language`` header. [optional]
|
|
67
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
ApiResponse, ``200``.
|
|
71
|
+
"""
|
|
72
|
+
media_type = ("application/vnd.dspRecommendationsListAdvertiserGuidanceV"
|
|
73
|
+
+ version.split(".")[0] + "Request.v" + version + "+json")
|
|
74
|
+
accept = ("application/vnd.dspRecommendationsListGuidanceV"
|
|
75
|
+
+ version.split(".")[0] + "Response.v" + version + "+json")
|
|
76
|
+
headers = {"Accept": accept, "Content-Type": media_type}
|
|
77
|
+
language = kwargs.pop("accept_language", None)
|
|
78
|
+
if language:
|
|
79
|
+
headers["Accept-Language"] = language
|
|
80
|
+
body = Utils.convert_body(kwargs.pop("body"), False)
|
|
81
|
+
return self._request(fill_query_params(kwargs.pop("path")),
|
|
82
|
+
data=body, params=kwargs, headers=headers)
|
|
83
|
+
|
|
84
|
+
@sp_endpoint("/dsp/v1/guidance/campaigns/list", method="POST",
|
|
85
|
+
headers=["Amazon-Advertising-API-Scope",
|
|
86
|
+
"Amazon-Ads-AccountId"])
|
|
87
|
+
def list_campaign_guidance(self, version: str = "1.0", **kwargs) -> ApiResponse:
|
|
88
|
+
r"""
|
|
89
|
+
Lists the guidance for campaigns. Read only.
|
|
90
|
+
|
|
91
|
+
Keyword Args
|
|
92
|
+
|
|
93
|
+
- ``version`` (str): the version, ``1.0``. It appears twice in the
|
|
94
|
+
media type, as ``V1`` and as ``.v1.0``. [optional]
|
|
95
|
+
- ``accept_language`` (str): the ``Accept-Language`` header. [optional]
|
|
96
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
97
|
+
|
|
98
|
+
Returns
|
|
99
|
+
ApiResponse, ``200``.
|
|
100
|
+
"""
|
|
101
|
+
media_type = ("application/vnd.dspRecommendationsListCampaignGuidanceV"
|
|
102
|
+
+ version.split(".")[0] + "Request.v" + version + "+json")
|
|
103
|
+
accept = ("application/vnd.dspRecommendationsListGuidanceV"
|
|
104
|
+
+ version.split(".")[0] + "Response.v" + version + "+json")
|
|
105
|
+
headers = {"Accept": accept, "Content-Type": media_type}
|
|
106
|
+
language = kwargs.pop("accept_language", None)
|
|
107
|
+
if language:
|
|
108
|
+
headers["Accept-Language"] = language
|
|
109
|
+
body = Utils.convert_body(kwargs.pop("body"), False)
|
|
110
|
+
return self._request(fill_query_params(kwargs.pop("path")),
|
|
111
|
+
data=body, params=kwargs, headers=headers)
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Inherited settings /dsp/v1/inheritedSettings.
|
|
2
|
+
|
|
3
|
+
Contract: Inherited Settings API - V1 3.0. Six operations over six paths: the
|
|
4
|
+
settings themselves, their general variant, and the matching deletes and lists.
|
|
5
|
+
|
|
6
|
+
Plain ``application/json``, no version. All three headers are required,
|
|
7
|
+
``Scope`` included.
|
|
8
|
+
|
|
9
|
+
The four writes answer 207; the two lists answer 200.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class DspInheritedSettings(Client):
|
|
16
|
+
r"""Inherited settings - /dsp/v1/inheritedSettings
|
|
17
|
+
|
|
18
|
+
Documentation: https://advertising.amazon.com/API/docs/en-us/dsp-inherited-settings
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
@sp_endpoint('/dsp/v1/inheritedSettings', method='POST',
|
|
22
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
23
|
+
def create_inherited_settings(self, **kwargs) -> ApiResponse:
|
|
24
|
+
r"""
|
|
25
|
+
Creates inherited settings.
|
|
26
|
+
|
|
27
|
+
Keyword Args
|
|
28
|
+
|
|
29
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
30
|
+
|
|
31
|
+
Returns
|
|
32
|
+
ApiResponse, **207** multi-status.
|
|
33
|
+
"""
|
|
34
|
+
headers = {'Accept': 'application/json'}
|
|
35
|
+
headers['Content-Type'] = 'application/json'
|
|
36
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
37
|
+
return self._request(kwargs.pop('path'),
|
|
38
|
+
data=body, params=kwargs, headers=headers)
|
|
39
|
+
|
|
40
|
+
@sp_endpoint('/dsp/v1/inheritedSettings/delete', method='POST',
|
|
41
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
42
|
+
def delete_inherited_settings(self, **kwargs) -> ApiResponse:
|
|
43
|
+
r"""
|
|
44
|
+
Deletes inherited settings.
|
|
45
|
+
|
|
46
|
+
Keyword Args
|
|
47
|
+
|
|
48
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
ApiResponse, **207** multi-status.
|
|
52
|
+
"""
|
|
53
|
+
headers = {'Accept': 'application/json'}
|
|
54
|
+
headers['Content-Type'] = 'application/json'
|
|
55
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
56
|
+
return self._request(kwargs.pop('path'),
|
|
57
|
+
data=body, params=kwargs, headers=headers)
|
|
58
|
+
|
|
59
|
+
@sp_endpoint('/dsp/v1/inheritedSettings/list', method='POST',
|
|
60
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
61
|
+
def list_inherited_settings(self, **kwargs) -> ApiResponse:
|
|
62
|
+
r"""
|
|
63
|
+
Lists inherited settings. Read only.
|
|
64
|
+
|
|
65
|
+
Keyword Args
|
|
66
|
+
|
|
67
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
ApiResponse, ``200``, with the settings.
|
|
71
|
+
"""
|
|
72
|
+
headers = {'Accept': 'application/json'}
|
|
73
|
+
headers['Content-Type'] = 'application/json'
|
|
74
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
75
|
+
return self._request(kwargs.pop('path'),
|
|
76
|
+
data=body, params=kwargs, headers=headers)
|
|
77
|
+
|
|
78
|
+
@sp_endpoint('/dsp/v1/inheritedSettings/general', method='POST',
|
|
79
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
80
|
+
def create_general_settings(self, **kwargs) -> ApiResponse:
|
|
81
|
+
r"""
|
|
82
|
+
Creates the general inherited settings.
|
|
83
|
+
|
|
84
|
+
Keyword Args
|
|
85
|
+
|
|
86
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
87
|
+
|
|
88
|
+
Returns
|
|
89
|
+
ApiResponse, **207** multi-status.
|
|
90
|
+
"""
|
|
91
|
+
headers = {'Accept': 'application/json'}
|
|
92
|
+
headers['Content-Type'] = 'application/json'
|
|
93
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
94
|
+
return self._request(kwargs.pop('path'),
|
|
95
|
+
data=body, params=kwargs, headers=headers)
|
|
96
|
+
|
|
97
|
+
@sp_endpoint('/dsp/v1/inheritedSettings/general/delete', method='POST',
|
|
98
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
99
|
+
def delete_general_settings(self, **kwargs) -> ApiResponse:
|
|
100
|
+
r"""
|
|
101
|
+
Deletes the general inherited settings.
|
|
102
|
+
|
|
103
|
+
Keyword Args
|
|
104
|
+
|
|
105
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
106
|
+
|
|
107
|
+
Returns
|
|
108
|
+
ApiResponse, **207** multi-status.
|
|
109
|
+
"""
|
|
110
|
+
headers = {'Accept': 'application/json'}
|
|
111
|
+
headers['Content-Type'] = 'application/json'
|
|
112
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
113
|
+
return self._request(kwargs.pop('path'),
|
|
114
|
+
data=body, params=kwargs, headers=headers)
|
|
115
|
+
|
|
116
|
+
@sp_endpoint('/dsp/v1/inheritedSettings/general/list', method='POST',
|
|
117
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
118
|
+
def list_general_settings(self, **kwargs) -> ApiResponse:
|
|
119
|
+
r"""
|
|
120
|
+
Lists the general inherited settings. Read only.
|
|
121
|
+
|
|
122
|
+
Keyword Args
|
|
123
|
+
|
|
124
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
125
|
+
|
|
126
|
+
Returns
|
|
127
|
+
ApiResponse, ``200``, with the settings.
|
|
128
|
+
"""
|
|
129
|
+
headers = {'Accept': 'application/json'}
|
|
130
|
+
headers['Content-Type'] = 'application/json'
|
|
131
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
132
|
+
return self._request(kwargs.pop('path'),
|
|
133
|
+
data=body, params=kwargs, headers=headers)
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"""Inventory groups /dsp/inventory.
|
|
2
|
+
|
|
3
|
+
Contract: Inventory Groups 3.0. Nine operations over eight paths, and **two
|
|
4
|
+
generations living side by side**:
|
|
5
|
+
|
|
6
|
+
- ``/dsp/inventory/packages`` speaks ``vnd.supplypackages``.
|
|
7
|
+
- ``/dsp/v1/inventory/inventoryGroups`` speaks plain ``application/json``.
|
|
8
|
+
|
|
9
|
+
The second family is the newer one and carries the ``v1`` in the path, so no
|
|
10
|
+
``version`` argument is needed: the generation is in the URL.
|
|
11
|
+
|
|
12
|
+
Also ``201`` on the package create, ``204`` on its update, ``201`` on the group
|
|
13
|
+
create and ``204`` on the group update.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DspInventoryGroups(Client):
|
|
20
|
+
r"""Inventory groups - /dsp/inventory
|
|
21
|
+
|
|
22
|
+
Documentation: https://advertising.amazon.com/API/docs/en-us/inventory-groups
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
@sp_endpoint('/dsp/inventory/packages', method='POST',
|
|
26
|
+
headers=['Amazon-Advertising-API-Scope'])
|
|
27
|
+
def create_package(self, version: str = "1", **kwargs) -> ApiResponse:
|
|
28
|
+
r"""
|
|
29
|
+
Creates a supply package.
|
|
30
|
+
|
|
31
|
+
Keyword Args
|
|
32
|
+
|
|
33
|
+
- ``version`` (str): the version in the media type, ``1``. [optional]
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
ApiResponse, **201 created**.
|
|
37
|
+
"""
|
|
38
|
+
media_type = 'application/vnd.supplypackages.v' + version + '+json'
|
|
39
|
+
headers = {'Accept': media_type}
|
|
40
|
+
headers['Content-Type'] = media_type
|
|
41
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
42
|
+
return self._request(kwargs.pop('path'),
|
|
43
|
+
data=body, params=kwargs, headers=headers)
|
|
44
|
+
|
|
45
|
+
@sp_endpoint('/dsp/inventory/packages/list', method='POST',
|
|
46
|
+
headers=['Amazon-Advertising-API-Scope'])
|
|
47
|
+
def list_packages(self, version: str = "1", **kwargs) -> ApiResponse:
|
|
48
|
+
r"""
|
|
49
|
+
Lists supply packages. Read only.
|
|
50
|
+
|
|
51
|
+
Keyword Args
|
|
52
|
+
|
|
53
|
+
- ``version`` (str): the version in the media type, ``1``. [optional]
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
ApiResponse, ``200``, with the packages.
|
|
57
|
+
"""
|
|
58
|
+
media_type = 'application/vnd.supplypackages.v' + version + '+json'
|
|
59
|
+
headers = {'Accept': media_type}
|
|
60
|
+
headers['Content-Type'] = media_type
|
|
61
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
62
|
+
return self._request(kwargs.pop('path'),
|
|
63
|
+
data=body, params=kwargs, headers=headers)
|
|
64
|
+
|
|
65
|
+
@sp_endpoint('/dsp/inventory/packages/{}', method='PUT',
|
|
66
|
+
headers=['Amazon-Advertising-API-Scope'])
|
|
67
|
+
def update_package(self, supplyPackageId, version: str = "1", **kwargs) -> ApiResponse:
|
|
68
|
+
r"""
|
|
69
|
+
Updates a supply package.
|
|
70
|
+
|
|
71
|
+
Keyword Args
|
|
72
|
+
|
|
73
|
+
- ``version`` (str): the version in the media type, ``1``. [optional]
|
|
74
|
+
|
|
75
|
+
Returns
|
|
76
|
+
ApiResponse, **204**, with **no body**.
|
|
77
|
+
"""
|
|
78
|
+
media_type = 'application/vnd.supplypackages.v' + version + '+json'
|
|
79
|
+
headers = {'Accept': media_type}
|
|
80
|
+
headers['Content-Type'] = media_type
|
|
81
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
82
|
+
return self._request(fill_query_params(kwargs.pop('path'), supplyPackageId),
|
|
83
|
+
data=body, params=kwargs, headers=headers)
|
|
84
|
+
|
|
85
|
+
@sp_endpoint('/dsp/inventorySourceInventoryGroups/list', method='POST',
|
|
86
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
87
|
+
def list_inventory_source_groups(self, version: str = "1", **kwargs) -> ApiResponse:
|
|
88
|
+
r"""
|
|
89
|
+
Lists the inventory groups of the inventory sources. Read only.
|
|
90
|
+
|
|
91
|
+
The request speaks ``vnd.inventorydiscoveryinventorygroups`` and **the answer
|
|
92
|
+
speaks ``vnd.supplypackages``**: two names.
|
|
93
|
+
|
|
94
|
+
Keyword Args
|
|
95
|
+
|
|
96
|
+
- ``version`` (str): the version in the media type, ``1``. [optional]
|
|
97
|
+
|
|
98
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
99
|
+
|
|
100
|
+
Returns
|
|
101
|
+
ApiResponse, ``200``, with the groups. The answer is ``supplypackages``.
|
|
102
|
+
"""
|
|
103
|
+
media_type = 'application/vnd.inventorydiscoveryinventorygroups.v' + version + '+json'
|
|
104
|
+
headers = {'Accept': media_type}
|
|
105
|
+
headers['Content-Type'] = media_type
|
|
106
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
107
|
+
return self._request(kwargs.pop('path'),
|
|
108
|
+
data=body, params=kwargs, headers=headers)
|
|
109
|
+
|
|
110
|
+
@sp_endpoint('/dsp/v1/inventory/eligibility/inventoryGroups/list', method='POST',
|
|
111
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
112
|
+
def list_eligible_inventory_groups(self, **kwargs) -> ApiResponse:
|
|
113
|
+
r"""
|
|
114
|
+
Lists the inventory groups an advertiser is eligible for. Read only.
|
|
115
|
+
|
|
116
|
+
Plain ``application/json``; no ``vnd`` here.
|
|
117
|
+
|
|
118
|
+
Keyword Args
|
|
119
|
+
|
|
120
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
ApiResponse, ``200``, with the eligibility.
|
|
124
|
+
"""
|
|
125
|
+
headers = {'Accept': 'application/json'}
|
|
126
|
+
headers['Content-Type'] = 'application/json'
|
|
127
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
128
|
+
return self._request(kwargs.pop('path'),
|
|
129
|
+
data=body, params=kwargs, headers=headers)
|
|
130
|
+
|
|
131
|
+
@sp_endpoint('/dsp/v1/inventory/inventoryGroups', method='POST',
|
|
132
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
133
|
+
def create_inventory_group(self, **kwargs) -> ApiResponse:
|
|
134
|
+
r"""
|
|
135
|
+
Creates an inventory group.
|
|
136
|
+
|
|
137
|
+
Keyword Args
|
|
138
|
+
|
|
139
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
140
|
+
|
|
141
|
+
Returns
|
|
142
|
+
ApiResponse, **201 created**.
|
|
143
|
+
"""
|
|
144
|
+
headers = {'Accept': 'application/json'}
|
|
145
|
+
headers['Content-Type'] = 'application/json'
|
|
146
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
147
|
+
return self._request(kwargs.pop('path'),
|
|
148
|
+
data=body, params=kwargs, headers=headers)
|
|
149
|
+
|
|
150
|
+
@sp_endpoint('/dsp/v1/inventory/inventoryGroups', method='PUT',
|
|
151
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
152
|
+
def update_inventory_group(self, **kwargs) -> ApiResponse:
|
|
153
|
+
r"""
|
|
154
|
+
Updates an inventory group. The id goes in the body, not in the path.
|
|
155
|
+
|
|
156
|
+
Keyword Args
|
|
157
|
+
|
|
158
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
159
|
+
|
|
160
|
+
Returns
|
|
161
|
+
ApiResponse, **204**, with **no body**.
|
|
162
|
+
"""
|
|
163
|
+
headers = {'Accept': 'application/json'}
|
|
164
|
+
headers['Content-Type'] = 'application/json'
|
|
165
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
166
|
+
return self._request(kwargs.pop('path'),
|
|
167
|
+
data=body, params=kwargs, headers=headers)
|
|
168
|
+
|
|
169
|
+
@sp_endpoint('/dsp/v1/inventory/inventoryGroups/list', method='POST',
|
|
170
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
171
|
+
def list_inventory_groups(self, **kwargs) -> ApiResponse:
|
|
172
|
+
r"""
|
|
173
|
+
Lists inventory groups. Read only.
|
|
174
|
+
|
|
175
|
+
Keyword Args
|
|
176
|
+
|
|
177
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
178
|
+
|
|
179
|
+
Returns
|
|
180
|
+
ApiResponse, ``200``, with the groups.
|
|
181
|
+
"""
|
|
182
|
+
headers = {'Accept': 'application/json'}
|
|
183
|
+
headers['Content-Type'] = 'application/json'
|
|
184
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
185
|
+
return self._request(kwargs.pop('path'),
|
|
186
|
+
data=body, params=kwargs, headers=headers)
|
|
187
|
+
|
|
188
|
+
@sp_endpoint('/dsp/v1/inventory/inventoryGroups/{}/adgroups/list', method='POST',
|
|
189
|
+
headers=['Amazon-Advertising-API-Scope', 'Amazon-Ads-AccountId'])
|
|
190
|
+
def list_inventory_group_ad_groups(self, inventoryGroupId, **kwargs) -> ApiResponse:
|
|
191
|
+
r"""
|
|
192
|
+
Lists the ad groups of an inventory group. Read only.
|
|
193
|
+
|
|
194
|
+
Path Parameters
|
|
195
|
+
|
|
196
|
+
- ``inventoryGroupId`` (str): the group. [required]
|
|
197
|
+
|
|
198
|
+
Keyword Args
|
|
199
|
+
|
|
200
|
+
- ``selector`` (str): ``profile_id`` or ``account_id``. [optional]
|
|
201
|
+
|
|
202
|
+
Returns
|
|
203
|
+
ApiResponse, ``200``, with the ad groups.
|
|
204
|
+
"""
|
|
205
|
+
headers = {'Accept': 'application/json'}
|
|
206
|
+
headers['Content-Type'] = 'application/json'
|
|
207
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
208
|
+
return self._request(fill_query_params(kwargs.pop('path'), inventoryGroupId),
|
|
209
|
+
data=body, params=kwargs, headers=headers)
|