Skip to content

Commit

Permalink
drop a few fields that are not being used. Also take care of multiple…
Browse files Browse the repository at this point in the history
… matches
  • Loading branch information
rajagopalans committed Oct 16, 2023
1 parent d36959a commit 3e99ecd
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions apstra/api_iba_probes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,19 @@ const (
)

type IbaProbe struct {
Id ObjectId `json:"id"`
Label string `json:"label"`
TaskError string `json:"task_error"`
Stages []map[string]interface{} `json:"stages"`
AnomalyCount int `json:"anomaly_count"`
Tags []string `json:"tags"`
LastError interface{} `json:"last_error"`
UpdatedAt string `json:"updated_at"`
UpdatedBy string `json:"updated_by"`
Disabled bool `json:"disabled"`
ConfigCompletedAt string `json:"config_completed_at"`
State string `json:"state"`
Version int `json:"version"`
HostNode string `json:"host_node"`
TaskState string `json:"task_state"`
ConfigStartedAt string `json:"config_started_at"`
IbaUnit string `json:"iba_unit"`
PredefinedProbe string `json:"predefined_probe"`
Description string `json:"description"`
Id ObjectId `json:"id"`
Label string `json:"label"`
TaskError string `json:"task_error"`
Stages []map[string]interface{} `json:"stages"`
AnomalyCount int `json:"anomaly_count"`
Tags []string `json:"tags"`
Disabled bool `json:"disabled"`
State string `json:"state"`
Version int `json:"version"`
TaskState string `json:"task_state"`
IbaUnit string `json:"iba_unit"`
PredefinedProbe string `json:"predefined_probe"`
Description string `json:"description"`
}

func (o *Client) getAllIbaProbes(ctx context.Context, bpId ObjectId) ([]IbaProbe, error) {
Expand All @@ -55,17 +49,27 @@ func (o *Client) getIbaProbeByLabel(ctx context.Context, bpId ObjectId, label st
if err != nil {
return nil, err
}

var probe IbaProbe
i := 0
for _, p := range pps {
if p.Label == label {
return &p, nil
probe := p
i := i + 1
}
}

return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("no Predefined Probe with label '%s' found", label),
if i == 0 {
return nil, ClientErr{
errType: ErrNotfound,
err: fmt.Errorf("no Predefined Probe with label '%s' found", label),
}
}
if i > 1 {
return nil, ClientErr{
errType: ErrMultipleMatch,
err: fmt.Errorf("too many probes with label %s found, expected 1 got %d", label, i),
}
}
return &probe, nil
}

func (o *Client) getIbaProbe(ctx context.Context, bpId ObjectId, id ObjectId) (*IbaProbe, error) {
Expand Down

0 comments on commit 3e99ecd

Please sign in to comment.