-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtypes.go
297 lines (266 loc) · 10.5 KB
/
types.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
// types.go
// This file contains the various types used by the API
package atlas
import (
"log"
"net/http"
)
// Client is the main struct holding state in an API client
type Client struct {
config Config
client *http.Client
log *log.Logger
level int
opts map[string]string // Default, optional options
}
// Config is the main object when creating an API Client
type Config struct {
endpoint string
APIKey string
DefaultProbe int
AreaType string
AreaValue string
IsOneOff bool
PoolSize int
WantAF string
ProxyAuth string
Verbose bool
Tags string
Log *log.Logger
Level int
}
// APIError is for errors returned by the RIPE API.
type APIError struct {
Err struct {
Status int `json:"status"`
Code int `json:"code"`
Detail string `json:"detail"`
Title string `json:"title"`
Errors []struct {
Source struct {
Pointer string
} `json:"source"`
Detail string
} `json:"errors"`
} `json:"error"`
}
// Key is holding the API key parameters
type Key struct {
UUID string `json:"uuid"`
ValidFrom string `json:"valid_from"`
ValidTo string `json:"valid_to"`
Enabled bool
IsActive bool `json:"is_active"`
CreatedAt string `json:"created_at"`
Label string `json:"label"`
Grants []Grant `json:"grants"`
Type string `json:"type"`
}
// Grant is the permission(s) associated with a key
type Grant struct {
Permission string `json:"permission"`
Target struct {
Type string `json:"type"`
ID string `json:"id"`
} `json:"target"`
}
// Credits is holding credits data
type Credits struct {
CurrentBalance int `json:"current_balance"`
EstimatedDailyIncome int `json:"estimated_daily_income"`
EstimatedDailyExpenditure int `json:"estimated_daily_expenditure"`
EstimatedDailyBalance int `json:"estimated_daily_balance"`
CalculationTime string `json:"calculation_time"`
EstimatedRunoutSeconds int `json:"estimated_runout_seconds"`
PastDayMeasurementResults int `json:"past_day_measurement_results"`
PastDayCreditsSpent int `json:"past_day_credits_spent"`
IncomeItems string `json:"income_items"`
ExpenseItems string `json:"expense_items"`
Transactions string `json:"transactions"`
}
// Probe is holding probe's data
type Probe struct {
AddressV4 string `json:"address_v4"`
AddressV6 string `json:"address_v6"`
AsnV4 int `json:"asn_v4"`
AsnV6 int `json:"asn_v6"`
CountryCode string `json:"country_code"`
Description string `json:"description"`
FirstConnected int `json:"first_connected"`
Geometry struct {
Type string `json:"type"`
Coordinates []float64 `json:"coordinates"`
} `json:"geometry"`
ID int `json:"id"`
IsAnchor bool `json:"is_anchor"`
IsPublic bool `json:"is_public"`
LastConnected int `json:"last_connected"`
PrefixV4 string `json:"prefix_v4"`
PrefixV6 string `json:"prefix_v6"`
Status struct {
Since string `json:"since"`
ID int `json:"id"`
Name string `json:"name"`
} `json:"status"`
StatusSince int `json:"status_since"`
Tags []struct {
Name string `json:"name"`
Slug string `json:"slug"`
} `json:"tags"`
TotalUptime int `json:"total_uptime"`
Type string `json:"type"`
}
// Measurement is what we are working with
type Measurement struct {
Af int `json:"af"`
CreationTime int `json:"creation_time"`
Description string `json:"description"`
DestinationOptionSize interface{} `json:"destination_option_size"`
DontFragment interface{} `json:"dont_fragment"`
DuplicateTimeout interface{} `json:"duplicate_timeout"`
FirstHop int `json:"first_hop"`
Group string `json:"group"`
GroupID int `json:"group_id"`
HopByHopOptionSize interface{} `json:"hop_by_hop_option_size"`
ID int `json:"id"`
InWifiGroup bool `json:"in_wifi_group"`
Interval int `json:"interval"`
IsAllScheduled bool `json:"is_all_scheduled"`
IsOneoff bool `json:"is_oneoff"`
IsPublic bool `json:"is_public"`
MaxHops int `json:"max_hops"`
PacketInterval interface{} `json:"packet_interval"`
Packets int `json:"packets"`
Paris int `json:"paris"`
ParticipantCount int `json:"participant_count"`
ParticipationRequests []ParticipationRequest `json:"participation_requests"`
Port interface{} `json:"port"`
ProbesRequested int `json:"probes_requested"`
ProbesScheduled int `json:"probes_scheduled"`
Protocol string `json:"protocol"`
ResolveOnProbe bool `json:"resolve_on_probe"`
ResolvedIPs []string `json:"resolved_ips"`
ResponseTimeout int `json:"response_timeout"`
Result string `json:"result"`
Size int `json:"size"`
Spread interface{} `json:"spread"`
StartTime int `json:"start_time"`
Status struct {
ID int `json:"id"`
Name string `json:"name"`
} `json:"status"`
StopTime int `json:"stop_time"`
Target string `json:"target"`
TargetASN int `json:"target_asn"`
TargetIP string `json:"target_ip"`
Type string `json:"type"`
}
// ParticipationRequest allow you to add or remove probes from a measurement that
// was already created
type ParticipationRequest struct {
Action string `json:"action"`
CreatedAt int `json:"created_at,omitempty"`
ID int `json:"id,omitempty"`
Self string `json:"self,omitempty"`
Measurement string `json:"measurement,omitempty"`
MeasurementID int `json:"measurement_id,omitempty"`
Requested int `json:"requested,omitempty"`
Type string `json:"type,omitempty"`
Value string `json:"value,omitempty"`
Logs string `json:"logs,omitempty"`
}
var (
// ProbeTypes should be obvious
ProbeTypes = []string{"area", "country", "prefix", "asn", "probes", "msm"}
// AreaTypes should also be obvious
AreaTypes = []string{"WW", "West", "North-Central", "South-Central", "North-East", "South-East"}
)
// MeasurementRequest contains the different measurement to create/view
type MeasurementRequest struct {
// see below for definition
Definitions []Definition `json:"definitions"`
// requested set of probes
Probes []ProbeSet `json:"probes"`
//
BillTo int `json:"bill_to,omitempty"`
IsOneoff bool `json:"is_oneoff,omitempty"`
SkipDNSCheck bool `json:"skip_dns_check,omitempty"`
Times int `json:"times,omitempty"`
StartTime int `json:"start_time,omitempty"`
StopTime int `json:"stop_time,omitempty"`
}
// ProbeSet is a set of probes obviously
type ProbeSet struct {
Requested int `json:"requested"` // number of probes
Type string `json:"type"` // area, country, prefix, asn, probes, msm
Value string `json:"value"` // can be numeric or string
TagsInclude string `json:"tags_include,omitempty"`
TagsExclude string `json:"tags_exclude,omitempty"`
}
// Definition is used to create measurements
type Definition struct {
// Required fields
Description string `json:"description"`
Type string `json:"type"`
AF int `json:"af"`
// Required for all but "dns"
Target string `json:"target,omitempty"`
GroupID int `json:"group_id,omitempty"`
Group string `json:"group,omitempty"`
InWifiGroup bool `json:"in_wifi_group,omitempty"`
Spread int `json:"spread,omitempty"`
Packets int `json:"packets,omitempty"`
PacketInterval int `json:"packet_interval,omitempty"`
Tags []string `json:"tags,omitempty"`
// Common parameters
ExtraWait int `json:"extra_wait,omitempty"`
IsOneoff bool `json:"is_oneoff,omitempty"`
IsPublic bool `json:"is_public,omitempty"`
ResolveOnProbe bool `json:"resolve_on_probe,omitempty"`
// Default depends on type
Interval int `json:"interval,omitempty"`
// dns & traceroute parameters
Protocol string `json:"protocol,omitempty"`
// dns parameters
QueryClass string `json:"query_class,omitempty"`
QueryType string `json:"query_type,omitempty"`
QueryArgument string `json:"query_argument,omitempty"`
Retry int `json:"retry,omitempty"`
SetCDBit bool `json:"set_cd_bit,omitempty"`
SetDOBit bool `json:"set_do_bit,omitempty"`
SetNSIDBit bool `json:"set_nsid_bit,omitempty"`
SetRDBit bool `json:"set_rd_bit,omitempty"`
UDPPayloadSize int `json:"udp_payload_size,omitempty"`
UseProbeResolver bool `json:"use_probe_resolver"`
// ping parameters
// none (see target)
// traceroute parameters
DestinationOptionSize int `json:"destination_option_size,omitempty"`
DontFragment bool `json:"dont_fragment,omitempty"`
DuplicateTimeout int `json:"duplicate_timeout,omitempty"`
FirstHop int `json:"first_hop,omitempty"`
HopByHopOptionSize int `json:"hop_by_hop_option_size,omitempty"`
MaxHops int `json:"max_hops,omitempty"`
Paris int `json:"paris,omitempty"`
// ntp parameters
// none (see target)
// http parameters
ExtendedTiming bool `json:"extended_timing,omitempty"`
HeaderBytes int `json:"header_bytes,omitempty"`
Method string `json:"method,omitempty"`
MoreExtendedTiming bool `json:"more_extended_timing,omitempty"`
Path string `json:"path,omitempty"`
QueryOptions string `json:"query_options,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
Version string `json:"version,omitempty"`
// sslcert parameters
// none (see target)
// sslcert & traceroute & http parameters
Port int `json:"port,omitempty"`
// ping & traceroute parameters
Size int `json:"size,omitempty"`
// wifi parameters
AnonymousIdentity string `json:"anonymous_identity,omitempty"`
Cert string `json:"cert,omitempty"`
EAP string `json:"eap,omitempty"`
}