Exemplo n.º 1
0
// ListNotes method retrieves notes of an alert from OpsGenie.
func (cli *OpsGenieAlertClient) ListNotes(req alerts.ListAlertNotesRequest) (*alerts.ListAlertNotesResponse, error) {
	req.APIKey = cli.apiKey
	resp, err := cli.sendRequest(cli.buildGetRequest(listAlertNotesURL, req))

	if resp == nil {
		return nil, err
	}
	defer resp.Body.Close()

	var listAlertNotesResp alerts.ListAlertNotesResponse

	if err = resp.Body.FromJsonTo(&listAlertNotesResp); err != nil {
		message := "Server response can not be parsed, " + err.Error()
		logging.Logger().Warn(message)
		return nil, errors.New(message)
	}
	return &listAlertNotesResp, nil
}