gazer 0.3.2 → 0.3.3

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.
@@ -0,0 +1,73 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2018 Mike DeAngelo Google, Inc.
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # frozen_string_literal: true
23
+
24
+ require_relative '../../command'
25
+ require_relative '../../modules/project'
26
+ require 'tty-table'
27
+
28
+ module Gzr
29
+ module Commands
30
+ class Project
31
+ class Ls < Gzr::Command
32
+ include Gzr::Project
33
+ def initialize(options)
34
+ super()
35
+ @options = options
36
+ end
37
+
38
+ def execute(input: $stdin, output: $stdout)
39
+ say_warning(@options) if @options[:debug]
40
+ with_session do
41
+ say_warning "querying all_projects({ fields: '#{@options[:fields]}' })" if @options[:debug]
42
+ data = all_projects(fields: @options[:fields])
43
+ begin
44
+ say_ok "No projects found"
45
+ return nil
46
+ end unless data && data.length > 0
47
+
48
+ table_hash = Hash.new
49
+ fields = field_names(@options[:fields])
50
+ table_hash[:header] = fields unless @options[:plain]
51
+ expressions = fields.collect { |fn| field_expression(fn) }
52
+ table_hash[:rows] = data.map do |row|
53
+ expressions.collect do |e|
54
+ eval "row.#{e}"
55
+ end
56
+ end
57
+ table = TTY::Table.new(table_hash)
58
+ alignments = fields.collect do |k|
59
+ (k =~ /id$/) ? :right : :left
60
+ end
61
+ begin
62
+ if @options[:csv] then
63
+ output.puts render_csv(table)
64
+ else
65
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
66
+ end
67
+ end if table
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,69 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2023 Mike DeAngelo Google, Inc.
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # frozen_string_literal: true
23
+
24
+ require_relative '../../../gzr'
25
+ require_relative '../../command'
26
+ require_relative '../../modules/project'
27
+ require_relative '../../modules/filehelper'
28
+
29
+ module Gzr
30
+ module Commands
31
+ class Project
32
+ class Update < Gzr::Command
33
+ include Gzr::Project
34
+ include Gzr::FileHelper
35
+ def initialize(id,file, options)
36
+ super()
37
+ @id = id
38
+ @file = file
39
+ @options = options
40
+ end
41
+
42
+ def execute(input: $stdin, output: $stdout)
43
+ say_warning("options: #{@options.inspect}", output: output) if @options[:debug]
44
+ with_session do
45
+ if get_auth()[:workspace_id] == 'production'
46
+ say_warning %Q(
47
+ This command only works in dev mode. Use persistent sessions and
48
+ change to dev mode before running this command.
49
+
50
+ $ gzr session login --host looker.example.com
51
+ $ gzr session update dev --token_file --host looker.example.com
52
+ $ # run the command requiring dev mode here with the --token_file switch
53
+ $ gzr session logout --token_file --host looker.example.com
54
+ )
55
+ end
56
+ read_file(@file) do |data|
57
+ data.select! do |k,v|
58
+ keys_to_keep('update_project').include? k
59
+ end
60
+ project = update_project(@id, data)
61
+ output.puts "Updated project #{project[:id]}" unless @options[:plain]
62
+ output.puts project[:id] if @options[:plain]
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,104 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2023 Mike DeAngelo Google, Inc.
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # frozen_string_literal: true
23
+
24
+ require 'thor'
25
+
26
+ module Gzr
27
+ module Commands
28
+ class Project < Thor
29
+
30
+ namespace :project
31
+
32
+ desc 'ls', 'List all projects'
33
+ method_option :help, aliases: '-h', type: :boolean,
34
+ desc: 'Display usage information'
35
+ method_option :fields, type: :string, default: 'id,name,git_production_branch_name',
36
+ desc: 'Fields to display'
37
+ method_option :plain, type: :boolean, default: false,
38
+ desc: 'print without any extra formatting'
39
+ method_option :csv, type: :boolean, default: false,
40
+ desc: 'output in csv format per RFC4180'
41
+
42
+ def ls(*)
43
+ if options[:help]
44
+ invoke :help, ['ls']
45
+ else
46
+ require_relative 'project/ls'
47
+ Gzr::Commands::Project::Ls.new(options).execute
48
+ end
49
+ end
50
+
51
+ desc 'cat PROJECT_ID', 'Output json information about a project to screen or file'
52
+ method_option :help, aliases: '-h', type: :boolean,
53
+ desc: 'Display usage information'
54
+ method_option :dir, type: :string,
55
+ desc: 'Directory to store output file'
56
+ method_option :trim, type: :boolean,
57
+ desc: 'Trim output to minimal set of fields for later import'
58
+ def cat(project_id)
59
+ if options[:help]
60
+ invoke :help, ['cat']
61
+ else
62
+ require_relative 'project/cat'
63
+ Gzr::Commands::Project::Cat.new(project_id,options).execute
64
+ end
65
+ end
66
+
67
+ desc 'import PROJECT_FILE', 'Import a project from a file containing json information'
68
+ method_option :help, aliases: '-h', type: :boolean,
69
+ desc: 'Display usage information'
70
+ def import(project_file)
71
+ if options[:help]
72
+ invoke :help, ['import']
73
+ else
74
+ require_relative 'project/import'
75
+ Gzr::Commands::Project::Import.new(project_file,options).execute
76
+ end
77
+ end
78
+
79
+ desc 'update PROJECT_ID PROJECT_FILE', 'Update the given project from a file containing json information'
80
+ method_option :help, aliases: '-h', type: :boolean,
81
+ desc: 'Display usage information'
82
+ def update(project_id,project_file)
83
+ if options[:help]
84
+ invoke :help, ['update']
85
+ else
86
+ require_relative 'project/update'
87
+ Gzr::Commands::Project::Update.new(project_id,project_file,options).execute
88
+ end
89
+ end
90
+ desc 'deploy_key PROJECT_ID', 'Generate a git deploy public key for the given project'
91
+ method_option :help, aliases: '-h', type: :boolean,
92
+ desc: 'Display usage information'
93
+ def deploy_key(project_id)
94
+ if options[:help]
95
+ invoke :help, ['deploy_key']
96
+ else
97
+ require_relative 'project/deploy_key'
98
+ Gzr::Commands::Project::DeployKey.new(project_id,options).execute
99
+ end
100
+ end
101
+
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,47 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2023 Mike DeAngelo Google, Inc.
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # frozen_string_literal: true
23
+
24
+ require_relative '../../command'
25
+ require_relative '../../modules/session'
26
+
27
+ module Gzr
28
+ module Commands
29
+ class Session
30
+ class Get < Gzr::Command
31
+ include Gzr::Session
32
+ def initialize(options)
33
+ super()
34
+ @options = options
35
+ end
36
+
37
+ def execute(input: $stdin, output: $stdout)
38
+ say_warning(@options) if @options[:debug]
39
+ with_session do
40
+ auth = get_auth()
41
+ output.puts JSON.pretty_generate(auth)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,50 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2023 Mike DeAngelo Google, Inc.
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # frozen_string_literal: true
23
+
24
+ require_relative '../../command'
25
+
26
+ module Gzr
27
+ module Commands
28
+ class Session
29
+ class Login < Gzr::Command
30
+ def initialize(options)
31
+ super()
32
+ @options = options
33
+ end
34
+
35
+ def execute(input: $stdin, output: $stdout)
36
+ say_warning(@options) if @options[:debug]
37
+ login
38
+ if @options[:text]
39
+ puts @sdk.access_token
40
+ return
41
+ end
42
+ token_data = read_token_data || {}
43
+ token_data[@options[:host].to_sym] ||= {}
44
+ token_data[@options[:host].to_sym][@options[:su]&.to_sym || :default] = { token: @sdk.access_token, expiration: @sdk.access_token_expires_at }
45
+ write_token_data(token_data)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,47 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2023 Mike DeAngelo Google, Inc.
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # frozen_string_literal: true
23
+
24
+ require_relative '../../command'
25
+
26
+ module Gzr
27
+ module Commands
28
+ class Session
29
+ class Logout < Gzr::Command
30
+ def initialize(options)
31
+ super()
32
+ @options = options
33
+ end
34
+
35
+ def execute(input: $stdin, output: $stdout)
36
+ say_warning(@options) if @options[:debug]
37
+ login
38
+ @sdk.logout
39
+ token_data = read_token_data || {}
40
+ token_data[@options[:host].to_sym] ||= {}
41
+ token_data[@options[:host].to_sym]&.delete(@options[:su]&.to_sym || :default)
42
+ write_token_data(token_data)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,51 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2023 Mike DeAngelo Google, Inc.
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # frozen_string_literal: true
23
+
24
+ require_relative '../../command'
25
+ require_relative '../../modules/session'
26
+
27
+ module Gzr
28
+ module Commands
29
+ class Session
30
+ class Update < Gzr::Command
31
+ include Gzr::Session
32
+ def initialize(workspace_id,options)
33
+ super()
34
+ @options = options
35
+ @workspace_id = workspace_id
36
+ end
37
+
38
+ def execute(input: $stdin, output: $stdout)
39
+ say_warning(@options) if @options[:debug]
40
+ if !@options[:token] && !@options[:token_file]
41
+ say_warning "Setting the session workspace_id only makes sense with a persistent session using --token or --token_file options"
42
+ end
43
+ with_session do
44
+ auth = update_auth(@workspace_id)
45
+ output.puts JSON.pretty_generate(auth)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,76 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2023 Mike DeAngelo Google, Inc.
4
+
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ # this software and associated documentation files (the "Software"), to deal in
7
+ # the Software without restriction, including without limitation the rights to
8
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ # the Software, and to permit persons to whom the Software is furnished to do so,
10
+ # subject to the following conditions:
11
+
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ # frozen_string_literal: true
23
+
24
+ require 'thor'
25
+
26
+ module Gzr
27
+ module Commands
28
+ class Session < Thor
29
+
30
+ namespace :session
31
+
32
+ desc 'login', 'Create a persistent session'
33
+ method_option :text, type: :boolean, default: false,
34
+ desc: 'output token to screen instead of file'
35
+ def login(*)
36
+ if options[:help]
37
+ invoke :help, ['login']
38
+ else
39
+ require_relative 'session/login'
40
+ Gzr::Commands::Session::Login.new(options).execute
41
+ end
42
+ end
43
+
44
+ desc 'logout', 'End a persistent session'
45
+ def logout(*)
46
+ if options[:help]
47
+ invoke :help, ['logout']
48
+ else
49
+ require_relative 'session/logout'
50
+ Gzr::Commands::Session::Logout.new(options).execute
51
+ end
52
+ end
53
+
54
+ desc 'get', 'Get data about current session'
55
+ def get(*)
56
+ if options[:help]
57
+ invoke :help, ['get']
58
+ else
59
+ require_relative 'session/get'
60
+ Gzr::Commands::Session::Get.new(options).execute
61
+ end
62
+ end
63
+
64
+ desc 'update WORKSPACE_ID', 'change the workspace_id of the current session'
65
+ def update(workspace_id)
66
+ if options[:help]
67
+ invoke :help, ['update']
68
+ else
69
+ require_relative 'session/update'
70
+ Gzr::Commands::Session::Update.new(workspace_id,options).execute
71
+ end
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -48,5 +48,85 @@ module Gzr
48
48
  data
49
49
  end
50
50
 
51
+ def test_connection(name, tests=nil)
52
+ data = nil
53
+
54
+ if tests.nil?
55
+ connection = cat_connection(name)
56
+ if connection.nil?
57
+ return nil
58
+ end
59
+ tests = connection[:dialect][:connection_tests]
60
+ end
61
+
62
+ begin
63
+ data = @sdk.test_connection(name, {}, tests: tests)
64
+ rescue LookerSDK::NotFound => e
65
+ return nil
66
+ rescue LookerSDK::Error => e
67
+ say_error "Error executing test_connection(#{name},#{tests})"
68
+ say_error e
69
+ raise
70
+ end
71
+ data
72
+ end
73
+
74
+ def delete_connection(name)
75
+ begin
76
+ @sdk.delete_connection(name)
77
+ rescue LookerSDK::NotFound => e
78
+ say_warning "Connection #{name} not found"
79
+ rescue LookerSDK::Error => e
80
+ say_error "Error executing delete_connection(#{name})"
81
+ say_error e
82
+ raise
83
+ end
84
+ end
85
+
86
+ def create_connection(body)
87
+ data = nil
88
+ begin
89
+ data = @sdk.create_connection(body).to_attrs
90
+ rescue LookerSDK::Error => e
91
+ say_error "Error executing create_connection(#{JSON.pretty_generate(body)})"
92
+ say_error e
93
+ raise
94
+ end
95
+ data
96
+ end
97
+
98
+ def update_connection(name,body)
99
+ data = nil
100
+ begin
101
+ data = @sdk.connection(name,body).to_attrs
102
+ rescue LookerSDK::NotFound => e
103
+ say_warning "Connection #{name} not found"
104
+ rescue LookerSDK::Error => e
105
+ say_error "Error executing update_connection(#{name},#{JSON.pretty_generate(body)})"
106
+ say_error e
107
+ raise
108
+ end
109
+ data
110
+ end
111
+
112
+ def cat_connection(name)
113
+ data = nil
114
+ begin
115
+ data = @sdk.connection(name).to_attrs
116
+ rescue LookerSDK::NotFound => e
117
+ return nil
118
+ rescue LookerSDK::Error => e
119
+ say_error "Error executing connection(#{name})"
120
+ say_error e
121
+ raise
122
+ end
123
+ data
124
+ end
125
+
126
+ def trim_connection(data)
127
+ data.select do |k,v|
128
+ (keys_to_keep('create_connection') + [:pdt_context_override]).include? k
129
+ end
130
+ end
51
131
  end
52
132
  end