looker-sdk 0.1.7 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/lib/looker-sdk/client/dynamic.rb +5 -3
  4. data/lib/looker-sdk/client.rb +16 -7
  5. data/lib/looker-sdk/default.rb +1 -1
  6. data/lib/looker-sdk/error.rb +8 -2
  7. data/lib/looker-sdk/version.rb +1 -1
  8. data/lib/looker-sdk.rb +2 -1
  9. data/test/helper.rb +10 -4
  10. data/test/looker/swagger.json +42011 -1117
  11. data/test/looker/test_client.rb +19 -15
  12. data/test/looker/test_dynamic_client.rb +36 -34
  13. data/test/looker/test_dynamic_client_agent.rb +45 -12
  14. data/test/looker/test_inline_query.rb +97 -0
  15. metadata +14 -45
  16. data/.github/CODEOWNERS +0 -1
  17. data/.github/scripts/wait_for_looker.sh +0 -35
  18. data/.github/workflows/release-metrics.yml +0 -44
  19. data/.github/workflows/release.yml +0 -47
  20. data/.github/workflows/ruby-ci.yml +0 -140
  21. data/.gitignore +0 -60
  22. data/.ruby-gemset +0 -1
  23. data/Gemfile +0 -22
  24. data/Gemfile.lock +0 -73
  25. data/Makefile +0 -81
  26. data/Rakefile +0 -38
  27. data/examples/.netrc +0 -1
  28. data/examples/add_delete_users.rb +0 -118
  29. data/examples/change_credentials_email_address_for_users.rb +0 -47
  30. data/examples/convert_look_to_lookless_tile.rb +0 -71
  31. data/examples/create_credentials_email_for_users.rb +0 -43
  32. data/examples/delete_all_user_sessions.rb +0 -39
  33. data/examples/delete_credentials_google_for_users.rb +0 -43
  34. data/examples/errors.rb +0 -47
  35. data/examples/generate_password_reset_tokens_for_users.rb +0 -43
  36. data/examples/ldap_roles_test.rb +0 -74
  37. data/examples/me.rb +0 -27
  38. data/examples/refresh_user_notification_addresses.rb +0 -34
  39. data/examples/roles_and_users_with_permission.rb +0 -46
  40. data/examples/sdk_setup.rb +0 -45
  41. data/examples/streaming_downloads.rb +0 -44
  42. data/examples/users_with_credentials_email.rb +0 -30
  43. data/examples/users_with_credentials_embed.rb +0 -33
  44. data/examples/users_with_credentials_google.rb +0 -30
  45. data/examples/users_with_credentials_google_without_credentials_email.rb +0 -30
  46. data/looker-sdk.gemspec +0 -32
  47. data/shell/.gitignore +0 -41
  48. data/shell/.netrc +0 -3
  49. data/shell/Gemfile +0 -6
  50. data/shell/Gemfile.lock +0 -60
  51. data/shell/readme.md +0 -18
  52. data/shell/shell.rb +0 -62
  53. data/shell.nix +0 -38
  54. data/test/fixtures/.netrc.template +0 -1
