gazer 0.2.58 → 0.2.60

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/lint-pr.yml +17 -0
  3. data/.github/workflows/release.yml +3 -4
  4. data/.github/workflows/ruby-ci.yml +72 -38
  5. data/.rspec +2 -0
  6. data/.ruby-version +1 -1
  7. data/CHANGELOG.md +14 -0
  8. data/Gemfile +1 -1
  9. data/Gemfile.lock +12 -8
  10. data/gzr.gemspec +3 -1
  11. data/lib/gzr/cli.rb +5 -6
  12. data/lib/gzr/command.rb +12 -8
  13. data/lib/gzr/commands/attribute/get_group_value.rb +1 -1
  14. data/lib/gzr/commands/attribute/set_group_value.rb +1 -1
  15. data/lib/gzr/commands/dashboard/cat.rb +1 -1
  16. data/lib/gzr/commands/dashboard/import.rb +33 -26
  17. data/lib/gzr/commands/dashboard/mv.rb +7 -7
  18. data/lib/gzr/commands/dashboard.rb +8 -8
  19. data/lib/gzr/commands/{space → folder}/cat.rb +7 -7
  20. data/lib/gzr/commands/{space → folder}/create.rb +9 -9
  21. data/lib/gzr/commands/{space → folder}/export.rb +20 -20
  22. data/lib/gzr/commands/{space → folder}/ls.rb +11 -11
  23. data/lib/gzr/commands/{space → folder}/rm.rb +12 -12
  24. data/lib/gzr/commands/{space → folder}/top.rb +7 -7
  25. data/lib/gzr/commands/{space → folder}/tree.rb +21 -21
  26. data/lib/gzr/commands/{space.rb → folder.rb} +28 -28
  27. data/lib/gzr/commands/group.rb +1 -1
  28. data/lib/gzr/commands/look/import.rb +3 -3
  29. data/lib/gzr/commands/look/mv.rb +8 -8
  30. data/lib/gzr/commands/look.rb +8 -8
  31. data/lib/gzr/commands/user.rb +2 -2
  32. data/lib/gzr/modules/dashboard.rb +17 -4
  33. data/lib/gzr/modules/{space.rb → folder.rb} +38 -38
  34. data/lib/gzr/modules/look.rb +18 -17
  35. data/lib/gzr/modules/session.rb +10 -15
  36. data/lib/gzr/version.rb +1 -1
  37. metadata +41 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71d91f9fd62be429d6cda41b4bbf5a7cb6b7b4dc2d271f45d327370f3aa68b96
4
- data.tar.gz: 445e0c520b50f7da011b7742045a5f8a35fef89022b0aeddd4749a420373879d
3
+ metadata.gz: ffbe3dcb8878d37708779d3b188b007db7a1fac7807183ccdee7f8e0410dbcf8
4
+ data.tar.gz: 3feaf5d5dd4d55c3f6844afdf62b86177ab489186c77b54dfcfc81b6b8b59daa
5
5
  SHA512:
6
- metadata.gz: b3e8ebc3d02a6ac73e43a4da4a2256a8c2b3a58c254eea90c2204a64428c03032bbfd9330ac9b37c4440328b86a62f6c969697348243701d9dc58f54683078ff
7
- data.tar.gz: a28a41041e739a5724f4ebba873a1afd67be9d473f66a7a2efef439ea342cd760435aac7dfcc100d73e89562d8f2de796ad1e86f82faeb70d3546481adf9d0e3
6
+ metadata.gz: 8e28bcbc38b1f0077d7b4242649524b72db04ba7064add9e296569519bee38b43792f1b80bac96cbcdb4f50bf136aae6aa211c6f92d2a2ebdada43c6b79999fa
7
+ data.tar.gz: 857b9185b9ce97528befaa636895295bf0a1ff7724fa5b747227198f58324922ac74bf2e113a8d9fb09f420ebdb847fd8525ba2cc56eb3ddd8e574c92fdfb3ae
@@ -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,6 +11,8 @@ jobs:
11
11
  release-please:
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
+ # Checkout code
15
+ - uses: actions/checkout@v3
14
16
  - uses: GoogleCloudPlatform/release-please-action@v2
15
17
  id: release
16
18
  with:
@@ -20,13 +22,10 @@ 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:
29
- ruby-version: 2.5.8
28
+ ruby-version: 2.7.7
30
29
  if: ${{ steps.release.outputs.release_created }}
31
30
  # Bundle install
32
31
  - run: bundle install
@@ -5,73 +5,61 @@ on:
5
5
  branches: [ main ]
6
6
  pull_request:
7
7
  branches: [ main ]
8
+ workflow_dispatch:
8
9
 
9
10
  env:
10
11
  LOOKERSDK_BASE_URL: https://localhost:20000
11
12
  LOOKERSDK_VERIFY_SSL: false
