gazer 0.2.37 → 0.2.42
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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +20 -20
- data/README.md +12 -0
- data/lib/gzr/command.rb +146 -4
- data/lib/gzr/commands/dashboard/cat.rb +13 -3
- data/lib/gzr/commands/dashboard/import.rb +1 -1
- data/lib/gzr/commands/look/cat.rb +10 -4
- data/lib/gzr/commands/look/import.rb +1 -1
- data/lib/gzr/commands/space/export.rb +28 -13
- data/lib/gzr/commands/space/ls.rb +37 -22
- data/lib/gzr/modules/look.rb +30 -15
- data/lib/gzr/modules/session.rb +3 -3
- data/lib/gzr/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a778eafa848d0fed39847e648457923f248355c84fcdc46ac659cb254bf44a96
|
|
4
|
+
data.tar.gz: b70966d2e4b233e5739c5595f4b0a7b34be662fe6f2d73de48142ec915377fb1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 90f24e564a4d026e79544455f010adec376ab299ee2d7ad58b0242beaa5f388dfcae5eddc393c7bdf3cfab6042296d9699db687fc535ae2e23ce19ced6d309ad
|
|
7
|
+
data.tar.gz: 273aa7ec357bf6a0f4c6ebc412e55a58d5002615b5cd66b3c4df63cd6f0bba530333ba40ce25b3b475d7a241457817fb7081131063c834e4041e022b532e3358
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ruby-2.
|
|
1
|
+
ruby-2.5.8
|
data/Gemfile
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
RUBY_VERSION = File.read(File.join(File.dirname(__FILE__), '.ruby-version')).split('-').last.chomp
|
|
23
23
|
|
|
24
|
-
ruby '2.
|
|
24
|
+
ruby '2.5.8', engine: 'ruby', engine_version: RUBY_VERSION
|
|
25
25
|
|
|
26
26
|
source "https://rubygems.org"
|
|
27
27
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
gazer (0.2.
|
|
4
|
+
gazer (0.2.42)
|
|
5
5
|
looker-sdk (~> 0.0.7)
|
|
6
6
|
netrc (~> 0.11.0)
|
|
7
7
|
pastel (~> 0.7.2)
|
|
@@ -18,7 +18,7 @@ GEM
|
|
|
18
18
|
public_suffix (>= 2.0.2, < 5.0)
|
|
19
19
|
diff-lcs (1.3)
|
|
20
20
|
equatable (0.5.0)
|
|
21
|
-
faraday (0.17.
|
|
21
|
+
faraday (0.17.3)
|
|
22
22
|
multipart-post (>= 1.2, < 3)
|
|
23
23
|
kramdown (1.16.2)
|
|
24
24
|
looker-sdk (0.0.7)
|
|
@@ -30,33 +30,33 @@ GEM
|
|
|
30
30
|
pastel (0.7.2)
|
|
31
31
|
equatable (~> 0.5.0)
|
|
32
32
|
tty-color (~> 0.4.0)
|
|
33
|
-
public_suffix (4.0.
|
|
33
|
+
public_suffix (4.0.6)
|
|
34
34
|
rake (12.3.3)
|
|
35
35
|
rouge (3.1.1)
|
|
36
|
-
rspec (3.
|
|
37
|
-
rspec-core (~> 3.
|
|
38
|
-
rspec-expectations (~> 3.
|
|
39
|
-
rspec-mocks (~> 3.
|
|
40
|
-
rspec-core (3.
|
|
41
|
-
rspec-support (~> 3.
|
|
42
|
-
rspec-expectations (3.
|
|
36
|
+
rspec (3.9.0)
|
|
37
|
+
rspec-core (~> 3.9.0)
|
|
38
|
+
rspec-expectations (~> 3.9.0)
|
|
39
|
+
rspec-mocks (~> 3.9.0)
|
|
40
|
+
rspec-core (3.9.2)
|
|
41
|
+
rspec-support (~> 3.9.3)
|
|
42
|
+
rspec-expectations (3.9.2)
|
|
43
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
44
|
-
rspec-support (~> 3.
|
|
45
|
-
rspec-mocks (3.
|
|
44
|
+
rspec-support (~> 3.9.0)
|
|
45
|
+
rspec-mocks (3.9.1)
|
|
46
46
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
47
|
-
rspec-support (~> 3.
|
|
48
|
-
rspec-support (3.
|
|
47
|
+
rspec-support (~> 3.9.0)
|
|
48
|
+
rspec-support (3.9.3)
|
|
49
49
|
rubyzip (1.3.0)
|
|
50
50
|
sawyer (0.8.2)
|
|
51
51
|
addressable (>= 2.3.5)
|
|
52
52
|
faraday (> 0.8, < 2.0)
|
|
53
|
-
strings (0.1.
|
|
53
|
+
strings (0.1.8)
|
|
54
54
|
strings-ansi (~> 0.1)
|
|
55
55
|
unicode-display_width (~> 1.5)
|
|
56
56
|
unicode_utils (~> 1.4)
|
|
57
|
-
strings-ansi (0.
|
|
57
|
+
strings-ansi (0.2.0)
|
|
58
58
|
thor (0.20.3)
|
|
59
|
-
timers (4.3.
|
|
59
|
+
timers (4.3.2)
|
|
60
60
|
tty (0.8.1)
|
|
61
61
|
bundler (~> 1.16, < 2.0)
|
|
62
62
|
equatable (~> 0.5.0)
|
|
@@ -129,9 +129,9 @@ GEM
|
|
|
129
129
|
tty-screen (~> 0.6.4)
|
|
130
130
|
tty-tree (0.1.0)
|
|
131
131
|
tty-which (0.3.0)
|
|
132
|
-
unicode-display_width (1.
|
|
132
|
+
unicode-display_width (1.7.0)
|
|
133
133
|
unicode_utils (1.4.0)
|
|
134
|
-
wisper (2.0.
|
|
134
|
+
wisper (2.0.1)
|
|
135
135
|
|
|
136
136
|
PLATFORMS
|
|
137
137
|
ruby
|
|
@@ -144,7 +144,7 @@ DEPENDENCIES
|
|
|
144
144
|
tty (~> 0.8)
|
|
145
145
|
|
|
146
146
|
RUBY VERSION
|
|
147
|
-
ruby 2.
|
|
147
|
+
ruby 2.5.8p224
|
|
148
148
|
|
|
149
149
|
BUNDLED WITH
|
|
150
150
|
1.17.3
|
data/README.md
CHANGED
|
@@ -34,6 +34,18 @@ machine foo.bar.mycompany.com
|
|
|
34
34
|
|
|
35
35
|
Make sure that the `~/.netrc` file has restricted permissions by running `chmod 600 ~/.netrc`.
|
|
36
36
|
|
|
37
|
+
### API port
|
|
38
|
+
Most instances of Looker use port 19999 for the API. Gazer will use that port by default when executing a command.
|
|
39
|
+
Looker instances that are hosted in Google Cloud direct both the API and the web
|
|
40
|
+
interface traffic through port 443, the standard https port. Some other
|
|
41
|
+
installations may also use port 443.
|
|
42
|
+
|
|
43
|
+
If your Looker instance is GCP-hosted (*.cloud.looker.com), you must specify `--port 443`, eg:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
$ gzr user me --host mycompany.cloud.looker.com --port 443
|
|
47
|
+
```
|
|
48
|
+
|
|
37
49
|
### Options that apply to many commands
|
|
38
50
|
|
|
39
51
|
#### --su option
|
data/lib/gzr/command.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# The MIT
|
|
1
|
+
# The MIT icense (MIT)
|
|
2
2
|
|
|
3
3
|
# Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc.
|
|
4
4
|
|
|
@@ -116,6 +116,148 @@ module Gzr
|
|
|
116
116
|
data
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
+
def all_color_collections()
|
|
120
|
+
data = nil
|
|
121
|
+
begin
|
|
122
|
+
data = @sdk.all_color_collections()
|
|
123
|
+
rescue NoMethodError => nme
|
|
124
|
+
say_warning "The api endpoint all_color_collections() is not implemented on this Looker instance"
|
|
125
|
+
rescue LookerSDK::NotFound => nf
|
|
126
|
+
say_warning "The current user can't query all color collections"
|
|
127
|
+
rescue LookerSDK::Error => e
|
|
128
|
+
say_error "Error querying all_color_collections()"
|
|
129
|
+
say_error e.message
|
|
130
|
+
raise
|
|
131
|
+
end
|
|
132
|
+
data
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def default_color_collection()
|
|
136
|
+
return @dcc if @dcc
|
|
137
|
+
data = nil
|
|
138
|
+
begin
|
|
139
|
+
data = @sdk.default_color_collection()
|
|
140
|
+
@dcc = data
|
|
141
|
+
rescue NoMethodError => nme
|
|
142
|
+
say_warning "The api endpoint default_color_collection() is not implemented on this Looker instance"
|
|
143
|
+
rescue LookerSDK::NotFound => nf
|
|
144
|
+
say_warning "The current user can't query the default color collection"
|
|
145
|
+
rescue LookerSDK::Error => e
|
|
146
|
+
say_error "Error querying default_color_collection()"
|
|
147
|
+
say_error e.message
|
|
148
|
+
raise
|
|
149
|
+
end
|
|
150
|
+
data
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def color_collection(collection_id)
|
|
154
|
+
data = nil
|
|
155
|
+
begin
|
|
156
|
+
data = @sdk.color_collection(collection_id)
|
|
157
|
+
rescue NoMethodError => nme
|
|
158
|
+
say_warning "The api endpoint color_collection(collection_id) is not implemented on this Looker instance"
|
|
159
|
+
rescue LookerSDK::NotFound => nf
|
|
160
|
+
say_warning "The color_collection(#{collection_id}) is not found"
|
|
161
|
+
rescue LookerSDK::Error => e
|
|
162
|
+
say_error "Error querying color_collection(#{collection_id})"
|
|
163
|
+
say_error e.message
|
|
164
|
+
raise
|
|
165
|
+
end
|
|
166
|
+
data
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def find_vis_config_reference(obj, &block)
|
|
170
|
+
if obj.respond_to?(:'has_key?') && obj.has_key?(:vis_config)
|
|
171
|
+
yield (obj[:vis_config])
|
|
172
|
+
elsif obj.is_a? Enumerable
|
|
173
|
+
obj.each { |o| find_vis_config_reference(o,&block) }
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def find_color_palette_reference(obj, default_colors=nil, &block)
|
|
178
|
+
begin
|
|
179
|
+
dcc = default_color_collection()
|
|
180
|
+
if dcc.nil?
|
|
181
|
+
say_warning "You do not have access to query color palettes so these won't be processed."
|
|
182
|
+
return
|
|
183
|
+
end
|
|
184
|
+
default_colors=color_palette_lookup!(dcc)
|
|
185
|
+
end unless default_colors
|
|
186
|
+
|
|
187
|
+
if obj.respond_to?(:'has_key?') && obj.has_key?(:collection_id) && obj.has_key?(:palette_id)
|
|
188
|
+
yield(obj,default_colors)
|
|
189
|
+
elsif obj.is_a? Enumerable
|
|
190
|
+
obj.each { |o| find_color_palette_reference(o,default_colors,&block) }
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def color_palette_lookup!(obj)
|
|
195
|
+
say_warning("performing color_palette_lookup! on #{obj.inspect}") if @options[:debug]
|
|
196
|
+
return nil unless obj.respond_to?(:'has_key?')
|
|
197
|
+
palettes = []
|
|
198
|
+
palettes += obj[:categoricalPalettes] if obj[:categoricalPalettes]
|
|
199
|
+
palettes += obj[:sequentialPalettes] if obj[:sequentialPalettes]
|
|
200
|
+
palettes += obj[:divergingPalettes] if obj[:divergingPalettes]
|
|
201
|
+
obj[:palettes]=palettes
|
|
202
|
+
say_warning("got palettes #{palettes.inspect}") if @options[:debug]
|
|
203
|
+
obj
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def rewrite_color_palette!(o,default_colors)
|
|
207
|
+
cc = nil
|
|
208
|
+
if o[:collection_id] == default_colors[:id]
|
|
209
|
+
o[:collection_default] = true
|
|
210
|
+
cc = default_colors
|
|
211
|
+
else
|
|
212
|
+
o[:collection_default] = false
|
|
213
|
+
cc = color_palette_lookup!(color_collection(o[:collection_id]))
|
|
214
|
+
end
|
|
215
|
+
return unless cc
|
|
216
|
+
o[:collection_label] = cc[:label]
|
|
217
|
+
ps = cc[:palettes].select { |p| p[:id] == o[:palette_id] }
|
|
218
|
+
if ps.length > 0
|
|
219
|
+
o[:palette_label] = ps.first[:label]
|
|
220
|
+
o[:palette_type] = ps.first[:type]
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def update_color_palette!(o,default_colors,force_default=false)
|
|
225
|
+
return unless o.has_key?(:collection_label) && o.has_key?(:palette_type)
|
|
226
|
+
|
|
227
|
+
cc = default_colors
|
|
228
|
+
if !(force_default && o[:collection_default])
|
|
229
|
+
# look up color collection by id
|
|
230
|
+
say_warning("attempting to match palette on id #{o[:collection_id]}") if @options[:debug]
|
|
231
|
+
cc = color_palette_lookup!(color_collection(o[:collection_id]))
|
|
232
|
+
if cc.nil?
|
|
233
|
+
# find color collection by name
|
|
234
|
+
say_warning("no match on id, attempting to match palette on name #{o[:collection_label]}") if @options[:debug]
|
|
235
|
+
ccs = all_color_collections()&.select { |cc| o[:collection_label] == cc[:label]}
|
|
236
|
+
if ccs.nil? || ccs.length == 0
|
|
237
|
+
# no color collection found. Use default.
|
|
238
|
+
say_warning "Color collection #{o[:collection_label]} not found. Using default."
|
|
239
|
+
cc = default_colors
|
|
240
|
+
else
|
|
241
|
+
cc = color_palette_lookup!(ccs.first)
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
o[:collection_id] = cc[:id]
|
|
246
|
+
|
|
247
|
+
# look up palette by id
|
|
248
|
+
ps = cc[:palettes].select {|p| p[:id] == o[:palette_id]}
|
|
249
|
+
if ps.length == 0
|
|
250
|
+
# find palette by type
|
|
251
|
+
ps = cc[:palettes].select {|p| p[:type] == o[:palette_type]}
|
|
252
|
+
if ps.length > 0
|
|
253
|
+
o[:palette_id] = ps.first[:id]
|
|
254
|
+
else
|
|
255
|
+
# no palette found
|
|
256
|
+
say_warning "Color palette #{o[:palette_type]} not found."
|
|
257
|
+
o.delete(:palette_id)
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
119
261
|
|
|
120
262
|
##
|
|
121
263
|
# This method accepts the name of an sdk operation, then finds the parameter for that
|
|
@@ -131,7 +273,7 @@ module Gzr
|
|
|
131
273
|
# new_obj_hash = existing_obj_hash.select do |k,v|
|
|
132
274
|
# keys_to_keep('create_new_obj').include? k
|
|
133
275
|
# end
|
|
134
|
-
|
|
276
|
+
|
|
135
277
|
def keys_to_keep(operation)
|
|
136
278
|
o = @sdk.operations[operation]
|
|
137
279
|
begin
|
|
@@ -145,12 +287,12 @@ module Gzr
|
|
|
145
287
|
schema_ref = parameters[0][:schema][:$ref].split(/\//)
|
|
146
288
|
return @sdk.swagger[schema_ref[1].to_sym][schema_ref[2].to_sym][:properties].reject { |k,v| v[:readOnly] }.keys
|
|
147
289
|
end
|
|
148
|
-
|
|
290
|
+
|
|
149
291
|
##
|
|
150
292
|
# The tty-table gem is normally used to output tabular data. This method accepts a Table
|
|
151
293
|
# object as used by the tty-table gem, and generates CSV output. It returns a string
|
|
152
294
|
# with crlf encoding
|
|
153
|
-
|
|
295
|
+
|
|
154
296
|
def render_csv(t)
|
|
155
297
|
io = StringIO.new
|
|
156
298
|
io.puts (
|
|
@@ -46,12 +46,22 @@ module Gzr
|
|
|
46
46
|
data = query_dashboard(@dashboard_id).to_attrs
|
|
47
47
|
data[:dashboard_elements].each_index do |i|
|
|
48
48
|
element = data[:dashboard_elements][i]
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
find_vis_config_reference(element) do |vis_config|
|
|
50
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
|
51
|
+
rewrite_color_palette!(o,default_colors)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
merge_result = merge_query(element[:merge_result_id])&.to_attrs if element[:merge_result_id]
|
|
55
|
+
if merge_result
|
|
51
56
|
merge_result[:source_queries].each_index do |j|
|
|
52
57
|
source_query = merge_result[:source_queries][j]
|
|
53
58
|
merge_result[:source_queries][j][:query] = query(source_query[:query_id]).to_attrs
|
|
54
59
|
end
|
|
60
|
+
find_vis_config_reference(merge_result) do |vis_config|
|
|
61
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
|
62
|
+
rewrite_color_palette!(o,default_colors)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
55
65
|
data[:dashboard_elements][i][:merge_result] = merge_result
|
|
56
66
|
end
|
|
57
67
|
end
|
|
@@ -86,7 +96,7 @@ module Gzr
|
|
|
86
96
|
elsif e[:position] === 'bottom'
|
|
87
97
|
row = max_row.to_s
|
|
88
98
|
end
|
|
89
|
-
|
|
99
|
+
|
|
90
100
|
column = '0'
|
|
91
101
|
width = e[:width].to_s
|
|
92
102
|
height = e[:height].to_s
|
|
@@ -64,7 +64,7 @@ module Gzr
|
|
|
64
64
|
end
|
|
65
65
|
filter[:dashboard_id] = dashboard.id
|
|
66
66
|
say_warning "Creating filter" if @options[:debug]
|
|
67
|
-
dashboard[:dashboard_filters].
|
|
67
|
+
dashboard[:dashboard_filters].push create_dashboard_filter(filter)
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
dashboard[:dashboard_elements] ||= []
|
|
@@ -42,10 +42,16 @@ module Gzr
|
|
|
42
42
|
def execute(input: $stdin, output: $stdout)
|
|
43
43
|
say_warning("options: #{@options.inspect}") if @options[:debug]
|
|
44
44
|
with_session do
|
|
45
|
-
data = query_look(@look_id)
|
|
46
|
-
data
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
data = query_look(@look_id).to_attrs
|
|
46
|
+
find_vis_config_reference(data) do |vis_config|
|
|
47
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
|
48
|
+
rewrite_color_palette!(o,default_colors)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
data[:scheduled_plans] = query_scheduled_plans_for_look(@look_id,"all").to_attrs if @options[:plans]
|
|
53
|
+
write_file(@options[:dir] ? "Look_#{data[:id]}_#{data[:title]}.json" : nil, @options[:dir],nil, output) do |f|
|
|
54
|
+
f.puts JSON.pretty_generate(data)
|
|
49
55
|
end
|
|
50
56
|
end
|
|
51
57
|
end
|
|
@@ -47,7 +47,7 @@ module Gzr
|
|
|
47
47
|
with_session do
|
|
48
48
|
|
|
49
49
|
@me ||= query_me("id")
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
read_file(@file) do |data|
|
|
52
52
|
look = upsert_look(@me.id,create_fetch_query(data[:query]).id,@dest_space_id,data,output: output)
|
|
53
53
|
upsert_plans_for_look(look.id,@me.id,data[:scheduled_plans]) if data[:scheduled_plans]
|
|
@@ -84,33 +84,48 @@ module Gzr
|
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def process_space(space_id, base, rel_path = nil)
|
|
87
|
-
space = query_space(space_id)
|
|
88
|
-
name = space
|
|
87
|
+
space = query_space(space_id).to_attrs
|
|
88
|
+
name = space[:name]
|
|
89
89
|
name = "nil (#{space_id})" if name.nil?
|
|
90
90
|
path = Pathname.new(name.gsub('/',"\u{2215}"))
|
|
91
91
|
path = rel_path + path if rel_path
|
|
92
92
|
|
|
93
|
-
write_file("Space_#{space
|
|
94
|
-
f.write JSON.pretty_generate(space.
|
|
93
|
+
write_file("Space_#{space[:id]}_#{name}.json", base, path) do |f|
|
|
94
|
+
f.write JSON.pretty_generate(space.reject do |k,v|
|
|
95
95
|
[:looks, :dashboards].include?(k)
|
|
96
96
|
end)
|
|
97
97
|
end
|
|
98
|
-
space
|
|
99
|
-
look = query_look(l
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
space[:looks].each do |l|
|
|
99
|
+
look = query_look(l[:id]).to_attrs
|
|
100
|
+
find_vis_config_reference(look) do |vis_config|
|
|
101
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
|
102
|
+
rewrite_color_palette!(o,default_colors)
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
write_file("Look_#{look[:id]}_#{look[:title]}.json", base, path) do |f|
|
|
106
|
+
f.write JSON.pretty_generate(look)
|
|
102
107
|
end
|
|
103
108
|
end
|
|
104
|
-
space
|
|
105
|
-
data = query_dashboard(d
|
|
109
|
+
space[:dashboards].each do |d|
|
|
110
|
+
data = query_dashboard(d[:id]).to_attrs()
|
|
106
111
|
data[:dashboard_elements].each_index do |i|
|
|
107
112
|
element = data[:dashboard_elements][i]
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
find_vis_config_reference(element) do |vis_config|
|
|
114
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
|
115
|
+
rewrite_color_palette!(o,default_colors)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
merge_result = merge_query(element[:merge_result_id])&.to_attrs() if element[:merge_result_id]
|
|
119
|
+
if merge_result
|
|
110
120
|
merge_result[:source_queries].each_index do |j|
|
|
111
121
|
source_query = merge_result[:source_queries][j]
|
|
112
122
|
merge_result[:source_queries][j][:query] = query(source_query[:query_id]).to_attrs()
|
|
113
123
|
end
|
|
124
|
+
find_vis_config_reference(merge_result) do |vis_config|
|
|
125
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
|
126
|
+
rewrite_color_palette!(o,default_colors)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
114
129
|
data[:dashboard_elements][i][:merge_result] = merge_result
|
|
115
130
|
end
|
|
116
131
|
end
|
|
@@ -120,7 +135,7 @@ module Gzr
|
|
|
120
135
|
end
|
|
121
136
|
space_children = query_space_children(space_id)
|
|
122
137
|
space_children.each do |child_space|
|
|
123
|
-
process_space(child_space
|
|
138
|
+
process_space(child_space[:id], base, path)
|
|
124
139
|
end
|
|
125
140
|
end
|
|
126
141
|
end
|
|
@@ -36,6 +36,28 @@ module Gzr
|
|
|
36
36
|
@options = options
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
def flatten_data(raw_array)
|
|
40
|
+
rows = raw_array.map do |entry|
|
|
41
|
+
entry.select do |k,v|
|
|
42
|
+
!(v.kind_of?(Array) || v.kind_of?(Hash))
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
raw_array.map do |entry|
|
|
46
|
+
entry.select do |k,v|
|
|
47
|
+
v.kind_of? Array
|
|
48
|
+
end.each do |section,section_value|
|
|
49
|
+
section_value.each do |section_entry|
|
|
50
|
+
h = {}
|
|
51
|
+
section_entry.each_pair do |k,v|
|
|
52
|
+
h[:"#{section}.#{k}"] = v
|
|
53
|
+
end
|
|
54
|
+
rows.push(h)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
rows
|
|
59
|
+
end
|
|
60
|
+
|
|
39
61
|
def execute(input: $stdin, output: $stdout)
|
|
40
62
|
say_warning("options: #{@options.inspect}") if @options[:debug]
|
|
41
63
|
with_session do
|
|
@@ -45,40 +67,33 @@ module Gzr
|
|
|
45
67
|
return nil
|
|
46
68
|
end unless space_ids && space_ids.length > 0
|
|
47
69
|
|
|
70
|
+
@options[:fields] = 'dashboards(id,title)' if @filter_spec == 'lookml'
|
|
71
|
+
f = @options[:fields]
|
|
72
|
+
|
|
48
73
|
data = space_ids.map do |space_id|
|
|
49
|
-
query_space(space_id,
|
|
74
|
+
query_space(space_id, f).to_attrs
|
|
50
75
|
end.compact
|
|
76
|
+
space_ids.each do |space_id|
|
|
77
|
+
query_space_children(space_id, 'id,name,parent_id').map {|child| child.to_attrs}.each do |child|
|
|
78
|
+
data.push child
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
51
82
|
|
|
52
83
|
begin
|
|
53
84
|
puts "No data returned for spaces #{space_ids.inspect}"
|
|
54
85
|
return nil
|
|
55
86
|
end unless data && data.length > 0
|
|
56
87
|
|
|
57
|
-
@options[:fields] = 'dashboards(id,title)' if @filter_spec == 'lookml'
|
|
58
88
|
table_hash = Hash.new
|
|
59
89
|
fields = field_names(@options[:fields])
|
|
60
|
-
table_hash[:header] =
|
|
61
|
-
rows =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if @filter_spec != 'lookml' then
|
|
65
|
-
rows << [h[:parent_id],h[:id],h[:name], nil, nil, nil, nil]
|
|
66
|
-
subspaces = query_space_children(h[:id], "id,name,parent_id")
|
|
67
|
-
rows += subspaces.map do |r|
|
|
68
|
-
h1 = r.to_attrs
|
|
69
|
-
[h1[:parent_id], h1[:id], h1[:name], nil, nil, nil, nil]
|
|
70
|
-
end
|
|
90
|
+
table_hash[:header] = fields unless @options[:plain]
|
|
91
|
+
table_hash[:rows] = flatten_data(data).map do |row|
|
|
92
|
+
fields.collect do |e|
|
|
93
|
+
row.fetch(e.to_sym,nil)
|
|
71
94
|
end
|
|
72
|
-
h[:looks].each do |r|
|
|
73
|
-
rows << [h[:parent_id],h[:id],h[:name], r[:id], r[:title], nil, nil]
|
|
74
|
-
end if h[:looks]
|
|
75
|
-
h[:dashboards].each do |r|
|
|
76
|
-
rows << [h[:parent_id],h[:id],h[:name], nil, nil, r[:id], r[:title]] unless @filter_spec == 'lookml'
|
|
77
|
-
rows << [r[:id], r[:title]] if @filter_spec == 'lookml'
|
|
78
|
-
end if h[:dashboards]
|
|
79
95
|
end
|
|
80
|
-
|
|
81
|
-
table = TTY::Table.new(table_hash) if data[0]
|
|
96
|
+
table = TTY::Table.new(table_hash)
|
|
82
97
|
alignments = fields.collect do |k|
|
|
83
98
|
(k =~ /id\)*$/) ? :right : :left
|
|
84
99
|
end
|
data/lib/gzr/modules/look.rb
CHANGED
|
@@ -136,34 +136,44 @@ module Gzr
|
|
|
136
136
|
new_look = source.select do |k,v|
|
|
137
137
|
(keys_to_keep('update_look') - [:space_id,:folder_id,:user_id,:query_id,:slug]).include? k
|
|
138
138
|
end
|
|
139
|
-
new_look[:slug] = source[:slug] if source[:slug] && !slug_used
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
new_look[:slug] = source[:slug] if source[:slug] && !slug_used
|
|
140
|
+
new_look[:deleted] = false if existing_look[:deleted]
|
|
141
|
+
new_look[:query_id] = query_id
|
|
142
|
+
return update_look(existing_look.id,new_look)
|
|
143
|
+
else
|
|
144
|
+
new_look = source.select do |k,v|
|
|
145
|
+
(keys_to_keep('create_look') - [:space_id,:folder_id,:user_id,:query_id,:slug]).include? k
|
|
146
|
+
end
|
|
147
|
+
new_look[:slug] = source[:slug] unless slug_used
|
|
148
|
+
new_look[:query_id] = query_id
|
|
149
|
+
new_look[:user_id] = user_id
|
|
150
|
+
new_look[:space_id] = space_id
|
|
151
|
+
|
|
152
|
+
find_vis_config_reference(new_look) do |vis_config|
|
|
153
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
|
154
|
+
update_color_palette!(o,default_colors)
|
|
146
155
|
end
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
new_look[:user_id] = user_id
|
|
150
|
-
new_look[:space_id] = space_id
|
|
151
|
-
|
|
152
|
-
return create_look(new_look)
|
|
156
|
+
end
|
|
157
|
+
return create_look(new_look)
|
|
153
158
|
end
|
|
154
159
|
end
|
|
155
160
|
|
|
156
161
|
def create_fetch_query(source_query)
|
|
157
162
|
new_query = source_query.select do |k,v|
|
|
158
163
|
(keys_to_keep('create_query') - [:client_id]).include? k
|
|
159
|
-
end
|
|
164
|
+
end
|
|
165
|
+
find_vis_config_reference(new_query) do |vis_config|
|
|
166
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
|
167
|
+
update_color_palette!(o,default_colors)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
160
170
|
return create_query(new_query)
|
|
161
171
|
end
|
|
162
172
|
|
|
163
173
|
def create_merge_result(merge_result)
|
|
164
174
|
new_merge_result = merge_result.select do |k,v|
|
|
165
175
|
(keys_to_keep('create_merge_query') - [:client_id,:source_queries]).include? k
|
|
166
|
-
end
|
|
176
|
+
end
|
|
167
177
|
new_merge_result[:source_queries] = merge_result[:source_queries].map do |query|
|
|
168
178
|
new_query = {}
|
|
169
179
|
new_query[:query_id] = create_fetch_query(query[:query]).id
|
|
@@ -171,6 +181,11 @@ module Gzr
|
|
|
171
181
|
new_query[:merge_fields] = query[:merge_fields]
|
|
172
182
|
new_query
|
|
173
183
|
end
|
|
184
|
+
find_vis_config_reference(new_merge_result) do |vis_config|
|
|
185
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
|
186
|
+
update_color_palette!(o,default_colors)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
174
189
|
return create_merge_query(new_merge_result)
|
|
175
190
|
end
|
|
176
191
|
end
|
data/lib/gzr/modules/session.rb
CHANGED
|
@@ -116,15 +116,15 @@ module Gzr
|
|
|
116
116
|
http.headers[:accept] = 'application/json'
|
|
117
117
|
http.headers[:user_agent] = conn_hash[:user_agent]
|
|
118
118
|
end
|
|
119
|
-
|
|
120
|
-
begin
|
|
119
|
+
|
|
120
|
+
begin
|
|
121
121
|
versions_response = agent.call(:get,"/versions")
|
|
122
122
|
versions = versions_response.data.supported_versions
|
|
123
123
|
current_version = versions_response.data.current_version
|
|
124
124
|
rescue Faraday::SSLError => e
|
|
125
125
|
raise Gzr::CLI::Error, "SSL Certificate could not be verified\nDo you need the --no-verify-ssl option or the --no-ssl option?"
|
|
126
126
|
rescue Faraday::ConnectionFailed => cf
|
|
127
|
-
raise Gzr::CLI::Error, "Connection Failed.\nDid you specify the --no-ssl option for an ssl secured server
|
|
127
|
+
raise Gzr::CLI::Error, "Connection Failed.\nDid you specify the --no-ssl option for an ssl secured server?\nYou may need to use --port=443 in some cases as well."
|
|
128
128
|
rescue LookerSDK::NotFound => nf
|
|
129
129
|
say_warning "endpoint #{root}/versions was not found"
|
|
130
130
|
end
|
data/lib/gzr/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gazer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.42
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike DeAngelo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-09-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: tty-reader
|
|
@@ -357,7 +357,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
357
357
|
- !ruby/object:Gem::Version
|
|
358
358
|
version: '0'
|
|
359
359
|
requirements: []
|
|
360
|
-
|
|
360
|
+
rubyforge_project:
|
|
361
|
+
rubygems_version: 2.7.6.2
|
|
361
362
|
signing_key:
|
|
362
363
|
specification_version: 4
|
|
363
364
|
summary: Command line tool to manage the content of a Looker instance.
|