gazer 0.2.59 → 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.
@@ -22,7 +22,7 @@
22
22
  # frozen_string_literal: true
23
23
 
24
24
  module Gzr
25
- module Space
25
+ module Folder
26
26
  def self.included klass
27
27
  require_relative '../modules/user'
28
28
  klass.class_eval do
@@ -30,43 +30,43 @@ module Gzr
30
30
  end
31
31
  end
32
32
 
33
- def create_space(name, parent_id)
33
+ def create_folder(name, parent_id)
34
34
  data = nil
35
35
  begin
36
36
  req = {:name => name, :parent_id => parent_id}
37
- data = @sdk.create_space(req)
37
+ data = @sdk.create_folder(req)
38
38
  rescue LookerSDK::Error => e
39
- say_error "Error creating space(#{JSON.pretty_generate(req)})"
39
+ say_error "Error creating folder(#{JSON.pretty_generate(req)})"
40
40
  say_error e.message
41
41
  raise
42
42
  end
43
43
  data
44
44
  end
45
45
 
46
- def search_spaces(name,fields=nil)
46
+ def search_folders(name,fields=nil)
47
47
  data = nil
48
48
  begin
49
49
  req = {:name => name}
50
50
  req[:fields] = fields if fields
51
- data = @sdk.search_spaces(req)
51
+ data = @sdk.search_folders(req)
52
52
  rescue LookerSDK::Error => e
53
- say_error "Error querying search_spaces(#{JSON.pretty_generate(req)})"
53
+ say_error "Error querying search_folders(#{JSON.pretty_generate(req)})"
54
54
  say_error e.message
55
55
  raise
56
56
  end
57
57
  data
58
58
  end
59
59
 
60
- def query_space(id,fields=nil)
60
+ def query_folder(id,fields=nil)
61
61
  data = nil
62
62
  begin
63
63
  req = {}
64
64
  req[:fields] = fields if fields
65
- data = @sdk.space(id, req)
65
+ data = @sdk.folder(id, req)
66
66
  rescue LookerSDK::NotFound
67
67
  return nil
68
68
  rescue LookerSDK::Error => e
69
- say_error "Error querying space(#{id},#{JSON.pretty_generate(req)})"
69
+ say_error "Error querying folder(#{id},#{JSON.pretty_generate(req)})"
70
70
  say_error e.message
71
71
  raise
72
72
  end
@@ -74,83 +74,83 @@ module Gzr
74
74
  end
75
75
 
76
76
  def process_args(args)
77
- space_ids = []
77
+ folder_ids = []
78
78
 
79
79
  begin
80
- user = query_me("home_space_id")
81
- space_ids << user.home_space_id
80
+ user = query_me("home_folder_id")
81
+ folder_ids << user.home_folder_id
82
82
  end unless args && args.length > 0 && !(args[0].nil?)
83
83
 
84
84
  if args[0] == 'lookml'
85
- space_ids << 'lookml'
85
+ folder_ids << 'lookml'
86
86
  elsif args[0] =~ /^[0-9]+$/ then
87
- space_ids << args[0].to_i
87
+ folder_ids << args[0].to_i
88
88
  elsif args[0] == "~" then
89
- user = query_me("personal_space_id")
90
- space_ids << user.personal_space_id
89
+ user = query_me("personal_folder_id")
90
+ folder_ids << user.personal_folder_id
91
91
  elsif args[0] =~ /^~[0-9]+$/ then
92
- user = query_user(args[0].sub('~',''), "personal_space_id")
93
- space_ids << user.personal_space_id
92
+ user = query_user(args[0].sub('~',''), "personal_folder_id")
93
+ folder_ids << user.personal_folder_id
94
94
  elsif args[0] =~ /^~.+@.+$/ then
95
- search_results = search_users( { :email=>args[0].sub('~','') },"personal_space_id" )
96
- space_ids += search_results.map { |r| r.personal_space_id }
95
+ search_results = search_users( { :email=>args[0].sub('~','') },"personal_folder_id" )
96
+ folder_ids += search_results.map { |r| r.personal_folder_id }
97
97
  elsif args[0] =~ /^~.+$/ then