12
- LOOKERSDK_CLIENT_ID: ${{ secrets.LOOKERSDK_CLIENT_ID__21_18 }}
13
- LOOKERSDK_CLIENT_SECRET: ${{ secrets.LOOKERSDK_CLIENT_SECRET__21_18 }}
13
+ LOOKERSDK_CLIENT_ID: ${{ secrets.LOOKERSDK_CLIENT_ID }}
14
+ LOOKERSDK_CLIENT_SECRET: ${{ secrets.LOOKERSDK_CLIENT_SECRET }}
14
15
 
15
16
  jobs:
17
+ setup:
18
+ uses: looker-open-source/reusable-actions/.github/workflows/supported-versions.yml@main
19
+
16
20
  test:
17
- name: Test - ${{ matrix.os }} / Looker.${{ matrix.looker }} / Ruby.${{ matrix.ruby-version }}
18
- runs-on: ${{ matrix.os }}-latest
21
+ name: Test - Looker.${{ matrix.looker }} / Ruby.${{ matrix.ruby-version }}
22
+ runs-on: ubuntu-latest
23
+ needs: setup
19
24
  strategy:
20
25
  matrix:
21
- os:
22
- - ubuntu
23
- looker:
24
- - '21_18'
25
- - '21_20'
26
- - '22_0'
27
- ruby-version: [2.5.8]
26
+ looker: ${{ fromJson(needs.setup.outputs.matrix_json) }}
27
+ ruby-version: [2.7.7]
28
28
 
29
29
  steps:
30
- - uses: actions/checkout@v2
30
+ - name: Cancel Previous Runs
31
+ uses: styfle/cancel-workflow-action@0.11.0
32
+ with:
33
+ access_token: ${{ secrets.GITHUB_TOKEN }}
31
34
 
32
- - name: Set up Cloud SDK
33
- uses: google-github-actions/setup-gcloud@v0.2.0
35
+ - uses: actions/checkout@v3
36
+
37
+ - name: Authenticate to Google Cloud
38
+ uses: google-github-actions/auth@v1.0.0
34
39
  with:
40
+ credentials_json: ${{ secrets.GCP_AR_READER_SA_KEY }}
35
41
  project_id: ${{ secrets.GCP_PROJECT_ID }}
36
- service_account_key: ${{ secrets.GCP_AR_READER_SA_KEY }}
37
- export_default_credentials: true
42
+ create_credentials_file: true
43
+ export_environment_variables: true
44
+
45
+ - name: Set up Cloud SDK
46
+ uses: google-github-actions/setup-gcloud@v1.1.0
38
47
 
39
48
  - name: Authenticate Artifact Repository
40
49
  run: gcloud auth configure-docker us-west1-docker.pkg.dev --quiet
41
50
 
42
51
  - name: Pull and run Looker docker image
43
- # TODO: can we cache some layers of the image for faster download?
44
- # we probably don't want to cache the final image for IP security...
45
52
  run: |
46
53
  docker pull --quiet us-west1-docker.pkg.dev/cloud-looker-sdk-codegen-cicd/looker/${{ matrix.looker }}
47
54
  # set $LOOKER_OPTS to --no-ssl if we want to turn off ssl
48
55
  docker run --name looker-sdk-codegen-ci -d -p 10000:9999 -p 20000:19999 us-west1-docker.pkg.dev/cloud-looker-sdk-codegen-cicd/looker/${{ matrix.looker }}
49
56
  docker logs -f looker-sdk-codegen-ci --until=30s &
50
57
 
51
- - name: Determine credentials version
52
- # Prior to 21_18, each version had different credentials and a
53
- # different secret. 21_20 and later all use the same credentials
54
- # as 21_18. The parse_version.sh script parses the version and
55
- # yields 21_12, 21_14, 21_16 etc for those versions but 21_18 for
56
- # anything 21_18, 21_20, 22_0, etc.
57
- #
58
- # This can be factored out entirely once 21_18 is the earliest
59
- # supported looker version.
60
- run: |
61
- echo "CREDENTIALS_VERSION=$(${{ github.workspace }}/.github/scripts/parse_version.sh <<< ${{ matrix.looker }})" >> $GITHUB_ENV
62
-
63
- - name: Set up Looker credentials
64
- # Load the correct credentials based on the version from
65
- # the prior step.
66
- run: |
67
- echo "LOOKERSDK_CLIENT_ID=${{ secrets[format('LOOKERSDK_CLIENT_ID__{0}', env.CREDENTIALS_VERSION )] }}" >> $GITHUB_ENV
68
- echo "LOOKERSDK_CLIENT_SECRET=${{ secrets[format('LOOKERSDK_CLIENT_SECRET__{0}', env.CREDENTIALS_VERSION )] }}" >> $GITHUB_ENV
69
-
70
58
  - name: Set up Ruby ${{ matrix.ruby-version }}
