Source file cli.ml

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
(* generated by: awso-codegen generate-all --botocore-data vendor/botocore/botocore/data -o aws --runtime-dir lib/runtime/awso --cli-dir awso-cli *)
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 delete_lexicon =
  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 name = flag "name" (required string) ~doc:"STRING LexiconName" in
       fun () ->
         call ?endpoint_url ?profile:cli_profile ?region:cli_region
           Io.delete_lexicon (Values.DeleteLexiconInput.make ~name ())
           (Some Values.DeleteLexiconOutput.to_json)
           (Some Values.DeleteLexiconOutput.error_to_json)])
let describe_voices =
  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 engine = flag "engine" (optional json_arg) ~doc:"JSON Engine"
       and languageCode =
         flag "language-code" (optional json_arg) ~doc:"JSON LanguageCode"
       and includeAdditionalLanguageCodes =
         flag "include-additional-language-codes" (optional bool)
           ~doc:"BOOL IncludeAdditionalLanguageCodes"
       and nextToken =
         flag "next-token" (optional string) ~doc:"STRING NextToken" in
       fun () ->
         call ?endpoint_url ?profile:cli_profile ?region:cli_region
           Io.describe_voices
           (Values.DescribeVoicesInput.make
              ?engine:(Option.map ~f:Values.Engine.of_json engine)
              ?languageCode:(Option.map ~f:Values.LanguageCode.of_json
                               languageCode) ?includeAdditionalLanguageCodes
              ?nextToken ()) (Some Values.DescribeVoicesOutput.to_json)
           (Some Values.DescribeVoicesOutput.error_to_json)])
let get_lexicon =
  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 name = flag "name" (required string) ~doc:"STRING LexiconName" in
       fun () ->
         call ?endpoint_url ?profile:cli_profile ?region:cli_region
           Io.get_lexicon (Values.GetLexiconInput.make ~name ())
           (Some Values.GetLexiconOutput.to_json)
           (Some Values.GetLexiconOutput.error_to_json)])
let get_speech_synthesis_task =
  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 taskId = flag "task-id" (required string) ~doc:"STRING TaskId" in
       fun () ->
         call ?endpoint_url ?profile:cli_profile ?region:cli_region
           Io.get_speech_synthesis_task
           (Values.GetSpeechSynthesisTaskInput.make ~taskId ())
           (Some Values.GetSpeechSynthesisTaskOutput.to_json)
           (Some Values.GetSpeechSynthesisTaskOutput.error_to_json)])
let list_lexicons =
  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 nextToken =
         flag "next-token" (optional string) ~doc:"STRING NextToken" in
       fun () ->
         call ?endpoint_url ?profile:cli_profile ?region:cli_region
           Io.list_lexicons (Values.ListLexiconsInput.make ?nextToken ())
           (Some Values.ListLexiconsOutput.to_json)
           (Some Values.ListLexiconsOutput.error_to_json)])
let list_speech_synthesis_tasks =
  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 maxResults =
         flag "max-results" (optional int) ~doc:"INT MaxResults"
       and nextToken =
         flag "next-token" (optional string) ~doc:"STRING NextToken"
       and status = flag "status" (optional json_arg) ~doc:"JSON TaskStatus" in
       fun () ->
         call ?endpoint_url ?profile:cli_profile ?region:cli_region
           Io.list_speech_synthesis_tasks
           (Values.ListSpeechSynthesisTasksInput.make ?maxResults ?nextToken
              ?status:(Option.map ~f:Values.TaskStatus.of_json status) ())
           (Some Values.ListSpeechSynthesisTasksOutput.to_json)
           (Some Values.ListSpeechSynthesisTasksOutput.error_to_json)])
let put_lexicon =
  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 name = flag "name" (required string) ~doc:"STRING LexiconName"
       and content =
         flag "content" (required string) ~doc:"STRING LexiconContent" in
       fun () ->
         call ?endpoint_url ?profile:cli_profile ?region:cli_region
           Io.put_lexicon (Values.PutLexiconInput.make ~name ~content ())
           (Some Values.PutLexiconOutput.to_json)
           (Some Values.PutLexiconOutput.error_to_json)])
let start_speech_synthesis_stream =
  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 languageCode =
         flag "language-code" (optional json_arg) ~doc:"JSON LanguageCode"
       and lexiconNames =
         flag "lexicon-names" (optional json_arg) ~doc:"JSON LexiconNameList"
       and sampleRate =
         flag "sample-rate" (optional string) ~doc:"STRING SampleRate"
       and actionStream =
         flag "action-stream" (optional json_arg)
           ~doc:"JSON StartSpeechSynthesisStreamActionStream"
       and engine = flag "engine" (required json_arg) ~doc:"JSON Engine"
       and outputFormat =
         flag "output-format" (required json_arg) ~doc:"JSON OutputFormat"
       and voiceId = flag "voice-id" (required json_arg) ~doc:"JSON VoiceId" in
       fun () ->
         call ?endpoint_url ?profile:cli_profile ?region:cli_region
           Io.start_speech_synthesis_stream
           (Values.StartSpeechSynthesisStreamInput.make
              ?languageCode:(Option.map ~f:Values.LanguageCode.of_json
                               languageCode)
              ?lexiconNames:(Option.map ~f:Values.LexiconNameList.of_json
                               lexiconNames) ?sampleRate
              ?actionStream:(Option.map
                               ~f:Values.StartSpeechSynthesisStreamActionStream.of_json
                               actionStream)
              ~engine:(Values.Engine.of_json engine)
              ~outputFormat:(Values.OutputFormat.of_json outputFormat)
              ~voiceId:(Values.VoiceId.of_json voiceId) ())
           (Some Values.StartSpeechSynthesisStreamOutput.to_json)
           (Some Values.StartSpeechSynthesisStreamOutput.error_to_json)])
