gazer 0.2.9 → 0.2.10
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/Gemfile.lock +1 -1
- data/lib/gzr/cli.rb +3 -0
- data/lib/gzr/commands/dashboard/import.rb +15 -11
- data/lib/gzr/commands/permissions.rb +28 -0
- data/lib/gzr/commands/permissions/ls.rb +74 -0
- data/lib/gzr/commands/user.rb +12 -0
- data/lib/gzr/commands/user/delete.rb +47 -0
- data/lib/gzr/modules/permissions.rb +41 -0
- data/lib/gzr/modules/user.rb +13 -0
- data/lib/gzr/templates/permissions/ls/.gitkeep +1 -0
- data/lib/gzr/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aee99a2281ea5f0a3fe6f8bb8dc25e0dc3d0ff96
|
4
|
+
data.tar.gz: e398cadd5f43339d815aef1f4ab232077e4203f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 661520994b099375d67bae336f5d7da249c8c0c704f789da70030392db0eb4db28ee74d21f8a00f42edf89d4b89ab00c191e6561e13060fdedcf4a30871e0c5b
|
7
|
+
data.tar.gz: ce6d3808b51a5c9209385f7dbe3b36044d2cbff4c6a4f3f130a8a49856df9a41c7c6735f1ff98ddc0067ce3d14650711bb28204afc0a483f732ec89b22e328eb
|
data/Gemfile.lock
CHANGED
data/lib/gzr/cli.rb
CHANGED
@@ -53,6 +53,9 @@ module Gzr
|
|
53
53
|
end
|
54
54
|
map %w(--version -v) => :version
|
55
55
|
|
56
|
+
require_relative 'commands/permissions'
|
57
|
+
register Gzr::Commands::Permissions, 'permissions', 'permissions [SUBCOMMAND]', 'Command to retrieve available permissions'
|
58
|
+
|
56
59
|
require_relative 'commands/query'
|
57
60
|
register Gzr::Commands::Query, 'query', 'query [SUBCOMMAND]', 'Commands to retrieve and run queries'
|
58
61
|
|
@@ -90,26 +90,30 @@ module Gzr
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def sync_dashboard(source,target_space_id)
|
93
|
-
existing_dashboard = search_dashboards_by_title(source[:title], target_space_id).fetch(0,nil)
|
94
93
|
slug_used = search_dashboards_by_slug(source[:slug]).fetch(0,nil) if source[:slug]
|
94
|
+
title_used = search_dashboards_by_title(source[:title], target_space_id).fetch(0,nil)
|
95
|
+
existing_dashboard = search_dashboards_by_slug(source[:slug], target_space_id).fetch(0,nil) if source[:slug]
|
96
|
+
if existing_dashboard then
|
97
|
+
title_used = false if title_used.id == existing_dashboard.id
|
98
|
+
else
|
99
|
+
existing_dashboard = title_used
|
100
|
+
title_used = false
|
101
|
+
end
|
102
|
+
slug_used = false if existing_dashboard && slug_used && slug_used.id == existing_dashboard.id
|
95
103
|
|
96
104
|
if slug_used then
|
97
|
-
|
98
|
-
|
99
|
-
say_warning "slug #{slug_used.slug} already used for dashboard #{slug_used.title} in space #{slug_used.space_id}"
|
100
|
-
say_warning "dashboard will be imported with new slug"
|
101
|
-
end
|
102
|
-
else
|
103
|
-
say_warning "slug #{slug_used.slug} already used for dashboard #{slug_used.title} in space #{slug_used.space_id}"
|
104
|
-
say_warning "dashboard will be imported with new slug"
|
105
|
-
end
|
105
|
+
say_warning "slug #{slug_used.slug} already used for dashboard #{slug_used.title} in space #{slug_used.space_id}"
|
106
|
+
say_warning "dashboard will be imported with new slug"
|
106
107
|
end
|
107
108
|
|
108
109
|
if existing_dashboard then
|
110
|
+
if title_used then
|
111
|
+
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."
|
112
|
+
end
|
109
113
|
if @options[:force] then
|
110
114
|
say_ok "Modifying existing dashboard #{existing_dashboard.id} #{existing_dashboard[:title]} in space #{target_space_id}"
|
111
115
|
new_dash = source.select do |k,v|
|
112
|
-
(keys_to_keep('update_dashboard') - [:space_id,:user_id,:
|
116
|
+
(keys_to_keep('update_dashboard') - [:space_id,:user_id,:slug]).include? k
|
113
117
|
end
|
114
118
|
new_dash[:slug] = source[:slug] unless slug_used
|
115
119
|
return update_dashboard(existing_dashboard.id,new_dash)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module Gzr
|
6
|
+
module Commands
|
7
|
+
class Permissions < Thor
|
8
|
+
|
9
|
+
namespace :permissions
|
10
|
+
|
11
|
+
desc 'ls', 'List all available permissions'
|
12
|
+
method_option :help, aliases: '-h', type: :boolean,
|
13
|
+
desc: 'Display usage information'
|
14
|
+
method_option :plain, type: :boolean, default: false,
|
15
|
+
desc: 'print without any extra formatting'
|
16
|
+
method_option :csv, type: :boolean, default: false,
|
17
|
+
desc: 'output in csv format per RFC4180'
|
18
|
+
def ls(*)
|
19
|
+
if options[:help]
|
20
|
+
invoke :help, ['ls']
|
21
|
+
else
|
22
|
+
require_relative 'permissions/ls'
|
23
|
+
Gzr::Commands::Permissions::Ls.new(options).execute
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, 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 '../../command'
|
25
|
+
require_relative '../../modules/permissions'
|
26
|
+
require 'tty-table'
|
27
|
+
|
28
|
+
require_relative '../../command'
|
29
|
+
|
30
|
+
module Gzr
|
31
|
+
module Commands
|
32
|
+
class Permissions
|
33
|
+
class Ls < Gzr::Command
|
34
|
+
include Gzr::Permissions
|
35
|
+
def initialize(options)
|
36
|
+
super()
|
37
|
+
@options = options
|
38
|
+
end
|
39
|
+
|
40
|
+
def execute(input: $stdin, output: $stdout)
|
41
|
+
say_warning(@options) if @options[:debug]
|
42
|
+
with_session do
|
43
|
+
data = query_all_permissions()
|
44
|
+
begin
|
45
|
+
say_ok "No permissions found"
|
46
|
+
return nil
|
47
|
+
end unless data && data.length > 0
|
48
|
+
|
49
|
+
table_hash = Hash.new
|
50
|
+
fields = field_names('permission,parent,description')
|
51
|
+
table_hash[:header] = fields unless @options[:plain]
|
52
|
+
expressions = fields.collect { |fn| field_expression(fn) }
|
53
|
+
table_hash[:rows] = data.map do |row|
|
54
|
+
expressions.collect do |e|
|
55
|
+
eval "row.#{e}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
table = TTY::Table.new(table_hash)
|
59
|
+
alignments = fields.collect do |k|
|
60
|
+
(k =~ /id$/) ? :right : :left
|
61
|
+
end
|
62
|
+
begin
|
63
|
+
if @options[:csv] then
|
64
|
+
output.puts render_csv(table)
|
65
|
+
else
|
66
|
+
output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: 1024)
|
67
|
+
end
|
68
|
+
end if table
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/gzr/commands/user.rb
CHANGED
@@ -53,6 +53,18 @@ module Gzr
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
desc 'delete USER_ID', 'Delete the user given by user_id'
|
57
|
+
method_option :help, aliases: '-h', type: :boolean,
|
58
|
+
desc: 'Display usage information'
|
59
|
+
def delete(user_id)
|
60
|
+
if options[:help]
|
61
|
+
invoke :help, ['delete']
|
62
|
+
else
|
63
|
+
require_relative 'user/delete'
|
64
|
+
Gzr::Commands::User::Delete.new(user_id,options).execute
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
56
68
|
desc 'cat USER_ID', 'Output json information about a user to screen or file'
|
57
69
|
method_option :help, aliases: '-h', type: :boolean,
|
58
70
|
desc: 'Display usage information'
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, 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 '../../command'
|
25
|
+
require_relative '../../modules/user'
|
26
|
+
|
27
|
+
module Gzr
|
28
|
+
module Commands
|
29
|
+
class User
|
30
|
+
class Delete < Gzr::Command
|
31
|
+
include Gzr::User
|
32
|
+
def initialize(user_id,options)
|
33
|
+
super()
|
34
|
+
@user_id = user_id
|
35
|
+
@options = options
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute(input: $stdin, output: $stdout)
|
39
|
+
say_warning(@options) if @options[:debug]
|
40
|
+
with_session do
|
41
|
+
data = delete_user(@user_id)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, 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
|
+
module Gzr
|
25
|
+
module Permissions
|
26
|
+
|
27
|
+
def query_all_permissions()
|
28
|
+
data = nil
|
29
|
+
begin
|
30
|
+
data = @sdk.all_permissions()
|
31
|
+
rescue LookerSDK::Error => e
|
32
|
+
say_error "Error querying all_permissions()"
|
33
|
+
say_error e.message
|
34
|
+
raise
|
35
|
+
end
|
36
|
+
data
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
data/lib/gzr/modules/user.rb
CHANGED
@@ -110,5 +110,18 @@ module Gzr
|
|
110
110
|
end
|
111
111
|
data
|
112
112
|
end
|
113
|
+
|
114
|
+
def delete_user(id)
|
115
|
+
data = nil
|
116
|
+
req = id
|
117
|
+
begin
|
118
|
+
data = @sdk.delete_user(req)
|
119
|
+
rescue LookerSDK::Error => e
|
120
|
+
say_error "Error deleting user(#{id},#{JSON.pretty_generate(req)})"
|
121
|
+
say_error e.message
|
122
|
+
raise
|
123
|
+
end
|
124
|
+
data
|
125
|
+
end
|
113
126
|
end
|
114
127
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
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.2.
|
4
|
+
version: 0.2.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike DeAngelo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-reader
|
@@ -207,6 +207,8 @@ files:
|
|
207
207
|
- lib/gzr/commands/look/rm.rb
|
208
208
|
- lib/gzr/commands/model.rb
|
209
209
|
- lib/gzr/commands/model/ls.rb
|
210
|
+
- lib/gzr/commands/permissions.rb
|
211
|
+
- lib/gzr/commands/permissions/ls.rb
|
210
212
|
- lib/gzr/commands/plan.rb
|
211
213
|
- lib/gzr/commands/plan/cat.rb
|
212
214
|
- lib/gzr/commands/plan/disable.rb
|
@@ -239,6 +241,7 @@ files:
|
|
239
241
|
- lib/gzr/commands/subcommandbase.rb
|
240
242
|
- lib/gzr/commands/user.rb
|
241
243
|
- lib/gzr/commands/user/cat.rb
|
244
|
+
- lib/gzr/commands/user/delete.rb
|
242
245
|
- lib/gzr/commands/user/disable.rb
|
243
246
|
- lib/gzr/commands/user/enable.rb
|
244
247
|
- lib/gzr/commands/user/ls.rb
|
@@ -249,6 +252,7 @@ files:
|
|
249
252
|
- lib/gzr/modules/group.rb
|
250
253
|
- lib/gzr/modules/look.rb
|
251
254
|
- lib/gzr/modules/model.rb
|
255
|
+
- lib/gzr/modules/permissions.rb
|
252
256
|
- lib/gzr/modules/plan.rb
|
253
257
|
- lib/gzr/modules/role.rb
|
254
258
|
- lib/gzr/modules/session.rb
|
@@ -267,6 +271,7 @@ files:
|
|
267
271
|
- lib/gzr/templates/look/import/.gitkeep
|
268
272
|
- lib/gzr/templates/look/rm/.gitkeep
|
269
273
|
- lib/gzr/templates/model/ls/.gitkeep
|
274
|
+
- lib/gzr/templates/permissions/ls/.gitkeep
|
270
275
|
- lib/gzr/templates/plan/cat/.gitkeep
|
271
276
|
- lib/gzr/templates/plan/disable/.gitkeep
|
272
277
|
- lib/gzr/templates/plan/enable/.gitkeep
|