// FindAgents finds AgentInfos which match the given Criteria
FindAgents finds AgentInfos which match the given Criteria
// FindAgents finds AgentInfos which match the given Criteria
func FindAgents(profile *config.Profile, criteria Criteria) (Messages, error) {
	caller := helper.NewCaller(profile)
	switch {
	case criteria.TaskID != "":
		msgs, err := FromMaster(caller.CallMaster(master.GetTasks()))
		if err != nil {
			return nil, err
		}
		task, err := AsTask(msgs.FindOne(TaskIDFilter(criteria.TaskID, criteria.Fuzzy)))
		if err != nil {
			return nil, err
		}
		return FindAgents(profile, Criteria{AgentID: task.AgentID.Value})
	case criteria.AgentID != "":
		msgs, err := FromMaster(caller.CallMaster(master.GetAgents()))
		if err != nil {
			return nil, err
		}
		return msgs.FindMany(AgentIDFilter(criteria.AgentID, criteria.Fuzzy)), nil
	default:
		msgs, err := FromMaster(caller.CallMaster(master.GetAgents()))
		if err != nil {
			return nil, err
		}
		return msgs.FindMany(), nil
	}
}
func FindAgents ( profile * config . Profile , criteria Criteria ) ( Messages , error ) { caller := helper . NewCaller ( profile ) switch { case criteria . TaskID != " " : msgs , err := FromMaster ( caller . CallMaster ( master . GetTasks ( ) ) ) if err != nil { return nil , err } task , err := AsTask ( msgs . FindOne ( TaskIDFilter ( criteria . TaskID , criteria . Fuzzy ) ) ) if err != nil { return nil , err } return FindAgents ( profile , Criteria { AgentID : task . AgentID . Value } ) case criteria . AgentID != " " : msgs , err := FromMaster ( caller . CallMaster ( master . GetAgents ( ) ) ) if err != nil { return nil , err } return msgs . FindMany ( AgentIDFilter ( criteria . AgentID , criteria . Fuzzy ) ) , nil default : msgs , err := FromMaster ( caller . CallMaster ( master . GetAgents ( ) ) ) if err != nil { return nil , err } return msgs . FindMany ( ) , nil } }
FindAgents finds AgentInfos which match the given Criteria
FindAgents finds AgentInfos which match the given Criteria
// Caller is attempting to resolve the agent based on a TaskID // Get all tasks running on the master // Lookup the AgentID from the task if there is a match // Return the results of a Find based on the resolved AgentID // Caller specified an AgentID, match based on GET_AGENTS call // Return all agents