arc_weld 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/lib/arc_weld/cli.rb +1 -0
- data/lib/arc_weld/cli/project.rb +5 -5
- data/lib/arc_weld/cli/readers/relation_csv.rb +12 -3
- data/lib/arc_weld/cli/readers/relation_csv_category_uri.rb +46 -0
- data/lib/arc_weld/relationships/in_category.rb +8 -0
- data/lib/arc_weld/resource.rb +8 -1
- data/lib/arc_weld/resources/group.rb +1 -1
- data/lib/arc_weld/templates/project-csv/in/customer_networks.csv.tt +3 -0
- data/lib/arc_weld/templates/project-csv/in/group_categories.csv.tt +4 -3
- data/lib/arc_weld/templates/project-csv/in/zonegroup_networks.csv.tt +2 -0
- data/lib/arc_weld/templates/project-csv/weld.json.tt +7 -2
- data/lib/arc_weld/version.rb +1 -1
- metadata +5 -4
- data/lib/arc_weld/templates/project-csv/Gemfile.tt +0 -3
- data/lib/arc_weld/templates/project-csv/in/customer_groups.csv.tt +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 185b20cf9daefae896f7e79f91a4e7dcc65433d9
|
4
|
+
data.tar.gz: 30e29565d435aacb40f9926f9250bf802d0cd807
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa66678d4b1d2fcea65c461cf0b97f670c4e0de2cb78fe2e42fa59f9e3be626b3c2a29e60b0d2bc7b434ba46f6c2d32baa8610abc4d5be755523494cbe05f3b1
|
7
|
+
data.tar.gz: 12c2ab85729ce8ed1c8931288bddb1274acbf0ac509a5f3401e346ba6e94655d63998bdefbf72cdcaab9844e5a14306ac434a650893802eb7d0c7b6d730dea7a
|
data/Gemfile
CHANGED
data/lib/arc_weld/cli.rb
CHANGED
data/lib/arc_weld/cli/project.rb
CHANGED
@@ -82,11 +82,11 @@ module ArcWeld
|
|
82
82
|
relationships.each do |rel|
|
83
83
|
klass = ArcWeld::Cli::RelationReaders.const_get(constantize(rel['driver']))
|
84
84
|
rel_reader = klass.new(
|
85
|
-
path:
|
86
|
-
relationship_type: rel['type']
|
87
|
-
|
88
|
-
|
89
|
-
rel_reader.relate(
|
85
|
+
path: File.join(input_dir,rel['file']),
|
86
|
+
relationship_type: rel['type']
|
87
|
+
)
|
88
|
+
|
89
|
+
rel_reader.relate(resources)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -21,10 +21,19 @@ module ArcWeld
|
|
21
21
|
self
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def sources(inputs)
|
25
|
+
inputs[src_type]
|
26
|
+
end
|
27
|
+
|
28
|
+
def destinations(inputs)
|
29
|
+
inputs[dst_type]
|
30
|
+
end
|
31
|
+
|
32
|
+
def relate(inputs)
|
25
33
|
csv.each do |selected_src, selected_dst|
|
26
|
-
src_instance=sources.find {|s| s.send(src_select)==selected_src}
|
27
|
-
dst_instance=destinations.find {|s| s.send(dst_select)==selected_dst}
|
34
|
+
src_instance=sources(inputs).find {|s| s.send(src_select) == selected_src }
|
35
|
+
dst_instance=destinations(inputs).find {|s| s.send(dst_select) == selected_dst}
|
36
|
+
|
28
37
|
if (src_instance.nil? || dst_instance.nil?)
|
29
38
|
STDERR.puts format('could not %s %s/%s',
|
30
39
|
relationship_type,
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module ArcWeld
|
2
|
+
module Cli
|
3
|
+
module RelationReaders
|
4
|
+
class CsvCategoryUri
|
5
|
+
include ArcWeld::Helpers
|
6
|
+
attr_accessor :path, :src_select, :src_class, :relationship_type
|
7
|
+
|
8
|
+
attr_accessor :inputs
|
9
|
+
attr_reader :csv, :keys, :src_type
|
10
|
+
|
11
|
+
def initialize(*args)
|
12
|
+
Hash[*args].each {|k,v| self.send(format('%s=',k),v)}
|
13
|
+
@csv = CSV.open(path)
|
14
|
+
@keys = csv.readline
|
15
|
+
@src_type, @src_select, *unused= keys.flat_map do |k|
|
16
|
+
k.split(':')
|
17
|
+
end
|
18
|
+
@src_class=ArcWeld.const_get(constantize(src_type))
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def sources(inputs)
|
23
|
+
inputs[src_type]
|
24
|
+
end
|
25
|
+
|
26
|
+
def destinations(inputs)
|
27
|
+
[]
|
28
|
+
end
|
29
|
+
|
30
|
+
def relate(inputs)
|
31
|
+
csv.each do |selected_src, category_uri|
|
32
|
+
src_instance=sources(inputs).find {|s| s.send(src_select)==selected_src}
|
33
|
+
|
34
|
+
if (src_instance.nil?)
|
35
|
+
STDERR.puts format('could not %s %s/%s',
|
36
|
+
relationship_type,
|
37
|
+
selected_src)
|
38
|
+
else
|
39
|
+
src_instance.send(relationship_type,category_uri)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -2,6 +2,14 @@ module ArcWeld
|
|
2
2
|
module Relationships
|
3
3
|
module InCategory
|
4
4
|
|
5
|
+
def add_category_uri(uri)
|
6
|
+
if (uri.match(%r{\A/All Asset Categories/}))
|
7
|
+
ref = ArcWeld::Reference.new(type: 'Group', uri: uri)
|
8
|
+
add_category(ref)
|
9
|
+
end # silent fail?
|
10
|
+
|
11
|
+
end
|
12
|
+
|
5
13
|
def add_category(cat)
|
6
14
|
unless in_category.include?(cat.ref)
|
7
15
|
in_category << cat.ref
|
data/lib/arc_weld/resource.rb
CHANGED
@@ -31,7 +31,14 @@ module ArcWeld
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def parent_ref=(containing_group)
|
34
|
-
@parent_ref = containing_group.ref
|
34
|
+
@parent_ref = containing_group.ref if containing_group.ref.type=='Group'
|
35
|
+
end
|
36
|
+
|
37
|
+
def parent_uri=(uri)
|
38
|
+
top_root = Regexp.new(format('\A%s',self.class.toplevel.uri))
|
39
|
+
if top_root.match(uri)
|
40
|
+
@parent_ref = ArcWeld::Reference.new(uri: uri)
|
41
|
+
end
|
35
42
|
end
|
36
43
|
|
37
44
|
def identity_hash
|
@@ -4,7 +4,7 @@ module ArcWeld
|
|
4
4
|
include ArcWeld::Relationship
|
5
5
|
|
6
6
|
resource_property :containedResourceType, :description, :memberReferencePage
|
7
|
-
has_relationship :has_child, :in_category, :in_network,
|
7
|
+
has_relationship :has_child, :in_category, :in_network, multiple: true
|
8
8
|
|
9
9
|
def self.class_id
|
10
10
|
fail TypeError, 'no group resource class_id'
|
@@ -1,3 +1,4 @@
|
|
1
|
-
group:externalID,
|
2
|
-
weld_asset_root
|
3
|
-
weld_zone_root
|
1
|
+
group:externalID,uri
|
2
|
+
weld_asset_root,/All Asset Categories/<%= @config[:name] -%> Categories/Welded Assets
|
3
|
+
weld_zone_root,/All Asset Categories/<%= @config[:name] -%> Categories/Welded Zones
|
4
|
+
weld_zone_root,/All Asset Categories/Site Asset Categories/Address Spaces/Protected
|
@@ -27,13 +27,18 @@
|
|
27
27
|
},
|
28
28
|
{
|
29
29
|
"driver" : "csv",
|
30
|
-
"type" : "
|
30
|
+
"type" : "add_network",
|
31
|
+
"file" : "zonegroup_networks.csv"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"driver" : "csv_category_uri",
|
35
|
+
"type" : "add_category_uri",
|
31
36
|
"file" : "group_categories.csv"
|
32
37
|
},
|
33
38
|
{
|
34
39
|
"driver" : "csv",
|
35
40
|
"type" : "add_customer_resource",
|
36
|
-
"file" : "
|
41
|
+
"file" : "customer_networks.csv"
|
37
42
|
}
|
38
43
|
]
|
39
44
|
}
|
data/lib/arc_weld/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arc_weld
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Breed
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- lib/arc_weld/cli.rb
|
204
204
|
- lib/arc_weld/cli/project.rb
|
205
205
|
- lib/arc_weld/cli/readers/relation_csv.rb
|
206
|
+
- lib/arc_weld/cli/readers/relation_csv_category_uri.rb
|
206
207
|
- lib/arc_weld/cli/readers/resource_csv.rb
|
207
208
|
- lib/arc_weld/helpers.rb
|
208
209
|
- lib/arc_weld/reference.rb
|
@@ -226,16 +227,16 @@ files:
|
|
226
227
|
- lib/arc_weld/resources/network.rb
|
227
228
|
- lib/arc_weld/resources/zone.rb
|
228
229
|
- lib/arc_weld/templates/project-csv/.gitignore.tt
|
229
|
-
- lib/arc_weld/templates/project-csv/Gemfile.tt
|
230
230
|
- lib/arc_weld/templates/project-csv/Thorfile.tt
|
231
231
|
- lib/arc_weld/templates/project-csv/in/assets.csv.tt
|
232
232
|
- lib/arc_weld/templates/project-csv/in/categories.csv.tt
|
233
|
-
- lib/arc_weld/templates/project-csv/in/
|
233
|
+
- lib/arc_weld/templates/project-csv/in/customer_networks.csv.tt
|
234
234
|
- lib/arc_weld/templates/project-csv/in/customers.csv.tt
|
235
235
|
- lib/arc_weld/templates/project-csv/in/group_categories.csv.tt
|
236
236
|
- lib/arc_weld/templates/project-csv/in/locations.csv.tt
|
237
237
|
- lib/arc_weld/templates/project-csv/in/networks.csv.tt
|
238
238
|
- lib/arc_weld/templates/project-csv/in/zone_locations.csv.tt
|
239
|
+
- lib/arc_weld/templates/project-csv/in/zonegroup_networks.csv.tt
|
239
240
|
- lib/arc_weld/templates/project-csv/in/zones.csv.tt
|
240
241
|
- lib/arc_weld/templates/project-csv/lib/thor/README.txt.tt
|
241
242
|
- lib/arc_weld/templates/project-csv/lib/thor/sample.thor.tt
|
@@ -261,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
262
|
version: '0'
|
262
263
|
requirements: []
|
263
264
|
rubyforge_project:
|
264
|
-
rubygems_version: 2.4.5
|
265
|
+
rubygems_version: 2.4.5
|
265
266
|
signing_key:
|
266
267
|
specification_version: 4
|
267
268
|
summary: Toolkit for building ArcSight resources
|