Insert a task.

@param \BobFridley\GoogleTasks\Tasks|Google_Service_Tasks $task

@link https://developers.google.com/google-apps/tasks/v1/reference/tasks/insert

@return \Google_Service_Tasks
177933
public function insertTask($task): Google_Service_Tasks
    {
        if ($task instanceof Tasks) {
            $task = $task->googleTasks;
        }

        return $this->service->tasks->insert($this->tasklist, $task);
    }
921322
public function serialize(Task $task)
    {
        $assignedUser = $this->userManager->find($task->getAssignedUserId());
        $createUser = $this->userManager->find($task->getCreateUserId());

        $type = $this->types->get($task->getType());

        $transitions = [];
        foreach ($task->getTransitions() as $transition) {
            $transitionUser = $this->userManager->find($transition->getCreateUserId());
            $createdAt = $transition->getCreatedAt()->format('Y-m-d H:i:s');
            $transitions[$createdAt.'_'.$transition->getId()] = [
                'id' => $transition->getId(),
                'name' => $transition->getName(),
                'new_state' => $transition->getNewState(),
                'old_state' => $transition->getOldState(),
                'created_at' => $createdAt,
                'create_user' => $transitionUser->getDisplayName(),
            ];
        }
        ksort($transitions);
        $transitions = array_values($transitions);

        $comments = [];
        foreach ($task->getComments() as $comment) {
            $commentUser = $this->userManager->find($comment->getCreateUserId());
            $createdAt = $comment->getCreatedAt()->format('Y-m-d H:i:s');
            $comments[$createdAt.'_'.$comment->getId()] = [
                'id' => $comment->getId(),
                'current_state' => $comment->getCurrentState(),
                'comment' => $comment->getComment(),
                'created_at' => $createdAt,
                'create_user' => $commentUser->getDisplayName(),
            ];
        }
        ksort($comments);
        $comments = array_values($comments);

        $taskData = [
            'id' => $task->getId(),
            'type' => $task->getType(),
            'generic' => $task->getType() === 'generic',
            'name' => $type->getName(),
            'summary' => $task->getSummary(),
            'description' => $task->getDescription(),
            'component' => $type->getComponent(),
            'link' => $type->getLink($task),
            'assigned_user_id' => $task->getAssignedUserId(),
            'assigned_user' => $assignedUser->getDisplayName(),
            'status' => $task->getFiniteState(),
            'create_user' => $createUser->getDisplayName(),
            'create_user_id' => $task->getCreateUserId(),
            'created_at' => $task->getCreatedAt()->format('Y-m-d H:i:s'),
            'transitions' => $transitions,
            'comments' => $comments,
            'states' => $this->taskManager->getTransitions($task),
        ];

        return $taskData;
    }
1166101
public function dispatch(TaskContract $task, array $params = [], bool $async = true, float $timeout = 1)
    {
        $data = ['object' => $task, 'params' => $params];

        return $async ? $this->server->task($data, -1, function (Server $server, int $taskId, $data) use ($task) {
            $task->finish($data);
        }) : $this->server->taskwait($data, $timeout);
    }
1250625
public function create($task)
    {
        $attributes = $task instanceof OrmTask ? $task->toArray() : $task;
        $attributes['id'] = static::nextId();
        $task = new OrmTask($attributes, true);
        $this->tasks[$attributes['id']] = $task;
        return $task;
    }
119268
public static function action($task)
    {
        //====================================================================//
        // Stack Trace
        Splash::log()->trace();
        Splash::log()->deb("Admin => ".$task->name." (".$task->desc.")");

        //====================================================================//
        // Initial Response
        $response = self::getEmptyResponse($task);

        switch ($task->name) {
            //====================================================================//
            //  READING OF SERVER OBJECT LIST
            case SPL_F_GET_OBJECTS:
                $response->data = Splash::objects();
                if (false != $response->data) {
                    $response->result = true;
                }

                break;
            //====================================================================//
            //  READING OF SERVER WIDGETS LIST
            case SPL_F_GET_WIDGETS:
                $response->data = Splash::widgets();
                if (false != $response->data) {
                    $response->result = true;
                }

                break;
            //====================================================================//
            //  READING OF SERVER SELFTEST RESULTS
            case SPL_F_GET_SELFTEST:
                $response->result = Splash::selfTest();
                $response->data = $response->result;

                break;
            //====================================================================//
            //  READING OF SERVER INFORMATIONS
            case SPL_F_GET_INFOS:
                $response->data = Splash::informations();
                if (false != $response->data) {
                    $response->result = true;
                }

                break;
            default:
                Splash::log()->err("Admin - Requested task not found => ".$task->name);

                break;
        }

        return $response;
    }
473297
public function add(AbstractTask $task)
    {
        $task->setRuntime($this->runtime);
        $this->registeredTasks[$task->getName()] = $task;
    }