let start_speech_synthesis_task =
  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 engine = flag "engine" (optional json_arg) ~doc:"JSON Engine"
       and languageCode =
         flag "language-code" (optional json_arg) ~doc:"JSON LanguageCode"
       and lexiconNames =
         flag "lexicon-names" (optional json_arg) ~doc:"JSON LexiconNameList"
       and outputS3KeyPrefix =
         flag "output-s3-key-prefix" (optional string)
           ~doc:"STRING OutputS3KeyPrefix"
       and sampleRate =
         flag "sample-rate" (optional string) ~doc:"STRING SampleRate"
       and snsTopicArn =
         flag "sns-topic-arn" (optional string) ~doc:"STRING SnsTopicArn"
       and speechMarkTypes =
         flag "speech-mark-types" (optional json_arg)
           ~doc:"JSON SpeechMarkTypeList"
       and textType =
         flag "text-type" (optional json_arg) ~doc:"JSON TextType"
       and outputFormat =
         flag "output-format" (required json_arg) ~doc:"JSON OutputFormat"
       and outputS3BucketName =
         flag "output-s3-bucket-name" (required string)
           ~doc:"STRING OutputS3BucketName"
       and text = flag "text" (required string) ~doc:"STRING Text"
       and voiceId = flag "voice-id" (required json_arg) ~doc:"JSON VoiceId" in
       fun () ->
         call ?endpoint_url ?profile:cli_profile ?region:cli_region
           Io.start_speech_synthesis_task
           (Values.StartSpeechSynthesisTaskInput.make
              ?engine:(Option.map ~f:Values.Engine.of_json engine)
              ?languageCode:(Option.map ~f:Values.LanguageCode.of_json
                               languageCode)
              ?lexiconNames:(Option.map ~f:Values.LexiconNameList.of_json
                               lexiconNames) ?outputS3KeyPrefix ?sampleRate
              ?snsTopicArn
              ?speechMarkTypes:(Option.map
                                  ~f:Values.SpeechMarkTypeList.of_json
                                  speechMarkTypes)
              ?textType:(Option.map ~f:Values.TextType.of_json textType)
              ~outputFormat:(Values.OutputFormat.of_json outputFormat)
              ~outputS3BucketName ~text
              ~voiceId:(Values.VoiceId.of_json voiceId) ())
           (Some Values.StartSpeechSynthesisTaskOutput.to_json)
           (Some Values.StartSpeechSynthesisTaskOutput.error_to_json)])
let synthesize_speech =
  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 engine = flag "engine" (optional json_arg) ~doc:"JSON Engine"
       and languageCode =
         flag "language-code" (optional json_arg) ~doc:"JSON LanguageCode"
       and lexiconNames =
         flag "lexicon-names" (optional json_arg) ~doc:"JSON LexiconNameList"
       and sampleRate =
         flag "sample-rate" (optional string) ~doc:"STRING SampleRate"
       and speechMarkTypes =
         flag "speech-mark-types" (optional json_arg)
           ~doc:"JSON SpeechMarkTypeList"
       and textType =
         flag "text-type" (optional json_arg) ~doc:"JSON TextType"
       and outputFormat =
         flag "output-format" (required json_arg) ~doc:"JSON OutputFormat"
       and text = flag "text" (required string) ~doc:"STRING Text"
       and voiceId = flag "voice-id" (required json_arg) ~doc:"JSON VoiceId" in
       fun () ->
         call ?endpoint_url ?profile:cli_profile ?region:cli_region
           Io.synthesize_speech
           (Values.SynthesizeSpeechInput.make
              ?engine:(Option.map ~f:Values.Engine.of_json engine)
              ?languageCode:(Option.map ~f:Values.LanguageCode.of_json
                               languageCode)
              ?lexiconNames:(Option.map ~f:Values.LexiconNameList.of_json
                               lexiconNames) ?sampleRate
              ?speechMarkTypes:(Option.map
                                  ~f:Values.SpeechMarkTypeList.of_json
                                  speechMarkTypes)
              ?textType:(Option.map ~f:Values.TextType.of_json textType)
              ~outputFormat:(Values.OutputFormat.of_json outputFormat) ~text
              ~voiceId:(Values.VoiceId.of_json voiceId) ())
           (Some Values.SynthesizeSpeechOutput.to_json)
           (Some Values.SynthesizeSpeechOutput.error_to_json)])
let main =
  Command.group
    ~summary:((Awso.Service.to_string Values.service) ^ " commands")
    [("delete-lexicon", delete_lexicon);
    ("describe-voices", describe_voices);
    ("get-lexicon", get_lexicon);
    ("get-speech-synthesis-task", get_speech_synthesis_task);
    ("list-lexicons", list_lexicons);
    ("list-speech-synthesis-tasks", list_speech_synthesis_tasks);
    ("put-lexicon", put_lexicon);
    ("start-speech-synthesis-stream", start_speech_synthesis_stream);
    ("start-speech-synthesis-task", start_speech_synthesis_task);
    ("synthesize-speech", synthesize_speech)]