etna 0.1.13 → 0.1.19
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.
- checksums.yaml +4 -4
- data/bin/etna +18 -0
- data/etna.completion +926 -0
- data/etna_app.completion +133 -0
- data/ext/completions/extconf.rb +20 -0
- data/lib/commands.rb +360 -0
- data/lib/etna.rb +6 -0
- data/lib/etna/application.rb +46 -22
- data/lib/etna/client.rb +82 -48
- data/lib/etna/clients.rb +4 -0
- data/lib/etna/clients/enum.rb +9 -0
- data/lib/etna/clients/janus.rb +2 -0
- data/lib/etna/clients/janus/client.rb +73 -0
- data/lib/etna/clients/janus/models.rb +78 -0
- data/lib/etna/clients/magma.rb +4 -0
- data/lib/etna/clients/magma/client.rb +80 -0
- data/lib/etna/clients/magma/formatting.rb +1 -0
- data/lib/etna/clients/magma/formatting/models_csv.rb +345 -0
- data/lib/etna/clients/magma/models.rb +579 -0
- data/lib/etna/clients/magma/workflows.rb +10 -0
- data/lib/etna/clients/magma/workflows/add_project_models_workflow.rb +78 -0
- data/lib/etna/clients/magma/workflows/attribute_actions_from_json_workflow.rb +62 -0
- data/lib/etna/clients/magma/workflows/create_project_workflow.rb +117 -0
- data/lib/etna/clients/magma/workflows/crud_workflow.rb +85 -0
- data/lib/etna/clients/magma/workflows/ensure_containing_record_workflow.rb +44 -0
- data/lib/etna/clients/magma/workflows/file_attributes_blank_workflow.rb +68 -0
- data/lib/etna/clients/magma/workflows/file_linking_workflow.rb +115 -0
- data/lib/etna/clients/magma/workflows/json_converters.rb +81 -0
- data/lib/etna/clients/magma/workflows/json_validators.rb +447 -0
- data/lib/etna/clients/magma/workflows/model_synchronization_workflow.rb +306 -0
- data/lib/etna/clients/magma/workflows/record_synchronization_workflow.rb +63 -0
- data/lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb +178 -0
- data/lib/etna/clients/metis.rb +3 -0
- data/lib/etna/clients/metis/client.rb +239 -0
- data/lib/etna/clients/metis/models.rb +313 -0
- data/lib/etna/clients/metis/workflows.rb +2 -0
- data/lib/etna/clients/metis/workflows/metis_download_workflow.rb +37 -0
- data/lib/etna/clients/metis/workflows/metis_upload_workflow.rb +137 -0
- data/lib/etna/clients/polyphemus.rb +3 -0
- data/lib/etna/clients/polyphemus/client.rb +33 -0
- data/lib/etna/clients/polyphemus/models.rb +68 -0
- data/lib/etna/clients/polyphemus/workflows.rb +1 -0
- data/lib/etna/clients/polyphemus/workflows/set_configuration_workflow.rb +47 -0
- data/lib/etna/command.rb +243 -5
- data/lib/etna/controller.rb +4 -0
- data/lib/etna/directed_graph.rb +56 -0
- data/lib/etna/environment_scoped.rb +19 -0
- data/lib/etna/generate_autocompletion_script.rb +131 -0
- data/lib/etna/hmac.rb +1 -0
- data/lib/etna/json_serializable_struct.rb +37 -0
- data/lib/etna/logger.rb +15 -1
- data/lib/etna/multipart_serializable_nested_hash.rb +50 -0
- data/lib/etna/parse_body.rb +1 -1
- data/lib/etna/route.rb +1 -1
- data/lib/etna/server.rb +3 -0
- data/lib/etna/spec/vcr.rb +98 -0
- data/lib/etna/templates/attribute_actions_template.json +43 -0
- data/lib/etna/test_auth.rb +4 -2
- data/lib/etna/user.rb +11 -1
- data/lib/helpers.rb +87 -0
- metadata +69 -5
@@ -0,0 +1,43 @@
|
|
1
|
+
// Make sure to remove all comments before using -- JSON doesn't allow comments!
|
2
|
+
[
|
3
|
+
// Attribute actions can be "add_attribute", "update_attribute", "rename_attribute", or "add_link".
|
4
|
+
// These are all executed at the same time -- so you can't "update" an attribute that you "add"
|
5
|
+
// in the same file -- everything must already exist on the server."
|
6
|
+
{
|
7
|
+
"action_name": "add_attribute",
|
8
|
+
"model_name": "assay_name", // Each action must include a model_name that it applies to.
|
9
|
+
"attribute_type": "string", // When adding, you must include attribute_type, attribute_name, desc, and display_name.
|
10
|
+
"attribute_name": "notes",
|
11
|
+
"display_name": "Notes",
|
12
|
+
"desc": "for notes that you have."
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"action_name": "update_attribute",
|
16
|
+
"model_name": "document",
|
17
|
+
"attribute_name": "version", // When updating, you must include model_name and attribute_name, but any additional values are optional.
|
18
|
+
"read_only": true
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"action_name": "rename_attribute",
|
22
|
+
"model_name": "assay_name",
|
23
|
+
"attribute_name": "vendor",
|
24
|
+
"new_attribute_name": "e_vendor" // When renaming an attribute, you need to include a "new_attribute_name" value.
|
25
|
+
},
|
26
|
+
{
|
27
|
+
// Links require two hashes inside of a "links" attribute.
|
28
|
+
"action_name": "add_link",
|
29
|
+
"links": [
|
30
|
+
{
|
31
|
+
"model_name": "assay_name",
|
32
|
+
"attribute_name": "document",
|
33
|
+
"attribute_type": "link" // One link must be of type "link". This has a one-to-one relationship with the other model.
|
34
|
+
// In this case, each assay_name has one document record, but document records can point to zero-or-more assay_name records.
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"model_name": "document",
|
38
|
+
"attribute_name": "assay_name",
|
39
|
+
"attribute_type": "collection" // The other link must be of type "collection". This is a one-to-many relationship with the other model.
|
40
|
+
}
|
41
|
+
]
|
42
|
+
}
|
43
|
+
]
|
data/lib/etna/test_auth.rb
CHANGED
@@ -43,7 +43,9 @@ module Etna
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def approve_hmac(request)
|
46
|
-
hmac_signature = etna_param(request, :signature)
|
46
|
+
hmac_signature = etna_param(request, :signature)
|
47
|
+
|
48
|
+
return false unless hmac_signature
|
47
49
|
|
48
50
|
headers = (etna_param(request, :headers)&.split(/,/) || []).map do |header|
|
49
51
|
[ header.to_sym, etna_param(request, header) ]
|
@@ -74,7 +76,7 @@ module Etna
|
|
74
76
|
end
|
75
77
|
class TestHmac < Hmac
|
76
78
|
def valid?
|
77
|
-
@test_signature == 'valid'
|
79
|
+
@test_signature == 'valid' || super
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|
data/lib/etna/user.rb
CHANGED
@@ -7,7 +7,9 @@ module Etna
|
|
7
7
|
}
|
8
8
|
|
9
9
|
def initialize params, token=nil
|
10
|
-
@first, @last, @email, @encoded_permissions = params.values_at(:first, :last, :email, :perm)
|
10
|
+
@first, @last, @email, @encoded_permissions, encoded_flags = params.values_at(:first, :last, :email, :perm, :flags)
|
11
|
+
|
12
|
+
@flags = encoded_flags&.split(/;/) || []
|
11
13
|
@token = token unless !token
|
12
14
|
raise ArgumentError, "No email given!" unless @email
|
13
15
|
end
|
@@ -30,6 +32,10 @@ module Etna
|
|
30
32
|
end.inject([],:+).to_h
|
31
33
|
end
|
32
34
|
|
35
|
+
def has_flag?(flag)
|
36
|
+
@flags.include?(flag)
|
37
|
+
end
|
38
|
+
|
33
39
|
def name
|
34
40
|
"#{first} #{last}"
|
35
41
|
end
|
@@ -75,5 +81,9 @@ module Etna
|
|
75
81
|
def is_admin? project
|
76
82
|
is_superuser? || has_roles(project, :admin)
|
77
83
|
end
|
84
|
+
|
85
|
+
def active? project=nil
|
86
|
+
permissions.keys.length > 0
|
87
|
+
end
|
78
88
|
end
|
79
89
|
end
|
data/lib/helpers.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require_relative './etna/clients'
|
2
|
+
require_relative './etna/environment_scoped'
|
3
|
+
|
4
|
+
module WithEtnaClients
|
5
|
+
def environment
|
6
|
+
EtnaApp.instance.environment
|
7
|
+
end
|
8
|
+
|
9
|
+
def token
|
10
|
+
if environment == :many
|
11
|
+
raise "You have multiple environments configured, please specify your environment by adding --environment #{@config.keys.join("|")}"
|
12
|
+
elsif environment == :none
|
13
|
+
raise "You do not have a successfully configured environment, please run #{program_name} config set https://polyphemus.ucsf.edu"
|
14
|
+
end
|
15
|
+
|
16
|
+
env_token = ENV['TOKEN']
|
17
|
+
if !env_token
|
18
|
+
puts "No environment variable TOKEN is set. You should set your token with `export TOKEN=<your.janus.token>` before running."
|
19
|
+
redirect = EtnaApp.instance.config(:auth_redirect)
|
20
|
+
|
21
|
+
if redirect.nil? && EtnaApp.instance.environment == :production
|
22
|
+
redirect = 'https://janus.ucsf.edu/'
|
23
|
+
end
|
24
|
+
|
25
|
+
unless redirect.nil?
|
26
|
+
puts "Open your browser to #{redirect} to complete login and copy your token."
|
27
|
+
end
|
28
|
+
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
|
32
|
+
env_token
|
33
|
+
end
|
34
|
+
|
35
|
+
def magma_client
|
36
|
+
@magma_client ||= Etna::Clients::Magma.new(
|
37
|
+
token: token,
|
38
|
+
ignore_ssl: EtnaApp.instance.config(:ignore_ssl),
|
39
|
+
# Persistent connections cause problem with magma restarts, until we can fix that we should force them
|
40
|
+
# to close + reopen each request.
|
41
|
+
persistent: false,
|
42
|
+
**EtnaApp.instance.config(:magma, environment) || {})
|
43
|
+
end
|
44
|
+
|
45
|
+
def metis_client
|
46
|
+
@metis_client ||= Etna::Clients::Metis.new(
|
47
|
+
token: token,
|
48
|
+
ignore_ssl: EtnaApp.instance.config(:ignore_ssl),
|
49
|
+
**EtnaApp.instance.config(:metis, environment) || {})
|
50
|
+
end
|
51
|
+
|
52
|
+
def janus_client
|
53
|
+
@janus_client ||= Etna::Clients::Janus.new(
|
54
|
+
token: token,
|
55
|
+
ignore_ssl: EtnaApp.instance.config(:ignore_ssl),
|
56
|
+
**EtnaApp.instance.config(:janus, environment) || {})
|
57
|
+
end
|
58
|
+
|
59
|
+
def polyphemus_client
|
60
|
+
@polyphemus_client ||= Etna::Clients::Polyphemus.new(
|
61
|
+
token: token,
|
62
|
+
ignore_ssl: EtnaApp.instance.config(:ignore_ssl),
|
63
|
+
**EtnaApp.instance.config(:polyphemus, environment) || {})
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
module WithLogger
|
68
|
+
def logger
|
69
|
+
EtnaApp.instance.logger
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
module StrongConfirmation
|
74
|
+
def confirm
|
75
|
+
puts "Confirm Y/n:"
|
76
|
+
input = STDIN.gets.chomp
|
77
|
+
if input != "Y"
|
78
|
+
return false
|
79
|
+
end
|
80
|
+
|
81
|
+
true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
WithEtnaClientsByEnvironment = EnvironmentScoped.new do
|
86
|
+
include WithEtnaClients
|
87
|
+
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.
|
4
|
+
version: 0.1.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Saurabh Asthana
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -66,37 +66,101 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rollbar
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: See summary
|
70
84
|
email: Saurabh.Asthana@ucsf.edu
|
71
|
-
executables:
|
72
|
-
|
85
|
+
executables:
|
86
|
+
- etna
|
87
|
+
extensions:
|
88
|
+
- ext/completions/extconf.rb
|
73
89
|
extra_rdoc_files: []
|
74
90
|
files:
|
91
|
+
- bin/etna
|
92
|
+
- etna.completion
|
93
|
+
- etna_app.completion
|
94
|
+
- ext/completions/extconf.rb
|
95
|
+
- lib/commands.rb
|
75
96
|
- lib/etna.rb
|
76
97
|
- lib/etna/application.rb
|
77
98
|
- lib/etna/auth.rb
|
78
99
|
- lib/etna/client.rb
|
100
|
+
- lib/etna/clients.rb
|
101
|
+
- lib/etna/clients/enum.rb
|
102
|
+
- lib/etna/clients/janus.rb
|
103
|
+
- lib/etna/clients/janus/client.rb
|
104
|
+
- lib/etna/clients/janus/models.rb
|
105
|
+
- lib/etna/clients/magma.rb
|
106
|
+
- lib/etna/clients/magma/client.rb
|
107
|
+
- lib/etna/clients/magma/formatting.rb
|
108
|
+
- lib/etna/clients/magma/formatting/models_csv.rb
|
109
|
+
- lib/etna/clients/magma/models.rb
|
110
|
+
- lib/etna/clients/magma/workflows.rb
|
111
|
+
- lib/etna/clients/magma/workflows/add_project_models_workflow.rb
|
112
|
+
- lib/etna/clients/magma/workflows/attribute_actions_from_json_workflow.rb
|
113
|
+
- lib/etna/clients/magma/workflows/create_project_workflow.rb
|
114
|
+
- lib/etna/clients/magma/workflows/crud_workflow.rb
|
115
|
+
- lib/etna/clients/magma/workflows/ensure_containing_record_workflow.rb
|
116
|
+
- lib/etna/clients/magma/workflows/file_attributes_blank_workflow.rb
|
117
|
+
- lib/etna/clients/magma/workflows/file_linking_workflow.rb
|
118
|
+
- lib/etna/clients/magma/workflows/json_converters.rb
|
119
|
+
- lib/etna/clients/magma/workflows/json_validators.rb
|
120
|
+
- lib/etna/clients/magma/workflows/model_synchronization_workflow.rb
|
121
|
+
- lib/etna/clients/magma/workflows/record_synchronization_workflow.rb
|
122
|
+
- lib/etna/clients/magma/workflows/update_attributes_from_csv_workflow.rb
|
123
|
+
- lib/etna/clients/metis.rb
|
124
|
+
- lib/etna/clients/metis/client.rb
|
125
|
+
- lib/etna/clients/metis/models.rb
|
126
|
+
- lib/etna/clients/metis/workflows.rb
|
127
|
+
- lib/etna/clients/metis/workflows/metis_download_workflow.rb
|
128
|
+
- lib/etna/clients/metis/workflows/metis_upload_workflow.rb
|
129
|
+
- lib/etna/clients/polyphemus.rb
|
130
|
+
- lib/etna/clients/polyphemus/client.rb
|
131
|
+
- lib/etna/clients/polyphemus/models.rb
|
132
|
+
- lib/etna/clients/polyphemus/workflows.rb
|
133
|
+
- lib/etna/clients/polyphemus/workflows/set_configuration_workflow.rb
|
79
134
|
- lib/etna/command.rb
|
80
135
|
- lib/etna/controller.rb
|
81
136
|
- lib/etna/cross_origin.rb
|
82
137
|
- lib/etna/describe_routes.rb
|
138
|
+
- lib/etna/directed_graph.rb
|
139
|
+
- lib/etna/environment_scoped.rb
|
83
140
|
- lib/etna/errors.rb
|
84
141
|
- lib/etna/ext.rb
|
142
|
+
- lib/etna/generate_autocompletion_script.rb
|
85
143
|
- lib/etna/hmac.rb
|
144
|
+
- lib/etna/json_serializable_struct.rb
|
86
145
|
- lib/etna/logger.rb
|
146
|
+
- lib/etna/multipart_serializable_nested_hash.rb
|
87
147
|
- lib/etna/parse_body.rb
|
88
148
|
- lib/etna/route.rb
|
89
149
|
- lib/etna/server.rb
|
90
150
|
- lib/etna/sign_service.rb
|
91
151
|
- lib/etna/spec.rb
|
92
152
|
- lib/etna/spec/auth.rb
|
153
|
+
- lib/etna/spec/vcr.rb
|
93
154
|
- lib/etna/symbolize_params.rb
|
155
|
+
- lib/etna/templates/attribute_actions_template.json
|
94
156
|
- lib/etna/test_auth.rb
|
95
157
|
- lib/etna/user.rb
|
158
|
+
- lib/helpers.rb
|
96
159
|
homepage: http://github.com/mountetna/etna
|
97
160
|
licenses: []
|
98
161
|
metadata: {}
|
99
|
-
post_install_message:
|
162
|
+
post_install_message: "\n\n\e[1;31mAdd 'source ~/etna.completion' to your .bashrc
|
163
|
+
to get etna command line completions!\e[0m\n\n"
|
100
164
|
rdoc_options: []
|
101
165
|
require_paths:
|
102
166
|
- lib
|