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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
open Core
open Async
let json_arg = Command.Arg_type.create Yojson.Safe.from_string
let call ?endpoint_url ?profile ?region f m result_to_json error_to_json =
let region =
match region with
| Some region -> Some (Awso.Region.of_string region)
| None -> None in
(Awso_async.Cfg.get_exn ?profile ?region ()) >>=
(fun cfg ->
(f ?endpoint_url ?cfg:(Some cfg) m) >>=
(fun result ->
match result with
| Error err ->
(match error_to_json with
| None ->
failwithf
"endpoint error, but no error values defined in boto"
()
| Some to_json ->
let s = (err |> to_json) |> Yojson.Safe.to_string in
failwithf "AWS error: %s" s ())
| Ok result ->
((match result_to_json with
| None -> print_endline "ok response from endpoint"
| Some to_json ->
((result |> to_json) |> Yojson.Safe.to_string) |>
print_endline);
return ())))
let calculate_isolines =
Command.async ~summary:""
([%map_open.Command
let cli_profile =
flag "-cli-profile" (optional string) ~doc:"NAME aws profile to use"
and cli_region =
flag "-cli-region" (optional string) ~doc:"REGION override region"
and endpoint_url =
flag "-endpoint-url" (optional string)
~doc:"URL override endpoint url"
and allow =
flag "allow" (optional json_arg) ~doc:"JSON IsolineAllowOptions"
and arrivalTime =
flag "arrival-time" (optional string)
~doc:"STRING TimestampWithTimezoneOffset"
and avoid =
flag "avoid" (optional json_arg) ~doc:"JSON IsolineAvoidanceOptions"
and departNow =
flag "depart-now" (optional bool) ~doc:"BOOL SensitiveBoolean"
and departureTime =
flag "departure-time" (optional string)
~doc:"STRING TimestampWithTimezoneOffset"
and destination =
flag "destination" (optional json_arg) ~doc:"JSON Position"
and destinationOptions =
flag "destination-options" (optional json_arg)
~doc:"JSON IsolineDestinationOptions"
and isolineGeometryFormat =
flag "isoline-geometry-format" (optional json_arg)
~doc:"JSON GeometryFormat"
and isolineGranularity =
flag "isoline-granularity" (optional json_arg)
~doc:"JSON IsolineGranularityOptions"
and key = flag "key" (optional string) ~doc:"STRING ApiKey"
and optimizeIsolineFor =
flag "optimize-isoline-for" (optional json_arg)
~doc:"JSON IsolineOptimizationObjective"
and optimizeRoutingFor =
flag "optimize-routing-for" (optional json_arg)
~doc:"JSON RoutingObjective"
and origin = flag "origin" (optional json_arg) ~doc:"JSON Position"
and originOptions =
flag "origin-options" (optional json_arg)
~doc:"JSON IsolineOriginOptions"
and traffic =
flag "traffic" (optional json_arg) ~doc:"JSON IsolineTrafficOptions"
and travelMode =
flag "travel-mode" (optional json_arg) ~doc:"JSON IsolineTravelMode"
and travelModeOptions =
flag "travel-mode-options" (optional json_arg)
~doc:"JSON IsolineTravelModeOptions"
and thresholds =
flag "thresholds" (required json_arg) ~doc:"JSON IsolineThresholds" in
fun () ->
call ?endpoint_url ?profile:cli_profile ?region:cli_region
Io.calculate_isolines
(Values.CalculateIsolinesRequest.make
?allow:(Option.map ~f:Values.IsolineAllowOptions.of_json allow)
?arrivalTime
?avoid:(Option.map ~f:Values.IsolineAvoidanceOptions.of_json
avoid) ?departNow ?departureTime
?destination:(Option.map ~f:Values.Position.of_json destination)
?destinationOptions:(Option.map
~f:Values.IsolineDestinationOptions.of_json
destinationOptions)
?isolineGeometryFormat:(Option.map
~f:Values.GeometryFormat.of_json
isolineGeometryFormat)
?isolineGranularity:(Option.map
~f:Values.IsolineGranularityOptions.of_json
isolineGranularity) ?key
?optimizeIsolineFor:(Option.map
~f:Values.IsolineOptimizationObjective.of_json
optimizeIsolineFor)
?optimizeRoutingFor:(Option.map
~f:Values.RoutingObjective.of_json
optimizeRoutingFor)
?origin:(Option.map ~f:Values.Position.of_json origin)
?originOptions:(Option.map
~f:Values.IsolineOriginOptions.of_json
originOptions)
?traffic:(Option.map ~f:Values.IsolineTrafficOptions.of_json
traffic)
?travelMode:(Option.map ~f:Values.IsolineTravelMode.of_json
travelMode)
?travelModeOptions:(Option.map
~f:Values.IsolineTravelModeOptions.of_json
travelModeOptions)
~thresholds:(Values.IsolineThresholds.of_json thresholds) ())
(Some Values.CalculateIsolinesResponse.to_json)
(Some Values.CalculateIsolinesResponse.error_to_json)])
let calculate_route_matrix =
Command.async ~summary:""
([%map_open.Command
let cli_profile =
flag "-cli-profile" (optional string) ~doc:"NAME aws profile to use"
and cli_region =
flag "-cli-region" (optional string) ~doc:"REGION override region"
and endpoint_url =
flag "-endpoint-url" (optional string)
~doc:"URL override endpoint url"
and allow =
flag "allow" (optional json_arg) ~doc:"JSON RouteMatrixAllowOptions"
and avoid =
flag "avoid" (optional json_arg)
~doc:"JSON RouteMatrixAvoidanceOptions"
and departNow =
flag "depart-now" (optional bool) ~doc:"BOOL SensitiveBoolean"
and departureTime =
flag "departure-time" (optional string)
~doc:"STRING TimestampWithTimezoneOffset"
and exclude =
flag "exclude" (optional json_arg)
~doc:"JSON RouteMatrixExclusionOptions"
and key = flag "key" (optional string) ~doc:"STRING ApiKey"
and optimizeRoutingFor =
flag "optimize-routing-for" (optional json_arg)
~doc:"JSON RoutingObjective"
and routingBoundary =
flag "routing-boundary" (optional json_arg)
~doc:"JSON RouteMatrixBoundary"
and traffic =
flag "traffic" (optional json_arg)
~doc:"JSON RouteMatrixTrafficOptions"
and travelMode =
flag "travel-mode" (optional json_arg)
~doc:"JSON RouteMatrixTravelMode"
and travelModeOptions =
flag "travel-mode-options" (optional json_arg)
~doc:"JSON RouteMatrixTravelModeOptions"
and destinations =
flag "destinations" (required json_arg)
~doc:"JSON CalculateRouteMatrixRequestDestinationsList"
and origins =
flag "origins" (required json_arg)
~doc:"JSON CalculateRouteMatrixRequestOriginsList" in
fun () ->
call ?endpoint_url ?profile:cli_profile ?region:cli_region
Io.calculate_route_matrix
(Values.CalculateRouteMatrixRequest.make
?allow:(Option.map ~f:Values.RouteMatrixAllowOptions.of_json
allow)
?avoid:(Option.map
~f:Values.RouteMatrixAvoidanceOptions.of_json avoid)
?departNow ?departureTime
?exclude:(Option.map
~f:Values.RouteMatrixExclusionOptions.of_json
exclude) ?key
?optimizeRoutingFor:(Option.map
~f:Values.RoutingObjective.of_json
optimizeRoutingFor)
?routingBoundary:(Option.map
~f:Values.RouteMatrixBoundary.of_json
routingBoundary)
?traffic:(Option.map
~f:Values.RouteMatrixTrafficOptions.of_json traffic)
?travelMode:(Option.map ~f:Values.RouteMatrixTravelMode.of_json
travelMode)
?travelModeOptions:(Option.map
~f:Values.RouteMatrixTravelModeOptions.of_json
travelModeOptions)
~destinations:(Values.CalculateRouteMatrixRequestDestinationsList.of_json
destinations)
~origins:(Values.CalculateRouteMatrixRequestOriginsList.of_json
origins) ())
(Some Values.CalculateRouteMatrixResponse.to_json)
(Some Values.CalculateRouteMatrixResponse.error_to_json)])
let calculate_routes =
Command.async ~summary:""
([%map_open.Command
let cli_profile =
flag "-cli-profile" (optional string) ~doc:"NAME aws profile to use"
and cli_region =
flag "-cli-region" (optional string) ~doc:"REGION override region"
and endpoint_url =
flag "-endpoint-url" (optional string)
~doc:"URL override endpoint url"
and allow =
flag "allow" (optional json_arg) ~doc:"JSON RouteAllowOptions"
and arrivalTime =
flag "arrival-time" (optional string)
~doc:"STRING TimestampWithTimezoneOffset"
and avoid =
flag "avoid" (optional json_arg) ~doc:"JSON RouteAvoidanceOptions"
and departNow =
flag "depart-now" (optional bool) ~doc:"BOOL SensitiveBoolean"
and departureTime =
flag "departure-time" (optional string)
~doc:"STRING TimestampWithTimezoneOffset"
and destinationOptions =
flag "destination-options" (optional json_arg)
~doc:"JSON RouteDestinationOptions"
and driver =
flag "driver" (optional json_arg) ~doc:"JSON RouteDriverOptions"
and exclude =
flag "exclude" (optional json_arg) ~doc:"JSON RouteExclusionOptions"
and instructionsMeasurementSystem =
flag "instructions-measurement-system" (optional json_arg)
~doc:"JSON MeasurementSystem"
and key = flag "key" (optional string) ~doc:"STRING ApiKey"
and languages =
flag "languages" (optional json_arg)
~doc:"JSON CalculateRoutesRequestLanguagesList"
and legAdditionalFeatures =
flag "leg-additional-features" (optional json_arg)
~doc:"JSON RouteLegAdditionalFeatureList"
and legGeometryFormat =
flag "leg-geometry-format" (optional json_arg)
~doc:"JSON GeometryFormat"
and maxAlternatives =
flag "max-alternatives" (optional int)
~doc:"INT CalculateRoutesRequestMaxAlternativesInteger"
and optimizeRoutingFor =
flag "optimize-routing-for" (optional json_arg)
~doc:"JSON RoutingObjective"
and originOptions =
flag "origin-options" (optional json_arg)
~doc:"JSON RouteOriginOptions"
and spanAdditionalFeatures =
flag "span-additional-features" (optional json_arg)
~doc:"JSON RouteSpanAdditionalFeatureList"
and tolls =
flag "tolls" (optional json_arg) ~doc:"JSON RouteTollOptions"
and traffic =
flag "traffic" (optional json_arg) ~doc:"JSON RouteTrafficOptions"
and travelMode =
flag "travel-mode" (optional json_arg) ~doc:"JSON RouteTravelMode"
and travelModeOptions =
flag "travel-mode-options" (optional json_arg)
~doc:"JSON RouteTravelModeOptions"
and travelStepType =
flag "travel-step-type" (optional json_arg)
~doc:"JSON RouteTravelStepType"
and waypoints =
flag "waypoints" (optional json_arg) ~doc:"JSON RouteWaypointList"
and destination =
flag "destination" (required json_arg) ~doc:"JSON Position"
and origin = flag "origin" (required json_arg) ~doc:"JSON Position" in
fun () ->
call ?endpoint_url ?profile:cli_profile ?region:cli_region
Io.calculate_routes
(Values.CalculateRoutesRequest.make
?allow:(Option.map ~f:Values.RouteAllowOptions.of_json allow)
?arrivalTime
?avoid:(Option.map ~f:Values.RouteAvoidanceOptions.of_json
avoid) ?departNow ?departureTime
?destinationOptions:(Option.map
~f:Values.RouteDestinationOptions.of_json
destinationOptions)
?driver:(Option.map ~f:Values.RouteDriverOptions.of_json driver)
?exclude:(Option.map ~f:Values.RouteExclusionOptions.of_json
exclude)
?instructionsMeasurementSystem:(Option.map
~f:Values.MeasurementSystem.of_json
instructionsMeasurementSystem)
?key
?languages:(Option.map
~f:Values.CalculateRoutesRequestLanguagesList.of_json
languages)
?legAdditionalFeatures:(Option.map
~f:Values.RouteLegAdditionalFeatureList.of_json
legAdditionalFeatures)
?legGeometryFormat:(Option.map ~f:Values.GeometryFormat.of_json
legGeometryFormat) ?maxAlternatives
?optimizeRoutingFor:(Option.map
~f:Values.RoutingObjective.of_json
optimizeRoutingFor)
?originOptions:(Option.map ~f:Values.RouteOriginOptions.of_json
originOptions)
?spanAdditionalFeatures:(Option.map
~f:Values.RouteSpanAdditionalFeatureList.of_json
spanAdditionalFeatures)
?tolls:(Option.map ~f:Values.RouteTollOptions.of_json tolls)
?traffic:(Option.map ~f:Values.RouteTrafficOptions.of_json
traffic)
?travelMode:(Option.map ~f:Values.RouteTravelMode.of_json
travelMode)
?travelModeOptions:(Option.map
~f:Values.RouteTravelModeOptions.of_json
travelModeOptions)
?travelStepType:(Option.map
~f:Values.RouteTravelStepType.of_json
travelStepType)
?waypoints:(Option.map ~f:Values.RouteWaypointList.of_json
waypoints)
~destination:(Values.Position.of_json destination)
~origin:(Values.Position.of_json origin) ())
(Some Values.CalculateRoutesResponse.to_json)
(Some Values.CalculateRoutesResponse.error_to_json)])
let optimize_waypoints =
Command.async ~summary:""
([%map_open.Command
let cli_profile =
flag "-cli-profile" (optional string) ~doc:"NAME aws profile to use"
and cli_region =
flag "-cli-region" (optional string) ~doc:"REGION override region"
and endpoint_url =
flag "-endpoint-url" (optional string)
~doc:"URL override endpoint url"
and avoid =
flag "avoid" (optional json_arg)
~doc:"JSON WaypointOptimizationAvoidanceOptions"
and clustering =
flag "clustering" (optional json_arg)
~doc:"JSON WaypointOptimizationClusteringOptions"
and departureTime =
flag "departure-time" (optional string)
~doc:"STRING TimestampWithTimezoneOffset"
and destination =
flag "destination" (optional json_arg) ~doc:"JSON Position"
and destinationOptions =
flag "destination-options" (optional json_arg)
~doc:"JSON WaypointOptimizationDestinationOptions"
and driver =
flag "driver" (optional json_arg)
~doc:"JSON WaypointOptimizationDriverOptions"
and exclude =
flag "exclude" (optional json_arg)
~doc:"JSON WaypointOptimizationExclusionOptions"
and key = flag "key" (optional string) ~doc:"STRING ApiKey"
and optimizeSequencingFor =
flag "optimize-sequencing-for" (optional json_arg)
~doc:"JSON WaypointOptimizationSequencingObjective"
and originOptions =
flag "origin-options" (optional json_arg)
~doc:"JSON WaypointOptimizationOriginOptions"
and traffic =
flag "traffic" (optional json_arg)
~doc:"JSON WaypointOptimizationTrafficOptions"
and travelMode =
flag "travel-mode" (optional json_arg)
~doc:"JSON WaypointOptimizationTravelMode"
and travelModeOptions =
flag "travel-mode-options" (optional json_arg)
~doc:"JSON WaypointOptimizationTravelModeOptions"
and waypoints =
flag "waypoints" (optional json_arg)
~doc:"JSON WaypointOptimizationWaypointList"
and origin = flag "origin" (required json_arg) ~doc:"JSON Position" in
fun () ->
call ?endpoint_url ?profile:cli_profile ?region:cli_region
Io.optimize_waypoints
(Values.OptimizeWaypointsRequest.make
?avoid:(Option.map
~f:Values.WaypointOptimizationAvoidanceOptions.of_json
avoid)
?clustering:(Option.map
~f:Values.WaypointOptimizationClusteringOptions.of_json
clustering) ?departureTime
?destination:(Option.map ~f:Values.Position.of_json destination)
?destinationOptions:(Option.map
~f:Values.WaypointOptimizationDestinationOptions.of_json
destinationOptions)
?driver:(Option.map
~f:Values.WaypointOptimizationDriverOptions.of_json
driver)
?exclude:(Option.map
~f:Values.WaypointOptimizationExclusionOptions.of_json
exclude) ?key
?optimizeSequencingFor:(Option.map
~f:Values.WaypointOptimizationSequencingObjective.of_json
optimizeSequencingFor)
?originOptions:(Option.map
~f:Values.WaypointOptimizationOriginOptions.of_json
originOptions)
?traffic:(Option.map
~f:Values.WaypointOptimizationTrafficOptions.of_json
traffic)
?travelMode:(Option.map
~f:Values.WaypointOptimizationTravelMode.of_json
travelMode)
?travelModeOptions:(Option.map
~f:Values.WaypointOptimizationTravelModeOptions.of_json
travelModeOptions)
?waypoints:(Option.map
~f:Values.WaypointOptimizationWaypointList.of_json
waypoints)
~origin:(Values.Position.of_json origin) ())
(Some Values.OptimizeWaypointsResponse.to_json)
(Some Values.OptimizeWaypointsResponse.error_to_json)])
let snap_to_roads =
Command.async ~summary:""
([%map_open.Command
let cli_profile =
flag "-cli-profile" (optional string) ~doc:"NAME aws profile to use"
and cli_region =
flag "-cli-region" (optional string) ~doc:"REGION override region"
and endpoint_url =
flag "-endpoint-url" (optional string)
~doc:"URL override endpoint url"
and key = flag "key" (optional string) ~doc:"STRING ApiKey"
and snappedGeometryFormat =
flag "snapped-geometry-format" (optional json_arg)
~doc:"JSON GeometryFormat"
and snapRadius =
flag "snap-radius" (optional json_arg)
~doc:"JSON SnapToRoadsRequestSnapRadiusLong"
and travelMode =
flag "travel-mode" (optional json_arg)
~doc:"JSON RoadSnapTravelMode"
and travelModeOptions =
flag "travel-mode-options" (optional json_arg)
~doc:"JSON RoadSnapTravelModeOptions"
and tracePoints =
flag "trace-points" (required json_arg)
~doc:"JSON SnapToRoadsRequestTracePointsList" in
fun () ->
call ?endpoint_url ?profile:cli_profile ?region:cli_region
Io.snap_to_roads
(Values.SnapToRoadsRequest.make ?key
?snappedGeometryFormat:(Option.map
~f:Values.GeometryFormat.of_json
snappedGeometryFormat)
?snapRadius:(Option.map
~f:Values.SnapToRoadsRequestSnapRadiusLong.of_json
snapRadius)
?travelMode:(Option.map ~f:Values.RoadSnapTravelMode.of_json
travelMode)
?travelModeOptions:(Option.map
~f:Values.RoadSnapTravelModeOptions.of_json
travelModeOptions)
~tracePoints:(Values.SnapToRoadsRequestTracePointsList.of_json
tracePoints) ())
(Some Values.SnapToRoadsResponse.to_json)
(Some Values.SnapToRoadsResponse.error_to_json)])
let main =
Command.group
~summary:((Awso.Service.to_string Values.service) ^ " commands")
[("calculate-isolines", calculate_isolines);
("calculate-route-matrix", calculate_route_matrix);
("calculate-routes", calculate_routes);
("optimize-waypoints", optimize_waypoints);
("snap-to-roads", snap_to_roads)]