2323
2424from google .ads .googleads .client import GoogleAdsClient
2525from google .ads .googleads .errors import GoogleAdsException
26+ from google .ads .googleads .v19 .services .types import (
27+ AssetOperation ,
28+ MutateAssetsResponse ,
29+ )
30+ from google .ads .googleads .v19 .resources .types import Asset
2631from examples .utils .example_helpers import get_image_bytes_from_url
2732
2833
2934# [START upload_image_asset]
30- def main (client , customer_id ) :
35+ def main (client : GoogleAdsClient , customer_id : str ) -> None :
3136 """Main method, to run this code example as a standalone application."""
3237
3338 # Download image from URL
34- url = "https://gaagl.page.link/Eit5"
35- image_content = get_image_bytes_from_url (url )
39+ url : str = "https://gaagl.page.link/Eit5"
40+ image_content : bytes = get_image_bytes_from_url (url )
3641
3742 asset_service = client .get_service ("AssetService" )
38- asset_operation = client .get_type ("AssetOperation" )
39- asset = asset_operation .create
43+ asset_operation : AssetOperation = client .get_type ("AssetOperation" )
44+ asset : Asset = asset_operation .create
4045 asset .type_ = client .enums .AssetTypeEnum .IMAGE
4146 asset .image_asset .data = image_content
4247 asset .image_asset .file_size = len (image_content )
@@ -49,9 +54,10 @@ def main(client, customer_id):
4954 # When there is an existing image asset with the same content but a different
5055 # name, the new name will be dropped silently.
5156 asset .name = "Marketing Image"
52-
53- mutate_asset_response = asset_service .mutate_assets (
54- customer_id = customer_id , operations = [asset_operation ]
57+ mutate_asset_response : MutateAssetsResponse = (
58+ asset_service .mutate_assets (
59+ customer_id = customer_id , operations = [asset_operation ]
60+ )
5561 )
5662 print ("Uploaded file(s):" )
5763 for row in mutate_asset_response .results :
0 commit comments