gazer 0.3.10 → 0.3.11
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/command.rb +9 -5
- data/lib/gzr/commands/alert/cat.rb +2 -2
- data/lib/gzr/commands/alert/ls.rb +2 -2
- data/lib/gzr/commands/alert/notifications.rb +2 -2
- data/lib/gzr/commands/attribute/cat.rb +3 -3
- data/lib/gzr/commands/attribute/create.rb +2 -2
- data/lib/gzr/commands/attribute/get_group_value.rb +4 -4
- data/lib/gzr/commands/attribute/import.rb +3 -3
- data/lib/gzr/commands/attribute/ls.rb +3 -3
- data/lib/gzr/commands/attribute/rm.rb +4 -4
- data/lib/gzr/commands/attribute/set_group_value.rb +4 -4
- data/lib/gzr/commands/connection/dialects.rb +4 -4
- data/lib/gzr/commands/connection/ls.rb +2 -2
- data/lib/gzr/commands/connection/test.rb +2 -2
- data/lib/gzr/commands/dashboard/import.rb +30 -30
- data/lib/gzr/commands/dashboard/mv.rb +1 -1
- data/lib/gzr/commands/folder/cat.rb +3 -3
- data/lib/gzr/commands/folder/create.rb +3 -3
- data/lib/gzr/commands/folder/export.rb +2 -2
- data/lib/gzr/commands/folder/ls.rb +3 -4
- data/lib/gzr/commands/folder/rm.rb +3 -3
- data/lib/gzr/commands/folder/top.rb +4 -4
- data/lib/gzr/commands/folder/tree.rb +11 -11
- data/lib/gzr/commands/group/ls.rb +3 -3
- data/lib/gzr/commands/group/member_groups.rb +3 -3
- data/lib/gzr/commands/group/member_users.rb +3 -3
- data/lib/gzr/commands/look/cat.rb +1 -1
- data/lib/gzr/commands/look/import.rb +5 -5
- data/lib/gzr/commands/look/mv.rb +1 -1
- data/lib/gzr/commands/look/rm.rb +1 -1
- data/lib/gzr/commands/model/ls.rb +4 -4
- data/lib/gzr/commands/model/set/ls.rb +2 -2
- data/lib/gzr/commands/permission/ls.rb +2 -2
- data/lib/gzr/commands/permission/set/ls.rb +2 -2
- data/lib/gzr/commands/plan/cat.rb +3 -3
- data/lib/gzr/commands/plan/disable.rb +3 -3
- data/lib/gzr/commands/plan/enable.rb +3 -3
- data/lib/gzr/commands/plan/failures.rb +12 -7
- data/lib/gzr/commands/plan/import.rb +5 -5
- data/lib/gzr/commands/plan/ls.rb +5 -5
- data/lib/gzr/commands/plan/run.rb +2 -2
- data/lib/gzr/commands/project/branch.rb +4 -4
- data/lib/gzr/commands/project/ls.rb +3 -3
- data/lib/gzr/commands/role/cat.rb +2 -2
- data/lib/gzr/commands/role/group_add.rb +2 -2
- data/lib/gzr/commands/role/group_ls.rb +3 -3
- data/lib/gzr/commands/role/group_rm.rb +2 -2
- data/lib/gzr/commands/role/ls.rb +3 -3
- data/lib/gzr/commands/role/user_add.rb +2 -2
- data/lib/gzr/commands/role/user_ls.rb +3 -3
- data/lib/gzr/commands/role/user_rm.rb +2 -2
- data/lib/gzr/commands/user/cat.rb +5 -3
- data/lib/gzr/commands/user/delete.rb +2 -1
- data/lib/gzr/commands/user/disable.rb +2 -1
- data/lib/gzr/commands/user/enable.rb +2 -1
- data/lib/gzr/commands/user/ls.rb +22 -11
- data/lib/gzr/commands/user/me.rb +6 -2
- data/lib/gzr/commands/user.rb +2 -0
- data/lib/gzr/modules/alert.rb +30 -17
- data/lib/gzr/modules/attribute.rb +24 -22
- data/lib/gzr/modules/connection.rb +10 -25
- data/lib/gzr/modules/dashboard.rb +86 -44
- data/lib/gzr/modules/folder.rb +20 -28
- data/lib/gzr/modules/group.rb +8 -10
- data/lib/gzr/modules/look.rb +23 -21
- data/lib/gzr/modules/model/set.rb +6 -6
- data/lib/gzr/modules/model.rb +14 -7
- data/lib/gzr/modules/permission/set.rb +2 -2
- data/lib/gzr/modules/permission.rb +2 -4
- data/lib/gzr/modules/plan.rb +36 -36
- data/lib/gzr/modules/project.rb +26 -21
- data/lib/gzr/modules/role.rb +48 -36
- data/lib/gzr/modules/session.rb +2 -2
- data/lib/gzr/modules/user.rb +52 -43
- data/lib/gzr/version.rb +1 -1
- metadata +2 -2
@@ -41,9 +41,11 @@ module Gzr
|
|
41
41
|
say_warning("options: #{@options.inspect}") if @options[:debug]
|
42
42
|
with_session do
|
43
43
|
data = query_user(@user_id,@options[:fields])
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
data = trim_user(data) if @options[:trim]
|
45
|
+
write_file(@options[:dir] ? "User_#{data[:id]}_#{data[:first_name]}_#{data[:last_name]}.json" : nil, @options[:dir],nil, output) do |f|
|
46
|
+
f.puts JSON.pretty_generate(data)
|
47
|
+
end if data
|
48
|
+
say_error "user #{@user_id} not found" unless data
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
4
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
# this software and associated documentation files (the "Software"), to deal in
|
@@ -39,6 +39,7 @@ module Gzr
|
|
39
39
|
say_warning(@options) if @options[:debug]
|
40
40
|
with_session do
|
41
41
|
data = delete_user(@user_id)
|
42
|
+
say_error "user #{@user_id} not found" unless data
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
4
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
# this software and associated documentation files (the "Software"), to deal in
|
@@ -39,6 +39,7 @@ module Gzr
|
|
39
39
|
say_warning(@options) if @options[:debug]
|
40
40
|
with_session do
|
41
41
|
data = update_user(@user_id, { :is_disabled=>true })
|
42
|
+
say_error "user #{@user_id} not found" unless data
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
4
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
# this software and associated documentation files (the "Software"), to deal in
|
@@ -39,6 +39,7 @@ module Gzr
|
|
39
39
|
say_warning(@options) if @options[:debug]
|
40
40
|
with_session do
|
41
41
|
data = update_user(@user_id, { :is_disabled=>false })
|
42
|
+
say_error "user #{@user_id} not found" unless data
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
data/lib/gzr/commands/user/ls.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
4
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
# this software and associated documentation files (the "Software"), to deal in
|
@@ -37,9 +37,19 @@ module Gzr
|
|
37
37
|
|
38
38
|
def execute(input: $stdin, output: $stdout)
|
39
39
|
say_warning(@options) if @options[:debug]
|
40
|
+
credentials = [
|
41
|
+
'credentials_email',
|
42
|
+
'credentials_embed',
|
43
|
+
'credentials_google',
|
44
|
+
'credentials_ldap',
|
45
|
+
'credentials_looker_openid',
|
46
|
+
'credentials_oidc',
|
47
|
+
'credentials_saml',
|
48
|
+
'credentials_totp'
|
49
|
+
]
|
40
50
|
with_session do
|
41
51
|
f = @options[:fields]
|
42
|
-
f
|
52
|
+
f = f + ',' + credentials.join(',') if @options[:"last-login"]
|
43
53
|
data = query_all_users(f, "id")
|
44
54
|
begin
|
45
55
|
say_ok "No users found"
|
@@ -50,17 +60,18 @@ module Gzr
|
|
50
60
|
fields = field_names(@options[:fields])
|
51
61
|
fields.unshift 'last_login' if @options[:"last-login"]
|
52
62
|
table_hash[:header] = fields unless @options[:plain]
|
53
|
-
expressions = fields.collect { |fn|
|
63
|
+
expressions = fields.collect { |fn| field_expression_hash(fn) }
|
54
64
|
table_hash[:rows] = data.map do |row|
|
55
65
|
expressions.collect do |e|
|
56
|
-
next(eval "row
|
57
|
-
|
58
|
-
row.
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
66
|
+
next(eval "row#{e}") unless (e == '&.fetch(:last_login,nil)')
|
67
|
+
credentials.collect do |c|
|
68
|
+
obj = row.fetch(c.to_sym)
|
69
|
+
if obj.kind_of?(Array)
|
70
|
+
obj.collect { |e| e.fetch(:logged_in_at,nil)&.to_s }
|
71
|
+
else
|
72
|
+
obj&.fetch(:logged_in_at,nil)&.to_s
|
73
|
+
end
|
74
|
+
end.flatten.compact.max
|
64
75
|
end
|
65
76
|
end
|
66
77
|
table = TTY::Table.new(table_hash)
|
data/lib/gzr/commands/user/me.rb
CHANGED
@@ -40,17 +40,20 @@ module Gzr
|
|
40
40
|
say_warning(@options) if @options[:debug]
|
41
41
|
with_session do
|
42
42
|
data = query_me(@options[:fields])
|
43
|
+
|
43
44
|
table_hash = Hash.new
|
44
45
|
fields = field_names(@options[:fields])
|
45
46
|
table_hash[:header] = fields unless @options[:plain]
|
46
|
-
expressions = fields.collect { |fn|
|
47
|
+
expressions = fields.collect { |fn| field_expression_hash(fn) }
|
47
48
|
table_hash[:rows] = [expressions.collect do |e|
|
48
|
-
eval "data
|
49
|
+
eval "data#{e}"
|
49
50
|
end]
|
51
|
+
|
50
52
|
table = TTY::Table.new(table_hash) if data
|
51
53
|
alignments = fields.collect do |k|
|
52
54
|
(k =~ /id$/) ? :right : :left
|
53
55
|
end
|
56
|
+
|
54
57
|
begin
|
55
58
|
if @options[:csv] then
|
56
59
|
output.puts render_csv(table)
|
@@ -58,6 +61,7 @@ module Gzr
|
|
58
61
|
output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
|
59
62
|
end
|
60
63
|
end if table
|
64
|
+
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
data/lib/gzr/commands/user.rb
CHANGED
@@ -72,6 +72,8 @@ module Gzr
|
|
72
72
|
desc: 'Fields to display'
|
73
73
|
method_option :dir, type: :string,
|
74
74
|
desc: 'Directory to store output file'
|
75
|
+
method_option :trim, type: :boolean,
|
76
|
+
desc: 'Trim output to minimal set of fields for later import'
|
75
77
|
def cat(user_id)
|
76
78
|
if options[:help]
|
77
79
|
invoke :help, ['cat']
|
data/lib/gzr/modules/alert.rb
CHANGED
@@ -26,7 +26,7 @@ module Gzr
|
|
26
26
|
def get_alert(alert_id)
|
27
27
|
data = nil
|
28
28
|
begin
|
29
|
-
data = @sdk.get_alert(alert_id)
|
29
|
+
data = @sdk.get_alert(alert_id).to_attrs
|
30
30
|
rescue LookerSDK::NotFound => e
|
31
31
|
# do nothing
|
32
32
|
rescue LookerSDK::Error => e
|
@@ -34,11 +34,11 @@ module Gzr
|
|
34
34
|
say_error e
|
35
35
|
raise
|
36
36
|
end
|
37
|
-
if data[:owner_id]
|
37
|
+
if data and data[:owner_id]
|
38
38
|
owner = get_user_by_id(data[:owner_id])
|
39
|
-
data[:owner] = owner.
|
39
|
+
data[:owner] = owner.select do |k,v|
|
40
40
|
[:email,:last_name,:first_name].include?(k) && !(v.nil? || v.empty?)
|
41
|
-
end
|
41
|
+
end if owner
|
42
42
|
end
|
43
43
|
data
|
44
44
|
end
|
@@ -57,7 +57,7 @@ module Gzr
|
|
57
57
|
req[:all_owners] = all_owners unless all_owners.nil?
|
58
58
|
req[:limit] = 64
|
59
59
|
loop do
|
60
|
-
page = @sdk.search_alerts(req)
|
60
|
+
page = @sdk.search_alerts(req).collect { |a| a.to_attrs }
|
61
61
|
data+=page
|
62
62
|
break unless page.length == req[:limit]
|
63
63
|
req[:offset] = (req[:offset] || 0) + req[:limit]
|
@@ -75,6 +75,10 @@ module Gzr
|
|
75
75
|
def follow_alert(alert_id)
|
76
76
|
begin
|
77
77
|
@sdk.follow_alert(alert_id)
|
78
|
+
rescue LookerSDK::NotFound => e
|
79
|
+
say_error "Alert #{alert_id} not found"
|
80
|
+
say_error e
|
81
|
+
raise
|
78
82
|
rescue LookerSDK::Error => e
|
79
83
|
say_error "Error following alert(#{alert_id})"
|
80
84
|
say_error e
|
@@ -85,8 +89,12 @@ module Gzr
|
|
85
89
|
def unfollow_alert(alert_id)
|
86
90
|
begin
|
87
91
|
@sdk.unfollow_alert(alert_id)
|
92
|
+
rescue LookerSDK::NotFound => e
|
93
|
+
say_error "Alert #{alert_id} not found"
|
94
|
+
say_error e
|
95
|
+
raise
|
88
96
|
rescue LookerSDK::Error => e
|
89
|
-
say_error "Error
|
97
|
+
say_error "Error unfollowing alert(#{alert_id})"
|
90
98
|
say_error e
|
91
99
|
raise
|
92
100
|
end
|
@@ -99,20 +107,26 @@ module Gzr
|
|
99
107
|
req[:disabled_reason] = disabled_reason unless disabled_reason.nil?
|
100
108
|
req[:is_public] = is_public unless is_public.nil?
|
101
109
|
req[:threshold] = threshold unless threshold.nil?
|
102
|
-
data = nil
|
103
110
|
begin
|
104
|
-
|
111
|
+
@sdk.update_alert_field(alert_id, req).to_attrs
|
112
|
+
rescue LookerSDK::NotFound => e
|
113
|
+
say_error "Alert #{alert_id} not found"
|
114
|
+
say_error e
|
115
|
+
raise
|
105
116
|
rescue LookerSDK::Error => e
|
106
117
|
say_error "Error calling update_alert_field(#{alert_id},#{JSON.pretty_generate(req)})"
|
107
118
|
say_error e
|
108
119
|
raise
|
109
120
|
end
|
110
|
-
data
|
111
121
|
end
|
112
122
|
|
113
123
|
def delete_alert(alert_id)
|
114
124
|
begin
|
115
125
|
@sdk.delete_alert(alert_id)
|
126
|
+
rescue LookerSDK::NotFound => e
|
127
|
+
say_error "Alert #{alert_id} not found"
|
128
|
+
say_error e
|
129
|
+
raise
|
116
130
|
rescue LookerSDK::Error => e
|
117
131
|
say_error "Error calling delete_alert(#{alert_id})"
|
118
132
|
say_error e
|
@@ -126,7 +140,7 @@ module Gzr
|
|
126
140
|
begin
|
127
141
|
req[:limit] = 64
|
128
142
|
loop do
|
129
|
-
page = @sdk.alert_notifications(req)
|
143
|
+
page = @sdk.alert_notifications(req).collect { |a| a.to_attrs }
|
130
144
|
data+=page
|
131
145
|
break unless page.length == req[:limit]
|
132
146
|
req[:offset] = (req[:offset] || 0) + req[:limit]
|
@@ -142,28 +156,27 @@ module Gzr
|
|
142
156
|
end
|
143
157
|
|
144
158
|
def read_alert_notification(notification_id)
|
145
|
-
data = nil
|
146
159
|
begin
|
147
|
-
|
160
|
+
@sdk.read_alert_notification(notification_id).to_attrs
|
161
|
+
rescue LookerSDK::NotFound => e
|
162
|
+
say_error "Alert notification #{notification_id} not found"
|
163
|
+
say_error e
|
164
|
+
raise
|
148
165
|
rescue LookerSDK::Error => e
|
149
166
|
say_error "Error calling read_alert_notification(#{notification_id})"
|
150
167
|
say_error e
|
151
168
|
raise
|
152
169
|
end
|
153
|
-
data.to_attrs
|
154
170
|
end
|
155
171
|
|
156
172
|
def create_alert(req)
|
157
|
-
data = nil
|
158
173
|
begin
|
159
|
-
|
174
|
+
@sdk.create_alert(req).to_attrs
|
160
175
|
rescue LookerSDK::Error => e
|
161
176
|
say_error "Error calling create_alert(#{JSON.pretty_generate(req)})"
|
162
177
|
say_error e
|
163
178
|
raise
|
164
179
|
end
|
165
|
-
data.to_attrs
|
166
180
|
end
|
167
|
-
|
168
181
|
end
|
169
182
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
4
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
# this software and associated documentation files (the "Software"), to deal in
|
@@ -24,89 +24,91 @@
|
|
24
24
|
module Gzr
|
25
25
|
module Attribute
|
26
26
|
def query_user_attribute(attr_id,fields=nil)
|
27
|
-
data = nil
|
28
27
|
begin
|
29
28
|
req = {}
|
30
29
|
req[:fields] = fields if fields
|
31
|
-
|
30
|
+
@sdk.user_attribute(attr_id,req).to_attrs
|
32
31
|
rescue LookerSDK::NotFound => e
|
33
|
-
#
|
32
|
+
say_error "User_attribute #{attr_id} not found"
|
33
|
+
say_error e
|
34
|
+
raise
|
34
35
|
rescue LookerSDK::Error => e
|
35
36
|
say_error "Error querying user_attribute(#{attr_id},#{JSON.pretty_generate(req)})"
|
36
37
|
say_error e
|
37
38
|
raise
|
38
39
|
end
|
39
|
-
data
|
40
40
|
end
|
41
41
|
|
42
42
|
def query_all_user_attributes(fields=nil, sorts=nil)
|
43
|
-
data = nil
|
44
43
|
begin
|
45
44
|
req = {}
|
46
45
|
req[:fields] = fields if fields
|
47
46
|
req[:sorts] = sorts if sorts
|
48
|
-
|
47
|
+
@sdk.all_user_attributes(req).collect { |a| a.to_attrs }
|
48
|
+
rescue LookerSDK::NotFound => e
|
49
|
+
[]
|
49
50
|
rescue LookerSDK::Error => e
|
50
51
|
say_error "Error querying all_user_attributes(#{JSON.pretty_generate(req)})"
|
51
52
|
say_error e
|
52
53
|
raise
|
53
54
|
end
|
54
|
-
data
|
55
55
|
end
|
56
56
|
|
57
57
|
def get_attribute_by_name(name, fields = nil)
|
58
|
-
data = query_all_user_attributes(fields).select {|a| a
|
58
|
+
data = query_all_user_attributes(fields).select {|a| a[:name] == name}
|
59
59
|
return nil if data.empty?
|
60
60
|
data.first
|
61
61
|
end
|
62
62
|
|
63
63
|
def get_attribute_by_label(label, fields = nil)
|
64
|
-
data = query_all_user_attributes(fields).select {|a| a
|
64
|
+
data = query_all_user_attributes(fields).select {|a| a[:label] == label}
|
65
65
|
return nil if data.empty?
|
66
66
|
data.first
|
67
67
|
end
|
68
68
|
|
69
69
|
def create_attribute(attr)
|
70
|
-
data = nil
|
71
70
|
begin
|
72
|
-
|
71
|
+
@sdk.create_user_attribute(attr).to_attrs
|
73
72
|
rescue LookerSDK::Error => e
|
74
73
|
say_error "Error creating user_attribute(#{JSON.pretty_generate(attr)})"
|
75
74
|
say_error e
|
76
75
|
raise
|
77
76
|
end
|
78
|
-
data
|
79
77
|
end
|
80
78
|
|
81
79
|
def update_attribute(id,attr)
|
82
|
-
data = nil
|
83
80
|
begin
|
84
|
-
|
81
|
+
@sdk.update_user_attribute(id,attr).to_attrs
|
82
|
+
rescue LookerSDK::NotFound => e
|
83
|
+
say_error "user_attribute #{id} not found"
|
84
|
+
say_error e
|
85
|
+
raise
|
85
86
|
rescue LookerSDK::Error => e
|
86
87
|
say_error "Error updating user_attribute(#{id},#{JSON.pretty_generate(attr)})"
|
87
88
|
say_error e
|
88
89
|
raise
|
89
90
|
end
|
90
|
-
data
|
91
91
|
end
|
92
92
|
|
93
93
|
def delete_user_attribute(id)
|
94
|
-
data = nil
|
95
94
|
begin
|
96
|
-
|
95
|
+
@sdk.delete_user_attribute(id)
|
96
|
+
rescue LookerSDK::NotFound => e
|
97
|
+
say_error "user_attribute #{id} not found"
|
98
|
+
say_error e
|
99
|
+
raise
|
97
100
|
rescue LookerSDK::Error => e
|
98
101
|
say_error "Error deleting user_attribute(#{id})"
|
99
102
|
say_error e
|
100
103
|
raise
|
101
104
|
end
|
102
|
-
data
|
103
105
|
end
|
104
106
|
|
105
107
|
def query_all_user_attribute_group_values(attr_id, fields=nil)
|
106
108
|
begin
|
107
109
|
req = {}
|
108
110
|
req[:fields] = fields if fields
|
109
|
-
return @sdk.all_user_attribute_group_values(attr_id,req)
|
111
|
+
return @sdk.all_user_attribute_group_values(attr_id,req).collect { |v| v.to_attrs }
|
110
112
|
rescue LookerSDK::NotFound => e
|
111
113
|
return nil
|
112
114
|
rescue LookerSDK::Error => e
|
@@ -117,7 +119,7 @@ module Gzr
|
|
117
119
|
end
|
118
120
|
|
119
121
|
def query_user_attribute_group_value(group_id, attr_id)
|
120
|
-
data = query_all_user_attribute_group_values(attr_id)&.select {|a| a
|
122
|
+
data = query_all_user_attribute_group_values(attr_id)&.select {|a| a[:group_id] == group_id}
|
121
123
|
return nil if data.nil? || data.empty?
|
122
124
|
data.first
|
123
125
|
end
|
@@ -141,7 +143,7 @@ module Gzr
|
|
141
143
|
keys_to_keep('update_user_attribute').include?(k) && !(name_used[k] == v)
|
142
144
|
end
|
143
145
|
|
144
|
-
return update_attribute(existing
|
146
|
+
return update_attribute(existing[:id],upd_attr)
|
145
147
|
else
|
146
148
|
new_attr = source.select do |k,v|
|
147
149
|
(keys_to_keep('create_user_attribute') - [:hidden_value_domain_whitelist]).include? k
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
4
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
# this software and associated documentation files (the "Software"), to deal in
|
@@ -25,50 +25,41 @@ module Gzr
|
|
25
25
|
module Connection
|
26
26
|
|
27
27
|
def query_all_connections(fields=nil)
|
28
|
-
data = nil
|
29
28
|
begin
|
30
|
-
|
29
|
+
@sdk.all_connections(fields ? {:fields=>fields} : nil ).collect { |e| e.to_attrs }
|
31
30
|
rescue LookerSDK::Error => e
|
32
31
|
say_error "Error querying all_connections({:fields=>\"#{fields}\"})"
|
33
32
|
say_error e
|
34
33
|
raise
|
35
34
|
end
|
36
|
-
data
|
37
35
|
end
|
38
36
|
|
39
37
|
def query_all_dialects(fields=nil)
|
40
|
-
data = nil
|
41
38
|
begin
|
42
|
-
|
39
|
+
@sdk.all_dialect_infos(fields ? {:fields=>fields} : nil ).collect { |e| e.to_attrs }
|
43
40
|
rescue LookerSDK::Error => e
|
44
41
|
say_error "Error querying all_dialect_infos({:fields=>\"#{fields}\"})"
|
45
42
|
say_error e
|
46
43
|
raise
|
47
44
|
end
|
48
|
-
data
|
49
45
|
end
|
50
46
|
|
51
47
|
def test_connection(name, tests=nil)
|
52
|
-
data = nil
|
53
|
-
|
54
48
|
if tests.nil?
|
55
49
|
connection = cat_connection(name)
|
56
|
-
if connection.nil?
|
57
|
-
return nil
|
58
|
-
end
|
50
|
+
return nil if connection.nil?
|
59
51
|
tests = connection[:dialect][:connection_tests]
|
60
52
|
end
|
61
53
|
|
62
54
|
begin
|
63
|
-
|
55
|
+
@sdk.test_connection(name, {}, tests: tests).collect { |e| e.to_attrs }
|
64
56
|
rescue LookerSDK::NotFound => e
|
65
|
-
return
|
57
|
+
return []
|
66
58
|
rescue LookerSDK::Error => e
|
67
59
|
say_error "Error executing test_connection(#{name},#{tests})"
|
68
60
|
say_error e
|
69
61
|
raise
|
70
62
|
end
|
71
|
-
data
|
72
63
|
end
|
73
64
|
|
74
65
|
def delete_connection(name)
|
@@ -84,21 +75,18 @@ module Gzr
|
|
84
75
|
end
|
85
76
|
|
86
77
|
def create_connection(body)
|
87
|
-
data = nil
|
88
78
|
begin
|
89
|
-
|
79
|
+
@sdk.create_connection(body).to_attrs
|
90
80
|
rescue LookerSDK::Error => e
|
91
81
|
say_error "Error executing create_connection(#{JSON.pretty_generate(body)})"
|
92
82
|
say_error e
|
93
83
|
raise
|
94
84
|
end
|
95
|
-
data
|
96
85
|
end
|
97
86
|
|
98
87
|
def update_connection(name,body)
|
99
|
-
data = nil
|
100
88
|
begin
|
101
|
-
|
89
|
+
@sdk.update_connection(name,body).to_attrs
|
102
90
|
rescue LookerSDK::NotFound => e
|
103
91
|
say_warning "Connection #{name} not found"
|
104
92
|
rescue LookerSDK::Error => e
|
@@ -106,21 +94,18 @@ module Gzr
|
|
106
94
|
say_error e
|
107
95
|
raise
|
108
96
|
end
|
109
|
-
data
|
110
97
|
end
|
111
98
|
|
112
99
|
def cat_connection(name)
|
113
|
-
data = nil
|
114
100
|
begin
|
115
|
-
|
101
|
+
@sdk.connection(name).to_attrs
|
116
102
|
rescue LookerSDK::NotFound => e
|
117
|
-
|
103
|
+
nil
|
118
104
|
rescue LookerSDK::Error => e
|
119
105
|
say_error "Error executing connection(#{name})"
|
120
106
|
say_error e
|
121
107
|
raise
|
122
108
|
end
|
123
|
-
data
|
124
109
|
end
|
125
110
|
|
126
111
|
def trim_connection(data)
|