98
98
  first_name, last_name = args[0].sub('~','').split(' ')
99
- search_results = search_users( { :first_name=>first_name, :last_name=>last_name },"personal_space_id" )
100
- space_ids += search_results.map { |r| r.personal_space_id }
99
+ search_results = search_users( { :first_name=>first_name, :last_name=>last_name },"personal_folder_id" )
100
+ folder_ids += search_results.map { |r| r.personal_folder_id }
101
101
  else
102
- search_results = search_spaces(args[0],"id")
103
- space_ids += search_results.map { |r| r.id }
102
+ search_results = search_folders(args[0],"id")
103
+ folder_ids += search_results.map { |r| r.id }
104
104
 
105
- # The built in Shared space is only availabe by
105
+ # The built in Shared folder is only availabe by
106
106
  # searching for Home. https://github.com/looker/helltool/issues/34994
107
107
  if args[0] == 'Shared' then
108
- search_results = search_spaces('Home',"id,is_shared_root")
109
- space_ids += search_results.select { |r| r.is_shared_root }.map { |r| r.id }
108
+ search_results = search_folders('Home',"id,is_shared_root")
109
+ folder_ids += search_results.select { |r| r.is_shared_root }.map { |r| r.id }
110
110
  end
111
111
  end if args && args.length > 0 && !args[0].nil?
112
112
 
113
- return space_ids
113
+ return folder_ids
114
114
  end
115
115
 
116
- def all_spaces(fields=nil)
116
+ def all_folders(fields=nil)
117
117
  data = nil
118
118
  begin
119
119
  req = {}
120
120
  req[:fields] = fields if fields
121
- data = @sdk.all_spaces(req)
121
+ data = @sdk.all_folders(req)
122
122
  rescue LookerSDK::Error => e
123
- say_error "Error querying all_spaces(#{JSON.pretty_generate(req)})"
123
+ say_error "Error querying all_folders(#{JSON.pretty_generate(req)})"
124
124
  say_error e.message
125
125
  raise
126
126
  end
127
127
  data
128
128
  end
129
129
 
130
- def query_space_children(space_id, fields=nil)
130
+ def query_folder_children(folder_id, fields=nil)
131
131
  data = nil
132
132
  req = {}
133
133
  req[:fields] = fields if fields
134
134
  begin
135
- data = @sdk.space_children(space_id, req)
135
+ data = @sdk.folder_children(folder_id, req)
136
136
  rescue LookerSDK::NotFound
137
137
  return nil
138
138
  rescue LookerSDK::Error => e
139
- say_error "Error querying space_children(#{space_id}, #{JSON.pretty_generate(req)})"
139
+ say_error "Error querying folder_children(#{folder_id}, #{JSON.pretty_generate(req)})"
140
140
  say_error e.message
141
141
  raise
142
142
  end
143
143
  data
144
144
  end
145
145
 
146
- def delete_space(space_id)
146
+ def delete_folder(folder_id)
147
147
  data = nil
148
148
  begin
149
- data = @sdk.delete_space(space_id)
149
+ data = @sdk.delete_folder(folder_id)
150
150
  rescue LookerSDK::NotFound
151
151
  return nil
152
152
  rescue LookerSDK::Error => e
153
- say_error "Error deleting space #{space_id}"
153
+ say_error "Error deleting folder #{folder_id}"
154
154
  say_error e.message
155
155
  raise
156
156
  end
@@ -35,11 +35,11 @@ module Gzr
35
35
  data
36
36
  end
37
37
 
38
- def search_looks_by_slug(slug, space_id=nil)
38
+ def search_looks_by_slug(slug, folder_id=nil)
39
39
  data = []
40
40
  begin
41
41
  req = { :slug => slug }
42
- req[:space_id] = space_id if space_id
42
+ req[:folder_id] = folder_id if folder_id
43
43
  data = @sdk.search_looks(req)
44
44
  req[:deleted] = true
45
45
  data = @sdk.search_looks(req) if data.empty?
@@ -51,11 +51,11 @@ module Gzr
51
51
  data
52
52
  end
53
53
 
54
- def search_looks_by_title(title, space_id=nil)
54
+ def search_looks_by_title(title, folder_id=nil)
55
55
  data = []
