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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/Gemfile.lock +1 -1
  4. data/lib/gzr/command.rb +9 -5
  5. data/lib/gzr/commands/alert/cat.rb +2 -2
  6. data/lib/gzr/commands/alert/ls.rb +2 -2
  7. data/lib/gzr/commands/alert/notifications.rb +2 -2
  8. data/lib/gzr/commands/attribute/cat.rb +3 -3
  9. data/lib/gzr/commands/attribute/create.rb +2 -2
  10. data/lib/gzr/commands/attribute/get_group_value.rb +4 -4
  11. data/lib/gzr/commands/attribute/import.rb +3 -3
  12. data/lib/gzr/commands/attribute/ls.rb +3 -3
  13. data/lib/gzr/commands/attribute/rm.rb +4 -4
  14. data/lib/gzr/commands/attribute/set_group_value.rb +4 -4
  15. data/lib/gzr/commands/connection/dialects.rb +4 -4
  16. data/lib/gzr/commands/connection/ls.rb +2 -2
  17. data/lib/gzr/commands/connection/test.rb +2 -2
  18. data/lib/gzr/commands/dashboard/import.rb +30 -30
  19. data/lib/gzr/commands/dashboard/mv.rb +1 -1
  20. data/lib/gzr/commands/folder/cat.rb +3 -3
  21. data/lib/gzr/commands/folder/create.rb +3 -3
  22. data/lib/gzr/commands/folder/export.rb +2 -2
  23. data/lib/gzr/commands/folder/ls.rb +3 -4
  24. data/lib/gzr/commands/folder/rm.rb +3 -3
  25. data/lib/gzr/commands/folder/top.rb +4 -4
  26. data/lib/gzr/commands/folder/tree.rb +11 -11
  27. data/lib/gzr/commands/group/ls.rb +3 -3
  28. data/lib/gzr/commands/group/member_groups.rb +3 -3
  29. data/lib/gzr/commands/group/member_users.rb +3 -3
  30. data/lib/gzr/commands/look/cat.rb +1 -1
  31. data/lib/gzr/commands/look/import.rb +5 -5
  32. data/lib/gzr/commands/look/mv.rb +1 -1
  33. data/lib/gzr/commands/look/rm.rb +1 -1
  34. data/lib/gzr/commands/model/ls.rb +4 -4
  35. data/lib/gzr/commands/model/set/ls.rb +2 -2
  36. data/lib/gzr/commands/permission/ls.rb +2 -2
  37. data/lib/gzr/commands/permission/set/ls.rb +2 -2
  38. data/lib/gzr/commands/plan/cat.rb +3 -3
  39. data/lib/gzr/commands/plan/disable.rb +3 -3
  40. data/lib/gzr/commands/plan/enable.rb +3 -3
  41. data/lib/gzr/commands/plan/failures.rb +12 -7
  42. data/lib/gzr/commands/plan/import.rb +5 -5
  43. data/lib/gzr/commands/plan/ls.rb +5 -5
  44. data/lib/gzr/commands/plan/run.rb +2 -2
  45. data/lib/gzr/commands/project/branch.rb +4 -4
  46. data/lib/gzr/commands/project/ls.rb +3 -3
  47. data/lib/gzr/commands/role/cat.rb +2 -2
  48. data/lib/gzr/commands/role/group_add.rb +2 -2
  49. data/lib/gzr/commands/role/group_ls.rb +3 -3
  50. data/lib/gzr/commands/role/group_rm.rb +2 -2
  51. data/lib/gzr/commands/role/ls.rb +3 -3
  52. data/lib/gzr/commands/role/user_add.rb +2 -2
  53. data/lib/gzr/commands/role/user_ls.rb +3 -3
  54. data/lib/gzr/commands/role/user_rm.rb +2 -2
  55. data/lib/gzr/commands/user/cat.rb +5 -3
  56. data/lib/gzr/commands/user/delete.rb +2 -1
  57. data/lib/gzr/commands/user/disable.rb +2 -1
  58. data/lib/gzr/commands/user/enable.rb +2 -1
  59. data/lib/gzr/commands/user/ls.rb +22 -11
  60. data/lib/gzr/commands/user/me.rb +6 -2
  61. data/lib/gzr/commands/user.rb +2 -0
  62. data/lib/gzr/modules/alert.rb +30 -17
  63. data/lib/gzr/modules/attribute.rb +24 -22
  64. data/lib/gzr/modules/connection.rb +10 -25
  65. data/lib/gzr/modules/dashboard.rb +86 -44
  66. data/lib/gzr/modules/folder.rb +20 -28
  67. data/lib/gzr/modules/group.rb +8 -10
  68. data/lib/gzr/modules/look.rb +23 -21
  69. data/lib/gzr/modules/model/set.rb +6 -6
  70. data/lib/gzr/modules/model.rb +14 -7
  71. data/lib/gzr/modules/permission/set.rb +2 -2
  72. data/lib/gzr/modules/permission.rb +2 -4
  73. data/lib/gzr/modules/plan.rb +36 -36
  74. data/lib/gzr/modules/project.rb +26 -21
  75. data/lib/gzr/modules/role.rb +48 -36
  76. data/lib/gzr/modules/session.rb +2 -2
  77. data/lib/gzr/modules/user.rb +52 -43
  78. data/lib/gzr/version.rb +1 -1
  79. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 378d891160a3f1d4a96dad3083a865fcc642fa18f90af66c03c30ecf60c5d04c
4
- data.tar.gz: 762d4625315eafec4780539439230727b7793a22a2badb3493c811170bd8012e
3
+ metadata.gz: dce76479c6d89605e315f8f83c7e8290ccefbb6a543d8e3343b9a391ac3ed454
4
+ data.tar.gz: 6d54b5c93354d8b09531cdbe4aefd5d335a52e37f2db7c45682292d06d27592c
5
5
  SHA512:
6
- metadata.gz: ff29c0527bcf56fce1bc2b3284068e73e52540c00648ad1665bcafeb509448e72e6185d3729e59ff3b22c0c5c141ee763c381adcc99c0fc4d5076dff267ba06e
7
- data.tar.gz: 76a2a1a2507f1822decd68f69c6f1430c28c492cb95531c3c37fdd995c337bdf1e4986b8f53cd65b479b6e2b91d024e48e6e17bcc0a4e5a07775cb12684e27d6
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gazer (0.3.10)
4
+ gazer (0.3.11)
5
5
  faraday (~> 2.7.8)
6
6
  faraday-multipart (~> 1.0)
7
7
  looker-sdk (~> 0.1.6)
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
- user = @sdk.user(user_id, req)
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
- data = @sdk.run_inline_query("json",query)
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.id}_#{alert.field.name}.json" : nil, @options[:dir],nil, output) do |f|
45
- f.puts JSON.pretty_generate(alert.to_attrs)
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| field_expression(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.#{e}"
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| field_expression(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.#{e}"
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) 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
@@ -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.id}_#{attr.name}.json" : nil, @options[:dir],nil, output) do |f|
53
- f.puts JSON.pretty_generate(attr.to_attrs)
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) 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
@@ -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.name} #{attr.id}" unless @options[:plain]
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) 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
@@ -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.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
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) 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
@@ -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.name} #{attr.id}" unless @options[:plain]
46
- output.puts attr.id if @options[:plain]
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) 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
@@ -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| field_expression(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.#{e}"
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) 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
@@ -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.id)
53
+ delete_user_attribute(attr[:id])
54
54
 
55
- output.puts "Deleted attribute #{attr.name} #{attr.id}" unless @options[:plain]
56
- output.puts attr.id if @options[:plain]
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) 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
@@ -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.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}"
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) 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
@@ -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].to_attrs.keys unless @options[:plain]
50
- expressions = fields.collect { |fn| field_expression(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.#{e}"
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| field_expression(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.#{e}"
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| field_expression(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.#{e}"
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.id
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.id
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.id]
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.id)
111
- say_warning "Updating layout #{layout_obj.id}" if @options[:debug]
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.id
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.dashboard_layout_components)
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.dashboard_layout_id
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.id}" if @options[:debug]
134
- update_dashboard_layout_component(target.id,component)
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.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]
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.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
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.id} #{existing_dashboard[:title]} in folder #{target_folder_id}", output: output
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.id,new_dash)
182
+ d = update_dashboard(existing_dashboard[:id],new_dash)
183
183
 
184
- d.dashboard_filters.each do |f|
185
- delete_dashboard_filter(f.id)
184
+ d[:dashboard_filters].each do |f|
185
+ delete_dashboard_filter(f[:id])
186
186
  end
187
- d.dashboard_filters = []
187
+ d[:dashboard_filters] = []
188
188
 
189
- d.dashboard_elements.each do |e|
190
- delete_dashboard_element(e.id)
189
+ d[:dashboard_elements].each do |e|
190
+ delete_dashboard_element(e[:id])
191
191
  end
192
- d.dashboard_elements = []
192
+ d[:dashboard_elements] = []
193
193
 
194
- d.dashboard_layouts.each do |l|
195
- delete_dashboard_layout(l.id) unless l.active
194
+ d[:dashboard_layouts].each do |l|
195
+ delete_dashboard_layout(l[:id]) unless l[:active]
196
196
  end
197
- d.dashboard_layouts.select! { |l| l.active }
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.id
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.id, create_fetch_query(dash_elem[:look][:query]).id, @dest_folder_id, dash_elem[:look]).id, nil] if dash_elem[:look]
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).id, nil, nil] if 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).id] if 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) 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
@@ -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
@@ -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.id}_#{data.name}.json" : nil, @options[:dir], nil, output) do |f|
46
- f.puts JSON.pretty_generate(data.to_attrs)
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) 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
@@ -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.id}" unless @options[:plain]
44
- output.puts folder.id if @options[:plain]
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) 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
@@ -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).to_attrs
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) 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
@@ -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).to_attrs
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').map {|child| child.to_attrs}.each do |child|
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) 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,8 +44,8 @@ module Gzr
44
44
  return nil
45
45
  end unless folder
46
46
  children = query_folder_children(@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"
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) 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
@@ -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| field_expression(fn) }
53
+ expressions = fields.collect { |fn| field_expression_hash(fn) }
54
54
  rows = []
55
55
  folders.each do |h|
56
- if ( h.is_shared_root || h.is_users_root || h.is_embed_shared_root || h.is_embed_users_root) then
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.#{e}"
58
+ eval "h#{e}"
59
59
  end
60
60
  end
61
61
  end