adloop 0.42.1__tar.gz → 0.43.0__tar.gz

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 (104) hide show
  1. {adloop-0.42.1 → adloop-0.43.0}/PKG-INFO +1 -1
  2. {adloop-0.42.1 → adloop-0.43.0}/pyproject.toml +1 -1
  3. {adloop-0.42.1 → adloop-0.43.0}/pyproject.toml.orig +1 -1
  4. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/assets.py +121 -20
  5. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/write.py +18 -1
  6. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/rules/adloop.md +3 -3
  7. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/server.py +35 -7
  8. {adloop-0.42.1 → adloop-0.43.0}/README.md +0 -0
  9. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/__init__.py +0 -0
  10. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/__main__.py +0 -0
  11. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/_mcp_patches.py +0 -0
  12. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/__init__.py +0 -0
  13. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/ai_max.py +0 -0
  14. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/audiences.py +0 -0
  15. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/brands.py +0 -0
  16. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/campaign_settings.py +0 -0
  17. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/client.py +0 -0
  18. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/conversion_actions.py +0 -0
  19. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/currency.py +0 -0
  20. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/custom_conversion_goals.py +0 -0
  21. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/enums.py +0 -0
  22. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/forecast.py +0 -0
  23. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/gaql.py +0 -0
  24. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/image_fetch.py +0 -0
  25. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/pmax.py +0 -0
  26. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/read.py +0 -0
  27. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/recommendation_subscriptions.py +0 -0
  28. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/recommendations.py +0 -0
  29. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/shopping.py +0 -0
  30. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/snippet_headers.py +0 -0
  31. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ads/validate_only.py +0 -0
  32. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/auth.py +0 -0
  33. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/cli.py +0 -0
  34. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/config.py +0 -0
  35. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/conversion_setup.py +0 -0
  36. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/crossref.py +0 -0
  37. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/diagnostics.py +0 -0
  38. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/__init__.py +0 -0
  39. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/admin.py +0 -0
  40. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/annotations.py +0 -0
  41. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/attribution.py +0 -0
  42. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/audit.py +0 -0
  43. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/client.py +0 -0
  44. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/definitions.py +0 -0
  45. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/funnels.py +0 -0
  46. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/reports.py +0 -0
  47. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/retention.py +0 -0
  48. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/suggest.py +0 -0
  49. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/tracking.py +0 -0
  50. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/ga4/write.py +0 -0
  51. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/gsc/__init__.py +0 -0
  52. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/gsc/client.py +0 -0
  53. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/gsc/reports.py +0 -0
  54. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/gtm/__init__.py +0 -0
  55. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/gtm/client.py +0 -0
  56. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/gtm/entities.py +0 -0
  57. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/gtm/read.py +0 -0
  58. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/gtm/write.py +0 -0
  59. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/merchant/__init__.py +0 -0
  60. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/merchant/client.py +0 -0
  61. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/merchant/read.py +0 -0
  62. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/__init__.py +0 -0
  63. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/auth.py +0 -0
  64. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/client.py +0 -0
  65. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/manage/__init__.py +0 -0
  66. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/manage/_common.py +0 -0
  67. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/manage/ad_groups.py +0 -0
  68. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/manage/ads.py +0 -0
  69. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/manage/campaigns.py +0 -0
  70. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/manage/extensions.py +0 -0
  71. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/manage/negatives.py +0 -0
  72. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/manage/removal.py +0 -0
  73. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/manage/targeting.py +0 -0
  74. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/read.py +0 -0
  75. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/microsoft_ads/write.py +0 -0
  76. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/oauth_redirect.py +0 -0
  77. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/pagespeed.py +0 -0
  78. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/reddit/__init__.py +0 -0
  79. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/reddit/auth.py +0 -0
  80. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/reddit/client.py +0 -0
  81. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/reddit/read.py +0 -0
  82. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/reddit/schedule.py +0 -0
  83. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/reddit/write.py +0 -0
  84. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/rules/__init__.py +0 -0
  85. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/rules/commands/analyze-performance.md +0 -0
  86. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/rules/commands/budget-plan.md +0 -0
  87. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/rules/commands/create-ad.md +0 -0
  88. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/rules/commands/create-campaign.md +0 -0
  89. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/rules/commands/diagnose-tracking.md +0 -0
  90. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/rules/commands/optimize-campaign.md +0 -0
  91. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/rules_install.py +0 -0
  92. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/runtime.py +0 -0
  93. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/safety/__init__.py +0 -0
  94. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/safety/approval.py +0 -0
  95. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/safety/approval_card.html +0 -0
  96. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/safety/audit.py +0 -0
  97. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/safety/guards.py +0 -0
  98. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/safety/outcomes.py +0 -0
  99. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/safety/preview.py +0 -0
  100. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/tracking.py +0 -0
  101. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/upload_card.html +0 -0
  102. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/uploads.py +0 -0
  103. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/views/__init__.py +0 -0
  104. {adloop-0.42.1 → adloop-0.43.0}/src/adloop/views/performance.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: adloop