56
56
  begin
57
57
  req = { :title => title }
58
- req[:space_id] = space_id if space_id
58
+ req[:folder_id] = folder_id if folder_id
59
59
  data = @sdk.search_looks(req)
60
60
  req[:deleted] = true
61
61
  data = @sdk.search_looks(req) if data.empty?
@@ -69,10 +69,11 @@ module Gzr
69
69
 
70
70
  def create_look(look)
71
71
  begin
72
+ look[:public] = false unless look[:public]
72
73
  data = @sdk.create_look(look)
73
74
  rescue LookerSDK::Error => e
74
75
  say_error "Error creating look(#{JSON.pretty_generate(look)})"
75
- say_error e.message
76
+ say_error e
76
77
  raise
77
78
  end
78
79
  data
@@ -101,16 +102,16 @@ module Gzr
101
102
  data
102
103
  end
103
104
 
104
- def upsert_look(user_id, query_id, space_id, source, output: $stdout)
105
- # try to find look by slug in target space
106
- existing_look = search_looks_by_slug(source[:slug], space_id).fetch(0,nil) if source[:slug]
107
- # check for look of same title in target space
108
- title_used = search_looks_by_title(source[:title], space_id).fetch(0,nil)
105
+ def upsert_look(user_id, query_id, folder_id, source, output: $stdout)
106
+ # try to find look by slug in target folder
107
+ existing_look = search_looks_by_slug(source[:slug], folder_id).fetch(0,nil) if source[:slug]
108
+ # check for look of same title in target folder
109
+ title_used = search_looks_by_title(source[:title], folder_id).fetch(0,nil)
109
110
 
110
- # If there is no match by slug in target space or no slug given, then we match by title
111
+ # If there is no match by slug in target folder or no slug given, then we match by title
111
112
  existing_look ||= title_used
112
113
 
113
- # same_title is now a flag indicating that there is already a look in the same space with
114
+ # same_title is now a flag indicating that there is already a look in the same folder with
114
115
  # that title, and it is the one we are updating.
115
116
  same_title = (title_used&.fetch(:id,nil) == existing_look&.fetch(:id,nil))
116
117
 
@@ -122,17 +123,17 @@ module Gzr
122
123
  same_slug = (slug_used&.fetch(:id,nil) == existing_look&.fetch(:id,nil))
123
124
 
124
125
  if slug_used && !same_slug then
125
- say_warning "slug #{slug_used.slug} already used for look #{slug_used.title} in space #{slug_used.space_id}", output: output
126
+ say_warning "slug #{slug_used.slug} already used for look #{slug_used.title} in folder #{slug_used.folder_id}", output: output
126
127
  say_warning("That look is in the 'Trash' but not fully deleted yet", output: output) if slug_used.deleted
127
128
  say_warning "look will be imported with new slug", output: output
128
129
  end
129
130
 
130
131
  if existing_look then
131
132
  if title_used && !same_title then
132
- raise Gzr::CLI::Error, "Look #{source[:title]} already exists in space #{space_id}\nDelete it before trying to upate another Look to have that title."
133
+ raise Gzr::CLI::Error, "Look #{source[:title]} already exists in folder #{folder_id}\nDelete it before trying to upate another Look to have that title."
133
134
  end
134
- raise Gzr::CLI::Error, "Look #{existing_look[:title]} with slug #{existing_look[:slug]} already exists in space #{space_id}\nUse --force if you want to overwrite it" unless @options[:force]
135
- say_ok "Modifying existing Look #{existing_look.id} #{existing_look.title} in space #{space_id}", output: output
135
+ raise Gzr::CLI::Error, "Look #{existing_look[:title]} with slug #{existing_look[:slug]} already exists in folder #{folder_id}\nUse --force if you want to overwrite it" unless @options[:force]
136
+ say_ok "Modifying existing Look #{existing_look.id} #{existing_look.title} in folder #{folder_id}", output: output
136
137
  new_look = source.select do |k,v|
137
138
  (keys_to_keep('update_look') - [:space_id,:folder_id,:user_id,:query_id,:slug]).include? k
138
139
  end