14250
public function install($selfedit = 'false', $task = null) {
		$this->selfedit = $selfedit;
		$this->installService = new ComposerInstaller($selfedit == 'true');
		
		if ($task !== null) {
			$taskArray = unserialize($task);
		} else {
			$taskArray = null;
		}
		
		if ($taskArray == null) {
			$this->installService->installAll();
		} else {
			$this->installService->install($taskArray);
		}
		// The call to install or installAll redirects to printInstallationScreen.
	}
237422
public static function runTask($task)
    {
        $run = $task->createTaskRun();
        $run->setTaskId($task->getTaskId());
        $run->setTs(date('Y-m-d H:i:s'));
        $run->setStatus(TaskRunInterface::RUN_STATUS_STARTED);
        $run->saveTaskRun();
        $run_final_status = TaskRunInterface::RUN_STATUS_COMPLETED;

        ob_start();
        $time_begin = microtime(true);

        $result = self::parseAndRunCommand($task->getCommand());
        if (!$result) {
            $run_final_status = TaskRunInterface::RUN_STATUS_ERROR;
        }

        $output = ob_get_clean();
        $run->setOutput($output);

        $time_end = microtime(true);
        $time = round(($time_end - $time_begin), 2);
        $run->setExecutionTime($time);

        $run->setStatus($run_final_status);
        $run->saveTaskRun();
        return $output;
    }
834720
public function buildCommand($task, $slug = null)
    {
        // Build the task instance
        try {
            $instance = $this->modulable->buildTask($task);
        } catch (TaskCompositionException $exception) {
            $instance = null;
        }

        // Get the command name
        $name = $instance ? $instance->getName() : null;
        $command = $this->modulable->findQualifiedName($name, 'commands');

        // If no command found, use BaseTaskCommand or task name
        if ($command === BaseTaskCommand::class) {
            $name = is_string($task) ? $task : $name;
            $command = $this->modulable->findQualifiedName($name, 'commands');
        }

        /** @var AbstractCommand $command */
        $command = new $command($instance, $slug);
        $command->setContainer($this->container);

        return $command;
    }
1082116
async def insert(self, task: Task) -> None:
        ''''''

        if not isinstance(task, Task):
            task = task()

        if task.name not in self.all_tasks:
            task.tasky = self
            self.all_tasks[task.name] = task

            await task.init()

        elif task != self.all_tasks[task.name]:
            raise Exception('Duplicate task %s' % task.name)

        if task.enabled:
            task.task = asyncio.ensure_future(self.start_task(task))
            self.running_tasks.add(task)
        else:
            task.task = None

        return task
1276265
public static function create(Task $task, $name, $weight = 1, $backup = false, \Closure $work = null)
    {
        return new self($task, $name, $weight, $backup, $work);
    }
1358441
public function insert(Tasks_TaskList $postBody, $optParams = array())
  {
    $params = array('postBody' => $postBody);
    $params = array_merge($params, $optParams);
    return $this->call('insert', array($params), "Tasks_TaskList");
  }
1349868
protected function add($task) {
		if (is_string($task)) {
			$task = new $task();
		}

		$class = get_class($task);
		if (!$task instanceof TaskInterface) {
			throw new InvalidArgumentException(
				"Cannot use '$class' as task, it is not implementing " . TaskInterface::class . '.'
			);
		}

		$this->tasks[$class] = $task;

		return $this;
	}
456039
public function execute(\Stackable $task) {
        if (!$this->isStarted) {
            $this->start();
        }

        if ($this->maxTaskQueueSize < 0 || $this->maxTaskQueueSize > $this->outstandingTaskCount) {
            return $this->acceptNewTask($task);
        } else {
            return new Failure(new TooBusyException(
                sprintf('Cannot execute task of type %s; too busy', get_class($task))
            ));
        }
    }
127064
public function add($service, $params = array()) {
        if (empty($service) || count(explode('.', $service)) < 2) {
            return FALSE;
        }
        if (!is_array($params)) {
            return FALSE;
        }

        $rs = $this->mq->add($service, $params);

        if (!$rs) {
            \PhalApi\DI()->logger->debug('task add a new mq', 
                array('service' => $service, 'params' => $params));

            return FALSE;
        }

        return TRUE;
    }
147727
public function update(Task $task): Task
    {
        $id = $task->getId();

        $task->setId(null);

        $response = $this->client->put($this->prepareUrlForKey('update-task', ['id' => $id]), [], $task->jsonSerialize());
        $responseData = $response->getDecodedBody();

        return new Task($responseData);
    }
1128988
public static function record_from_adhoc_task($task) {
        $record = new \stdClass();
        $record->classname = self::get_canonical_class_name($task);
        $record->id = $task->get_id();
        $record->component = $task->get_component();
        $record->blocking = $task->is_blocking();
        $record->nextruntime = $task->get_next_run_time();
        $record->faildelay = $task->get_fail_delay();
        $record->customdata = $task->get_custom_data_as_string();
        $record->userid = $task->get_userid();

        return $record;
    }