3
- Version: 0.42.1
3
+ Version: 0.43.0
4
4
  Summary: Google Ads MCP server for Claude, ChatGPT and Cursor, with Reddit Ads, GA4 and Tag Manager. Every change is previewed first.
5
5
  Keywords: mcp,mcp-server,google-ads,google-ads-mcp,reddit-ads,google-analytics,ga4,claude,chatgpt,cursor,marketing
6
6
  Author: Daniel Klose
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "adloop"
3
- version = "0.42.1"
3
+ version = "0.43.0"
4
4
  description = "Google Ads MCP server for Claude, ChatGPT and Cursor, with Reddit Ads, GA4 and Tag Manager. Every change is previewed first."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "adloop"
3
- version = "0.42.1"
3
+ version = "0.43.0"
4
4
  description = "Google Ads MCP server for Claude, ChatGPT and Cursor, with Reddit Ads, GA4 and Tag Manager. Every change is previewed first."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -136,6 +136,48 @@ def _account_scope_warning(kind: str) -> str:
136
136
  )
137
137
 
138
138
 
139
+ _SHOW_DATES = ("start_date", "end_date")
140
+
141
+
142
+ def _show_date_errors(label: str, start_date: str, end_date: str) -> list[str]:
143
+ """Errors for the first and last day an asset shows (YYYY-MM-DD, either may be empty)."""
144
+ errors = [
145
+ f"{label}{field} '{value}' must be a date YYYY-MM-DD"
146
+ for field, value in (("start_date", start_date), ("end_date", end_date))
147
+ if value and not _iso_date(value)
148
+ ]
149
+ if not errors and start_date and end_date and end_date < start_date:
150
+ errors.append(f"{label}end_date {end_date} is before start_date {start_date}")
151
+ return errors
152
+
153
+
154
+ def _past_end_date_warning(label: str, end_date: str) -> list[str]:
155
+ from datetime import UTC, datetime
156
+
157
+ if end_date and _iso_date(end_date) and end_date < datetime.now(UTC).date().isoformat():
158
+ return [f"{label}end_date {end_date} is in the past, so it would never show."]
159
+ return []
160
+
161
+
162
+ def _show_date_edit(
163
+ new: dict, clear_fields: list[str] | None, current: dict
164
+ ) -> tuple[dict, list[str]]:
165
+ """``(changed, errors)`` for start_date / end_date on an in-place edit.
166
+
167
+ A date passed is set, one named in ``clear_fields`` is removed, the rest
168
+ stay. The check for end before start runs on the dates the asset ends up with.
169
+ """
170
+ clear = [_clean(field) for field in clear_fields or []]
171
+ errors = [f"clear_fields takes start_date and/or end_date, got '{f}'" for f in clear if f not in _SHOW_DATES]
172
+ errors += [f"{f} is both set and in clear_fields" for f in _SHOW_DATES if new[f] and f in clear]
173
+ if errors:
174
+ return {}, errors
175
+ changed = {f: new[f] for f in _SHOW_DATES if new[f] and new[f] != current[f]}
176
+ changed.update({f: "" for f in _SHOW_DATES if f in clear and current[f]})
177
+ after = {f: changed.get(f, current[f]) for f in _SHOW_DATES}
178
+ return changed, _show_date_errors("", after["start_date"], after["end_date"])
179
+
180
+
139
181
  def _validate_callout_texts(callouts: list[str]) -> tuple[list[str], list[str]]:
140
182
  errors: list[str] = []
141
183
  validated: list[str] = []
@@ -218,8 +260,14 @@ def draft_callouts(
218
260
  ad_group_id: str = "",
219
261
  scope: str = "",
220
262
  callouts: list[str] | None = None,
263
+ start_date: str = "",
264
+ end_date: str = "",
221
265
  ) -> dict:
