// setTask is called from NewBuilder to populate task related environment
// variables.
189751
func (b *Builder) setTask(task *structs.Task) *Builder {
	b.taskName = task.Name
	b.envvars = make(map[string]string, len(task.Env))
	for k, v := range task.Env {
		b.envvars[k] = v
	}

	// COMPAT(0.11): Remove in 0.11
	if task.Resources == nil {
		b.memLimit = 0
		b.cpuLimit = 0
	} else {
		b.memLimit = int64(task.Resources.MemoryMB)
		b.cpuLimit = int64(task.Resources.CPU)
	}
	return b
}
717251
func (c oauthClient) UpdateTask(task wl.Task) (wl.Task, error) {
	err := c.validateRecurrence(task.RecurrenceType, task.RecurrenceCount)
	if err != nil {
		return wl.Task{}, err
	}

	origTask, err := c.Task(task.ID)
	if err != nil {
		return wl.Task{}, err
	}

	tuc := TaskUpdateConfig{
		Title:     task.Title,
		Revision:  task.Revision,
		Completed: task.Completed,
		Starred:   task.Starred,
		ListID:    task.ListID,

		Remove: []string{},
	}

	if origTask.AssigneeID == task.AssigneeID {
		tuc.AssigneeID = origTask.AssigneeID
	} else {
		if task.AssigneeID == 0 {
			tuc.Remove = append(tuc.Remove, "assignee_id")
		} else {
			tuc.AssigneeID = task.AssigneeID
		}
	}

	if origTask.DueDate == task.DueDate {
		tuc.DueDate = dueDateToString(origTask.DueDate)
	} else {
		if task.DueDate.IsZero() {
			tuc.Remove = append(tuc.Remove, "due_date")
		} else {
			tuc.DueDate = dueDateToString(task.DueDate)
		}
	}

	if origTask.RecurrenceCount == task.RecurrenceCount &&
		origTask.RecurrenceType == task.RecurrenceType {
		tuc.RecurrenceCount = origTask.RecurrenceCount
		tuc.RecurrenceType = origTask.RecurrenceType
	} else {
		if task.RecurrenceCount == 0 {
			tuc.Remove = append(tuc.Remove, "recurrence_type")
			tuc.Remove = append(tuc.Remove, "recurrence_count")
		} else {
			tuc.RecurrenceCount = task.RecurrenceCount
			tuc.RecurrenceType = task.RecurrenceType
		}
	}

	body, err := json.Marshal(tuc)
	if err != nil {
		return wl.Task{}, err
	}

	url := fmt.Sprintf(
		"%s/tasks/%d",
		c.apiURL,
		task.ID,
	)

	req, err := c.newPatchRequest(url, body)
	if err != nil {
		return wl.Task{}, err
	}

	resp, err := c.do(req)
	if err != nil {
		return wl.Task{}, err
	}

	if resp.StatusCode != http.StatusOK {
		return wl.Task{}, fmt.Errorf("Unexpected response code %d - expected %d", resp.StatusCode, http.StatusOK)
	}

	transport := transportTask{}
	err = json.NewDecoder(resp.Body).Decode(&transport)
	if err != nil {
		return wl.Task{}, err
	}
	return taskFromTransport(transport)
}
480495
func (s *ScheduleActivityTaskDecisionAttributes) SetTaskList(v *TaskList) *ScheduleActivityTaskDecisionAttributes {
	s.TaskList = v
	return s
}
851200
func (s *ECSTaskSet) SetTaskSetLabel(v string) *ECSTaskSet {
	s.TaskSetLabel = &v
	return s
}
259243
func (s *PollForDecisionTaskInput) SetTaskList(v *TaskList) *PollForDecisionTaskInput {
	s.TaskList = v
	return s
}
398720
func (s *GetSpeechSynthesisTaskOutput) SetSynthesisTask(v *SynthesisTask) *GetSpeechSynthesisTaskOutput {
	s.SynthesisTask = v
	return s
}
250738
func (f *ResourceFilter) SetTask(t *api.Task) bool {
	r := t.Spec.Resources
	if r == nil || r.Reservations == nil {
		return false
	}

	res := r.Reservations
	if res.NanoCPUs == 0 && res.MemoryBytes == 0 && len(res.Generic) == 0 {
		return false
	}

	f.reservations = r.Reservations
	return true
}
1198929
func (s *GetMaintenanceWindowTaskOutput) SetTaskParameters(v map[string]*MaintenanceWindowTaskParameterValueExpression) *GetMaintenanceWindowTaskOutput {
	s.TaskParameters = v
	return s
}
583643
func (s *CreateTaskOutput) SetTaskArn(v string) *CreateTaskOutput {
	s.TaskArn = &v
	return s
}
775677
func (s *DescribeMaintenanceWindowTasksOutput) SetTasks(v []*MaintenanceWindowTask) *DescribeMaintenanceWindowTasksOutput {
	s.Tasks = v
	return s
}
408401
func (s *StopReplicationTaskOutput) SetReplicationTask(v *ReplicationTask) *StopReplicationTaskOutput {
	s.ReplicationTask = v
	return s
}
556479
func (s *ListAuditTasksInput) SetTaskType(v string) *ListAuditTasksInput {
	s.TaskType = &v
	return s
}
462035
func (s *RegisterTaskDefinitionOutput) SetTaskDefinition(v *TaskDefinition) *RegisterTaskDefinitionOutput {
	s.TaskDefinition = v
	return s
}
1109878
func (g *TaskGroup) AddTask(t *Task) *TaskGroup {
	g.Tasks = append(g.Tasks, t)
	return g
}
68469
func (s *ModifyReplicationTaskOutput) SetReplicationTask(v *ReplicationTask) *ModifyReplicationTaskOutput {
	s.ReplicationTask = v
	return s
}
1035906
func (s *MaintenanceWindowTask) SetTaskParameters(v map[string]*MaintenanceWindowTaskParameterValueExpression) *MaintenanceWindowTask {
	s.TaskParameters = v
	return s
}
314157
func (s *GetMaintenanceWindowExecutionTaskInvocationOutput) SetTaskType(v string) *GetMaintenanceWindowExecutionTaskInvocationOutput {
	s.TaskType = &v
	return s
}