Skip to content

Account-level sitelinks and per-image field types on draft_image_assets - #123

Open
illia-sapryga wants to merge 1 commit into
kLOsk:mainfrom
illia-sapryga:feat/account-level-sitelinks-images
Open

illia-sapryga wants to merge 1 commit into
kLOsk:mainfrom
illia-sapryga:feat/account-level-sitelinks-images

Conversation

@illia-sapryga

Copy link
Copy Markdown
Contributor

draft_sitelinks and draft_image_assets can only create and link to a campaign. To get an account-wide sitelink you have to attach it to some campaign first and then promote it with link_asset_to_customer. A business logo is stuck the same way, and worse: draft_image_assets always links as AD_IMAGE, so the only way to create one is to attach it to a campaign as an ad image first.

draft_sitelinks now takes scope="account". It follows resolve_scope, so account level is explicit and an empty campaign_id stays an error.

draft_image_assets takes the same scope plus field_types, one entry per image, in the order uploads, paths, URLs. The values and where they're allowed come from the linkage table in Google's assets overview: AD_IMAGE on a campaign (still the default) and BUSINESS_LOGO on a campaign or the account. Account scope has no default, so it has to be named. Anything else is refused at draft time. The preview lists the resolved field_types.

Both now apply through _create_and_link, which takes either one field type or a function of the asset's payload. _apply_campaign_assets had no other callers, so it's gone. Plans stored without a scope or a field type still link to their campaign as AD_IMAGE.

What it does not do:

  • Add AD_IMAGE to CUSTOMER_ASSET_FIELD_TYPES or allow it at account level. Google's table lists AD_IMAGE for AdGroupAsset and CampaignAsset only. We have used it live on campaign links, not as a CustomerAsset, so I left it out.
  • Add the marketing image types. Same table, and you already flagged MARKETING_IMAGE on link_asset_to_customer.
  • Pick a field type from the aspect ratio.
  • Add ad-group scope to these two tools.

draft_image_assets and draft_sitelinks no longer have campaign_id as a required schema parameter, because scope="account" takes none. campaign_id is also now checked as numeric, which it wasn't before. tests/test_image_fetch.py asserted the required parameter and tests/test_uploads.py called _validate_image_assets with the old signature, so both changed by a line.

Tested with the full suite plus tests/test_account_level_assets.py. Plans run through confirm_and_apply(dry_run=True) with real protos and the real validate-only wrapper, and fake services that only record the request. I have not run this code against a live account, so Google's answer to an account-level BUSINESS_LOGO or sitelink link here comes from its documentation only.

draft_sitelinks takes scope="account" and links through CustomerAsset. Account
level is explicit, following resolve_scope; an empty campaign_id stays an error.

draft_image_assets takes field_types, one per image: AD_IMAGE (campaign links,
the default) or BUSINESS_LOGO (campaign or account links, as Google's linkage
table lists them), so a logo can be created without first linking it as an ad
image. scope="account" takes BUSINESS_LOGO only.

Both now apply through _create_and_link; _apply_campaign_assets had no other
callers and is gone.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant