etna 0.1.30 → 0.1.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/etna/clients/magma/workflows/crud_workflow.rb +10 -2
- data/lib/etna/clients/magma/workflows/materialize_magma_record_files_workflow.rb +1 -1
- data/lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb +7 -1
- data/lib/etna/clients/magma/workflows/walk_model_tree_workflow.rb +29 -7
- data/lib/etna/clients/metis/client.rb +5 -0
- data/lib/etna/clients/metis/models.rb +15 -0
- data/lib/etna/user.rb +13 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e8722ab25f18920f6d9b101d3fb78d52e03a7ffbb884da89b5942c0f3985bb1
|
4
|
+
data.tar.gz: 24547dbfc711d1a97cdad56302f1e29ebd6b3bdd6286ca046b34619c134137a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c878e9867cd036b302bacb0040003f803003760b5445c482797a1e7045b8421852e0f4326916f62d02e4a12e182930b90f06c4f5a66c5baa5a7d1c5c153ef047
|
7
|
+
data.tar.gz: c40d34810aef6d6de593732401842d29aa0bd2f33774a439e36713b6736c05a19539e616d3473a73db3104a97f3a89f6c59bfe8aaf6942a013df86eb03f6225c
|
@@ -48,8 +48,16 @@ module Etna
|
|
48
48
|
|
49
49
|
retry
|
50
50
|
rescue Etna::Error => e
|
51
|
-
|
52
|
-
|
51
|
+
if e.status === 502
|
52
|
+
if attempts > 5
|
53
|
+
raise e
|
54
|
+
end
|
55
|
+
|
56
|
+
retry
|
57
|
+
else
|
58
|
+
raise e unless e.message.include?('not found')
|
59
|
+
break
|
60
|
+
end
|
53
61
|
end
|
54
62
|
|
55
63
|
documents += last_page.models.model(model_name).documents unless block_given?
|
@@ -34,7 +34,7 @@ module Etna
|
|
34
34
|
record_names,
|
35
35
|
model_attributes_mask: model_attributes_mask,
|
36
36
|
model_filters: model_filters,
|
37
|
-
page_size:
|
37
|
+
page_size: 20,
|
38
38
|
) do |template, document|
|
39
39
|
logger&.info("Materializing #{template.name}##{document[template.identifier]}")
|
40
40
|
templates[template.name] = template
|
@@ -241,7 +241,13 @@ module Etna
|
|
241
241
|
attribute_name_clean = attribute_name.strip
|
242
242
|
raise "Invalid attribute \"#{attribute_name_clean}\" for model #{@model_name}." unless attribute = @workflow.find_attribute(@model_name, attribute_name_clean)
|
243
243
|
|
244
|
-
|
244
|
+
stripped = stripped_value(attribute, @raw[attribute_name])
|
245
|
+
|
246
|
+
unless @workflow.hole_value.nil?
|
247
|
+
next if stripped == @workflow.hole_value
|
248
|
+
end
|
249
|
+
|
250
|
+
attributes[attribute_name_clean] = stripped
|
245
251
|
end
|
246
252
|
end
|
247
253
|
end
|
@@ -9,6 +9,27 @@ module Etna
|
|
9
9
|
class WalkModelTreeWorkflow < Struct.new(:magma_crud, :logger, keyword_init: true)
|
10
10
|
def initialize(**args)
|
11
11
|
super(**({}.update(args)))
|
12
|
+
@template_for = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def masked_attributes(template:, model_attributes_mask:, model_name:)
|
16
|
+
attributes_mask = model_attributes_mask[model_name]
|
17
|
+
return ["all", "all"] if attributes_mask.nil?
|
18
|
+
[(attributes_mask + [template.identifier, 'parent']).uniq, attributes_mask]
|
19
|
+
end
|
20
|
+
|
21
|
+
def attribute_included?(mask, attribute_name)
|
22
|
+
return true if mask == "all"
|
23
|
+
mask.include?(attribute_name)
|
24
|
+
end
|
25
|
+
|
26
|
+
def template_for(model_name)
|
27
|
+
@template_for[model_name] ||= magma_crud.magma_client.retrieve(RetrievalRequest.new(
|
28
|
+
project_name: magma_crud.project_name,
|
29
|
+
model_name: model_name,
|
30
|
+
record_names: [],
|
31
|
+
attribute_names: [],
|
32
|
+
)).models.model(model_name).template
|
12
33
|
end
|
13
34
|
|
14
35
|
def walk_from(
|
@@ -26,29 +47,30 @@ module Etna
|
|
26
47
|
next if seen.include?([path[:from], model_name])
|
27
48
|
seen.add([path[:from], model_name])
|
28
49
|
|
50
|
+
template = template_for(model_name)
|
51
|
+
query_attributes, walk_attributes = masked_attributes(template: template, model_attributes_mask: model_attributes_mask, model_name: model_name)
|
52
|
+
|
29
53
|
request = RetrievalRequest.new(
|
30
54
|
project_name: magma_crud.project_name,
|
31
55
|
model_name: model_name,
|
32
56
|
record_names: path[:record_names],
|
33
57
|
filter: model_filters[model_name],
|
58
|
+
attribute_names: query_attributes,
|
34
59
|
page_size: page_size, page: 1
|
35
60
|
)
|
36
61
|
|
37
62
|
related_models = {}
|
38
63
|
|
39
64
|
magma_crud.page_records(model_name, request) do |response|
|
40
|
-
model = response.models.model(model_name)
|
41
|
-
template = model.template
|
42
|
-
|
43
65
|
tables = []
|
44
66
|
collections = []
|
45
67
|
links = []
|
46
68
|
attributes = []
|
47
69
|
|
70
|
+
model = response.models.model(model_name)
|
71
|
+
|
48
72
|
template.attributes.attribute_keys.each do |attr_name|
|
49
|
-
|
50
|
-
black_listed = !attributes_mask.nil? && !attributes_mask.include?(attr_name)
|
51
|
-
next if black_listed && attr_name != template.identifier && attr_name != 'parent'
|
73
|
+
next unless attribute_included?(query_attributes, attr_name)
|
52
74
|
attributes << attr_name
|
53
75
|
|
54
76
|
attr = template.attributes.attribute(attr_name)
|
@@ -63,7 +85,7 @@ module Etna
|
|
63
85
|
elsif attr.attribute_type == AttributeType::CHILD
|
64
86
|
related_models[attr.link_model_name] ||= Set.new
|
65
87
|
links << attr_name
|
66
|
-
elsif attr.attribute_type == AttributeType::PARENT &&
|
88
|
+
elsif attr.attribute_type == AttributeType::PARENT && attribute_included?(walk_attributes, attr_name)
|
67
89
|
related_models[attr.link_model_name] ||= Set.new
|
68
90
|
links << attr_name
|
69
91
|
end
|
@@ -69,6 +69,11 @@ module Etna
|
|
69
69
|
@etna_client.folder_remove(delete_folder_request.to_h))
|
70
70
|
end
|
71
71
|
|
72
|
+
def delete_file(delete_file_request)
|
73
|
+
FilesResponse.new(
|
74
|
+
@etna_client.file_remove(delete_file_request.to_h))
|
75
|
+
end
|
76
|
+
|
72
77
|
def find(find_request)
|
73
78
|
FoldersAndFilesResponse.new(
|
74
79
|
@etna_client.bucket_find(find_request.to_h))
|
@@ -95,6 +95,21 @@ module Etna
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
+
class DeleteFileRequest < Struct.new(:project_name, :bucket_name, :file_path, keyword_init: true)
|
99
|
+
include JsonSerializableStruct
|
100
|
+
|
101
|
+
def initialize(**params)
|
102
|
+
super({}.update(params))
|
103
|
+
end
|
104
|
+
|
105
|
+
def to_h
|
106
|
+
# The :project_name comes in from Polyphemus as a symbol value,
|
107
|
+
# we need to make sure it's a string because it's going
|
108
|
+
# in the URL.
|
109
|
+
super().compact.transform_values(&:to_s)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
98
113
|
class FindRequest < Struct.new(:project_name, :bucket_name, :limit, :offset, :params, keyword_init: true)
|
99
114
|
include JsonSerializableStruct
|
100
115
|
|
data/lib/etna/user.rb
CHANGED
@@ -46,7 +46,7 @@ module Etna
|
|
46
46
|
viewer: /[Vv]/,
|
47
47
|
restricted: /[AEV]/,
|
48
48
|
}
|
49
|
-
def
|
49
|
+
def has_any_role?(project, *roles)
|
50
50
|
perm = permissions[project.to_s]
|
51
51
|
|
52
52
|
return false unless perm
|
@@ -55,15 +55,23 @@ module Etna
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def is_superuser? project=nil
|
58
|
-
|
58
|
+
has_any_role?(:administration, :admin)
|
59
|
+
end
|
60
|
+
|
61
|
+
def is_supereditor? project=nil
|
62
|
+
has_any_role?(:administration, :admin, :editor)
|
63
|
+
end
|
64
|
+
|
65
|
+
def is_superviewer? project=nil
|
66
|
+
has_any_role?(:administration, :admin, :editor, :viewer)
|
59
67
|
end
|
60
68
|
|
61
69
|
def can_edit? project
|
62
|
-
|
70
|
+
is_supereditor? || has_any_role?(project, :admin, :editor)
|
63
71
|
end
|
64
72
|
|
65
73
|
def can_view? project
|
66
|
-
|
74
|
+
is_superviewer? || has_any_role?(project, :admin, :editor, :viewer)
|
67
75
|
end
|
68
76
|
|
69
77
|
# superusers - administrators of the Administration group - cannot
|
@@ -75,7 +83,7 @@ module Etna
|
|
75
83
|
end
|
76
84
|
|
77
85
|
def is_admin? project
|
78
|
-
is_superuser? ||
|
86
|
+
is_superuser? || has_any_role?(project, :admin)
|
79
87
|
end
|
80
88
|
|
81
89
|
def active? project=nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: etna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saurabh Asthana
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|