@@ -147,7 +148,7 @@ module Gzr
147
148
  new_look[:slug] = source[:slug] unless slug_used
148
149
  new_look[:query_id] = query_id
149
150
  new_look[:user_id] = user_id
150
- new_look[:space_id] = space_id
151
+ new_look[:folder_id] = folder_id
151
152
 
152
153
  find_vis_config_reference(new_look) do |vis_config|
153
154
  find_color_palette_reference(vis_config) do |o,default_colors|
@@ -102,7 +102,7 @@ module Gzr
102
102
  conn_hash
103
103
  end
104
104
 
105
- def login(min_api_version=nil)
105
+ def login(min_api_version="4.0")
106
106
  if (@options[:client_id].nil? && ENV["LOOKERSDK_CLIENT_ID"])
107
107
  @options[:client_id] = ENV["LOOKERSDK_CLIENT_ID"]
108
108
  end
@@ -111,10 +111,6 @@ module Gzr
111
111
  @options[:client_secret] = ENV["LOOKERSDK_CLIENT_SECRET"]
112
112
  end
113
113
 
114
- if (@options[:api_version].nil? && ENV["LOOKERSDK_API_VERSION"])
115
- @options[:api_version] = ENV["LOOKERSDK_API_VERSION"]
116
- end
117
-
118
114
  if (@options[:verify_ssl] && ENV["LOOKERSDK_VERIFY_SSL"])
119
115
  @options[:verify_ssl] = !(/^f(alse)?$/i =~ ENV["LOOKERSDK_VERIFY_SSL"])
120
116
  end
@@ -137,6 +133,7 @@ module Gzr
137
133
  :links_parser => Sawyer::LinkParsers::Simple.new,
138
134
  :serializer => LookerSDK::Client::Serializer.new(JSON),
139
135
  :faraday => Faraday.new(conn_hash[:connection_options]) do |conn|
136
+ conn.use LookerSDK::Response::RaiseError
140
137
  if @options[:persistent]
141
138
  conn.adapter :net_http_persistent
142
139
  end
@@ -166,21 +163,19 @@ module Gzr
166
163
  end
167
164
 
168
165
  say_warning "API current_version #{@current_version}" if @options[:debug]
169
- say_warning "API versions #{@versions}" if @options[:debug]
170
-
171
- raise Gzr::CLI::Error, "Operation requires API v#{min_api_version}, but user specified version #{@options[:api_version]}" unless sufficient_version?(@options[:api_version],min_api_version)
166
+ say_warning "Supported API versions #{@versions}" if @options[:debug]
172
167
 
173
168
  api_version = [min_api_version, @current_version].max
174
169
  raise Gzr::CLI::Error, "Operation requires API v#{api_version}, which is not available from this host" if api_version && !@versions.any? {|v| v == api_version}
175
- raise Gzr::CLI::Error, "User specified API v#{@options[:api_version]}, which is not available from this host" if @options[:api_version] && !@versions.any? {|v| v == @options[:api_version]}
176
170
 
177
- conn_hash = build_connection_hash(@options[:api_version] || api_version)
171
+ conn_hash = build_connection_hash(api_version)
178
172
  @secret = nil
179
173
 
