FetchChannelProbe returns monitored protocol of the channel
(channel Channel)
| 629 | } |
| 630 | |
| 631 | // FetchChannelProbe returns monitored protocol of the channel |
| 632 | func (a *API) FetchChannelProbe(channel Channel) (*Probe, error) { |
| 633 | pth := path.Join(channel.CalnexAPI(), "ptp_synce", "mode", "probe_type") |
| 634 | if MeasureChannelDatatypeMap[channel] == TE { |
| 635 | pth = path.Join(channel.CalnexAPI(), "signal_type") |
| 636 | } |
| 637 | url := fmt.Sprintf(measureURL, a.source, pth) |
| 638 | |
| 639 | resp, err := a.Client.Get(url) |
| 640 | if err != nil { |
| 641 | return nil, err |
| 642 | } |
| 643 | defer resp.Body.Close() |
| 644 | |
| 645 | if resp.StatusCode != http.StatusOK { |
| 646 | return nil, errors.New(http.StatusText(resp.StatusCode)) |
| 647 | } |
| 648 | |
| 649 | b, err := io.ReadAll(resp.Body) |
| 650 | if err != nil { |
| 651 | return nil, err |
| 652 | } |
| 653 | |
| 654 | probe, err := parseResponse(string(b)) |
| 655 | if err != nil { |
| 656 | return nil, err |
| 657 | } |
| 658 | p, err := ProbeFromCalnex(probe) |
| 659 | return p, err //nolint:nilnil |
| 660 | } |
| 661 | |
| 662 | // FetchChannelTarget returns the measure target of the server monitored on the channel |