amazon-ads-mcp 0.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.
Files changed (82) hide show
  1. amazon_ads_mcp/__init__.py +11 -0
  2. amazon_ads_mcp/auth/__init__.py +33 -0
  3. amazon_ads_mcp/auth/base.py +211 -0
  4. amazon_ads_mcp/auth/hooks.py +172 -0
  5. amazon_ads_mcp/auth/manager.py +791 -0
  6. amazon_ads_mcp/auth/oauth_state_store.py +277 -0
  7. amazon_ads_mcp/auth/providers/__init__.py +14 -0
  8. amazon_ads_mcp/auth/providers/direct.py +393 -0
  9. amazon_ads_mcp/auth/providers/example_auth0.py.example +216 -0
  10. amazon_ads_mcp/auth/providers/openbridge.py +512 -0
  11. amazon_ads_mcp/auth/registry.py +146 -0
  12. amazon_ads_mcp/auth/secure_token_store.py +297 -0
  13. amazon_ads_mcp/auth/token_store.py +723 -0
  14. amazon_ads_mcp/config/__init__.py +5 -0
  15. amazon_ads_mcp/config/sampling.py +111 -0
  16. amazon_ads_mcp/config/settings.py +366 -0
  17. amazon_ads_mcp/exceptions.py +314 -0
  18. amazon_ads_mcp/middleware/__init__.py +11 -0
  19. amazon_ads_mcp/middleware/authentication.py +1474 -0
  20. amazon_ads_mcp/middleware/caching.py +177 -0
  21. amazon_ads_mcp/middleware/oauth.py +175 -0
  22. amazon_ads_mcp/middleware/sampling.py +112 -0
  23. amazon_ads_mcp/models/__init__.py +320 -0
  24. amazon_ads_mcp/models/amc_models.py +837 -0
  25. amazon_ads_mcp/models/api_responses.py +847 -0
  26. amazon_ads_mcp/models/base_models.py +215 -0
  27. amazon_ads_mcp/models/builtin_responses.py +496 -0
  28. amazon_ads_mcp/models/dsp_models.py +556 -0
  29. amazon_ads_mcp/models/stores_brands.py +610 -0
  30. amazon_ads_mcp/server/__init__.py +6 -0
  31. amazon_ads_mcp/server/__main__.py +6 -0
  32. amazon_ads_mcp/server/builtin_prompts.py +269 -0
  33. amazon_ads_mcp/server/builtin_tools.py +962 -0
  34. amazon_ads_mcp/server/file_routes.py +547 -0
  35. amazon_ads_mcp/server/html_templates.py +149 -0
  36. amazon_ads_mcp/server/mcp_server.py +327 -0
  37. amazon_ads_mcp/server/openapi_utils.py +158 -0
  38. amazon_ads_mcp/server/sampling_handler.py +251 -0
  39. amazon_ads_mcp/server/server_builder.py +751 -0
  40. amazon_ads_mcp/server/sidecar_loader.py +178 -0
  41. amazon_ads_mcp/server/transform_executor.py +827 -0
  42. amazon_ads_mcp/tools/__init__.py +22 -0
  43. amazon_ads_mcp/tools/cache_management.py +105 -0
  44. amazon_ads_mcp/tools/download_tools.py +267 -0
  45. amazon_ads_mcp/tools/identity.py +236 -0
  46. amazon_ads_mcp/tools/oauth.py +598 -0
  47. amazon_ads_mcp/tools/profile.py +150 -0
  48. amazon_ads_mcp/tools/profile_listing.py +285 -0
  49. amazon_ads_mcp/tools/region.py +320 -0
  50. amazon_ads_mcp/tools/region_identity.py +175 -0
  51. amazon_ads_mcp/utils/__init__.py +6 -0
  52. amazon_ads_mcp/utils/async_compat.py +215 -0
  53. amazon_ads_mcp/utils/errors.py +452 -0
  54. amazon_ads_mcp/utils/export_content_type_resolver.py +249 -0
  55. amazon_ads_mcp/utils/export_download_handler.py +579 -0
  56. amazon_ads_mcp/utils/header_resolver.py +81 -0
  57. amazon_ads_mcp/utils/http/__init__.py +56 -0
  58. amazon_ads_mcp/utils/http/circuit_breaker.py +127 -0
  59. amazon_ads_mcp/utils/http/client_manager.py +329 -0
  60. amazon_ads_mcp/utils/http/request.py +207 -0
  61. amazon_ads_mcp/utils/http/resilience.py +512 -0
  62. amazon_ads_mcp/utils/http/resilient_client.py +195 -0
  63. amazon_ads_mcp/utils/http/retry.py +76 -0
  64. amazon_ads_mcp/utils/http_client.py +873 -0
  65. amazon_ads_mcp/utils/media/__init__.py +21 -0
  66. amazon_ads_mcp/utils/media/negotiator.py +243 -0
  67. amazon_ads_mcp/utils/media/types.py +199 -0
  68. amazon_ads_mcp/utils/openapi/__init__.py +16 -0
  69. amazon_ads_mcp/utils/openapi/json.py +55 -0
  70. amazon_ads_mcp/utils/openapi/loader.py +263 -0
  71. amazon_ads_mcp/utils/openapi/refs.py +46 -0
  72. amazon_ads_mcp/utils/region_config.py +200 -0
  73. amazon_ads_mcp/utils/response_wrapper.py +171 -0
  74. amazon_ads_mcp/utils/sampling_helpers.py +156 -0
  75. amazon_ads_mcp/utils/sampling_wrapper.py +173 -0
  76. amazon_ads_mcp/utils/security.py +630 -0
  77. amazon_ads_mcp/utils/tool_naming.py +137 -0
  78. amazon_ads_mcp-0.2.7.dist-info/METADATA +664 -0
  79. amazon_ads_mcp-0.2.7.dist-info/RECORD +82 -0
  80. amazon_ads_mcp-0.2.7.dist-info/WHEEL +4 -0
  81. amazon_ads_mcp-0.2.7.dist-info/entry_points.txt +3 -0
  82. amazon_ads_mcp-0.2.7.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,847 @@
