python-amazon-ad-api 2.2.6__py3-none-any.whl → 2.2.8__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 CHANGED
@@ -34,6 +34,7 @@ from .stores import Stores
34
34
  from .brand_home import BrandHome
35
35
  from .ras_retailer_identity import RasRetailerIdentity
36
36
  from .ras_campaign_management import RasCampaignManagement
37
+ from .ads_data_manager import AdsDataManager
37
38
 
38
39
  __all__ = [
39
40
  "v1",
@@ -74,5 +75,6 @@ __all__ = [
74
75
  "BrandHome",
75
76
  "RasRetailerIdentity",
76
77
  "RasCampaignManagement",
78
+ "AdsDataManager",
77
79
  "Account"
78
80
  ]
@@ -0,0 +1,390 @@
1
+ """Ads Data Manager /adm.
2
+
3
+ Contract: Ads Data Manager 3.0, every route under ``/adm``. The family
4
+ identifies the caller with ``Amazon-Ads-AccountId``, so each route declares
5
+ that header.
6
+
7
+ Three routes carry a vendor media type: the two Datasets ones use
8
+ ``admmetrics.v1`` and the audiences ingest route uses ``admAudiences.v1``.
9
+ Those build the schema in the body of the method, as Sponsored TV does with
10
+ ``stCampaign.v<version>``, and send it as ``Accept`` and ``Content-Type``.
11
+
12
+ The routes that delete a DataSet or an identity, and the one that revokes a
13
+ sharing rule, are final. Nothing in the client calls them on its own.
14
+ """
15
+
16
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils, fill_query_params
17
+
18
+
19
+ class AdsDataManager(Client):
20
+ r"""Ads Data Manager - /adm"""
21
+
22
+ # ------------------------------------------------------------------
23
+ # Audiences
24
+ # ------------------------------------------------------------------
25
+
26
+ @sp_endpoint('/adm/audiences', method='GET', headers=['Amazon-Ads-AccountId'])
27
+ def list_audience_datasets(self, **kwargs) -> ApiResponse:
28
+ r"""
29
+ Lists all Audience DataSets. Read only.
30
+
31
+ Keyword Args
32
+
33
+ - ``selector`` (str): ``'account_id'``. [optional]
34
+ - ``nextToken`` (str): pagination token. [optional]
35
+ - ``limit`` (int): page size. [optional]
36
+
37
+ Returns
38
+ ApiResponse with ``dataSets`` and ``nextToken``.
39
+ """
40
+ return self._request(kwargs.pop('path'), params=kwargs)
41
+
42
+ @sp_endpoint('/adm/audiences/{}', method='GET', headers=['Amazon-Ads-AccountId'])
43
+ def get_audience_dataset(self, dataSetId, **kwargs) -> ApiResponse:
44
+ r"""
45
+ Gets one Audience DataSet. Read only.
46
+
47
+ Path Parameters
48
+
49
+ - ``dataSetId`` (str): the DataSet. [required]
50
+
51
+ Keyword Args
52
+
53
+ - ``selector`` (str): ``'account_id'``. [optional]
54
+
55
+ Returns
56
+ ApiResponse with ``dataSetId``, ``name``, ``clientName``,
57
+ ``countryCode``, ``createdBy``, ``dateCreated``, ``dataSetType``,
58
+ ``lastModified``, ``lastModifiedBy``, ``schema``, ``description``,
59
+ ``idRetention``, ``metadata``, ``partitionedBy`` and ``teeEnabled``.
60
+ """
61
+ return self._request(fill_query_params(kwargs.pop('path'), dataSetId), params=kwargs)
62
+
63
+ @sp_endpoint('/adm/audiences', method='POST', headers=['Amazon-Ads-AccountId'])
64
+ def create_audience_dataset(self, **kwargs) -> ApiResponse:
65
+ r"""
66
+ Creates an Audience DataSet. It holds no members until they are ingested.
67
+
68
+ Request Body [Required]
69
+ | **name** (str): the DataSet name.
70
+ | **countryCode** (str): ISO 3166-1 alpha-2.
71
+ | **description** (str). [optional]
72
+ | **idRetention** (bool). [optional]
73
+ | **teeEnabled** (bool). [optional]
74
+
75
+ Keyword Args
76
+
77
+ - ``selector`` (str): ``'account_id'``. [optional]
78
+
79
+ Returns
80
+ ApiResponse with the new ``dataSetId`` and the DataSet as stored.
81
+ """
82
+ body = Utils.convert_body(kwargs.pop('body'), False)
83
+ return self._request(kwargs.pop('path'), data=body, params=kwargs)
84
+
85
+ @sp_endpoint('/adm/audiences/{}/members', method='POST', headers=['Amazon-Ads-AccountId'])
86
+ def ingest_audiences(self, dataSetId, version: int = 1, **kwargs) -> ApiResponse:
87
+ r"""
88
+ Adds or removes members of one Audience DataSet.
89
+
90
+ Path Parameters
91
+
92
+ - ``dataSetId`` (str): the DataSet. [required]
93
+
94
+ Request Body [Required]
95
+ | **members** (list): each entry has **action** (``CREATE`` or
96
+ | ``DELETE``), **externalUserId**, **userIdentity** and an
97
+ | optional **userConsent**.
98
+
99
+ Keyword Args
100
+
101
+ - ``version`` (int): media type version. Defaults to 1.
102
+ - ``selector`` (str): ``'account_id'``. [optional]
103
+
104
+ Returns
105
+ ApiResponse with ``ingressId`` and the rejected ``errors``.
106
+ """
107
+ schema = 'application/vnd.admAudiences.v' + str(version) + '+json'
108
+ headers = {'Accept': schema, 'Content-Type': schema}
109
+ body = Utils.convert_body(kwargs.pop('body'), False)
110
+ return self._request(fill_query_params(kwargs.pop('path'), dataSetId), data=body, params=kwargs, headers=headers)
111
+
112
+ # ------------------------------------------------------------------
113
+ # Terms
114
+ # ------------------------------------------------------------------
115
+
116
+ @sp_endpoint('/adm/terms', method='GET', headers=['Amazon-Ads-AccountId'])
117
+ def get_terms(self, **kwargs) -> ApiResponse:
118
+ r"""
119
+ Gets the Ads Data Manager Terms and Conditions. Read only.
120
+
121
+ Keyword Args
122
+
123
+ - ``selector`` (str): ``'account_id'``. [optional]
124
+
125
+ Returns
126
+ ApiResponse with ``hasAccepted``, the ``agreementToken`` that
127
+ acceptance needs and the ``agreementContent`` as HTML.
128
+ """
129
+ return self._request(kwargs.pop('path'), params=kwargs)
130
+
131
+ @sp_endpoint('/adm/terms', method='PATCH', headers=['Amazon-Ads-AccountId'])
132
+ def set_terms_acceptance(self, **kwargs) -> ApiResponse:
133
+ r"""
134
+ Accepts the Ads Data Manager Terms. This is a legal acceptance on the
135
+ account; nothing calls it for you.
136
+
137
+ Request Body [Required]
138
+ | **agreementToken** (str): from ``get_terms``.
139
+ | **hasAccepted** (bool): true.
140
+
141
+ Keyword Args
142
+
143
+ - ``selector`` (str): ``'account_id'``. [optional]
144
+
145
+ Returns
146
+ ApiResponse, 204 No Content on success.
147
+ """
148
+ body = Utils.convert_body(kwargs.pop('body'), False)
149
+ return self._request(kwargs.pop('path'), data=body, params=kwargs)
150
+
151
+ # ------------------------------------------------------------------
152
+ # Data rooms
153
+ # ------------------------------------------------------------------
154
+
155
+ @sp_endpoint('/adm/datarooms', method='GET', headers=['Amazon-Ads-AccountId'])
156
+ def get_dataroom(self, **kwargs) -> ApiResponse:
157
+ r"""
158
+ Gets the Data room assigned to the account. Read only. Answers 404 while
159
+ the room does not exist.
160
+
161
+ Keyword Args
162
+
163
+ - ``selector`` (str): ``'account_id'``. [optional]
164
+
165
+ Returns
166
+ ApiResponse with ``accountId``, ``assignedToAccountId``,
167
+ ``creationDateTime`` and ``region``.
168
+ """
169
+ return self._request(kwargs.pop('path'), params=kwargs)
170
+
171
+ @sp_endpoint('/adm/datarooms', method='POST', headers=['Amazon-Ads-AccountId'])
172
+ def create_dataroom(self, **kwargs) -> ApiResponse:
173
+ r"""
174
+ Creates the Data room for the account. No body: the service assigns the
175
+ region.
176
+
177
+ Keyword Args
178
+
179
+ - ``selector`` (str): ``'account_id'``. [optional]
180
+
181
+ Returns
182
+ ApiResponse with ``accountId``, ``assignedToAccountId``,
183
+ ``creationDateTime`` and ``region``.
184
+ """
185
+ return self._request(kwargs.pop('path'), params=kwargs)
186
+
187
+ @sp_endpoint('/adm/datarooms/metadata', method='GET', headers=['Amazon-Ads-AccountId'])
188
+ def get_dataroom_metadata(self, **kwargs) -> ApiResponse:
189
+ r"""
190
+ Gets the Data room counters. Read only.
191
+
192
+ Keyword Args
193
+
194
+ - ``selector`` (str): ``'account_id'``. [optional]
195
+
196
+ Returns
197
+ ApiResponse with ``totalDataSets``, ``dataSetsInUse``,
198
+ ``activeDestinations`` and ``linkedAccounts``.
199
+ """
200
+ return self._request(kwargs.pop('path'), params=kwargs)
201
+
202
+ # ------------------------------------------------------------------
203
+ # Datasets
204
+ # ------------------------------------------------------------------
205
+
206
+ @sp_endpoint('/adm/datasets/list', method='POST', headers=['Amazon-Ads-AccountId'])
207
+ def list_dataset_details(self, version: int = 1, **kwargs) -> ApiResponse:
208
+ r"""
209
+ Lists the DataSets registered in the account. Read only.
210
+
211
+ Request Body [Optional]
212
+ | **datasetIds** (list): narrow to these ids.
213
+
214
+ Keyword Args
215
+
216
+ - ``version`` (int): media type version. Defaults to 1.
217
+ - ``search`` (str): free text over the names. [optional]
218
+ - ``order`` (str): sort order. [optional]
219
+ - ``nextToken`` (str): pagination token. [optional]
220
+ - ``maxResults`` (int): page size. [optional]
221
+ - ``selector`` (str): ``'account_id'``. [optional]
222
+
223
+ Returns
224
+ ApiResponse with ``datasets`` and ``nextToken``.
225
+ """
226
+ schema = 'application/vnd.admmetrics.v' + str(version) + '+json'
227
+ headers = {'Accept': schema, 'Content-Type': schema}
228
+ body = Utils.convert_body(kwargs.pop('body', {}), False)
229
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
230
+
231
+ @sp_endpoint('/adm/datasets/{}', method='DELETE', headers=['Amazon-Ads-AccountId'])
232
+ def delete_dataset(self, dataSetId, **kwargs) -> ApiResponse:
233
+ r"""
234
+ Deletes a DataSet and the data in it. Final; nothing calls it.
235
+
236
+ Path Parameters
237
+
238
+ - ``dataSetId`` (str): the DataSet. [required]
239
+
240
+ Keyword Args
241
+
242
+ - ``selector`` (str): ``'account_id'``. [optional]
243
+
244
+ Returns
245
+ ApiResponse, 204 No Content on success.
246
+ """
247
+ return self._request(fill_query_params(kwargs.pop('path'), dataSetId), params=kwargs)
248
+
249
+ @sp_endpoint('/adm/datasets/{}/metrics', method='GET', headers=['Amazon-Ads-AccountId'])
250
+ def get_dataset_metrics(self, dataSetId, **kwargs) -> ApiResponse:
251
+ r"""
252
+ Gets the counters and the match rate of one DataSet. Read only.
253
+
254
+ Path Parameters
255
+
256
+ - ``dataSetId`` (str): the DataSet. [required]
257
+
258
+ Keyword Args
259
+
260
+ - ``selector`` (str): ``'account_id'``. [optional]
261
+
262
+ Returns
263
+ ApiResponse with ``dataSetId``, ``dataSetType``, ``dataSetSource``,
264
+ ``acceptedCount``, ``invalidRecordCount``, ``matchRecordPercentage``,
265
+ ``dateCreated``, ``lastModified``, ``description``, ``countryCode``
266
+ and ``metadata``.
267
+ """
268
+ return self._request(fill_query_params(kwargs.pop('path'), dataSetId), params=kwargs)
269
+
270
+ @sp_endpoint('/adm/datasets/{}/metrics/aggregates', method='POST', headers=['Amazon-Ads-AccountId'])
271
+ def get_dataset_aggregates(self, dataSetId, version: int = 1, **kwargs) -> ApiResponse:
272
+ r"""
273
+ Gets the time series of one DataSet between two dates. Read only.
274
+
275
+ Path Parameters
276
+
277
+ - ``dataSetId`` (str): the DataSet. [required]
278
+
279
+ Request Body [Required]
280
+ | **startDate** (str): first day, ISO date.
281
+ | **endDate** (str): last day, ISO date.
282
+ | **metrics** (list): ``CONSENTED``, ``RECEIVED``, ``RESOLVED``
283
+ | or ``VALID``. [optional]
284
+
285
+ Keyword Args
286
+
287
+ - ``version`` (int): media type version. Defaults to 1.
288
+ - ``selector`` (str): ``'account_id'``. [optional]
289
+
290
+ Returns
291
+ ApiResponse with ``metrics``, the DatasetTimeSeries.
292
+ """
293
+ schema = 'application/vnd.admmetrics.v' + str(version) + '+json'
294
+ headers = {'Accept': schema, 'Content-Type': schema}
295
+ body = Utils.convert_body(kwargs.pop('body'), False)
296
+ return self._request(fill_query_params(kwargs.pop('path'), dataSetId), data=body, params=kwargs, headers=headers)
297
+
298
+ # ------------------------------------------------------------------
299
+ # Identity Deletion
300
+ # ------------------------------------------------------------------
301
+
302
+ @sp_endpoint('/adm/identities/delete', method='POST', headers=['Amazon-Ads-AccountId'])
303
+ def delete_identities(self, **kwargs) -> ApiResponse:
304
+ r"""
305
+ Deletes end-user identities from the DataSets. Final; nothing calls it.
306
+
307
+ Request Body [Required]
308
+ | **targetIdentities** (list): each entry is ``{"externalUserId": ...}``
309
+ | or ``{"identity": {...}}`` with hashed PII.
310
+
311
+ Keyword Args
312
+
313
+ - ``selector`` (str): ``'account_id'``. [optional]
314
+
315
+ Returns
316
+ ApiResponse with the result of the deletion.
317
+ """
318
+ body = Utils.convert_body(kwargs.pop('body'), False)
319
+ return self._request(kwargs.pop('path'), data=body, params=kwargs)
320
+
321
+ # ------------------------------------------------------------------
322
+ # Sharing Rules
323
+ # ------------------------------------------------------------------
324
+
325
+ @sp_endpoint('/adm/sharingRules', method='POST', headers=['Amazon-Ads-AccountId'])
326
+ def create_sharing_rule(self, **kwargs) -> ApiResponse:
327
+ r"""
328
+ Shares one DataSet with another account or application.
329
+
330
+ Request Body [Required]
331
+ | **application** (str): ``AMAZON_MARKETING_CLOUD``, ``AUDIENCE_HUB``,
332
+ | ``DSP_AUDIENCES``, ``EVENTS_MANAGER``, ``GEO_LOCATIONS`` or
333
+ | ``PG_DEALS``.
334
+ | **dataSetId** (str).
335
+ | **destinationAccountId** (str).
336
+ | **marketplaceId** (str).
337
+ | **metadata** (object): application metadata.
338
+ | **accountEntityId** (str). [optional]
339
+
340
+ Keyword Args
341
+
342
+ - ``selector`` (str): ``'account_id'``. [optional]
343
+
344
+ Returns
345
+ ApiResponse with the ``sharingRuleId``, its ``status`` and the rule.
346
+ """
347
+ body = Utils.convert_body(kwargs.pop('body'), False)
348
+ return self._request(kwargs.pop('path'), data=body, params=kwargs)
349
+
350
+ @sp_endpoint('/adm/sharingRules/list', method='POST', headers=['Amazon-Ads-AccountId'])
351
+ def list_sharing_rules(self, **kwargs) -> ApiResponse:
352
+ r"""
353
+ Lists the sharing rules of the account. Read only.
354
+
355
+ Request Body [Optional]
356
+ | **datasetIds**, **statuses** (lists), **destinationAccountId**,
357
+ | **application**, **activatedAfter**, **activatedBefore**,
358
+ | **nextToken**, **maxResults**.
359
+ | Status values: ``ACTIVE``, ``PENDING``, ``SHADOW``,
360
+ | ``REVOKED_BY_DATASET``, ``REVOKED_BY_SHARING_GRANT``,
361
+ | ``REVOKED_BY_USER``.
362
+
363
+ Keyword Args
364
+
365
+ - ``selector`` (str): ``'account_id'``. [optional]
366
+
367
+ Returns
368
+ ApiResponse with ``sharingRules`` and ``nextToken``.
369
+ """
370
+ body = Utils.convert_body(kwargs.pop('body', {}), False)
371
+ return self._request(kwargs.pop('path'), data=body, params=kwargs)
372
+
373
+ @sp_endpoint('/adm/sharingRules/{}/revoke', method='PATCH', headers=['Amazon-Ads-AccountId'])
374
+ def revoke_sharing_rule(self, sharingRuleId, **kwargs) -> ApiResponse:
375
+ r"""
376
+ Revokes one sharing rule. Final; the DataSet stops being visible to the
377
+ destination.
378
+
379
+ Path Parameters
380
+
381
+ - ``sharingRuleId`` (str): the rule. [required]
382
+
383
+ Keyword Args
384
+
385
+ - ``selector`` (str): ``'account_id'``. [optional]
386
+
387
+ Returns
388
+ ApiResponse, 204 No Content on success.
389
+ """
390
+ return self._request(fill_query_params(kwargs.pop('path'), sharingRuleId), params=kwargs)
@@ -5,7 +5,7 @@ _HEADERS = {'Accept': 'application/json'}
5
5
 
6
6
 
7
7
  class RasCampaignManagement(Client):
8
- """ ​ """
8
+ r"""Retail Ad Service - Campaign management - /ras/v1"""
9
9
 
10
10
  # ------------------------------------------------------------------
11
11
  # Campaigns
@@ -2,7 +2,7 @@ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
2
2
 
3
3
 
4
4
  class RasRetailerIdentity(Client):
5
- """ """
5
+ r"""Retail Ad Service - Retailer identity - /ras/v1"""
6
6
 
7
7
  @sp_endpoint('/ras/v1/retailers/list', method='POST',
8
8
  headers=['Amazon-Advertising-API-Scope'])
ad_api/api/stream.py CHANGED
@@ -1,67 +1,227 @@
1
+ """Amazon Marketing Stream /streams and /dsp/streams.
2
+
3
+ Contract: Amazon Marketing Stream 3.0. Two branches, the advertiser one under
4
+ ``/streams/subscriptions`` and the DSP one under ``/dsp/streams/subscriptions``,
5
+ with the same four operations each.
6
+
7
+ The two branches do not declare the same identity header. The advertiser routes
8
+ take ``Amazon-Ads-AccountId`` and ``Amazon-Advertising-API-Scope``, both
9
+ optional; the DSP routes take ``Amazon-Ads-Account-ID``, with the ``ID`` in
10
+ capitals and required. They are different names, so each branch declares its own.
11
+
12
+ Both branches send and accept
13
+ ``application/vnd.amazonmarketingstreamsubscriptions.v<n>+json``. The media type
14
+ is built in the method body from the ``version`` argument, as the Sponsored TV
15
+ module does with ``stCampaign.v<n>``.
16
+ """
17
+
1
18
  from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
2
19
 
3
20
 
4
21
  class Stream(Client):
5
- """Amazon Marketing Stream
22
+ r"""Amazon Marketing Stream - /streams and /dsp/streams
6
23
 
7
- Documentation: https://advertising.amazon.com/API/docs/en-us/amazon-marketing-stream/openapi#tag/Stream-Subscription
24
+ Documentation: https://advertising.amazon.com/API/docs/en-us/amazon-marketing-stream/openapi
8
25
  """
9
26
 
10
- @sp_endpoint('/streams/subscriptions', method='POST')
11
- def create_subscription(self, **kwargs) -> ApiResponse:
27
+ # ------------------------------------------------------------------
28
+ # Stream Subscription
29
+ # ------------------------------------------------------------------
30
+
31
+ @sp_endpoint('/streams/subscriptions', method='POST',
32
+ headers=['Amazon-Advertising-API-Scope'])
33
+ def create_subscription(self, version: int = 1, **kwargs) -> ApiResponse:
34
+ r"""
35
+ Requests a new subscription.
36
+
37
+ Request Body [Required]
38
+ | **dataSetId** (str): the data set to subscribe to.
39
+ | **clientRequestToken** (str): caller token to make retries
40
+ | idempotent.
41
+ | **destinationArn** (str): AWS ARN of the destination (SQS, Firehose).
42
+ | **destination** (object): ``{"sqsDestination": {"queueArn": ...}}``
43
+ | or ``{"firehoseDestination": {...}}``.
44
+ | **notes** (str). [optional]
45
+
46
+ Keyword Args
47
+
48
+ - ``version`` (int): media type version. Defaults to 1.
49
+ - ``selector`` (str): ``'account_id'`` or ``'profile_id'``. [optional]
50
+
51
+ Returns
52
+ ApiResponse with ``subscriptionId`` and ``clientRequestToken``.
53
+ """
54
+ schema = 'application/vnd.amazonmarketingstreamsubscriptions.v' + str(version) + '+json'
55
+ headers = {'Accept': schema, 'Content-Type': schema}
56
+ body = Utils.convert_body(kwargs.pop('body'), False)
57
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
58
+
59
+ @sp_endpoint('/streams/subscriptions/{}', method='PUT',
60
+ headers=['Amazon-Advertising-API-Scope'])
61
+ def update_subscription(self, subscription_id: str, version: int = 1, **kwargs) -> ApiResponse:
12
62
  r"""
13
- Request the creation a new subscription
63
+ Updates an existing subscription.
14
64
 
15
- Request body
16
- | **notes** (string): [optional] Additional details associated with the subscription
17
- | **clientRequestToken** (string): [required] Unique value supplied by the caller used to track identical API requests. Should request be re-tried, the caller should supply the same value.
18
- | **dataSetId** (string): [required] Identifier of data set, callers can be subscribed to. Please refer to https://advertising.amazon.com/API/docs/en-us/amazon-marketing-stream/data-guide for the list of all data sets.
19
- | **destinationArn** (string): [required] AWS ARN of the destination endpoint associated with the subscription. Supported destination type - SQS.
65
+ Path Parameters
20
66
 
21
- Returns:
67
+ - ``subscription_id`` (str): the subscription. [required]
68
+
69
+ Request Body [Optional]
70
+ | **status** (str): the only accepted value is ``ARCHIVED``.
71
+ | **notes** (str).
72
+
73
+ Keyword Args
74
+
75
+ - ``version`` (int): media type version. Defaults to 1.
76
+ - ``selector`` (str): ``'account_id'`` or ``'profile_id'``. [optional]
77
+
78
+ Returns
22
79
  ApiResponse
23
80
  """
24
- body = Utils.convert_body(kwargs.pop('body'), wrap=False)
25
- return self._request(kwargs.pop('path'), data=body, params=kwargs)
81
+ schema = 'application/vnd.amazonmarketingstreamsubscriptions.v' + str(version) + '+json'
82
+ headers = {'Accept': schema, 'Content-Type': schema}
83
+ body = Utils.convert_body(kwargs.pop('body', {}), False)
84
+ return self._request(fill_query_params(kwargs.pop('path'), subscription_id),
85
+ data=body, params=kwargs, headers=headers)
86
+
87
+ @sp_endpoint('/streams/subscriptions/{}', method='GET',
88
+ headers=['Amazon-Advertising-API-Scope'])
89
+ def get_subscription(self, subscription_id: str, version: int = 1, **kwargs) -> ApiResponse:
90
+ r"""
91
+ Fetches one subscription.
26
92
 
27
- @sp_endpoint('/streams/subscriptions/{}', method='PUT')
28
- def update_subscription(self, subscription_id: str, **kwargs) -> ApiResponse:
93
+ Path Parameters
94
+
95
+ - ``subscription_id`` (str): the subscription. [required]
96
+
97
+ Keyword Args
98
+
99
+ - ``version`` (int): media type version. Defaults to 1.
100
+ - ``selector`` (str): ``'account_id'`` or ``'profile_id'``. [optional]
101
+
102
+ Returns
103
+ ApiResponse with the StreamSubscription: ``subscriptionId``,
104
+ ``dataSetId``, ``destination``, ``status``, ``createdDate``, ``notes``.
105
+ """
106
+ schema = 'application/vnd.amazonmarketingstreamsubscriptions.v' + str(version) + '+json'
107
+ headers = {'Accept': schema}
108
+ return self._request(fill_query_params(kwargs.pop('path'), subscription_id),
109
+ params=kwargs, headers=headers)
110
+
111
+ @sp_endpoint('/streams/subscriptions', method='GET',
112
+ headers=['Amazon-Advertising-API-Scope'])
113
+ def list_subscriptions(self, version: int = 1, **kwargs) -> ApiResponse:
29
114
  r"""
30
- Update an existing subscription
115
+ Lists the subscriptions.
31
116
 
32
- Request body
33
- | **notes** (string): [optional] Additional details associated with the subscription
34
- | **status** (string): [optional] Update the status of the entity. Supported value: 'ARCHIVED'
117
+ Keyword Args
35
118
 
36
- Returns:
37
- ApiResponse
119
+ - ``version`` (int): media type version. Defaults to 1.
120
+ - ``maxResults`` (int): 1 to 5000. [optional]
121
+ - ``startingToken`` (str): pagination token. [optional]
122
+ - ``selector`` (str): ``'account_id'`` or ``'profile_id'``. [optional]
123
+
124
+ Returns
125
+ ApiResponse with ``subscriptions`` and ``nextToken``.
38
126
  """
39
- body = Utils.convert_body(kwargs.pop('body'), wrap=False)
40
- return self._request(fill_query_params(kwargs.pop('path'), subscription_id), data=body, params=kwargs)
127
+ schema = 'application/vnd.amazonmarketingstreamsubscriptions.v' + str(version) + '+json'
128
+ headers = {'Accept': schema}
129
+ return self._request(kwargs.pop('path'), params=kwargs, headers=headers)
130
+
131
+ # ------------------------------------------------------------------
132
+ # DSP Stream Subscription
133
+ # ------------------------------------------------------------------
134
+
135
+ @sp_endpoint('/dsp/streams/subscriptions', method='POST',
136
+ headers=['Amazon-Ads-Account-ID'])
137
+ def create_dsp_subscription(self, version: int = 1, **kwargs) -> ApiResponse:
138
+ r"""
139
+ Requests a new DSP subscription.
41
140
 
42
- @sp_endpoint('/streams/subscriptions/{}', method='GET')
43
- def get_subscription(self, subscription_id: str, **kwargs) -> ApiResponse:
141
+ Request Body [Required]
142
+ | **dataSetId** (str): the data set to subscribe to.
143
+ | **clientRequestToken** (str): caller token to make retries
144
+ | idempotent.
145
+ | **destinationArn** (str): AWS ARN of the destination.
146
+ | **destination** (object): SQS or Firehose destination.
147
+ | **notes** (str). [optional]
148
+
149
+ Keyword Args
150
+
151
+ - ``version`` (int): media type version. Defaults to 1.
152
+
153
+ Returns
154
+ ApiResponse with ``subscriptionId`` and ``clientRequestToken``.
155
+ """
156
+ schema = 'application/vnd.amazonmarketingstreamsubscriptions.v' + str(version) + '+json'
157
+ headers = {'Accept': schema, 'Content-Type': schema}
158
+ body = Utils.convert_body(kwargs.pop('body'), False)
159
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
160
+
161
+ @sp_endpoint('/dsp/streams/subscriptions/{}', method='PUT',
162
+ headers=['Amazon-Ads-Account-ID'])
163
+ def update_dsp_subscription(self, subscription_id: str, version: int = 1, **kwargs) -> ApiResponse:
44
164
  r"""
45
- Fetch a specific subscription by ID
165
+ Updates an existing DSP subscription.
166
+
167
+ Path Parameters
168
+
169
+ - ``subscription_id`` (str): the subscription. [required]
170
+
171
+ Request Body [Optional]
172
+ | **status** (str): ``ARCHIVED``.
173
+ | **notes** (str).
46
174
 
47
175
  Keyword Args
48
- | path **subscriptionId** (string): [required] Unique subscription identifier
49
176
 
50
- Returns:
177
+ - ``version`` (int): media type version. Defaults to 1.
178
+
179
+ Returns
51
180
  ApiResponse
52
181
  """
53
- return self._request(fill_query_params(kwargs.pop('path'), subscription_id), params=kwargs)
182
+ schema = 'application/vnd.amazonmarketingstreamsubscriptions.v' + str(version) + '+json'
183
+ headers = {'Accept': schema, 'Content-Type': schema}
184
+ body = Utils.convert_body(kwargs.pop('body', {}), False)
185
+ return self._request(fill_query_params(kwargs.pop('path'), subscription_id),
186
+ data=body, params=kwargs, headers=headers)
187
+
188
+ @sp_endpoint('/dsp/streams/subscriptions/{}', method='GET',
189
+ headers=['Amazon-Ads-Account-ID'])
190
+ def get_dsp_subscription(self, subscription_id: str, version: int = 1, **kwargs) -> ApiResponse:
191
+ r"""
192
+ Fetches one DSP subscription.
193
+
194
+ Path Parameters
195
+
196
+ - ``subscription_id`` (str): the subscription. [required]
54
197
 
55
- @sp_endpoint('/streams/subscriptions', method='GET')
56
- def list_subscriptions(self, **kwargs) -> ApiResponse:
198
+ Keyword Args
199
+
200
+ - ``version`` (int): media type version. Defaults to 1.
201
+
202
+ Returns
203
+ ApiResponse with the StreamSubscription.
204
+ """
205
+ schema = 'application/vnd.amazonmarketingstreamsubscriptions.v' + str(version) + '+json'
206
+ headers = {'Accept': schema}
207
+ return self._request(fill_query_params(kwargs.pop('path'), subscription_id),
208
+ params=kwargs, headers=headers)
209
+
210
+ @sp_endpoint('/dsp/streams/subscriptions', method='GET',
211
+ headers=['Amazon-Ads-Account-ID'])
212
+ def list_dsp_subscriptions(self, version: int = 1, **kwargs) -> ApiResponse:
57
213
  r"""
58
- List subscriptions
214
+ Lists the DSP subscriptions.
59
215
 
60
- query **maxResults**:*string* | Optional. [1-5000] Desired number of entries in the response, defaults to maximum value
216
+ Keyword Args
61
217
 
62
- query **startingToken**:*string* | Optional. Token which can be used to get the next page of results, if more entries exist
218
+ - ``version`` (int): media type version. Defaults to 1.
219
+ - ``maxResults`` (int): page size. [optional]
220
+ - ``startingToken`` (str): pagination token. [optional]
63
221
 
64
- Returns:
65
- ApiResponse
222
+ Returns
223
+ ApiResponse with ``subscriptions`` and ``nextToken``.
66
224
  """
67
- return self._request(kwargs.pop('path'), params=kwargs)
225
+ schema = 'application/vnd.amazonmarketingstreamsubscriptions.v' + str(version) + '+json'
226
+ headers = {'Accept': schema}
227
+ return self._request(kwargs.pop('path'), params=kwargs, headers=headers)
ad_api/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.2.6"
1
+ __version__ = "2.2.8"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-amazon-ad-api
3
- Version: 2.2.6
3
+ Version: 2.2.8
4
4
  Summary: Python wrapper for the Amazon Advertising API
5
5
  Home-page: https://github.com/denisneuf/python-amazon-ad-api
6
6
  Author: Daniel Alvaro
@@ -1,8 +1,9 @@
1
1
  ad_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- ad_api/version.py,sha256=qzqxcwWCwWgKw_eJA2nZPycPzwfpaSjAKO3MwNvDqgw,22
3
- ad_api/api/__init__.py,sha256=oLnhfbIX_e-B-0MAkPySpSRjkC00yUUgI4c6rC3EGls,2249
2
+ ad_api/version.py,sha256=YZuLtr55Kuq9kEWnoXMkj5a8XMpLccTIPbg7OO2S8KM,22
3
+ ad_api/api/__init__.py,sha256=kK0UDutfyhkFzRCzuZZsL6lE5Ir3XMJ0hlp8lcaxLJ8,2316
4
4
  ad_api/api/account.py,sha256=jNYwfjW8b0HhqP7PjlMev55aXJP3YIuqWhrxri0Pk4Y,4673
5
5
  ad_api/api/account_budgets.py,sha256=jFce5eLWAFK3ydjnYR7_Sv7B0-gHTG5bMTx_TcHyy1A,2319
6
+ ad_api/api/ads_data_manager.py,sha256=70kWsZ4FxiSATG8UnCbf7X4HF1i7Z9pW6vxnCog42kg,14931
6
7
  ad_api/api/advertising_invitations.py,sha256=TRwULEFi_HVyfK35ABkuZbFOHAdl4tNnGWanxrvX32A,4629
7
8
  ad_api/api/advertising_test_account.py,sha256=8aKQddJrHhjmHAiA1282vqTw482eK70XpzVihpzk9z4,1531
8
9
  ad_api/api/advertising_user_permissions.py,sha256=0l0R0H_cpNWaa2qfmWPps7GgdFmjaxaY-ezp6-beyJs,4665
@@ -25,12 +26,12 @@ ad_api/api/metadata.py,sha256=v-06G_EFmCWA9v4WorEPtIlbLOaYnv-veboXZi95WUo,2472
25
26
  ad_api/api/portfolios.py,sha256=Oe3LS2HsjMJSq1Id8cwOWrH2AiPMcBb7oTkFHjudnTI,7103
26
27
  ad_api/api/portfolios_v3.py,sha256=wSV9XYmdsvUaqLNGLy6NvUTRJJmxGNMO7PMig2zT41c,7608
27
28
  ad_api/api/profiles.py,sha256=g8u3tD7i8DHZ8dKN3cBM-dNLDLeqh8ctXXWlLpw1Arw,4851
28
- ad_api/api/ras_campaign_management.py,sha256=mVnri8jZbyuf7B2hLvbPEjI5O57otASw8gVJ8xUKTDU,20631
29
- ad_api/api/ras_retailer_identity.py,sha256=jIs0z4Sfy1vtl9SThK_WbdmDEE3DPSj5K0NZB9xBPt8,2020
29
+ ad_api/api/ras_campaign_management.py,sha256=PeUF_W48iIAU1qoE0XWnW7OWYlpOp7iAdvR-OFoQdiY,20676
30
+ ad_api/api/ras_retailer_identity.py,sha256=RobQLsLv9lF29ZDr5KwAQoh5skJ_Ono2CBmaSabCRm0,2067
30
31
  ad_api/api/recommendations.py,sha256=dV9uB8_hmylObZINvUetahc-tL4DBX0s9XMhYLkYFYE,6324
31
32
  ad_api/api/reports.py,sha256=u9mYkWOYSBVf8N1NyEc7pxUS04xzberGsCffTHKkFTA,8140
32
33
  ad_api/api/stores.py,sha256=BiwqOldK9zEsNjQzcII1DgBxQkDNsGP20aBx5i5Dmg8,2709
33
- ad_api/api/stream.py,sha256=mg_3SD5uXPAYjXVwOs1WsoHvk3AcP-XOXyoS3HhNEhw,3013
34
+ ad_api/api/stream.py,sha256=Ga1VHOR_z2YAZY3kRhDvzwEDad3P260g1lWfc4OAjGk,9338
34
35
  ad_api/api/validation_configurations.py,sha256=Qaxy_J67Fqw0ecS4f1sK9lGdiOLsq323RXeZO0_2KV0,4092
35
36
  ad_api/api/sb/__init__.py,sha256=APbCAkWM1gzYuhpEUU98XDIKJKJx1NXALjLBXA9zdBU,1538
36
37
  ad_api/api/sb/ad_creatives_v4.py,sha256=zQzTivDkGzX3I5ZfCWIlzRUGWfTRsXJZCKQrKMaMDpc,14512
@@ -147,8 +148,8 @@ ad_api/base/marketplaces.py,sha256=44lvCcluXNpqTprWQ80e3weSQmQbJoWL-WDSOWVbCyQ,4
147
148
  ad_api/base/utils.py,sha256=_qnCBOvyJTLgaZjJzUWTi38GGLHkQszXELs79133Rb4,5618
148
149
  ad_api/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
149
150
  ad_api/shared/base_client.py,sha256=zOL_LTh-58URWf3ZDlrwmqXXbd6PX66QF5hrr2p83yY,356
150
- python_amazon_ad_api-2.2.6.dist-info/licenses/LICENSE,sha256=h2rpqlmmLy-4l1tN6KpWAFxx1JEMYeEFrMrZUbx_B_o,1105
151
- python_amazon_ad_api-2.2.6.dist-info/METADATA,sha256=MveVbMzu_3II2Cdz2L0ghNYgU4u2TsXqXejPSxOenS4,10678
152
- python_amazon_ad_api-2.2.6.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
153
- python_amazon_ad_api-2.2.6.dist-info/top_level.txt,sha256=nN9twUos-8pkP514ZwpvRU9YL9L2XyQyHsMQFfudGTU,7
154
- python_amazon_ad_api-2.2.6.dist-info/RECORD,,
151
+ python_amazon_ad_api-2.2.8.dist-info/licenses/LICENSE,sha256=h2rpqlmmLy-4l1tN6KpWAFxx1JEMYeEFrMrZUbx_B_o,1105
152
+ python_amazon_ad_api-2.2.8.dist-info/METADATA,sha256=7y65JSg_7UA8BY9Wp9Cp_BPGop9r4XwcIyJPqLSZf1Q,10678
153
+ python_amazon_ad_api-2.2.8.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
154
+ python_amazon_ad_api-2.2.8.dist-info/top_level.txt,sha256=nN9twUos-8pkP514ZwpvRU9YL9L2XyQyHsMQFfudGTU,7
155
+ python_amazon_ad_api-2.2.8.dist-info/RECORD,,