gazer 0.3.0 → 0.3.2

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,49 @@
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/alert'
26
+
27
+ module Gzr
28
+ module Commands
29
+ class Alert
30
+ class Read < Gzr::Command
31
+ include Gzr::Alert
32
+ def initialize(notification_id,options)
33
+ super()
34
+ @notification_id = notification_id
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
+ data = read_alert_notification(@notification_id)
42
+ output.puts JSON.pretty_generate(data) unless (data.nil? || data.empty?)
43
+ output.puts "No notification found" if (data.nil? || data.empty?)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,48 @@
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/alert'
26
+
27
+ module Gzr
28
+ module Commands
29
+ class Alert
30
+ class Threshold < Gzr::Command
31
+ include Gzr::Alert
32
+ def initialize(alert_id, threshold, options)
33
+ super()
34
+ @alert_id = alert_id
35
+ @threshold = threshold
36
+ @options = options
37
+ end
38
+
39
+ def execute(input: $stdin, output: $stdout)
40
+ say_warning(@options) if @options[:debug]
41
+ with_session do
42
+ update_alert_field(@alert_id, threshold: @threshold)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ 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/alert'
26
+
27
+ module Gzr
28
+ module Commands
29
+ class Alert
30
+ class Unfollow < Gzr::Command
31
+ include Gzr::Alert
32
+ def initialize(alert_id,options)
33
+ super()
34
+ @alert_id = alert_id
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
+ unfollow_alert(@alert_id)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,200 @@
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 Alert < Thor
29
+
30
+ namespace :alert
31
+
32
+ desc 'ls', 'list alerts'
33
+ method_option :help, aliases: '-h', type: :boolean,
34
+ desc: 'Display usage information'
35
+ method_option :fields, type: :string, default: 'id,field(title,name),comparison_type,threshold,cron,custom_title,dashboard_element_id,description',
36
+ desc: 'Fields to display'
37
+ method_option :disabled, type: :boolean, default: nil,
38
+ desc: 'return disabled alerts'
39
+ method_option :all, type: :boolean, default: nil,
40
+ desc: 'return alerts from all users (must be admin)'
41
+ method_option :plain, type: :boolean, default: false,
42
+ desc: 'print without any extra formatting'
43
+ method_option :csv, type: :boolean, default: false,
44
+ desc: 'output in csv format per RFC4180'
45
+ def ls(*)
46
+ if options[:help]
47
+ invoke :help, ['ls']
48
+ else
49
+ require_relative 'alert/ls'
50
+ Gzr::Commands::Alert::Ls.new(options).execute
51
+ end
52
+ end
53
+
54
+ desc 'cat ALERT_ID', 'Output json information about an alert to screen or file'
55
+ method_option :help, aliases: '-h', type: :boolean,
56
+ desc: 'Display usage information'
57
+ method_option :dir, type: :string,
58
+ desc: 'Directory to store output file'
59
+ def cat(alert_id)
60
+ if options[:help]
61
+ invoke :help, ['cat']
62
+ else
63
+ require_relative 'alert/cat'
64
+ Gzr::Commands::Alert::Cat.new(alert_id,options).execute
65
+ end
66
+ end
67
+
68
+ desc 'follow ALERT_ID', 'Start following the alert given by ALERT_ID'
69
+ method_option :help, aliases: '-h', type: :boolean,
70
+ desc: 'Display usage information'
71
+ def follow_alert(alert_id)
72
+ if options[:help]
73
+ invoke :help, ['follow']
74
+ else
75
+ require_relative 'alert/follow'
76
+ Gzr::Commands::Alert::Follow.new(alert_id,options).execute
77
+ end
78
+ end
79
+
80
+ desc 'unfollow ALERT_ID', 'Stop following the alert given by ALERT_ID'
81
+ method_option :help, aliases: '-h', type: :boolean,
82
+ desc: 'Display usage information'
83
+ def unfollow_alert(alert_id)
84
+ if options[:help]
85
+ invoke :help, ['unfollow']
86
+ else
87
+ require_relative 'alert/unfollow'
88
+ Gzr::Commands::Alert::Unfollow.new(alert_id,options).execute
89
+ end
90
+ end
91
+
92
+ desc 'enable ALERT_ID', 'Enable the alert given by ALERT_ID'
93
+ method_option :help, aliases: '-h', type: :boolean,
94
+ desc: 'Display usage information'
95
+ def enable(alert_id)
96
+ if options[:help]
97
+ invoke :help, ['enable']
98
+ else
99
+ require_relative 'alert/enable'
100
+ Gzr::Commands::Alert::Enable.new(alert_id,options).execute
101
+ end
102
+ end
103
+
104
+ desc 'disable ALERT_ID REASON', 'Disable the alert given by ALERT_ID'
105
+ method_option :help, aliases: '-h', type: :boolean,
106
+ desc: 'Display usage information'
107
+ def disable(alert_id,reason)
108
+ if options[:help]
109
+ invoke :help, ['disable']
110
+ else
111
+ require_relative 'alert/disable'
112
+ Gzr::Commands::Alert::Disable.new(alert_id,reason,options).execute
113
+ end
114
+ end
115
+
116
+ desc 'threshold ALERT_ID THRESHOLD', 'Change the threshold of the alert given by ALERT_ID'
117
+ method_option :help, aliases: '-h', type: :boolean,
118
+ desc: 'Display usage information'
119
+ def threshold(alert_id,threshold)
120
+ if options[:help]
121
+ invoke :help, ['threshold']
122
+ else
123
+ require_relative 'alert/threshold'
124
+ Gzr::Commands::Alert::Threshold.new(alert_id,threshold,options).execute
125
+ end
126
+ end
127
+
128
+ desc 'rm ALERT_ID', 'Delete the alert given by ALERT_ID'
129
+ method_option :help, aliases: '-h', type: :boolean,
130
+ desc: 'Display usage information'
131
+ def rm(alert_id)
132
+ if options[:help]
133
+ invoke :help, ['delete']
134
+ else
135
+ require_relative 'alert/delete'
136
+ Gzr::Commands::Alert::Delete.new(alert_id,options).execute
137
+ end
138
+ end
139
+
140
+ desc 'chown ALERT_ID OWNER_ID', 'Change the owner of the alert given by ALERT_ID to OWNER_ID'
141
+ method_option :help, aliases: '-h', type: :boolean,
142
+ desc: 'Display usage information'
143
+ def chown(alert_id, owner_id)
144
+ if options[:help]
145
+ invoke :help, ['chown']
146
+ else
147
+ require_relative 'alert/chown'
148
+ Gzr::Commands::Alert::Chown.new(alert_id,owner_id,options).execute
149
+ end
150
+ end
151
+
152
+ desc 'notifications', 'Get notifications'
153
+ method_option :help, aliases: '-h', type: :boolean,
154
+ desc: 'Display usage information'
155
+ method_option :plain, type: :boolean, default: false,
156
+ desc: 'print without any extra formatting'
157
+ method_option :csv, type: :boolean, default: false,
158
+ desc: 'output in csv format per RFC4180'
159
+ def notifications(*)
160
+ if options[:help]
161
+ invoke :help, ['notifications']
162
+ else
163
+ require_relative 'alert/notifications'
164
+ Gzr::Commands::Alert::Notifications.new(options).execute
165
+ end
166
+ end
167
+
168
+ desc 'read NOTIFICATION_ID', 'Read notification id'
169
+ method_option :help, aliases: '-h', type: :boolean,
170
+ desc: 'Display usage information'
171
+ method_option :plain, type: :boolean, default: false,
172
+ desc: 'print without any extra formatting'
173
+ method_option :csv, type: :boolean, default: false,
174
+ desc: 'output in csv format per RFC4180'
175
+ def read(notification_id)
176
+ if options[:help]
177
+ invoke :help, ['read']
178
+ else
179
+ require_relative 'alert/read'
180
+ Gzr::Commands::Alert::Read.new(notification_id,options).execute
181
+ end
182
+ end
183
+
184
+ desc 'import FILE [DASHBOARD_ELEMENT_ID]', 'Import an alert from a file'
185
+ method_option :help, aliases: '-h', type: :boolean,
186
+ desc: 'Display usage information'
187
+ method_option :plain, type: :boolean,
188
+ desc: 'Provide minimal response information'
189
+ def import(file,dashboard_element_id=nil)
190
+ if options[:help]
191
+ invoke :help, ['import']
192
+ else
193
+ require_relative 'alert/import'
194
+ Gzr::Commands::Alert::Import.new(file, dashboard_element_id, options).execute
195
+ end
196
+ end
197
+
198
+ end
199
+ end
200
+ 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
@@ -44,6 +44,7 @@ module Gzr
44
44
  say_warning("options: #{@options.inspect}") if @options[:debug]
