def main(client, parent_id):
  # Initialize appropriate service.
  inventory_service = client.GetService('InventoryService', version='v201508')

  # Create ad unit size.
  ad_unit_size = {
      'size': {
          'width': '300',
          'height': '250'
      },
      'environmentType': 'BROWSER'
  }

  # Create ad unit objects.
  ad_unit = {
      'name': 'Ad_unit_%s' % uuid.uuid4(),
      'parentId': parent_id,
      'description': 'Ad unit description.',
      'targetWindow': 'BLANK',
      'targetPlatform': 'WEB',
      'adUnitSizes': [ad_unit_size]
  }

  # Add ad units.
  ad_units = inventory_service.createAdUnits([ad_unit])

  # Display results.
  for ad_unit in ad_units:
    print ('Ad unit with ID \'%s\' and name \'%s\' was created.'
           % (ad_unit['id'], ad_unit['name']))
dataset/ETHPy150Open googleads/googleads-python-lib/examples/dfp/v201508/inventory_service/create_ad_units.py/main/original