コード例 #1
0
// ListRecipients method retrieves recipients of an alert from OpsGenie.
func (cli *OpsGenieAlertClient) ListRecipients(req alerts.ListAlertRecipientsRequest) (*alerts.ListAlertRecipientsResponse, error) {
	req.APIKey = cli.apiKey
	resp, err := cli.sendRequest(cli.buildGetRequest(listAlertRecipientsURL, req))

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

	var listAlertRecipientsResp alerts.ListAlertRecipientsResponse

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