FetchChannelTarget returns the measure target of the server monitored on the channel
(channel Channel, probe Probe)
| 660 | } |
| 661 | |
| 662 | // FetchChannelTarget returns the measure target of the server monitored on the channel |
| 663 | func (a *API) FetchChannelTarget(channel Channel, probe Probe) (string, error) { |
| 664 | pth := path.Join(channel.CalnexAPI(), "ptp_synce", probe.CalnexAPI(), probe.ServerType()) |
| 665 | if MeasureChannelDatatypeMap[channel] == TE { |
| 666 | pth = path.Join(channel.CalnexAPI(), probe.ServerType()) |
| 667 | } |
| 668 | url := fmt.Sprintf(measureURL, a.source, pth) |
| 669 | resp, err := a.Client.Get(url) |
| 670 | if err != nil { |
| 671 | return "", err |
| 672 | } |
| 673 | defer resp.Body.Close() |
| 674 | |
| 675 | if resp.StatusCode != http.StatusOK { |
| 676 | return "", errors.New(http.StatusText(resp.StatusCode)) |
| 677 | } |
| 678 | |
| 679 | b, err := io.ReadAll(resp.Body) |
| 680 | if err != nil { |
| 681 | return "", err |
| 682 | } |
| 683 | |
| 684 | return parseResponse(string(b)) |
| 685 | } |
| 686 | |
| 687 | // FetchUsedChannels returns list of channels in use |