cielo24-cli 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/cielo24cli +15 -0
- data/lib/cielo24_cli.rb +4 -0
- data/lib/{cielo24_command → cielo24_cli}/application.rb +391 -403
- data/lib/cielo24_cli/version.rb +3 -0
- metadata +34 -24
- checksums.yaml +0 -7
- data/bin/cielo24 +0 -15
- data/lib/cielo24_command.rb +0 -4
- data/lib/cielo24_command/version.rb +0 -3
data/bin/cielo24cli
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'cielo24'
|
4
|
+
require_relative '../lib/cielo24_cli/application'
|
5
|
+
include Cielo24Cli
|
6
|
+
|
7
|
+
begin
|
8
|
+
Application.start(ARGV)
|
9
|
+
rescue ArgumentError => e
|
10
|
+
puts 'ERROR: ' + e.message
|
11
|
+
exit(1)
|
12
|
+
rescue Cielo24::WebError => e
|
13
|
+
puts 'ERROR: ' + e.message
|
14
|
+
exit(1)
|
15
|
+
end
|
data/lib/cielo24_cli.rb
ADDED
@@ -1,404 +1,392 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
require 'thor'
|
4
|
-
require 'cielo24'
|
5
|
-
|
6
|
-
class Application < Thor
|
7
|
-
|
8
|
-
include Cielo24
|
9
|
-
|
10
|
-
ENV[
|
11
|
-
|
12
|
-
# ALWAYS REQUIRED:
|
13
|
-
username_option = [:u, :required => false, :desc =>
|
14
|
-
password_option = [:p, :required => false, :desc =>
|
15
|
-
securekey_option = [:k, :required => false, :desc =>
|
16
|
-
api_token_option = [:N, :required => false, :desc =>
|
17
|
-
server_url_option =[:s, :required => false, :desc =>
|
18
|
-
# JOB CONTROL:
|
19
|
-
job_id_option = [:j, :required => true, :desc =>
|
20
|
-
media_url_option = [:m, :required => false, :desc =>
|
21
|
-
media_file_option = [:M, :required => false, :desc =>
|
22
|
-
# OTHER OPTIONS:
|
23
|
-
header_option = [:H, :required => false, :desc =>
|
24
|
-
fidelity_option = [:f, :required => false, :desc =>
|
25
|
-
priority_option = [:P, :required => false, :desc =>
|
26
|
-
source_language_option = [:l, :required => false, :desc =>
|
27
|
-
target_language_option = [:t, :required => false, :desc =>
|
28
|
-
job_name_option = [:n, :required => false, :desc =>
|
29
|
-
job_options_option = [:J, :required => false, :desc =>
|
30
|
-
caption_options_option = [:O, :required => false, :desc =>
|
31
|
-
turn_around_hours_option = [:T, :required => false, :desc =>
|
32
|
-
callback_url_option = [:C, :required => false, :desc =>
|
33
|
-
caption_format_option = [:c, :required => false, :desc =>
|
34
|
-
elementlist_version_option = [:e, :required => false, :desc =>
|
35
|
-
force_new_option = [:F, :required => false, :desc =>
|
36
|
-
new_password_option = [:d, :required => true, :desc =>
|
37
|
-
verbose_option = [:v, :require => false, :desc =>
|
38
|
-
|
39
|
-
class_option *server_url_option # Server URL can be specified for any action
|
40
|
-
class_option *verbose_option # Verbose mode can be specified for any action
|
41
|
-
|
42
|
-
desc
|
43
|
-
option :u, :required => true, :desc =>
|
44
|
-
option :p, :required => false, :desc =>
|
45
|
-
option :k, :required => false, :desc =>
|
46
|
-
option *header_option
|
47
|
-
def login
|
48
|
-
puts
|
49
|
-
actions = initialize_actions
|
50
|
-
token = actions.login(options[:u], options[:p], options[:k], options[:h])
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
actions
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
option *
|
67
|
-
option *
|
68
|
-
option *
|
69
|
-
option *
|
70
|
-
option *
|
71
|
-
option *
|
72
|
-
option *
|
73
|
-
option *
|
74
|
-
|
75
|
-
option *
|
76
|
-
|
77
|
-
option *
|
78
|
-
option *
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
puts
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
task_id = actions.
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
option *
|
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
|
-
option *
|
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
|
-
option *
|
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
|
-
option *
|
274
|
-
|
275
|
-
option *
|
276
|
-
option *
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
option *
|
291
|
-
option *
|
292
|
-
option *
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
puts
|
300
|
-
end
|
301
|
-
|
302
|
-
desc
|
303
|
-
option
|
304
|
-
# always required (hidden)
|
305
|
-
option *username_option
|
306
|
-
option *password_option
|
307
|
-
option *securekey_option
|
308
|
-
option *api_token_option
|
309
|
-
def
|
310
|
-
puts
|
311
|
-
actions = initialize_actions
|
312
|
-
token = get_token(actions)
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
option *
|
322
|
-
option *
|
323
|
-
option *
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
token
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
option *
|
336
|
-
|
337
|
-
option *
|
338
|
-
option *
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
puts "
|
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
|
-
def get_token(actions)
|
394
|
-
return (options[:N].nil?) ? private_login(actions, options[:u], options[:p], options[:k]) : options[:N]
|
395
|
-
end
|
396
|
-
|
397
|
-
def print_url
|
398
|
-
if(options[:v])
|
399
|
-
puts WebUtils.LAST_URL
|
400
|
-
end
|
401
|
-
end
|
402
|
-
}
|
403
|
-
end
|
1
|
+
module Cielo24Cli
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require 'cielo24'
|
5
|
+
|
6
|
+
class Application < Thor
|
7
|
+
|
8
|
+
include Cielo24
|
9
|
+
|
10
|
+
ENV['THOR_COLUMNS'] = '300' # Increases the maximum allowed length of a console line, otherwise descriptions/help gets truncated (...)
|
11
|
+
|
12
|
+
# ALWAYS REQUIRED:
|
13
|
+
username_option = [:u, :required => false, :desc => 'cielo24 username', :type => :string, :banner => 'username', :hide => true]
|
14
|
+
password_option = [:p, :required => false, :desc => 'cielo24 password', :banner => 'password', :hide => true]
|
15
|
+
securekey_option = [:k, :required => false, :desc => 'The API Secure Key', :banner => 'securekey', :hide => true]
|
16
|
+
api_token_option = [:N, :required => false, :desc => 'The API token of the current session', :banner => 'token', :hide => true]
|
17
|
+
server_url_option =[:s, :required => false, :desc => 'cielo24 server URL [https://api.cielo24.com]', :banner => 'server_url', :hide => true, :default => 'http://api.cielo24.com']
|
18
|
+
# JOB CONTROL:
|
19
|
+
job_id_option = [:j, :required => true, :desc => 'Job Id', :banner => 'jobid']
|
20
|
+
media_url_option = [:m, :required => false, :desc => 'Media URL', :banner => 'mediaurl']
|
21
|
+
media_file_option = [:M, :required => false, :desc => 'Local media file', :banner => 'filepath']
|
22
|
+
# OTHER OPTIONS:
|
23
|
+
header_option = [:H, :required => false, :desc => 'Use headers', :default => false, :type => :boolean]
|
24
|
+
fidelity_option = [:f, :required => false, :desc => 'Fidelity ' + Fidelity.all.join(', '), :banner => 'fidelity', :default => Fidelity::PREMIUM]
|
25
|
+
priority_option = [:P, :required => false, :desc => 'Priority ' + Priority.all.join(', '), :banner => 'priority', :default => Priority::STANDARD]
|
26
|
+
source_language_option = [:l, :required => false, :desc => 'Source language ' + Language.all.join(', '), :banner => 'source', :default => Language::ENGLISH]
|
27
|
+
target_language_option = [:t, :required => false, :desc => 'Target language ' + Language.all.join(', '), :banner => 'target', :default => Language::ENGLISH]
|
28
|
+
job_name_option = [:n, :required => false, :desc => 'Job name', :banner => 'jobname']
|
29
|
+
job_options_option = [:J, :required => false, :desc => 'Job option (list key:value pairs after -J)', :banner => 'key:value', :type => :hash, :default => {}]
|
30
|
+
caption_options_option = [:O, :required => false, :desc => 'Caption/transcript options (list key:value pairs after -O)', :banner => 'key:value', :type => :hash, :default => {}]
|
31
|
+
turn_around_hours_option = [:T, :required => false, :desc => 'Turn around hours', :banner => 'hours']
|
32
|
+
callback_url_option = [:C, :required => false, :desc => 'Callback URL', :banner => 'callback']
|
33
|
+
caption_format_option = [:c, :required => false, :desc => 'Caption format ' + CaptionFormat.all.join(', '), :banner => 'format', :default => CaptionFormat::SRT]
|
34
|
+
elementlist_version_option = [:e, :required => false, :desc => 'ElementList Version', :banner => 'version']
|
35
|
+
force_new_option = [:F, :required => false, :desc => 'Force new key', :default => false]
|
36
|
+
new_password_option = [:d, :required => true, :desc => 'New password', :banner => 'newpass']
|
37
|
+
verbose_option = [:v, :require => false, :desc => 'Verbose mode', :hide => true, :default => false, :type => :boolean]
|
38
|
+
|
39
|
+
class_option *server_url_option # Server URL can be specified for any action
|
40
|
+
class_option *verbose_option # Verbose mode can be specified for any action
|
41
|
+
|
42
|
+
desc 'login', 'Performs a login action'
|
43
|
+
option :u, :required => true, :desc => 'cielo24 username', :type => :string, :banner => 'username'
|
44
|
+
option :p, :required => false, :desc => 'cielo24 password', :banner => 'password'
|
45
|
+
option :k, :required => false, :desc => 'The API Secure Key', :banner => 'securekey'
|
46
|
+
option *header_option
|
47
|
+
def login
|
48
|
+
puts 'Performing a login action...'
|
49
|
+
actions = initialize_actions
|
50
|
+
token = actions.login(options[:u], options[:p], options[:k], options[:h])
|
51
|
+
puts 'API token: ' + token
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'logout', 'Performs a logout action'
|
55
|
+
option :N, :required => true, :desc => 'The API token of the current session', :banner => 'token'
|
56
|
+
def logout
|
57
|
+
puts 'Performing a logout action...'
|
58
|
+
actions = initialize_actions
|
59
|
+
actions.logout(options[:N])
|
60
|
+
puts 'Logged out successfully'
|
61
|
+
end
|
62
|
+
|
63
|
+
desc 'create', 'Creates a job'
|
64
|
+
option *fidelity_option
|
65
|
+
option *priority_option
|
66
|
+
option *source_language_option
|
67
|
+
option *target_language_option
|
68
|
+
option *media_url_option
|
69
|
+
option *media_file_option
|
70
|
+
option *job_name_option
|
71
|
+
option *job_options_option
|
72
|
+
option *turn_around_hours_option
|
73
|
+
option *callback_url_option
|
74
|
+
# always required (hidden)
|
75
|
+
option *username_option
|
76
|
+
option *password_option
|
77
|
+
option *securekey_option
|
78
|
+
option *api_token_option
|
79
|
+
def create
|
80
|
+
|
81
|
+
if options[:m].nil? and options[:M].nil?
|
82
|
+
puts 'Media URL or local file path must be supplied'
|
83
|
+
exit(1)
|
84
|
+
end
|
85
|
+
|
86
|
+
puts 'Creating job...'
|
87
|
+
actions = initialize_actions
|
88
|
+
token = get_token(actions)
|
89
|
+
mash = actions.create_job(token, options[:n], options[:l])
|
90
|
+
puts 'Job ID: ' + mash.JobId
|
91
|
+
puts 'Task ID: ' + mash.TaskId
|
92
|
+
|
93
|
+
puts 'Adding media...'
|
94
|
+
if !options[:m].nil?
|
95
|
+
task_id = actions.add_media_to_job_url(token, mash.JobId, options[:m])
|
96
|
+
elsif !options[:M].nil?
|
97
|
+
file = File.new(File.absolute_path(options[:M]), 'r')
|
98
|
+
task_id = actions.add_media_to_job_file(token, mash.JobId, file)
|
99
|
+
end
|
100
|
+
puts 'Task ID: ' + task_id
|
101
|
+
|
102
|
+
puts 'Performing transcription...'
|
103
|
+
|
104
|
+
# Parse option hash
|
105
|
+
jobopts = PerformTranscriptionOptions.new
|
106
|
+
jobopts.populate_from_hash(options[:J])
|
107
|
+
|
108
|
+
task_id = actions.perform_transcription(token, mash.JobId, options[:f], options[:P], options[:C], options[:T], options[:t], jobopts)
|
109
|
+
puts 'Task ID: ' + task_id
|
110
|
+
end
|
111
|
+
|
112
|
+
desc 'delete', 'Delete a job'
|
113
|
+
option *job_id_option
|
114
|
+
# always required (hidden)
|
115
|
+
option *username_option
|
116
|
+
option *password_option
|
117
|
+
option *securekey_option
|
118
|
+
option *api_token_option
|
119
|
+
def delete
|
120
|
+
puts 'Deleting job...'
|
121
|
+
actions = initialize_actions
|
122
|
+
token = get_token(actions)
|
123
|
+
task_id = actions.delete_job(token, options[:j])
|
124
|
+
puts 'Task ID: ' + task_id
|
125
|
+
end
|
126
|
+
|
127
|
+
desc 'authorize', 'Authorize a job'
|
128
|
+
option *job_id_option
|
129
|
+
# always required (hidden)
|
130
|
+
option *username_option
|
131
|
+
option *password_option
|
132
|
+
option *securekey_option
|
133
|
+
option *api_token_option
|
134
|
+
def authorize
|
135
|
+
puts 'Authorizing job...'
|
136
|
+
actions = initialize_actions
|
137
|
+
token = get_token(actions)
|
138
|
+
actions.authorize_job(token, options[:j])
|
139
|
+
puts 'Authorized successfully'
|
140
|
+
end
|
141
|
+
|
142
|
+
desc 'add_media_to_job', 'Add media to job'
|
143
|
+
option *job_id_option
|
144
|
+
option *media_url_option
|
145
|
+
option *media_file_option
|
146
|
+
# always required (hidden)
|
147
|
+
option *username_option
|
148
|
+
option *password_option
|
149
|
+
option *securekey_option
|
150
|
+
option *api_token_option
|
151
|
+
def add_media_to_job
|
152
|
+
puts 'Adding media to job...'
|
153
|
+
actions = initialize_actions
|
154
|
+
token = get_token(actions)
|
155
|
+
if !options[:m].nil?
|
156
|
+
task_id = actions.add_media_to_job_url(token, options[:j], options[:m])
|
157
|
+
elsif !options[:M].nil?
|
158
|
+
file = File.new(File.absolute_path(options[:M]), 'r')
|
159
|
+
task_id = actions.add_media_to_job_file(token, options[:j], file)
|
160
|
+
else
|
161
|
+
raise ArgumentError.new('Media URL or local file path must be supplied')
|
162
|
+
end
|
163
|
+
puts 'Task ID: ' + task_id
|
164
|
+
end
|
165
|
+
|
166
|
+
desc 'add_embedded_media_to_job', 'Add embedded media to job'
|
167
|
+
option *job_id_option
|
168
|
+
option :m, :required => true, :desc => 'Media URL', :banner => 'mediaurl'
|
169
|
+
# always required (hidden)
|
170
|
+
option *username_option
|
171
|
+
option *password_option
|
172
|
+
option *securekey_option
|
173
|
+
option *api_token_option
|
174
|
+
def add_embedded_media_to_job
|
175
|
+
puts 'Adding embedded media to job...'
|
176
|
+
actions = initialize_actions
|
177
|
+
token = get_token(actions)
|
178
|
+
task_id = actions.add_media_to_job_embedded(token, options[:j], options[:m])
|
179
|
+
puts 'Task ID: ' + task_id
|
180
|
+
end
|
181
|
+
|
182
|
+
desc 'list', 'Lists current jobs'
|
183
|
+
# always required (hidden)
|
184
|
+
option *username_option
|
185
|
+
option *password_option
|
186
|
+
option *securekey_option
|
187
|
+
option *api_token_option
|
188
|
+
def list
|
189
|
+
puts 'Retrieving list...'
|
190
|
+
actions = initialize_actions
|
191
|
+
token = get_token(actions)
|
192
|
+
mash = actions.get_job_list(token)
|
193
|
+
puts JSON.pretty_generate(JSON.parse(mash.to_json(nil)))
|
194
|
+
end
|
195
|
+
|
196
|
+
desc 'list_elementlists', 'List ElementLists'
|
197
|
+
option *job_id_option
|
198
|
+
# always required (hidden)
|
199
|
+
option *username_option
|
200
|
+
option *password_option
|
201
|
+
option *securekey_option
|
202
|
+
option *api_token_option
|
203
|
+
def list_elementlists
|
204
|
+
puts 'Listing Element Lists...'
|
205
|
+
actions = initialize_actions
|
206
|
+
token = get_token(actions)
|
207
|
+
array = actions.get_list_of_element_lists(token, options[:j])
|
208
|
+
puts JSON.pretty_generate(array)
|
209
|
+
end
|
210
|
+
|
211
|
+
desc 'get_caption', 'Get Caption'
|
212
|
+
option *job_id_option
|
213
|
+
option *caption_format_option
|
214
|
+
option *elementlist_version_option
|
215
|
+
option *caption_options_option
|
216
|
+
# always required (hidden)
|
217
|
+
option *username_option
|
218
|
+
option *password_option
|
219
|
+
option *securekey_option
|
220
|
+
option *api_token_option
|
221
|
+
def get_caption
|
222
|
+
puts 'Getting caption...'
|
223
|
+
actions = initialize_actions
|
224
|
+
token = get_token(actions)
|
225
|
+
|
226
|
+
# Parse options
|
227
|
+
caption_opts = CaptionOptions.new
|
228
|
+
caption_opts.populate_from_hash(options[:O])
|
229
|
+
|
230
|
+
caption = actions.get_caption(token, options[:j], options[:c], caption_opts)
|
231
|
+
puts caption
|
232
|
+
end
|
233
|
+
|
234
|
+
desc 'get_transcript', 'Get Transcript'
|
235
|
+
option *job_id_option
|
236
|
+
option *elementlist_version_option
|
237
|
+
option *caption_options_option
|
238
|
+
# always required (hidden)
|
239
|
+
option *username_option
|
240
|
+
option *password_option
|
241
|
+
option *securekey_option
|
242
|
+
option *api_token_option
|
243
|
+
def get_transcript
|
244
|
+
puts 'Getting transcript...'
|
245
|
+
actions = initialize_actions
|
246
|
+
token = get_token(actions)
|
247
|
+
|
248
|
+
# Parse options
|
249
|
+
transcription_opts = TranscriptOptions.new
|
250
|
+
transcription_opts.populate_from_hash(options[:O])
|
251
|
+
|
252
|
+
transcript = actions.get_transcript(token, options[:j], transcription_opts)
|
253
|
+
puts transcript
|
254
|
+
end
|
255
|
+
|
256
|
+
desc 'get_elementlist', 'Get ElementList for JobId'
|
257
|
+
option *job_id_option
|
258
|
+
option *elementlist_version_option
|
259
|
+
# always required (hidden)
|
260
|
+
option *username_option
|
261
|
+
option *password_option
|
262
|
+
option *securekey_option
|
263
|
+
option *api_token_option
|
264
|
+
def get_elementlist
|
265
|
+
puts 'Getting ElementList...'
|
266
|
+
actions = initialize_actions
|
267
|
+
token = get_token(actions)
|
268
|
+
mash = actions.get_element_list(token, options[:j], options[:e])
|
269
|
+
puts JSON.pretty_generate(JSON.parse(mash.to_json(nil)))
|
270
|
+
end
|
271
|
+
|
272
|
+
desc 'get_media', 'Get Media'
|
273
|
+
option *job_id_option
|
274
|
+
# always required (hidden)
|
275
|
+
option *username_option
|
276
|
+
option *password_option
|
277
|
+
option *securekey_option
|
278
|
+
option *api_token_option
|
279
|
+
def get_media
|
280
|
+
puts 'Getting media...'
|
281
|
+
actions = initialize_actions
|
282
|
+
token = get_token(actions)
|
283
|
+
url = actions.get_media(token, options[:j])
|
284
|
+
puts url
|
285
|
+
end
|
286
|
+
|
287
|
+
desc 'generate_api_key', 'Generate API Secure Key'
|
288
|
+
option *force_new_option
|
289
|
+
# always required (hidden)
|
290
|
+
option *username_option
|
291
|
+
option *password_option
|
292
|
+
option *securekey_option
|
293
|
+
option *api_token_option
|
294
|
+
def generate_api_key
|
295
|
+
puts 'Generating API key...'
|
296
|
+
actions = initialize_actions
|
297
|
+
token = get_token(actions)
|
298
|
+
key = actions.generate_api_key(token, options[:u], options[:F])
|
299
|
+
puts 'API Secure Key: ' + key
|
300
|
+
end
|
301
|
+
|
302
|
+
desc 'remove_api_key', 'Remove API Secure Key'
|
303
|
+
option :api_key, :aliases => 'k', :required => true, :desc => 'The API Key to remove'
|
304
|
+
# always required (hidden)
|
305
|
+
option *username_option
|
306
|
+
option *password_option
|
307
|
+
option *securekey_option
|
308
|
+
option *api_token_option
|
309
|
+
def remove_api_key
|
310
|
+
puts 'Removing API key...'
|
311
|
+
actions = initialize_actions
|
312
|
+
token = get_token(actions)
|
313
|
+
actions.remove_api_key(token, options[:k])
|
314
|
+
puts 'The key was successfully removed.'
|
315
|
+
end
|
316
|
+
|
317
|
+
desc 'update_password', 'Update Password'
|
318
|
+
option *new_password_option
|
319
|
+
# always required (hidden)
|
320
|
+
option *username_option
|
321
|
+
option *password_option
|
322
|
+
option *securekey_option
|
323
|
+
option *api_token_option
|
324
|
+
def update_password
|
325
|
+
puts 'Updating password...'
|
326
|
+
actions = initialize_actions
|
327
|
+
token = get_token(actions)
|
328
|
+
actions.update_password(token, options[:d])
|
329
|
+
puts 'Password was updated successfully.'
|
330
|
+
end
|
331
|
+
|
332
|
+
desc 'job_info', 'Get Job Info'
|
333
|
+
option *job_id_option
|
334
|
+
# always required (hidden)
|
335
|
+
option *username_option
|
336
|
+
option *password_option
|
337
|
+
option *securekey_option
|
338
|
+
option *api_token_option
|
339
|
+
def job_info
|
340
|
+
puts 'Getting Job Info...'
|
341
|
+
actions = initialize_actions
|
342
|
+
token = get_token(actions)
|
343
|
+
mash = actions.get_job_info(token, options[:j])
|
344
|
+
puts JSON.pretty_generate(JSON.parse(mash.to_json(nil)))
|
345
|
+
end
|
346
|
+
|
347
|
+
# Method override, so that an 'always required' message can be printed out before everything else
|
348
|
+
def help(arg=nil, arg2=nil)
|
349
|
+
super(arg, arg2)
|
350
|
+
puts "\nAlways required options:"
|
351
|
+
puts " -u=username \# cielo24 username"
|
352
|
+
puts " [-s=serverurl] \# cielo24 server URL"
|
353
|
+
puts " \# Default: https://api.cielo24.com"
|
354
|
+
puts "\n ++Either one of the following:"
|
355
|
+
puts " --------------------------------------------"
|
356
|
+
puts " -p=password \# cielo24 password"
|
357
|
+
puts " -k=securekey \# The API Secure Key"
|
358
|
+
puts " -N=token \# The API token of the current session"
|
359
|
+
puts " --------------------------------------------"
|
360
|
+
end
|
361
|
+
|
362
|
+
no_commands{
|
363
|
+
def private_login(actions, username, password, securekey)
|
364
|
+
raise ArgumentError.new('Username was not supplied.') if username.nil?
|
365
|
+
return actions.login(username, password, securekey, true)
|
366
|
+
end
|
367
|
+
|
368
|
+
def initialize_actions
|
369
|
+
actions = Actions.new
|
370
|
+
actions.base_url = options[:s] unless options[:s].nil?
|
371
|
+
setup_logger()
|
372
|
+
return actions
|
373
|
+
end
|
374
|
+
|
375
|
+
def get_token(actions)
|
376
|
+
return (options[:N].nil?) ? private_login(actions, options[:u], options[:p], options[:k]) : options[:N]
|
377
|
+
end
|
378
|
+
|
379
|
+
def setup_logger
|
380
|
+
if options[:v]
|
381
|
+
# Custom logger formatter
|
382
|
+
WebUtils::LOGGER.formatter = proc { |severity, datetime, progname, msg|
|
383
|
+
msg + "\n"
|
384
|
+
}
|
385
|
+
else
|
386
|
+
# Disable logger
|
387
|
+
WebUtils::LOGGER.level = Logger::ERROR
|
388
|
+
end
|
389
|
+
end
|
390
|
+
}
|
391
|
+
end
|
404
392
|
end
|
metadata
CHANGED
@@ -1,105 +1,115 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cielo24-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- cielo24
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2015-08-03 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
21
|
+
version: 1.10.6
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: 1.10.6
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
37
|
+
version: 10.4.2
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
45
|
+
version: 10.4.2
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: cielo24
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
53
|
+
version: 0.0.15
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
61
|
+
version: 0.0.15
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: thor
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- -
|
67
|
+
- - ~>
|
60
68
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
69
|
+
version: 0.19.1
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- -
|
75
|
+
- - ~>
|
67
76
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
77
|
+
version: 0.19.1
|
69
78
|
description: Command line interface that allows you to make REST API calls using cielo24
|
70
79
|
gem.
|
71
80
|
email:
|
72
81
|
- support@cielo24.com
|
73
82
|
executables:
|
74
|
-
-
|
83
|
+
- cielo24cli
|
75
84
|
extensions: []
|
76
85
|
extra_rdoc_files: []
|
77
86
|
files:
|
78
|
-
- lib/
|
79
|
-
- lib/
|
80
|
-
- lib/
|
81
|
-
- bin/
|
87
|
+
- lib/cielo24_cli/application.rb
|
88
|
+
- lib/cielo24_cli/version.rb
|
89
|
+
- lib/cielo24_cli.rb
|
90
|
+
- bin/cielo24cli
|
82
91
|
homepage: http://cielo24.com
|
83
92
|
licenses: []
|
84
|
-
metadata: {}
|
85
93
|
post_install_message:
|
86
94
|
rdoc_options: []
|
87
95
|
require_paths:
|
88
96
|
- lib
|
89
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
90
99
|
requirements:
|
91
|
-
- - '>='
|
100
|
+
- - ! '>='
|
92
101
|
- !ruby/object:Gem::Version
|
93
102
|
version: '0'
|
94
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
95
105
|
requirements:
|
96
|
-
- - '>='
|
106
|
+
- - ! '>='
|
97
107
|
- !ruby/object:Gem::Version
|
98
108
|
version: '0'
|
99
109
|
requirements: []
|
100
110
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
111
|
+
rubygems_version: 1.8.23
|
102
112
|
signing_key:
|
103
|
-
specification_version:
|
113
|
+
specification_version: 3
|
104
114
|
summary: Command line interface to cielo24 gem.
|
105
115
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 9e0bab47a823806a72dea22ad42794ed0ca6a112
|
4
|
-
data.tar.gz: dddaf0934796ce2aa71f2172c67b8380ad9cad40
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 2cfc990796e37c1d9596c3cd61c1f828f6b0542292d0a67af358e9d2515cdb6d56da9289d7627c3b566c184e8e7feeda398c324088c879326d8bab5f898f9903
|
7
|
-
data.tar.gz: f13d9ce4393fcc77005c018c5483dec6355f6e12f2169dd3546b614e6b6df4428926ee1a7d92537822dd65f76a26128a8e9ae279ff39929e796e6b40b2c8a436
|
data/bin/cielo24
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'cielo24'
|
4
|
-
require_relative "../lib/cielo24_command/application"
|
5
|
-
include Cielo24Command
|
6
|
-
|
7
|
-
begin
|
8
|
-
Application.start(ARGV)
|
9
|
-
rescue ArgumentError => e
|
10
|
-
puts "ERROR: " + e.message
|
11
|
-
exit(1)
|
12
|
-
rescue Cielo24::WebError => e
|
13
|
-
puts "ERROR: " + e.message
|
14
|
-
exit(1)
|
15
|
-
end
|
data/lib/cielo24_command.rb
DELETED