gazer 0.3.1 → 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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/Gemfile.lock +1 -1
  4. data/lib/gzr/cli.rb +12 -1
  5. data/lib/gzr/command.rb +82 -1
  6. data/lib/gzr/commands/alert/cat.rb +52 -0
  7. data/lib/gzr/commands/alert/chown.rb +48 -0
  8. data/lib/gzr/commands/alert/delete.rb +47 -0
  9. data/lib/gzr/commands/alert/disable.rb +48 -0
  10. data/lib/gzr/commands/alert/enable.rb +47 -0
  11. data/lib/gzr/commands/alert/follow.rb +47 -0
  12. data/lib/gzr/commands/alert/import.rb +65 -0
  13. data/lib/gzr/commands/alert/ls.rb +76 -0
  14. data/lib/gzr/commands/alert/notifications.rb +74 -0
  15. data/lib/gzr/commands/alert/read.rb +49 -0
  16. data/lib/gzr/commands/alert/threshold.rb +48 -0
  17. data/lib/gzr/commands/alert/unfollow.rb +47 -0
  18. data/lib/gzr/commands/alert.rb +200 -0
  19. data/lib/gzr/commands/connection/cat.rb +66 -0
  20. data/lib/gzr/commands/connection/import.rb +78 -0
  21. data/lib/gzr/commands/connection/rm.rb +50 -0
  22. data/lib/gzr/commands/connection/test.rb +69 -0
  23. data/lib/gzr/commands/connection.rb +67 -1
  24. data/lib/gzr/commands/dashboard/cat.rb +1 -1
  25. data/lib/gzr/commands/dashboard/import.rb +12 -1
  26. data/lib/gzr/commands/project/cat.rb +58 -0
  27. data/lib/gzr/commands/project/deploy_key.rb +60 -0
  28. data/lib/gzr/commands/project/import.rb +68 -0
  29. data/lib/gzr/commands/project/ls.rb +73 -0
  30. data/lib/gzr/commands/project/update.rb +69 -0
  31. data/lib/gzr/commands/project.rb +104 -0
  32. data/lib/gzr/commands/session/get.rb +47 -0
  33. data/lib/gzr/commands/session/login.rb +50 -0
  34. data/lib/gzr/commands/session/logout.rb +47 -0
  35. data/lib/gzr/commands/session/update.rb +51 -0
  36. data/lib/gzr/commands/session.rb +76 -0
  37. data/lib/gzr/modules/alert.rb +169 -0
  38. data/lib/gzr/modules/connection.rb +80 -0
  39. data/lib/gzr/modules/dashboard.rb +23 -2
  40. data/lib/gzr/modules/project.rb +106 -0
  41. data/lib/gzr/modules/session.rb +81 -7
  42. data/lib/gzr/version.rb +1 -1
  43. metadata +32 -2
