gazer 0.3.9 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +11 -0
  3. data/CHANGELOG.md +14 -0
  4. data/Gemfile.lock +8 -24
  5. data/README.md +1 -8
  6. data/gzr.gemspec +3 -2
  7. data/lib/gzr/command.rb +9 -5
  8. data/lib/gzr/commands/alert/cat.rb +2 -2
  9. data/lib/gzr/commands/alert/ls.rb +2 -2
  10. data/lib/gzr/commands/alert/notifications.rb +2 -2
  11. data/lib/gzr/commands/attribute/cat.rb +3 -3
  12. data/lib/gzr/commands/attribute/create.rb +2 -2
  13. data/lib/gzr/commands/attribute/get_group_value.rb +4 -4
  14. data/lib/gzr/commands/attribute/import.rb +3 -3
  15. data/lib/gzr/commands/attribute/ls.rb +3 -3
  16. data/lib/gzr/commands/attribute/rm.rb +4 -4
  17. data/lib/gzr/commands/attribute/set_group_value.rb +4 -4
  18. data/lib/gzr/commands/connection/dialects.rb +4 -4
  19. data/lib/gzr/commands/connection/ls.rb +2 -2
  20. data/lib/gzr/commands/connection/test.rb +2 -2
  21. data/lib/gzr/commands/dashboard/import.rb +30 -30
  22. data/lib/gzr/commands/dashboard/mv.rb +1 -1
  23. data/lib/gzr/commands/folder/cat.rb +3 -3
  24. data/lib/gzr/commands/folder/create.rb +3 -3
  25. data/lib/gzr/commands/folder/export.rb +2 -2
  26. data/lib/gzr/commands/folder/ls.rb +3 -4
  27. data/lib/gzr/commands/folder/rm.rb +3 -3
  28. data/lib/gzr/commands/folder/top.rb +4 -4
  29. data/lib/gzr/commands/folder/tree.rb +11 -11
  30. data/lib/gzr/commands/group/ls.rb +3 -3
  31. data/lib/gzr/commands/group/member_groups.rb +3 -3
  32. data/lib/gzr/commands/group/member_users.rb +3 -3
  33. data/lib/gzr/commands/look/cat.rb +1 -1
  34. data/lib/gzr/commands/look/import.rb +5 -5
  35. data/lib/gzr/commands/look/mv.rb +1 -1
  36. data/lib/gzr/commands/look/rm.rb +1 -1
  37. data/lib/gzr/commands/model/ls.rb +4 -4
  38. data/lib/gzr/commands/model/set/ls.rb +2 -2
  39. data/lib/gzr/commands/permission/ls.rb +2 -2
  40. data/lib/gzr/commands/permission/set/ls.rb +2 -2
  41. data/lib/gzr/commands/plan/cat.rb +3 -3
  42. data/lib/gzr/commands/plan/disable.rb +3 -3
  43. data/lib/gzr/commands/plan/enable.rb +3 -3
  44. data/lib/gzr/commands/plan/failures.rb +12 -7
  45. data/lib/gzr/commands/plan/import.rb +5 -5
  46. data/lib/gzr/commands/plan/ls.rb +5 -5
  47. data/lib/gzr/commands/plan/run.rb +2 -2
  48. data/lib/gzr/commands/project/branch.rb +4 -4
  49. data/lib/gzr/commands/project/ls.rb +3 -3
  50. data/lib/gzr/commands/role/cat.rb +2 -2
  51. data/lib/gzr/commands/role/group_add.rb +2 -2
  52. data/lib/gzr/commands/role/group_ls.rb +3 -3
  53. data/lib/gzr/commands/role/group_rm.rb +2 -2
  54. data/lib/gzr/commands/role/ls.rb +3 -3
  55. data/lib/gzr/commands/role/user_add.rb +2 -2
  56. data/lib/gzr/commands/role/user_ls.rb +3 -3
  57. data/lib/gzr/commands/role/user_rm.rb +2 -2
  58. data/lib/gzr/commands/user/cat.rb +5 -3
  59. data/lib/gzr/commands/user/delete.rb +2 -1
  60. data/lib/gzr/commands/user/disable.rb +2 -1
  61. data/lib/gzr/commands/user/enable.rb +2 -1
  62. data/lib/gzr/commands/user/ls.rb +22 -11
  63. data/lib/gzr/commands/user/me.rb +6 -2
  64. data/lib/gzr/commands/user.rb +2 -0
  65. data/lib/gzr/modules/alert.rb +30 -17
  66. data/lib/gzr/modules/attribute.rb +24 -22
  67. data/lib/gzr/modules/connection.rb +10 -25
  68. data/lib/gzr/modules/dashboard.rb +86 -44
  69. data/lib/gzr/modules/folder.rb +20 -28
  70. data/lib/gzr/modules/group.rb +8 -10
  71. data/lib/gzr/modules/look.rb +23 -21
  72. data/lib/gzr/modules/model/set.rb +6 -6
  73. data/lib/gzr/modules/model.rb +14 -7
  74. data/lib/gzr/modules/permission/set.rb +2 -2
  75. data/lib/gzr/modules/permission.rb +2 -4
  76. data/lib/gzr/modules/plan.rb +36 -36
  77. data/lib/gzr/modules/project.rb +26 -21
  78. data/lib/gzr/modules/role.rb +48 -36
  79. data/lib/gzr/modules/session.rb +2 -2
  80. data/lib/gzr/modules/user.rb +52 -43
  81. data/lib/gzr/version.rb +1 -1
  82. metadata +21 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08df27aaf125092476d3b5cc5a35c07aec483a6785d45d57a24965e2a5f6e5e8'
4
- data.tar.gz: 417f85b8b695e2edd7e8758714991650dae3c95a7e0edb513b9dd282d6fcfaa4
3
+ metadata.gz: dce76479c6d89605e315f8f83c7e8290ccefbb6a543d8e3343b9a391ac3ed454
4
+ data.tar.gz: 6d54b5c93354d8b09531cdbe4aefd5d335a52e37f2db7c45682292d06d27592c
5
5
  SHA512:
6
- metadata.gz: 5a708df5171e637f015bd55156a9c19b5dde8d0a8acc536e906aeb7a2ca6ddfca88ed49ed11db8d0457b62c29fbd95510d3029ed76831e5a3250fd9690b644a6
7
- data.tar.gz: 564f6d56e7d6ac26cf88ca4276752014b0a91005359389fab11b37a71251c8ecaa279e91ee0c30576594107b982cf19dceacc523e624d2cb81bd8556c399ec22
6
+ metadata.gz: c2f41c52c372487a5214d9f9472b0896947c5f33663f7f3e75726d7350c0fc73cea814be179312156542fcc2c08e79f308bab2c0bfa6a0275ff3a0b7313a9067
7
+ data.tar.gz: c8263710569aa4a6e1bf457e4bb0c21b5cf2d01e39b3c230fe7599b81ace74f5d69fa1799f110f3af387fcbda236d2592fb3bae476af70c52754ca9dbe7a6a47
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
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
+
10
+ ## [0.3.10](https://github.com/looker-open-source/gzr/compare/v0.3.9...v0.3.10) (2023-06-28)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * Faraday 2.x ([bdc5e52](https://github.com/looker-open-source/gzr/commit/bdc5e5205c1be21d76b93624f193fadb8a1b32b3))
16
+
3
17
  ## [0.3.9](https://github.com/looker-open-source/gzr/compare/v0.3.8...v0.3.9) (2023-05-25)
4
18
 
5
19
 
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gazer (0.3.9)
5
- faraday (~> 1.10.3)
6
- looker-sdk (~> 0.1.1)
4
+ gazer (0.3.11)
5
+ faraday (~> 2.7.8)
6
+ faraday-multipart (~> 1.0)
7
+ looker-sdk (~> 0.1.6)
7
8
  net-http-persistent (~> 4.0, >= 4.0.1)
8
9
  netrc (~> 0.11.0)
9
10
  pastel (~> 0.8.0)
@@ -20,30 +21,13 @@ GEM
20
21
  public_suffix (>= 2.0.2, < 6.0)
21
22
  connection_pool (2.4.0)
22
23
  diff-lcs (1.4.4)
23
- faraday (1.10.3)
24
- faraday-em_http (~> 1.0)
25
- faraday-em_synchrony (~> 1.0)
26
- faraday-excon (~> 1.1)
27
- faraday-httpclient (~> 1.0)
28
- faraday-multipart (~> 1.0)
29
- faraday-net_http (~> 1.0)
30
- faraday-net_http_persistent (~> 1.0)
31
- faraday-patron (~> 1.0)
32
- faraday-rack (~> 1.0)
33
- faraday-retry (~> 1.0)
24
+ faraday (2.7.8)
25
+ faraday-net_http (>= 2.0, < 3.1)
34
26
  ruby2_keywords (>= 0.0.4)
35
- faraday-em_http (1.0.0)
36
- faraday-em_synchrony (1.0.0)
37
- faraday-excon (1.1.0)
38
- faraday-httpclient (1.0.1)
39
27
  faraday-multipart (1.0.4)
40
28
  multipart-post (~> 2)
41
- faraday-net_http (1.0.1)
42
- faraday-net_http_persistent (1.2.0)
43
- faraday-patron (1.0.0)
44
- faraday-rack (1.0.0)
45
- faraday-retry (1.0.3)
46
- looker-sdk (0.1.4)
29
+ faraday-net_http (3.0.2)
30
+ looker-sdk (0.1.6)
47
31
  faraday (>= 1.2, < 3.0)
48
32
  sawyer (~> 0.8)
49
33
  multipart-post (2.3.0)
data/README.md CHANGED
@@ -5,17 +5,10 @@ and Dashboards via a simple command line tool.
5
5
 
6
6
  <br/>
7
7
 
8
- ## *Attention*
9
-
10
- > This project is on a path towards deprecation in favor of (Looker Deployer)[https://github.com/looker-open-source/looker_deployer]. New users should start with Looker Deployer if possible.
11
- >
12
- > Looker Deployer is based on newer Looker APIs and is intended to provide a superset of CLI functionality, including content migration features.
13
-
14
- <br/>
15
8
 
16
9
  ## Status and Support
17
10
 
18
- As of November 2021, Gazer is supported, but not warrantied by Bytecode IO, Inc. Issues and feature requests can be reported via https://github.com/looker-open-source/gzr/issues, which will be regularly monitored and prioritized by Bytecode IO, Inc., a preferred Looker consulting partner.
11
+ As of 2023, Gazer is supported, but not warrantied by Google. Issues and feature requests can be reported via https://github.com/looker-open-source/gzr/issues, which will be regularly monitored and prioritized.
19
12
 
20
13
  ## Installation
21
14
 
data/gzr.gemspec CHANGED
@@ -59,8 +59,9 @@ Gem::Specification.new do |spec|
59
59
  spec.add_runtime_dependency 'thor', '~> 1.1', '>= 1.1.0'
60
60
  spec.add_dependency 'netrc', "~> 0.11.0"
61
61
  spec.add_runtime_dependency 'rubyzip', '~> 1.3', '>= 1.3.0'
62
- spec.add_dependency 'faraday', "~> 1.10.3"
63
- spec.add_dependency 'looker-sdk', "~> 0.1.1"
62
+ spec.add_dependency 'faraday', "~> 2.7.8"
63
+ spec.add_dependency 'faraday-multipart', '~> 1.0'
64
+ spec.add_dependency 'looker-sdk', "~> 0.1.6"
64
65
  spec.add_runtime_dependency 'net-http-persistent', '~> 4.0', '>= 4.0.1'
65
66
 
66
67
  spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.10'
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}"))