func (a *API) FetchAlert(cid CIDType) (*Alert, error) {
	if cid == nil || *cid == "" {
		return nil, fmt.Errorf("Invalid alert CID [none]")
	}

	alertCID := string(*cid)

	matched, err := regexp.MatchString(config.AlertCIDRegex, alertCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid alert CID [%s]", alertCID)
	}

	result, err := a.Get(alertCID)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] fetch alert, received JSON: %s", string(result))
	}

	alert := &Alert{}
	if err := json.Unmarshal(result, alert); err != nil {
		return nil, err
	}

	return alert, nil
}
func (a *API) FetchAlert(cid CIDType) (*Alert, error) {
	if cid == nil || *cid == "" {
		return nil, fmt.Errorf("Invalid alert CID [none]")
	}

	alertCID := string(*cid)

	matched, err := regexp.MatchString(config.AlertCIDRegex, alertCID)
	if err != nil {
		return nil, err
	}
	if !matched {
		return nil, fmt.Errorf("Invalid alert CID [%s]", alertCID)
	}

	result, err := a.Get(alertCID)
	if err != nil {
		return nil, err
	}

	if a.Debug {
		a.Log.Printf("[DEBUG] fetch alert, received JSON: %s", string(result))
	}

	alert := &Alert{}
	if err := json.Unmarshal(result, alert); err != nil {
		return nil, err
	}

	return alert, nil
}
func ( a * API ) FetchAlert ( cid CIDType ) ( * Alert , error ) { if cid == nil || * cid == " " { return nil , fmt . Errorf ( " " ) } alertCID := string ( * cid ) matched , err := regexp . MatchString ( config . AlertCIDRegex , alertCID ) if err != nil { return nil , err } if ! matched { return nil , fmt . Errorf ( " " , alertCID ) } result , err := a . Get ( alertCID ) if err != nil { return nil , err } if a . Debug { a . Log . Printf ( " " , string ( result ) ) } alert := & Alert { } if err := json . Unmarshal ( result , alert ) ; err != nil { return nil , err } return alert , nil }
// FetchAlert retrieves alert with passed cid.
FetchAlert retrieves alert with passed cid .