1
+ """Pydantic models for Amazon Ads API responses.
2
+
3
+ This module provides comprehensive type definitions for all Amazon Ads API
4
+ responses, ensuring type safety and validation throughout the SDK.
5
+
6
+ The models cover all major Amazon Ads functionality including:
7
+ - Profile and account management
8
+ - Campaign and ad group management
9
+ - Keyword and targeting management
10
+ - Product ad management
11
+ - Reporting and analytics
12
+ - Performance metrics
13
+ - Error handling and batch operations
14
+ """
15
+
16
+ from datetime import datetime
17
+ from decimal import Decimal
18
+ from enum import Enum
19
+ from typing import Any, Dict, List, Optional
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field
22
+
23
+
24
+ # Base Models
25
+ class BaseAPIResponse(BaseModel):
26
+ """Base model for all API responses with common fields.
27
+
28
+ Provides consistent configuration for all API response models
29
+ including extra field handling, alias population, and string
30
+ processing to accommodate API variations.
31
+ """
32
+
33
+ model_config = ConfigDict(
34
+ extra="allow", # Allow extra fields from API
35
+ populate_by_name=True, # Allow field population by alias
36
+ str_strip_whitespace=True, # Strip whitespace from strings
37
+ )
38
+
39
+
40
+ class PaginatedResponse(BaseAPIResponse):
41
+ """Base model for paginated API responses.
42
+
43
+ Provides common pagination fields that are used across
44
+ many Amazon Ads API endpoints.
45
+
46
+ :param nextToken: Token for retrieving the next page of results
47
+ :type nextToken: Optional[str]
48
+ :param totalResults: Total number of results available
49
+ :type totalResults: Optional[int]
50
+ """
51
+
52
+ nextToken: Optional[str] = Field(None, description="Token for next page")
53
+ totalResults: Optional[int] = Field(None, description="Total number of results")
54
+
55
+
56
+ # Enums
57
+ class ProfileType(str, Enum):
58
+ """Amazon Ads profile types.
59
+
60
+ Defines the different types of advertising profiles
61
+ available in the Amazon Ads platform.
62
+ """
63
+
64
+ SELLER = "SELLER"
65
+ VENDOR = "VENDOR"
66
+ AGENCY = "AGENCY"
67
+
68
+
69
+ class MarketplaceId(str, Enum):
70
+ """Amazon marketplace identifiers.
71
+
72
+ Contains the unique identifiers for all Amazon marketplaces
73
+ where advertising is supported.
74
+ """
75
+
76
+ NA = "ATVPDKIKX0DER" # US
77
+ CA = "A2EUQ1WTGCTBG2" # Canada
78
+ MX = "A1AM78C64UM0Y8" # Mexico
79
+ BR = "A2Q3Y263D00KWC" # Brazil
80
+ UK = "A1F83G8C2ARO7P" # UK
81
+ DE = "A1PA6795UKMFR9" # Germany
82
+ FR = "A13V1IB3VIYZZH" # France
83
+ ES = "A1RKKUPIHCS9HS" # Spain
84
+ IT = "APJ6JRA9NG5V4" # Italy
85
+ NL = "A1805IZSGTT6HS" # Netherlands
86
+ SE = "A2NODRKZP88ZB9" # Sweden
87
+ PL = "A1C3SOZRARQ6R3" # Poland
88
+ EG = "ARBP9OOSHTCHU" # Egypt
89
+ TR = "A33AVAJ2PDY3EV" # Turkey
90
+ SA = "A17E79C6D8DWNP" # Saudi Arabia
91
+ AE = "A2VIGQ35RCS4UG" # UAE
92
+ IN = "A21TJRUUN4KGV" # India
93
+ JP = "A1VC38T7YXB528" # Japan
94
+ AU = "A39IBJ37TRP1C6" # Australia
95
+ SG = "A19VAU5U5O7RUS" # Singapore
96
+
97
+
98
+ class CampaignState(str, Enum):
99
+ """Campaign states.
100
+
101
+ Defines the possible states a campaign can be in
102
+ within the Amazon Ads platform.
103
+ """
104
+
105
+ ENABLED = "enabled"
106
+ PAUSED = "paused"
107
+ ARCHIVED = "archived"
108
+
109
+
110
+ class AdGroupState(str, Enum):
111
+ """Ad group states.
112
+
113
+ Defines the possible states an ad group can be in
114
+ within a campaign.
115
+ """
116
+
117
+ ENABLED = "enabled"
118
+ PAUSED = "paused"
119
+ ARCHIVED = "archived"
120
+
121
+
122
+ class TargetingType(str, Enum):
123
+ """Targeting types.
124
+
125
+ Defines the different targeting strategies available
126
+ for Amazon Ads campaigns.
127
+ """
128
+
129
+ KEYWORD = "keyword"
130
+ PRODUCT = "product"
131
+ AUTO = "auto"
132
+ CATEGORY = "category"
133
+ AUDIENCE = "audience"
134
+
135
+
136
+ class MatchType(str, Enum):
137
+ """Keyword match types.
138
+
139
+ Defines how keywords should be matched against
140
+ customer search queries.
141
+ """
142
+
143
+ EXACT = "exact"
144
+ PHRASE = "phrase"
145
+ BROAD = "broad"
146
+
147
+
148
+ class BidOptimization(str, Enum):
149
+ """Bid optimization strategies.
150
+
151
+ Defines the different bid optimization approaches
152
+ available for Amazon Ads campaigns.
153
+ """
154
+
155
+ CLICKS = "clicks"
156
+ CONVERSIONS = "conversions"
157
+ REACH = "reach"
158
+
159
+
160
+ class ReportStatus(str, Enum):
161
+ """Report generation status.
162
+
163
+ Defines the possible states of a report generation
164
+ request in the Amazon Ads platform.
165
+ """
166
+
167
+ IN_PROGRESS = "IN_PROGRESS"
168
+ SUCCESS = "SUCCESS"
169
+ FAILURE = "FAILURE"
170
+
171
+
172
+ # Profile Models
173
+ class Profile(BaseAPIResponse):
174
+ """Amazon Ads profile/account model.
175
+
176
+ Represents an advertising profile with marketplace,
177
+ currency, and account information.
178
+
179
+ :param profileId: Unique identifier for the profile
180
+ :type profileId: str
181
+ :param countryCode: ISO country code for the profile
182
+ :type countryCode: str
183
+ :param currencyCode: ISO currency code for the profile
184
+ :type currencyCode: str
185
+ :param timezone: Timezone for the profile
186
+ :type timezone: str
187
+ :param marketplaceStringId: Marketplace identifier
188
+ :type marketplaceStringId: MarketplaceId
189
+ :param profileType: Type of advertising profile
190
+ :type profileType: ProfileType
191
+ :param accountName: Optional account name
192
+ :type accountName: Optional[str]
193
+ :param accountId: Optional account identifier
194
+ :type accountId: Optional[str]
195
+ :param accountSubType: Optional account sub-type
196
+ :type accountSubType: Optional[str]
197
+ :param accountValidPaymentMethod: Whether account has valid payment method
198
+ :type accountValidPaymentMethod: bool
199
+ """
200
+
201
+ profileId: str = Field(..., description="Unique profile identifier")
202
+ countryCode: str = Field(..., description="Country code")
203
+ currencyCode: str = Field(..., description="Currency code")
204
+ timezone: str = Field(..., description="Profile timezone")
205
+ marketplaceStringId: MarketplaceId = Field(..., description="Marketplace ID")
206
+ profileType: ProfileType = Field(..., description="Profile type")
207
+ accountName: Optional[str] = Field(None, description="Account name")
208
+ accountId: Optional[str] = Field(None, description="Account ID")
209
+ accountSubType: Optional[str] = Field(None, description="Account sub-type")
210
+ accountValidPaymentMethod: bool = Field(True, description="Valid payment method")
211
+
212
+
213
+ class ProfileListResponse(PaginatedResponse):
214
+ """Response for profile list operations.
215
+
216
+ Contains a list of advertising profiles with pagination support.
217
+
218
+ :param profiles: List of advertising profiles
219
+ :type profiles: List[Profile]
220
+ """
221
+
222
+ profiles: List[Profile] = Field(default_factory=list)
223
+
224
+
225
+ # Campaign Models
226
+ class Campaign(BaseAPIResponse):
227
+ """Campaign model.
228
+
229
+ Represents an advertising campaign with targeting,
230
+ budget, and performance settings.
231
+
232
+ :param campaignId: Unique identifier for the campaign
233
+ :type campaignId: str
234
+ :param campaignName: Human-readable name for the campaign
235
+ :type campaignName: str
236
+ :param campaignType: Type of advertising campaign
237
+ :type campaignType: str
238
+ :param state: Current state of the campaign
239
+ :type state: CampaignState
240
+ :param dailyBudget: Daily budget limit for the campaign
241
+ :type dailyBudget: Decimal
242
+ :param startDate: When the campaign starts
243
+ :type startDate: datetime
244
+ :param endDate: When the campaign ends (optional)
245
+ :type endDate: Optional[datetime]
246
+ :param targetingType: Targeting strategy for the campaign
247
+ :type targetingType: TargetingType
248
+ :param bidOptimization: Bid optimization strategy
249
+ :type bidOptimization: Optional[BidOptimization]
250
+ :param portfolioId: Associated portfolio identifier
251
+ :type portfolioId: Optional[str]
252
+ :param createdDate: When the campaign was created
253
+ :type createdDate: datetime
254
+ :param lastUpdatedDate: When the campaign was last updated
255
+ :type lastUpdatedDate: datetime
256
+ :param servingStatus: Current serving status
257
+ :type servingStatus: Optional[str]
258
+ """
259
+
260
+ campaignId: str = Field(..., description="Campaign ID")
261
+ campaignName: str = Field(..., description="Campaign name")
262
+ campaignType: str = Field(..., description="Campaign type")
263
+ state: CampaignState = Field(..., description="Campaign state")
264
+ dailyBudget: Decimal = Field(..., description="Daily budget")
265
+ startDate: datetime = Field(..., description="Start date")
266
+ endDate: Optional[datetime] = Field(None, description="End date")
267
+ targetingType: TargetingType = Field(..., description="Targeting type")
268
+ bidOptimization: Optional[BidOptimization] = Field(
269
+ None, description="Bid optimization"
270
+ )
271
+ portfolioId: Optional[str] = Field(None, description="Portfolio ID")
272
+ createdDate: datetime = Field(..., description="Creation date")
273
+ lastUpdatedDate: datetime = Field(..., description="Last update date")
274
+ servingStatus: Optional[str] = Field(None, description="Serving status")
275
+
276
+
277
+ class CampaignListResponse(PaginatedResponse):
278
+ """Response for campaign list operations.
279
+
280
+ Contains a list of campaigns with pagination support.
281
+
282
+ :param campaigns: List of advertising campaigns
283
+ :type campaigns: List[Campaign]
284
+ """
285
+
286
+ campaigns: List[Campaign] = Field(default_factory=list)
287
+
288
+
289
+ class CampaignCreateRequest(BaseModel):
290
+ """Request to create a campaign.
291
+
292
+ Contains all parameters needed to create a new
293
+ advertising campaign.
294
+
295
+ :param name: Name for the new campaign
296
+ :type name: str
297
+ :param campaignType: Type of campaign to create
298
+ :type campaignType: str
299
+ :param targetingType: Targeting strategy for the campaign
300
+ :type targetingType: TargetingType
301
+ :param state: Initial state of the campaign
302
+ :type state: CampaignState
303
+ :param dailyBudget: Daily budget limit
304
+ :type dailyBudget: Decimal
305
+ :param startDate: When the campaign should start
306
+ :type startDate: datetime
307
+ :param endDate: When the campaign should end (optional)
308
+ :type endDate: Optional[datetime]
309
+ :param portfolioId: Associated portfolio identifier
310
+ :type portfolioId: Optional[str]
311
+ """
312
+
313
+ name: str = Field(..., description="Campaign name")
314
+ campaignType: str = Field(..., description="Campaign type")
315
+ targetingType: TargetingType = Field(..., description="Targeting type")
316
+ state: CampaignState = Field(CampaignState.ENABLED, description="Initial state")
317
+ dailyBudget: Decimal = Field(..., description="Daily budget")
318
+ startDate: datetime = Field(..., description="Start date")
319
+ endDate: Optional[datetime] = Field(None, description="End date")
320
+ portfolioId: Optional[str] = Field(None, description="Portfolio ID")
321
+
322
+
323
+ class CampaignUpdateRequest(BaseModel):
324
+ """Request to update a campaign.
325
+
326
+ Contains parameters that can be modified for an
327
+ existing advertising campaign.
328
+
329
+ :param name: New name for the campaign
330
+ :type name: Optional[str]
331
+ :param state: New state for the campaign
332
+ :type state: Optional[CampaignState]
333
+ :param dailyBudget: New daily budget limit
334
+ :type dailyBudget: Optional[Decimal]
335
+ :param endDate: New end date for the campaign
336
+ :type endDate: Optional[datetime]
337
+ :param portfolioId: New associated portfolio identifier
338
+ :type portfolioId: Optional[str]
339
+ """
340
+
341
+ name: Optional[str] = Field(None, description="Campaign name")
342
+ state: Optional[CampaignState] = Field(None, description="Campaign state")
343
+ dailyBudget: Optional[Decimal] = Field(None, description="Daily budget")
344
+ endDate: Optional[datetime] = Field(None, description="End date")
345
+ portfolioId: Optional[str] = Field(None, description="Portfolio ID")
346
+
347
+
348
+ # Ad Group Models
349
+ class AdGroup(BaseAPIResponse):
350
+ """Ad group model.
351
+
352
+ Represents an ad group within a campaign with
353
+ targeting and bid settings.
354
+
355
+ :param adGroupId: Unique identifier for the ad group
356
+ :type adGroupId: str
357
+ :param adGroupName: Human-readable name for the ad group
358
+ :type adGroupName: str
359
+ :param campaignId: Parent campaign identifier
360
+ :type campaignId: str
361
+ :param state: Current state of the ad group
362
+ :type state: AdGroupState
363
+ :param defaultBid: Default bid amount for the ad group
364
+ :type defaultBid: Decimal
365
+ :param createdDate: When the ad group was created
366
+ :type createdDate: datetime
367
+ :param lastUpdatedDate: When the ad group was last updated
368
+ :type lastUpdatedDate: datetime
369
+ :param servingStatus: Current serving status
370
+ :type servingStatus: Optional[str]
371
+ """
372
+
373
+ adGroupId: str = Field(..., description="Ad group ID")
374
+ adGroupName: str = Field(..., description="Ad group name")
375
+ campaignId: str = Field(..., description="Campaign ID")
376
+ state: AdGroupState = Field(..., description="Ad group state")
377
+ defaultBid: Decimal = Field(..., description="Default bid")
378
+ createdDate: datetime = Field(..., description="Creation date")
379
+ lastUpdatedDate: datetime = Field(..., description="Last update date")
380
+ servingStatus: Optional[str] = Field(None, description="Serving status")
381
+
382
+
383
+ class AdGroupListResponse(PaginatedResponse):
384
+ """Response for ad group list operations.
385
+
386
+ Contains a list of ad groups with pagination support.
387
+
388
+ :param adGroups: List of ad groups
389
+ :type adGroups: List[AdGroup]
390
+ """
391
+
392
+ adGroups: List[AdGroup] = Field(default_factory=list)
393
+
394
+
395
+ # Keyword Models
396
+ class Keyword(BaseAPIResponse):
397
+ """Keyword targeting model.
398
+
399
+ Represents a keyword target within an ad group
400
+ with bid and match type settings.
401
+
402
+ :param keywordId: Unique identifier for the keyword
403
+ :type keywordId: str
404
+ :param keywordText: The actual keyword text
405
+ :type keywordText: str
406
+ :param campaignId: Parent campaign identifier
407
+ :type campaignId: str
408
+ :param adGroupId: Parent ad group identifier
409
+ :type adGroupId: str
410
+ :param state: Current state of the keyword
411
+ :type state: str
412
+ :param matchType: How the keyword should be matched
413
+ :type matchType: MatchType
414
+ :param bid: Bid amount for the keyword
415
+ :type bid: Decimal
416
+ :param createdDate: When the keyword was created
417
+ :type createdDate: datetime
418
+ :param lastUpdatedDate: When the keyword was last updated
419
+ :type lastUpdatedDate: datetime
420
+ :param servingStatus: Current serving status
421
+ :type servingStatus: Optional[str]
422
+ """
423
+
424
+ keywordId: str = Field(..., description="Keyword ID")
425
+ keywordText: str = Field(..., description="Keyword text")
426
+ campaignId: str = Field(..., description="Campaign ID")
427
+ adGroupId: str = Field(..., description="Ad group ID")
428
+ state: str = Field(..., description="Keyword state")
429
+ matchType: MatchType = Field(..., description="Match type")
430
+ bid: Decimal = Field(..., description="Keyword bid")
431
+ createdDate: datetime = Field(..., description="Creation date")
432
+ lastUpdatedDate: datetime = Field(..., description="Last update date")
433
+ servingStatus: Optional[str] = Field(None, description="Serving status")
434
+
435
+
436
+ class KeywordListResponse(PaginatedResponse):
437
+ """Response for keyword list operations.
438
+
439
+ Contains a list of keywords with pagination support.
440
+
441
+ :param keywords: List of keyword targets
442
+ :type keywords: List[Keyword]
443
+ """
444
+
445
+ keywords: List[Keyword] = Field(default_factory=list)
446
+
447
+
448
+ # Product Ad Models
449
+ class ProductAd(BaseAPIResponse):
450
+ """Product ad model.
451
+
452
+ Represents a product advertisement with SKU,
453
+ ASIN, and targeting information.
454
+
455
+ :param adId: Unique identifier for the ad
456
+ :type adId: str
457
+ :param campaignId: Parent campaign identifier
458
+ :type campaignId: str
459
+ :param adGroupId: Parent ad group identifier
460
+ :type adGroupId: str
461
+ :param sku: Product SKU identifier
462
+ :type sku: str
463
+ :param asin: Product ASIN identifier
464
+ :type asin: str
465
+ :param state: Current state of the ad
466
+ :type state: str
467
+ :param createdDate: When the ad was created
468
+ :type createdDate: datetime
469
+ :param lastUpdatedDate: When the ad was last updated
470
+ :type lastUpdatedDate: datetime
471
+ :param servingStatus: Current serving status
472
+ :type servingStatus: Optional[str]
473
+ """
474
+
475
+ adId: str = Field(..., description="Ad ID")
476
+ campaignId: str = Field(..., description="Campaign ID")
477
+ adGroupId: str = Field(..., description="Ad group ID")
478
+ sku: str = Field(..., description="Product SKU")
479
+ asin: str = Field(..., description="Product ASIN")
480
+ state: str = Field(..., description="Ad state")
481
+ createdDate: datetime = Field(..., description="Creation date")
482
+ lastUpdatedDate: datetime = Field(..., description="Last update date")
483
+ servingStatus: Optional[str] = Field(None, description="Serving status")
484
+
485
+
486
+ class ProductAdListResponse(PaginatedResponse):
487
+ """Response for product ad list operations.
488
+
489
+ Contains a list of product ads with pagination support.
490
+
491
+ :param productAds: List of product advertisements
492
+ :type productAds: List[ProductAd]
493
+ """
494
+
495
+ productAds: List[ProductAd] = Field(default_factory=list)
496
+
497
+
498
+ # Reporting Models
499
+ class ReportRequest(BaseModel):
500
+ """Request to generate a report.
501
+
502
+ Contains all parameters needed to request
503
+ a report from the Amazon Ads API.
504
+
505
+ :param reportType: Type of report to generate
506
+ :type reportType: str
507
+ :param reportDate: Date for the report data
508
+ :type reportDate: datetime
509
+ :param metrics: Performance metrics to include
510
+ :type metrics: List[str]
511
+ :param dimensions: Data dimensions to include
512
+ :type dimensions: Optional[List[str]]
513
+ :param filters: Optional filters for the report
514
+ :type filters: Optional[Dict[str, Any]]
515
+ """
516
+
517
+ reportType: str = Field(..., description="Type of report")
518
+ reportDate: datetime = Field(..., description="Report date")
519
+ metrics: List[str] = Field(..., description="Metrics to include")
520
+ dimensions: Optional[List[str]] = Field(None, description="Dimensions to include")
521
+ filters: Optional[Dict[str, Any]] = Field(None, description="Report filters")
522
+
523
+
524
+ class ReportResponse(BaseAPIResponse):
525
+ """Response for report generation.
526
+
527
+ Contains information about a requested report
528
+ including status and download location.
529
+
530
+ :param reportId: Unique identifier for the report
531
+ :type reportId: str
532
+ :param reportType: Type of report requested
533
+ :type reportType: str
534
+ :param status: Current status of report generation
535
+ :type status: ReportStatus
536
+ :param statusDetails: Additional status information
537
+ :type statusDetails: Optional[str]
538
+ :param location: URL for downloading the report
539
+ :type location: Optional[str]
540
+ :param createdDate: When the report was requested
541
+ :type createdDate: datetime
542
+ :param completedDate: When the report was completed
543
+ :type completedDate: Optional[datetime]
544
+ """
545
+
546
+ reportId: str = Field(..., description="Report ID")
547
+ reportType: str = Field(..., description="Report type")
548
+ status: ReportStatus = Field(..., description="Report status")
549
+ statusDetails: Optional[str] = Field(None, description="Status details")
550
+ location: Optional[str] = Field(None, description="Report download URL")
551
+ createdDate: datetime = Field(..., description="Creation date")
552
+ completedDate: Optional[datetime] = Field(None, description="Completion date")
553
+
554
+
555
+ class ReportData(BaseAPIResponse):
556
+ """Generic report data model.
557
+
558
+ Contains the actual data from a generated report
559
+ with metadata about the report structure.
560
+
561
+ :param data: List of report data rows
562
+ :type data: List[Dict[str, Any]]
563
+ :param metadata: Additional report metadata
564
+ :type metadata: Dict[str, Any]
565
+ """
566
+
567
+ data: List[Dict[str, Any]] = Field(..., description="Report data rows")
568
+ metadata: Dict[str, Any] = Field(
569
+ default_factory=dict, description="Report metadata"
570
+ )
571
+
572
+
573
+ # Metrics Models
574
+ class CampaignMetrics(BaseAPIResponse):
575
+ """Campaign performance metrics.
576
+
577
+ Contains comprehensive performance data for
578
+ an advertising campaign.
579
+
580
+ :param campaignId: Campaign identifier
581
+ :type campaignId: str
582
+ :param impressions: Number of ad impressions
583
+ :type impressions: int
584
+ :param clicks: Number of ad clicks
585
+ :type clicks: int
586
+ :param cost: Total advertising cost
587
+ :type cost: Decimal
588
+ :param sales: Total sales attributed to the campaign
589
+ :type sales: Decimal
590
+ :param orders: Number of orders attributed
591
+ :type orders: int
592
+ :param unitsSold: Number of units sold
593
+ :type unitsSold: int
594
+ :param acos: Advertising Cost of Sales percentage
595
+ :type acos: Decimal
596
+ :param roas: Return on Advertising Spend
597
+ :type roas: Decimal
598
+ :param ctr: Click-through rate
599
+ :type ctr: Decimal
600
+ :param cvr: Conversion rate
601
+ :type cvr: Decimal
602
+ :param cpc: Cost per click
603
+ :type cpc: Decimal
604
+ """
605
+
606
+ campaignId: str = Field(..., description="Campaign ID")
607
+ impressions: int = Field(..., description="Number of impressions")
608
+ clicks: int = Field(..., description="Number of clicks")
609
+ cost: Decimal = Field(..., description="Total cost")
610
+ sales: Decimal = Field(..., description="Total sales")
611
+ orders: int = Field(..., description="Number of orders")
612
+ unitsSold: int = Field(..., description="Units sold")
613
+ acos: Decimal = Field(..., description="ACoS percentage")
614
+ roas: Decimal = Field(..., description="ROAS")
615
+ ctr: Decimal = Field(..., description="Click-through rate")
616
+ cvr: Decimal = Field(..., description="Conversion rate")
617
+ cpc: Decimal = Field(..., description="Cost per click")
618
+
619
+
620
+ class AdGroupMetrics(BaseAPIResponse):
621
+ """Ad group performance metrics.
622
+
623
+ Contains comprehensive performance data for
624
+ an advertising group.
625
+
626
+ :param adGroupId: Ad group identifier
627
+ :type adGroupId: str
628
+ :param impressions: Number of ad impressions
629
+ :type impressions: int
630
+ :param clicks: Number of ad clicks
631
+ :type clicks: int
632
+ :param cost: Total advertising cost
633
+ :type cost: Decimal
634
+ :param sales: Total sales attributed to the ad group
635
+ :type sales: Decimal
636
+ :param orders: Number of orders attributed
637
+ :type orders: int
638
+ :param unitsSold: Number of units sold
639
+ :type unitsSold: int
640
+ :param acos: Advertising Cost of Sales percentage
641
+ :type acos: Decimal
642
+ :param roas: Return on Advertising Spend
643
+ :type roas: Decimal
644
+ :param ctr: Click-through rate
645
+ :type ctr: Decimal
646
+ :param cvr: Conversion rate
647
+ :type cvr: Decimal
648
+ :param cpc: Cost per click
649
+ :type cpc: Decimal
650
+ """
651
+
652
+ adGroupId: str = Field(..., description="Ad group ID")
653
+ impressions: int = Field(..., description="Number of impressions")
654
+ clicks: int = Field(..., description="Number of clicks")
655
+ cost: Decimal = Field(..., description="Total cost")
656
+ sales: Decimal = Field(..., description="Total sales")
657
+ orders: int = Field(..., description="Number of orders")
658
+ unitsSold: int = Field(..., description="Units sold")
659
+ acos: Decimal = Field(..., description="ACoS percentage")
660
+ roas: Decimal = Field(..., description="ROAS")
661
+ ctr: Decimal = Field(..., description="Click-through rate")
662
+ cvr: Decimal = Field(..., description="Conversion rate")
663
+ cpc: Decimal = Field(..., description="Cost per click")
664
+
665
+
666
+ # Budget Models
667
+ class BudgetRecommendation(BaseAPIResponse):
668
+ """Budget recommendation model.
669
+
670
+ Contains budget optimization recommendations
671
+ for advertising campaigns.
672
+
673
+ :param campaignId: Campaign identifier
674
+ :type campaignId: str
675
+ :param recommendedDailyBudget: Recommended daily budget amount
676
+ :type recommendedDailyBudget: Decimal
677
+ :param currentDailyBudget: Current daily budget setting
678
+ :type currentDailyBudget: Decimal
679
+ :param estimatedMissedImpressions: Estimated missed impressions
680
+ :type estimatedMissedImpressions: int
681
+ :param estimatedMissedClicks: Estimated missed clicks
682
+ :type estimatedMissedClicks: int
683
+ :param estimatedMissedSales: Estimated missed sales
684
+ :type estimatedMissedSales: Decimal
685
+ """
686
+
687
+ campaignId: str = Field(..., description="Campaign ID")
688
+ recommendedDailyBudget: Decimal = Field(..., description="Recommended daily budget")
689
+ currentDailyBudget: Decimal = Field(..., description="Current daily budget")
690
+ estimatedMissedImpressions: int = Field(
691
+ ..., description="Estimated missed impressions"
692
+ )
693
+ estimatedMissedClicks: int = Field(..., description="Estimated missed clicks")
694
+ estimatedMissedSales: Decimal = Field(..., description="Estimated missed sales")
695
+
696
+
697
+ # Error Response Models
698
+ class APIError(BaseAPIResponse):
699
+ """API error response model.
700
+
701
+ Contains detailed error information from
702
+ Amazon Ads API calls.
703
+
704
+ :param code: Error code identifier
705
+ :type code: str
706
+ :param message: Human-readable error message
707
+ :type message: str
708
+ :param details: Additional error details
709
+ :type details: Optional[Dict[str, Any]]
710
+ """
711
+
712
+ code: str = Field(..., description="Error code")
713
+ message: str = Field(..., description="Error message")
714
+ details: Optional[Dict[str, Any]] = Field(None, description="Error details")
715
+
716
+
717
+ class APIErrorResponse(BaseAPIResponse):
718
+ """API error response wrapper.
719
+
720
+ Contains multiple errors and request tracking
721
+ information for failed API calls.
722
+
723
+ :param errors: List of error details
724
+ :type errors: List[APIError]
725
+ :param requestId: Request identifier for tracking
726
+ :type requestId: Optional[str]
727
+ """
728
+
729
+ errors: List[APIError] = Field(..., description="List of errors")
730
+ requestId: Optional[str] = Field(None, description="Request ID for tracking")
731
+
732
+
733
+ # Batch Operation Models
734
+ class BatchOperationRequest(BaseModel):
735
+ """Request for batch operations.
736
+
737
+ Contains multiple operations to be executed
738
+ in a single API call.
739
+
740
+ :param operations: List of operations to execute
741
+ :type operations: List[Dict[str, Any]]
742
+ """
743
+
744
+ operations: List[Dict[str, Any]] = Field(..., description="Batch operations")
745
+
746
+
747
+ class BatchOperationResponse(BaseAPIResponse):
748
+ """Response for batch operations.
749
+
750
+ Contains results from executing multiple
751
+ operations in a single request.
752
+
753
+ :param successCount: Number of successful operations
754
+ :type successCount: int
755
+ :param failureCount: Number of failed operations
756
+ :type failureCount: int
757
+ :param results: Detailed results for each operation
758
+ :type results: List[Dict[str, Any]]
759
+ """
760
+
761
+ successCount: int = Field(..., description="Number of successful operations")
762
+ failureCount: int = Field(..., description="Number of failed operations")
763
+ results: List[Dict[str, Any]] = Field(..., description="Operation results")
764
+
765
+
766
+ # Generic Response Wrapper
767
+ class APIResponse(BaseAPIResponse):
768
+ """Generic API response wrapper with metadata.
769
+
770
+ Provides a standardized response structure with
771
+ success indicators and metadata for all API calls.
772
+
773
+ :param success: Whether the request was successful
774
+ :type success: bool
775
+ :param data: Response data payload
776
+ :type data: Optional[Any]
777
+ :param error: Error information if request failed
778
+ :type error: Optional[APIError]
779
+ :param metadata: Additional response metadata
780
+ :type metadata: Dict[str, Any]
781
+ :param requestId: Request identifier for tracking
782
+ :type requestId: Optional[str]
783
+ :param timestamp: When the response was generated
784
+ :type timestamp: datetime
785
+ """
786
+
787
+ success: bool = Field(..., description="Whether the request was successful")
788
+ data: Optional[Any] = Field(None, description="Response data")
789
+ error: Optional[APIError] = Field(None, description="Error information")
790
+ metadata: Dict[str, Any] = Field(
791
+ default_factory=dict, description="Response metadata"
792
+ )
793
+ requestId: Optional[str] = Field(None, description="Request ID for tracking")
794
+ timestamp: datetime = Field(
795
+ default_factory=datetime.now, description="Response timestamp"
796
+ )
797
+
798
+
799
+ # Export all models
800
+ __all__ = [
801
+ # Base models
802
+ "BaseAPIResponse",
803
+ "PaginatedResponse",
804
+ # Enums
805
+ "ProfileType",
806
+ "MarketplaceId",
807
+ "CampaignState",
808
+ "AdGroupState",
809
+ "TargetingType",
810
+ "MatchType",
811
+ "BidOptimization",
812
+ "ReportStatus",
813
+ # Profile models
814
+ "Profile",
815
+ "ProfileListResponse",
816
+ # Campaign models
817
+ "Campaign",
818
+ "CampaignListResponse",
819
+ "CampaignCreateRequest",
820
+ "CampaignUpdateRequest",
821
+ # Ad group models
822
+ "AdGroup",
823
+ "AdGroupListResponse",
824
+ # Keyword models
825
+ "Keyword",
826
+ "KeywordListResponse",
827
+ # Product ad models
828
+ "ProductAd",
829
+ "ProductAdListResponse",
830
+ # Reporting models
831
+ "ReportRequest",
832
+ "ReportResponse",
833
+ "ReportData",
834
+ # Metrics models
835
+ "CampaignMetrics",
836
+ "AdGroupMetrics",
837
+ # Budget models
838
+ "BudgetRecommendation",
839
+ # Error models
840
+ "APIError",
841
+ "APIErrorResponse",
842
+ # Batch models
843
+ "BatchOperationRequest",
844
+ "BatchOperationResponse",
845
+ # Generic wrapper
846
+ "APIResponse",
847
+ ]