Module: Gzr::Connection
- Included in:
- Gzr::Commands::Connection::Cat, Gzr::Commands::Connection::Dialects, Gzr::Commands::Connection::Import, Gzr::Commands::Connection::Ls, Gzr::Commands::Connection::Rm, Gzr::Commands::Connection::Test
- Defined in:
- lib/gzr/modules/connection.rb
Instance Method Summary collapse
- #cat_connection(name) ⇒ Object
- #create_connection(body) ⇒ Object
- #delete_connection(name) ⇒ Object
- #query_all_connections(fields = nil) ⇒ Object
- #query_all_dialects(fields = nil) ⇒ Object
- #test_connection(name, tests = nil) ⇒ Object
- #trim_connection(data) ⇒ Object
- #update_connection(name, body) ⇒ Object
Instance Method Details
#cat_connection(name) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/gzr/modules/connection.rb', line 99 def cat_connection(name) begin @sdk.connection(name).to_attrs rescue LookerSDK::NotFound => e nil rescue LookerSDK::Error => e say_error "Error executing connection(#{name})" say_error e raise end end |
#create_connection(body) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/gzr/modules/connection.rb', line 77 def create_connection(body) begin @sdk.create_connection(body).to_attrs rescue LookerSDK::Error => e say_error "Error executing create_connection(#{JSON.pretty_generate(body)})" say_error e raise end end |
#delete_connection(name) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/gzr/modules/connection.rb', line 65 def delete_connection(name) begin @sdk.delete_connection(name) rescue LookerSDK::NotFound => e say_warning "Connection #{name} not found" rescue LookerSDK::Error => e say_error "Error executing delete_connection(#{name})" say_error e raise end end |
#query_all_connections(fields = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/gzr/modules/connection.rb', line 27 def query_all_connections(fields=nil) begin @sdk.all_connections(fields ? {:fields=>fields} : nil ).collect { |e| e.to_attrs } rescue LookerSDK::Error => e say_error "Error querying all_connections({:fields=>\"#{fields}\"})" say_error e raise end end |
#query_all_dialects(fields = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/gzr/modules/connection.rb', line 37 def query_all_dialects(fields=nil) begin @sdk.all_dialect_infos(fields ? {:fields=>fields} : nil ).collect { |e| e.to_attrs } rescue LookerSDK::Error => e say_error "Error querying all_dialect_infos({:fields=>\"#{fields}\"})" say_error e raise end end |
#test_connection(name, tests = nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/gzr/modules/connection.rb', line 47 def test_connection(name, tests=nil) if tests.nil? connection = cat_connection(name) return nil if connection.nil? tests = connection[:dialect][:connection_tests] end begin @sdk.test_connection(name, {}, tests: tests).collect { |e| e.to_attrs } rescue LookerSDK::NotFound => e return [] rescue LookerSDK::Error => e say_error "Error executing test_connection(#{name},#{tests})" say_error e raise end end |
#trim_connection(data) ⇒ Object
111 112 113 114 115 |
# File 'lib/gzr/modules/connection.rb', line 111 def trim_connection(data) data.select do |k,v| (keys_to_keep('create_connection') + [:pdt_context_override]).include? k end end |
#update_connection(name, body) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/gzr/modules/connection.rb', line 87 def update_connection(name,body) begin @sdk.update_connection(name,body).to_attrs rescue LookerSDK::NotFound => e say_warning "Connection #{name} not found" rescue LookerSDK::Error => e say_error "Error executing update_connection(#{name},#{JSON.pretty_generate(body)})" say_error e raise end end |