unimatrix-cli 2.2.0

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.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/README.md +12 -0
  6. data/Rakefile +6 -0
  7. data/VERSION +1 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +8 -0
  10. data/exe/unimatrix +11 -0
  11. data/lib/unimatrix_cli.rb +74 -0
  12. data/lib/unimatrix_cli/alchemist/rendition/list_command.rb +72 -0
  13. data/lib/unimatrix_cli/alchemist/rendition_profile/assign_command.rb +59 -0
  14. data/lib/unimatrix_cli/alchemist/rendition_profile/list_command.rb +36 -0
  15. data/lib/unimatrix_cli/alchemist/video/create_command.rb +40 -0
  16. data/lib/unimatrix_cli/alchemist/video/describe_command.rb +40 -0
  17. data/lib/unimatrix_cli/alchemist/video_encoder/create_command.rb +37 -0
  18. data/lib/unimatrix_cli/alchemist/video_encoder/describe_command.rb +39 -0
  19. data/lib/unimatrix_cli/alchemist/video_encoder/encode_command.rb +102 -0
  20. data/lib/unimatrix_cli/alchemist/video_encoder/list_command.rb +35 -0
  21. data/lib/unimatrix_cli/archivist/blueprint/create_command.rb +94 -0
  22. data/lib/unimatrix_cli/citadel/app/build_command.rb +28 -0
  23. data/lib/unimatrix_cli/citadel/app/console_command.rb +17 -0
  24. data/lib/unimatrix_cli/citadel/app/db_setup_command.rb +17 -0
  25. data/lib/unimatrix_cli/citadel/app/environment_command.rb +30 -0
  26. data/lib/unimatrix_cli/citadel/app/logs_command.rb +17 -0
  27. data/lib/unimatrix_cli/citadel/app/migrate_command.rb +17 -0
  28. data/lib/unimatrix_cli/citadel/app/migrate_status_command.rb +17 -0
  29. data/lib/unimatrix_cli/citadel/app/rake_command.rb +18 -0
  30. data/lib/unimatrix_cli/citadel/app/routes_command.rb +17 -0
  31. data/lib/unimatrix_cli/citadel/citadel_command.rb +285 -0
  32. data/lib/unimatrix_cli/citadel/instance/details_command.rb +18 -0
  33. data/lib/unimatrix_cli/citadel/instance/scp_command.rb +48 -0
  34. data/lib/unimatrix_cli/citadel/instance/ssh_command.rb +29 -0
  35. data/lib/unimatrix_cli/citadel/instance/status_command.rb +17 -0
  36. data/lib/unimatrix_cli/citadel/instance/user_data_command.rb +17 -0
  37. data/lib/unimatrix_cli/citadel/instance/user_data_logs_command.rb +17 -0
  38. data/lib/unimatrix_cli/cli.rb +30 -0
  39. data/lib/unimatrix_cli/command.rb +138 -0
  40. data/lib/unimatrix_cli/config/acceptance.yml +23 -0
  41. data/lib/unimatrix_cli/config/configuration.rb +66 -0
  42. data/lib/unimatrix_cli/config/production.yml +15 -0
  43. data/lib/unimatrix_cli/config/staging.yml +15 -0
  44. data/lib/unimatrix_cli/config/unimatrix.rb +4 -0
  45. data/lib/unimatrix_cli/iris/stream/create_command.rb +43 -0
  46. data/lib/unimatrix_cli/iris/stream/describe_command.rb +35 -0
  47. data/lib/unimatrix_cli/iris/stream_encoder/create_command.rb +43 -0
  48. data/lib/unimatrix_cli/iris/stream_encoder/describe_command.rb +37 -0
  49. data/lib/unimatrix_cli/iris/stream_input/create_command.rb +43 -0
  50. data/lib/unimatrix_cli/iris/stream_input/describe_command.rb +37 -0
  51. data/lib/unimatrix_cli/iris/stream_output/create_command.rb +55 -0
  52. data/lib/unimatrix_cli/iris/stream_output/describe_command.rb +37 -0
  53. data/lib/unimatrix_cli/iris/stream_recorder/create_command.rb +49 -0
  54. data/lib/unimatrix_cli/iris/stream_recorder/describe_command.rb +37 -0
  55. data/lib/unimatrix_cli/iris/stream_transcriber/create_command.rb +54 -0
  56. data/lib/unimatrix_cli/iris/stream_transcriber/describe_command.rb +37 -0
  57. data/lib/unimatrix_cli/iris/stream_transmutator/create_command.rb +65 -0
  58. data/lib/unimatrix_cli/iris/stream_transmutator/describe_command.rb +38 -0
  59. data/lib/unimatrix_cli/login_command.rb +91 -0
  60. data/lib/unimatrix_cli/logout_command.rb +21 -0
  61. data/lib/unimatrix_cli/version.rb +3 -0
  62. data/lib/unimatrix_cli/zephyrus/input/create_command.rb +40 -0
  63. data/lib/unimatrix_cli/zephyrus/input/describe_command.rb +35 -0
  64. data/lib/unimatrix_cli/zephyrus/input/list_command.rb +38 -0
  65. data/lib/unimatrix_cli/zephyrus/output/list_command.rb +44 -0
  66. data/lib/unimatrix_cli/zephyrus/recording/configuration_command.rb +43 -0
  67. data/lib/unimatrix_cli/zephyrus/rendition/list_command.rb +40 -0
  68. data/lib/unimatrix_cli/zephyrus/routing/configuration_command.rb +43 -0
  69. data/lib/unimatrix_cli/zephyrus/transcoding/configuration_command.rb +55 -0
  70. data/lib/unimatrix_cli/zephyrus/transcribing/configuration_command.rb +55 -0
  71. data/lib/unimatrix_cli/zephyrus/transmutation/configuration_command.rb +55 -0
  72. data/lib/unimatrix_parser.rb +796 -0
  73. data/unimatrix-cli.gemspec +30 -0
  74. metadata +247 -0
