Uploads the image from the specified url.

  Args:
    client: An AdWordsClient instance.
    url: The image URL.

  Returns:
    The ID of the uploaded image.

def UploadImageAsset(client, url):
  """Uploads the image from the specified url.

  Args:
    client: An AdWordsClient instance.
    url: The image URL.

  Returns:
    The ID of the uploaded image.
  """
  # Initialize appropriate service.
  asset_service = client.GetService('AssetService', version='v201809')

  # Download the image.
  image_request = requests.get(url)

  # Create the image asset.
  image_asset = {
      'xsi_type': 'ImageAsset',
      'imageData': image_request.content,
      # This field is optional, and if provided should be unique.
      # 'assetName': 'Image asset ' + str(uuid.uuid4()),
  }

  # Create the operation.
  operation = {
      'operator': 'ADD',
      'operand': image_asset
  }

  # Create the asset and return the ID.
  result = asset_service.mutate([operation])

  return result['value'][0]['assetId']