Module: WithEtnaClients
- Included in:
- EtnaApp::Config::Set, EtnaApp::Magma::Materialize, EtnaApp::Magma::Models::ApplyTemplate, EtnaApp::Magma::Models::Attributes::CreateFileLinkingCsv, EtnaApp::Magma::Models::Attributes::LoadTableFromCsv, EtnaApp::Magma::Models::Attributes::UpdateFromCsv, EtnaApp::Magma::Models::CopyTemplate, EtnaApp::Magma::Models::LoadFromRedcap, EtnaApp::Magma::Models::SetDateShiftRoot, EtnaApp::Magma::Project::Create, EtnaApp::Metis::PullArchive, EtnaApp::Metis::PutArchive, EtnaApp::Polyphemus
- Defined in:
- lib/helpers.rb
Class Method Summary collapse
-
.exit(status) ⇒ Object
Abstraction used to prevent accidental exist in specs.
Instance Method Summary collapse
- #environment ⇒ Object
- #exit(status = true) ⇒ Object
- #janus_client(opts = {}) ⇒ Object
- #magma_client(logger: nil) ⇒ Object
- #metis_client(logger: nil) ⇒ Object
- #polyphemus_client ⇒ Object
- #token(ignore_environment: false) ⇒ Object
Class Method Details
.exit(status) ⇒ Object
Abstraction used to prevent accidental exist in specs.
14 15 16 |
# File 'lib/helpers.rb', line 14 def self.exit(status) Kernel.exit(status) end |
Instance Method Details
#environment ⇒ Object
5 6 7 |
# File 'lib/helpers.rb', line 5 def environment EtnaApp.instance.environment end |
#exit(status = true) ⇒ Object
9 10 11 |
# File 'lib/helpers.rb', line 9 def exit(status=true) WithEtnaClients.exit(status) end |
#janus_client(opts = {}) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/helpers.rb', line 62 def janus_client(opts={}) @janus_client ||= Etna::Clients::Janus.new( token: opts.has_key?(:token) ? opts[:token] : token, ignore_ssl: EtnaApp.instance.config(:ignore_ssl), **EtnaApp.instance.config(:janus, environment) || {}) end |
#magma_client(logger: nil) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/helpers.rb', line 46 def magma_client(logger: nil) @magma_client ||= Etna::Clients::Magma.new( token: token, ignore_ssl: EtnaApp.instance.config(:ignore_ssl), logger: logger, **EtnaApp.instance.config(:magma, environment) || {}) end |
#metis_client(logger: nil) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/helpers.rb', line 54 def metis_client(logger: nil) @metis_client ||= Etna::Clients::Metis.new( token: token, ignore_ssl: EtnaApp.instance.config(:ignore_ssl), logger: logger, **EtnaApp.instance.config(:metis, environment) || {}) end |
#polyphemus_client ⇒ Object
69 70 71 72 73 74 |
# File 'lib/helpers.rb', line 69 def polyphemus_client @polyphemus_client ||= Etna::Clients::Polyphemus.new( token: token, ignore_ssl: EtnaApp.instance.config(:ignore_ssl), **EtnaApp.instance.config(:polyphemus, environment) || {}) end |
#token(ignore_environment: false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/helpers.rb', line 18 def token(ignore_environment: false) unless ignore_environment if environment == :many raise "You have multiple environments configured, please specify your environment by adding --environment <staging|production|development>" elsif environment == :none raise "You do not have a successfully configured environment, please run #{program_name} config set https://polyphemus.ucsf.edu" end end env_token = ENV['TOKEN'] if !env_token puts "No environment variable TOKEN is set. You should set your token with `export TOKEN=<your.janus.token>` before running." redirect = EtnaApp.instance.config(:auth_redirect) if redirect.nil? && EtnaApp.instance.environment == :production redirect = 'https://janus.ucsf.edu/' end unless redirect.nil? puts "Open your browser to #{redirect} to complete login and copy your token." end exit end env_token end |