@@ -0,0 +1,39 @@
1
+ module UnimatrixCLI
2
+ module Alchemist
3
+ module VideoEncoder
4
+ class DescribeCommand < Command
5
+
6
+ option :realm, "The realm uuid", type: :string, required: true
7
+ option :video_encoder, "The video_encoder uuid", type: :string, required: true, short: :e
8
+
9
+ synopsis "Describe a video_encoder"
10
+
11
+ def execute
12
+ video_encoder = find_video_encoder
13
+
14
+ if validate( video_encoder, 'Alchemist::VideoEncoder' )
15
+ parse_object( video_encoder ).each do | response |
16
+ write( message: response )
17
+ end
18
+ else
19
+ write(
20
+ message: "Video Encoder could not be found: #{ video_encoder.inspect }",
21
+ error: true
22
+ )
23
+ end
24
+ end
25
+
26
+ #----------------------------------------------------------------------------
27
+
28
+ private; def find_video_encoder
29
+ endpoint = "/realms/#{ @options[ :realm ] }/video_encoders"
30
+ options = {
31
+ uuid: @options[ :video_encoder ]
32
+ }
33
+
34
+ operation( endpoint, options ).read.first
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,102 @@
1
+ module UnimatrixCLI
2
+ module Alchemist
3
+ module VideoEncoder
4
+ class EncodeCommand < Command
5
+
6
+ option :realm, "The realm uuid", type: :string, required: true
7
+ option :video_encoder, "The video_encoder uuid", type: :string, required: true, short: :e
8
+ option :video, "The video uuid", type: :string, required: true
9
+
10
+ synopsis "Start a video_encoder for a video. The video_encoder will use default " +
11
+ "rendition_profiles if none are already assigned to it. A list of the " +
12
+ "rendition_profiles being used to create renditions will be returned."
13
+
14
+ def execute
15
+ video_encoder = query_encoder_for_rendition_profiles
16
+ if validate( video_encoder, 'Alchemist::VideoEncoder' )
17
+ rendition_profiles = video_encoder.rendition_profiles
18
+
19
+ unless validate_collection( rendition_profiles, 'Alchemist::RenditionProfile' )
20
+ rendition_profiles = assign_default_rendition_profiles_to_encoder
21
+ end
22
+
23
+ if validate_collection( rendition_profiles, 'Alchemist::RenditionProfile' )
24
+ video_encoder = assign_video_to_encoder
25
+
26
+ if validate( video_encoder, 'Alchemist::VideoEncoder' )
27
+ video = video_encoder.videos.first
28
+
29
+ if validate( video, 'Alchemist::Video' )
30
+
31
+ rendition_profiles.map do | rendition_profile |
32
+ write( message: rendition_profile.uuid )
33
+ end
34
+ else
35
+ write(
36
+ message: "Error assigning video to video_encoder: #{ video.inspect }",
37
+ error: true
38
+ )
39
+ end
40
+ else
41
+ write(
42
+ message: "Error assigning video to " +
43
+ "video_encoder: #{ video_encoder.inspect }",
44
+ error: true
45
+ )
46
+ end
47
+ else
48
+ write(
49
+ message: "Error assigning rendition_profiles " +
50
+ "to video_encoder: #{ rendition_profiles.inspect }",
51
+ error: true
52
+ )
53
+ end
54
+ else
55
+ write(
56
+ message: "Error querying for rendition_profiles. " +
57
+ "Video Encoder not found: #{ video_encoder.inspect }",
58
+ error: true
59
+ )
60
+ end
61
+ end
62
+
63
+ #----------------------------------------------------------------------------
64
+
65
+ private; def query_encoder_for_rendition_profiles
66
+ endpoint = "/realms/#{ @options[ :realm ] }/video_encoders"
67
+ options = {
68
+ uuid: @options[ :video_encoder ]
69
+ }
70
+
71
+ operation( endpoint, options ).include(
72
+ 'rendition_profiles'
73
+ ).read.first rescue nil
74
+ end
75
+
76
+ private; def assign_default_rendition_profiles_to_encoder
77
+ endpoint = "/realms/#{ @options[ :realm ] }/video_encoders/" +
78
+ "#{ @options[ :video_encoder ] }/rendition_profiles"
79
+
80
+ uuids = Configuration.default_config[ 'rendition_profile_uuids' ]
81
+
82
+ rendition_profiles = uuids.map do | uuid |
83
+ Unimatrix::Alchemist::RenditionProfile.new( uuid: uuid )
84
+ end
85
+
86
+ operation( endpoint ).write(
87
+ 'rendition_profiles', rendition_profiles
88
+ ).first rescue nil
89
+ end
90
+
91
+ private; def assign_video_to_encoder
92
+ endpoint = "/realms/#{ @options[ :realm ] }/video_encoders/" +
93
+ "#{ @options[ :video_encoder ] }/videos"
94
+
95
+ video = Unimatrix::Alchemist::Video.new( uuid: @options[ :video ] )
96
+
97
+ operation( endpoint ).write( 'videos', video ).first rescue nil
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,35 @@
1
+ module UnimatrixCLI
2
+ module Alchemist
3
+ module VideoEncoder
4
+ class ListCommand < Command
5
+
6
+ option :realm, "The realm uuid", type: :string, required: true
7
+
8
+ synopsis "List all the video_encoders for the specified realm"
9
+
10
+ def execute
11
+ video_encoders = find_video_encoders
12
+
13
+ if validate_collection( video_encoders, 'Alchemist::VideoEncoder' )
14
+ video_encoders.each do | video_encoder |
15
+ write( message: video_encoder.uuid )
16
+ end
17
+ else
18
+ write(
19
+ message: "No video_encoders found: #{ video_encoders.inspect }",
20
+ error: true
21
+ )
22
+ end
23
+ end
24
+
25
+ #----------------------------------------------------------------------------
26
+
27
+ private; def find_video_encoders
28
+ endpoint = "/realms/#{ @options[ :realm ] }/video_encoders"
29
+
30
+ operation( endpoint ).read
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,94 @@
1
+ module UnimatrixCLI
2
+ module Archivist
3
+ module Blueprint
4
+ class CreateCommand < Command
5
+
6
+ option :realm, "Realm uuid where the blueprint belongs", type: :string, required: true
7
+ option :file, "Path to file describing blueprints", type: :string, required: true
8
+
9
+ synopsis "Create a new blueprint"
10
+
11
+ def execute
12
+ contents = read_file( @options[ :file ] )
13
+
14
+ if contents.respond_to?( :each )
15
+
16
+ requests = build_requests( contents )
17
+
18
+ blueprint_response = make_resource_request( requests[ :blueprints ], 'blueprints' )
19
+
20
+ if blueprint_response[ 'errors' ].nil?
21
+
22
+ requests[ :blueprint_attributes ] = attach_blueprint_ids_to_attributes(
23
+ blueprint_response[ 'blueprints' ],
24
+ requests[ :blueprint_attributes ]
25
+ )
26
+
27
+ blueprint_attribute_response =
28
+ make_resource_request( requests[ :blueprint_attributes ], 'blueprint_attributes' )
29
+
30
+ if blueprint_attribute_response[ 'errors' ].nil?
31
+
32
+ write( message: "Success! To verify, in your browser, visit:\n" +
33
+ "#{ Configuration.default_config[ 'archivist_url' ] }/realms" +
34
+ "/#{ @options[ :realm ] }/blueprints/" +
35
+ "?access_token=#{ Configuration.access_token }&" +
36
+ "include[blueprint_attributes]=true" )
37
+
38
+ else
39
+ write( message: "Error creating blueprint_attributes: " +
40
+ "#{ blueprint_attribute_response[ 'errors' ].inspect }", error: true )
41
+ end
42
+ else
43
+ write( message: "Error creating blueprint: " +
44
+ "#{ blueprint_response[ 'errors' ].inspect }", error: true )
45
+ end
46
+ else
47
+ write( message: "File empty or not correctly formatted", error: true )
48
+ end
49
+ end
50
+
51
+ #----------------------------------------------------------------------------
52
+
53
+ private; def build_requests( file_contents )
54
+ requests = { blueprints: [], blueprint_attributes: {} }
55
+
56
+ file_contents.each do | blueprint |
57
+ requests[ :blueprints ].push( blueprint.reject{ | key | key == 'attributes' } )
58
+
59
+ if requests[ :blueprint_attributes ][ blueprint[ 'name' ] ].nil?
60
+ requests[ :blueprint_attributes ][ blueprint[ 'name' ] ] = []
61
+ end
62
+
63
+ blueprint[ 'attributes' ].each do | attribute_set |
64
+ requests[ :blueprint_attributes ][ blueprint[ 'name' ] ].push( attribute_set )
65
+ end
66
+ end
67
+ requests
68
+ end
69
+
70
+ private; def make_resource_request( request_body, resource )
71
+ endpoint = "#{ Configuration.default_config[ 'archivist_url' ] }/" +
72
+ "realms/#{ @options[ :realm ] }/#{ resource }/" +
73
+ "?access_token=#{ Configuration.access_token }"
74
+
75
+ body = { "#{ resource }": request_body }
76
+
77
+ make_request( endpoint, 'Post', body )
78
+ end
79
+
80
+ private; def attach_blueprint_ids_to_attributes ( blueprints, attributes )
81
+ blueprint_attribute_requests = []
82
+
83
+ blueprints.each do | blueprint |
84
+ attributes[ blueprint[ 'name' ] ].each do | attribute |
85
+ attribute[ 'blueprint_uuid' ] = blueprint[ 'uuid' ]
86
+ blueprint_attribute_requests.push( attribute )
87
+ end
88
+ end
89
+ blueprint_attribute_requests
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,28 @@
1
+ module UnimatrixCLI
2
+ module Citadel
3
+ module App
4
+ class BuildCommand < CitadelCommand
5
+
6
+ option :builder, "Keyword for the name of the build server", type: :string, required: true
7
+ option :app, "Keyword for the name of the app to build", type: :string, required: true
8
+ option :branch, "The recipe or branch to build from (optional)", type: :string
9
+
10
+ synopsis "Build a package of the specified app"
11
+
12
+ def execute
13
+ if load_environment
14
+ execute_build
15
+ end
16
+ end
17
+
18
+ #----------------------------------------------------------------------------
19
+
20
+ def execute_build
21
+ command = base_command + " -t do_it #{ @options[ :builder ] } " +
22
+ "#{ @options[ :app ] } #{ @options[ :branch ] }"
23
+ system( command )
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ module UnimatrixCLI
2
+ module Citadel
3
+ module App
4
+ class ConsoleCommand < CitadelCommand
5
+
6
+ option :app, "Keyword for the name of the app", type: :string, required: true
7
+
8
+ synopsis "Enter the console on a Rails-based API instance"
9
+
10
+ def execute
11
+ super
12
+ execute_command( 'console' )
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module UnimatrixCLI
2
+ module Citadel
3
+ module App
4
+ class DbSetupCommand < CitadelCommand
5
+
6
+ option :app, "Keyword for the name of the app", type: :string, required: true
7
+
8
+ synopsis "Set up the database on a Rails-based API instance"
9
+
10
+ def execute
11
+ super
12
+ execute_command( 'db:setup' )
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ module UnimatrixCLI
2
+ module Citadel
3
+ module App
4
+ class EnvironmentCommand < CitadelCommand
5
+
6
+ option :app, "Keyword for the name of the app", type: :string, required: true
7
+ option :set, "Set env variables in the format KEY=value", type: :string
8
+ option :unset, "Remove env variables in the format KEY=value", type: :string
9
+
10
+ synopsis "Display or change environment variables"
11
+
12
+ def execute
13
+ super
14
+
15
+ if @options[ :set ]
16
+ @options[ :commands ] = "set '#{ @options[ :set ] }'"
17
+ elsif @options[ :unset ]
18
+ @options[ :commands ] = "unset '#{ @options[ :unset ] }'"
19
+ end
20
+
21
+ if @options[ :commands ]
22
+ execute_command( 'environment' )
23
+ else
24
+ execute_tunnel( 'cat /etc/environment' )
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,17 @@
1
+ module UnimatrixCLI
2
+ module Citadel
3
+ module App
4
+ class LogsCommand < CitadelCommand
5
+
6
+ option :app, "Keyword for the name of the app", type: :string, required: true
7
+
8
+ synopsis "Tail logs on the specified app"
9
+
10
+ def execute
11
+ super
12
+ execute_command( 'logs' )
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module UnimatrixCLI
2
+ module Citadel
3
+ module App
4
+ class MigrateCommand < CitadelCommand
5
+
6
+ option :app, "Keyword for the name of the app", type: :string, required: true
7
+
8
+ synopsis "Migrate the database on a Rails-based API instance"
9
+
10
+ def execute
11
+ super
12
+ execute_command( 'migrate' )
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module UnimatrixCLI
2
+ module Citadel
3
+ module App
4
+ class MigrateStatusCommand < CitadelCommand
5
+
6
+ option :app, "Keyword for the name of the app", type: :string, required: true
7
+
8
+ synopsis "Check database migration status on a Rails-based API instance"
9
+
10
+ def execute
11
+ super
12
+ execute_command( 'migrate:status' )
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ module UnimatrixCLI
2
+ module Citadel
3
+ module App
4
+ class RakeCommand < CitadelCommand
5
+
6
+ option :app, "Keyword for the name of the app", type: :string, required: true
7
+ option :commands, "The rake task commands", type: :string
8
+
9
+ synopsis "Run a rake task on a Rails-based API instance"
10
+
11
+ def execute
12
+ super
13
+ execute_command( 'rake' )
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end