Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RepeatedComposite delete method #322

Open
e-lepilov opened this issue Jun 7, 2022 · 0 comments
Open

RepeatedComposite delete method #322

e-lepilov opened this issue Jun 7, 2022 · 0 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.

Comments

@e-lepilov
Copy link

e-lepilov commented Jun 7, 2022

Hi there!
As I understend it RepeatedComposite is list-like container. So list methods like append or extend
work fine.
I am looking for a way to delete the contents of the list (clear the object RepeatedComposite)
The ad contains 4 video files , the print function below shows them

ga_service = client.get_service("GoogleAdsService")
    response = ga_service.search(customer_id=customer_id, query=query)
    ad = response.results[0].ad_group_ad.ad
    
    print(f'{ad.app_ad.youtube_videos}') 
   # [asset: "customers/2309565764/assets/23954537753"
    # , asset: "customers/2309565764/assets/23995613823"
    # , asset: "customers/2309565764/assets/23954549468"
    # , asset: "customers/2309565764/assets/23967118006"
    # ]
    print(f'{type(ad.app_ad.youtube_videos)}') -- > <class 'proto.marshal.collections.repeated.RepeatedComposite'>
     

    # Here I try to delete as a python object
    del ad.app_ad.youtube_videos[:]

    ad_service = client.get_service("AdService")
    ad_operation = client.get_type("AdOperation")

    client.copy_from(ad_operation.update, ad)
    client.copy_from(
        ad_operation.update_mask, protobuf_helpers.field_mask(None, ad._pb)
    )
    ad_service.mutate_ads(
        customer_id=customer_id, operations=[ad_operation]
    )

But it has no effect.
Also try this
del ad.app_ad.youtube_videos
I've also tried clearing the object via an assignment operation
ad.app_ad.youtube_videos = []
but also to no effect.

How to correctly delete linked objects ?

p.s. This code works with the append and extend methods

@e-lepilov e-lepilov added priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue. labels Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

1 participant