cielo24-cli 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,4 @@
1
+ require 'cielo24_cli/application'
2
+
3
+ module Cielo24CLI
4
+ end
@@ -1,404 +1,392 @@
1
- module Cielo24Command
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, :banner => "fidelity", :default => Fidelity.PREMIUM]
25
- priority_option = [:P, :required => false, :desc => "Priority " + Priority.all, :banner => "priority", :default => Priority.STANDARD]
26
- source_language_option = [:l, :required => false, :desc => "Source language " + Language.all, :banner => "source", :default => Language.English]
27
- target_language_option = [:t, :required => false, :desc => "Target language " + Language.all, :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, :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
- print_url()
52
- puts "API token: " + token
53
- end
54
-
55
- desc "logout", 'Performs a logout action'
56
- option :N, :required => true, :desc => "The API token of the current session", :banner => "token"
57
- def logout
58
- puts "Performing a logout action..."
59
- actions = initialize_actions
60
- actions.logout(options[:N])
61
- print_url()
62
- puts "Logged out successfully"
63
- end
64
-
65
- desc "create", 'Creates a job'
66
- option *fidelity_option
67
- option *priority_option
68
- option *source_language_option
69
- option *target_language_option
70
- option *media_url_option
71
- option *media_file_option
72
- option *job_name_option
73
- option *job_options_option
74
- option *turn_around_hours_option
75
- option *callback_url_option
76
- # always required (hidden)
77
- option *username_option
78
- option *password_option
79
- option *securekey_option
80
- option *api_token_option
81
- def create
82
-
83
- if options[:m].nil? and options[:M].nil?
84
- puts "Media URL or local file path must be supplied"
85
- exit(1)
86
- end
87
-
88
- puts "Creating job..."
89
- actions = initialize_actions
90
- token = get_token(actions)
91
- mash = actions.create_job(token, options[:n], options[:l])
92
- puts "Job ID: " + mash.JobId
93
- puts "Task ID: " + mash.TaskId
94
- print_url()
95
-
96
- puts "Adding media..."
97
- if !options[:m].nil?
98
- task_id = actions.add_media_to_job_url(token, mash.JobId, options[:m])
99
- elsif !options[:M].nil?
100
- file = File.new(File.absolute_path(options[:M]), "r")
101
- task_id = actions.add_media_to_job_file(token, mash.JobId, file)
102
- end
103
- puts "Task ID: " + task_id
104
- print_url()
105
-
106
- puts "Performing transcription..."
107
-
108
- # Parse option hash
109
- jobopts = PerformTranscriptionOptions.new
110
- jobopts.populate_from_hash(options[:J])
111
-
112
- task_id = actions.perform_transcription(token, mash.JobId, options[:f], options[:P], options[:C], options[:T], options[:t], jobopts)
113
- puts "Task ID: " + task_id
114
- print_url()
115
- end
116
-
117
- desc "delete", 'Delete a job'
118
- option *job_id_option
119
- # always required (hidden)
120
- option *username_option
121
- option *password_option
122
- option *securekey_option
123
- option *api_token_option
124
- def delete
125
- puts "Deleting job..."
126
- actions = initialize_actions
127
- token = get_token(actions)
128
- task_id = actions.delete_job(token, options[:j])
129
- puts "Task ID: " + task_id
130
- print_url()
131
- end
132
-
133
- desc "authorize", 'Authorize a job'
134
- option *job_id_option
135
- # always required (hidden)
136
- option *username_option
137
- option *password_option
138
- option *securekey_option
139
- option *api_token_option
140
- def authorize
141
- puts "Authorizing job..."
142
- actions = initialize_actions
143
- token = get_token(actions)
144
- actions.authorize_job(token, options[:j])
145
- print_url()
146
- puts "Authorized successfully"
147
- end
148
-
149
- desc "add_media_to_job", 'Add media to job'
150
- option *job_id_option
151
- option *media_url_option
152
- option *media_file_option
153
- # always required (hidden)
154
- option *username_option
155
- option *password_option
156
- option *securekey_option
157
- option *api_token_option
158
- def add_media_to_job
159
- puts "Adding media to job..."
160
- actions = initialize_actions
161
- token = get_token(actions)
162
- if !options[:m].nil?
163
- task_id = actions.add_media_to_job_url(token, options[:j], options[:m])
164
- elsif !options[:M].nil?
165
- file = File.new(File.absolute_path(options[:M]), "r")
166
- task_id = actions.add_media_to_job_file(token, options[:j], file)
167
- else
168
- raise ArgumentError.new("Media URL or local file path must be supplied")
169
- end
170
- puts "Task ID: " + task_id
171
- print_url()
172
- end
173
-
174
- desc "add_embedded_media_to_job", 'Add embedded media to job'
175
- option *job_id_option
176
- option :m, :required => true, :desc => "Media URL", :banner => "mediaurl"
177
- # always required (hidden)
178
- option *username_option
179
- option *password_option
180
- option *securekey_option
181
- option *api_token_option
182
- def add_embedded_media_to_job
183
- puts "Adding embedded media to job..."
184
- actions = initialize_actions
185
- token = get_token(actions)
186
- task_id = actions.add_media_to_job_embedded(token, options[:j], options[:m])
187
- puts "Task ID: " + task_id
188
- print_url()
189
- end
190
-
191
- desc "list", 'Lists current jobs'
192
- # always required (hidden)
193
- option *username_option
194
- option *password_option
195
- option *securekey_option
196
- option *api_token_option
197
- def list
198
- puts "Retrieving list..."
199
- actions = initialize_actions
200
- token = get_token(actions)
201
- mash = actions.get_job_list(token)
202
- print_url()
203
- puts JSON.pretty_generate(JSON.parse(mash.to_json(nil)))
204
- end
205
-
206
- desc "list_elementlists", 'List ElementLists'
207
- option *job_id_option
208
- # always required (hidden)
209
- option *username_option
210
- option *password_option
211
- option *securekey_option
212
- option *api_token_option
213
- def list_elementlists
214
- puts "Listing Element Lists..."
215
- actions = initialize_actions
216
- token = get_token(actions)
217
- array = actions.get_list_of_element_lists(token, options[:j])
218
- print_url()
219
- puts JSON.pretty_generate(array)
220
- end
221
-
222
- desc "get_caption", 'Get Caption'
223
- option *job_id_option
224
- option *caption_format_option
225
- option *elementlist_version_option
226
- option *caption_options_option
227
- # always required (hidden)
228
- option *username_option
229
- option *password_option
230
- option *securekey_option
231
- option *api_token_option
232
- def get_caption
233
- puts "Getting caption..."
234
- actions = initialize_actions
235
- token = get_token(actions)
236
-
237
- # Parse options
238
- caption_opts = CaptionOptions.new
239
- caption_opts.populate_from_hash(options[:O])
240
-
241
- caption = actions.get_caption(token, options[:j], options[:c], caption_opts)
242
- print_url()
243
- puts caption
244
- end
245
-
246
- desc "get_transcript", 'Get Transcript'
247
- option *job_id_option
248
- option *elementlist_version_option
249
- option *caption_options_option
250
- # always required (hidden)
251
- option *username_option
252
- option *password_option
253
- option *securekey_option
254
- option *api_token_option
255
- def get_transcript
256
- puts "Getting transcript..."
257
- actions = initialize_actions
258
- token = get_token(actions)
259
-
260
- # Parse options
261
- transcription_opts = TranscriptionOptions.new
262
- transcription_opts.populate_from_hash(options[:O])
263
-
264
- transcript = actions.get_transcript(token, options[:j], transcription_opts)
265
- print_url()
266
- puts transcript
267
- end
268
-
269
- desc "get_elementlist", 'Get ElementList for JobId'
270
- option *job_id_option
271
- option *elementlist_version_option
272
- # always required (hidden)
273
- option *username_option
274
- option *password_option
275
- option *securekey_option
276
- option *api_token_option
277
- def get_elementlist
278
- puts "Getting ELement List..."
279
- actions = initialize_actions
280
- token = get_token(actions)
281
- mash = actions.get_element_list(token, options[:j], options[:e])
282
- print_url()
283
- puts JSON.pretty_generate(JSON.parse(mash.to_json(nil)))
284
- end
285
-
286
- desc "get_media", 'Get Media'
287
- option *job_id_option
288
- # always required (hidden)
289
- option *username_option
290
- option *password_option
291
- option *securekey_option
292
- option *api_token_option
293
- def get_media
294
- puts "Getting media..."
295
- actions = initialize_actions
296
- token = get_token(actions)
297
- url = actions.get_media(token, options[:j])
298
- print_url()
299
- puts url
300
- end
301
-
302
- desc "generate_api_key", 'Generate API Secure Key'
303
- option *force_new_option
304
- # always required (hidden)
305
- option *username_option
306
- option *password_option
307
- option *securekey_option
308
- option *api_token_option
309
- def generate_api_key
310
- puts "Generating API key..."
311
- actions = initialize_actions
312
- token = get_token(actions)
313
- key = actions.generate_api_key(token, options[:u], options[:F])
314
- print_url()
315
- puts "API Secure Key: " + key
316
- end
317
-
318
- desc "remove_api_key", 'Remove API Secure Key'
319
- option :api_key, :aliases => 'k', :required => true, :desc => "The API Key to remove"
320
- # always required (hidden)
321
- option *username_option
322
- option *password_option
323
- option *securekey_option
324
- option *api_token_option
325
- def remove_api_key
326
- puts "Removing API key..."
327
- actions = initialize_actions
328
- token = get_token(actions)
329
- actions.remove_api_key(token, options[:k])
330
- print_url()
331
- puts "The key was successfully removed."
332
- end
333
-
334
- desc "update_password", 'Update Password'
335
- option *new_password_option
336
- # always required (hidden)
337
- option *username_option
338
- option *password_option
339
- option *securekey_option
340
- option *api_token_option
341
- def update_password
342
- puts "Updating password..."
343
- actions = initialize_actions
344
- token = get_token(actions)
345
- actions.update_password(token, options[:d])
346
- print_url()
347
- puts "Password was updated successfully."
348
- end
349
-
350
- desc "job_info", 'Get Job Info'
351
- option *job_id_option
352
- # always required (hidden)
353
- option *username_option
354
- option *password_option
355
- option *securekey_option
356
- option *api_token_option
357
- def job_info
358
- puts "Getting Job Info..."
359
- actions = initialize_actions
360
- token = get_token(actions)
361
- mash = actions.get_job_info(token, options[:j])
362
- print_url()
363
- puts JSON.pretty_generate(JSON.parse(mash.to_json(nil)))
364
- end
365
-
366
- # Method override, so that an "always required" message can be printed out before everything else
367
- def help(arg=nil, arg2=nil)
368
- super(arg, arg2)
369
- puts "\nAlways required options:"
370
- puts " -u=username \# cielo24 username"
371
- puts " [-s=serverurl] \# cielo24 server URL"
372
- puts " \# Default: https://api.cielo24.com"
373
- puts "\n ++Either one of the following:"
374
- puts " --------------------------------------------"
375
- puts " -p=password \# cielo24 password"
376
- puts " -k=securekey \# The API Secure Key"
377
- puts " -N=token \# The API token of the current session"
378
- puts " --------------------------------------------"
379
- end
380
-
381
- no_commands{
382
- def private_login(actions, username, password, securekey)
383
- raise ArgumentError.new("Username was not supplied.") if username.nil?
384
- return actions.login(username, password, securekey, true)
385
- end
386
-
387
- def initialize_actions
388
- actions = Actions.new
389
- actions.base_url = options[:s] if !options[:s].nil?
390
- return actions
391
- end
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
@@ -0,0 +1,3 @@
1
+ module Cielo24CLI
2
+ VERSION = '0.0.5'
3
+ 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
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: 2014-08-06 00:00:00.000000000 Z
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: '1.6'
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: '1.6'
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: '10.0'
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: '10.0'
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: '0'
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: '0'
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: '0'
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: '0'
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
- - cielo24
83
+ - cielo24cli
75
84
  extensions: []
76
85
  extra_rdoc_files: []
77
86
  files:
78
- - lib/cielo24_command/application.rb
79
- - lib/cielo24_command/version.rb
80
- - lib/cielo24_command.rb
81
- - bin/cielo24
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: 2.0.14
111
+ rubygems_version: 1.8.23
102
112
  signing_key:
103
- specification_version: 4
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
@@ -1,4 +0,0 @@
1
- require "cielo24_command/version"
2
-
3
- module Cielo24Command
4
- end
@@ -1,3 +0,0 @@
1
- module Cielo24Command
2
- VERSION = "0.0.4"
3
- end