unimatrix-cli 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/README.md +12 -0
- data/Rakefile +6 -0
- data/VERSION +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/unimatrix +11 -0
- data/lib/unimatrix_cli.rb +74 -0
- data/lib/unimatrix_cli/alchemist/rendition/list_command.rb +72 -0
- data/lib/unimatrix_cli/alchemist/rendition_profile/assign_command.rb +59 -0
- data/lib/unimatrix_cli/alchemist/rendition_profile/list_command.rb +36 -0
- data/lib/unimatrix_cli/alchemist/video/create_command.rb +40 -0
- data/lib/unimatrix_cli/alchemist/video/describe_command.rb +40 -0
- data/lib/unimatrix_cli/alchemist/video_encoder/create_command.rb +37 -0
- data/lib/unimatrix_cli/alchemist/video_encoder/describe_command.rb +39 -0
- data/lib/unimatrix_cli/alchemist/video_encoder/encode_command.rb +102 -0
- data/lib/unimatrix_cli/alchemist/video_encoder/list_command.rb +35 -0
- data/lib/unimatrix_cli/archivist/blueprint/create_command.rb +94 -0
- data/lib/unimatrix_cli/citadel/app/build_command.rb +28 -0
- data/lib/unimatrix_cli/citadel/app/console_command.rb +17 -0
- data/lib/unimatrix_cli/citadel/app/db_setup_command.rb +17 -0
- data/lib/unimatrix_cli/citadel/app/environment_command.rb +30 -0
- data/lib/unimatrix_cli/citadel/app/logs_command.rb +17 -0
- data/lib/unimatrix_cli/citadel/app/migrate_command.rb +17 -0
- data/lib/unimatrix_cli/citadel/app/migrate_status_command.rb +17 -0
- data/lib/unimatrix_cli/citadel/app/rake_command.rb +18 -0
- data/lib/unimatrix_cli/citadel/app/routes_command.rb +17 -0
- data/lib/unimatrix_cli/citadel/citadel_command.rb +285 -0
- data/lib/unimatrix_cli/citadel/instance/details_command.rb +18 -0
- data/lib/unimatrix_cli/citadel/instance/scp_command.rb +48 -0
- data/lib/unimatrix_cli/citadel/instance/ssh_command.rb +29 -0
- data/lib/unimatrix_cli/citadel/instance/status_command.rb +17 -0
- data/lib/unimatrix_cli/citadel/instance/user_data_command.rb +17 -0
- data/lib/unimatrix_cli/citadel/instance/user_data_logs_command.rb +17 -0
- data/lib/unimatrix_cli/cli.rb +30 -0
- data/lib/unimatrix_cli/command.rb +138 -0
- data/lib/unimatrix_cli/config/acceptance.yml +23 -0
- data/lib/unimatrix_cli/config/configuration.rb +66 -0
- data/lib/unimatrix_cli/config/production.yml +15 -0
- data/lib/unimatrix_cli/config/staging.yml +15 -0
- data/lib/unimatrix_cli/config/unimatrix.rb +4 -0
- data/lib/unimatrix_cli/iris/stream/create_command.rb +43 -0
- data/lib/unimatrix_cli/iris/stream/describe_command.rb +35 -0
- data/lib/unimatrix_cli/iris/stream_encoder/create_command.rb +43 -0
- data/lib/unimatrix_cli/iris/stream_encoder/describe_command.rb +37 -0
- data/lib/unimatrix_cli/iris/stream_input/create_command.rb +43 -0
- data/lib/unimatrix_cli/iris/stream_input/describe_command.rb +37 -0
- data/lib/unimatrix_cli/iris/stream_output/create_command.rb +55 -0
- data/lib/unimatrix_cli/iris/stream_output/describe_command.rb +37 -0
- data/lib/unimatrix_cli/iris/stream_recorder/create_command.rb +49 -0
- data/lib/unimatrix_cli/iris/stream_recorder/describe_command.rb +37 -0
- data/lib/unimatrix_cli/iris/stream_transcriber/create_command.rb +54 -0
- data/lib/unimatrix_cli/iris/stream_transcriber/describe_command.rb +37 -0
- data/lib/unimatrix_cli/iris/stream_transmutator/create_command.rb +65 -0
- data/lib/unimatrix_cli/iris/stream_transmutator/describe_command.rb +38 -0
- data/lib/unimatrix_cli/login_command.rb +91 -0
- data/lib/unimatrix_cli/logout_command.rb +21 -0
- data/lib/unimatrix_cli/version.rb +3 -0
- data/lib/unimatrix_cli/zephyrus/input/create_command.rb +40 -0
- data/lib/unimatrix_cli/zephyrus/input/describe_command.rb +35 -0
- data/lib/unimatrix_cli/zephyrus/input/list_command.rb +38 -0
- data/lib/unimatrix_cli/zephyrus/output/list_command.rb +44 -0
- data/lib/unimatrix_cli/zephyrus/recording/configuration_command.rb +43 -0
- data/lib/unimatrix_cli/zephyrus/rendition/list_command.rb +40 -0
- data/lib/unimatrix_cli/zephyrus/routing/configuration_command.rb +43 -0
- data/lib/unimatrix_cli/zephyrus/transcoding/configuration_command.rb +55 -0
- data/lib/unimatrix_cli/zephyrus/transcribing/configuration_command.rb +55 -0
- data/lib/unimatrix_cli/zephyrus/transmutation/configuration_command.rb +55 -0
- data/lib/unimatrix_parser.rb +796 -0
- data/unimatrix-cli.gemspec +30 -0
- metadata +247 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
module UnimatrixCLI
|
2
|
+
class LoginCommand < Command
|
3
|
+
|
4
|
+
option :username, "Your username", type: :string, required: true
|
5
|
+
option :password, "Your password", type: :string, required: true
|
6
|
+
option :environment, "The environment to log into", type: :string, required: true
|
7
|
+
option :region, "The region to log into", type: :string
|
8
|
+
option :client, "Client id (optional)", type: :string
|
9
|
+
option :secret, "Client secret (optional)", type: :string
|
10
|
+
|
11
|
+
synopsis "Log in with your username, password, and environment. " +
|
12
|
+
"Specify region as 'us-east-1' or 'us-west-1'." +
|
13
|
+
"Specify a client_id, or make sure to provide it as an ENV variable. " +
|
14
|
+
"Specify a client_secret, if necessary, or provide as an ENV variable."
|
15
|
+
|
16
|
+
ENVIRONMENTS = %w( development acceptance staging production )
|
17
|
+
REGIONS = %w( us-east-1 us-west-2 )
|
18
|
+
|
19
|
+
def execute
|
20
|
+
if save_environment
|
21
|
+
save_region
|
22
|
+
|
23
|
+
response = log_in_request
|
24
|
+
if response[ 'access_token' ].nil?
|
25
|
+
write( message: "Error logging in: #{ response.inspect }", error: true )
|
26
|
+
else
|
27
|
+
save_access_token( response[ 'access_token' ] )
|
28
|
+
write( message: 'Successfully logged in; saving access_token and environment' )
|
29
|
+
end
|
30
|
+
else
|
31
|
+
write( message: 'Invalid environment', error: true )
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
#----------------------------------------------------------------------------
|
36
|
+
|
37
|
+
private; def log_in_request
|
38
|
+
endpoint = "#{ Configuration.default_config[ 'keymaker_url' ] }/token"
|
39
|
+
|
40
|
+
client_id = @options[ :client ] || ENV[ 'CLIENT_ID' ]
|
41
|
+
client_secret = @options[ :secret ] || ENV[ 'CLIENT_SECRET' ]
|
42
|
+
|
43
|
+
body = {
|
44
|
+
client_id: client_id,
|
45
|
+
client_secret: client_secret,
|
46
|
+
grant_type: 'password',
|
47
|
+
username: @options[ :username ],
|
48
|
+
password: @options[ :password ]
|
49
|
+
}
|
50
|
+
|
51
|
+
# Unimatrix SDK does not support Keymaker token response
|
52
|
+
make_request( endpoint, 'Post', body )
|
53
|
+
end
|
54
|
+
|
55
|
+
private; def save_environment
|
56
|
+
if ENVIRONMENTS.include?( @options[ :environment ] )
|
57
|
+
create_unimatrix_directory
|
58
|
+
File.write(
|
59
|
+
Configuration.environment_file_path,
|
60
|
+
"#{ @options[ :environment ] }"
|
61
|
+
)
|
62
|
+
else
|
63
|
+
false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
private; def save_region
|
68
|
+
if @options[ :region ] && REGIONS.include?( @options[ :region ] )
|
69
|
+
create_unimatrix_directory
|
70
|
+
File.write(
|
71
|
+
Configuration.region_file_path,
|
72
|
+
"#{ @options[ :region ] }"
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
private; def save_access_token( access_token )
|
78
|
+
create_unimatrix_directory
|
79
|
+
File.write(
|
80
|
+
Configuration.access_token_file_path,
|
81
|
+
"#{ access_token }"
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
private; def create_unimatrix_directory
|
86
|
+
unless Dir.exist?( Configuration.unimatrix_directory_path )
|
87
|
+
Dir.mkdir( Configuration.unimatrix_directory_path )
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module UnimatrixCLI
|
2
|
+
class LogoutCommand < Command
|
3
|
+
|
4
|
+
synopsis "Log out"
|
5
|
+
|
6
|
+
def execute
|
7
|
+
write( message: "Logging you out." )
|
8
|
+
delete_saved_data( Configuration.access_token_file_path )
|
9
|
+
delete_saved_data( Configuration.environment_file_path )
|
10
|
+
delete_saved_data( Configuration.region_file_path )
|
11
|
+
end
|
12
|
+
|
13
|
+
#----------------------------------------------------------------------------
|
14
|
+
|
15
|
+
private; def delete_saved_data( file_path )
|
16
|
+
if File.file?( file_path )
|
17
|
+
File.write( file_path, "" )
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module UnimatrixCLI
|
2
|
+
module Zephyrus
|
3
|
+
module Input
|
4
|
+
class CreateCommand < Command
|
5
|
+
|
6
|
+
option :key, "The input key", type: :string, required: true
|
7
|
+
option :uid, "The input uid", type: :string
|
8
|
+
|
9
|
+
synopsis "Create a new input"
|
10
|
+
|
11
|
+
def execute
|
12
|
+
input = create_input
|
13
|
+
|
14
|
+
if validate( input, 'Zephyrus::Input' )
|
15
|
+
write( message: "Input uuid: #{ input.uuid }" )
|
16
|
+
else
|
17
|
+
write(
|
18
|
+
message: "Error creating input: #{ input.inspect }",
|
19
|
+
error: true
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#----------------------------------------------------------------------------
|
25
|
+
|
26
|
+
private; def create_input
|
27
|
+
input = Unimatrix::Zephyrus::Input.new(
|
28
|
+
key: @options[ :key ],
|
29
|
+
state: 'disconnected'
|
30
|
+
)
|
31
|
+
input.uid = @options[ :uid ] if @options[ :uid ]
|
32
|
+
|
33
|
+
operation(
|
34
|
+
'/inputs'
|
35
|
+
).write( 'inputs', input ).first rescue nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module UnimatrixCLI
|
2
|
+
module Zephyrus
|
3
|
+
module Input
|
4
|
+
class DescribeCommand < Command
|
5
|
+
|
6
|
+
option :input, "The input uuid", type: :string, required: true
|
7
|
+
|
8
|
+
synopsis "Describe an input"
|
9
|
+
|
10
|
+
def execute
|
11
|
+
input = find_input
|
12
|
+
|
13
|
+
if validate( input, 'Zephyrus::Input' )
|
14
|
+
parse_object( input ).each do | response |
|
15
|
+
write( message: response )
|
16
|
+
end
|
17
|
+
else
|
18
|
+
write(
|
19
|
+
message: "Input could not be found: #{ input.inspect }",
|
20
|
+
error: true
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#----------------------------------------------------------------------------
|
26
|
+
|
27
|
+
private; def find_input
|
28
|
+
operation(
|
29
|
+
"/inputs/#{ @options[ :input ] }"
|
30
|
+
).read.first
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module UnimatrixCLI
|
2
|
+
module Zephyrus
|
3
|
+
module Input
|
4
|
+
class ListCommand < Command
|
5
|
+
|
6
|
+
option :key, "The key of the inputs", type: :string
|
7
|
+
option :uid, "The uid of the inputs", type: :string
|
8
|
+
|
9
|
+
synopsis "List inputs with a specific key and/or uid"
|
10
|
+
|
11
|
+
def execute
|
12
|
+
inputs = find_inputs
|
13
|
+
|
14
|
+
if validate_collection( inputs, 'Zephyrus::Input' )
|
15
|
+
inputs.each do | input |
|
16
|
+
write( message: input.uuid )
|
17
|
+
end
|
18
|
+
else
|
19
|
+
write(
|
20
|
+
message: "Inputs could not be found: #{ inputs.inspect }",
|
21
|
+
error: true
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
#----------------------------------------------------------------------------
|
27
|
+
|
28
|
+
private; def find_inputs
|
29
|
+
endpoint = "/inputs?"
|
30
|
+
endpoint += "key=#{ @options[ :key ] }&" if @options[ :key ]
|
31
|
+
endpoint += "uid=#{ @options[ :uid ] }" if @options[ :uid ]
|
32
|
+
|
33
|
+
operation( endpoint ).read
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module UnimatrixCLI
|
2
|
+
module Zephyrus
|
3
|
+
module Output
|
4
|
+
class ListCommand < Command
|
5
|
+
|
6
|
+
option :input, "The input uuid", type: :string, required: true
|
7
|
+
option :type_name, "The type of outputs", type: :string, required: true
|
8
|
+
option :key, "The key of the outputs", type: :string
|
9
|
+
option :url, "The url of the outputs", type: :string
|
10
|
+
option :uid, "The uid of the outputs", type: :string
|
11
|
+
|
12
|
+
synopsis "List outputs for a specific input"
|
13
|
+
|
14
|
+
def execute
|
15
|
+
outputs = find_outputs
|
16
|
+
|
17
|
+
if validate_collection( outputs, 'Zephyrus::Output' )
|
18
|
+
outputs.each do | output |
|
19
|
+
write( message: output.uuid )
|
20
|
+
end
|
21
|
+
else
|
22
|
+
write(
|
23
|
+
message: "Outputs could not be found: #{ outputs.inspect }",
|
24
|
+
error: true
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#----------------------------------------------------------------------------
|
30
|
+
|
31
|
+
private; def find_outputs
|
32
|
+
endpoint = "/inputs/#{ @options[ :input ] }/outputs?" +
|
33
|
+
"type_name=#{ @options[ :type_name ] }"
|
34
|
+
|
35
|
+
endpoint += "&key=#{ @options[ :key ] }" if @options[ :key ]
|
36
|
+
endpoint += "&url=#{ @options[ :url ] }" if @options[ :url ]
|
37
|
+
endpoint += "&uid=#{ @options[ :uid ] }" if @options[ :uid ]
|
38
|
+
|
39
|
+
operation( endpoint ).read
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module UnimatrixCLI
|
2
|
+
module Zephyrus
|
3
|
+
module Recording
|
4
|
+
class ConfigurationCommand < Command
|
5
|
+
|
6
|
+
option :key, "The key for an input", type: :string, required: true
|
7
|
+
|
8
|
+
synopsis "Display recording configuration for an input"
|
9
|
+
|
10
|
+
def execute
|
11
|
+
response = recording_configuration_request
|
12
|
+
if response[ 'outputs' ].nil?
|
13
|
+
write(
|
14
|
+
message: "Configuration could not be found: #{ response.inspect }",
|
15
|
+
error: true
|
16
|
+
)
|
17
|
+
else
|
18
|
+
response[ 'outputs' ].each do | output |
|
19
|
+
write( message: parse_configuration_output( output ) )
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#----------------------------------------------------------------------------
|
25
|
+
|
26
|
+
private; def recording_configuration_request
|
27
|
+
endpoint = "#{ Configuration.default_config[ 'zephyrus_url' ] }/" +
|
28
|
+
"recording/configuration?key=#{ @options[ :key ] }"
|
29
|
+
|
30
|
+
# Unimatrix SDK cannot handle Zephyrus configuration responses
|
31
|
+
make_request( endpoint, 'Get' )
|
32
|
+
end
|
33
|
+
|
34
|
+
private; def parse_configuration_output( output )
|
35
|
+
output = output.map do | key, value |
|
36
|
+
"#{ key }: #{ value }\n"
|
37
|
+
end
|
38
|
+
output << "\n"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module UnimatrixCLI
|
2
|
+
module Zephyrus
|
3
|
+
module Rendition
|
4
|
+
class ListCommand < Command
|
5
|
+
|
6
|
+
option :input, "The input uuid", type: :string, required: true
|
7
|
+
option :output, "The output uuid", type: :string, required: true
|
8
|
+
option :uid, "The uid of the renditions", type: :string, required: true
|
9
|
+
|
10
|
+
synopsis "List renditions for a specific output and uid"
|
11
|
+
|
12
|
+
def execute
|
13
|
+
renditions = find_renditions
|
14
|
+
|
15
|
+
if validate_collection( renditions, 'Zephyrus::Rendition' )
|
16
|
+
renditions.each do | rendition |
|
17
|
+
write( message: rendition.uuid )
|
18
|
+
end
|
19
|
+
else
|
20
|
+
write(
|
21
|
+
message: "Renditions could not be found: #{ renditions.inspect }",
|
22
|
+
error: true
|
23
|
+
)
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#----------------------------------------------------------------------------
|
29
|
+
|
30
|
+
private; def find_renditions
|
31
|
+
endpoint = "/inputs/#{ @options[ :input ] }/" +
|
32
|
+
"outputs/#{ @options[ :output ] }" +
|
33
|
+
"/renditions?uid=#{ @options[ :uid ] }"
|
34
|
+
|
35
|
+
operation( endpoint ).read
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module UnimatrixCLI
|
2
|
+
module Zephyrus
|
3
|
+
module Routing
|
4
|
+
class ConfigurationCommand < Command
|
5
|
+
|
6
|
+
option :key, "The key for an input", type: :string, required: true
|
7
|
+
|
8
|
+
synopsis "Display routing configuration for an input"
|
9
|
+
|
10
|
+
def execute
|
11
|
+
response = routing_configuration_request
|
12
|
+
if response[ 'outputs' ].nil?
|
13
|
+
write(
|
14
|
+
message: "Configuration could not be found: #{ response.inspect }",
|
15
|
+
error: true
|
16
|
+
)
|
17
|
+
else
|
18
|
+
response[ 'outputs' ].each do | output |
|
19
|
+
write( message: parse_configuration_output( output ) )
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#----------------------------------------------------------------------------
|
25
|
+
|
26
|
+
private; def routing_configuration_request
|
27
|
+
endpoint = "#{ Configuration.default_config[ 'zephyrus_url' ] }/" +
|
28
|
+
"routing/configuration?key=#{ @options[ :key ] }"
|
29
|
+
|
30
|
+
# Unimatrix SDK cannot handle Zephyrus configuration responses
|
31
|
+
make_request( endpoint, 'Get' )
|
32
|
+
end
|
33
|
+
|
34
|
+
private; def parse_configuration_output( output )
|
35
|
+
output = output.map do | key, value |
|
36
|
+
"#{ key }: #{ value }\n"
|
37
|
+
end
|
38
|
+
output << "\n"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module UnimatrixCLI
|
2
|
+
module Zephyrus
|
3
|
+
module Transcoding
|
4
|
+
class ConfigurationCommand < Command
|
5
|
+
|
6
|
+
option :key, "The key for an input", type: :string, required: true
|
7
|
+
|
8
|
+
synopsis "Display transcoding configuration for an input"
|
9
|
+
|
10
|
+
def execute
|
11
|
+
response = transcoding_configuration_request
|
12
|
+
if response[ 'outputs' ].nil?
|
13
|
+
write(
|
14
|
+
message: "Configuration could not be found: #{ response.inspect }",
|
15
|
+
error: true
|
16
|
+
)
|
17
|
+
else
|
18
|
+
response[ 'outputs' ].each do | output |
|
19
|
+
write( message: parse_configuration_output( output ) )
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#----------------------------------------------------------------------------
|
25
|
+
|
26
|
+
private; def transcoding_configuration_request
|
27
|
+
endpoint = "#{ Configuration.default_config[ 'zephyrus_url' ] }/" +
|
28
|
+
"transcoding/configuration?key=#{ @options[ :key ] }"
|
29
|
+
|
30
|
+
# Unimatrix SDK cannot handle Zephyrus configuration responses
|
31
|
+
make_request( endpoint, 'Get' )
|
32
|
+
end
|
33
|
+
|
34
|
+
private; def parse_configuration_output( output )
|
35
|
+
output = output.map do | key, value |
|
36
|
+
if key == "renditions"
|
37
|
+
renditions = value.map { | rendition | parse_rendition( rendition ) }.join
|
38
|
+
"renditions:\n*\n#{ renditions }"
|
39
|
+
else
|
40
|
+
"#{ key }: #{ value }\n"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
output << "\n"
|
44
|
+
end
|
45
|
+
|
46
|
+
private; def parse_rendition( rendition )
|
47
|
+
rendition = rendition.map do | key, value |
|
48
|
+
"#{ key }: #{ value }\n"
|
49
|
+
end
|
50
|
+
rendition << "*\n"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|