-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
probe_source.go
51 lines (41 loc) · 1.8 KB
/
probe_source.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package measurement
import (
"encoding/json"
"fmt"
)
type ProbeSource struct {
ParseError error
data struct {
Requested int `json:"requested"`
Type string `json:"type"`
Value string `json:"value"`
TagsInclude string `json:"tags_include"`
TagsExclude string `json:"tags_exclude"`
}
}
func (p *ProbeSource) UnmarshalJSON(b []byte) error {
if err := json.Unmarshal(b, &p.data); err != nil {
return fmt.Errorf("%s for %s", err.Error(), string(b))
}
return nil
}
// Number of probes that have to be added or removed.
func (p *ProbeSource) Requested() int {
return p.data.Requested
}
// Probe selector. Options are: `area` allows a compass quarter of the world, `asn` selects an Autonomous System, `country` selects a country, `msm` selects the probes used in another measurement, `prefix` selects probes based on prefix, `probes` selects probes directly.
func (p *ProbeSource) Type() string {
return p.data.Type
}
// Value for given selector type. `area`: ['WW','West','North-Central','South-Central','North-East','South-East']. `asn`: ASN (integer). `country`: two-letter country code according to ISO 3166-1 alpha-2, e.g. GR. `msm`: measurement id (integer). `prefix`: prefix in CIDR notation, e.g. 193.0.0/16. `probes`: comma-separated list of probe IDs.
func (p *ProbeSource) Value() string {
return p.data.Value
}
// Comma-separated list of probe tags. Only probes with all these tags attached will be selected from this participation request.
func (p *ProbeSource) TagsInclude() string {
return p.data.TagsInclude
}
// Comma-separated list of probe tags. Probes with any of these tags attached will be excluded from this participation request.
func (p *ProbeSource) TagsExclude() string {
return p.data.TagsExclude
}