python-amazon-ad-api 2.2.5__py3-none-any.whl → 2.2.7__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
@@ -33,6 +33,8 @@ from .exports import Exports
33
33
  from .stores import Stores
34
34
  from .brand_home import BrandHome
35
35
  from .ras_retailer_identity import RasRetailerIdentity
36
+ from .ras_campaign_management import RasCampaignManagement
37
+ from .ads_data_manager import AdsDataManager
36
38
 
37
39
  __all__ = [
38
40
  "v1",
@@ -72,5 +74,7 @@ __all__ = [
72
74
  "Stores",
73
75
  "BrandHome",
74
76
  "RasRetailerIdentity",
77
+ "RasCampaignManagement",
78
+ "AdsDataManager",
75
79
  "Account"
76
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)
@@ -0,0 +1,533 @@
1
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
2
+
3
+
4
+ _HEADERS = {'Accept': 'application/json'}
5
+
6
+
7
+ class RasCampaignManagement(Client):
8
+ r"""Retail Ad Service - Campaign management - /ras/v1"""
9
+
10
+ # ------------------------------------------------------------------
11
+ # Campaigns
12
+ # ------------------------------------------------------------------
13
+
14
+ @sp_endpoint('/ras/v1/campaigns/list', method='POST',
15
+ headers=['Amazon-Advertising-API-Scope'])
16
+ def list_campaigns(self, **kwargs) -> ApiResponse:
17
+ r"""
18
+ list_campaigns(body: (dict, str) = None) -> ApiResponse
19
+
20
+ Lists campaigns of Retail Ad Service. Read only.
21
+
22
+ Requires one of these permissions: ["advertiser_campaign_edit","advertiser_campaign_view"]
23
+
24
+ Kwargs:
25
+
26
+ **body**: *dict or str* (data) [optional]
27
+ | {
28
+ | "campaignIdFilter": {"include": ["string"]},
29
+ | "nameFilter": {"include": ["string"], "queryTermMatchType": "BROAD_MATCH"},
30
+ | "portfolioIdFilter": {"include": ["string"]},
31
+ | "stateFilter": {"include": ["ENABLED"]},
32
+ | "maxResults": 1000,
33
+ | "nextToken": "string"
34
+ | }
35
+
36
+ No member is required. campaignIdFilter holds up to 1000 ids;
37
+ portfolioIdFilter, nameFilter and the state list up to 100 (states:
38
+ ARCHIVED, ENABLED, PAUSED). maxResults is 1..1000, default 1000.
39
+
40
+ Returns ApiResponse
41
+
42
+ | **campaigns**: *list* 0..1000, each with campaignId, name, state,
43
+ | targetingType, budget {budget, budgetType, effectiveBudget},
44
+ | dynamicBidding, startDate, endDate, portfolioId, tags
45
+ | **nextToken**: *string*
46
+ | **totalResults**: *integer*
47
+ """
48
+ body = kwargs.pop('body', None)
49
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
50
+ **({'data': Utils.convert_body(body, False)} if body is not None else {}))
51
+
52
+ @sp_endpoint('/ras/v1/campaigns', method='POST',
53
+ headers=['Amazon-Advertising-API-Scope'])
54
+ def create_campaigns(self, **kwargs) -> ApiResponse:
55
+ r"""
56
+ create_campaigns(body: (dict, str)) -> ApiResponse
57
+
58
+ Creates up to 1000 campaigns. This changes the account.
59
+
60
+ Requires one of these permissions: ["advertiser_campaign_edit"]
61
+
62
+ Kwargs:
63
+
64
+ **Prefer**: *string* (header) [optional] 0 responde 207 directo
65
+
66
+ **body**: *dict or str* (data) REQUIRED
67
+ | { "campaigns": [ CampaignInput ] }
68
+ |
69
+ | CampaignInput {
70
+ | "name": "string" [required]
71
+ | "state": "ENABLED" [required] ARCHIVED, ENABLED, PAUSED
72
+ | "targetingType": "AUTO" [required] AUTO, MANUAL
73
+ | "budget": {"budget": 10, "budgetType": "DAILY"} [required]
74
+ | "dynamicBidding": { [required]
75
+ | "strategy": "MANUAL",
76
+ | "placementBidding": [{"placement": "PLACEMENT_TOP", "percentage": 10}]
77
+ | },
78
+ | "startDate": "YYYYMMDD",
79
+ | "endDate": "YYYYMMDD",
80
+ | "portfolioId": "string",
81
+ | "tags": [{"key": "string", "value": "string"}]
82
+ | }
83
+
84
+ Placements: PLACEMENT_BROWSE_OTHER, PLACEMENT_PRODUCT_PAGE,
85
+ PLACEMENT_REST_OF_SEARCH, PLACEMENT_TOP, PLACEMENT_TOP_BROWSE.
86
+
87
+ Returns ApiResponse
88
+
89
+ 207 MultiStatus: **success** and **error** lists, one entry per
90
+ campaign with its index. Inspect both before reporting success.
91
+ """
92
+ body = kwargs.pop('body')
93
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
94
+ data=Utils.convert_body(body, False))
95
+
96
+ @sp_endpoint('/ras/v1/campaigns', method='PUT',
97
+ headers=['Amazon-Advertising-API-Scope'])
98
+ def update_campaigns(self, **kwargs) -> ApiResponse:
99
+ r"""
100
+ update_campaigns(body: (dict, str)) -> ApiResponse
101
+
102
+ Updates up to 1000 campaigns. This changes the account.
103
+
104
+ Requires one of these permissions: ["advertiser_campaign_edit"]
105
+
106
+ Kwargs:
107
+
108
+ **Prefer**: *string* (header) [optional]
109
+
110
+ **body**: *dict or str* (data) REQUIRED
111
+ | { "campaigns": [ CampaignUpdate ] }
112
+ |
113
+ | CampaignUpdate {
114
+ | "campaignId": "string" [required]
115
+ | "name", "state", "startDate", "endDate", "portfolioId",
116
+ | "budget": {"budget": 10, "budgetType": "DAILY"},
117
+ | "dynamicBidding": {"strategy": "MANUAL", "placementBidding": [...]},
118
+ | "tags": [{"key": "string", "value": "string"}]
119
+ | }
120
+
121
+ Only campaignId is required; the rest is the patch.
122
+
123
+ Returns ApiResponse
124
+ 207 MultiStatus with **success** and **error** lists.
125
+ """
126
+ body = kwargs.pop('body')
127
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
128
+ data=Utils.convert_body(body, False))
129
+
130
+ @sp_endpoint('/ras/v1/campaigns/delete', method='POST',
131
+ headers=['Amazon-Advertising-API-Scope'])
132
+ def delete_campaigns(self, **kwargs) -> ApiResponse:
133
+ r"""
134
+ delete_campaigns(body: (dict, str)) -> ApiResponse
135
+
136
+ Deletes campaigns. This changes the account.
137
+
138
+ Requires one of these permissions: ["advertiser_campaign_edit"]
139
+
140
+ Kwargs:
141
+
142
+ **body**: *dict or str* (data) REQUIRED
143
+ | { "campaignIdFilter": {"include": ["string"]} } [required]
144
+
145
+ include holds up to 1000 campaign ids.
146
+
147
+ Returns ApiResponse
148
+ 207 MultiStatus with **success** and **error** lists.
149
+ """
150
+ body = kwargs.pop('body')
151
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
152
+ data=Utils.convert_body(body, False))
153
+
154
+ # ------------------------------------------------------------------
155
+ # Ad groups
156
+ # ------------------------------------------------------------------
157
+
158
+ @sp_endpoint('/ras/v1/adGroups/list', method='POST',
159
+ headers=['Amazon-Advertising-API-Scope'])
160
+ def list_ad_groups(self, **kwargs) -> ApiResponse:
161
+ r"""
162
+ list_ad_groups(body: (dict, str) = None) -> ApiResponse
163
+
164
+ Lists ad groups of Retail Ad Service. Read only.
165
+
166
+ Requires one of these permissions: ["advertiser_campaign_edit","advertiser_campaign_view"]
167
+
168
+ Kwargs:
169
+
170
+ **body**: *dict or str* (data) [optional]
171
+ | {
172
+ | "adGroupIdFilter": {"include": ["string"]},
173
+ | "campaignIdFilter": {"include": ["string"]},
174
+ | "nameFilter": {"include": ["string"], "queryTermMatchType": "BROAD_MATCH"},
175
+ | "stateFilter": {"include": ["ENABLED"]},
176
+ | "maxResults": 1000,
177
+ | "nextToken": "string"
178
+ | }
179
+
180
+ Returns ApiResponse
181
+
182
+ | **adGroups**: *list* 0..1000, each with adGroupId, campaignId,
183
+ | name, state, defaultBid, retailerId
184
+ | **nextToken**, **totalResults**
185
+ """
186
+ body = kwargs.pop('body', None)
187
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
188
+ **({'data': Utils.convert_body(body, False)} if body is not None else {}))
189
+
190
+ @sp_endpoint('/ras/v1/adGroups', method='POST',
191
+ headers=['Amazon-Advertising-API-Scope'])
192
+ def create_ad_groups(self, **kwargs) -> ApiResponse:
193
+ r"""
194
+ create_ad_groups(body: (dict, str)) -> ApiResponse
195
+
196
+ Creates up to 1000 ad groups. This changes the account.
197
+
198
+ Requires one of these permissions: ["advertiser_campaign_edit"]
199
+
200
+ Kwargs:
201
+
202
+ **Prefer**: *string* (header) [optional]
203
+
204
+ **body**: *dict or str* (data) REQUIRED
205
+ | { "adGroups": [ AdGroupInput ] }
206
+ |
207
+ | AdGroupInput {
208
+ | "campaignId": "string" [required]
209
+ | "name": "string" [required]
210
+ | "retailerId": "string" [required]
211
+ | "defaultBid": 1.0 [required]
212
+ | "state": "ENABLED" [required] ARCHIVED, ENABLED, PAUSED
213
+ | }
214
+
215
+ Returns ApiResponse
216
+ 207 MultiStatus with **success** and **error** lists.
217
+ """
218
+ body = kwargs.pop('body')
219
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
220
+ data=Utils.convert_body(body, False))
221
+
222
+ @sp_endpoint('/ras/v1/adGroups', method='PUT',
223
+ headers=['Amazon-Advertising-API-Scope'])
224
+ def update_ad_groups(self, **kwargs) -> ApiResponse:
225
+ r"""
226
+ update_ad_groups(body: (dict, str)) -> ApiResponse
227
+
228
+ Updates up to 1000 ad groups. This changes the account.
229
+
230
+ Requires one of these permissions: ["advertiser_campaign_edit"]
231
+
232
+ Kwargs:
233
+
234
+ **Prefer**: *string* (header) [optional]
235
+
236
+ **body**: *dict or str* (data) REQUIRED
237
+ | { "adGroups": [ AdGroupUpdate ] }
238
+ |
239
+ | AdGroupUpdate {
240
+ | "adGroupId": "string" [required]
241
+ | "name", "state", "defaultBid"
242
+ | }
243
+
244
+ Returns ApiResponse
245
+ 207 MultiStatus with **success** and **error** lists.
246
+ """
247
+ body = kwargs.pop('body')
248
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
249
+ data=Utils.convert_body(body, False))
250
+
251
+ @sp_endpoint('/ras/v1/adGroups/delete', method='POST',
252
+ headers=['Amazon-Advertising-API-Scope'])
253
+ def delete_ad_groups(self, **kwargs) -> ApiResponse:
254
+ r"""
255
+ delete_ad_groups(body: (dict, str)) -> ApiResponse
256
+
257
+ Deletes ad groups. This changes the account.
258
+
259
+ Requires one of these permissions: ["advertiser_campaign_edit"]
260
+
261
+ Kwargs:
262
+
263
+ **body**: *dict or str* (data) REQUIRED
264
+ | { "adGroupIdFilter": {"include": ["string"]} } [required]
265
+
266
+ Returns ApiResponse
267
+ 207 MultiStatus with **success** and **error** lists.
268
+ """
269
+ body = kwargs.pop('body')
270
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
271
+ data=Utils.convert_body(body, False))
272
+
273
+ # ------------------------------------------------------------------
274
+ # Product ads
275
+ # ------------------------------------------------------------------
276
+
277
+ @sp_endpoint('/ras/v1/productAds/list', method='POST',
278
+ headers=['Amazon-Advertising-API-Scope'])
279
+ def list_product_ads(self, **kwargs) -> ApiResponse:
280
+ r"""
281
+ list_product_ads(body: (dict, str) = None) -> ApiResponse
282
+
283
+ Lists product ads of Retail Ad Service. Read only.
284
+
285
+ Requires one of these permissions: ["advertiser_campaign_edit","advertiser_campaign_view"]
286
+
287
+ Kwargs:
288
+
289
+ **body**: *dict or str* (data) [optional]
290
+ | {
291
+ | "productAdIdFilter": {"include": ["string"]},
292
+ | "adGroupIdFilter": {"include": ["string"]},
293
+ | "campaignIdFilter": {"include": ["string"]},
294
+ | "stateFilter": {"include": ["ENABLED"]},
295
+ | "maxResults": 1000,
296
+ | "nextToken": "string"
297
+ | }
298
+
299
+ Returns ApiResponse
300
+
301
+ | **productAds**: *list* 0..1000, each with productAdId, adGroupId,
302
+ | campaignId, retailerId, retailerOfferId, state
303
+ | **nextToken**, **totalResults**
304
+ """
305
+ body = kwargs.pop('body', None)
306
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
307
+ **({'data': Utils.convert_body(body, False)} if body is not None else {}))
308
+
309
+ @sp_endpoint('/ras/v1/productAds', method='POST',
310
+ headers=['Amazon-Advertising-API-Scope'])
311
+ def create_product_ads(self, **kwargs) -> ApiResponse:
312
+ r"""
313
+ create_product_ads(body: (dict, str)) -> ApiResponse
314
+
315
+ Creates up to 1000 product ads. This changes the account.
316
+
317
+ Requires one of these permissions: ["advertiser_campaign_edit"]
318
+
319
+ Kwargs:
320
+
321
+ **Prefer**: *string* (header) [optional]
322
+
323
+ **body**: *dict or str* (data) REQUIRED
324
+ | { "productAds": [ ProductAdInput ] }
325
+ |
326
+ | ProductAdInput {
327
+ | "campaignId": "string" [required]
328
+ | "adGroupId": "string" [required]
329
+ | "retailerId": "string" [required]
330
+ | "retailerOfferId": "string" [required]
331
+ | "state": "ENABLED" [required]
332
+ | }
333
+
334
+ Returns ApiResponse
335
+ 207 MultiStatus with **success** and **error** lists.
336
+ """
337
+ body = kwargs.pop('body')
338
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
339
+ data=Utils.convert_body(body, False))
340
+
341
+ @sp_endpoint('/ras/v1/productAds', method='PUT',
342
+ headers=['Amazon-Advertising-API-Scope'])
343
+ def update_product_ads(self, **kwargs) -> ApiResponse:
344
+ r"""
345
+ update_product_ads(body: (dict, str)) -> ApiResponse
346
+
347
+ Updates up to 1000 product ads. This changes the account.
348
+
349
+ Requires one of these permissions: ["advertiser_campaign_edit"]
350
+
351
+ Kwargs:
352
+
353
+ **Prefer**: *string* (header) [optional]
354
+
355
+ **body**: *dict or str* (data) REQUIRED
356
+ | { "productAds": [ ProductAdUpdate ] }
357
+ |
358
+ | ProductAdUpdate {
359
+ | "productAdId": "string" [required]
360
+ | "state"
361
+ | }
362
+
363
+ Returns ApiResponse
364
+ 207 MultiStatus with **success** and **error** lists.
365
+ """
366
+ body = kwargs.pop('body')
367
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
368
+ data=Utils.convert_body(body, False))
369
+
370
+ @sp_endpoint('/ras/v1/productAds/delete', method='POST',
371
+ headers=['Amazon-Advertising-API-Scope'])
372
+ def delete_product_ads(self, **kwargs) -> ApiResponse:
373
+ r"""
374
+ delete_product_ads(body: (dict, str)) -> ApiResponse
375
+
376
+ Deletes product ads. This changes the account.
377
+
378
+ Requires one of these permissions: ["advertiser_campaign_edit"]
379
+
380
+ Kwargs:
381
+
382
+ **body**: *dict or str* (data) REQUIRED
383
+ | { "productAdIdFilter": {"include": ["string"]} } [required]
384
+
385
+ Returns ApiResponse
386
+ 207 MultiStatus with **success** and **error** lists.
387
+ """
388
+ body = kwargs.pop('body')
389
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
390
+ data=Utils.convert_body(body, False))
391
+
392
+ # ------------------------------------------------------------------
393
+ # Targets
394
+ # ------------------------------------------------------------------
395
+
396
+ @sp_endpoint('/ras/v1/targets/list', method='POST',
397
+ headers=['Amazon-Advertising-API-Scope'])
398
+ def list_targets(self, **kwargs) -> ApiResponse:
399
+ r"""
400
+ list_targets(body: (dict, str) = None) -> ApiResponse
401
+
402
+ Lists targets of Retail Ad Service. Read only.
403
+
404
+ Requires one of these permissions: ["advertiser_campaign_edit","advertiser_campaign_view"]
405
+
406
+ Kwargs:
407
+
408
+ **body**: *dict or str* (data) [optional]
409
+ | {
410
+ | "targetIdFilter": {"include": ["string"]},
411
+ | "adGroupIdFilter": {"include": ["string"]},
412
+ | "campaignIdFilter": {"include": ["string"]},
413
+ | "keywordFilter": {"include": ["string"], "queryTermMatchType": "BROAD_MATCH"},
414
+ | "productIdFilter": {"include": ["string"]},
415
+ | "negativeFilter": {"include": [true]},
416
+ | "targetLevelFilter": {"include": ["AD_GROUP"]},
417
+ | "targetTypeFilter": ["KEYWORD"],
418
+ | "matchTypeFilter": ["EXACT"],
419
+ | "stateFilter": {"include": ["ENABLED"]},
420
+ | "maxResults": 1000,
421
+ | "nextToken": "string"
422
+ | }
423
+
424
+ targetType: AUTO, KEYWORD, PRODUCT, PRODUCT_CATEGORY.
425
+ targetLevel: AD_GROUP, CAMPAIGN.
426
+
427
+ Returns ApiResponse
428
+
429
+ | **targets**: *list* 0..1000, each with targetId, campaignId,
430
+ | adGroupId, targetType, targetLevel, targetDetails, negative,
431
+ | bid {bid, currencyCode}, state
432
+ | **nextToken**, **totalResults**
433
+ """
434
+ body = kwargs.pop('body', None)
435
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
436
+ **({'data': Utils.convert_body(body, False)} if body is not None else {}))
437
+
438
+ @sp_endpoint('/ras/v1/targets', method='POST',
439
+ headers=['Amazon-Advertising-API-Scope'])
440
+ def create_targets(self, **kwargs) -> ApiResponse:
441
+ r"""
442
+ create_targets(body: (dict, str)) -> ApiResponse
443
+
444
+ Creates up to 1000 targets. This changes the account.
445
+
446
+ Requires one of these permissions: ["advertiser_campaign_edit"]
447
+
448
+ Kwargs:
449
+
450
+ **Prefer**: *string* (header) [optional]
451
+
452
+ **body**: *dict or str* (data) REQUIRED
453
+ | { "targets": [ TargetInput ] }
454
+ |
455
+ | TargetInput {
456
+ | "campaignId": "string" [required]
457
+ | "adGroupId": "string",
458
+ | "negative": false [required]
459
+ | "state": "ENABLED" [required]
460
+ | "targetDetails": { [required]
461
+ | "targetType": "KEYWORD", [required] AUTO, KEYWORD, PRODUCT, PRODUCT_CATEGORY
462
+ | "keywordTarget": {"keyword": "string", "matchType": "BROAD"},
463
+ | "autoTarget": {"matchType": "KEYWORDS_CLOSE_MATCH"},
464
+ | "productTarget": {"matchType": "PRODUCT_EXACT",
465
+ | "productId": "string",
466
+ | "productIdType": "RETAILER_OFFER",
467
+ | "retailerId": "string"},
468
+ | "productCategoryTarget": {"productCategoryRefinement": {...}}
469
+ | },
470
+ | "bid": {"bid": 1.0}
471
+ | }
472
+
473
+ Auto match types: KEYWORDS_CLOSE_MATCH, KEYWORDS_LOOSE_MATCH,
474
+ PRODUCT_COMPLEMENTS, PRODUCT_SUBSTITUTES.
475
+ Keyword match types: BROAD, EXACT, PHRASE.
476
+
477
+ Returns ApiResponse
478
+ 207 MultiStatus with **success** and **error** lists.
479
+ """
480
+ body = kwargs.pop('body')
481
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
482
+ data=Utils.convert_body(body, False))
483
+
484
+ @sp_endpoint('/ras/v1/targets', method='PUT',
485
+ headers=['Amazon-Advertising-API-Scope'])
486
+ def update_targets(self, **kwargs) -> ApiResponse:
487
+ r"""
488
+ update_targets(body: (dict, str)) -> ApiResponse
489
+
490
+ Updates up to 1000 targets. This changes the account.
491
+
492
+ Requires one of these permissions: ["advertiser_campaign_edit"]
493
+
494
+ Kwargs:
495
+
496
+ **Prefer**: *string* (header) [optional]
497
+
498
+ **body**: *dict or str* (data) REQUIRED
499
+ | { "targets": [ TargetUpdate ] }
500
+ |
501
+ | TargetUpdate {
502
+ | "targetId": "string" [required]
503
+ | "state", "bid": {"bid": 1.0}
504
+ | }
505
+
506
+ Returns ApiResponse
507
+ 207 MultiStatus with **success** and **error** lists.
508
+ """
509
+ body = kwargs.pop('body')
510
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
511
+ data=Utils.convert_body(body, False))
512
+
513
+ @sp_endpoint('/ras/v1/targets/delete', method='POST',
514
+ headers=['Amazon-Advertising-API-Scope'])
515
+ def delete_targets(self, **kwargs) -> ApiResponse:
516
+ r"""
517
+ delete_targets(body: (dict, str)) -> ApiResponse
518
+
519
+ Deletes targets. This changes the account.
520
+
521
+ Requires one of these permissions: ["advertiser_campaign_edit"]
522
+
523
+ Kwargs:
524
+
525
+ **body**: *dict or str* (data) REQUIRED
526
+ | { "targetIdFilter": {"include": ["string"]} } [required]
527
+
528
+ Returns ApiResponse
529
+ 207 MultiStatus with **success** and **error** lists.
530
+ """
531
+ body = kwargs.pop('body')
532
+ return self._request(kwargs.pop('path'), params=kwargs, headers=_HEADERS,
533
+ data=Utils.convert_body(body, False))
@@ -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/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.2.5"
1
+ __version__ = "2.2.7"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-amazon-ad-api
3
- Version: 2.2.5
3
+ Version: 2.2.7
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=r1Tn-QXWA9VMrkPdk9c6Clll9uei6qKO7PemQL_uDYI,22
3
- ad_api/api/__init__.py,sha256=s_mvEUiFt7FHqhgOQYQVKe-DfHmY0P5BAGbQ-G48bBU,2161
2
+ ad_api/version.py,sha256=ihs-OTG_m4F3lSAGofZ1X6UqOU41N4HD297yIDBaSZ0,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=dTsWuAZSlcyGKAqvph49IopYdSV6ypgWhEzToVGF8rE,14930
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,7 +26,8 @@ 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_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
29
31
  ad_api/api/recommendations.py,sha256=dV9uB8_hmylObZINvUetahc-tL4DBX0s9XMhYLkYFYE,6324
