gazer 0.2.15 → 0.2.16
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/Gemfile.lock +1 -1
- data/lib/gzr/commands/dashboard/import.rb +16 -16
- data/lib/gzr/modules/dashboard.rb +6 -2
- data/lib/gzr/modules/session.rb +6 -6
- data/lib/gzr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1e108603b48eccf755e49bb74db4f1d3a8095c0
|
4
|
+
data.tar.gz: c5df7d93f59e9231880904bfa1bcbce1400153e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d22b564ba4fd7ef8f0f98b33fdb0b6d522a77448f7de44e01ec90631c378da4c1f8dedc8df7b509e8bf07fde139ed9470b82be37f14886da9f7f392c4541ae2
|
7
|
+
data.tar.gz: b9d39d2ce886949c42f5681c23fe795fdce14c211aad94fb3e5ed34f95458eab4a475dfb5082e0725137e17aa77df3ad3775ac0324f28f8332aaae5d4753571d
|
data/Gemfile.lock
CHANGED
@@ -46,14 +46,14 @@ module Gzr
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def execute(input: $stdin, output: $stdout)
|
49
|
-
say_warning("options: #{@options.inspect}") if @options[:debug]
|
49
|
+
say_warning("options: #{@options.inspect}", output) if @options[:debug]
|
50
50
|
with_session("3.1") do
|
51
51
|
|
52
52
|
@me ||= query_me("id")
|
53
53
|
|
54
54
|
read_file(@file) do |data|
|
55
55
|
|
56
|
-
dashboard = sync_dashboard(data,@dest_space_id)
|
56
|
+
dashboard = sync_dashboard(data,@dest_space_id, output: output)
|
57
57
|
|
58
58
|
source_filters = data[:dashboard_filters].sort { |a,b| a[:row] <=> b[:row] }
|
59
59
|
existing_filters = dashboard.dashboard_filters.sort { |a,b| a.row <=> b.row }
|
@@ -67,7 +67,7 @@ module Gzr
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
pairs(source_filters,existing_filters,dashboard.id) do |source,target,id|
|
70
|
-
say_warning
|
70
|
+
say_warning("Synching dashboard filter for dashboard #{id}", output: output) if @options[:debug]
|
71
71
|
sync_dashboard_filter(source,target,id)
|
72
72
|
end
|
73
73
|
|
@@ -89,11 +89,11 @@ module Gzr
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
def sync_dashboard(source,target_space_id)
|
92
|
+
def sync_dashboard(source, target_space_id, output: $stdout)
|
93
93
|
# try to find dashboard by slug in target space
|
94
94
|
existing_dashboard = search_dashboards_by_slug(source[:slug], target_space_id).fetch(0,nil) if source[:slug]
|
95
95
|
# check for dash of same title in target space
|
96
|
-
title_used = search_dashboards_by_title(source[:title], target_space_id).fetch(0,nil)
|
96
|
+
title_used = search_dashboards_by_title(source[:title], target_space_id).select {|d| !d[:deleted] }.fetch(0,nil)
|
97
97
|
|
98
98
|
# If there is no match by slug in target space or no slug given, then we match by title
|
99
99
|
existing_dashboard ||= title_used
|
@@ -110,24 +110,24 @@ module Gzr
|
|
110
110
|
same_slug = (slug_used&.fetch(:id,nil) == existing_dashboard&.fetch(:id,nil))
|
111
111
|
|
112
112
|
if slug_used && !same_slug then
|
113
|
-
say_warning "slug #{slug_used.slug} already used for dashboard #{slug_used.title} in space #{slug_used.space_id}"
|
114
|
-
say_warning
|
113
|
+
say_warning "slug #{slug_used.slug} already used for dashboard #{slug_used.title} in space #{slug_used.space_id}", output: output
|
114
|
+
say_warning("That dashboard is in the 'Trash' but not fully deleted yet", output: output) if slug_used.deleted
|
115
|
+
say_warning "dashboard will be imported with new slug", output: output
|
115
116
|
end
|
116
117
|
|
117
118
|
if existing_dashboard then
|
118
119
|
if title_used && !same_title then
|
119
120
|
raise Gzr::CLI::Error, "Dashboard #{source[:title]} already exists in space #{target_space_id}\nDelete it before trying to upate another dashboard to have that title."
|
120
121
|
end
|
121
|
-
if @options[:force]
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
new_dash[:slug] = source[:slug] unless slug_used && !same_slug
|
127
|
-
return update_dashboard(existing_dashboard.id,new_dash)
|
128
|
-
else
|
129
|
-
raise Gzr::CLI::Error, "Dashboard #{existing_dashboard[:title]} with slug #{existing_dashboard[:slug]} already exists in space #{target_space_id}\nUse --force if you want to overwrite it"
|
122
|
+
raise Gzr::CLI::Error, "Dashboard #{existing_dashboard[:title]} with slug #{existing_dashboard[:slug]} already exists in space #{target_space_id}\nUse --force if you want to overwrite it" unless @options[:force]
|
123
|
+
|
124
|
+
say_ok "Modifying existing dashboard #{existing_dashboard.id} #{existing_dashboard[:title]} in space #{target_space_id}", output: output
|
125
|
+
new_dash = source.select do |k,v|
|
126
|
+
(keys_to_keep('update_dashboard') - [:space_id,:user_id,:slug]).include? k
|
130
127
|
end
|
128
|
+
new_dash[:slug] = source[:slug] unless slug_used
|
129
|
+
new_dash[:deleted] = false if existing_dashboard[:deleted]
|
130
|
+
return update_dashboard(existing_dashboard.id,new_dash)
|
131
131
|
else
|
132
132
|
new_dash = source.select do |k,v|
|
133
133
|
(keys_to_keep('create_dashboard') - [:space_id,:user_id,:slug]).include? k
|
@@ -50,11 +50,13 @@ module Gzr
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def search_dashboards_by_slug(slug, space_id=nil)
|
53
|
-
data =
|
53
|
+
data = []
|
54
54
|
begin
|
55
55
|
req = { :slug => slug }
|
56
56
|
req[:space_id] = space_id if space_id
|
57
57
|
data = @sdk.search_dashboards(req)
|
58
|
+
req[:deleted] = true
|
59
|
+
data = @sdk.search_dashboards(req) if data.empty?
|
58
60
|
rescue LookerSDK::Error => e
|
59
61
|
say_error "Error search_dashboards_by_slug(#{JSON.pretty_generate(req)})"
|
60
62
|
say_error e.message
|
@@ -64,11 +66,13 @@ module Gzr
|
|
64
66
|
end
|
65
67
|
|
66
68
|
def search_dashboards_by_title(title, space_id=nil)
|
67
|
-
data =
|
69
|
+
data = []
|
68
70
|
begin
|
69
71
|
req = { :title => title }
|
70
72
|
req[:space_id] = space_id if space_id
|
71
73
|
data = @sdk.search_dashboards(req)
|
74
|
+
req[:deleted] = true
|
75
|
+
data = @sdk.search_dashboards(req) if data.empty?
|
72
76
|
rescue LookerSDK::Error => e
|
73
77
|
say_error "Error search_dashboards_by_title(#{JSON.pretty_generate(req)})"
|
74
78
|
say_error e.message
|
data/lib/gzr/modules/session.rb
CHANGED
@@ -33,16 +33,16 @@ module Gzr
|
|
33
33
|
@pastel ||= Pastel.new
|
34
34
|
end
|
35
35
|
|
36
|
-
def say_ok(data)
|
37
|
-
puts pastel.green data
|
36
|
+
def say_ok(data, output: $stdout)
|
37
|
+
output.puts pastel.green data
|
38
38
|
end
|
39
39
|
|
40
|
-
def say_warning(data)
|
41
|
-
puts pastel.yellow data
|
40
|
+
def say_warning(data, output: $stdout)
|
41
|
+
output.puts pastel.yellow data
|
42
42
|
end
|
43
43
|
|
44
|
-
def say_error(data)
|
45
|
-
puts pastel.red data
|
44
|
+
def say_error(data, output: $stdout)
|
45
|
+
output.puts pastel.red data
|
46
46
|
end
|
47
47
|
|
48
48
|
def v3_1_available?
|
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.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike DeAngelo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-reader
|