unimatrix-cli 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/VERSION +1 -1
- data/lib/unimatrix_cli.rb +5 -1
- data/lib/unimatrix_cli/cartographer/region/create_command.rb +38 -0
- data/lib/unimatrix_cli/cartographer/region/import_cities_command.rb +113 -0
- data/lib/unimatrix_cli/config/production.yml +6 -6
- data/lib/unimatrix_cli/version.rb +1 -1
- data/unimatrix-cli.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86f06aee20a499466a63b5f39f896dff36c4e8b5
|
4
|
+
data.tar.gz: 227e1e436d35c9fab6c1cb4712c190a1deba541b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58cf112a2c172d7f07b5a42d74d56745fd5172e3812ff67ded73cd8ee801a0a0af98ce1bb1ca6f477c30a79055424688d6190f0c53f77043550b161d824f153a
|
7
|
+
data.tar.gz: be51fa45a46b90782a90512aa470404a542ab8059a8ad8972c3211af46536e40c0a88942147ee482e3e1163359afb8bb09e82bceb06e0c0b440ca41dce69edd0
|
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.0
|
data/lib/unimatrix_cli.rb
CHANGED
@@ -24,6 +24,10 @@ require 'unimatrix_cli/alchemist/video_encoder/create_command'
|
|
24
24
|
require 'unimatrix_cli/alchemist/video_encoder/describe_command'
|
25
25
|
require 'unimatrix_cli/alchemist/video_encoder/list_command'
|
26
26
|
|
27
|
+
# cartographer
|
28
|
+
require 'unimatrix_cli/cartographer/region/import_cities_command'
|
29
|
+
require 'unimatrix_cli/cartographer/region/create_command'
|
30
|
+
|
27
31
|
# citadel
|
28
32
|
require 'unimatrix_cli/citadel/citadel_command'
|
29
33
|
require 'unimatrix_cli/citadel/app/build_command'
|
@@ -71,4 +75,4 @@ require 'unimatrix_cli/zephyrus/transcribing/configuration_command'
|
|
71
75
|
require 'unimatrix_cli/zephyrus/transmutation/configuration_command'
|
72
76
|
|
73
77
|
# must be loaded after all commands in order to dynamically enumerate available commands
|
74
|
-
require 'unimatrix_cli/cli'
|
78
|
+
require 'unimatrix_cli/cli'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module UnimatrixCLI
|
2
|
+
module Cartographer
|
3
|
+
module Region
|
4
|
+
class CreateCommand < Command
|
5
|
+
|
6
|
+
option :realm, "The realm uuid", type: :string, required: true
|
7
|
+
option :name, "The name of the region", type: :string, required: true
|
8
|
+
|
9
|
+
synopsis "Create a new region"
|
10
|
+
|
11
|
+
def execute
|
12
|
+
region = create_region
|
13
|
+
|
14
|
+
if validate( region, 'Cartographer::Region' )
|
15
|
+
write( message: "Region id: #{ region.id }" )
|
16
|
+
else
|
17
|
+
write(
|
18
|
+
message: "Error creating region: #{ region.inspect }",
|
19
|
+
error: true
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#----------------------------------------------------------------------------
|
25
|
+
|
26
|
+
private; def create_region
|
27
|
+
endpoint = "/realms/#{ @options[ :realm ] }/regions"
|
28
|
+
|
29
|
+
region = Unimatrix::Cartographer::Region.new(
|
30
|
+
name: @options[ :name ]
|
31
|
+
)
|
32
|
+
|
33
|
+
operation( endpoint ).write( 'regions', region ).first rescue nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module UnimatrixCLI
|
4
|
+
module Cartographer
|
5
|
+
module Region
|
6
|
+
class ImportCitiesCommand < Command
|
7
|
+
option :realm, "The realm uuid", type: :string, required: true
|
8
|
+
option :region, "The region id", type: :integer, required: true
|
9
|
+
option :file, "Path to file with cities", type: :string, required: true
|
10
|
+
|
11
|
+
synopsis "Import cities to a region from csv"
|
12
|
+
|
13
|
+
def execute
|
14
|
+
successful_region_geographic_areas, csv_rows = add_cities_to_region
|
15
|
+
if successful_region_geographic_areas == csv_rows
|
16
|
+
write(
|
17
|
+
message: "Imported #{ successful_region_geographic_areas } cities " +
|
18
|
+
"to region #{ @options[ :region ] }"
|
19
|
+
)
|
20
|
+
else
|
21
|
+
write(
|
22
|
+
message: "Only #{ successful_region_geographic_areas } / #{ csv_rows } " +
|
23
|
+
"cities imported to region #{ @options[:region] }",
|
24
|
+
error: true
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#----------------------------------------------------------------------------
|
30
|
+
|
31
|
+
private; def find_territory( territory_name )
|
32
|
+
options = {
|
33
|
+
name: territory_name
|
34
|
+
}
|
35
|
+
operation( "/territories", options ).read.first rescue nil
|
36
|
+
end
|
37
|
+
|
38
|
+
private; def find_city( territory, city_name )
|
39
|
+
options = {
|
40
|
+
name: city_name
|
41
|
+
}
|
42
|
+
cities = operation( "/cities", options ).read
|
43
|
+
|
44
|
+
city = nil
|
45
|
+
if validate_collection( cities, "Cartographer::City" )
|
46
|
+
city = cities.find do | city |
|
47
|
+
city.parent_uuid == territory.uuid
|
48
|
+
end
|
49
|
+
else
|
50
|
+
write(
|
51
|
+
message: "error finding city: #{ city_name }, #{ territory.name }. " +
|
52
|
+
"#{ city.inspect }",
|
53
|
+
error: true
|
54
|
+
)
|
55
|
+
end
|
56
|
+
city
|
57
|
+
end
|
58
|
+
|
59
|
+
private; def create_region_geographic_area( geographic_area_id )
|
60
|
+
|
61
|
+
endpoint = "/realms/#{ @options[ :realm ] }/region_geographic_areas"
|
62
|
+
region_geographic_area = Unimatrix::Cartographer::RegionGeographicArea.new(
|
63
|
+
region_id: @options[ :region ],
|
64
|
+
geographic_area_id: geographic_area_id
|
65
|
+
)
|
66
|
+
|
67
|
+
operation( endpoint ).write(
|
68
|
+
"region_geographic_areas", region_geographic_area ).first rescue nil
|
69
|
+
end
|
70
|
+
|
71
|
+
private; def add_cities_to_region
|
72
|
+
success_count = 0
|
73
|
+
row_count = 0
|
74
|
+
|
75
|
+
CSV.foreach( @options[ :file ], headers: false ) do | row |
|
76
|
+
city_name, territory_name = *row
|
77
|
+
row_count += 1
|
78
|
+
|
79
|
+
territory = find_territory( territory_name )
|
80
|
+
if validate( territory, 'Cartographer::Territory' )
|
81
|
+
city = find_city( territory, city_name )
|
82
|
+
if !city.nil?
|
83
|
+
region_geographic_area = create_region_geographic_area( city.id )
|
84
|
+
if region_geographic_area.nil? || !region_geographic_area.id.present?
|
85
|
+
write(
|
86
|
+
message: "error importing city to region: #{ region_geographic_area.inspect }",
|
87
|
+
error: true
|
88
|
+
)
|
89
|
+
else
|
90
|
+
success_count +=1
|
91
|
+
write(
|
92
|
+
message: "imported city: #{ city.name }, #{ territory.name }"
|
93
|
+
)
|
94
|
+
end
|
95
|
+
else
|
96
|
+
write(
|
97
|
+
message: "could not find city #{ city.name } in territory #{ territory.name }"
|
98
|
+
)
|
99
|
+
end
|
100
|
+
else
|
101
|
+
write(
|
102
|
+
message: "error finding territory: #{ territory_name }. #{ territory.inspect }",
|
103
|
+
error: true
|
104
|
+
)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
[ success_count, row_count ]
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -3,13 +3,13 @@ us-east-1:
|
|
3
3
|
archivist_url: ""
|
4
4
|
rendition_profile_uuids:
|
5
5
|
- ""
|
6
|
-
zephyrus_url: ""
|
7
|
-
unimatrix_api_url: ""
|
6
|
+
zephyrus_url: "http://zephyrus.boxxspring.com"
|
7
|
+
unimatrix_api_url: "http://api.unimatrix.io"
|
8
8
|
|
9
9
|
us-west-2:
|
10
|
-
keymaker_url: ""
|
11
|
-
archivist_url: ""
|
10
|
+
keymaker_url: "http://us-west-2.keymaker.boxxspring.net"
|
11
|
+
archivist_url: "http://us-west-2.archivist.boxxspring.net"
|
12
12
|
rendition_profile_uuids:
|
13
13
|
- ""
|
14
|
-
zephyrus_url: ""
|
15
|
-
unimatrix_api_url: ""
|
14
|
+
zephyrus_url: "http://zephyrus.boxxspring.com"
|
15
|
+
unimatrix_api_url: "http://us-west-2.api.unimatrix.io"
|
data/unimatrix-cli.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do | spec |
|
|
17
17
|
spec.executables = spec.files.grep( %r{^exe/} ) { | f | File.basename( f ) }
|
18
18
|
spec.require_paths = [ "lib" ]
|
19
19
|
|
20
|
-
spec.add_runtime_dependency "unimatrix", "~>
|
20
|
+
spec.add_runtime_dependency "unimatrix", "~> 2.3"
|
21
21
|
spec.add_runtime_dependency "aws-sdk", "~> 2.10"
|
22
22
|
spec.add_runtime_dependency "net-ssh", '~> 4.2', '>= 4.2.0'
|
23
23
|
spec.add_runtime_dependency "tty-prompt", "~> 0.14.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unimatrix-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sportsrocket
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unimatrix
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '2.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: aws-sdk
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,6 +169,8 @@ files:
|
|
169
169
|
- lib/unimatrix_cli/alchemist/video_encoder/encode_command.rb
|
170
170
|
- lib/unimatrix_cli/alchemist/video_encoder/list_command.rb
|
171
171
|
- lib/unimatrix_cli/archivist/blueprint/create_command.rb
|
172
|
+
- lib/unimatrix_cli/cartographer/region/create_command.rb
|
173
|
+
- lib/unimatrix_cli/cartographer/region/import_cities_command.rb
|
172
174
|
- lib/unimatrix_cli/citadel/app/build_command.rb
|
173
175
|
- lib/unimatrix_cli/citadel/app/console_command.rb
|
174
176
|
- lib/unimatrix_cli/citadel/app/db_setup_command.rb
|