222
- """Draft callout assets linked to an ad group, a campaign or the account."""
266
+ """Draft callout assets linked to an ad group, a campaign or the account.
267
+
268
+ ``start_date`` / ``end_date`` (YYYY-MM-DD) are the first and last day every
269
+ callout of this draft shows.
270
+ """
223
271
  from adloop.safety.preview import ChangePlan, store_plan
224
272
 
225
273
  if blocked := _blocked("create_callouts", config):
@@ -227,6 +275,8 @@ def draft_callouts(
227
275
  scope, campaign_id, ad_group_id, errors = resolve_scope(scope, campaign_id, ad_group_id)
228
276
  validated, text_errors = _validate_callout_texts(callouts or [])
229
277
  errors.extend(text_errors)
278
+ dates = {"start_date": _clean(start_date), "end_date": _clean(end_date)}
279
+ errors.extend(_show_date_errors("", **dates))
230
280
  if errors:
231
281
  return {"error": "Validation failed", "details": errors}
232
282
 
@@ -237,12 +287,15 @@ def draft_callouts(
237
287
  entity_id=entity_id,
238
288
  customer_id=customer_id,
239
289
  changes={"scope": scope, "campaign_id": campaign_id, "ad_group_id": ad_group_id,
240
- "callouts": validated},
290
+ "callouts": validated, **{k: v for k, v in dates.items() if v}},
241
291
  )
242
292
  store_plan(plan)
243
293
  preview = plan.to_preview()
294
+ warnings = _past_end_date_warning("", dates["end_date"])
244
295
  if scope == "account":
245
- preview["warnings"] = [_account_scope_warning("callouts")]
296
+ warnings.insert(0, _account_scope_warning("callouts"))
297
+ if warnings:
298
+ preview["warnings"] = warnings
246
299
  return preview
247
300
 
248
301
 
