etna 0.1.28 → 0.1.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/etna.completion +115 -1
  3. data/lib/commands.rb +30 -0
  4. data/lib/etna/application.rb +4 -0
  5. data/lib/etna/auth.rb +25 -0
  6. data/lib/etna/client.rb +43 -6
  7. data/lib/etna/clients/base_client.rb +2 -3
  8. data/lib/etna/clients/janus.rb +1 -0
  9. data/lib/etna/clients/janus/client.rb +19 -0
  10. data/lib/etna/clients/janus/models.rb +7 -1
  11. data/lib/etna/clients/janus/workflows.rb +1 -0
  12. data/lib/etna/clients/janus/workflows/generate_token_workflow.rb +77 -0
  13. data/lib/etna/clients/magma/models.rb +13 -1
  14. data/lib/etna/clients/magma/workflows/create_project_workflow.rb +1 -1
  15. data/lib/etna/clients/magma/workflows/crud_workflow.rb +19 -2
  16. data/lib/etna/clients/magma/workflows/file_linking_workflow.rb +3 -1
  17. data/lib/etna/clients/magma/workflows/materialize_magma_record_files_workflow.rb +43 -28
  18. data/lib/etna/clients/magma/workflows/model_synchronization_workflow.rb +1 -1
  19. data/lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb +19 -6
  20. data/lib/etna/clients/magma/workflows/walk_model_tree_workflow.rb +33 -6
  21. data/lib/etna/clients/metis/client.rb +6 -1
  22. data/lib/etna/clients/metis/models.rb +15 -0
  23. data/lib/etna/clients/metis/workflows/metis_download_workflow.rb +15 -11
  24. data/lib/etna/clients/metis/workflows/metis_upload_workflow.rb +83 -13
  25. data/lib/etna/clients/metis/workflows/sync_metis_data_workflow.rb +43 -79
  26. data/lib/etna/command.rb +1 -0
  27. data/lib/etna/cwl.rb +4 -0
  28. data/lib/etna/directed_graph.rb +88 -5
  29. data/lib/etna/filesystem.rb +143 -15
  30. data/lib/etna/hmac.rb +2 -2
  31. data/lib/etna/route.rb +4 -0
  32. data/lib/etna/spec/auth.rb +6 -6
  33. data/lib/etna/user.rb +15 -11
  34. data/lib/helpers.rb +2 -2
  35. metadata +18 -2
data/lib/etna/hmac.rb CHANGED
@@ -20,14 +20,14 @@ module Etna
20
20
  end
21
21
 
22
22
  # this returns arguments for URI::HTTP.build
23
- def url_params
23
+ def url_params(with_headers=true)
24
24
  params = {
25
25
  signature: signature,
26
26
  expiration: @expiration,
27
27
  nonce: @nonce,
28
28
  id: @id.to_s,
29
29
  headers: @headers.keys.join(','),
30
- }.merge(@headers).map do |name, value|
30
+ }.merge(with_headers ? @headers : {}).map do |name, value|
31
31
  [
32
32
  "X-Etna-#{ name.to_s.split(/_/).map(&:capitalize).join('-') }",
33
33
  value
data/lib/etna/route.rb CHANGED
@@ -91,6 +91,10 @@ module Etna
91
91
  @auth && @auth[:noauth]
92
92
  end
93
93
 
94
+ def ignore_janus?
95
+ @auth && @auth[:ignore_janus]
96
+ end
97
+
94
98
  private
95
99
 
96
100
  def application
@@ -2,22 +2,22 @@ module Etna::Spec
2
2
  module Auth
3
3
  AUTH_USERS = {
4
4
  superuser: {
5
- email: 'zeus@olympus.org', first: 'Zeus', perm: 'A:administration'
5
+ email: 'zeus@olympus.org', name: 'Zeus', perm: 'A:administration'
6
6
  },
7
7
  admin: {
8
- email: 'hera@olympus.org', first: 'Hera', perm: 'a:labors'
8
+ email: 'hera@olympus.org', name: 'Hera', perm: 'a:labors'
9
9
  },
10
10
  editor: {
11
- email: 'eurystheus@twelve-labors.org', first: 'Eurystheus', perm: 'E:labors'
11
+ email: 'eurystheus@twelve-labors.org', name: 'Eurystheus', perm: 'E:labors'
12
12
  },
13
13
  restricted_editor: {
14
- email: 'copreus@twelve-labors.org', first: 'Copreus', perm: 'e:labors'
14
+ email: 'copreus@twelve-labors.org', name: 'Copreus', perm: 'e:labors'
15
15
  },
16
16
  viewer: {
17
- email: 'hercules@twelve-labors.org', first: 'Hercules', perm: 'v:labors'
17
+ email: 'hercules@twelve-labors.org', name: 'Hercules', perm: 'v:labors'
18
18
  },
19
19
  non_user: {
20
- email: 'nessus@centaurs.org', first: 'Nessus', perm: ''
20
+ email: 'nessus@centaurs.org', name: 'Nessus', perm: ''
21
21
  }
22
22
  }
23
23
 
data/lib/etna/user.rb CHANGED
@@ -7,14 +7,14 @@ module Etna
7
7
  }