45
45
  with_session do
46
46
  data = cat_dashboard(@dashboard_id)
47
+ data = trim_dashboard(data) if @options[:trim]
47
48
 
48
49
  replacements = {}
49
50
  if @options[:transform]
@@ -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
@@ -89,6 +89,17 @@ module Gzr
89
89
  element[:result_maker] = result_maker if result_maker
90
90
  dashboard_element = create_dashboard_element(element)
91
91
  say_warning "dashboard_element #{dashboard_element.inspect}" if @options[:debug]
92
+ if new_element[:alerts]
93
+ new_element[:alerts].each do |a|
94
+ a.select! do |k,v|
95
+ (keys_to_keep('create_alert') - [:owner_id, :dashboard_element_id]).include? k
96
+ end
97
+ a[:dashboard_element_id] = dashboard_element[:id]
98
+ a[:owner_id] = @me[:id]
99
+ new_alert = create_alert(a)
100
+ say_warning "alert #{JSON.pretty_generate(new_alert)}" if @options[:debug]
101
+ end
102
+ end
92
103
  dashboard[:dashboard_elements].push dashboard_element
93
104
  [new_element[:id], dashboard_element.id]
94
105
  end
@@ -53,7 +53,9 @@ module Gzr
53
53
  method_option :transform, type: :string,