30
32
  ad_api/api/reports.py,sha256=u9mYkWOYSBVf8N1NyEc7pxUS04xzberGsCffTHKkFTA,8140
31
33
  ad_api/api/stores.py,sha256=BiwqOldK9zEsNjQzcII1DgBxQkDNsGP20aBx5i5Dmg8,2709
@@ -146,8 +148,8 @@ ad_api/base/marketplaces.py,sha256=44lvCcluXNpqTprWQ80e3weSQmQbJoWL-WDSOWVbCyQ,4
146
148
  ad_api/base/utils.py,sha256=_qnCBOvyJTLgaZjJzUWTi38GGLHkQszXELs79133Rb4,5618
147
149
  ad_api/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
148
150
  ad_api/shared/base_client.py,sha256=zOL_LTh-58URWf3ZDlrwmqXXbd6PX66QF5hrr2p83yY,356
149
- python_amazon_ad_api-2.2.5.dist-info/licenses/LICENSE,sha256=h2rpqlmmLy-4l1tN6KpWAFxx1JEMYeEFrMrZUbx_B_o,1105
150
- python_amazon_ad_api-2.2.5.dist-info/METADATA,sha256=yOjYhAE0bZXt6cUIFAwd0Chol2ZiTKhAagkoAz0cPzI,10678
151
- python_amazon_ad_api-2.2.5.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
152
- python_amazon_ad_api-2.2.5.dist-info/top_level.txt,sha256=nN9twUos-8pkP514ZwpvRU9YL9L2XyQyHsMQFfudGTU,7
153
- python_amazon_ad_api-2.2.5.dist-info/RECORD,,
151
+ python_amazon_ad_api-2.2.7.dist-info/licenses/LICENSE,sha256=h2rpqlmmLy-4l1tN6KpWAFxx1JEMYeEFrMrZUbx_B_o,1105
152
+ python_amazon_ad_api-2.2.7.dist-info/METADATA,sha256=5rvQsX7ffs-UMrDiW3oQUbvLQLRPjhNFRSEkPQBdXwo,10678
153
+ python_amazon_ad_api-2.2.7.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
154
+ python_amazon_ad_api-2.2.7.dist-info/top_level.txt,sha256=nN9twUos-8pkP514ZwpvRU9YL9L2XyQyHsMQFfudGTU,7
155
+ python_amazon_ad_api-2.2.7.dist-info/RECORD,,