8
8
 
9
9
  def initialize params, token=nil
10
- @first, @last, @email, @encoded_permissions, encoded_flags = params.values_at(:first, :last, :email, :perm, :flags)
10
+ @name, @email, @encoded_permissions, encoded_flags = params.values_at(:name, :email, :perm, :flags)
11
11
 
12
12
  @flags = encoded_flags&.split(/;/) || []
13
13
  @token = token unless !token
14
14
  raise ArgumentError, "No email given!" unless @email
15
15
  end
16
16
 
17
- attr_reader :first, :last, :email, :token
17
+ attr_reader :name, :email, :token
18
18
 
19
19
  def permissions
20
20
  @permissions ||= @encoded_permissions.split(/\;/).map do |roles|
@@ -36,10 +36,6 @@ module Etna
36
36
  @flags.include?(flag)
37
37
  end
38
38
 
39
- def name
40
- "#{first} #{last}"
41
- end
42
-
43
39
  def projects
44
40
  permissions.keys
45
41
  end
@@ -50,7 +46,7 @@ module Etna
50
46
  viewer: /[Vv]/,
51
47
  restricted: /[AEV]/,
52
48
  }
53
- def has_roles(project, *roles)
49
+ def has_any_role?(project, *roles)
54
50
  perm = permissions[project.to_s]
55
51
 
56
52
  return false unless perm
@@ -59,15 +55,23 @@ module Etna
59
55
  end
60
56
 
61
57
  def is_superuser? project=nil
62
- has_roles(:administration, :admin)
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)
63
67
  end
64
68
 
65
69
  def can_edit? project
66
- is_superuser? || has_roles(project, :admin, :editor)
70
+ is_supereditor? || has_any_role?(project, :admin, :editor)
67
71
  end
68
72
 
69
73
  def can_view? project
70
- is_superuser? || has_roles(project, :admin, :editor, :viewer)
74
+ is_superviewer? || has_any_role?(project, :admin, :editor, :viewer)
71
75
  end
72
76
 
73
77
  # superusers - administrators of the Administration group - cannot
@@ -79,7 +83,7 @@ module Etna
79
83
  end
80
84
 
81
85
  def is_admin? project
82
- is_superuser? || has_roles(project, :admin)
86
+ is_superuser? || has_any_role?(project, :admin)
83
87
  end
84
88
 
85
89
  def active? project=nil
data/lib/helpers.rb CHANGED
@@ -57,9 +57,9 @@ module WithEtnaClients
57
57
  **EtnaApp.instance.config(:metis, environment) || {})
58
58
  end
59
59
 
60
- def janus_client
60
+ def janus_client(opts={})
61
61
  @janus_client ||= Etna::Clients::Janus.new(
62
- token: token,
62
+ token: opts.has_key?(:token) ? opts[:token] : token,
63
63
  ignore_ssl: EtnaApp.instance.config(:ignore_ssl),
64
64
  **EtnaApp.instance.config(:janus, environment) || {})
65
65
  end
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.28
4
+ version: 0.1.33
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-02-17 00:00:00.000000000 Z
11
+ date: 2021-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: concurrent-ruby
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: See summary
84
98
  email: Saurabh.Asthana@ucsf.edu
85
99
  executables:
@@ -103,6 +117,8 @@ files:
103
117
  - lib/etna/clients/janus.rb
104
118
  - lib/etna/clients/janus/client.rb
105
119
  - lib/etna/clients/janus/models.rb
120
+ - lib/etna/clients/janus/workflows.rb
121
+ - lib/etna/clients/janus/workflows/generate_token_workflow.rb
106
122
  - lib/etna/clients/magma.rb
107
123
  - lib/etna/clients/magma/client.rb
108
124
  - lib/etna/clients/magma/formatting.rb