@@ -1,71 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require 'looker-sdk'
26
- require 'json'
27
-
28
- # Note that this example requires API 3.1 or greater for new dashboard element manipulation functions
29
-
30
- sdk = LookerSDK::Client.new(
31
- :client_id => ENV['KEY'],
32
- :client_secret => ENV['SECRET'],
33
-
34
- # API 4.0 URL would look like: https://myhost.com:19999/api/4.0
35
- :api_endpoint => ENV['URL']
36
- )
37
- #Set the dashboard here.
38
- dashboard_id = ENV['DASHBOARD_ID']
39
- # Get the dashboard we want to convert and get elements
40
-
41
- dashboard = sdk.dashboard(dashboard_id).to_h
42
-
43
- elements = dashboard[:dashboard_elements]
44
- if dashboard then puts "Dashboard has been received" end
45
-
46
- for element in elements
47
-
48
- # Extract important IDs
49
-
50
- element_id = element[:id]
51
- look_id = element[:look_id]
52
- query_id = element[:query_id]
53
-
54
- # If look_id is non-null and query_id is null, tile is a Look-based tile
55
- if look_id && query_id.nil?
56
-
57
- # Get the Look so we can get its query_id
58
- look = sdk.look(look_id).to_h
59
- query_id = look[:query_id]
60
-
61
- # Update the tile to have a null look_id and update query_id
62
- sdk.update_dashboard_element(element_id,
63
- {
64
- "look_id": nil,
65
- "query_id": query_id,
66
- }
67
- )
68
- puts "Tile #{element_id.to_s} has been updated in Dashboard #{dashboard_id.to_s}"
69
-
70
- end
71
- end
@@ -1,43 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- $stdin.each_line do |line|
28
- line.chomp!
29
-
30
- id, email = line.split(',', 2).map(&:strip)
31
-
32
- begin
33
- user = sdk.user(id)
34
- if user.credentials_email
35
- puts "Error: User with id '#{id}' Already has credentials_email"
36
- else
37
- sdk.create_user_credentials_email(id, {:email => email})
38
- puts "Success: Created credentials_email for User with id '#{id}' and email '#{email}'"
39
- end
40
- rescue LookerSDK::NotFound
41
- puts "Error: User with id '#{id}' Not found"
42
- end
43
- end
@@ -1,39 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- total_count = 0
28
- sdk.all_users(:fields => 'id, display_name').each do |user|
29
- count = 0
30
- sdk.all_user_sessions(user.id, :fields => 'id').each do |session|
31
- sdk.delete_user_session(user.id, session.id)
32
- count += 1
33
- end
34
- puts "Deleted #{count} sessions for #{user.id} #{user.display_name}"
35
- total_count += count
36
- end
37
- puts "Deleted #{total_count} sessions"
38
-
39
-
@@ -1,43 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- $stdin.each_line do |line|
28
- line.chomp!
29
-
30
- id, _ = line.split(',', 2).map(&:strip)
31
-
32
- begin
33
- user = sdk.user(id)
34
- if user.credentials_google
35
- sdk.delete_user_credentials_google(id)
36
- puts "Success: Deleted credentials_google for User with id '#{id}'"
37
- else
38
- puts "Error: User with id '#{id}' Does not have credentials_google"
39
- end
40
- rescue LookerSDK::NotFound
41
- puts "Error: User with id '#{id}' Not found"
42
- end
43
- end
data/examples/errors.rb DELETED
@@ -1,47 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- begin
28
- puts sdk.validate_theme({}).inspect
29
- rescue LookerSDK::Error => e
30
- puts e
31
- end
32
-
33
- puts "\n\n"
34
-
35
- begin
36
- puts sdk.connection("foo").inspect
37
- rescue LookerSDK::Error => e
38
- puts e
39
- end
40
-
41
- puts "\n\n"
42
-
43
- begin
44
- puts sdk.run_look(1,"foo").inspect
45
- rescue LookerSDK::Error => e
46
- puts e
47
- end
@@ -1,43 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- $stdin.each_line do |line|
28
- line.chomp!
29
-
30
- id = line.split(',', 2).map(&:strip).first
31
-
32
- begin
33
- user = sdk.user(id)
34
- if user.credentials_email
35
- token = sdk.create_user_credentials_email_password_reset(id)
36
- puts "#{token.email},#{token.password_reset_url}"
37
- else
38
- puts "Error: User with id '#{id}' Does not have credentials_email"
39
- end
40
- rescue LookerSDK::NotFound
41
- puts "Error: User with id '#{id}' Not found"
42
- end
43
- end
@@ -1,74 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- ############################################################################################
28
- # simulate a list read from file
29
-
30
- user_list = <<-ENDMARK
31
-
32
- mward
33
- mwhite
34
- missing
35
-
36
- ENDMARK
37
-
38
- ############################################################################################
39
- # helpers
40
-
41
- def ldap_config
42
- @ldap_config ||= sdk.ldap_config.to_attrs
43
- end
44
-
45
- def groups_map_for_config
46
- @groups_map_for_config ||= ldap_config[:groups].map do |group|
47
- {:name => group[:name], :role_ids => group[:roles].map{|role| role[:id]}}
48
- end
49
- end
50
-
51
- def test_ldap_user(user)
52
- params = ldap_config.merge({:groups_with_role_ids => groups_map_for_config, :test_ldap_user => user})
53
- sdk.test_ldap_config_user_info(params)
54
- end
55
-
56
- ############################################################################################
57
- # process the list and puts results
58
-
59
- user_list.each_line do |user|
60
- user.strip!
61
- next if user.empty?
62
-
63
- puts "'#{user}' ..."
64
-
65
- result = test_ldap_user(user).to_attrs
66
- if result[:status] == 'success'
67
- puts "Success"
68
- puts result[:user]
69
- else
70
- puts "FAILURE"
71
- puts result
72
- end
73
- puts
74
- end
data/examples/me.rb DELETED
@@ -1,27 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- puts sdk.me.inspect
@@ -1,34 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- sdk.all_users(:fields => 'id,email').each do |user|
28
- new_user = sdk.update_user(user.id, {})
29
- if user.email == new_user.email
30
- puts "No Change for #{user.id}"
31
- else
32
- puts "Refreshed #{user.id}. Old email '#{user.email}'. Refreshed email: '#{new_user.email}'."
33
- end
34
- end
@@ -1,46 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
-
28
- while true do
29
- print "permission [,model]? "
30
- permission_name, model_name = gets.chomp.split(',')
31
-
32
- break if permission_name.empty?
33
-
34
- roles = sdk.all_roles.select do |role|
35
- (role.permission_set.all_access || role.permission_set.permissions.join(',').include?(permission_name)) &&
36
- (model_name.nil? || role.model_set.all_access || role.model_set.models.join(',').include?(model_name))
37
- end
38
-
39
- puts "Roles: #{roles.map(&:name).join(', ')}"
40
-
41
- role_ids = roles.map(&:id)
42
- users = sdk.all_users.select {|user| (user.role_ids & role_ids).any?}
43
- user_names = users.map{|u| "#{u.id}#{" ("+u.display_name+")" if u.display_name}"}.join(', ')
44
-
45
- puts "Users: #{user_names}"
46
- end
@@ -1,45 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require 'rubygems'
26
- require 'bundler/setup'
27
-
28
- require 'looker-sdk'
29
-
30
- # common file used by various examples to setup and init sdk
31
-
32
- def sdk
33
- @sdk ||= LookerSDK::Client.new(
34
- :netrc => true,
35
- :netrc_file => "./.netrc",
36
-
37
- # use my local looker with self-signed cert
38
- :connection_options => {:ssl => {:verify => false}},
39
- :api_endpoint => "https://localhost:19999/api/4.0",
40
-
41
- # use a real looker the way you are supposed to!
42
- # :connection_options => {:ssl => {:verify => true}},
43
- # :api_endpoint => "https://mycoolcompany.looker.com:19999/api/4.0",
44
- )
45
- end
@@ -1,44 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- # This snippet shows how to download sdk responses using http streaming.
28
- # Streaming processes the download in chunks which you can write
29
- # to file or perform other processing on without having to wait for the entire
30
- # response to download first. Streaming can be very memory efficient
31
- # for handling large result sets compared to just downloading the whole thing into
32
- # a Ruby object in memory.
33
-
34
- def run_look_to_file(look_id, filename, format, opts = {})
35
- File.open(filename, 'w') do |file|
36
- sdk.run_look(look_id, format, opts) do |data, progress|
37
- file.write(data)
38
- puts "Wrote #{data.length} bytes of #{progress.length} total"
39
- end
40
- end
41
- end
42
-
43
- # Replace the look id (38) with the id of your actual look
44
- run_look_to_file(38, 'out.csv', 'csv', limit: 10000)
@@ -1,30 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- users = sdk.all_users(:fields => 'id, is_disabled, credentials_email').
28
- select {|u| !u.is_diabled && u.credentials_email && u.credentials_email.email}
29
-
30
- users.each {|u| puts "#{u.id},#{u.credentials_email.email}"}
@@ -1,33 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- users = sdk.all_users(fields:'id, is_disabled, display_name, credentials_embed').map do |u|
28
- next if u.is_diabled || u.credentials_embed.empty?
29
- creds = u.credentials_embed.first
30
- [u.id, u.display_name, creds.external_user_id, creds.external_group_id, creds.logged_in_at]
31
- end.compact
32
-
33
- users.each{|u| p u}
@@ -1,30 +0,0 @@
1
- ############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2022 Looker Data Sciences, Inc.
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the "Software"), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in
14
- # all copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- # THE SOFTWARE.
23
- ############################################################################################
24
-
25
- require './sdk_setup'
26
-
27
- users = sdk.all_users(:fields => 'id, credentials_google').
28
- select {|u| u.credentials_google}
29
-
30
- users.each {|u| puts "#{u.id},#{u.credentials_google.email}"}