gazer 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +35 -0
- data/Gemfile.lock +150 -0
- data/LICENSE.txt +20 -0
- data/README.md +527 -0
- data/Rakefile +27 -0
- data/bin/console +35 -0
- data/bin/setup +30 -0
- data/exe/gzr +40 -0
- data/gzr.gemspec +67 -0
- data/lib/gzr.rb +25 -0
- data/lib/gzr/cli.rb +86 -0
- data/lib/gzr/command.rb +251 -0
- data/lib/gzr/commands/.gitkeep +1 -0
- data/lib/gzr/commands/connection.rb +69 -0
- data/lib/gzr/commands/connection/dialects.rb +72 -0
- data/lib/gzr/commands/connection/ls.rb +72 -0
- data/lib/gzr/commands/dashboard.rb +75 -0
- data/lib/gzr/commands/dashboard/cat.rb +67 -0
- data/lib/gzr/commands/dashboard/import.rb +256 -0
- data/lib/gzr/commands/dashboard/rm.rb +47 -0
- data/lib/gzr/commands/group.rb +87 -0
- data/lib/gzr/commands/group/ls.rb +73 -0
- data/lib/gzr/commands/group/member_groups.rb +74 -0
- data/lib/gzr/commands/group/member_users.rb +74 -0
- data/lib/gzr/commands/look.rb +75 -0
- data/lib/gzr/commands/look/cat.rb +55 -0
- data/lib/gzr/commands/look/import.rb +62 -0
- data/lib/gzr/commands/look/rm.rb +47 -0
- data/lib/gzr/commands/model.rb +51 -0
- data/lib/gzr/commands/model/ls.rb +72 -0
- data/lib/gzr/commands/plan.rb +149 -0
- data/lib/gzr/commands/plan/cat.rb +52 -0
- data/lib/gzr/commands/plan/disable.rb +49 -0
- data/lib/gzr/commands/plan/enable.rb +49 -0
- data/lib/gzr/commands/plan/failures.rb +98 -0
- data/lib/gzr/commands/plan/import.rb +69 -0
- data/lib/gzr/commands/plan/ls.rb +102 -0
- data/lib/gzr/commands/plan/rm.rb +47 -0
- data/lib/gzr/commands/plan/run.rb +58 -0
- data/lib/gzr/commands/query.rb +49 -0
- data/lib/gzr/commands/query/runquery.rb +102 -0
- data/lib/gzr/commands/role.rb +163 -0
- data/lib/gzr/commands/role/cat.rb +52 -0
- data/lib/gzr/commands/role/group_add.rb +51 -0
- data/lib/gzr/commands/role/group_ls.rb +76 -0
- data/lib/gzr/commands/role/group_rm.rb +51 -0
- data/lib/gzr/commands/role/ls.rb +75 -0
- data/lib/gzr/commands/role/rm.rb +47 -0
- data/lib/gzr/commands/role/user_add.rb +51 -0
- data/lib/gzr/commands/role/user_ls.rb +76 -0
- data/lib/gzr/commands/role/user_rm.rb +51 -0
- data/lib/gzr/commands/space.rb +137 -0
- data/lib/gzr/commands/space/cat.rb +53 -0
- data/lib/gzr/commands/space/create.rb +50 -0
- data/lib/gzr/commands/space/export.rb +117 -0
- data/lib/gzr/commands/space/ls.rb +97 -0
- data/lib/gzr/commands/space/rm.rb +56 -0
- data/lib/gzr/commands/space/top.rb +62 -0
- data/lib/gzr/commands/space/tree.rb +79 -0
- data/lib/gzr/commands/subcommandbase.rb +41 -0
- data/lib/gzr/commands/user.rb +111 -0
- data/lib/gzr/commands/user/cat.rb +52 -0
- data/lib/gzr/commands/user/disable.rb +47 -0
- data/lib/gzr/commands/user/enable.rb +47 -0
- data/lib/gzr/commands/user/ls.rb +82 -0
- data/lib/gzr/commands/user/me.rb +66 -0
- data/lib/gzr/modules/connection.rb +52 -0
- data/lib/gzr/modules/dashboard.rb +215 -0
- data/lib/gzr/modules/filehelper.rb +81 -0
- data/lib/gzr/modules/group.rb +93 -0
- data/lib/gzr/modules/look.rb +162 -0
- data/lib/gzr/modules/model.rb +40 -0
- data/lib/gzr/modules/plan.rb +216 -0
- data/lib/gzr/modules/role.rb +128 -0
- data/lib/gzr/modules/session.rb +203 -0
- data/lib/gzr/modules/space.rb +160 -0
- data/lib/gzr/modules/user.rb +114 -0
- data/lib/gzr/templates/.gitkeep +1 -0
- data/lib/gzr/templates/connection/dialects/.gitkeep +1 -0
- data/lib/gzr/templates/connection/ls/.gitkeep +1 -0
- data/lib/gzr/templates/dashboard/cat/.gitkeep +1 -0
- data/lib/gzr/templates/dashboard/import/.gitkeep +1 -0
- data/lib/gzr/templates/dashboard/rm/.gitkeep +1 -0
- data/lib/gzr/templates/group/ls/.gitkeep +1 -0
- data/lib/gzr/templates/group/member_groups/.gitkeep +1 -0
- data/lib/gzr/templates/group/member_users/.gitkeep +1 -0
- data/lib/gzr/templates/look/cat/.gitkeep +1 -0
- data/lib/gzr/templates/look/import/.gitkeep +1 -0
- data/lib/gzr/templates/look/rm/.gitkeep +1 -0
- data/lib/gzr/templates/model/ls/.gitkeep +1 -0
- data/lib/gzr/templates/plan/cat/.gitkeep +1 -0
- data/lib/gzr/templates/plan/disable/.gitkeep +1 -0
- data/lib/gzr/templates/plan/enable/.gitkeep +1 -0
- data/lib/gzr/templates/plan/failures/.gitkeep +1 -0
- data/lib/gzr/templates/plan/import/.gitkeep +1 -0
- data/lib/gzr/templates/plan/ls/.gitkeep +1 -0
- data/lib/gzr/templates/plan/rm/.gitkeep +1 -0
- data/lib/gzr/templates/plan/run/.gitkeep +1 -0
- data/lib/gzr/templates/query/run/.gitkeep +1 -0
- data/lib/gzr/templates/role/cat/.gitkeep +1 -0
- data/lib/gzr/templates/role/group_add/.gitkeep +1 -0
- data/lib/gzr/templates/role/group_ls/.gitkeep +1 -0
- data/lib/gzr/templates/role/group_rm/.gitkeep +1 -0
- data/lib/gzr/templates/role/ls/.gitkeep +1 -0
- data/lib/gzr/templates/role/rm/.gitkeep +1 -0
- data/lib/gzr/templates/role/user_add/.gitkeep +1 -0
- data/lib/gzr/templates/role/user_ls/.gitkeep +1 -0
- data/lib/gzr/templates/role/user_rm/.gitkeep +1 -0
- data/lib/gzr/templates/space/cat/.gitkeep +1 -0
- data/lib/gzr/templates/space/create/.gitkeep +1 -0
- data/lib/gzr/templates/space/export/.gitkeep +1 -0
- data/lib/gzr/templates/space/ls/.gitkeep +1 -0
- data/lib/gzr/templates/space/rm/.gitkeep +1 -0
- data/lib/gzr/templates/space/top/.gitkeep +1 -0
- data/lib/gzr/templates/space/tree/.gitkeep +1 -0
- data/lib/gzr/templates/user/cat/.gitkeep +1 -0
- data/lib/gzr/templates/user/disable/.gitkeep +1 -0
- data/lib/gzr/templates/user/enable/.gitkeep +1 -0
- data/lib/gzr/templates/user/ls/.gitkeep +1 -0
- data/lib/gzr/templates/user/me/.gitkeep +1 -0
- data/lib/gzr/version.rb +24 -0
- metadata +325 -0
@@ -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/dashboard'
|
26
|
+
|
27
|
+
module Gzr
|
28
|
+
module Commands
|
29
|
+
class Dashboard
|
30
|
+
class Rm < Gzr::Command
|
31
|
+
include Gzr::Dashboard
|
32
|
+
def initialize(dashboard,options)
|
33
|
+
super()
|
34
|
+
@dashboard = dashboard
|
35
|
+
@options = options
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute(input: $stdin, output: $stdout)
|
39
|
+
say_warning("options: #{@options.inspect}") if @options[:debug]
|
40
|
+
with_session do
|
41
|
+
delete_dashboard(@dashboard)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,87 @@
|
|
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 'subcommandbase'
|
25
|
+
|
26
|
+
module Gzr
|
27
|
+
module Commands
|
28
|
+
class Group < SubCommandBase
|
29
|
+
|
30
|
+
namespace :group
|
31
|
+
|
32
|
+
desc 'member_users GROUP_ID', 'List the users that are members of the given group'
|
33
|
+
method_option :help, aliases: '-h', type: :boolean,
|
34
|
+
desc: 'Display usage information'
|
35
|
+
method_option :fields, type: :string, default: 'id,email,last_name,first_name,personal_space_id,home_space_id',
|
36
|
+
desc: 'Fields to display'
|
37
|
+
method_option :plain, type: :boolean, default: false,
|
38
|
+
desc: 'print without any extra formatting'
|
39
|
+
method_option :csv, type: :boolean, default: false,
|
40
|
+
desc: 'output in csv format per RFC4180'
|
41
|
+
def member_users(group_id)
|
42
|
+
if options[:help]
|
43
|
+
invoke :help, ['member_users']
|
44
|
+
else
|
45
|
+
require_relative 'group/member_users'
|
46
|
+
Gzr::Commands::Group::MemberUsers.new(group_id,options).execute
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
desc 'member_groups GROUP_ID', 'List the groups that are members of the given group'
|
51
|
+
method_option :help, aliases: '-h', type: :boolean,
|
52
|
+
desc: 'Display usage information'
|
53
|
+
method_option :fields, type: :string, default: 'id,name,user_count,contains_current_user,externally_managed,external_group_id',
|
54
|
+
desc: 'Fields to display'
|
55
|
+
method_option :plain, type: :boolean, default: false,
|
56
|
+
desc: 'print without any extra formatting'
|
57
|
+
method_option :csv, type: :boolean, default: false,
|
58
|
+
desc: 'output in csv format per RFC4180'
|
59
|
+
def member_groups(group_id)
|
60
|
+
if options[:help]
|
61
|
+
invoke :help, ['member_groups']
|
62
|
+
else
|
63
|
+
require_relative 'group/member_groups'
|
64
|
+
Gzr::Commands::Group::MemberGroups.new(group_id,options).execute
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'ls', 'List the groups that are defined on this server'
|
69
|
+
method_option :help, aliases: '-h', type: :boolean,
|
70
|
+
desc: 'Display usage information'
|
71
|
+
method_option :fields, type: :string, default: 'id,name,user_count,contains_current_user,externally_managed,external_group_id',
|
72
|
+
desc: 'Fields to display'
|
73
|
+
method_option :plain, type: :boolean, default: false,
|
74
|
+
desc: 'print without any extra formatting'
|
75
|
+
method_option :csv, type: :boolean, default: false,
|
76
|
+
desc: 'output in csv format per RFC4180'
|
77
|
+
def ls(*)
|
78
|
+
if options[:help]
|
79
|
+
invoke :help, ['ls']
|
80
|
+
else
|
81
|
+
require_relative 'group/ls'
|
82
|
+
Gzr::Commands::Group::Ls.new(options).execute
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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/group'
|
26
|
+
require 'tty-table'
|
27
|
+
|
28
|
+
module Gzr
|
29
|
+
module Commands
|
30
|
+
class Group
|
31
|
+
class Ls < Gzr::Command
|
32
|
+
include Gzr::Group
|
33
|
+
def initialize(options)
|
34
|
+
super()
|
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 = query_all_groups(@options[:fields], "id")
|
42
|
+
begin
|
43
|
+
say_ok "No groups found"
|
44
|
+
return nil
|
45
|
+
end unless data && data.length > 0
|
46
|
+
|
47
|
+
table_hash = Hash.new
|
48
|
+
fields = field_names(@options[:fields])
|
49
|
+
table_hash[:header] = fields unless @options[:plain]
|
50
|
+
expressions = fields.collect { |fn| field_expression(fn) }
|
51
|
+
table_hash[:rows] = data.map do |row|
|
52
|
+
expressions.collect do |e|
|
53
|
+
eval "row.#{e}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
table = TTY::Table.new(table_hash)
|
57
|
+
alignments = fields.collect do |k|
|
58
|
+
next :left if k == "external_group_id"
|
59
|
+
(k =~ /(id|count)$/) ? :right : :left
|
60
|
+
end
|
61
|
+
begin
|
62
|
+
if @options[:csv] then
|
63
|
+
output.puts render_csv(table)
|
64
|
+
else
|
65
|
+
output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments)
|
66
|
+
end
|
67
|
+
end if table
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
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/group'
|
26
|
+
require 'tty-table'
|
27
|
+
|
28
|
+
module Gzr
|
29
|
+
module Commands
|
30
|
+
class Group
|
31
|
+
class MemberGroups < Gzr::Command
|
32
|
+
include Gzr::Group
|
33
|
+
def initialize(group_id,options)
|
34
|
+
super()
|
35
|
+
@group_id = group_id
|
36
|
+
@options = options
|
37
|
+
end
|
38
|
+
|
39
|
+
def execute(input: $stdin, output: $stdout)
|
40
|
+
say_warning(@options) if @options[:debug]
|
41
|
+
with_session do
|
42
|
+
data = query_group_groups(@group_id,@options[:fields])
|
43
|
+
begin
|
44
|
+
say_ok "No groups found"
|
45
|
+
return nil
|
46
|
+
end unless data && data.length > 0
|
47
|
+
|
48
|
+
table_hash = Hash.new
|
49
|
+
fields = field_names(@options[:fields])
|
50
|
+
table_hash[:header] = fields unless @options[:plain]
|
51
|
+
expressions = fields.collect { |fn| field_expression(fn) }
|
52
|
+
table_hash[:rows] = data.map do |row|
|
53
|
+
expressions.collect do |e|
|
54
|
+
eval "row.#{e}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
table = TTY::Table.new(table_hash)
|
58
|
+
alignments = fields.collect do |k|
|
59
|
+
next :left if k == "external_group_id"
|
60
|
+
(k =~ /(id|count)$/) ? :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)
|
67
|
+
end
|
68
|
+
end if table
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
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/group'
|
26
|
+
require 'tty-table'
|
27
|
+
|
28
|
+
module Gzr
|
29
|
+
module Commands
|
30
|
+
class Group
|
31
|
+
class MemberUsers < Gzr::Command
|
32
|
+
include Gzr::Group
|
33
|
+
def initialize(group_id,options)
|
34
|
+
super()
|
35
|
+
@group_id = group_id
|
36
|
+
@options = options
|
37
|
+
end
|
38
|
+
|
39
|
+
def execute(input: $stdin, output: $stdout)
|
40
|
+
say_warning(@options) if @options[:debug]
|
41
|
+
with_session do
|
42
|
+
data = query_group_users(@group_id,@options[:fields],"id")
|
43
|
+
begin
|
44
|
+
say_ok "No users found"
|
45
|
+
return nil
|
46
|
+
end unless data && data.length > 0
|
47
|
+
|
48
|
+
table_hash = Hash.new
|
49
|
+
fields = field_names(@options[:fields])
|
50
|
+
table_hash[:header] = fields unless @options[:plain]
|
51
|
+
expressions = fields.collect { |fn| field_expression(fn) }
|
52
|
+
table_hash[:rows] = data.map do |row|
|
53
|
+
expressions.collect do |e|
|
54
|
+
eval "row.#{e}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
table = TTY::Table.new(table_hash)
|
58
|
+
alignments = fields.collect do |k|
|
59
|
+
next :left if k == "external_group_id"
|
60
|
+
(k =~ /(id|count)$/) ? :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)
|
67
|
+
end
|
68
|
+
end if table
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,75 @@
|
|
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 'subcommandbase'
|
25
|
+
|
26
|
+
module Gzr
|
27
|
+
module Commands
|
28
|
+
class Look < SubCommandBase
|
29
|
+
|
30
|
+
namespace :look
|
31
|
+
|
32
|
+
desc 'rm LOOK_ID', 'Delete look given by LOOK_ID'
|
33
|
+
method_option :help, aliases: '-h', type: :boolean,
|
34
|
+
desc: 'Display usage information'
|
35
|
+
def rm(look_id)
|
36
|
+
if options[:help]
|
37
|
+
invoke :help, ['rm']
|
38
|
+
else
|
39
|
+
require_relative 'look/rm'
|
40
|
+
Gzr::Commands::Look::Rm.new(look_id, options).execute
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'import FILE DEST_SPACE_ID', 'Import a look from a file'
|
45
|
+
method_option :help, aliases: '-h', type: :boolean,
|
46
|
+
desc: 'Display usage information'
|
47
|
+
method_option :plain, type: :boolean,
|
48
|
+
desc: 'Provide minimal response information'
|
49
|
+
def import(file,dest_space_id)
|
50
|
+
if options[:help]
|
51
|
+
invoke :help, ['import']
|
52
|
+
else
|
53
|
+
require_relative 'look/import'
|
54
|
+
Gzr::Commands::Look::Import.new(file, dest_space_id, options).execute
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc 'cat LOOK_ID', 'Output the JSON representation of a look to the screen or a file'
|
59
|
+
method_option :help, aliases: '-h', type: :boolean,
|
60
|
+
desc: 'Display usage information'
|
61
|
+
method_option :dir, type: :string,
|
62
|
+
desc: 'Directory to store output file'
|
63
|
+
method_option :plans, type: :boolean,
|
64
|
+
desc: 'Include scheduled plans'
|
65
|
+
def cat(look_id)
|
66
|
+
if options[:help]
|
67
|
+
invoke :help, ['cat']
|
68
|
+
else
|
69
|
+
require_relative 'look/cat'
|
70
|
+
Gzr::Commands::Look::Cat.new(look_id, options).execute
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,55 @@
|
|
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/look'
|
26
|
+
require_relative '../../modules/plan'
|
27
|
+
require_relative '../../modules/filehelper'
|
28
|
+
|
29
|
+
module Gzr
|
30
|
+
module Commands
|
31
|
+
class Look
|
32
|
+
class Cat < Gzr::Command
|
33
|
+
include Gzr::Look
|
34
|
+
include Gzr::FileHelper
|
35
|
+
include Gzr::Plan
|
36
|
+
def initialize(look_id,options)
|
37
|
+
super()
|
38
|
+
@look_id = look_id
|
39
|
+
@options = options
|
40
|
+
end
|
41
|
+
|
42
|
+
def execute(input: $stdin, output: $stdout)
|
43
|
+
say_warning("options: #{@options.inspect}") if @options[:debug]
|
44
|
+
with_session do
|
45
|
+
data = query_look(@look_id)
|
46
|
+
data[:scheduled_plans] = query_scheduled_plans_for_look(@look_id,"all") if @options[:plans]
|
47
|
+
write_file(@options[:dir] ? "Look_#{data.id}_#{data.title}.json" : nil, @options[:dir],nil, output) do |f|
|
48
|
+
f.puts JSON.pretty_generate(data.to_attrs)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|