71
59
  uses: ruby/setup-ruby@v1
72
60
  with:
73
61
  ruby-version: ${{ matrix.ruby-version }}
74
- bundler-cache: true
62
+ bundler-cache: false
75
63
 
76
64
  - name: Install dependencies
77
65
  run: bundle install
@@ -80,5 +68,51 @@ jobs:
80
68
  run: |
81
69
  ${{ github.workspace }}/.github/scripts/wait_for_looker.sh
82
70
 
71
+ - name: Report Failure
72
+ run: |
73
+ curl --request POST \
74
+ --url https://api.github.com/repos/looker-open-source/sdk-codegen/check-runs \
75
+ --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
76
+ --header "content-type: application/json" \
77
+ --header "Accept: application/vnd.github.v3+json" \
78
+ --data '{
79
+ "name": "Ruby-CI Tests",
80
+ "head_sha": "${{ github.event.pull_request.head.sha || github.sha }}",
81
+ "conclusion": "failure"
82
+ }' \
83
+ --fail
84
+ if: failure()
85
+
83
86
  - name: Run tests
84
87
  run: bundle exec rake
88
+
89
+ - name: Upload ts unit test results
90
+ if: ${{ always() }}
91
+ uses: actions/upload-artifact@v2
92
+ with:
93
+ name: ruby-ci-test-results-${{ matrix.looker }}
94
+ path: rspec.xml
95
+
96
+ publish-test-results:
97
+ needs: [test]
98
+ if: success() || failure()
99
+ runs-on: ubuntu-latest
100
+
101
+ steps:
102
+ - name: Download Artifacts
103
+ uses: actions/download-artifact@v2
104
+ with:
105
+ path: artifacts
106
+
107
+ - name: Publish Test Results
108
+ uses: EnricoMi/publish-unit-test-result-action@v1.12
109
+ with:
110
+ # Cosmetic issue with `check_name` being associated to the wrong
111
+ # workflow: https://github.com/EnricoMi/publish-unit-test-result-action/issues/12
112
+ check_name: Ruby-CI Tests
113
+ github_token: ${{ secrets.GITHUB_TOKEN }}
114
+ report_individual_runs: true
115
+ hide_comments: orphaned commits
116
+ check_run_annotations: 'none'
117
+ compare_to_earlier_commit: false
118
+ files: 'artifacts/**/*.xml'
data/.rspec CHANGED
@@ -1,3 +1,5 @@
1
1
  --format documentation
2
2
  --color
3
+ --format RspecJunitFormatter
4
+ --out rspec.xml
3
5
  --require spec_helper
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.5.8
1
+ ruby-2.7.7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ### [0.2.60](https://www.github.com/looker-open-source/gzr/compare/v0.2.59...v0.2.60) (2023-04-11)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * 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))
9
+
10
+ ### [0.2.59](https://www.github.com/looker-open-source/gzr/compare/v0.2.58...v0.2.59) (2023-03-29)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * migrate to API 4.0 ([#154](https://www.github.com/looker-open-source/gzr/issues/154)) ([eecdfd4](https://www.github.com/looker-open-source/gzr/commit/eecdfd41a886f2edbac528a34f83dc7a6ea83f74))
16
+
3
17
  ### [0.2.58](https://www.github.com/looker-open-source/gzr/compare/v0.2.57...v0.2.58) (2023-03-16)
4
18
 
5
19
 
data/Gemfile CHANGED
@@ -21,7 +21,7 @@
21
21
 
22
22
  RUBY_VERSION = File.read(File.join(File.dirname(__FILE__), '.ruby-version')).split('-').last.chomp
23
23
 
24
- ruby '2.5.8', engine: 'ruby', engine_version: '2.5.8'
24
+ ruby '2.7.7', engine: 'ruby', engine_version: '2.7.7'
25
25
 
26
26
  source "https://rubygems.org"
27
27
 
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gazer (0.2.58)
5
- looker-sdk (~> 0.1.1, <= 0.1.2)
4
+ gazer (0.2.60)
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)
@@ -17,7 +18,7 @@ GEM
17
18
  specs:
18
19
  addressable (2.8.1)
19
20
  public_suffix (>= 2.0.2, < 6.0)
20
- connection_pool (2.3.0)
21
+ connection_pool (2.4.0)
21
22
  diff-lcs (1.4.4)
22
23
  faraday (1.10.3)
23
24
  faraday-em_http (~> 1.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.2)
46
- faraday (>= 1.2, < 2.0)
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 (4.0.7)
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)
@@ -66,6 +67,8 @@ GEM
66
67
  diff-lcs (>= 1.2.0, < 2.0)
67
68
  rspec-support (~> 3.10.0)
68
69
  rspec-support (3.10.2)
