gazer 0.2.46 → 0.2.53

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1111e80913b3cdb2b0649e59b963a0d656f19b84e6ccb523f20609f70d9dd068
4
- data.tar.gz: 4733f9a2ac19d708b91e5729e3b7a588344f63a8726dfb776444ac3ec297d9ad
3
+ metadata.gz: b5f44f5af050d76e652c008b4cd8210240522688232a8f747601ad8dd59032b7
4
+ data.tar.gz: 3f0a76d313a7c640a85f77212af8639f44d39b392604509185847a6e4a3899d7
5
5
  SHA512:
6
- metadata.gz: b296ce9ecb25983851508cda708c8ad2ded39834a63d2d4f1c00ce924311268fb6ce990ee9c4c2fd37d715dbe208472ceb1866539d456a585a09720305d584c2
7
- data.tar.gz: cb29a1df8bf6e02bc061c99ba33cb1746805b66d46edc777589c2112a5d7db837b953033c53a5547605216063aa3b0119a23f644b2f4e38ce1fc66452ffb48af
6
+ metadata.gz: 6e49f6a5f997b55e16e090ab10dd372e0c3ff620d82a13a24379ca8fcb411486cc93e5272883c7f545e0fe544813cd02194f603f405da0b69fac92064b94560e
7
+ data.tar.gz: a0fa72d8e16b6c4d318814d96aade1434b924b73c6caebfa01f046190fe0fc93ed68f37737d07f2308367c1514d65b352ed0ccb8e92c7b986e1ff43654e9a6f9
@@ -0,0 +1,35 @@
1
+ #!/bin/sh
2
+
3
+ check_looker() {
4
+ status=$(curl --silent --insecure --write "%{http_code}" \
5
+ --data "client_id=$LOOKERSDK_CLIENT_ID&client_secret=$LOOKERSDK_CLIENT_SECRET"\
6
+ $LOOKERSDK_BASE_URL/api/${LOOKERSDK_API_VERSION:-4.0}/login\
7
+ -o /dev/null)
8
+ }
9
+
10
+ MAX_RETRIES=160
11
+ ATTEMPTS=1
12
+ status=0
13
+ check_looker
14
+ while [ $status -ne 200 ];
15
+ do
16
+ RETRY_MSG="after $ATTEMPTS attempts: $MAX_RETRIES retries remaining."
17
+ if [ $ATTEMPTS -ge $MAX_RETRIES ];
18
+ then
19
+ echo 'Looker took too long to start'
20
+ exit 1
21
+ else
22
+ if [ $status -ne 0 ];
23
+ then
24
+ echo "Received status($status) from Looker $RETRY_MSG"
25
+ else
26
+ echo "Looker server connection rejected $RETRY_MSG"
27
+ fi
28
+ fi
29
+
30
+ sleep 2
31
+ ATTEMPTS=$(( $ATTEMPTS + 1 ))
32
+ check_looker
33
+ done
34
+ echo "Looker ready after $ATTEMPTS attempts"
35
+ exit 0
@@ -0,0 +1,47 @@
1
+ # .github/workflows/release.yml
2
+
3
+ name: release
4
+
5
+ on:
6
+ push:
7
+ branches:
8
+ - main
9
+
10
+ jobs:
11
+ release-please:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: GoogleCloudPlatform/release-please-action@v2
15
+ id: release
16
+ with:
17
+ release-type: ruby
18
+ package-name: gazer
19
+ bump-minor-pre-major: true
20
+ bump-patch-for-minor-pre-major: true
21
+ version-file: "lib/gzr/version.rb"
22
+ 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
+ # Setup ruby if a release was created
27
+ - uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: 2.5.8
30
+ if: ${{ steps.release.outputs.release_created }}
31
+ # Bundle install
32
+ - run: bundle install
33
+ if: ${{ steps.release.outputs.release_created }}
34
+ # Publish
35
+ - name: publish gem
36
+ run: |
37
+ mkdir -p $HOME/.gem
38
+ touch $HOME/.gem/credentials
39
+ chmod 0600 $HOME/.gem/credentials
40
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
41
+ gem build *.gemspec
42
+ gem push *.gem
43
+ env:
44
+ # Make sure to update the secret name
45
+ # if yours isn't named RUBYGEMS_AUTH_TOKEN
46
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
47
+ if: ${{ steps.release.outputs.release_created }}
@@ -0,0 +1,60 @@
1
+ name: Ruby-CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ env:
10
+ LOOKERSDK_BASE_URL: https://localhost:20000
11
+ LOOKERSDK_VERIFY_SSL: false
12
+ TS_JUNIT_OUTPUT_DIR: results/sdk-codegen
13
+ LOOKERSDK_CLIENT_ID: ${{ secrets.LOOKERSDK_CLIENT_ID__21_18 }}
14
+ LOOKERSDK_CLIENT_SECRET: ${{ secrets.LOOKERSDK_CLIENT_SECRET__21_18 }}
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: [2.5.8]
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+
27
+ - name: Set up Cloud SDK
28
+ uses: google-github-actions/setup-gcloud@v0.2.0
29
+ with:
30
+ project_id: ${{ secrets.GCP_PROJECT_ID }}
31
+ service_account_key: ${{ secrets.GCP_AR_READER_SA_KEY }}
32
+ export_default_credentials: true
33
+
34
+ - name: Authenticate Artifact Repository
35
+ run: gcloud auth configure-docker us-west1-docker.pkg.dev --quiet
36
+
37
+ - name: Pull and run Looker docker image
38
+ # TODO: can we cache some layers of the image for faster download?
39
+ # we probably don't want to cache the final image for IP security...
40
+ run: |
41
+ docker pull --quiet us-west1-docker.pkg.dev/cloud-looker-sdk-codegen-cicd/looker/21_18
42
+ # set $LOOKER_OPTS to --no-ssl if we want to turn off ssl
43
+ 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/21_20
44
+ docker logs -f looker-sdk-codegen-ci --until=30s &
45
+
46
+ - name: Set up Ruby ${{ matrix.ruby-version }}
47
+ uses: ruby/setup-ruby@v1
48
+ with:
49
+ ruby-version: ${{ matrix.ruby-version }}
50
+ bundler-cache: true
51
+
52
+ - name: Install dependencies
53
+ run: bundle install
54
+
55
+ - name: Check that Looker is ready
56
+ run: |
57
+ ${{ github.workspace }}/.github/scripts/wait_for_looker.sh
58
+
59
+ - name: Run tests
60
+ run: bundle exec rake
data/CHANGELOG.md ADDED
@@ -0,0 +1,46 @@
1
+ # Changelog
2
+
3
+ ### [0.2.53](https://www.github.com/looker-open-source/gzr/compare/v0.2.52...v0.2.53) (2021-12-14)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * fix version ([#121](https://www.github.com/looker-open-source/gzr/issues/121)) ([f9b0b22](https://www.github.com/looker-open-source/gzr/commit/f9b0b2237eb3c520aabc2f1ff5a63ddf6c934ce4))
9
+
10
+ ### [0.2.52](https://www.github.com/looker-open-source/gzr/compare/v0.2.51...v0.2.52) (2021-12-14)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * version number ([#119](https://www.github.com/looker-open-source/gzr/issues/119)) ([b55a892](https://www.github.com/looker-open-source/gzr/commit/b55a892d8d040ce4547924d613a590877e129322))
16
+
17
+ ### [0.2.51](https://www.github.com/looker-open-source/gzr/compare/v0.2.50...v0.2.51) (2021-12-14)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * detect if dashboard import gets a look file and vice versa, warn on importing a deleted dashboard or look ([#116](https://www.github.com/looker-open-source/gzr/issues/116)) ([a12dc25](https://www.github.com/looker-open-source/gzr/commit/a12dc2525bed55816b368306f2d05a24dc07aaf4))
23
+ * Gemfile.lock was out of date ([a4e49c3](https://www.github.com/looker-open-source/gzr/commit/a4e49c3972772e0629a8f1589172ddd136ee7e21))
24
+ * refactored look and dashboard cat commands and space export to use the same code to generate each look and dashboard file. ([#114](https://www.github.com/looker-open-source/gzr/issues/114)) ([8dadd50](https://www.github.com/looker-open-source/gzr/commit/8dadd500376e2b971c38dbcd69f507268a3e6b9e))
25
+ * remove Thor deprecation warning ([#115](https://www.github.com/looker-open-source/gzr/issues/115)) ([1100c5a](https://www.github.com/looker-open-source/gzr/commit/1100c5a24b0626c01c6248d87172c7ab624bf42f))
26
+
27
+ ### [0.2.50](https://www.github.com/looker-open-source/gzr/compare/v0.2.49...v0.2.50) (2021-11-19)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * resolved warnings in gemspec. Improved handling of live tests ([6291147](https://www.github.com/looker-open-source/gzr/commit/6291147a09f55ed095d718a7a998d5af09b716e3))
33
+
34
+ ### [0.2.49](https://www.github.com/looker-open-source/gzr/compare/v0.2.48...v0.2.49) (2021-11-18)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * Bump version ([652486c](https://www.github.com/looker-open-source/gzr/commit/652486ce6571d4fea2d3ea847c5927395aa4373e))
40
+
41
+ ### [0.2.48](https://www.github.com/looker-open-source/gzr/compare/v0.2.47...v0.2.48) (2021-11-18)
42
+
43
+
44
+ ### Bug Fixes
45
+
46
+ * Add release please workflow to automate releases ([6279bc6](https://www.github.com/looker-open-source/gzr/commit/6279bc68fcfd8f09f7385053767e6a9571570333))
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: RUBY_VERSION
24
+ ruby '2.5.8', engine: 'ruby', engine_version: '2.5.8'
25
25
 
26
26
  source "https://rubygems.org"
27
27
 
@@ -29,7 +29,4 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
29
29
 
30
30
  # Specify your gem's dependencies in gzr.gemspec
31
31
  gemspec
32
- #gem 'looker-sdk', :git => 'git@github.com:looker/looker-sdk-ruby.git'
33
- #gem 'tty', :git => 'git@github.com:piotrmurach/tty.git'
34
- #gem 'tty-file', :git => 'git@github.com:piotrmurach/tty-file.git'
35
32
 
data/Gemfile.lock CHANGED
@@ -1,16 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gazer (0.2.46)
4
+ gazer (0.2.53)
5
5
  looker-sdk (~> 0.1.1)
6
- net-http-persistent (~> 4.0.1)
6
+ net-http-persistent (~> 4.0, >= 4.0.1)
7
7
  netrc (~> 0.11.0)
8
- pastel (~> 0.7.2)
9
- rubyzip (~> 1.3.0)
10
- thor (~> 0.20.0)
11
- tty-reader (~> 0.3.0)
12
- tty-table (~> 0.10.0)
13
- tty-tree (~> 0.1.0)
8
+ pastel (~> 0.8.0)
9
+ rubyzip (~> 1.3, >= 1.3.0)
10
+ thor (~> 1.1, >= 1.1.0)
11
+ tty-reader (~> 0.9.0)
12
+ tty-table (~> 0.12.0)
13
+ tty-tree (~> 0.4.0)
14
14
 
15
15
  GEM
16
16
  remote: https://rubygems.org/
@@ -18,8 +18,7 @@ GEM
18
18
  addressable (2.8.0)
19
19
  public_suffix (>= 2.0.2, < 5.0)
20
20
  connection_pool (2.2.5)
21
- diff-lcs (1.3)
22
- equatable (0.5.0)
21
+ diff-lcs (1.4.4)
23
22
  faraday (1.8.0)
24
23
  faraday-em_http (~> 1.0)
25
24
  faraday-em_synchrony (~> 1.0)
@@ -39,21 +38,17 @@ GEM
39
38
  faraday-net_http_persistent (1.2.0)
40
39
  faraday-patron (1.0.0)
41
40
  faraday-rack (1.0.0)
42
- kramdown (1.16.2)
43
- looker-sdk (0.1.1)
41
+ looker-sdk (0.1.2)
44
42
  faraday (>= 1.2, < 2.0)
45
43
  sawyer (~> 0.8)
46
44
  multipart-post (2.1.1)
47
- necromancer (0.4.0)
48
45
  net-http-persistent (4.0.1)
49
46
  connection_pool (~> 2.2)
50
47
  netrc (0.11.0)
51
- pastel (0.7.2)
52
- equatable (~> 0.5.0)
53
- tty-color (~> 0.4.0)
48
+ pastel (0.8.0)
49
+ tty-color (~> 0.5)
54
50
  public_suffix (4.0.6)
55
51
  rake (12.3.3)
56
- rouge (3.1.1)
57
52
  rspec (3.10.0)
58
53
  rspec-core (~> 3.10.0)
59
54
  rspec-expectations (~> 3.10.0)
@@ -72,101 +67,39 @@ GEM
72
67
  sawyer (0.8.2)
73
68
  addressable (>= 2.3.5)
74
69
  faraday (> 0.8, < 2.0)
75
- strings (0.1.8)
76
- strings-ansi (~> 0.1)
77
- unicode-display_width (~> 1.5)
70
+ strings (0.2.1)
71
+ strings-ansi (~> 0.2)
72
+ unicode-display_width (>= 1.5, < 3.0)
78
73
  unicode_utils (~> 1.4)
79
74
  strings-ansi (0.2.0)
80
- thor (0.20.3)
81
- timers (4.3.3)
82
- tty (0.8.1)
83
- bundler (~> 1.16, < 2.0)
84
- equatable (~> 0.5.0)
85
- pastel (~> 0.7.2)
86
- thor (~> 0.20.0)
87
- tty-color (~> 0.4.2)
88
- tty-command (~> 0.8.0)
89
- tty-config (~> 0.2.0)
90
- tty-cursor (~> 0.5.0)
91
- tty-editor (~> 0.4.0)
92
- tty-file (~> 0.6.0)
93
- tty-font (~> 0.2.0)
94
- tty-markdown (~> 0.4.0)
95
- tty-pager (~> 0.11.0)
96
- tty-platform (~> 0.1.0)
97
- tty-progressbar (~> 0.15.0)
98
- tty-prompt (~> 0.16.1)
99
- tty-screen (~> 0.6.4)
100
- tty-spinner (~> 0.8.0)
101
- tty-table (~> 0.10.0)
102
- tty-tree (~> 0.1.0)
103
- tty-which (~> 0.3.0)
104
- tty-color (0.4.3)
105
- tty-command (0.8.2)
106
- pastel (~> 0.7.0)
107
- tty-config (0.2.0)
108
- tty-cursor (0.5.0)
109
- tty-editor (0.4.0)
110
- tty-prompt (~> 0.16.0)
111
- tty-which (~> 0.3.0)
112
- tty-file (0.6.0)
113
- diff-lcs (~> 1.3.0)
114
- pastel (~> 0.7.2)
115
- tty-prompt (~> 0.16.1)
116
- tty-font (0.2.0)
117
- tty-markdown (0.4.0)
118
- kramdown (~> 1.16.2)
119
- pastel (~> 0.7.2)
120
- rouge (~> 3.1.0)
121
- strings (~> 0.1.0)
122
- tty-color (~> 0.4.2)
123
- tty-screen (~> 0.6.4)
124
- tty-pager (0.11.0)
125
- strings (~> 0.1.0)
126
- tty-screen (~> 0.6.4)
127
- tty-which (~> 0.3.0)
128
- tty-platform (0.1.0)
129
- tty-progressbar (0.15.1)
130
- tty-cursor (~> 0.5.0)
131
- tty-screen (~> 0.6.4)
132
- unicode-display_width (~> 1.3)
133
- tty-prompt (0.16.1)
134
- necromancer (~> 0.4.0)
135
- pastel (~> 0.7.0)
136
- timers (~> 4.0)
137
- tty-cursor (~> 0.5.0)
138
- tty-reader (~> 0.3.0)
139
- tty-reader (0.3.0)
140
- tty-cursor (~> 0.5.0)
141
- tty-screen (~> 0.6.4)
142
- wisper (~> 2.0.0)
143
- tty-screen (0.6.5)
144
- tty-spinner (0.8.0)
145
- tty-cursor (>= 0.5.0)
146
- tty-table (0.10.0)
147
- equatable (~> 0.5.0)
148
- necromancer (~> 0.4.0)
149
- pastel (~> 0.7.2)
150
- strings (~> 0.1.0)
151
- tty-screen (~> 0.6.4)
152
- tty-tree (0.1.0)
153
- tty-which (0.3.0)
154
- unicode-display_width (1.8.0)
75
+ thor (1.1.0)
76
+ tty-color (0.6.0)
77
+ tty-cursor (0.7.1)
78
+ tty-reader (0.9.0)
79
+ tty-cursor (~> 0.7)
80
+ tty-screen (~> 0.8)
81
+ wisper (~> 2.0)
82
+ tty-screen (0.8.1)
83
+ tty-table (0.12.0)
84
+ pastel (~> 0.8)
85
+ strings (~> 0.2.0)
86
+ tty-screen (~> 0.8)
87
+ tty-tree (0.4.0)
88
+ unicode-display_width (2.1.0)
155
89
  unicode_utils (1.4.0)
156
90
  wisper (2.0.1)
157
91
 
158
92
  PLATFORMS
159
- ruby
93
+ x86_64-linux
160
94
 
161
95
  DEPENDENCIES
162
- bundler (~> 1.17)
96
+ bundler (~> 2.2, >= 2.2.10)
163
97
  gazer!
164
- rake (~> 12.3.3)
98
+ rake (~> 12.3, >= 12.3.3)
165
99
  rspec (~> 3.0)
166
- tty (~> 0.8)
167
100
 
168
101
  RUBY VERSION
169
102
  ruby 2.5.8p224
170
103
 
171
104
  BUNDLED WITH
172
- 1.17.3
105
+ 2.2.30
data/README.md CHANGED
@@ -5,8 +5,7 @@ and Dashboards via a simple command line tool.
5
5
 
6
6
  ## Status and Support
7
7
 
8
- Gazer is **NOT** supported or warranteed by Looker in any way. Please do not contact Looker support
9
- for issues with Gazer. Issues can be logged via https://github.com/looker-open-source/gzr/issues
8
+ 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.
10
9
 
11
10
  ## Installation
12
11
 
data/gzr.gemspec CHANGED
@@ -28,10 +28,10 @@ Gem::Specification.new do |spec|
28
28
  spec.license = "MIT"
29
29
  spec.version = Gzr::VERSION
30
30
  spec.authors = ["Mike DeAngelo"]
31
- spec.email = ["deangelo@looker.com"]
31
+ spec.email = ["drstrangelove@google.com"]
32
32
 
33
33
  spec.summary = %q{Command line tool to manage the content of a Looker instance.}
34
- spec.description = %q{Command line tool to manage the content of a Looker instance.}
34
+ spec.description = %q{This tool will help manage the content of a Looker instance.}
35
35
  spec.homepage = "https://github.com/looker-open-source/gzr"
36
36
 
37
37
  spec.required_ruby_version = '>= 2.3.0'
@@ -52,18 +52,17 @@ Gem::Specification.new do |spec|
52
52
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
53
53
  spec.require_paths = ["lib"]
54
54
 
55
- spec.add_dependency "tty-reader", "~> 0.3.0"
56
- spec.add_dependency "tty-table", "~> 0.10.0"
57
- spec.add_dependency "tty-tree", "~> 0.1.0"
58
- spec.add_dependency "pastel", "~> 0.7.2"
59
- spec.add_dependency "thor", "~> 0.20.0"
55
+ spec.add_dependency "tty-reader", "~> 0.9.0"
56
+ spec.add_dependency "tty-table", "~> 0.12.0"
57
+ spec.add_dependency "tty-tree", "~> 0.4.0"
58
+ spec.add_dependency "pastel", "~> 0.8.0"
59
+ spec.add_runtime_dependency 'thor', '~> 1.1', '>= 1.1.0'
60
60
  spec.add_dependency 'netrc', "~> 0.11.0"
61
- spec.add_dependency 'rubyzip', "~> 1.3.0"
61
+ spec.add_runtime_dependency 'rubyzip', '~> 1.3', '>= 1.3.0'
62
62
  spec.add_dependency 'looker-sdk', "~> 0.1.1"
63
- spec.add_dependency 'net-http-persistent', '~> 4.0.1'
63
+ spec.add_runtime_dependency 'net-http-persistent', '~> 4.0', '>= 4.0.1'
64
64
 
65
- spec.add_development_dependency "bundler", "~> 1.17"
66
- spec.add_development_dependency "rake", "~> 12.3.3"
65
+ spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.10'
66
+ spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
67
67
  spec.add_development_dependency "rspec", "~> 3.0"
68
- spec.add_development_dependency "tty", "~> 0.8"
69
68
  end
data/lib/gzr/cli.rb CHANGED
@@ -29,6 +29,10 @@ module Gzr
29
29
  #
30
30
  # @api public
31
31
  class CLI < Thor
32
+ def self.exit_on_failure?
33
+ true
34
+ end
35
+
32
36
  class_option :debug, type: :boolean, default: false, desc: 'Run in debug mode'
33
37
  class_option :host, type: :string, default: 'localhost', desc: 'Looker Host'
34
38
  class_option :port, type: :string, default: '19999', desc: 'Looker API Port'
@@ -44,7 +48,6 @@ module Gzr
44
48
  class_option :width, type: :numeric, default: nil, desc: 'Width of rendering for tables'
45
49
  class_option :persistent, type: :boolean, default: false, desc: 'Use persistent connection to communicate with host'
46
50
 
47
-
48
51
  # Error raised by this runner
49
52
  Error = Class.new(StandardError)
50
53
 
data/lib/gzr/command.rb CHANGED
@@ -281,7 +281,7 @@ module Gzr
281
281
  # end
282
282
 
283
283
  def keys_to_keep(operation)
284
- o = @sdk.operations[operation]
284
+ o = @sdk.operations[operation] || @sdk.operations[operation.to_sym]
285
285
  begin
286
286
  say_error "Operation #{operation} not found"
287
287
  return []
@@ -43,29 +43,7 @@ module Gzr
43
43
  def execute(*args, input: $stdin, output: $stdout)
44
44
  say_warning("options: #{@options.inspect}") if @options[:debug]
45
45
  with_session("3.1") do
46
- data = query_dashboard(@dashboard_id).to_attrs
47
- data[:dashboard_elements].each_index do |i|
48
- element = data[:dashboard_elements][i]
49
- find_vis_config_reference(element) do |vis_config|
50
- find_color_palette_reference(vis_config) do |o,default_colors|
51
- rewrite_color_palette!(o,default_colors)
52
- end
53
- end
54
- merge_result = merge_query(element[:merge_result_id])&.to_attrs if element[:merge_result_id]
55
- if merge_result
56
- merge_result[:source_queries].each_index do |j|
57
- source_query = merge_result[:source_queries][j]
58
- merge_result[:source_queries][j][:query] = query(source_query[:query_id]).to_attrs
59
- end
60
- find_vis_config_reference(merge_result) do |vis_config|
61
- find_color_palette_reference(vis_config) do |o,default_colors|
62
- rewrite_color_palette!(o,default_colors)
63
- end
64
- end
65
- data[:dashboard_elements][i][:merge_result] = merge_result
66
- end
67
- end
68
- data[:scheduled_plans] = query_scheduled_plans_for_dashboard(@dashboard_id,"all").to_attrs if @options[:plans]
46
+ data = cat_dashboard(@dashboard_id)
69
47
 
70
48
  replacements = {}
71
49
  if @options[:transform]
@@ -117,7 +95,12 @@ module Gzr
117
95
  outputJSON.gsub! k,v
118
96
  end
119
97
 
120
- write_file(@options[:dir] ? "Dashboard_#{data[:id]}_#{data[:title]}.json" : nil, @options[:dir], nil, output) do |f|
98
+ file_name = if @options[:dir]
99
+ @options[:simple_filename] ? "Dashboard_#{data[:id]}.json" : "Dashboard_#{data[:id]}_#{data[:title]}.json"
100
+ else
101
+ nil
102
+ end
103
+ write_file(file_name, @options[:dir], nil, output) do |f|
121
104
  f.puts outputJSON
122
105
  end
123
106
  end
@@ -53,8 +53,17 @@ module Gzr
53
53
 
54
54
  read_file(@file) do |data|
55
55
 
56
- dashboard = sync_dashboard(data,@dest_space_id, output: output)
56
+ if data[:deleted]
57
+ say_warning("Attempt to import a deleted dashboard!")
58
+ say_warning("This may result in errors.")
59
+ end
57
60
 
61
+ if !data[:dashboard_elements]
62
+ say_error("File contains no dashboard_elements! Is this a look?")
63
+ raise Gzr::CLI::Error, "import file is not a valid dashboard"
64
+ end
65
+
66
+ dashboard = sync_dashboard(data,@dest_space_id, output: output)
58
67
 
59
68
  dashboard[:dashboard_filters] ||= []
60
69
  source_filters = data[:dashboard_filters].sort { |a,b| a[:row] <=> b[:row] }
@@ -52,6 +52,8 @@ module Gzr
52
52
  desc: 'Include scheduled plans'
53
53
  method_option :transform, type: :string,
54
54
  desc: 'Fully-qualified path to a JSON file describing the transformations to apply'
55
+ method_option :simple_filename, type: :boolean,
56
+ desc: 'Use simple filename for output (Dashboard_<id>.json)'
55
57
  def cat(dashboard_id)
56
58
  if options[:help]
57
59
  invoke :help, ['cat']
@@ -42,15 +42,13 @@ module Gzr
42
42
  def execute(input: $stdin, output: $stdout)
43
43
  say_warning("options: #{@options.inspect}") if @options[:debug]
44
44
  with_session do
45
- data = query_look(@look_id).to_attrs
46
- find_vis_config_reference(data) do |vis_config|
47
- find_color_palette_reference(vis_config) do |o,default_colors|
48
- rewrite_color_palette!(o,default_colors)
49
- end
50
- end
51
-
52
- data[:scheduled_plans] = query_scheduled_plans_for_look(@look_id,"all").to_attrs if @options[:plans]
53
- write_file(@options[:dir] ? "Look_#{data[:id]}_#{data[:title]}.json" : nil, @options[:dir],nil, output) do |f|
45
+ data = cat_look(@look_id)
46
+ file_name = if @options[:dir]
47
+ @options[:simple_filename] ? "Look_#{data[:id]}.json" : "Look_#{data[:id]}_#{data[:title]}.json"
48
+ else
49
+ nil
50
+ end
51
+ write_file(file_name, @options[:dir],nil, output) do |f|
54
52
  f.puts JSON.pretty_generate(data)
55
53
  end
56
54
  end
@@ -49,6 +49,17 @@ module Gzr
49
49
  @me ||= query_me("id")
50
50
 
51
51
  read_file(@file) do |data|
52
+
53
+ if data[:deleted]
54
+ say_warning("Attempt to import a deleted look!")
55
+ say_warning("This may result in errors.")
56
+ end
57
+
58
+ if data[:dashboard_elements]
59
+ say_error("File contains dashboard_elements! Is this a dashboard?")
60
+ raise Gzr::CLI::Error, "import file is not a valid look"
61
+ end
62
+
52
63
  look = upsert_look(@me.id,create_fetch_query(data[:query]).id,@dest_space_id,data,output: output)
53
64
  upsert_plans_for_look(look.id,@me.id,data[:scheduled_plans]) if data[:scheduled_plans]
54
65
  output.puts "Imported look #{look.id}" unless @options[:plain]
@@ -82,6 +82,8 @@ module Gzr
82
82
  desc: 'Directory to store output file'
83
83
  method_option :plans, type: :boolean,
84
84
  desc: 'Include scheduled plans'
85
+ method_option :simple_filename, type: :boolean,
86
+ desc: 'Use simple filename for output (Look_<id>.json)'
85
87
  def cat(look_id)
86
88
  if options[:help]
87
89
  invoke :help, ['cat']
@@ -38,7 +38,7 @@ module Gzr
38
38
  def execute(input: $stdin, output: $stdout)
39
39
  say_warning("options: #{@options.inspect}") if @options[:debug]
40
40
  with_session do
41
- delete_role(@plan_id)
41
+ delete_role(@role_id)
42
42
  end
43
43
  end
44
44
  end
@@ -25,6 +25,7 @@ require_relative '../../command'
25
25
  require_relative '../../modules/space'
26
26
  require_relative '../../modules/look'
27
27
  require_relative '../../modules/dashboard'
28
+ require_relative '../../modules/plan'
28
29
  require_relative '../../modules/filehelper'
29
30
  require 'pathname'
30
31
  require 'stringio'
@@ -37,6 +38,7 @@ module Gzr
37
38
  include Gzr::Space
38
39
  include Gzr::Look
39
40
  include Gzr::Dashboard
41
+ include Gzr::Plan
40
42
  include Gzr::FileHelper
41
43
  def initialize(space_id, options)
42
44
  super()
@@ -96,39 +98,13 @@ module Gzr
96
98
  end)
97
99
  end
98
100
  space[:looks].each do |l|
99
- look = query_look(l[:id]).to_attrs
100
- find_vis_config_reference(look) do |vis_config|
101
- find_color_palette_reference(vis_config) do |o,default_colors|
102
- rewrite_color_palette!(o,default_colors)
103
- end
104
- end
101
+ look = cat_look(l[:id])
105
102
  write_file("Look_#{look[:id]}_#{look[:title]}.json", base, path) do |f|
106
103
  f.write JSON.pretty_generate(look)
107
104
  end
108
105
  end
109
106
  space[:dashboards].each do |d|
110
- data = query_dashboard(d[:id]).to_attrs()
111
- data[:dashboard_elements].each_index do |i|
112
- element = data[:dashboard_elements][i]
113
- find_vis_config_reference(element) do |vis_config|
114
- find_color_palette_reference(vis_config) do |o,default_colors|
115
- rewrite_color_palette!(o,default_colors)
116
- end
117
- end
118
- merge_result = merge_query(element[:merge_result_id])&.to_attrs() if element[:merge_result_id]
119
- if merge_result
120
- merge_result[:source_queries].each_index do |j|
121
- source_query = merge_result[:source_queries][j]
122
- merge_result[:source_queries][j][:query] = query(source_query[:query_id]).to_attrs()
123
- end
124
- find_vis_config_reference(merge_result) do |vis_config|
125
- find_color_palette_reference(vis_config) do |o,default_colors|
126
- rewrite_color_palette!(o,default_colors)
127
- end
128
- end
129
- data[:dashboard_elements][i][:merge_result] = merge_result
130
- end
131
- end
107
+ data = cat_dashboard(d[:id])
132
108
  write_file("Dashboard_#{data[:id]}_#{data[:title]}.json", base, path) do |f|
133
109
  f.write JSON.pretty_generate(data)
134
110
  end
@@ -64,6 +64,8 @@ module Gzr
64
64
  desc 'export SPACE_ID', 'Export a space, including all child looks, dashboards, and spaces.'
65
65
  method_option :help, aliases: '-h', type: :boolean,
66
66
  desc: 'Display usage information'
67
+ method_option :plans, type: :boolean,
68
+ desc: 'Include scheduled plans'
67
69
  method_option :dir, type: :string, default: '.',
68
70
  desc: 'Directory to store output tree'
69
71
  method_option :tar, type: :string,
@@ -226,5 +226,32 @@ module Gzr
226
226
  end
227
227
  data
228
228
  end
229
+
230
+ def cat_dashboard(dashboard_id)
231
+ data = query_dashboard(dashboard_id).to_attrs
232
+ data[:dashboard_elements].each_index do |i|
233
+ element = data[:dashboard_elements][i]
234
+ find_vis_config_reference(element) do |vis_config|
235
+ find_color_palette_reference(vis_config) do |o,default_colors|
236
+ rewrite_color_palette!(o,default_colors)
237
+ end
238
+ end
239
+ merge_result = merge_query(element[:merge_result_id])&.to_attrs if element[:merge_result_id]
240
+ if merge_result
241
+ merge_result[:source_queries].each_index do |j|
242
+ source_query = merge_result[:source_queries][j]
243
+ merge_result[:source_queries][j][:query] = query(source_query[:query_id]).to_attrs
244
+ end
245
+ find_vis_config_reference(merge_result) do |vis_config|
246
+ find_color_palette_reference(vis_config) do |o,default_colors|
247
+ rewrite_color_palette!(o,default_colors)
248
+ end
249
+ end
250
+ data[:dashboard_elements][i][:merge_result] = merge_result
251
+ end
252
+ end
253
+ data[:scheduled_plans] = query_scheduled_plans_for_dashboard(@dashboard_id,"all")&.to_attrs if @options[:plans]
254
+ data
255
+ end
229
256
  end
230
257
  end
@@ -188,5 +188,17 @@ module Gzr
188
188
  end
189
189
  return create_merge_query(new_merge_result)
190
190
  end
191
+
192
+ def cat_look(look_id)
193
+ data = query_look(look_id).to_attrs
194
+ find_vis_config_reference(data) do |vis_config|
195
+ find_color_palette_reference(vis_config) do |o,default_colors|
196
+ rewrite_color_palette!(o,default_colors)
197
+ end
198
+ end
199
+
200
+ data[:scheduled_plans] = query_scheduled_plans_for_look(@look_id,"all")&.to_attrs if @options[:plans]
201
+ data
202
+ end
191
203
  end
192
204
  end
@@ -49,6 +49,9 @@ module Gzr
49
49
  data = nil
50
50
  begin
51
51
  data = @sdk.scheduled_plans_for_look(look_id,req)
52
+ return nil if data.respond_to?(:message) && data.message == 'Not found'
53
+ rescue LookerSDK::NotFound
54
+ return nil
52
55
  rescue LookerSDK::ClientError => e
53
56
  say_error "Unable to get scheduled_plans_for_look(#{look_id},#{JSON.pretty_generate(req)})"
54
57
  say_error e.message
@@ -65,6 +68,9 @@ module Gzr
65
68
  data = nil
66
69
  begin
67
70
  data = @sdk.scheduled_plans_for_dashboard(dashboard_id,req)
71
+ return nil if data.respond_to?(:message) && data.message == 'Not found'
72
+ rescue LookerSDK::NotFound
73
+ return nil
68
74
  rescue LookerSDK::ClientError => e
69
75
  say_error "Unable to get scheduled_plans_for_dashboard(#{dashboard_id},#{JSON.pretty_generate(req)})"
70
76
  say_error e.message
@@ -74,7 +74,8 @@ module Gzr
74
74
  }
75
75
  else
76
76
  conn_hash[:connection_options][:ssl] = {
77
- :verify => false
77
+ :verify => false,
78
+ :verify_mode => (OpenSSL::SSL::VERIFY_NONE)
78
79
  }
79
80
  end
80
81
  end
@@ -101,15 +102,33 @@ module Gzr
101
102
  conn_hash
102
103
  end
103
104
 
104
- def faraday_connection
105
- @faraday_connection ||= Faraday.new { |conn|
106
- if @options[:persistent]
107
- conn.adapter :net_http_persistent
108
- end
109
- }
110
- end
111
-
112
105
  def login(min_api_version=nil)
106
+ if (@options[:client_id].nil? && ENV["LOOKERSDK_CLIENT_ID"])
107
+ @options[:client_id] = ENV["LOOKERSDK_CLIENT_ID"]
108
+ end
109
+
110
+ if (@options[:client_secret].nil? && ENV["LOOKERSDK_CLIENT_SECRET"])
111
+ @options[:client_secret] = ENV["LOOKERSDK_CLIENT_SECRET"]
112
+ end
113
+
114
+ if (@options[:api_version].nil? && ENV["LOOKERSDK_API_VERSION"])
115
+ @options[:api_version] = ENV["LOOKERSDK_API_VERSION"]
116
+ end
117
+
118
+ if (@options[:verify_ssl] && ENV["LOOKERSDK_VERIFY_SSL"])
119
+ @options[:verify_ssl] = !(/^f(alse)?$/i =~ ENV["LOOKERSDK_VERIFY_SSL"])
120
+ end
121
+
122
+ if ((@options[:host] == 'localhost') && ENV["LOOKERSDK_BASE_URL"])
123
+ base_url = ENV["LOOKERSDK_BASE_URL"]
124
+ @options[:ssl] = !!(/^https/ =~ base_url)
125
+ @options[:host] = /^https?:\/\/([^:\/]+)/.match(base_url)[1]
126
+ md = /:([0-9]+)\/?$/.match(base_url)
127
+ @options[:port] = md[1] if md
128
+ end
129
+
130
+ say_ok("using options #{@options.select { |k,v| k != 'client_secret' }.map { |k,v| "#{k}=>#{v}" }}") if @options[:debug]
131
+
113
132
  @secret = nil
114
133
  begin
115
134
  conn_hash = build_connection_hash
@@ -117,7 +136,11 @@ module Gzr
117
136
  sawyer_options = {
118
137
  :links_parser => Sawyer::LinkParsers::Simple.new,
119
138
  :serializer => LookerSDK::Client::Serializer.new(JSON),
120
- :faraday => Faraday.new(conn_hash[:connection_options])
139
+ :faraday => Faraday.new(conn_hash[:connection_options]) do |conn|
140
+ if @options[:persistent]
141
+ conn.adapter :net_http_persistent
142
+ end
143
+ end
121
144
  }
122
145
 
123
146
  endpoint = conn_hash[:api_endpoint]
@@ -157,7 +180,12 @@ module Gzr
157
180
  say_ok("connecting to #{conn_hash.map { |k,v| "#{k}=>#{(k == :client_secret) ? '*********' : v}" }}") if @options[:debug]
158
181
 
159
182
  begin
160
- @sdk = LookerSDK::Client.new(conn_hash.merge!(faraday: faraday_connection)) unless @sdk
183
+ faraday = Faraday.new(conn_hash[:connection_options]) do |conn|
184
+ if @options[:persistent]
185
+ conn.adapter :net_http_persistent
186
+ end
187
+ end
188
+ @sdk = LookerSDK::Client.new(conn_hash.merge(faraday: faraday)) unless @sdk
161
189
 
162
190
  say_ok "check for connectivity: #{@sdk.alive?}" if @options[:debug]
163
191
  say_ok "verify authentication: #{@sdk.authenticated?}" if @options[:debug]
data/lib/gzr/version.rb CHANGED
@@ -20,5 +20,5 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  module Gzr
23
- VERSION = "0.2.46"
23
+ VERSION = '0.2.53'.freeze
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.46
4
+ version: 0.2.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike DeAngelo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-04 00:00:00.000000000 Z
11
+ date: 2021-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-reader
@@ -16,70 +16,76 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.0
19
+ version: 0.9.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.0
26
+ version: 0.9.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tty-table
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.10.0
33
+ version: 0.12.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.10.0
40
+ version: 0.12.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: tty-tree
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.0
47
+ version: 0.4.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.0
54
+ version: 0.4.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pastel
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.7.2
61
+ version: 0.8.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.7.2
68
+ version: 0.8.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: thor
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.20.0
75
+ version: '1.1'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 1.1.0
76
79
  type: :runtime
77
80
  prerelease: false
78
81
  version_requirements: !ruby/object:Gem::Requirement
79
82
  requirements:
80
83
  - - "~>"
81
84
  - !ruby/object:Gem::Version
82
- version: 0.20.0
85
+ version: '1.1'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 1.1.0
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: netrc
85
91
  requirement: !ruby/object:Gem::Requirement
@@ -99,6 +105,9 @@ dependencies:
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
107
  - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.3'
110
+ - - ">="
102
111
  - !ruby/object:Gem::Version
103
112
  version: 1.3.0
104
113
  type: :runtime
@@ -106,6 +115,9 @@ dependencies:
106
115
  version_requirements: !ruby/object:Gem::Requirement
107
116
  requirements:
108
117
  - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '1.3'
120
+ - - ">="
109
121
  - !ruby/object:Gem::Version
110
122
  version: 1.3.0
111
123
  - !ruby/object:Gem::Dependency
@@ -127,6 +139,9 @@ dependencies:
127
139
  requirement: !ruby/object:Gem::Requirement
128
140
  requirements:
129
141
  - - "~>"
142
+ - !ruby/object:Gem::Version
143
+ version: '4.0'
144
+ - - ">="
130
145
  - !ruby/object:Gem::Version
131
146
  version: 4.0.1
132
147
  type: :runtime
@@ -134,6 +149,9 @@ dependencies:
134
149
  version_requirements: !ruby/object:Gem::Requirement
135
150
  requirements:
136
151
  - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '4.0'
154
+ - - ">="
137
155
  - !ruby/object:Gem::Version
138
156
  version: 4.0.1
139
157
  - !ruby/object:Gem::Dependency
@@ -142,19 +160,28 @@ dependencies:
142
160
  requirements:
143
161
  - - "~>"
144
162
  - !ruby/object:Gem::Version
145
- version: '1.17'
163
+ version: '2.2'
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 2.2.10
146
167
  type: :development
147
168
  prerelease: false
148
169
  version_requirements: !ruby/object:Gem::Requirement
149
170
  requirements:
150
171
  - - "~>"
151
172
  - !ruby/object:Gem::Version
152
- version: '1.17'
173
+ version: '2.2'
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: 2.2.10
153
177
  - !ruby/object:Gem::Dependency
154
178
  name: rake
155
179
  requirement: !ruby/object:Gem::Requirement
156
180
  requirements:
157
181
  - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: '12.3'
184
+ - - ">="
158
185
  - !ruby/object:Gem::Version
159
186
  version: 12.3.3
160
187
  type: :development
@@ -162,6 +189,9 @@ dependencies:
162
189
  version_requirements: !ruby/object:Gem::Requirement
163
190
  requirements:
164
191
  - - "~>"
192
+ - !ruby/object:Gem::Version
193
+ version: '12.3'
194
+ - - ">="
165
195
  - !ruby/object:Gem::Version
166
196
  version: 12.3.3
167
197
  - !ruby/object:Gem::Dependency
@@ -178,32 +208,22 @@ dependencies:
178
208
  - - "~>"
179
209
  - !ruby/object:Gem::Version
180
210
  version: '3.0'
181
- - !ruby/object:Gem::Dependency
182
- name: tty
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '0.8'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: '0.8'
195
- description: Command line tool to manage the content of a Looker instance.
211
+ description: This tool will help manage the content of a Looker instance.
196
212
  email:
197
- - deangelo@looker.com
213
+ - drstrangelove@google.com
198
214
  executables:
199
215
  - gzr
200
216
  extensions: []
201
217
  extra_rdoc_files: []
202
218
  files:
219
+ - ".github/scripts/wait_for_looker.sh"
220
+ - ".github/workflows/release.yml"
221
+ - ".github/workflows/ruby-ci.yml"
203
222
  - ".gitignore"
204
223
  - ".rspec"
205
224
  - ".ruby-version"
206
225
  - ".travis.yml"
226
+ - CHANGELOG.md
207
227
  - CODE_OF_CONDUCT.md
208
228
  - CONTRIBUTING.md
209
229
  - Gemfile