54
54
  desc: 'Fully-qualified path to a JSON file describing the transformations to apply'
55
55
  method_option :simple_filename, type: :boolean,
56
- desc: 'Use simple filename for output (Dashboard_<id>.json)'
56
+ desc: 'Use simple filename for output (Dashboard_<id>.json)'
57
+ method_option :trim, type: :boolean,
58
+ desc: 'Trim output to minimal set of fields for later import'
57
59
  def cat(dashboard_id)
58
60
  if options[:help]
59
61
  invoke :help, ['cat']
@@ -99,12 +99,14 @@ module Gzr
99
99
  end
100
100
  folder[:looks].each do |l|
101
101
  look = cat_look(l[:id])
102
+ look = trim_look(look) if @options[:trim]
102
103
  write_file("Look_#{look[:id]}_#{look[:title]}.json", base, path) do |f|
103
104
  f.write JSON.pretty_generate(look)
104
105
  end
105
106
  end
106
107
  folder[:dashboards].each do |d|
107
108
  data = cat_dashboard(d[:id])
109
+ data = trim_dashboard(data) if @options[:trim]
108
110
  write_file("Dashboard_#{data[:id]}_#{data[:title]}.json", base, path) do |f|
109
111
  f.write JSON.pretty_generate(data)
110
112
  end
@@ -66,6 +66,8 @@ module Gzr
66
66
  desc: 'Display usage information'
67
67
  method_option :plans, type: :boolean,
68
68
  desc: 'Include scheduled plans'
69
+ method_option :trim, type: :boolean,
70
+ desc: 'Trim output to minimal set of fields for later import'
69
71
  method_option :dir, type: :string, default: '.',
70
72
  desc: 'Directory to store output tree'
71
73
  method_option :tar, type: :string,
@@ -43,6 +43,7 @@ module Gzr
43
43
  say_warning("options: #{@options.inspect}") if @options[:debug]
44
44
  with_session do
45
45
  data = cat_look(@look_id)
46
+ data = trim_look(data) if @options[:trim]
46
47
  file_name = if @options[:dir]
47
48
  @options[:simple_filename] ? "Look_#{data[:id]}.json" : "Look_#{data[:id]}_#{data[:title]}.json"
48
49
  else
@@ -84,6 +84,8 @@ module Gzr
84
84
  desc: 'Include scheduled plans'
85
85
  method_option :simple_filename, type: :boolean,
86
86
  desc: 'Use simple filename for output (Look_<id>.json)'
87
+ method_option :trim, type: :boolean,
88
+ desc: 'Trim output to minimal set of fields for later import'
87
89
  def cat(look_id)
88
90
  if options[:help]
89
91
  invoke :help, ['cat']
@@ -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