180
174
  say_ok("connecting to #{conn_hash.map { |k,v| "#{k}=>#{(k == :client_secret) ? '*********' : v}" }}") if @options[:debug]
181
175
 
182
176
  begin
183
177
  faraday = Faraday.new(conn_hash[:connection_options]) do |conn|
178
+ conn.use LookerSDK::Response::RaiseError
184
179
  if @options[:persistent]
185
180
  conn.adapter :net_http_persistent
186
181
  end
@@ -242,7 +237,7 @@ module Gzr
242
237
  end
243
238
  end
244
239
 
245
- def with_session(min_api_version="3.0")
240
+ def with_session(min_api_version="4.0")
246
241
  return nil unless block_given?
247
242
  begin
248
243
  login(min_api_version) unless @sdk
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.59'.freeze
23
+ VERSION = '0.2.60'.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.59
4
+ version: 0.2.60
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-03-29 00:00:00.000000000 Z
11
+ date: 2023-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-reader
@@ -120,6 +120,20 @@ dependencies:
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: 1.3.0
123
+ - !ruby/object:Gem::Dependency
124
+ name: faraday
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: 1.10.3
130
+ type: :runtime
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: 1.10.3
123
137
  - !ruby/object:Gem::Dependency
124
138
  name: looker-sdk
125
139
  requirement: !ruby/object:Gem::Requirement
@@ -127,9 +141,6 @@ dependencies:
127
141
  - - "~>"
128
142
  - !ruby/object:Gem::Version
129
143
  version: 0.1.1
130
- - - "<="
131
- - !ruby/object:Gem::Version
132
- version: 0.1.2
133
144
  type: :runtime
134
145
  prerelease: false
135
146
  version_requirements: !ruby/object:Gem::Requirement
@@ -137,9 +148,6 @@ dependencies:
137
148
  - - "~>"
138
149
  - !ruby/object:Gem::Version
139
150
  version: 0.1.1
140
- - - "<="
141
- - !ruby/object:Gem::Version
142
- version: 0.1.2
143
151
  - !ruby/object:Gem::Dependency
144
152
  name: net-http-persistent
145
153
  requirement: !ruby/object:Gem::Requirement
@@ -238,6 +246,7 @@ extra_rdoc_files: []
238
246
  files:
239
247
  - ".github/scripts/parse_version.sh"
240
248
  - ".github/scripts/wait_for_looker.sh"
249
+ - ".github/workflows/lint-pr.yml"
241
250
  - ".github/workflows/release.yml"
242
251
  - ".github/workflows/ruby-ci.yml"
243
252
  - ".gitignore"
@@ -276,6 +285,14 @@ files:
276
285
  - lib/gzr/commands/dashboard/import.rb
277
286
  - lib/gzr/commands/dashboard/mv.rb
278
287
  - lib/gzr/commands/dashboard/rm.rb
288
+ - lib/gzr/commands/folder.rb
289
+ - lib/gzr/commands/folder/cat.rb
290
+ - lib/gzr/commands/folder/create.rb
291
+ - lib/gzr/commands/folder/export.rb
292
+ - lib/gzr/commands/folder/ls.rb
293
+ - lib/gzr/commands/folder/rm.rb
294
+ - lib/gzr/commands/folder/top.rb
295
+ - lib/gzr/commands/folder/tree.rb
279
296
  - lib/gzr/commands/group.rb
280
297
  - lib/gzr/commands/group/ls.rb
281
298
  - lib/gzr/commands/group/member_groups.rb
@@ -310,14 +327,6 @@ files:
310
327
  - lib/gzr/commands/role/user_add.rb
311
328
  - lib/gzr/commands/role/user_ls.rb
312
329
  - lib/gzr/commands/role/user_rm.rb
313
- - lib/gzr/commands/space.rb
314
- - lib/gzr/commands/space/cat.rb
315
- - lib/gzr/commands/space/create.rb
316
- - lib/gzr/commands/space/export.rb
317
- - lib/gzr/commands/space/ls.rb
318
- - lib/gzr/commands/space/rm.rb
319
- - lib/gzr/commands/space/top.rb
320
- - lib/gzr/commands/space/tree.rb
321
330
  - lib/gzr/commands/subcommandbase.rb
322
331
  - lib/gzr/commands/user.rb
323
332
  - lib/gzr/commands/user/cat.rb
@@ -330,6 +339,7 @@ files:
330
339
  - lib/gzr/modules/connection.rb
331
340
  - lib/gzr/modules/dashboard.rb
332
341
  - lib/gzr/modules/filehelper.rb
342
+ - lib/gzr/modules/folder.rb
333
343
  - lib/gzr/modules/group.rb
334
344
  - lib/gzr/modules/look.rb
335
345
  - lib/gzr/modules/model.rb
@@ -337,7 +347,6 @@ files:
337
347
  - lib/gzr/modules/plan.rb
338
348
  - lib/gzr/modules/role.rb
339
349
  - lib/gzr/modules/session.rb
340
- - lib/gzr/modules/space.rb
341
350
  - lib/gzr/modules/user.rb
342
351
  - lib/gzr/templates/.gitkeep
343
352
  - lib/gzr/templates/attribute/cat/.gitkeep