70
+ rspec_junit_formatter (0.6.0)
71
+ rspec-core (>= 2, < 4, != 2.12.0)
69
72
  ruby2_keywords (0.0.5)
70
73
  rubyzip (1.3.0)
71
74
  sawyer (0.9.2)
@@ -102,9 +105,10 @@ DEPENDENCIES
102
105
  gazer!
103
106
  rake (~> 12.3, >= 12.3.3)
104
107
  rspec (~> 3.0)
108
+ rspec_junit_formatter
105
109
 
106
110
  RUBY VERSION
107
- ruby 2.5.8p224
111
+ ruby 2.7.7p221
108
112
 
109
113
  BUNDLED WITH
110
- 2.3.26
114
+ 2.4.7
data/gzr.gemspec CHANGED
@@ -59,10 +59,12 @@ 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 'looker-sdk', "~> 0.1.1", "<= 0.1.2"
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'
66
67
  spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
67
68
  spec.add_development_dependency "rspec", "~> 3.0"
69
+ spec.add_development_dependency "rspec_junit_formatter"
68
70
  end
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: 'API3 Client Id'
40
- class_option :client_secret, type: :string, desc: 'API3 Client Secret'
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 folder: :space # Alias folder command to space
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/space'
96
- register Gzr::Commands::Space, 'space', 'space [SUBCOMMAND]', 'Commands pertaining to spaces'
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
 
@@ -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.
@@ -291,7 +292,10 @@ module Gzr
291
292
 
292
293
  say_warning "Expecting exactly one body parameter with a schema for operation #{operation}" unless parameters.length == 1
293
294
  schema_ref = parameters[0][:schema][:$ref].split(/\//)
294
- return @sdk.swagger[schema_ref[1].to_sym][schema_ref[2].to_sym][:properties].reject { |k,v| v[:readOnly] }.keys
295
+ key_list = @sdk.swagger[schema_ref[1].to_sym][schema_ref[2].to_sym][:properties].reject { |k,v| v[:readOnly] }.keys
296
+ say_warning "key_list #{operation} -> #{key_list}" if @options[:debug]
297
+ return key_list
298
+
295
299
  end
296
300
 
297
301
  ##
@@ -40,7 +40,7 @@ module Gzr
40
40
 
41
41
  def execute(input: $stdin, output: $stdout)
42
42
  say_warning(@options) if @options[:debug]
43
- with_session("3.1") do
43
+ with_session do
44
44
 
45
45
  group_id = @group if /^\d+$/.match @group
46
46
  group = nil
@@ -41,7 +41,7 @@ module Gzr
41
41
 
42
42
  def execute(input: $stdin, output: $stdout)
43
43
  say_warning(@options) if @options[:debug]
44
- with_session("3.1") do
44
+ with_session do
45
45
 
46
46
  group_id = @group if /^\d+$/.match @group
47
47
  group = nil
@@ -42,7 +42,7 @@ module Gzr
42
42
 
43
43
  def execute(*args, input: $stdin, output: $stdout)
44
44
  say_warning("options: #{@options.inspect}") if @options[:debug]
45
- with_session("3.1") do
45
+ with_session do
46
46
  data = cat_dashboard(@dashboard_id)
47
47
 
48
48
  replacements = {}
@@ -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, dest_space_id, options)
41
+ def initialize(file, dest_folder_id, options)
42
42
  super()
43
43
  @file = file
44
- @dest_space_id = dest_space_id
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("3.1") do
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,@dest_space_id, output: output)
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, target_space_id, output: $stdout)
131
- # try to find dashboard by slug in target space
132
- existing_dashboard = search_dashboards_by_slug(source[:slug], target_space_id).fetch(0,nil) if source[:slug]
133
- # check for dash of same title in target space
134
- title_used = search_dashboards_by_title(source[:title], target_space_id).select {|d| !d[:deleted] }.fetch(0,nil)
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 space with
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 space #{slug_used.space_id}", output: output
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 space #{target_space_id}\nDelete it before trying to upate another dashboard to have that title."
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 space #{target_space_id}\nUse --force if you want to overwrite it" unless @options[:force]
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 space #{target_space_id}", output: output
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[:space_id] = target_space_id
194
+ new_dash[:folder_id] = target_folder_id
192
195
  new_dash[:user_id] = @me.id
193
- return create_dashboard(new_dash)
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, @dest_space_id, dash_elem[:look]).id, nil] if dash_elem[:look]
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, target_space_id, options)
33
+ def initialize(dashboard_id, target_folder_id, options)
34
34
  super()
35
35
  @dashboard_id = dashboard_id
36
- @target_space_id = target_space_id
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],@target_space_id)
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 space #{@target_space_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 space #{@target_space_id}", output: output
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],{:space_id=>@target_space_id})
58
- output.puts "Moved dashboard #{dash[:id]} to space #{@target_space_id}" unless @options[:plain]
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