func (s *CachetClient) GetIncidentByComponent(cid int, cName string) (bool, *cachet.Incident, string) {
	var res *cachet.Incident
	var errMsg string
	isEvaluable := true

	filters := &cachet.IncidentsQueryParams{
		ComponentID: cid,
	}
	incidents, _, err := s.client.Incidents.GetAll(filters)

	if err != nil {
		return false, res, errMsg
	}

	switch {
	case incidents.Meta.Pagination.Count <= 0:
		errMsg = fmt.Sprintf("Not found a component to tag '%s'\n", cName)
		isEvaluable = false
	case incidents.Meta.Pagination.Count == 1:
		errMsg = fmt.Sprintf("Fabulous! Found it a component matching tag '%s'\n", cName)
	case incidents.Meta.Pagination.Count > 1:
		errMsg = fmt.Sprintf("Found multiple components matching tag '%s'. Please, refine your tags.\n", cName)
		isEvaluable = false
	default:
		errMsg = fmt.Sprint("Unknown error reading returned results...")
		isEvaluable = false
	}

	if !isEvaluable {
		return isEvaluable, res, errMsg
	}

	for _, incident := range incidents.Incidents {
		if incident.Status != cachet.IncidentStatusFixed {
			res = &incident
		}
	}

	return true, res, ""
}
// GetIncidentByComponent gets all incidents by a given component
// @todo: using NOT notation in querystring fields
GetIncidentByComponent gets all incidents by a given component
@todo: using NOT notation in querystring fields
// GetIncidentByComponent gets all incidents by a given component // @todo : using NOT notation in querystring fields
func (s *CachetClient) GetIncidentByComponent(cid int, cName string) (bool, *cachet.Incident, string) {
	var res *cachet.Incident
	var errMsg string
	isEvaluable := true
	filters := &cachet.IncidentsQueryParams{
		ComponentID: cid,
	}
	incidents, _, err := s.client.Incidents.GetAll(filters)
	if err != nil {
		return false, res, errMsg
	}
	switch {
	case incidents.Meta.Pagination.Count <= 0:
		errMsg = fmt.Sprintf("Not found a component to tag '%s'\n", cName)
		isEvaluable = false
	case incidents.Meta.Pagination.Count == 1:
		errMsg = fmt.Sprintf("Fabulous! Found it a component matching tag '%s'\n", cName)
	case incidents.Meta.Pagination.Count > 1:
		errMsg = fmt.Sprintf("Found multiple components matching tag '%s'. Please, refine your tags.\n", cName)
		isEvaluable = false
	default:
		errMsg = fmt.Sprint("Unknown error reading returned results...")
		isEvaluable = false
	}
	if !isEvaluable {
		return isEvaluable, res, errMsg
	}
	for _, incident := range incidents.Incidents {
		if incident.Status != cachet.IncidentStatusFixed {
			res = &incident
		}
	}
	return true, res, ""
}
func ( s * CachetClient ) GetIncidentByComponent ( cid int , cName string ) ( bool , * cachet . Incident , string ) { var res * cachet . Incident var errMsg string isEvaluable := true filters := & cachet . IncidentsQueryParams { ComponentID : cid , } incidents , _ , err := s . client . Incidents . GetAll ( filters ) if err != nil { return false , res , errMsg } switch { case incidents . Meta . Pagination . Count <= 0 : errMsg = fmt . Sprintf ( " \n " , cName ) isEvaluable = false case incidents . Meta . Pagination . Count == 1 : errMsg = fmt . Sprintf ( " \n " , cName ) case incidents . Meta . Pagination . Count > 1 : errMsg = fmt . Sprintf ( " \n " , cName ) isEvaluable = false default : errMsg = fmt . Sprint ( " " ) isEvaluable = false } if ! isEvaluable { return isEvaluable , res , errMsg } for _ , incident := range incidents . Incidents { if incident . Status != cachet . IncidentStatusFixed { res = & incident } } return true , res , " " }
GetIncidentByComponent gets all incidents by a given component
@todo: using NOT notation in querystring fields
GetIncidentByComponent gets all incidents by a given component @todo : using NOT notation in querystring fields