// GetTaskByGuid returns a task structure by requesting it with the tasks GUID.
17570
func (c *Client) GetTaskByGuid(guid string) (task Task, err error) {
	request := fmt.Sprintf("/v3/tasks/%s", guid)
	req := c.NewRequest("GET", request)

	resp, err := c.DoRequest(req)
	if err != nil {
		return task, errors.Wrap(err, "Error requesting task")
	}
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return task, errors.Wrap(err, "Error reading task")
	}

	err = json.Unmarshal(body, &task)
	if err != nil {
		return task, errors.Wrap(err, "Error unmarshaling task")
	}
	return task, err
}
20556
func (actor Actor) GetApplicationsByGUIDs(appGUIDs ...string) ([]Application, Warnings, error) {
	ccApps, warnings, err := actor.CloudControllerClient.GetApplications(
		ccv3.Query{Key: ccv3.GUIDFilter, Values: appGUIDs},
	)

	if err != nil {
		return []Application{}, Warnings(warnings), err
	}

	var apps []Application
	for _, ccApp := range ccApps {
		apps = append(apps, actor.convertCCToActorApplication(ccApp))
	}
	return apps, Warnings(warnings), nil
}
267388
func (api *TasksAPI) Get(id string) (task *Task, err error) {
	res, err := api.client.restClient.Get(api.client.Endpoint+taskUrl+"/"+id, api.client.options.TokenOptions)
	if err != nil {
		return
	}
	defer res.Body.Close()
	result, err := getTask(getError(res))
	return result, err
}
151379
func GetGuid() string {
	b := make([]byte, 48)
	if _, err := io.ReadFull(rand.Reader, b); err != nil {
		return ""
	}
	return getMd5String(base64.URLEncoding.EncodeToString(b))
}
1363989
func (t *Template) GetAllAWSSSMMaintenanceWindowTaskResources() map[string]*resources.AWSSSMMaintenanceWindowTask {
	results := map[string]*resources.AWSSSMMaintenanceWindowTask{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSSSMMaintenanceWindowTask:
			results[name] = resource
		}
	}
	return results
}
938477
func (c *Client) GetTaskResult(id int) []string {
	l, _ := c.GetTaskOutput(id, "result")
	return l
}
249483
func (r *GormWorkItemRepository) LoadByID(ctx context.Context, id uuid.UUID) (*WorkItem, error) {
	defer goa.MeasureSince([]string{"goa", "db", "workitem", "loadById"}, time.Now())
	res, err := r.LoadFromDB(ctx, id)
	if err != nil {
		return nil, errs.WithStack(err)
	}
	wiType, err := r.witr.Load(ctx, res.Type)
	if err != nil {
		return nil, errors.NewInternalError(ctx, err)
	}
	return ConvertWorkItemStorageToModel(wiType, res)
}
1359053
func (m *Migration) GetGUID() string {
	if m == nil || m.GUID == nil {
		return ""
	}
	return *m.GUID
}
855299
func (client *Client) UpdateTaskCancel(taskGUID string) (Task, Warnings, error) {
	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.PutTaskCancelRequest,
		URIParams: internal.Params{
			"task_guid": taskGUID,
		},
	})
	if err != nil {
		return Task{}, nil, err
	}

	var task Task
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &task,
	}

	err = client.connection.Make(request, &response)
	if err != nil {
		return Task{}, response.Warnings, err
	}

	return task, response.Warnings, nil
}
908375
func (client *Client) CreateApplicationTask(appGUID string, task Task) (Task, Warnings, error) {
	bodyBytes, err := json.Marshal(task)
	if err != nil {
		return Task{}, nil, err
	}

	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.PostApplicationTasksRequest,
		URIParams: internal.Params{
			"app_guid": appGUID,
		},
		Body: bytes.NewReader(bodyBytes),
	})
	if err != nil {
		return Task{}, nil, err
	}

	var responseTask Task
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &responseTask,
	}

	err = client.connection.Make(request, &response)
	return responseTask, response.Warnings, err
}
761231
func (i *Index) WaitTask(taskID int) error {
	return waitWithRetry(func() (bool, error) {
		res, err := i.GetStatus(taskID)
		if err != nil {
			return true, err
		}
		if res.Status == "published" {
			return true, nil
		}
		return false, nil
	})
}
373169
func (cm *CeleryMessage) GetTaskMessage() *TaskMessage {
	// ensure content-type is 'application/json'
	if cm.ContentType != "application/json" {
		log.Println("unsupported content type " + cm.ContentType)
		return nil
	}
	// ensure body encoding is base64
	if cm.Properties.BodyEncoding != "base64" {
		log.Println("unsupported body encoding " + cm.Properties.BodyEncoding)
		return nil
	}
	// ensure content encoding is utf-8
	if cm.ContentEncoding != "utf-8" {
		log.Println("unsupported encoding " + cm.ContentEncoding)
		return nil
	}
	// decode body
	taskMessage, err := DecodeTaskMessage(cm.Body)
	if err != nil {
		log.Println("failed to decode task message")
		return nil
	}
	return taskMessage
}
293249
func (m *Manager) GetQueryAsync(name string, userCredentials *cli.UserCredentials) *tasks.Task {
	if name == "" {
		panic("name must be present")
	}

	return m.client.GetQuery(m.httpEndpoint, name, userCredentials)
}
1358874
func getTaskInfoByContainerID(containerID string, tasks []TaskInfo) *TaskInfo {
	for _, task := range tasks {
		if len(task.Statuses) > 0 && task.Statuses[0].ContainerStatusInfo.ID.Value == containerID {
			return &task
		}
	}
	return nil
}
470871
func (s *TasksService) FindResultByTask(t Task) (*http.Response, error) {
	return s.client.GetResultByURI(t.ResultURI)
}
753504
func (i *Index) GetStatus(taskID int) (res TaskStatusRes, err error) {
	path := i.path("/task/%d", taskID)
	err = i.transport.Request(&res, http.MethodGet, path, nil, call.Read)
	return
}
596677
func (j *Jenkins) GetQueueItem(id int64) (*Task, error) {
	t := &Task{Raw: new(taskResponse), Jenkins: j, Base: j.getQueueItemURL(id)}
	_, err := t.Poll()
	if err != nil {
		return nil, err
	}
	return t, nil
}