func (s *CachetClient) GetComponentByTag(tag string) (bool, *cachet.Component, string) {
	var res *cachet.Component
	var errMsg string
	isEvaluable := true

	filters := &cachet.ComponentsQueryParams{
		Name:    tag,
		Enabled: true,
	}
	components, _, err := s.client.Components.GetAll(filters)

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

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

	if !isEvaluable {
		return isEvaluable, res, errMsg
	}

	for _, component := range components.Components {
		res = &cachet.Component{
			ID:     component.ID,
			Name:   component.Name,
			Status: component.Status,
		}
	}

	return true, res, errMsg
}
// GetComponentByTag returns all existing components that are enabled and matches
// with returned tags from StatusCake
GetComponentByTag returns all existing components that are enabled and matches
with returned tags from StatusCake
// GetComponentByTag returns all existing components that are enabled and matches // with returned tags from StatusCake
func (s *CachetClient) GetComponentByTag(tag string) (bool, *cachet.Component, string) {
	var res *cachet.Component
	var errMsg string
	isEvaluable := true
	filters := &cachet.ComponentsQueryParams{
		Name:    tag,
		Enabled: true,
	}
	components, _, err := s.client.Components.GetAll(filters)
	if err != nil {
		return false, res, ""
	}
	switch {
	case components.Meta.Pagination.Count <= 0:
		errMsg = fmt.Sprintf("Not found a component to tag '%s'\n", tag)
		isEvaluable = false
	case components.Meta.Pagination.Count == 1:
		errMsg = fmt.Sprintf("Fabulous! Found it a component matching tag '%s'\n", tag)
	case components.Meta.Pagination.Count > 1:
		errMsg = fmt.Sprintf("Found multiple components matching tag '%s'. Please, refine your tags.\n", tag)
		isEvaluable = false
	default:
		errMsg = fmt.Sprint("Unknown error reading returned results...")
		isEvaluable = false
	}
	if !isEvaluable {
		return isEvaluable, res, errMsg
	}
	for _, component := range components.Components {
		res = &cachet.Component{
			ID:     component.ID,
			Name:   component.Name,
			Status: component.Status,
		}
	}
	return true, res, errMsg
}
func ( s * CachetClient ) GetComponentByTag ( tag string ) ( bool , * cachet . Component , string ) { var res * cachet . Component var errMsg string isEvaluable := true filters := & cachet . ComponentsQueryParams { Name : tag , Enabled : true , } components , _ , err := s . client . Components . GetAll ( filters ) if err != nil { return false , res , " " } switch { case components . Meta . Pagination . Count <= 0 : errMsg = fmt . Sprintf ( " \n " , tag ) isEvaluable = false case components . Meta . Pagination . Count == 1 : errMsg = fmt . Sprintf ( " \n " , tag ) case components . Meta . Pagination . Count > 1 : errMsg = fmt . Sprintf ( " \n " , tag ) isEvaluable = false default : errMsg = fmt . Sprint ( " " ) isEvaluable = false } if ! isEvaluable { return isEvaluable , res , errMsg } for _ , component := range components . Components { res = & cachet . Component { ID : component . ID , Name : component . Name , Status : component . Status , } } return true , res , errMsg }
GetComponentByTag returns all existing components that are enabled and matches
with returned tags from StatusCake
GetComponentByTag returns all existing components that are enabled and matches with returned tags from StatusCake