@@ -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
@@ -0,0 +1,169 @@
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
+ module Gzr
25
+ module Alert
26
+ def get_alert(alert_id)
27
+ data = nil
28
+ begin
29
+ data = @sdk.get_alert(alert_id)
30
+ rescue LookerSDK::NotFound => e
31
+ # do nothing
32
+ rescue LookerSDK::Error => e
33
+ say_error "Error querying get_alert(#{alert_id})"
34
+ say_error e
35
+ raise
36
+ end
37
+ if data[:owner_id]
38
+ owner = get_user_by_id(data[:owner_id])
39
+ data[:owner] = owner.to_attrs.select do |k,v|
40
+ [:email,:last_name,:first_name].include?(k) && !(v.nil? || v.empty?)
41
+ end
42
+ end
43
+ data
44
+ end
45
+
46
+ def search_alerts(group_by: nil, fields: nil, disabled: nil, frequency: nil, condition_met: nil, last_run_start: nil, last_run_end: nil, all_owners: nil)
47
+ data = []
48
+ begin
49
+ req = {}
50
+ req[:group_by] = group_by unless group_by.nil?
51
+ req[:fields] = fields unless fields.nil?
52
+ req[:disabled] = disabled unless disabled.nil?
53
+ req[:frequency] = frequency unless frequency.nil?
54
+ req[:condition_met] = condition_met unless condition_met.nil?
55
+ req[:last_run_start] = last_run_start unless last_run_start.nil?
56
+ req[:last_run_end] = last_run_end unless last_run_end.nil?
57
+ req[:all_owners] = all_owners unless all_owners.nil?
58
+ req[:limit] = 64
59
+ loop do
60
+ page = @sdk.search_alerts(req)
61
+ data+=page
62
+ break unless page.length == req[:limit]
63
+ req[:offset] = (req[:offset] || 0) + req[:limit]
64
+ end
65
+ rescue LookerSDK::NotFound => e
66
+ # do nothing
67
+ rescue LookerSDK::Error => e
68
+ say_error "Error querying search_alerts(#{JSON.pretty_generate(req)})"
69
+ say_error e
70
+ raise
71
+ end
72
+ data
73
+ end
74
+
75
+ def follow_alert(alert_id)
76
+ begin
77
+ @sdk.follow_alert(alert_id)
78
+ rescue LookerSDK::Error => e
79
+ say_error "Error following alert(#{alert_id})"
80
+ say_error e
81
+ raise
82
+ end
83
+ end
84
+
85
+ def unfollow_alert(alert_id)
86
+ begin
87
+ @sdk.unfollow_alert(alert_id)
88
+ rescue LookerSDK::Error => e
89
+ say_error "Error following alert(#{alert_id})"
90
+ say_error e
91
+ raise
92
+ end
93
+ end
94
+
95
+ def update_alert_field(alert_id, owner_id: nil, is_disabled: nil, disabled_reason: nil, is_public: nil, threshold: nil)
96
+ req = {}
97
+ req[:owner_id] = owner_id unless owner_id.nil?
98
+ req[:is_disabled] = is_disabled unless is_disabled.nil?
99
+ req[:disabled_reason] = disabled_reason unless disabled_reason.nil?
100
+ req[:is_public] = is_public unless is_public.nil?
101
+ req[:threshold] = threshold unless threshold.nil?
102
+ data = nil
103
+ begin
104
+ data = @sdk.update_alert_field(alert_id, req)
105
+ rescue LookerSDK::Error => e
106
+ say_error "Error calling update_alert_field(#{alert_id},#{JSON.pretty_generate(req)})"
107
+ say_error e
108
+ raise
109
+ end
110
+ data
111
+ end
112
+
113
+ def delete_alert(alert_id)
114
+ begin
115
+ @sdk.delete_alert(alert_id)
116
+ rescue LookerSDK::Error => e
117
+ say_error "Error calling delete_alert(#{alert_id})"
118
+ say_error e
119
+ raise
120
+ end
121
+ end
122
+
123
+ def alert_notifications()
124
+ data = []
125
+ req = {}
126
+ begin
127
+ req[:limit] = 64
128
+ loop do
129
+ page = @sdk.alert_notifications(req)
130
+ data+=page
131
+ break unless page.length == req[:limit]
132
+ req[:offset] = (req[:offset] || 0) + req[:limit]
133
+ end
134
+ rescue LookerSDK::NotFound => e
135
+ # do nothing
136
+ rescue LookerSDK::Error => e
137
+ say_error "Error querying alert_notifications()"
138
+ say_error e
139
+ raise
140
+ end
141
+ data
142
+ end
143
+
144
+ def read_alert_notification(notification_id)
145
+ data = nil
146
+ begin
147
+ data = @sdk.read_alert_notification(notification_id)
148
+ rescue LookerSDK::Error => e
149
+ say_error "Error calling read_alert_notification(#{notification_id})"
150
+ say_error e
151
+ raise
152
+ end
153
+ data.to_attrs
154
+ end
155
+
156
+ def create_alert(req)
157
+ data = nil
158
+ begin
159
+ data = @sdk.create_alert(req)
160
+ rescue LookerSDK::Error => e
161
+ say_error "Error calling create_alert(#{JSON.pretty_generate(req)})"
162
+ say_error e
163
+ raise
164
+ end
165
+ data.to_attrs
166
+ end
167
+
168
+ end
169
+ 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
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
 
3
- # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc.
3
+ # Copyright (c) 2023 Mike DeAngelo Google, Inc.
4
4
 
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  # this software and associated documentation files (the "Software"), to deal in
@@ -20,9 +20,12 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  # frozen_string_literal: true
23
+ require_relative 'alert'
23
24
 
24
25
  module Gzr
25
26
  module Dashboard
27
+ include Gzr::Alert
28
+
26
29
  def query_dashboard(dashboard_id)
27
30
  data = nil
28
31
  begin
@@ -249,6 +252,17 @@ module Gzr
249
252
  rewrite_color_palette!(o,default_colors)
250
253
  end
251
254
  end
