gazer 0.3.10 → 0.3.11
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 +7 -0
- data/Gemfile.lock +1 -1
- data/lib/gzr/command.rb +9 -5
- data/lib/gzr/commands/alert/cat.rb +2 -2
- data/lib/gzr/commands/alert/ls.rb +2 -2
- data/lib/gzr/commands/alert/notifications.rb +2 -2
- data/lib/gzr/commands/attribute/cat.rb +3 -3
- data/lib/gzr/commands/attribute/create.rb +2 -2
- data/lib/gzr/commands/attribute/get_group_value.rb +4 -4
- data/lib/gzr/commands/attribute/import.rb +3 -3
- data/lib/gzr/commands/attribute/ls.rb +3 -3
- data/lib/gzr/commands/attribute/rm.rb +4 -4
- data/lib/gzr/commands/attribute/set_group_value.rb +4 -4
- data/lib/gzr/commands/connection/dialects.rb +4 -4
- data/lib/gzr/commands/connection/ls.rb +2 -2
- data/lib/gzr/commands/connection/test.rb +2 -2
- data/lib/gzr/commands/dashboard/import.rb +30 -30
- data/lib/gzr/commands/dashboard/mv.rb +1 -1
- data/lib/gzr/commands/folder/cat.rb +3 -3
- data/lib/gzr/commands/folder/create.rb +3 -3
- data/lib/gzr/commands/folder/export.rb +2 -2
- data/lib/gzr/commands/folder/ls.rb +3 -4
- data/lib/gzr/commands/folder/rm.rb +3 -3
- data/lib/gzr/commands/folder/top.rb +4 -4
- data/lib/gzr/commands/folder/tree.rb +11 -11
- data/lib/gzr/commands/group/ls.rb +3 -3
- data/lib/gzr/commands/group/member_groups.rb +3 -3
- data/lib/gzr/commands/group/member_users.rb +3 -3
- data/lib/gzr/commands/look/cat.rb +1 -1
- data/lib/gzr/commands/look/import.rb +5 -5
- data/lib/gzr/commands/look/mv.rb +1 -1
- data/lib/gzr/commands/look/rm.rb +1 -1
- data/lib/gzr/commands/model/ls.rb +4 -4
- data/lib/gzr/commands/model/set/ls.rb +2 -2
- data/lib/gzr/commands/permission/ls.rb +2 -2
- data/lib/gzr/commands/permission/set/ls.rb +2 -2
- data/lib/gzr/commands/plan/cat.rb +3 -3
- data/lib/gzr/commands/plan/disable.rb +3 -3
- data/lib/gzr/commands/plan/enable.rb +3 -3
- data/lib/gzr/commands/plan/failures.rb +12 -7
- data/lib/gzr/commands/plan/import.rb +5 -5
- data/lib/gzr/commands/plan/ls.rb +5 -5
- data/lib/gzr/commands/plan/run.rb +2 -2
- data/lib/gzr/commands/project/branch.rb +4 -4
- data/lib/gzr/commands/project/ls.rb +3 -3
- data/lib/gzr/commands/role/cat.rb +2 -2
- data/lib/gzr/commands/role/group_add.rb +2 -2
- data/lib/gzr/commands/role/group_ls.rb +3 -3
- data/lib/gzr/commands/role/group_rm.rb +2 -2
- data/lib/gzr/commands/role/ls.rb +3 -3
- data/lib/gzr/commands/role/user_add.rb +2 -2
- data/lib/gzr/commands/role/user_ls.rb +3 -3
- data/lib/gzr/commands/role/user_rm.rb +2 -2
- data/lib/gzr/commands/user/cat.rb +5 -3
- data/lib/gzr/commands/user/delete.rb +2 -1
- data/lib/gzr/commands/user/disable.rb +2 -1
- data/lib/gzr/commands/user/enable.rb +2 -1
- data/lib/gzr/commands/user/ls.rb +22 -11
- data/lib/gzr/commands/user/me.rb +6 -2
- data/lib/gzr/commands/user.rb +2 -0
- data/lib/gzr/modules/alert.rb +30 -17
- data/lib/gzr/modules/attribute.rb +24 -22
- data/lib/gzr/modules/connection.rb +10 -25
- data/lib/gzr/modules/dashboard.rb +86 -44
- data/lib/gzr/modules/folder.rb +20 -28
- data/lib/gzr/modules/group.rb +8 -10
- data/lib/gzr/modules/look.rb +23 -21
- data/lib/gzr/modules/model/set.rb +6 -6
- data/lib/gzr/modules/model.rb +14 -7
- data/lib/gzr/modules/permission/set.rb +2 -2
- data/lib/gzr/modules/permission.rb +2 -4
- data/lib/gzr/modules/plan.rb +36 -36
- data/lib/gzr/modules/project.rb +26 -21
- data/lib/gzr/modules/role.rb +48 -36
- data/lib/gzr/modules/session.rb +2 -2
- data/lib/gzr/modules/user.rb +52 -43
- 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: dce76479c6d89605e315f8f83c7e8290ccefbb6a543d8e3343b9a391ac3ed454
|
4
|
+
data.tar.gz: 6d54b5c93354d8b09531cdbe4aefd5d335a52e37f2db7c45682292d06d27592c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2f41c52c372487a5214d9f9472b0896947c5f33663f7f3e75726d7350c0fc73cea814be179312156542fcc2c08e79f308bab2c0bfa6a0275ff3a0b7313a9067
|
7
|
+
data.tar.gz: c8263710569aa4a6e1bf457e4bb0c21b5cf2d01e39b3c230fe7599b81ace74f5d69fa1799f110f3af387fcbda236d2592fb3bae476af70c52754ca9dbe7a6a47
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.3.11](https://github.com/looker-open-source/gzr/compare/v0.3.10...v0.3.11) (2023-09-29)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* Tech debt removal for better testing ([#223](https://github.com/looker-open-source/gzr/issues/223)) ([e3a7e88](https://github.com/looker-open-source/gzr/commit/e3a7e889fe020a4a1a5f496b634b11cf96c3028f))
|
9
|
+
|
3
10
|
## [0.3.10](https://github.com/looker-open-source/gzr/compare/v0.3.9...v0.3.10) (2023-06-28)
|
4
11
|
|
5
12
|
|
data/Gemfile.lock
CHANGED
data/lib/gzr/command.rb
CHANGED
@@ -53,15 +53,15 @@ module Gzr
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def get_user_by_id(user_id, req=nil)
|
56
|
-
user = nil
|
57
56
|
begin
|
58
|
-
|
57
|
+
@sdk.user(user_id, req).to_attrs
|
58
|
+
rescue LookerSDK::NotFound => e
|
59
|
+
nil
|
59
60
|
rescue LookerSDK::Error => e
|
60
61
|
say_error "Error querying get_user_by_id(#{user_id})"
|
61
62
|
say_error e
|
62
63
|
raise
|
63
64
|
end
|
64
|
-
user
|
65
65
|
end
|
66
66
|
|
67
67
|
def get_auth()
|
@@ -129,13 +129,12 @@ module Gzr
|
|
129
129
|
|
130
130
|
def run_inline_query(query)
|
131
131
|
begin
|
132
|
-
|
132
|
+
@sdk.run_inline_query("json",query).collect { |r| r.to_attrs }
|
133
133
|
rescue LookerSDK::Error => e
|
134
134
|
say_error "Error running inline_query(#{JSON.pretty_generate(query)})"
|
135
135
|
say_error e
|
136
136
|
raise
|
137
137
|
end
|
138
|
-
data
|
139
138
|
end
|
140
139
|
|
141
140
|
def all_color_collections()
|
@@ -410,6 +409,11 @@ module Gzr
|
|
410
409
|
parts.join('&.')
|
411
410
|
end
|
412
411
|
|
412
|
+
def field_expression_hash(name)
|
413
|
+
parts = name.split(/\./)
|
414
|
+
parts.collect { |p| "&.fetch(:#{p},nil)" }.join('')
|
415
|
+
end
|
416
|
+
|
413
417
|
|
414
418
|
# This version of field names yields an expression that can be evaluated against a hash structure
|
415
419
|
# like this one...
|
@@ -41,8 +41,8 @@ module Gzr
|
|
41
41
|
say_warning(@options) if @options[:debug]
|
42
42
|
with_session do
|
43
43
|
alert = get_alert(@alert_id)
|
44
|
-
write_file(@options[:dir] ? "Alert_#{alert
|
45
|
-
f.puts JSON.pretty_generate(alert
|
44
|
+
write_file(@options[:dir] ? "Alert_#{alert[:id]}_#{alert[:field][:name]}.json" : nil, @options[:dir],nil, output) do |f|
|
45
|
+
f.puts JSON.pretty_generate(alert)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -51,10 +51,10 @@ module Gzr
|
|
51
51
|
table_hash = Hash.new
|
52
52
|
fields = field_names(@options[:fields])
|
53
53
|
table_hash[:header] = fields unless @options[:plain]
|
54
|
-
expressions = fields.collect { |fn|
|
54
|
+
expressions = fields.collect { |fn| field_expression_hash(fn) }
|
55
55
|
table_hash[:rows] = data.map do |row|
|
56
56
|
expressions.collect do |e|
|
57
|
-
eval "row
|
57
|
+
eval "row#{e}"
|
58
58
|
end
|
59
59
|
end
|
60
60
|
table = TTY::Table.new(table_hash)
|
@@ -49,10 +49,10 @@ module Gzr
|
|
49
49
|
table_hash = Hash.new
|
50
50
|
fields = field_names(@fields)
|
51
51
|
table_hash[:header] = fields unless @options[:plain]
|
52
|
-
expressions = fields.collect { |fn|
|
52
|
+
expressions = fields.collect { |fn| field_expression_hash(fn) }
|
53
53
|
table_hash[:rows] = data.map do |row|
|
54
54
|
expressions.collect do |e|
|
55
|
-
eval "row
|
55
|
+
eval "row#{e}"
|
56
56
|
end
|
57
57
|
end
|
58
58
|
table = TTY::Table.new(table_hash)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -49,8 +49,8 @@ module Gzr
|
|
49
49
|
attr = get_attribute_by_name(@attr,f)
|
50
50
|
end
|
51
51
|
raise(Gzr::CLI::Error, "Attribute #{@attr} does not exist") unless attr
|
52
|
-
write_file(@options[:dir] ? "Attribute_#{attr
|
53
|
-
f.puts JSON.pretty_generate(attr
|
52
|
+
write_file(@options[:dir] ? "Attribute_#{attr[:id]}_#{attr[:name]}.json" : nil, @options[:dir],nil, output) do |f|
|
53
|
+
f.puts JSON.pretty_generate(attr)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -47,7 +47,7 @@ module Gzr
|
|
47
47
|
source[:'hidden_value_domain_allowlist'] = @options[:'domain-allowlist'] if @options[:'is-hidden'] && @options[:'domain-allowlist']
|
48
48
|
|
49
49
|
attr = upsert_user_attribute(source, @options[:force], output: $stdout)
|
50
|
-
output.puts "Imported attribute #{attr
|
50
|
+
output.puts "Imported attribute #{attr[:name]} #{attr[:id]}" unless @options[:plain]
|
51
51
|
output.puts attr.id if @options[:plain]
|
52
52
|
end
|
53
53
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -66,9 +66,9 @@ module Gzr
|
|
66
66
|
end
|
67
67
|
raise(Gzr::CLI::Error, "Attribute #{@attr} does not exist") unless attr
|
68
68
|
|
69
|
-
data = query_user_attribute_group_value(group
|
70
|
-
say_warning("Attribute #{attr
|
71
|
-
output.puts data
|
69
|
+
data = query_user_attribute_group_value(group[:id],attr[:id])
|
70
|
+
say_warning("Attribute #{attr[:name]} does not have a value set for group #{group[:name]}", output: output) unless data
|
71
|
+
output.puts data[:value] if data
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -42,8 +42,8 @@ module Gzr
|
|
42
42
|
with_session do
|
43
43
|
read_file(@file) do |source|
|
44
44
|
attr = upsert_user_attribute(source, @options[:force], output: $stdout)
|
45
|
-
output.puts "Imported attribute #{attr
|
46
|
-
output.puts attr
|
45
|
+
output.puts "Imported attribute #{attr[:name]} #{attr[:id]}" unless @options[:plain]
|
46
|
+
output.puts attr[:id] if @options[:plain]
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -48,10 +48,10 @@ module Gzr
|
|
48
48
|
table_hash = Hash.new
|
49
49
|
fields = field_names(@options[:fields])
|
50
50
|
table_hash[:header] = fields unless @options[:plain]
|
51
|
-
expressions = fields.collect { |fn|
|
51
|
+
expressions = fields.collect { |fn| field_expression_hash(fn) }
|
52
52
|
table_hash[:rows] = data.map do |row|
|
53
53
|
expressions.collect do |e|
|
54
|
-
eval "row
|
54
|
+
eval "row#{e}"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
table = TTY::Table.new(table_hash)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -50,10 +50,10 @@ module Gzr
|
|
50
50
|
raise(Gzr::CLI::Error, "Attribute #{attr[:name]} is a system built-in and cannot be deleted ") if attr[:is_system]
|
51
51
|
raise(Gzr::CLI::Error, "Attribute #{attr[:name]} is marked permanent and cannot be deleted ") if attr[:is_permanent]
|
52
52
|
|
53
|
-
delete_user_attribute(attr
|
53
|
+
delete_user_attribute(attr[:id])
|
54
54
|
|
55
|
-
output.puts "Deleted attribute #{attr
|
56
|
-
output.puts attr
|
55
|
+
output.puts "Deleted attribute #{attr[:name]} #{attr[:id]}" unless @options[:plain]
|
56
|
+
output.puts attr[:id] if @options[:plain]
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -67,9 +67,9 @@ module Gzr
|
|
67
67
|
end
|
68
68
|
raise(Gzr::CLI::Error, "Attribute #{@attr} does not exist") unless attr
|
69
69
|
|
70
|
-
data = update_user_attribute_group_value(group
|
71
|
-
say_warning("Attribute #{attr
|
72
|
-
output.puts "Group attribute #{data
|
70
|
+
data = update_user_attribute_group_value(group[:id],attr[:id], @value)
|
71
|
+
say_warning("Attribute #{attr[:name]} does not have a value set for group #{group[:name]}", output: output) unless data
|
72
|
+
output.puts "Group attribute #{data[:id]} set to #{data[:value]}"
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -46,11 +46,11 @@ module Gzr
|
|
46
46
|
|
47
47
|
table_hash = Hash.new
|
48
48
|
fields = field_names(@options[:fields])
|
49
|
-
table_hash[:header] = data[0].
|
50
|
-
expressions = fields.collect { |fn|
|
49
|
+
table_hash[:header] = data[0].keys unless @options[:plain]
|
50
|
+
expressions = fields.collect { |fn| field_expression_hash(fn) }
|
51
51
|
table_hash[:rows] = data.map do |row|
|
52
52
|
expressions.collect do |e|
|
53
|
-
eval "row
|
53
|
+
eval "row#{e}"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
table = TTY::Table.new(table_hash)
|
@@ -47,10 +47,10 @@ module Gzr
|
|
47
47
|
table_hash = Hash.new
|
48
48
|
fields = field_names(@options[:fields])
|
49
49
|
table_hash[:header] = fields unless @options[:plain]
|
50
|
-
expressions = fields.collect { |fn|
|
50
|
+
expressions = fields.collect { |fn| field_expression_hash(fn) }
|
51
51
|
table_hash[:rows] = data.map do |row|
|
52
52
|
expressions.collect do |e|
|
53
|
-
eval "row
|
53
|
+
eval "row#{e}"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
table = TTY::Table.new(table_hash)
|
@@ -44,10 +44,10 @@ module Gzr
|
|
44
44
|
table_hash = Hash.new
|
45
45
|
fields = field_names(@options[:fields])
|
46
46
|
table_hash[:header] = fields unless @options[:plain]
|
47
|
-
expressions = fields.collect { |fn|
|
47
|
+
expressions = fields.collect { |fn| field_expression_hash(fn) }
|
48
48
|
table_hash[:rows] = data.map do |row|
|
49
49
|
expressions.collect do |e|
|
50
|
-
eval "row
|
50
|
+
eval "row#{e}"
|
51
51
|
end
|
52
52
|
end
|
53
53
|
table = TTY::Table.new(table_hash)
|
@@ -72,7 +72,7 @@ module Gzr
|
|
72
72
|
filter = new_filter.select do |k,v|
|
73
73
|
(keys_to_keep('create_dashboard_filter') + [:row]).include? k
|
74
74
|
end
|
75
|
-
filter[:dashboard_id] = dashboard
|
75
|
+
filter[:dashboard_id] = dashboard[:id]
|
76
76
|
say_warning "Creating filter" if @options[:debug]
|
77
77
|
dashboard[:dashboard_filters].push create_dashboard_filter(filter)
|
78
78
|
end
|
@@ -84,7 +84,7 @@ module Gzr
|
|
84
84
|
end
|
85
85
|
(element[:query_id],element[:look_id],element[:merge_result_id]) = process_dashboard_element(new_element)
|
86
86
|
say_warning "Creating dashboard element #{element.select {|k,v| !v.nil?}.inspect}" if @options[:debug]
|
87
|
-
element[:dashboard_id] = dashboard
|
87
|
+
element[:dashboard_id] = dashboard[:id]
|
88
88
|
result_maker = copy_result_maker_filterables(new_element)
|
89
89
|
element[:result_maker] = result_maker if result_maker
|
90
90
|
dashboard_element = create_dashboard_element(element)
|
@@ -101,42 +101,42 @@ module Gzr
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
dashboard[:dashboard_elements].push dashboard_element
|
104
|
-
[new_element[:id], dashboard_element
|
104
|
+
[new_element[:id], dashboard_element[:id]]
|
105
105
|
end
|
106
106
|
|
107
107
|
source_dashboard_layouts = data[:dashboard_layouts].map do |new_layout|
|
108
108
|
layout_obj = nil
|
109
109
|
if new_layout[:active]
|
110
|
-
layout_obj = get_dashboard_layout(dashboard[:dashboard_layouts].first
|
111
|
-
say_warning "Updating layout #{layout_obj
|
110
|
+
layout_obj = get_dashboard_layout(dashboard[:dashboard_layouts].first[:id])
|
111
|
+
say_warning "Updating layout #{layout_obj[:id]}" if @options[:debug]
|
112
112
|
else
|
113
113
|
layout = new_layout.select do |k,v|
|
114
114
|
(keys_to_keep('create_dashboard_layout') - [:dashboard_id]).include? k
|
115
115
|
end
|
116
|
-
layout[:dashboard_id] = dashboard
|
116
|
+
layout[:dashboard_id] = dashboard[:id]
|
117
117
|
say_warning "Creating dashboard layout #{layout}" if @options[:debug]
|
118
118
|
layout_obj = create_dashboard_layout(layout)
|
119
119
|
say_warning "Created dashboard layout #{JSON.pretty_generate layout_obj.map(&:to_a).to_json}" if @options[:debug]
|
120
120
|
end
|
121
|
-
layout_components = new_layout[:dashboard_layout_components].zip(layout_obj
|
121
|
+
layout_components = new_layout[:dashboard_layout_components].zip(layout_obj[:dashboard_layout_components])
|
122
122
|
layout_components.each do |source,target|
|
123
123
|
component = keys_to_keep('update_dashboard_layout_component').collect do |e|
|
124
124
|
[e,nil]
|
125
125
|
end.to_h
|
126
|
-
component[:dashboard_layout_id] = target
|
126
|
+
component[:dashboard_layout_id] = target[:dashboard_layout_id]
|
127
127
|
|
128
128
|
component.merge!(source.select do |k,v|
|
129
129
|
(keys_to_keep('update_dashboard_layout_component') - [:id,:dashboard_layout_id]).include? k
|
130
130
|
end)
|
131
131
|
|
132
132
|
component[:dashboard_element_id] = elem_table.assoc(source[:dashboard_element_id])[1]
|
133
|
-
say_warning "Updating dashboard layout component #{target
|
134
|
-
update_dashboard_layout_component(target
|
133
|
+
say_warning "Updating dashboard layout component #{target[:id]}" if @options[:debug]
|
134
|
+
update_dashboard_layout_component(target[:id],component)
|
135
135
|
end
|
136
136
|
end
|
137
|
-
upsert_plans_for_dashboard(dashboard
|
138
|
-
output.puts "Imported dashboard #{dashboard
|
139
|
-
output.puts dashboard
|
137
|
+
upsert_plans_for_dashboard(dashboard[:id],@me[:id],data[:scheduled_plans]) if data[:scheduled_plans]
|
138
|
+
output.puts "Imported dashboard #{dashboard[:id]}" unless @options[:plain]
|
139
|
+
output.puts dashboard[:id] if @options[:plain]
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
@@ -162,8 +162,8 @@ module Gzr
|
|
162
162
|
same_slug = (slug_used&.fetch(:id,nil) == existing_dashboard&.fetch(:id,nil))
|
163
163
|
|
164
164
|
if slug_used && !same_slug then
|
165
|
-
say_warning "slug #{slug_used
|
166
|
-
say_warning("That dashboard is in the 'Trash' but not fully deleted yet", output: output) if slug_used
|
165
|
+
say_warning "slug #{slug_used[:slug]} already used for dashboard #{slug_used[:title]} in folder #{slug_used[:folder_id]}", output: output
|
166
|
+
say_warning("That dashboard is in the 'Trash' but not fully deleted yet", output: output) if slug_used[:deleted]
|
167
167
|
say_warning "dashboard will be imported with new slug", output: output
|
168
168
|
end
|
169
169
|
|
@@ -173,28 +173,28 @@ module Gzr
|
|
173
173
|
end
|
174
174
|
raise Gzr::CLI::Error, "Dashboard #{existing_dashboard[:title]} with slug #{existing_dashboard[:slug]} already exists in folder #{target_folder_id}\nUse --force if you want to overwrite it" unless @options[:force]
|
175
175
|
|
176
|
-
say_ok "Modifying existing dashboard #{existing_dashboard
|
176
|
+
say_ok "Modifying existing dashboard #{existing_dashboard[:id]} #{existing_dashboard[:title]} in folder #{target_folder_id}", output: output
|
177
177
|
new_dash = source.select do |k,v|
|
178
178
|
(keys_to_keep('update_dashboard') - [:space_id,:folder_id,:user_id,:slug]).include? k
|
179
179
|
end
|
180
180
|
new_dash[:slug] = source[:slug] unless slug_used
|
181
181
|
new_dash[:deleted] = false if existing_dashboard[:deleted]
|
182
|
-
d = update_dashboard(existing_dashboard
|
182
|
+
d = update_dashboard(existing_dashboard[:id],new_dash)
|
183
183
|
|
184
|
-
d
|
185
|
-
delete_dashboard_filter(f
|
184
|
+
d[:dashboard_filters].each do |f|
|
185
|
+
delete_dashboard_filter(f[:id])
|
186
186
|
end
|
187
|
-
d
|
187
|
+
d[:dashboard_filters] = []
|
188
188
|
|
189
|
-
d
|
190
|
-
delete_dashboard_element(e
|
189
|
+
d[:dashboard_elements].each do |e|
|
190
|
+
delete_dashboard_element(e[:id])
|
191
191
|
end
|
192
|
-
d
|
192
|
+
d[:dashboard_elements] = []
|
193
193
|
|
194
|
-
d
|
195
|
-
delete_dashboard_layout(l
|
194
|
+
d[:dashboard_layouts].each do |l|
|
195
|
+
delete_dashboard_layout(l[:id]) unless l[:active]
|
196
196
|
end
|
197
|
-
d
|
197
|
+
d[:dashboard_layouts].select! { |l| l[:active] }
|
198
198
|
|
199
199
|
return d
|
200
200
|
else
|
@@ -203,7 +203,7 @@ module Gzr
|
|
203
203
|
end
|
204
204
|
new_dash[:slug] = source[:slug] unless slug_used
|
205
205
|
new_dash[:folder_id] = target_folder_id
|
206
|
-
new_dash[:user_id] = @me
|
206
|
+
new_dash[:user_id] = @me[:id]
|
207
207
|
new_dash.select!{|k,v| !v.nil?}
|
208
208
|
say_warning "new dashboard request #{new_dash.inspect}" if @options[:debug]
|
209
209
|
d = create_dashboard(new_dash)
|
@@ -227,13 +227,13 @@ module Gzr
|
|
227
227
|
end
|
228
228
|
|
229
229
|
def process_dashboard_element(dash_elem)
|
230
|
-
return [nil, upsert_look(@me
|
230
|
+
return [nil, upsert_look(@me[:id], create_fetch_query(dash_elem[:look][:query])[:id], @dest_folder_id, dash_elem[:look])[:id], nil] if dash_elem[:look]
|
231
231
|
|
232
232
|
query = dash_elem[:result_maker]&.fetch(:query, false) || dash_elem[:query]
|
233
|
-
return [create_fetch_query(query)
|
233
|
+
return [create_fetch_query(query)[:id], nil, nil] if query
|
234
234
|
|
235
235
|
merge_result = dash_elem[:result_maker]&.fetch(:merge_result, false) || dash_elem[:merge_result]
|
236
|
-
return [nil,nil,create_merge_result(merge_result)
|
236
|
+
return [nil,nil,create_merge_result(merge_result)[:id]] if merge_result
|
237
237
|
|
238
238
|
[nil,nil,nil]
|
239
239
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -42,8 +42,8 @@ module Gzr
|
|
42
42
|
say_warning("options: #{@options.inspect}") if @options[:debug]
|
43
43
|
with_session do
|
44
44
|
data = query_folder(@folder_id)
|
45
|
-
write_file(@options[:dir] ? "Folder_#{data
|
46
|
-
f.puts JSON.pretty_generate(data
|
45
|
+
write_file(@options[:dir] ? "Folder_#{data[:id]}_#{data[:name]}.json" : nil, @options[:dir], nil, output) do |f|
|
46
|
+
f.puts JSON.pretty_generate(data)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -40,8 +40,8 @@ module Gzr
|
|
40
40
|
folder = nil
|
41
41
|
with_session do
|
42
42
|
folder = create_folder(@name, @parent_folder)
|
43
|
-
output.puts "Created folder #{folder
|
44
|
-
output.puts folder
|
43
|
+
output.puts "Created folder #{folder[:id]}" unless @options[:plain]
|
44
|
+
output.puts folder[:id] if @options[:plain]
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -86,7 +86,7 @@ module Gzr
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def process_folder(folder_id, base, rel_path = nil)
|
89
|
-
folder = query_folder(folder_id)
|
89
|
+
folder = query_folder(folder_id)
|
90
90
|
name = folder[:name]
|
91
91
|
name = "nil (#{folder_id})" if name.nil?
|
92
92
|
path = Pathname.new(name.gsub('/',"\u{2215}"))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -71,15 +71,14 @@ module Gzr
|
|
71
71
|
f = @options[:fields]
|
72
72
|
|
73
73
|
data = folder_ids.map do |folder_id|
|
74
|
-
query_folder(folder_id, f)
|
74
|
+
query_folder(folder_id, f)
|
75
75
|
end.compact
|
76
76
|
folder_ids.each do |folder_id|
|
77
|
-
query_folder_children(folder_id, 'id,name,parent_id').
|
77
|
+
query_folder_children(folder_id, 'id,name,parent_id').each do |child|
|
78
78
|
data.push child
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
|
83
82
|
begin
|
84
83
|
puts "No data returned for folders #{folder_ids.inspect}"
|
85
84
|
return nil
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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,8 +44,8 @@ module Gzr
|
|
44
44
|
return nil
|
45
45
|
end unless folder
|
46
46
|
children = query_folder_children(@folder)
|
47
|
-
unless (folder
|
48
|
-
raise Gzr::CLI::Error, "Folder '#{folder
|
47
|
+
unless (folder[:looks].length == 0 && folder[:dashboards].length == 0 && children.length == 0) || @options[:force] then
|
48
|
+
raise Gzr::CLI::Error, "Folder '#{folder[:name]}' is not empty. Folder cannot be deleted unless --force is specified"
|
49
49
|
end
|
50
50
|
delete_folder(@folder)
|
51
51
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
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
|
@@ -50,12 +50,12 @@ module Gzr
|
|
50
50
|
table_hash = Hash.new
|
51
51
|
fields = field_names(@options[:fields])
|
52
52
|
table_hash[:header] = fields unless @options[:plain]
|
53
|
-
expressions = fields.collect { |fn|
|
53
|
+
expressions = fields.collect { |fn| field_expression_hash(fn) }
|
54
54
|
rows = []
|
55
55
|
folders.each do |h|
|
56
|
-
if ( h
|
56
|
+
if ( h[:is_shared_root] || h[:is_users_root] || h[:is_embed_shared_root] || h[:is_embed_users_root] ) then
|
57
57
|
rows << expressions.collect do |e|
|
58
|
-
eval "h
|
58
|
+
eval "h#{e}"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|