def create_sdfdownloadtask(service, partner_id, advertiser_id, version, file_types, filter_type,
                           filter_ids):
  """Builds and runs the Sdfdownloadtasks.Create request.

  Args:
    service: the displayvideo service object.
    partner_id: long, the ID of the partner context of the request.
    advertiser_id: long, the ID of the advertiser context of the request.
    version: string, the SDF version to generate.
    file_types: list of strings, the SDF file types to generate
    filter_type: string, the type of resource to filter by.
    filter_ids: list of strings, the resource IDs to filter results by.

  Returns:
    The created operation.
  """

  create_sdf_download_task_request = {'version': version}

  if partner_id is not None:
    create_sdf_download_task_request['partnerId'] = partner_id
  else:
    create_sdf_download_task_request['advertiserId'] = advertiser_id

  parent_entity_filter = {'fileType': file_types, 'filterType': filter_type}

  if filter_ids:
    parent_entity_filter['filterIds'] = filter_ids

  create_sdf_download_task_request['parentEntityFilter'] = parent_entity_filter

  # Create the sdfdownloadtask.
  operation = service.sdfdownloadtasks().create(body=create_sdf_download_task_request).execute()

  print(f'Operation {operation["name"]} was created.')

  return operation