adloop 0.42.1__tar.gz → 0.44.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.
- {adloop-0.42.1 → adloop-0.44.0}/PKG-INFO +1 -1
- {adloop-0.42.1 → adloop-0.44.0}/pyproject.toml +1 -1
- {adloop-0.42.1 → adloop-0.44.0}/pyproject.toml.orig +1 -1
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/assets.py +121 -20
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/audiences.py +3 -2
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/write.py +18 -1
- adloop-0.44.0/src/adloop/ga4/audiences.py +456 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/write.py +5 -2
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/rules/adloop.md +7 -4
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/server.py +131 -8
- {adloop-0.42.1 → adloop-0.44.0}/README.md +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/__main__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/_mcp_patches.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/ai_max.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/brands.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/campaign_settings.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/client.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/conversion_actions.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/currency.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/custom_conversion_goals.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/enums.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/forecast.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/gaql.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/image_fetch.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/pmax.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/read.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/recommendation_subscriptions.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/recommendations.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/shopping.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/snippet_headers.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ads/validate_only.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/auth.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/cli.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/config.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/conversion_setup.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/crossref.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/diagnostics.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/admin.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/annotations.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/attribution.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/audit.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/client.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/definitions.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/funnels.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/reports.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/retention.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/suggest.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/ga4/tracking.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/gsc/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/gsc/client.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/gsc/reports.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/gtm/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/gtm/client.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/gtm/entities.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/gtm/read.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/gtm/write.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/merchant/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/merchant/client.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/merchant/read.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/auth.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/client.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/manage/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/manage/_common.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/manage/ad_groups.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/manage/ads.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/manage/campaigns.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/manage/extensions.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/manage/negatives.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/manage/removal.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/manage/targeting.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/read.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/microsoft_ads/write.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/oauth_redirect.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/pagespeed.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/reddit/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/reddit/auth.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/reddit/client.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/reddit/read.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/reddit/schedule.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/reddit/write.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/rules/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/rules/commands/analyze-performance.md +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/rules/commands/budget-plan.md +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/rules/commands/create-ad.md +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/rules/commands/create-campaign.md +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/rules/commands/diagnose-tracking.md +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/rules/commands/optimize-campaign.md +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/rules_install.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/runtime.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/safety/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/safety/approval.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/safety/approval_card.html +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/safety/audit.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/safety/guards.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/safety/outcomes.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/safety/preview.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/tracking.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/upload_card.html +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/uploads.py +0 -0
- {adloop-0.42.1 → adloop-0.44.0}/src/adloop/views/__init__.py +0 -0
- {adloop-0.42.1 → adloop-0.44.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.
|
|
3
|
+
Version: 0.44.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
|
|
@@ -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
|
-
|
|
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 = {
|
|
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
|
|
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
|
-
|
|
520
|
-
|
|
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
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
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
|
-
|
|
559
|
-
|
|
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
|
-
|
|
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
|
-
|
|
582
|
-
|
|
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
|
-
|
|
769
|
-
|
|
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)
|
|
@@ -51,8 +51,9 @@ _KIND_LABELS = {
|
|
|
51
51
|
"custom_audience": "custom segments",
|
|
52
52
|
"combined_audience": "combined segments",
|
|
53
53
|
}
|
|
54
|
-
#
|
|
55
|
-
|
|
54
|
+
# Google serves a remarketing list from 100 active users in the last 30 days,
|
|
55
|
+
# on Search as on Display and YouTube.
|
|
56
|
+
_SEARCH_MIN_SIZE = 100
|
|
56
57
|
_MAX_PER_DRAFT = 50
|
|
57
58
|
|
|
58
59
|
|
|
@@ -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
|
|
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
|