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
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 get_clip =
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 streamName =
flag "stream-name" (optional string) ~doc:"STRING StreamName"
and streamARN =
flag "stream-a-r-n" (optional string) ~doc:"STRING ResourceARN"
and clipFragmentSelector =
flag "clip-fragment-selector" (required json_arg)
~doc:"JSON ClipFragmentSelector" in
fun () ->
call ?endpoint_url ?profile:cli_profile ?region:cli_region
Io.get_clip
(Values.GetClipInput.make ?streamName ?streamARN
~clipFragmentSelector:(Values.ClipFragmentSelector.of_json
clipFragmentSelector) ())
(Some Values.GetClipOutput.to_json)
(Some Values.GetClipOutput.error_to_json)])
let get_d_a_s_h_streaming_session_u_r_l =
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 streamName =
flag "stream-name" (optional string) ~doc:"STRING StreamName"
and streamARN =
flag "stream-a-r-n" (optional string) ~doc:"STRING ResourceARN"
and playbackMode =
flag "playback-mode" (optional json_arg)
~doc:"JSON DASHPlaybackMode"
and displayFragmentTimestamp =
flag "display-fragment-timestamp" (optional json_arg)
~doc:"JSON DASHDisplayFragmentTimestamp"
and displayFragmentNumber =
flag "display-fragment-number" (optional json_arg)
~doc:"JSON DASHDisplayFragmentNumber"
and dASHFragmentSelector =
flag "d-a-s-h-fragment-selector" (optional json_arg)
~doc:"JSON DASHFragmentSelector"
and expires = flag "expires" (optional int) ~doc:"INT Expires"
and maxManifestFragmentResults =
flag "max-manifest-fragment-results" (optional json_arg)
~doc:"JSON DASHMaxResults" in
fun () ->
call ?endpoint_url ?profile:cli_profile ?region:cli_region
Io.get_d_a_s_h_streaming_session_u_r_l
(Values.GetDASHStreamingSessionURLInput.make ?streamName
?streamARN
?playbackMode:(Option.map ~f:Values.DASHPlaybackMode.of_json
playbackMode)
?displayFragmentTimestamp:(Option.map
~f:Values.DASHDisplayFragmentTimestamp.of_json
displayFragmentTimestamp)
?displayFragmentNumber:(Option.map
~f:Values.DASHDisplayFragmentNumber.of_json
displayFragmentNumber)
?dASHFragmentSelector:(Option.map
~f:Values.DASHFragmentSelector.of_json
dASHFragmentSelector) ?expires
?maxManifestFragmentResults:(Option.map
~f:Values.DASHMaxResults.of_json
maxManifestFragmentResults) ())
(Some Values.GetDASHStreamingSessionURLOutput.to_json)
(Some Values.GetDASHStreamingSessionURLOutput.error_to_json)])
let get_h_l_s_streaming_session_u_r_l =
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 streamName =
flag "stream-name" (optional string) ~doc:"STRING StreamName"
and streamARN =
flag "stream-a-r-n" (optional string) ~doc:"STRING ResourceARN"
and playbackMode =
flag "playback-mode" (optional json_arg) ~doc:"JSON HLSPlaybackMode"
and hLSFragmentSelector =
flag "h-l-s-fragment-selector" (optional json_arg)
~doc:"JSON HLSFragmentSelector"
and containerFormat =
flag "container-format" (optional json_arg)
~doc:"JSON ContainerFormat"
and discontinuityMode =
flag "discontinuity-mode" (optional json_arg)
~doc:"JSON HLSDiscontinuityMode"
and displayFragmentTimestamp =
flag "display-fragment-timestamp" (optional json_arg)
~doc:"JSON HLSDisplayFragmentTimestamp"
and expires = flag "expires" (optional int) ~doc:"INT Expires"
and maxMediaPlaylistFragmentResults =
flag "max-media-playlist-fragment-results" (optional json_arg)
~doc:"JSON HLSMaxResults" in
fun () ->
call ?endpoint_url ?profile:cli_profile ?region:cli_region
Io.get_h_l_s_streaming_session_u_r_l
(Values.GetHLSStreamingSessionURLInput.make ?streamName ?streamARN
?playbackMode:(Option.map ~f:Values.HLSPlaybackMode.of_json
playbackMode)
?hLSFragmentSelector:(Option.map
~f:Values.HLSFragmentSelector.of_json
hLSFragmentSelector)
?containerFormat:(Option.map ~f:Values.ContainerFormat.of_json
containerFormat)
?discontinuityMode:(Option.map
~f:Values.HLSDiscontinuityMode.of_json
discontinuityMode)
?displayFragmentTimestamp:(Option.map
~f:Values.HLSDisplayFragmentTimestamp.of_json
displayFragmentTimestamp) ?expires
?maxMediaPlaylistFragmentResults:(Option.map
~f:Values.HLSMaxResults.of_json
maxMediaPlaylistFragmentResults)
()) (Some Values.GetHLSStreamingSessionURLOutput.to_json)
(Some Values.GetHLSStreamingSessionURLOutput.error_to_json)])
let get_images =
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 streamName =
flag "stream-name" (optional string) ~doc:"STRING StreamName"
and streamARN =
flag "stream-a-r-n" (optional string) ~doc:"STRING ResourceARN"
and samplingInterval =
flag "sampling-interval" (optional int) ~doc:"INT SamplingInterval"
and formatConfig =
flag "format-config" (optional json_arg) ~doc:"JSON FormatConfig"
and widthPixels =
flag "width-pixels" (optional int) ~doc:"INT WidthPixels"
and heightPixels =
flag "height-pixels" (optional int) ~doc:"INT HeightPixels"
and maxResults =
flag "max-results" (optional json_arg)
~doc:"JSON GetImagesMaxResults"
and nextToken =
flag "next-token" (optional string) ~doc:"STRING NextToken"
and imageSelectorType =
flag "image-selector-type" (required json_arg)
~doc:"JSON ImageSelectorType"
and startTimestamp =
flag "start-timestamp" (required json_arg) ~doc:"JSON Timestamp"
and endTimestamp =
flag "end-timestamp" (required json_arg) ~doc:"JSON Timestamp"
and format = flag "format" (required json_arg) ~doc:"JSON Format" in
fun () ->
call ?endpoint_url ?profile:cli_profile ?region:cli_region
Io.get_images
(Values.GetImagesInput.make ?streamName ?streamARN
?samplingInterval
?formatConfig:(Option.map ~f:Values.FormatConfig.of_json
formatConfig) ?widthPixels ?heightPixels
?maxResults:(Option.map ~f:Values.GetImagesMaxResults.of_json
maxResults) ?nextToken
~imageSelectorType:(Values.ImageSelectorType.of_json
imageSelectorType)
~startTimestamp:(Values.Timestamp.of_json startTimestamp)
~endTimestamp:(Values.Timestamp.of_json endTimestamp)
~format:(Values.Format_.of_json format) ())
(Some Values.GetImagesOutput.to_json)
(Some Values.GetImagesOutput.error_to_json)])
let get_media_for_fragment_list =
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 streamName =
flag "stream-name" (optional string) ~doc:"STRING StreamName"
and streamARN =
flag "stream-a-r-n" (optional string) ~doc:"STRING ResourceARN"
and fragments =
flag "fragments" (required json_arg) ~doc:"JSON FragmentNumberList" in
fun () ->
call ?endpoint_url ?profile:cli_profile ?region:cli_region
Io.get_media_for_fragment_list
(Values.GetMediaForFragmentListInput.make ?streamName ?streamARN
~fragments:(Values.FragmentNumberList.of_json fragments) ())
(Some Values.GetMediaForFragmentListOutput.to_json)
(Some Values.GetMediaForFragmentListOutput.error_to_json)])
let list_fragments =
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 streamName =
flag "stream-name" (optional string) ~doc:"STRING StreamName"
and streamARN =
flag "stream-a-r-n" (optional string) ~doc:"STRING ResourceARN"
and maxResults =
flag "max-results" (optional json_arg)
~doc:"JSON ListFragmentsMaxResults"
and nextToken =
flag "next-token" (optional string) ~doc:"STRING NextToken"
and fragmentSelector =
flag "fragment-selector" (optional json_arg)
~doc:"JSON FragmentSelector" in
fun () ->
call ?endpoint_url ?profile:cli_profile ?region:cli_region
Io.list_fragments
(Values.ListFragmentsInput.make ?streamName ?streamARN
?maxResults:(Option.map
~f:Values.ListFragmentsMaxResults.of_json
maxResults) ?nextToken
?fragmentSelector:(Option.map
~f:Values.FragmentSelector.of_json
fragmentSelector) ())
(Some Values.ListFragmentsOutput.to_json)
(Some Values.ListFragmentsOutput.error_to_json)])
let main =
Command.group
~summary:((Awso.Service.to_string Values.service) ^ " commands")
[("get-clip", get_clip);
("get-d-a-s-h-streaming-session-u-r-l",
get_d_a_s_h_streaming_session_u_r_l);
("get-h-l-s-streaming-session-u-r-l", get_h_l_s_streaming_session_u_r_l);
("get-images", get_images);
("get-media-for-fragment-list", get_media_for_fragment_list);
("list-fragments", list_fragments)]