def _build_task_message(data, client_class_module, client_class,
                        model_api_endpoint, operation_name, success_topic,
                        error_topic, source_topic):
  """Creates a JSON object to be sent to the long running operations system.

  The message contains all the details so the long running operation system
  is able to reconstruct the right API client and poll for the operation status.

  Args:
    data: A JSON object representing the payload of the original message
    client_class_module: A string representing the API module containing the
      client class to poll the GCP long running operation
    client_class: A string representing the API client class name to poll the
      GCP long running operation
    model_api_endpoint: A string representing the API endpoint. Different for
      each region
    operation_name: A string representing the id of the operation to poll
    success_topic: A string representing the topic to where the initial message
      in case of success must be sent to
    error_topic: A string representing the topic to where the initial message in
      case of failure must be sent to
    source_topic: A string representing the topic from where the initial message
      was received

  Returns:
    The incoming msg JSON object containing all the input parameters together.
  """
  client_class_module = 'google.cloud.automl_v1beta1'
  client_class = 'AutoMlClient'
  client_params = {'client_options': {'api_endpoint': model_api_endpoint}}
  return {
      'operation_name': operation_name,
      'client_class_module': client_class_module,
      'client_class': client_class,
      'client_params': client_params,
      'payload': data,
      'error_topic': error_topic,
      'success_topic': success_topic,
      'source_topic': source_topic
  }