gazer 0.2.50 → 0.2.53
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/CHANGELOG.md +24 -0
- data/Gemfile.lock +2 -2
- data/lib/gzr/cli.rb +4 -0
- data/lib/gzr/commands/dashboard/cat.rb +1 -23
- data/lib/gzr/commands/dashboard/import.rb +10 -1
- data/lib/gzr/commands/look/cat.rb +1 -8
- data/lib/gzr/commands/look/import.rb +11 -0
- data/lib/gzr/commands/space/export.rb +4 -28
- data/lib/gzr/commands/space.rb +2 -0
- data/lib/gzr/modules/dashboard.rb +27 -0
- data/lib/gzr/modules/look.rb +12 -0
- data/lib/gzr/modules/plan.rb +6 -0
- data/lib/gzr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5f44f5af050d76e652c008b4cd8210240522688232a8f747601ad8dd59032b7
|
4
|
+
data.tar.gz: 3f0a76d313a7c640a85f77212af8639f44d39b392604509185847a6e4a3899d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e49f6a5f997b55e16e090ab10dd372e0c3ff620d82a13a24379ca8fcb411486cc93e5272883c7f545e0fe544813cd02194f603f405da0b69fac92064b94560e
|
7
|
+
data.tar.gz: a0fa72d8e16b6c4d318814d96aade1434b924b73c6caebfa01f046190fe0fc93ed68f37737d07f2308367c1514d65b352ed0ccb8e92c7b986e1ff43654e9a6f9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### [0.2.53](https://www.github.com/looker-open-source/gzr/compare/v0.2.52...v0.2.53) (2021-12-14)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* fix version ([#121](https://www.github.com/looker-open-source/gzr/issues/121)) ([f9b0b22](https://www.github.com/looker-open-source/gzr/commit/f9b0b2237eb3c520aabc2f1ff5a63ddf6c934ce4))
|
9
|
+
|
10
|
+
### [0.2.52](https://www.github.com/looker-open-source/gzr/compare/v0.2.51...v0.2.52) (2021-12-14)
|
11
|
+
|
12
|
+
|
13
|
+
### Bug Fixes
|
14
|
+
|
15
|
+
* version number ([#119](https://www.github.com/looker-open-source/gzr/issues/119)) ([b55a892](https://www.github.com/looker-open-source/gzr/commit/b55a892d8d040ce4547924d613a590877e129322))
|
16
|
+
|
17
|
+
### [0.2.51](https://www.github.com/looker-open-source/gzr/compare/v0.2.50...v0.2.51) (2021-12-14)
|
18
|
+
|
19
|
+
|
20
|
+
### Bug Fixes
|
21
|
+
|
22
|
+
* detect if dashboard import gets a look file and vice versa, warn on importing a deleted dashboard or look ([#116](https://www.github.com/looker-open-source/gzr/issues/116)) ([a12dc25](https://www.github.com/looker-open-source/gzr/commit/a12dc2525bed55816b368306f2d05a24dc07aaf4))
|
23
|
+
* Gemfile.lock was out of date ([a4e49c3](https://www.github.com/looker-open-source/gzr/commit/a4e49c3972772e0629a8f1589172ddd136ee7e21))
|
24
|
+
* refactored look and dashboard cat commands and space export to use the same code to generate each look and dashboard file. ([#114](https://www.github.com/looker-open-source/gzr/issues/114)) ([8dadd50](https://www.github.com/looker-open-source/gzr/commit/8dadd500376e2b971c38dbcd69f507268a3e6b9e))
|
25
|
+
* remove Thor deprecation warning ([#115](https://www.github.com/looker-open-source/gzr/issues/115)) ([1100c5a](https://www.github.com/looker-open-source/gzr/commit/1100c5a24b0626c01c6248d87172c7ab624bf42f))
|
26
|
+
|
3
27
|
### [0.2.50](https://www.github.com/looker-open-source/gzr/compare/v0.2.49...v0.2.50) (2021-11-19)
|
4
28
|
|
5
29
|
|
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.53)
|
5
5
|
looker-sdk (~> 0.1.1)
|
6
6
|
net-http-persistent (~> 4.0, >= 4.0.1)
|
7
7
|
netrc (~> 0.11.0)
|
@@ -38,7 +38,7 @@ GEM
|
|
38
38
|
faraday-net_http_persistent (1.2.0)
|
39
39
|
faraday-patron (1.0.0)
|
40
40
|
faraday-rack (1.0.0)
|
41
|
-
looker-sdk (0.1.
|
41
|
+
looker-sdk (0.1.2)
|
42
42
|
faraday (>= 1.2, < 2.0)
|
43
43
|
sawyer (~> 0.8)
|
44
44
|
multipart-post (2.1.1)
|
data/lib/gzr/cli.rb
CHANGED
@@ -29,6 +29,10 @@ module Gzr
|
|
29
29
|
#
|
30
30
|
# @api public
|
31
31
|
class CLI < Thor
|
32
|
+
def self.exit_on_failure?
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
32
36
|
class_option :debug, type: :boolean, default: false, desc: 'Run in debug mode'
|
33
37
|
class_option :host, type: :string, default: 'localhost', desc: 'Looker Host'
|
34
38
|
class_option :port, type: :string, default: '19999', desc: 'Looker API Port'
|
@@ -43,29 +43,7 @@ module Gzr
|
|
43
43
|
def execute(*args, input: $stdin, output: $stdout)
|
44
44
|
say_warning("options: #{@options.inspect}") if @options[:debug]
|
45
45
|
with_session("3.1") do
|
46
|
-
data =
|
47
|
-
data[:dashboard_elements].each_index do |i|
|
48
|
-
element = data[:dashboard_elements][i]
|
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
|
56
|
-
merge_result[:source_queries].each_index do |j|
|
57
|
-
source_query = merge_result[:source_queries][j]
|
58
|
-
merge_result[:source_queries][j][:query] = query(source_query[:query_id]).to_attrs
|
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
|
65
|
-
data[:dashboard_elements][i][:merge_result] = merge_result
|
66
|
-
end
|
67
|
-
end
|
68
|
-
data[:scheduled_plans] = query_scheduled_plans_for_dashboard(@dashboard_id,"all").to_attrs if @options[:plans]
|
46
|
+
data = cat_dashboard(@dashboard_id)
|
69
47
|
|
70
48
|
replacements = {}
|
71
49
|
if @options[:transform]
|
@@ -53,8 +53,17 @@ module Gzr
|
|
53
53
|
|
54
54
|
read_file(@file) do |data|
|
55
55
|
|
56
|
-
|
56
|
+
if data[:deleted]
|
57
|
+
say_warning("Attempt to import a deleted dashboard!")
|
58
|
+
say_warning("This may result in errors.")
|
59
|
+
end
|
57
60
|
|
61
|
+
if !data[:dashboard_elements]
|
62
|
+
say_error("File contains no dashboard_elements! Is this a look?")
|
63
|
+
raise Gzr::CLI::Error, "import file is not a valid dashboard"
|
64
|
+
end
|
65
|
+
|
66
|
+
dashboard = sync_dashboard(data,@dest_space_id, output: output)
|
58
67
|
|
59
68
|
dashboard[:dashboard_filters] ||= []
|
60
69
|
source_filters = data[:dashboard_filters].sort { |a,b| a[:row] <=> b[:row] }
|
@@ -42,14 +42,7 @@ 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 =
|
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]
|
45
|
+
data = cat_look(@look_id)
|
53
46
|
file_name = if @options[:dir]
|
54
47
|
@options[:simple_filename] ? "Look_#{data[:id]}.json" : "Look_#{data[:id]}_#{data[:title]}.json"
|
55
48
|
else
|
@@ -49,6 +49,17 @@ module Gzr
|
|
49
49
|
@me ||= query_me("id")
|
50
50
|
|
51
51
|
read_file(@file) do |data|
|
52
|
+
|
53
|
+
if data[:deleted]
|
54
|
+
say_warning("Attempt to import a deleted look!")
|
55
|
+
say_warning("This may result in errors.")
|
56
|
+
end
|
57
|
+
|
58
|
+
if data[:dashboard_elements]
|
59
|
+
say_error("File contains dashboard_elements! Is this a dashboard?")
|
60
|
+
raise Gzr::CLI::Error, "import file is not a valid look"
|
61
|
+
end
|
62
|
+
|
52
63
|
look = upsert_look(@me.id,create_fetch_query(data[:query]).id,@dest_space_id,data,output: output)
|
53
64
|
upsert_plans_for_look(look.id,@me.id,data[:scheduled_plans]) if data[:scheduled_plans]
|
54
65
|
output.puts "Imported look #{look.id}" unless @options[:plain]
|
@@ -25,6 +25,7 @@ require_relative '../../command'
|
|
25
25
|
require_relative '../../modules/space'
|
26
26
|
require_relative '../../modules/look'
|
27
27
|
require_relative '../../modules/dashboard'
|
28
|
+
require_relative '../../modules/plan'
|
28
29
|
require_relative '../../modules/filehelper'
|
29
30
|
require 'pathname'
|
30
31
|
require 'stringio'
|
@@ -37,6 +38,7 @@ module Gzr
|
|
37
38
|
include Gzr::Space
|
38
39
|
include Gzr::Look
|
39
40
|
include Gzr::Dashboard
|
41
|
+
include Gzr::Plan
|
40
42
|
include Gzr::FileHelper
|
41
43
|
def initialize(space_id, options)
|
42
44
|
super()
|
@@ -96,39 +98,13 @@ module Gzr
|
|
96
98
|
end)
|
97
99
|
end
|
98
100
|
space[:looks].each do |l|
|
99
|
-
look =
|
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
|
101
|
+
look = cat_look(l[:id])
|
105
102
|
write_file("Look_#{look[:id]}_#{look[:title]}.json", base, path) do |f|
|
106
103
|
f.write JSON.pretty_generate(look)
|
107
104
|
end
|
108
105
|
end
|
109
106
|
space[:dashboards].each do |d|
|
110
|
-
data =
|
111
|
-
data[:dashboard_elements].each_index do |i|
|
112
|
-
element = data[:dashboard_elements][i]
|
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
|
120
|
-
merge_result[:source_queries].each_index do |j|
|
121
|
-
source_query = merge_result[:source_queries][j]
|
122
|
-
merge_result[:source_queries][j][:query] = query(source_query[:query_id]).to_attrs()
|
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
|
129
|
-
data[:dashboard_elements][i][:merge_result] = merge_result
|
130
|
-
end
|
131
|
-
end
|
107
|
+
data = cat_dashboard(d[:id])
|
132
108
|
write_file("Dashboard_#{data[:id]}_#{data[:title]}.json", base, path) do |f|
|
133
109
|
f.write JSON.pretty_generate(data)
|
134
110
|
end
|
data/lib/gzr/commands/space.rb
CHANGED
@@ -64,6 +64,8 @@ module Gzr
|
|
64
64
|
desc 'export SPACE_ID', 'Export a space, including all child looks, dashboards, and spaces.'
|
65
65
|
method_option :help, aliases: '-h', type: :boolean,
|
66
66
|
desc: 'Display usage information'
|
67
|
+
method_option :plans, type: :boolean,
|
68
|
+
desc: 'Include scheduled plans'
|
67
69
|
method_option :dir, type: :string, default: '.',
|
68
70
|
desc: 'Directory to store output tree'
|
69
71
|
method_option :tar, type: :string,
|
@@ -226,5 +226,32 @@ module Gzr
|
|
226
226
|
end
|
227
227
|
data
|
228
228
|
end
|
229
|
+
|
230
|
+
def cat_dashboard(dashboard_id)
|
231
|
+
data = query_dashboard(dashboard_id).to_attrs
|
232
|
+
data[:dashboard_elements].each_index do |i|
|
233
|
+
element = data[:dashboard_elements][i]
|
234
|
+
find_vis_config_reference(element) do |vis_config|
|
235
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
236
|
+
rewrite_color_palette!(o,default_colors)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
merge_result = merge_query(element[:merge_result_id])&.to_attrs if element[:merge_result_id]
|
240
|
+
if merge_result
|
241
|
+
merge_result[:source_queries].each_index do |j|
|
242
|
+
source_query = merge_result[:source_queries][j]
|
243
|
+
merge_result[:source_queries][j][:query] = query(source_query[:query_id]).to_attrs
|
244
|
+
end
|
245
|
+
find_vis_config_reference(merge_result) do |vis_config|
|
246
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
247
|
+
rewrite_color_palette!(o,default_colors)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
data[:dashboard_elements][i][:merge_result] = merge_result
|
251
|
+
end
|
252
|
+
end
|
253
|
+
data[:scheduled_plans] = query_scheduled_plans_for_dashboard(@dashboard_id,"all")&.to_attrs if @options[:plans]
|
254
|
+
data
|
255
|
+
end
|
229
256
|
end
|
230
257
|
end
|
data/lib/gzr/modules/look.rb
CHANGED
@@ -188,5 +188,17 @@ module Gzr
|
|
188
188
|
end
|
189
189
|
return create_merge_query(new_merge_result)
|
190
190
|
end
|
191
|
+
|
192
|
+
def cat_look(look_id)
|
193
|
+
data = query_look(look_id).to_attrs
|
194
|
+
find_vis_config_reference(data) do |vis_config|
|
195
|
+
find_color_palette_reference(vis_config) do |o,default_colors|
|
196
|
+
rewrite_color_palette!(o,default_colors)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
data[:scheduled_plans] = query_scheduled_plans_for_look(@look_id,"all")&.to_attrs if @options[:plans]
|
201
|
+
data
|
202
|
+
end
|
191
203
|
end
|
192
204
|
end
|
data/lib/gzr/modules/plan.rb
CHANGED
@@ -49,6 +49,9 @@ module Gzr
|
|
49
49
|
data = nil
|
50
50
|
begin
|
51
51
|
data = @sdk.scheduled_plans_for_look(look_id,req)
|
52
|
+
return nil if data.respond_to?(:message) && data.message == 'Not found'
|
53
|
+
rescue LookerSDK::NotFound
|
54
|
+
return nil
|
52
55
|
rescue LookerSDK::ClientError => e
|
53
56
|
say_error "Unable to get scheduled_plans_for_look(#{look_id},#{JSON.pretty_generate(req)})"
|
54
57
|
say_error e.message
|
@@ -65,6 +68,9 @@ module Gzr
|
|
65
68
|
data = nil
|
66
69
|
begin
|
67
70
|
data = @sdk.scheduled_plans_for_dashboard(dashboard_id,req)
|
71
|
+
return nil if data.respond_to?(:message) && data.message == 'Not found'
|
72
|
+
rescue LookerSDK::NotFound
|
73
|
+
return nil
|
68
74
|
rescue LookerSDK::ClientError => e
|
69
75
|
say_error "Unable to get scheduled_plans_for_dashboard(#{dashboard_id},#{JSON.pretty_generate(req)})"
|
70
76
|
say_error e.message
|
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.53
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike DeAngelo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-reader
|