@@ -435,12 +488,18 @@ def link_asset_to_customer(
435
488
  # ---------------------------------------------------------------------------
436
489
 
437
490
  # What each edit reads and pins: plan key -> GAQL field.
438
- _CALLOUT_FIELDS = {"callout_text": "asset.callout_asset.callout_text"}
491
+ _CALLOUT_FIELDS = {
492
+ "callout_text": "asset.callout_asset.callout_text",
493
+ "start_date": "asset.callout_asset.start_date",
494
+ "end_date": "asset.callout_asset.end_date",
495
+ }
439
496
  _SITELINK_FIELDS = {
440
497
  "link_text": "asset.sitelink_asset.link_text",
441
498
  "description1": "asset.sitelink_asset.description1",
442
499
  "description2": "asset.sitelink_asset.description2",
443
500
  "final_url": "asset.final_urls",
501
+ "start_date": "asset.sitelink_asset.start_date",
502
+ "end_date": "asset.sitelink_asset.end_date",
444
503
  }
445
504
  _SNIPPET_FIELDS = {
446
505
  "header": "asset.structured_snippet_asset.header",
@@ -510,25 +569,39 @@ def update_callout(
510
569
  customer_id: str = "",
511
570
  asset_id: str = "",
512
571
  callout_text: str = "",
572
+ start_date: str = "",
573
+ end_date: str = "",
574
+ clear_fields: list[str] | None = None,
513
575
  ) -> dict:
514
- """Draft an in-place edit of a callout asset's text."""
576
+ """Draft an in-place edit of a callout asset; what is not passed stays as it is."""
515
577
  if blocked := _blocked("update_callout", config):
516
578
  return blocked
517
579
  asset_id = _clean(asset_id)
518
580
  errors: list[str] = [] if _is_numeric_id(asset_id) else [f"asset_id must be numeric, got '{asset_id}'"]
519
- validated, text_errors = _validate_callout_texts([callout_text or ""])
520
- errors.extend(text_errors)
581
+ text = _clean(callout_text)
582
+ dates = {"start_date": _clean(start_date), "end_date": _clean(end_date)}
583
+ if text:
584
+ validated, text_errors = _validate_callout_texts([text])
585
+ errors.extend(text_errors)
586
+ elif not any(dates.values()) and not clear_fields:
587
+ errors.append("No changes specified: pass callout_text, start_date, end_date and/or clear_fields")
521
588
  if errors:
522
589
  return {"error": "Validation failed", "details": errors}
523
- text = validated[0]
524
590
 
525
591
  current, error = _asset_for_edit(config, customer_id, asset_id, _CALLOUT_FIELDS, "CALLOUT")
526
592
  if error:
527
593
  return error
528
- if current["callout_text"] == text:
529
- return {"error": f"Callout {asset_id} already reads '{text}'; nothing to change"}
530
- return _edit_plan("update_callout", customer_id, asset_id, {"callout_text": text},
531
- {"callout_text": current["callout_text"]})
594
+ changed, date_errors = _show_date_edit(dates, clear_fields, current)
595
+ if date_errors:
596
+ return {"error": "Validation failed", "details": date_errors}
597
+ if text and text != current["callout_text"]:
598
+ changed = {"callout_text": text, **changed}
599
+ if not changed:
600
+ return {"error": f"Callout {asset_id} already has these values; nothing to change"}
601
+ preview = _edit_plan("update_callout", customer_id, asset_id, changed,
602
+ {key: current[key] for key in changed})
603
+ preview["warnings"] += _past_end_date_warning("", changed.get("end_date", ""))
604
+ return preview
532
605
 
533
606
 
534
607
  def update_sitelink(
@@ -540,8 +613,14 @@ def update_sitelink(
540
613
  final_url: str = "",
541
614
  description1: str = "",
542
615
  description2: str = "",
616
+ start_date: str = "",
617
+ end_date: str = "",
618
+ clear_fields: list[str] | None = None,
543
619
  ) -> dict:
544
- """Draft an in-place edit of a sitelink asset; empty fields stay as they are."""
620
+ """Draft an in-place edit of a sitelink asset; empty fields stay as they are.
621
+
622
+ ``clear_fields`` removes ``start_date`` and/or ``end_date``.
623
+ """
545
624
  from adloop.ads.write import _validate_urls
546
625
 
547
626
  if blocked := _blocked("update_sitelink", config):
@@ -555,8 +634,12 @@ def update_sitelink(
555
634
  for key in ("description1", "description2"):
556
635
  if len(new[key]) > 35:
557
636
  errors.append(f"{key} is {len(new[key])} chars (max 35)")
558
- if not any(new.values()):
559
- errors.append("No changes specified: pass link_text, final_url, description1 and/or description2")
637
+ dates = {"start_date": _clean(start_date), "end_date": _clean(end_date)}
638
+ if not any(new.values()) and not any(dates.values()) and not clear_fields:
639
+ errors.append(
640
+ "No changes specified: pass link_text, final_url, description1, description2, "
641
+ "start_date, end_date and/or clear_fields"
642
+ )
560
643
  if errors:
561
644
  return {"error": "Validation failed", "details": errors}
562
645
 
@@ -564,7 +647,10 @@ def update_sitelink(
564
647
  if error:
565
648
  return error
566
649
  previous = {key: current[key] for key in _SITELINK_FIELDS}
567
- changed = {k: v for k, v in new.items() if v and v != previous[k]}
650
+ date_changes, date_errors = _show_date_edit(dates, clear_fields, previous)
651
+ if date_errors:
652
+ return {"error": "Validation failed", "details": date_errors}
653
+ changed = {**{k: v for k, v in new.items() if v and v != previous[k]}, **date_changes}
568
654
  if not changed:
569
655
  return {"error": f"Sitelink {asset_id} already has these values; nothing to change"}
570
656
  after = {**previous, **changed}
@@ -578,8 +664,10 @@ def update_sitelink(
578
664
  if url_errors.get(changed["final_url"]):
579
665
  return {"error": "URL validation failed: sitelinks must point to working URLs",
580
666
  "details": [f"'{changed['final_url']}' is not reachable: {url_errors[changed['final_url']]}"]}
581
- return _edit_plan("update_sitelink", customer_id, asset_id, changed,
582
- {k: previous[k] for k in changed})
667
+ preview = _edit_plan("update_sitelink", customer_id, asset_id, changed,
668
+ {k: previous[k] for k in changed})
669
+ preview["warnings"] += _past_end_date_warning("", changed.get("end_date", ""))
670
+ return preview
583
671
 
584
672
 
585
673
  def update_structured_snippet(
@@ -679,6 +767,9 @@ def _create_and_link(client, cid: str, assets: list[dict], field_type, populate,
679
767
  def _apply_create_callouts(client, cid: str, changes: dict) -> dict:
680
768
  def populate(asset, payload):
681
769
  asset.callout_asset.callout_text = payload["callout_text"]
770
+ for field in _SHOW_DATES:
771
+ if changes.get(field):
772
+ setattr(asset.callout_asset, field, changes[field])
682
773
 
683
774
  return _create_and_link(client, cid, [{"callout_text": t} for t in changes["callouts"]],
684
775
  client.enums.AssetFieldTypeEnum.CALLOUT, populate, changes)
@@ -765,8 +856,13 @@ def _apply_update_callout(client, cid: str, changes: dict) -> dict:
765
856
  _check_unchanged(client, cid, changes, _CALLOUT_FIELDS)
766
857
 
767
858
  def set_fields(asset):
768
- asset.callout_asset.callout_text = changes["callout_text"]
769
- return ["callout_asset.callout_text"]
859
+ paths = []
860
+ for key in _CALLOUT_FIELDS:
861
+ if key in changes:
862
+ if changes[key]: # a masked field left unset is cleared
863
+ setattr(asset.callout_asset, key, changes[key])
864
+ paths.append(f"callout_asset.{key}")
865
+ return paths
770
866
 
771
867
  return _apply_asset_update(client, cid, changes["asset_id"], set_fields)
772
868
 
@@ -783,6 +879,11 @@ def _apply_update_sitelink(client, cid: str, changes: dict) -> dict:
783
879
  if changes.get("final_url"):
784
880
  asset.final_urls.append(changes["final_url"])
785
881
  paths.append("final_urls")
882
+ for key in _SHOW_DATES:
883
+ if key in changes:
884
+ if changes[key]: # a masked field left unset is cleared
885
+ setattr(asset.sitelink_asset, key, changes[key])
886
+ paths.append(f"sitelink_asset.{key}")
786
887
  return paths
787
888
 
788
889
  return _apply_asset_update(client, cid, changes["asset_id"], set_fields)
@@ -2831,9 +2831,16 @@ def draft_sitelinks(
2831
2831
  - final_url (str, required) — where the sitelink points
2832
2832
  - description1 (str, optional, max 35 chars) — first description line
2833
2833
  - description2 (str, optional, max 35 chars) — second description line
2834
+ - start_date / end_date (str, optional, YYYY-MM-DD) — first and last day it shows
2834
2835
  campaign_id: the campaign to attach sitelinks to
2835
2836
  """
2836
- from adloop.ads.assets import _account_scope_warning, resolve_scope, scope_entity
2837
+ from adloop.ads.assets import (
2838
+ _account_scope_warning,
2839
+ _past_end_date_warning,
2840
+ _show_date_errors,
2841
+ resolve_scope,
2842
+ scope_entity,
2843
+ )
2837
2844
  from adloop.safety.guards import SafetyViolation, check_blocked_operation
2838
2845
  from adloop.safety.preview import ChangePlan, store_plan
2839
2846
 
@@ -2878,11 +2885,18 @@ def draft_sitelinks(
2878
2885
  f"Sitelink {i + 1}: description2 without description1 — Google may ignore it"
2879
2886
  )
2880
2887
 
2888
+ dates = {
2889
+ field: str(sl.get(field) or "").strip() for field in ("start_date", "end_date")
2890
+ }
2891
+ errors.extend(_show_date_errors(f"Sitelink {i + 1}: ", **dates))
2892
+ warnings.extend(_past_end_date_warning(f"Sitelink {i + 1}: ", dates["end_date"]))
2893
+
2881
2894
  validated.append({
2882
2895
  "link_text": link_text,
2883
2896
  "final_url": final_url,
2884
2897
  "description1": desc1,
2885
2898
  "description2": desc2,
2899
+ **{field: value for field, value in dates.items() if value},
2886
2900
  })
2887
2901
 
2888
2902
  if errors:
@@ -6090,6 +6104,9 @@ def _apply_create_sitelinks(client: object, cid: str, changes: dict) -> dict:
6090
6104
  asset.sitelink_asset.description1 = payload["description1"]
6091
6105
  if payload.get("description2"):
6092
6106
  asset.sitelink_asset.description2 = payload["description2"]
6107
+ for field in ("start_date", "end_date"):
6108
+ if payload.get(field):
6109
+ setattr(asset.sitelink_asset, field, payload[field])
6093
6110
 
6094
6111
  return _create_and_link(
6095
6112
  client, cid, changes["sitelinks"], client.enums.AssetFieldTypeEnum.SITELINK, populate, changes
@@ -380,11 +380,11 @@ Conversions that happen offline (a sales call, a lead that turned into a deal) g
380
380
  | `update_campaign` | Modify existing campaign settings — bid strategy, budget, geo targets, geo exclusions, language targets, ad schedule, location options, Search partners, display expansion, URL options, campaign-level broad match | `campaign_id` (REQUIRED), plus any of: `bidding_strategy`, `daily_budget`, `geo_target_ids`, `language_ids`, `location_option`, `negative_location_option`, `search_partners_enabled`, `display_network_enabled`, TARGET_SPEND `max_cpc`, `tracking_url_template`, `final_url_suffix`, `url_custom_parameters`, `keyword_match_type`, `geo_exclude_ids`, `ad_schedule` |
381
381
  | `update_ad_group` | Update ad group name and/or MANUAL_CPC `max_cpc` | `ad_group_id`, optional `ad_group_name`, optional `max_cpc` |
382
382
  | `draft_responsive_search_ad` | Create RSA preview (does NOT publish) | 3-15 headlines (≤30 chars), 2-4 descriptions (≤90 chars), final_url required, path1/path2 (≤15 chars each). Each headline/description may be a plain string (unpinned) or `{"text": "...", "pinned_field": "HEADLINE_1"}` (pinned). Valid pin slots: `HEADLINE_1/2/3`, `DESCRIPTION_1/2`. Several assets may pin to one slot (they rotate there), but every slot must stay fillable: by an asset pinned to it or by a distinct unpinned asset. |
383
- | `draft_callouts` | Create callout assets for an ad group, a campaign or the account (does NOT publish) | `campaign_id` or `ad_group_id` (the scope follows the id), or `scope="account"`; `callouts` list with 1-25 chars each |
383
+ | `draft_callouts` | Create callout assets for an ad group, a campaign or the account (does NOT publish) | `campaign_id` or `ad_group_id` (the scope follows the id), or `scope="account"`; `callouts` list with 1-25 chars each; optional `start_date` / `end_date` (YYYY-MM-DD) for seasonal callouts |
384
384
  | `draft_structured_snippets` | Create structured snippet assets for an ad group, a campaign or the account (does NOT publish) | `campaign_id` or `ad_group_id`, or `scope="account"`; `snippets` list of `{header, values}`: an official header in the language of the values (English `Types`, or Google's translation such as German `Typen`) and 3-10 values |
385
385
  | `draft_business_name_asset` | Create the business name shown with the ads, for a campaign or the account | `business_name` (≤25), `campaign_id` or `scope="account"` |
386
386
  | `link_asset_to_customer` | Link EXISTING assets account-wide (CustomerAsset) | `links`: `{asset_id, field_type}` (CALLOUT, SITELINK, STRUCTURED_SNIPPET, CALL, PRICE, PROMOTION, BUSINESS_NAME, BUSINESS_LOGO, MOBILE_APP, HOTEL_CALLOUT); type is checked |
387
- | `update_callout` / `update_sitelink` / `update_structured_snippet` | Edit an existing asset IN PLACE: it keeps its ID and history and changes everywhere it is linked | `asset_id` plus the new values (sitelink: only the fields passed; snippet: the full `values` list, empty `header` keeps it) |
387
+ | `update_callout` / `update_sitelink` / `update_structured_snippet` | Edit an existing asset IN PLACE: it keeps its ID and history and changes everywhere it is linked | `asset_id` plus the new values (sitelink: only the fields passed; snippet: the full `values` list, empty `header` keeps it). Callouts and sitelinks also take `start_date` / `end_date`, and `clear_fields` to remove one; snippets have no dates |
388
388
  | `draft_call_asset` | Create a call asset (phone number shown with the ads) for an ad group, a campaign or the account | `phone_number`, `country_code` (REQUIRED, ISO alpha-2), `campaign_id` or `ad_group_id` or `scope="account"`; optional `call_conversion_action_id`, `ad_schedule` |
389
389
  | `update_call_asset` | Edit a call asset IN PLACE: number, call conversion action / reporting state, schedule | `asset_id`; `phone_number` needs `country_code`; `ad_schedule` replaces the schedule, `clear_ad_schedule=true` removes it |
390
390
  | `add_ad_schedule` | Add ad schedule windows to a campaign; existing windows stay | `campaign_id`, `schedule` list of {day_of_week, start_hour, end_hour, start_minute/end_minute 0/15/30/45}, whole numbers; no overlaps, at most 6 a day. A campaign's FIRST schedule needs a double confirmation |
@@ -392,7 +392,7 @@ Conversions that happen offline (a sales call, a lead that turned into a deal) g
392
392
  | `update_promotion` | Edit a promotion IN PLACE; fields not passed stay | `asset_id` plus the fields to change; `money_off`/`percent_off` and `promotion_code`/`orders_over_amount` replace each other; `ad_schedule` replaces its schedule; `clear_fields` removes optional ones (incl. `ad_schedule`) |
393
393
  | `draft_price_asset` | Create a price asset (3-8 offerings) for an ad group, a campaign or the account | `offerings` [{header ≤25, description ≤25, price, final_url, unit}], `price_type`, `language_code` (both REQUIRED); `price_qualifier` FROM/UP_TO/AVERAGE optional; account currency unless `currency_code` |
394
394
  | `draft_image_assets` | Create image assets for a campaign from local files, public image URLs or uploads (does NOT publish); a business logo can also go on the account | `campaign_id` or `scope="account"`, `field_types` (one per image: AD_IMAGE, the campaign default, or BUSINESS_LOGO; account level takes BUSINESS_LOGO only, one per account: to replace it, remove the current link with `remove_entity` first; the draft names it), `image_paths` (local PNG/JPEG/GIF files; not on a hosted server), `image_urls` (public http(s) image links, ≤5120 KB; re-checked at apply — if the image changed since the preview, draft again) and/or `upload_ids` (`up_...` from `upload_images` / `list_uploads`) |
395
- | `draft_sitelinks` | Create sitelink extensions for a campaign or the account (does NOT publish) | `campaign_id` or `scope="account"`, `sitelinks` list of {link_text ≤25 chars, final_url, description1 ≤35 chars, description2 ≤35 chars} |
395
+ | `draft_sitelinks` | Create sitelink extensions for a campaign or the account (does NOT publish) | `campaign_id` or `scope="account"`, `sitelinks` list of {link_text ≤25 chars, final_url, description1 ≤35 chars, description2 ≤35 chars, optional start_date / end_date} |
396
396
  | `draft_keywords` | Propose keyword additions (does NOT add) | Each keyword needs `text` and `match_type` (EXACT/PHRASE/BROAD) |
397
397
  | `add_negative_keywords` | Propose negative keywords directly on a campaign (does NOT add) | `campaign_id`, keyword list, `match_type` |
398
398
  | `add_negative_locations` | Propose negative geo exclusions on a campaign (does NOT add) — exclude cities/regions while keeping broader positive targets | `campaign_id`, `geo_target_ids` (numeric geo target constant IDs) |
@@ -5010,6 +5010,8 @@ def draft_callouts(
5010
5010
  ad_group_id: str = "",
5011
5011
  scope: str = "",
5012
5012
  customer_id: str = "",
5013
+ start_date: str = "",
5014
+ end_date: str = "",
5013
5015
  ) -> dict:
5014
5016
  """Draft callout assets for an ad group, a campaign or the account — returns a PREVIEW.
5015
5017
 
@@ -5028,6 +5030,9 @@ def draft_callouts(
5028
5030
  scope: Empty (follows the id), "campaign", "ad_group" or "account".
5029
5031
  customer_id: Google Ads customer ID (digits, dashes optional). Defaults to
5030
5032
  the configured account.
5033
+ start_date: First day the callouts show, YYYY-MM-DD. Empty: from now.
5034
+ end_date: Last day the callouts show, YYYY-MM-DD, so seasonal callouts
5035
+ switch off by themselves. Empty: no end.
5031
5036
  """
5032
5037
  from adloop.ads.assets import draft_callouts as _impl
5033
5038
 
@@ -5038,6 +5043,8 @@ def draft_callouts(
5038
5043
  ad_group_id=ad_group_id,
5039
5044
  scope=scope,
5040
5045
  callouts=callouts,
5046
+ start_date=start_date,
5047
+ end_date=end_date,
5041
5048
  )
5042
5049
 
5043
5050
 
@@ -5521,20 +5528,27 @@ def link_asset_to_customer(
5521
5528
  @_safe
5522
5529
  def update_callout(
5523
5530
  asset_id: str,
5524
- callout_text: str,
5531
+ callout_text: str = "",
5525
5532
  customer_id: str = "",
5533
+ start_date: str = "",
5534
+ end_date: str = "",
5535
+ clear_fields: _StrList = [], # noqa: B006
5526
5536
  ) -> dict:
5527
- """Draft changing a callout asset's text in place — returns a PREVIEW.
5537
+ """Draft changing a callout asset in place — returns a PREVIEW.
5528
5538
 
5529
- The asset keeps its ID and performance history, and the new text shows
5530
- everywhere it is linked. The preview pins the current text; if someone
5531
- edits the asset in Google Ads before the apply, nothing is sent.
5539
+ Only what is passed changes. The asset keeps its ID and performance
5540
+ history, and the change shows everywhere it is linked. The preview pins
5541
+ the current values; if someone edits the asset in Google Ads before the
5542
+ apply, nothing is sent.
5532
5543
 
5533
5544
  Args:
5534
5545
  asset_id: Numeric ID of the callout asset.
5535
- callout_text: The new text, at most 25 characters.
5546
+ callout_text: The new text, at most 25 characters. Empty keeps it.
5536
5547
  customer_id: Google Ads customer ID (digits, dashes optional). Defaults to
5537
5548
  the configured account.
5549
+ start_date: First day the callout shows, YYYY-MM-DD. Empty keeps it.
5550
+ end_date: Last day the callout shows, YYYY-MM-DD. Empty keeps it.
5551
+ clear_fields: "start_date" and/or "end_date" to remove that date.
5538
5552
  """
5539
5553
  from adloop.ads.assets import update_callout as _impl
5540
5554
 
@@ -5543,6 +5557,9 @@ def update_callout(
5543
5557
  customer_id=customer_id or current_config().ads.customer_id,
5544
5558
  asset_id=asset_id,
5545
5559
  callout_text=callout_text,
5560
+ start_date=start_date,
5561
+ end_date=end_date,
5562
+ clear_fields=clear_fields,
5546
5563
  )
5547
5564
 
5548
5565
 
@@ -5555,6 +5572,9 @@ def update_sitelink(
5555
5572
  description1: str = "",
5556
5573
  description2: str = "",
5557
5574
  customer_id: str = "",
5575
+ start_date: str = "",
5576
+ end_date: str = "",
5577
+ clear_fields: _StrList = [], # noqa: B006
5558
5578
  ) -> dict:
5559
5579
  """Draft changing a sitelink asset in place — returns a PREVIEW.
5560
5580
 
@@ -5572,6 +5592,9 @@ def update_sitelink(
5572
5592
  Google needs both description lines or neither.
5573
5593
  customer_id: Google Ads customer ID (digits, dashes optional). Defaults to
5574
5594
  the configured account.
5595
+ start_date: First day the sitelink shows, YYYY-MM-DD. Empty keeps it.
5596
+ end_date: Last day the sitelink shows, YYYY-MM-DD. Empty keeps it.
5597
+ clear_fields: "start_date" and/or "end_date" to remove that date.
5575
5598
  """
5576
5599
  from adloop.ads.assets import update_sitelink as _impl
5577
5600
 
@@ -5583,6 +5606,9 @@ def update_sitelink(
5583
5606
  final_url=final_url,
5584
5607
  description1=description1,
5585
5608
  description2=description2,
5609
+ start_date=start_date,
5610
+ end_date=end_date,
5611
+ clear_fields=clear_fields,
5586
5612
  )
5587
5613
 
5588
5614
 
@@ -5808,7 +5834,9 @@ def draft_sitelinks(
5808
5834
  required, max 25 chars) — the clickable text shown; final_url (str,
5809
5835
  required) — destination URL for this sitelink; description1 (str,
5810
5836
  optional, max 35 chars) — first description line; description2
5811
- (str, optional, max 35 chars) — second description line.
5837
+ (str, optional, max 35 chars) — second description line;
5838
+ start_date / end_date (str, optional, YYYY-MM-DD) — first and last
5839
+ day the sitelink shows, so seasonal links switch off by themselves.
5812
5840
  campaign_id: Numeric ID of the campaign to attach sitelinks to. Leave
5813
5841
  empty with scope="account".
5814
5842
  customer_id: Google Ads customer ID (digits, dashes optional). Defaults to
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes