gazer 0.2.59 → 0.3.0
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/.github/workflows/lint-pr.yml +17 -0
- data/.github/workflows/release.yml +3 -4
- data/.github/workflows/ruby-ci.yml +2 -2
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +6 -5
- data/gzr.gemspec +2 -1
- data/lib/gzr/cli.rb +5 -6
- data/lib/gzr/command.rb +27 -17
- data/lib/gzr/commands/attribute/create.rb +3 -3
- data/lib/gzr/commands/attribute/get_group_value.rb +1 -1
- data/lib/gzr/commands/attribute/import.rb +2 -2
- data/lib/gzr/commands/attribute/rm.rb +2 -2
- data/lib/gzr/commands/attribute/set_group_value.rb +1 -1
- data/lib/gzr/commands/attribute.rb +2 -2
- data/lib/gzr/commands/connection/ls.rb +1 -1
- data/lib/gzr/commands/dashboard/cat.rb +1 -1
- data/lib/gzr/commands/dashboard/import.rb +33 -26
- data/lib/gzr/commands/dashboard/mv.rb +8 -8
- data/lib/gzr/commands/dashboard.rb +8 -8
- data/lib/gzr/commands/{space → folder}/cat.rb +7 -7
- data/lib/gzr/commands/{space → folder}/create.rb +9 -9
- data/lib/gzr/commands/{space → folder}/export.rb +20 -20
- data/lib/gzr/commands/{space → folder}/ls.rb +11 -11
- data/lib/gzr/commands/{space → folder}/rm.rb +12 -12
- data/lib/gzr/commands/{space → folder}/top.rb +7 -7
- data/lib/gzr/commands/{space → folder}/tree.rb +21 -21
- data/lib/gzr/commands/{space.rb → folder.rb} +28 -28
- data/lib/gzr/commands/group.rb +1 -1
- data/lib/gzr/commands/look/import.rb +5 -5
- data/lib/gzr/commands/look/mv.rb +8 -8
- data/lib/gzr/commands/look.rb +8 -8
- data/lib/gzr/commands/permissions/ls.rb +1 -1
- data/lib/gzr/commands/plan/disable.rb +2 -2
- data/lib/gzr/commands/plan/enable.rb +2 -2
- data/lib/gzr/commands/plan/failures.rb +1 -1
- data/lib/gzr/commands/plan/import.rb +3 -3
- data/lib/gzr/commands/plan/run.rb +2 -2
- data/lib/gzr/commands/query/runquery.rb +3 -3
- data/lib/gzr/commands/role/group_add.rb +1 -1
- data/lib/gzr/commands/role/group_rm.rb +1 -1
- data/lib/gzr/commands/role/user_add.rb +1 -1
- data/lib/gzr/commands/role/user_rm.rb +1 -1
- data/lib/gzr/commands/user.rb +2 -2
- data/lib/gzr/modules/attribute.rb +8 -8
- data/lib/gzr/modules/connection.rb +2 -2
- data/lib/gzr/modules/dashboard.rb +34 -21
- data/lib/gzr/modules/filehelper.rb +1 -0
- data/lib/gzr/modules/{space.rb → folder.rb} +46 -46
- data/lib/gzr/modules/group.rb +10 -10
- data/lib/gzr/modules/look.rb +23 -22
- data/lib/gzr/modules/model.rb +1 -1
- data/lib/gzr/modules/permissions.rb +1 -1
- data/lib/gzr/modules/plan.rb +17 -17
- data/lib/gzr/modules/role.rb +7 -7
- data/lib/gzr/modules/session.rb +11 -16
- data/lib/gzr/modules/user.rb +7 -7
- data/lib/gzr/version.rb +1 -1
- metadata +26 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 371ab48fd0b84acabc2e3e69475c1091b55249385eb04f7829f0307ebc4f8b2e
|
4
|
+
data.tar.gz: 278b70d24348f197754f917fe9f386c77f46dd8491511379c670b24a0b72403b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52ebaf3617cbf085a9faeb3813e27abfbb603b42343dd61f86bc27b5a742bf3bc101877593c7aee863c87411416d97545c345c20ee45f3bb03319b5161a8e9e7
|
7
|
+
data.tar.gz: 4cb981d34fa562368feb3895ba8de78458237fd5428dec73b8d2c259f44a1fc5e0c07abb8471e2db802c947833573a505e186eeee7fb7170b1ab7a23e8ecd174
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name: "Lint PR"
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request_target:
|
5
|
+
types:
|
6
|
+
- opened
|
7
|
+
- edited
|
8
|
+
- synchronize
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
main:
|
12
|
+
name: Validate PR title
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
steps:
|
15
|
+
- uses: amannn/action-semantic-pull-request@v5
|
16
|
+
env:
|
17
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@@ -11,7 +11,9 @@ jobs:
|
|
11
11
|
release-please:
|
12
12
|
runs-on: ubuntu-latest
|
13
13
|
steps:
|
14
|
-
|
14
|
+
# Checkout code
|
15
|
+
- uses: actions/checkout@v3
|
16
|
+
- uses: GoogleCloudPlatform/release-please-action@v3
|
15
17
|
id: release
|
16
18
|
with:
|
17
19
|
release-type: ruby
|
@@ -20,9 +22,6 @@ jobs:
|
|
20
22
|
bump-patch-for-minor-pre-major: true
|
21
23
|
version-file: "lib/gzr/version.rb"
|
22
24
|
token: ${{ secrets.LOS_AUTO_BOT_RP_TOKEN }}
|
23
|
-
# Checkout code if release was created
|
24
|
-
- uses: actions/checkout@v2
|
25
|
-
if: ${{ steps.release.outputs.release_created }}
|
26
25
|
# Setup ruby if a release was created
|
27
26
|
- uses: ruby/setup-ruby@v1
|
28
27
|
with:
|
@@ -88,7 +88,7 @@ jobs:
|
|
88
88
|
|
89
89
|
- name: Upload ts unit test results
|
90
90
|
if: ${{ always() }}
|
91
|
-
uses: actions/upload-artifact@
|
91
|
+
uses: actions/upload-artifact@v3
|
92
92
|
with:
|
93
93
|
name: ruby-ci-test-results-${{ matrix.looker }}
|
94
94
|
path: rspec.xml
|
@@ -100,7 +100,7 @@ jobs:
|
|
100
100
|
|
101
101
|
steps:
|
102
102
|
- name: Download Artifacts
|
103
|
-
uses: actions/download-artifact@
|
103
|
+
uses: actions/download-artifact@v3
|
104
104
|
with:
|
105
105
|
path: artifacts
|
106
106
|
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.3.0](https://github.com/looker-open-source/gzr/compare/v0.2.60...v0.3.0) (2023-04-13)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* Misc fixes ([#175](https://github.com/looker-open-source/gzr/issues/175)) ([20b334b](https://github.com/looker-open-source/gzr/commit/20b334b3e4d1a76ecef79d5c686f6cf428cdc47d))
|
9
|
+
|
10
|
+
|
11
|
+
### Miscellaneous Chores
|
12
|
+
|
13
|
+
* release 0.3.0 ([5ed2182](https://github.com/looker-open-source/gzr/commit/5ed2182b94c20126f59b0678671d7c9b81c1c794))
|
14
|
+
|
15
|
+
### [0.2.60](https://www.github.com/looker-open-source/gzr/compare/v0.2.59...v0.2.60) (2023-04-11)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* quick typo fixes for API 4.0 changes ([#168](https://www.github.com/looker-open-source/gzr/issues/168)) ([82a634e](https://www.github.com/looker-open-source/gzr/commit/82a634e77de0aaee5bd62c84092e827a2f7f6c73))
|
21
|
+
|
3
22
|
### [0.2.59](https://www.github.com/looker-open-source/gzr/compare/v0.2.58...v0.2.59) (2023-03-29)
|
4
23
|
|
5
24
|
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gazer (0.
|
5
|
-
|
4
|
+
gazer (0.3.0)
|
5
|
+
faraday (~> 1.10.3)
|
6
|
+
looker-sdk (~> 0.1.1)
|
6
7
|
net-http-persistent (~> 4.0, >= 4.0.1)
|
7
8
|
netrc (~> 0.11.0)
|
8
9
|
pastel (~> 0.8.0)
|
@@ -42,8 +43,8 @@ GEM
|
|
42
43
|
faraday-patron (1.0.0)
|
43
44
|
faraday-rack (1.0.0)
|
44
45
|
faraday-retry (1.0.3)
|
45
|
-
looker-sdk (0.1.
|
46
|
-
faraday (>= 1.2, <
|
46
|
+
looker-sdk (0.1.4)
|
47
|
+
faraday (>= 1.2, < 3.0)
|
47
48
|
sawyer (~> 0.8)
|
48
49
|
multipart-post (2.3.0)
|
49
50
|
net-http-persistent (4.0.1)
|
@@ -51,7 +52,7 @@ GEM
|
|
51
52
|
netrc (0.11.0)
|
52
53
|
pastel (0.8.0)
|
53
54
|
tty-color (~> 0.5)
|
54
|
-
public_suffix (
|
55
|
+
public_suffix (5.0.1)
|
55
56
|
rake (12.3.3)
|
56
57
|
rspec (3.10.0)
|
57
58
|
rspec-core (~> 3.10.0)
|
data/gzr.gemspec
CHANGED
@@ -59,7 +59,8 @@ 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 '
|
62
|
+
spec.add_dependency 'faraday', "~> 1.10.3"
|
63
|
+
spec.add_dependency 'looker-sdk', "~> 0.1.1"
|
63
64
|
spec.add_runtime_dependency 'net-http-persistent', '~> 4.0', '>= 4.0.1'
|
64
65
|
|
65
66
|
spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.10'
|
data/lib/gzr/cli.rb
CHANGED
@@ -36,9 +36,8 @@ module Gzr
|
|
36
36
|
class_option :debug, type: :boolean, default: false, desc: 'Run in debug mode'
|
37
37
|
class_option :host, type: :string, default: 'localhost', desc: 'Looker Host'
|
38
38
|
class_option :port, type: :string, default: '19999', desc: 'Looker API Port'
|
39
|
-
class_option :client_id, type: :string, desc: '
|
40
|
-
class_option :client_secret, type: :string, desc: '
|
41
|
-
class_option :api_version, type: :string, desc: 'Looker API Version'
|
39
|
+
class_option :client_id, type: :string, desc: 'API Client Id'
|
40
|
+
class_option :client_secret, type: :string, desc: 'API Client Secret'
|
42
41
|
class_option :ssl, type: :boolean, default: true, desc: 'Use ssl to communicate with host'
|
43
42
|
class_option :verify_ssl, type: :boolean, default: true, desc: 'Verify the SSL certificate of the host'
|
44
43
|
class_option :timeout, type: :numeric, default: 60, desc: 'Seconds to wait for a response from the server'
|
@@ -57,7 +56,7 @@ module Gzr
|
|
57
56
|
puts "v#{Gzr::VERSION}"
|
58
57
|
end
|
59
58
|
map %w(--version -v) => :version
|
60
|
-
map
|
59
|
+
map space: :folder # Alias space command to folder
|
61
60
|
|
62
61
|
require_relative 'commands/attribute'
|
63
62
|
register Gzr::Commands::Attribute, 'attribute', 'attribute [SUBCOMMAND]', 'Command description...'
|
@@ -92,7 +91,7 @@ module Gzr
|
|
92
91
|
require_relative 'commands/look'
|
93
92
|
register Gzr::Commands::Look, 'look', 'look [SUBCOMMAND]', 'Commands pertaining to looks'
|
94
93
|
|
95
|
-
require_relative 'commands/
|
96
|
-
register Gzr::Commands::
|
94
|
+
require_relative 'commands/folder'
|
95
|
+
register Gzr::Commands::Folder, 'folder', 'folder [SUBCOMMAND]', 'Commands pertaining to folders'
|
97
96
|
end
|
98
97
|
end
|
data/lib/gzr/command.rb
CHANGED
@@ -25,6 +25,7 @@ require 'forwardable'
|
|
25
25
|
require 'tty-reader'
|
26
26
|
require 'netrc'
|
27
27
|
require 'looker-sdk'
|
28
|
+
require 'faraday/multipart'
|
28
29
|
|
29
30
|
require_relative 'modules/session'
|
30
31
|
|
@@ -57,7 +58,7 @@ module Gzr
|
|
57
58
|
data = @sdk.query(query_id)
|
58
59
|
rescue LookerSDK::Error => e
|
59
60
|
say_error "Error querying query(#{query_id})"
|
60
|
-
say_error e
|
61
|
+
say_error e
|
61
62
|
raise
|
62
63
|
end
|
63
64
|
data
|
@@ -71,7 +72,7 @@ module Gzr
|
|
71
72
|
end
|
72
73
|
rescue LookerSDK::Error => e
|
73
74
|
say_error "Error creating query(#{JSON.pretty_generate(query)})"
|
74
|
-
say_error e
|
75
|
+
say_error e
|
75
76
|
raise
|
76
77
|
end
|
77
78
|
data
|
@@ -85,7 +86,7 @@ module Gzr
|
|
85
86
|
say_error "The api endpoint merge_query(#{merge_result_id}) is not implemented on this Looker instance"
|
86
87
|
rescue LookerSDK::Error => e
|
87
88
|
say_error "Error querying merge_query(#{merge_result_id})"
|
88
|
-
say_error e
|
89
|
+
say_error e
|
89
90
|
raise
|
90
91
|
end
|
91
92
|
data
|
@@ -99,7 +100,7 @@ module Gzr
|
|
99
100
|
raise
|
100
101
|
rescue LookerSDK::Error => e
|
101
102
|
say_error "Error creating merge_query(#{JSON.pretty_generate(merge_query)})"
|
102
|
-
say_error e
|
103
|
+
say_error e
|
103
104
|
raise
|
104
105
|
end
|
105
106
|
data
|
@@ -110,7 +111,7 @@ module Gzr
|
|
110
111
|
data = @sdk.run_inline_query("json",query)
|
111
112
|
rescue LookerSDK::Error => e
|
112
113
|
say_error "Error running inline_query(#{JSON.pretty_generate(query)})"
|
113
|
-
say_error e
|
114
|
+
say_error e
|
114
115
|
raise
|
115
116
|
end
|
116
117
|
data
|
@@ -126,7 +127,7 @@ module Gzr
|
|
126
127
|
say_warning "The current user can't query all color collections"
|
127
128
|
rescue LookerSDK::Error => e
|
128
129
|
say_error "Error querying all_color_collections()"
|
129
|
-
say_error e
|
130
|
+
say_error e
|
130
131
|
raise
|
131
132
|
end
|
132
133
|
data
|
@@ -144,7 +145,7 @@ module Gzr
|
|
144
145
|
say_warning "The current user can't query the default color collection"
|
145
146
|
rescue LookerSDK::Error => e
|
146
147
|
say_error "Error querying default_color_collection()"
|
147
|
-
say_error e
|
148
|
+
say_error e
|
148
149
|
raise
|
149
150
|
end
|
150
151
|
data
|
@@ -160,7 +161,7 @@ module Gzr
|
|
160
161
|
say_warning "The color_collection(#{collection_id}) is not found"
|
161
162
|
rescue LookerSDK::Error => e
|
162
163
|
say_error "Error querying color_collection(#{collection_id})"
|
163
|
-
say_error e
|
164
|
+
say_error e
|
164
165
|
raise
|
165
166
|
end
|
166
167
|
data
|
@@ -182,7 +183,7 @@ module Gzr
|
|
182
183
|
return
|
183
184
|
end
|
184
185
|
@default_colors=color_palette_lookup!(dcc)
|
185
|
-
say_warning("Default colors #{JSON.pretty_generate @default_colors}") if @options[:debug]
|
186
|
+
#say_warning("Default colors #{JSON.pretty_generate @default_colors}") if @options[:debug]
|
186
187
|
end unless @default_colors
|
187
188
|
|
188
189
|
if obj.respond_to?(:'has_key?') && obj.has_key?(:collection_id) && obj.has_key?(:palette_id)
|
@@ -194,13 +195,13 @@ module Gzr
|
|
194
195
|
|
195
196
|
def color_palette_lookup!(obj)
|
196
197
|
return nil unless obj.respond_to?(:'has_key?')
|
197
|
-
say_warning("performing color_palette_lookup! on #{JSON.pretty_generate obj}") if @options[:debug]
|
198
|
+
#say_warning("performing color_palette_lookup! on #{JSON.pretty_generate obj}") if @options[:debug]
|
198
199
|
palettes = []
|
199
200
|
palettes += obj[:categoricalPalettes] if obj[:categoricalPalettes]
|
200
201
|
palettes += obj[:sequentialPalettes] if obj[:sequentialPalettes]
|
201
202
|
palettes += obj[:divergingPalettes] if obj[:divergingPalettes]
|
202
203
|
obj[:palettes]=palettes
|
203
|
-
say_warning("got palettes #{JSON.pretty_generate palettes}") if @options[:debug]
|
204
|
+
#say_warning("got palettes #{JSON.pretty_generate palettes}") if @options[:debug]
|
204
205
|
obj
|
205
206
|
end
|
206
207
|
|
@@ -211,11 +212,11 @@ module Gzr
|
|
211
212
|
cc = default_colors
|
212
213
|
else
|
213
214
|
o[:collection_default] = false
|
214
|
-
say_ok("looking up color collection by id #{o[:collection_id]}") if @options[:debug]
|
215
|
+
#say_ok("looking up color collection by id #{o[:collection_id]}") if @options[:debug]
|
215
216
|
cc = color_palette_lookup!(color_collection(o[:collection_id]))
|
216
217
|
end
|
217
218
|
return unless cc
|
218
|
-
say_warning("got color collection #{JSON.pretty_generate cc}") if @options[:debug]
|
219
|
+
#say_warning("got color collection #{JSON.pretty_generate cc}") if @options[:debug]
|
219
220
|
o[:collection_label] = cc[:label]
|
220
221
|
ps = cc[:palettes].select { |p| p[:id] == o[:palette_id] }
|
221
222
|
if ps.length > 0
|
@@ -233,11 +234,11 @@ module Gzr
|
|
233
234
|
cc = default_colors
|
234
235
|
if !(force_default && o[:collection_default])
|
235
236
|
# look up color collection by id
|
236
|
-
say_warning("attempting to match palette on id #{o[:collection_id]}") if @options[:debug]
|
237
|
+
#say_warning("attempting to match palette on id #{o[:collection_id]}") if @options[:debug]
|
237
238
|
cc = color_palette_lookup!(color_collection(o[:collection_id]))
|
238
239
|
if cc.nil?
|
239
240
|
# find color collection by name
|
240
|
-
say_warning("no match on id, attempting to match palette on name #{o[:collection_label]}") if @options[:debug]
|
241
|
+
#say_warning("no match on id, attempting to match palette on name #{o[:collection_label]}") if @options[:debug]
|
241
242
|
ccs = all_color_collections()&.select { |cc| o[:collection_label] == cc[:label]}
|
242
243
|
if ccs.nil? || ccs.length == 0
|
243
244
|
# no color collection found. Use default.
|
@@ -265,6 +266,7 @@ module Gzr
|
|
265
266
|
end
|
266
267
|
end
|
267
268
|
|
269
|
+
|
268
270
|
##
|
269
271
|
# This method accepts the name of an sdk operation, then finds the parameter for that
|
270
272
|
# operation in the data structures from the swagger.json file. The parameter is a
|
@@ -281,6 +283,11 @@ module Gzr
|
|
281
283
|
# end
|
282
284
|
|
283
285
|
def keys_to_keep(operation)
|
286
|
+
@keys_to_keep_cache ||= {}
|
287
|
+
@keys_to_keep_cache[operation] ||= keys_to_keep_internal(operation)
|
288
|
+
end
|
289
|
+
|
290
|
+
def keys_to_keep_internal(operation)
|
284
291
|
o = @sdk.operations[operation] || @sdk.operations[operation.to_sym]
|
285
292
|
begin
|
286
293
|
say_error "Operation #{operation} not found"
|
@@ -291,7 +298,10 @@ module Gzr
|
|
291
298
|
|
292
299
|
say_warning "Expecting exactly one body parameter with a schema for operation #{operation}" unless parameters.length == 1
|
293
300
|
schema_ref = parameters[0][:schema][:$ref].split(/\//)
|
294
|
-
|
301
|
+
key_list = @sdk.swagger[schema_ref[1].to_sym][schema_ref[2].to_sym][:properties].reject { |k,v| v[:readOnly] }.keys
|
302
|
+
say_warning "key_list #{operation} -> #{key_list}" if @options[:debug]
|
303
|
+
return key_list
|
304
|
+
|
295
305
|
end
|
296
306
|
|
297
307
|
##
|
@@ -382,7 +392,7 @@ module Gzr
|
|
382
392
|
##
|
383
393
|
# This method will accept two arrays, a and b, and create a third array
|
384
394
|
# like [ [a[0],b[0]], [a[1],b[1]], [a[2],b[2]], ...].
|
385
|
-
# If either array is longer than the other, additional pairs
|
395
|
+
# If either array is longer than the other, additional pairs
|
386
396
|
# will be generated with the shorter array padded out with nil values.
|
387
397
|
#
|
388
398
|
# Any additional args will be added to each inner array.
|
@@ -44,11 +44,11 @@ module Gzr
|
|
44
44
|
source[:'value_is_hidden'] = true if @options[:'is-hidden']
|
45
45
|
source[:'user_can_view'] = true if @options[:'can-view']
|
46
46
|
source[:'user_can_edit'] = true if @options[:'can-edit']
|
47
|
-
source[:'
|
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]
|
51
|
-
output.puts attr.id if @options[:plain]
|
50
|
+
output.puts "Imported attribute #{attr.name} #{attr.id}" unless @options[:plain]
|
51
|
+
output.puts attr.id if @options[:plain]
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -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
|
@@ -52,8 +52,8 @@ module Gzr
|
|
52
52
|
|
53
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
|
@@ -100,8 +100,8 @@ module Gzr
|
|
100
100
|
desc: 'can a non-admin user view the value'
|
101
101
|
method_option :'can-edit', type: :boolean, default: true,
|
102
102
|
desc: 'can a user change the value themself'
|
103
|
-
method_option :'domain-
|
104
|
-
desc: 'what domains can receive the value of a hidden attribute.'
|
103
|
+
method_option :'domain-allowlist', type: :string,
|
104
|
+
desc: 'what domains can receive the value of a hidden attribute.'
|
105
105
|
def create(attr_name, attr_label=nil)
|
106
106
|
if options[:help]
|
107
107
|
invoke :help, ['create']
|
@@ -61,7 +61,7 @@ module Gzr
|
|
61
61
|
if @options[:csv] then
|
62
62
|
output.puts render_csv(table)
|
63
63
|
else
|
64
|
-
output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width:
|
64
|
+
output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
|
65
65
|
end
|
66
66
|
end if table
|
67
67
|
end
|
@@ -38,16 +38,16 @@ module Gzr
|
|
38
38
|
include Gzr::User
|
39
39
|
include Gzr::Plan
|
40
40
|
include Gzr::FileHelper
|
41
|
-
def initialize(file,
|
41
|
+
def initialize(file, dest_folder_id, options)
|
42
42
|
super()
|
43
43
|
@file = file
|
44
|
-
@
|
44
|
+
@dest_folder_id = dest_folder_id
|
45
45
|
@options = options
|
46
46
|
end
|
47
47
|
|
48
48
|
def execute(input: $stdin, output: $stdout)
|
49
49
|
say_warning("options: #{@options.inspect}", output: output) if @options[:debug]
|
50
|
-
with_session
|
50
|
+
with_session do
|
51
51
|
|
52
52
|
@me ||= query_me("id")
|
53
53
|
|
@@ -63,7 +63,8 @@ module Gzr
|
|
63
63
|
raise Gzr::CLI::Error, "import file is not a valid dashboard"
|
64
64
|
end
|
65
65
|
|
66
|
-
dashboard = sync_dashboard(data,@
|
66
|
+
dashboard = sync_dashboard(data,@dest_folder_id, output: output)
|
67
|
+
say_warning "dashboard object #{JSON.pretty_generate dashboard.map(&:to_a).to_json}" if @options[:debug]
|
67
68
|
|
68
69
|
dashboard[:dashboard_filters] ||= []
|
69
70
|
source_filters = data[:dashboard_filters].sort { |a,b| a[:row] <=> b[:row] }
|
@@ -79,30 +80,32 @@ module Gzr
|
|
79
80
|
dashboard[:dashboard_elements] ||= []
|
80
81
|
elem_table = data[:dashboard_elements].map do |new_element|
|
81
82
|
element = new_element.select do |k,v|
|
82
|
-
(keys_to_keep('create_dashboard_element') - [:dashboard_id, :look_id, :query_id, :merge_result_id, :result_maker_id]).include? k
|
83
|
+
(keys_to_keep('create_dashboard_element') - [:dashboard_id, :look_id, :query_id, :merge_result_id, :result_maker_id, :query, :merge_result]).include? k
|
83
84
|
end
|
84
|
-
(element[:query_id],element[:look_id],element[:merge_result_id]) = process_dashboard_element(new_element)
|
85
|
-
say_warning "Creating dashboard element #{element.inspect}" if @options[:debug]
|
85
|
+
(element[:query_id],element[:look_id],element[:merge_result_id]) = process_dashboard_element(new_element)
|
86
|
+
say_warning "Creating dashboard element #{element.select {|k,v| !v.nil?}.inspect}" if @options[:debug]
|
86
87
|
element[:dashboard_id] = dashboard.id
|
87
88
|
result_maker = copy_result_maker_filterables(new_element)
|
88
89
|
element[:result_maker] = result_maker if result_maker
|
89
90
|
dashboard_element = create_dashboard_element(element)
|
91
|
+
say_warning "dashboard_element #{dashboard_element.inspect}" if @options[:debug]
|
90
92
|
dashboard[:dashboard_elements].push dashboard_element
|
91
93
|
[new_element[:id], dashboard_element.id]
|
92
94
|
end
|
93
95
|
|
94
96
|
source_dashboard_layouts = data[:dashboard_layouts].map do |new_layout|
|
95
97
|
layout_obj = nil
|
96
|
-
if new_layout[:active]
|
98
|
+
if new_layout[:active]
|
97
99
|
layout_obj = get_dashboard_layout(dashboard[:dashboard_layouts].first.id)
|
98
100
|
say_warning "Updating layout #{layout_obj.id}" if @options[:debug]
|
99
|
-
else
|
101
|
+
else
|
100
102
|
layout = new_layout.select do |k,v|
|
101
103
|
(keys_to_keep('create_dashboard_layout') - [:dashboard_id]).include? k
|
102
104
|
end
|
103
105
|
layout[:dashboard_id] = dashboard.id
|
104
106
|
say_warning "Creating dashboard layout #{layout}" if @options[:debug]
|
105
107
|
layout_obj = create_dashboard_layout(layout)
|
108
|
+
say_warning "Created dashboard layout #{JSON.pretty_generate layout_obj.map(&:to_a).to_json}" if @options[:debug]
|
106
109
|
end
|
107
110
|
layout_components = new_layout[:dashboard_layout_components].zip(layout_obj.dashboard_layout_components)
|
108
111
|
layout_components.each do |source,target|
|
@@ -121,22 +124,22 @@ module Gzr
|
|
121
124
|
end
|
122
125
|
end
|
123
126
|
upsert_plans_for_dashboard(dashboard.id,@me.id,data[:scheduled_plans]) if data[:scheduled_plans]
|
124
|
-
output.puts "Imported dashboard #{dashboard.id}" unless @options[:plain]
|
125
|
-
output.puts dashboard.id if @options[:plain]
|
127
|
+
output.puts "Imported dashboard #{dashboard.id}" unless @options[:plain]
|
128
|
+
output.puts dashboard.id if @options[:plain]
|
126
129
|
end
|
127
130
|
end
|
128
131
|
end
|
129
132
|
|
130
|
-
def sync_dashboard(source,
|
131
|
-
# try to find dashboard by slug in target
|
132
|
-
existing_dashboard = search_dashboards_by_slug(source[:slug],
|
133
|
-
# check for dash of same title in target
|
134
|
-
title_used = search_dashboards_by_title(source[:title],
|
135
|
-
|
136
|
-
# If there is no match by slug in target space or no slug given, then we match by title
|
133
|
+
def sync_dashboard(source, target_folder_id, output: $stdout)
|
134
|
+
# try to find dashboard by slug in target folder
|
135
|
+
existing_dashboard = search_dashboards_by_slug(source[:slug], target_folder_id).fetch(0,nil) if source[:slug]
|
136
|
+
# check for dash of same title in target folder
|
137
|
+
title_used = search_dashboards_by_title(source[:title], target_folder_id).select {|d| !d[:deleted] }.fetch(0,nil)
|
138
|
+
# If there is no match by slug in target folder or no slug given, then we match by title
|
137
139
|
existing_dashboard ||= title_used
|
140
|
+
say_warning "existing_dashboard object #{existing_dashboard.inspect}" if @options[:debug]
|
138
141
|
|
139
|
-
# same_title is now a flag indicating that there is already a dash in the same
|
142
|
+
# same_title is now a flag indicating that there is already a dash in the same folder with
|
140
143
|
# that title, and it is the one we are updating.
|
141
144
|
same_title = (title_used&.fetch(:id,nil) == existing_dashboard&.fetch(:id,nil))
|
142
145
|
|
@@ -148,18 +151,18 @@ module Gzr
|
|
148
151
|
same_slug = (slug_used&.fetch(:id,nil) == existing_dashboard&.fetch(:id,nil))
|
149
152
|
|
150
153
|
if slug_used && !same_slug then
|
151
|
-
say_warning "slug #{slug_used.slug} already used for dashboard #{slug_used.title} in
|
154
|
+
say_warning "slug #{slug_used.slug} already used for dashboard #{slug_used.title} in folder #{slug_used.folder_id}", output: output
|
152
155
|
say_warning("That dashboard is in the 'Trash' but not fully deleted yet", output: output) if slug_used.deleted
|
153
156
|
say_warning "dashboard will be imported with new slug", output: output
|
154
157
|
end
|
155
158
|
|
156
159
|
if existing_dashboard then
|
157
160
|
if title_used && !same_title then
|
158
|
-
raise Gzr::CLI::Error, "Dashboard #{source[:title]} already exists in
|
161
|
+
raise Gzr::CLI::Error, "Dashboard #{source[:title]} already exists in folder #{target_folder_id}\nDelete it before trying to upate another dashboard to have that title."
|
159
162
|
end
|
160
|
-
raise Gzr::CLI::Error, "Dashboard #{existing_dashboard[:title]} with slug #{existing_dashboard[:slug]} already exists in
|
163
|
+
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]
|
161
164
|
|
162
|
-
say_ok "Modifying existing dashboard #{existing_dashboard.id} #{existing_dashboard[:title]} in
|
165
|
+
say_ok "Modifying existing dashboard #{existing_dashboard.id} #{existing_dashboard[:title]} in folder #{target_folder_id}", output: output
|
163
166
|
new_dash = source.select do |k,v|
|
164
167
|
(keys_to_keep('update_dashboard') - [:space_id,:folder_id,:user_id,:slug]).include? k
|
165
168
|
end
|
@@ -188,9 +191,13 @@ module Gzr
|
|
188
191
|
(keys_to_keep('create_dashboard') - [:space_id,:folder_id,:user_id,:slug]).include? k
|
189
192
|
end
|
190
193
|
new_dash[:slug] = source[:slug] unless slug_used
|
191
|
-
new_dash[:
|
194
|
+
new_dash[:folder_id] = target_folder_id
|
192
195
|
new_dash[:user_id] = @me.id
|
193
|
-
|
196
|
+
new_dash.select!{|k,v| !v.nil?}
|
197
|
+
say_warning "new dashboard request #{new_dash.inspect}" if @options[:debug]
|
198
|
+
d = create_dashboard(new_dash)
|
199
|
+
say_warning "new dashboard object #{d.inspect}" if @options[:debug]
|
200
|
+
return d
|
194
201
|
end
|
195
202
|
end
|
196
203
|
|
@@ -209,7 +216,7 @@ module Gzr
|
|
209
216
|
end
|
210
217
|
|
211
218
|
def process_dashboard_element(dash_elem)
|
212
|
-
return [nil, upsert_look(@me.id, create_fetch_query(dash_elem[:look][:query]).id, @
|
219
|
+
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]
|
213
220
|
|
214
221
|
query = dash_elem[:result_maker]&.fetch(:query, false) || dash_elem[:query]
|
215
222
|
return [create_fetch_query(query).id, nil, nil] if query
|
@@ -30,10 +30,10 @@ module Gzr
|
|
30
30
|
class Dashboard
|
31
31
|
class Mv < Gzr::Command
|
32
32
|
include Gzr::Dashboard
|
33
|
-
def initialize(dashboard_id,
|
33
|
+
def initialize(dashboard_id, target_folder_id, options)
|
34
34
|
super()
|
35
35
|
@dashboard_id = dashboard_id
|
36
|
-
@
|
36
|
+
@target_folder_id = target_folder_id
|
37
37
|
@options = options
|
38
38
|
end
|
39
39
|
|
@@ -44,18 +44,18 @@ module Gzr
|
|
44
44
|
dash = query_dashboard(@dashboard_id)
|
45
45
|
raise Gzr::CLI::Error, "Dashboard with id #{@dashboard_id} does not exist" unless dash
|
46
46
|
|
47
|
-
matching_title = search_dashboards_by_title(dash[:title],@
|
47
|
+
matching_title = search_dashboards_by_title(dash[:title],@target_folder_id)
|
48
48
|
if matching_title.empty? || matching_title.first[:deleted]
|
49
49
|
matching_title = false
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
if matching_title
|
53
|
-
raise Gzr::CLI::Error, "Dashboard #{dash[:title]} already exists in
|
54
|
-
say_ok "Deleting existing dashboard #{matching_title.first[:id]} #{matching_title.first[:title]} in
|
53
|
+
raise Gzr::CLI::Error, "Dashboard #{dash[:title]} already exists in folder #{@target_folder_id}\nUse --force if you want to overwrite it" unless @options[:force]
|
54
|
+
say_ok "Deleting existing dashboard #{matching_title.first[:id]} #{matching_title.first[:title]} in folder #{@target_folder_id}", output: output
|
55
55
|
update_dashboard(matching_title.first[:id],{:deleted=>true})
|
56
56
|
end
|
57
|
-
update_dashboard(dash[:id],{:
|
58
|
-
output.puts "Moved dashboard #{dash[:id]} to
|
57
|
+
update_dashboard(dash[:id],{:folder_id=>@target_folder_id})
|
58
|
+
output.puts "Moved dashboard #{dash[:id]} to folder #{@target_folder_id}" unless @options[:plain]
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|