gazer 0.3.4 → 0.3.5
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/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/lib/gzr/commands/dashboard/import_lookml.rb +72 -0
- data/lib/gzr/commands/dashboard.rb +16 -0
- data/lib/gzr/modules/dashboard.rb +10 -0
- data/lib/gzr/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8353db2512a7ffe580a29ee37366871008368b6398d458fbc544eb5eca2e0e48
|
4
|
+
data.tar.gz: 32c1c523488511675f82106447f2d78572322399548894eb35bf9fb882358b20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5cdda279be77bb67a70ac68c8d7970550b67bfbf6a4a9ec93df3ed4515cf326179c1b7fc5b3a6d41c6f2ee8888c1b31e1e189bdf12ac5620cdc0a6c31bcedf5
|
7
|
+
data.tar.gz: babe51b71247333c6fd6091d814fa7ada1adaf71d852f07a4aa7ece6b93c8576415157c82370a49e4317bf9610b4cc3796e2aca22c43791fe2df5e3409448e29
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.3.5](https://github.com/looker-open-source/gzr/compare/v0.3.4...v0.3.5) (2023-05-05)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* dashboard import_lookml ([#192](https://github.com/looker-open-source/gzr/issues/192)) ([248d5eb](https://github.com/looker-open-source/gzr/commit/248d5eb4b9e1c9ae302ab1b598784dd5065e9bf0))
|
9
|
+
|
3
10
|
## [0.3.4](https://github.com/looker-open-source/gzr/compare/v0.3.3...v0.3.4) (2023-05-04)
|
4
11
|
|
5
12
|
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,72 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
|
+
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# frozen_string_literal: true
|
23
|
+
|
24
|
+
require_relative '../../../gzr'
|
25
|
+
require_relative '../../command'
|
26
|
+
require_relative '../../modules/dashboard'
|
27
|
+
|
28
|
+
module Gzr
|
29
|
+
module Commands
|
30
|
+
class Dashboard
|
31
|
+
class ImportLookml < Gzr::Command
|
32
|
+
include Gzr::Dashboard
|
33
|
+
def initialize(dashboard_id, target_folder_id, options)
|
34
|
+
super()
|
35
|
+
@dashboard_id = dashboard_id
|
36
|
+
@target_folder_id = target_folder_id
|
37
|
+
@options = options
|
38
|
+
end
|
39
|
+
|
40
|
+
def execute(input: $stdin, output: $stdout)
|
41
|
+
say_warning("options: #{@options.inspect}", output: output) if @options[:debug]
|
42
|
+
with_session do
|
43
|
+
|
44
|
+
dash = query_dashboard(@dashboard_id)
|
45
|
+
raise Gzr::CLI::Error, "Dashboard with id #{@dashboard_id} does not exist" unless dash
|
46
|
+
|
47
|
+
matching_title = search_dashboards_by_title(dash[:title],@target_folder_id)
|
48
|
+
if matching_title.empty? || matching_title.first[:deleted]
|
49
|
+
matching_title = false
|
50
|
+
end
|
51
|
+
|
52
|
+
if matching_title
|
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
|
+
update_dashboard(matching_title.first[:id],{:deleted=>true})
|
56
|
+
end
|
57
|
+
|
58
|
+
new_dash = import_lookml_dashboard(@dashboard_id,@target_folder_id)
|
59
|
+
|
60
|
+
if @options[:unlink]
|
61
|
+
body = {}
|
62
|
+
body[:lookml_link_id] = nil
|
63
|
+
update_dashboard(new_dash[:id],body)
|
64
|
+
end
|
65
|
+
output.puts "Created user defined dashboard #{new_dash[:id]} in folder #{@target_folder_id}" unless @options[:plain]
|
66
|
+
output.puts new_dash[:id] if @options[:plain]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -96,6 +96,22 @@ module Gzr
|
|
96
96
|
Gzr::Commands::Dashboard::Rm.new(id, options).execute
|
97
97
|
end
|
98
98
|
end
|
99
|
+
|
100
|
+
desc 'import_lookml DASHBOARD_ID TARGET_FOLDER_ID', 'Create a UDD from a lookml dashboard in the given folder'
|
101
|
+
method_option :help, aliases: '-h', type: :boolean,
|
102
|
+
desc: 'Display usage information'
|
103
|
+
method_option :unlink, type: :boolean,
|
104
|
+
desc: 'Unlink the new user defined dashboard from the LookML dashboard'
|
105
|
+
method_option :force, type: :boolean,
|
106
|
+
desc: 'Overwrite a dashboard with the same name in the target folder'
|
107
|
+
def import_lookml(dashboard_id, target_folder_id)
|
108
|
+
if options[:help]
|
109
|
+
invoke :help, ['import_lookml']
|
110
|
+
else
|
111
|
+
require_relative 'dashboard/import_lookml'
|
112
|
+
Gzr::Commands::Dashboard::ImportLookml.new(dashboard_id, target_folder_id, options).execute
|
113
|
+
end
|
114
|
+
end
|
99
115
|
end
|
100
116
|
end
|
101
117
|
end
|
@@ -354,5 +354,15 @@ module Gzr
|
|
354
354
|
|
355
355
|
trimmed
|
356
356
|
end
|
357
|
+
|
358
|
+
def import_lookml_dashboard(id,folder)
|
359
|
+
begin
|
360
|
+
return @sdk.import_lookml_dashboard(id,folder)&.to_attrs
|
361
|
+
rescue LookerSDK::Error => e
|
362
|
+
say_error "Error import_lookml_dashboard(#{id},#{folder})"
|
363
|
+
say_error e
|
364
|
+
raise
|
365
|
+
end
|
366
|
+
end
|
357
367
|
end
|
358
368
|
end
|
data/lib/gzr/version.rb
CHANGED
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.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike DeAngelo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-reader
|
@@ -300,6 +300,7 @@ files:
|
|
300
300
|
- lib/gzr/commands/dashboard.rb
|
301
301
|
- lib/gzr/commands/dashboard/cat.rb
|
302
302
|
- lib/gzr/commands/dashboard/import.rb
|
303
|
+
- lib/gzr/commands/dashboard/import_lookml.rb
|
303
304
|
- lib/gzr/commands/dashboard/mv.rb
|
304
305
|
- lib/gzr/commands/dashboard/rm.rb
|
305
306
|
- lib/gzr/commands/folder.rb
|