255
+ alerts = search_alerts(fields: 'id,dashboard_element_id', group_by: 'dashboard', all_owners: true)
256
+ alerts.map!{|v| v.to_attrs}
257
+ say_warning alerts if @options[:debug]
258
+ data[:dashboard_elements].each do |e|
259
+ alerts_found = alerts.select { |a| a[:dashboard_element_id] == e[:id]}
260
+ say_warning "Found alerts #{alerts_found}" if @options[:debug]
261
+ alerts_entries = alerts_found.map { |a| get_alert(a[:id]).to_attrs }
262
+ say_warning "Looked up alerts entries #{alerts_entries}" if @options[:debug]
263
+ e[:alerts] = alerts_entries
264
+ end
265
+
252
266
  merge_result = merge_query(element[:merge_result_id])&.to_attrs if element[:merge_result_id]
253
267
  if merge_result
254
268
  merge_result[:source_queries].each_index do |j|
@@ -274,7 +288,7 @@ module Gzr
274
288
 
275
289
  trimmed[:dashboard_elements] = data[:dashboard_elements].map do |de|
276
290
  new_de = de.select do |k,v|
277
- (keys_to_keep('update_dashboard_element') + [:id,:look,:query,:merge_result]).include? k
291
+ (keys_to_keep('update_dashboard_element') + [:id,:look,:query,:merge_result,:alerts]).include? k
278
292
  end
279
293
  if de[:look]
280
294
  new_de[:look] = de[:look].select do |k,v|
@@ -301,6 +315,13 @@ module Gzr
301
315
  end
302
316
  end
303
317
  end
318
+ if de[:alerts]
319
+ new_de[:alerts] = de[:alerts].map do |a|
320
+ a.select do |k,v|
321
+ (keys_to_keep('update_alert') + [:id,:owner]).include? k
322
+ end
323
+ end
324
+ end
304
325
  new_de
305
326
  end
306
327
 
@@ -0,0 +1,106 @@
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
+ module Gzr
25
+ module Project
26
+
27
+ def all_projects(fields: 'id')
28
+ data = []
29
+ begin
30
+ data = @sdk.all_projects({ fields: fields })
31
+ rescue LookerSDK::NotFound => e
32
+ return []
33
+ rescue LookerSDK::Error => e
34
+ say_error "Error querying all_projects(#{fields})"
35
+ say_error e
36
+ raise
37
+ end
38
+ data
39
+ end
40
+
41
+ def cat_project(project_id)
42
+ begin
43
+ return @sdk.project(project_id)&.to_attrs
44
+ rescue LookerSDK::NotFound => e
45
+ return nil
46
+ rescue LookerSDK::Error => e
47
+ say_error "Error getting project(#{project_id})"
48
+ say_error e
49
+ raise
50
+ end
51
+ end
52
+
53
+ def trim_project(data)
54
+ data.select do |k,v|
55
+ keys_to_keep('create_project').include? k
56
+ end
57
+ end
58
+
59
+ def create_project(body)
60
+ begin
61
+ return @sdk.create_project(body)&.to_attrs
62
+ rescue LookerSDK::Error => e
63
+ say_error "Error running create_project(#{JSON.pretty_generate(body)})"
64
+ say_error e
65
+ raise
66
+ end
67
+ end
68
+
69
+ def update_project(id,body)
70
+ begin
71
+ return @sdk.update_project(id,body)&.to_attrs
72
+ rescue LookerSDK::NotFound => e
73
+ return nil
74
+ rescue LookerSDK::Error => e
75
+ say_error "Error running update_project(#{id},#{JSON.pretty_generate(body)})"
76
+ say_error e
77
+ raise
78
+ end
79
+ end
80
+
81
+ def git_deploy_key(id)
82
+ begin
83
+ return @sdk.git_deploy_key(id)
84
+ rescue LookerSDK::NotFound => e
85
+ return nil
86
+ rescue LookerSDK::Error => e
87
+ say_error "Error running git_deploy_key(#{id})"
88
+ say_error e
89
+ raise
90
+ end
91
+ end
92
+
93
+ def create_git_deploy_key(id)
94
+ begin
95
+ return @sdk.create_git_deploy_key(id)
96
+ rescue LookerSDK::NotFound => e
97
+ return nil
98
+ rescue LookerSDK::Error => e
99
+ say_error "Error running create_git_deploy_key(#{id})"
100
+ say_error e
101
+ raise
102
+ end
103
+ end
104
+
105
+ end
106
+ end