looker-sdk 0.1.6 → 0.1.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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/lib/looker-sdk/client.rb +8 -6
  4. data/lib/looker-sdk/error.rb +1 -1
  5. data/lib/looker-sdk/version.rb +1 -1
  6. data/test/helper.rb +11 -5
  7. data/test/looker/swagger.json +42011 -1117
  8. data/test/looker/test_client.rb +19 -15
  9. data/test/looker/test_dynamic_client.rb +36 -34
  10. data/test/looker/test_dynamic_client_agent.rb +45 -12
  11. metadata +9 -40
  12. data/.github/scripts/wait_for_looker.sh +0 -35
  13. data/.github/workflows/release-metrics.yml +0 -44
  14. data/.github/workflows/release.yml +0 -47
  15. data/.github/workflows/ruby-ci.yml +0 -137
  16. data/.gitignore +0 -60
  17. data/.ruby-gemset +0 -1
  18. data/Gemfile +0 -22
  19. data/Gemfile.lock +0 -73
  20. data/Makefile +0 -81
  21. data/Rakefile +0 -38
  22. data/examples/.netrc +0 -1
  23. data/examples/add_delete_users.rb +0 -118
  24. data/examples/change_credentials_email_address_for_users.rb +0 -47
  25. data/examples/convert_look_to_lookless_tile.rb +0 -71
  26. data/examples/create_credentials_email_for_users.rb +0 -43
  27. data/examples/delete_all_user_sessions.rb +0 -39
  28. data/examples/delete_credentials_google_for_users.rb +0 -43
  29. data/examples/errors.rb +0 -47
  30. data/examples/generate_password_reset_tokens_for_users.rb +0 -43
  31. data/examples/ldap_roles_test.rb +0 -74
  32. data/examples/me.rb +0 -27
  33. data/examples/refresh_user_notification_addresses.rb +0 -34
  34. data/examples/roles_and_users_with_permission.rb +0 -46
  35. data/examples/sdk_setup.rb +0 -45
  36. data/examples/streaming_downloads.rb +0 -44
  37. data/examples/users_with_credentials_email.rb +0 -30
  38. data/examples/users_with_credentials_embed.rb +0 -33
  39. data/examples/users_with_credentials_google.rb +0 -30
  40. data/examples/users_with_credentials_google_without_credentials_email.rb +0 -30
  41. data/looker-sdk.gemspec +0 -32
  42. data/shell/.gitignore +0 -41
  43. data/shell/.netrc +0 -3
  44. data/shell/Gemfile +0 -6
  45. data/shell/readme.md +0 -18
  46. data/shell/shell.rb +0 -62
  47. data/shell.nix +0 -38
  48. data/test/fixtures/.netrc.template +0 -1
@@ -1,137 +0,0 @@
1
- name: Ruby-CI test matrix
2
-
3
- on:
4
- push:
5
- branches: [ main ]
6
- pull_request:
7
- branches: [ main ]
8
- workflow_dispatch:
9
- env:
10
- LOOKERSDK_BASE_URL: https://localhost:20000
11
- LOOKERSDK_VERIFY_SSL: false
12
- LOOKERSDK_API_VERSION: "4.0"
13
-
14
- jobs:
15
- setup:
16
- uses: looker-open-source/reusable-actions/.github/workflows/supported-versions.yml@main
17
-
18
- test:
19
- name: Ruby-CI ${{ matrix.ruby-version }}/${{ matrix.looker }}
20
- env:
21
- LOOKERSDK_CLIENT_ID: ${{ secrets.LOOKERSDK_CLIENT_ID }}
22
- LOOKERSDK_CLIENT_SECRET: ${{ secrets.LOOKERSDK_CLIENT_SECRET }}
23
- CI_REPORTS: results/Ruby-CI-ruby_${{ matrix.ruby-version }}_Looker_${{ matrix.looker }}
24
-
25
- needs: setup
26
- runs-on: ubuntu-latest
27
- strategy:
28
- matrix:
29
- ruby-version: [2.7.7]
30
- looker: ${{ fromJson(needs.setup.outputs.matrix_json) }}
31
-
32
- steps:
33
- - name: Cancel Previous Runs
34
- uses: styfle/cancel-workflow-action@0.11.0
35
- with:
36
- access_token: ${{ secrets.GITHUB_TOKEN }}
37
-
38
- - uses: actions/checkout@v3
39
-
40
- - name: Authenticate to Google Cloud
41
- uses: google-github-actions/auth@v1.0.0
42
- with:
43
- credentials_json: ${{ secrets.GCP_AR_READER_SA_KEY }}
44
- project_id: ${{ secrets.GCP_PROJECT_ID }}
45
- create_credentials_file: true
46
- export_environment_variables: true
47
-
48
- - name: Set up Cloud SDK
49
- uses: google-github-actions/setup-gcloud@v1.1.0
50
-
51
- - name: Authenticate Artifact Repository
52
- run: gcloud auth configure-docker us-west1-docker.pkg.dev --quiet
53
-
54
- - name: Pull and run Looker docker image
55
- # TODO: can we cache some layers of the image for faster download?
56
- # we probably don't want to cache the final image for IP security...
57
- run: |
58
- docker pull --quiet us-west1-docker.pkg.dev/cloud-looker-sdk-codegen-cicd/looker/${{ matrix.looker }}
59
- # set $LOOKER_OPTS to --no-ssl if we want to turn off ssl
60
- docker run --name looker-sdk-codegen-ci -d -p 10000:9999 -p 20000:19999 us-west1-docker.pkg.dev/cloud-looker-sdk-codegen-cicd/looker/${{ matrix.looker }}
61
- docker logs -f looker-sdk-codegen-ci --until=30s &
62
-
63
- - name: Set up Ruby ${{ matrix.ruby-version }}
64
- uses: ruby/setup-ruby@v1
65
- with:
66
- ruby-version: ${{ matrix.ruby-version }}
67
- bundler-cache: false
68
-
69
- - name: Install dependencies
70
- run: bundle install
71
-
72
- - name: Mock .netrc
73
- run: |
74
- mkdir -p test/fixtures
75
- echo "machine localhost" > test/fixtures/.netrc
76
- echo " login $LOOKERSDK_CLIENT_ID" >> test/fixtures/.netrc
77
- echo " password $LOOKERSDK_CLIENT_SECRET" >> test/fixtures/.netrc
78
- chmod 600 test/fixtures/.netrc
79
-
80
- - name: Check that Looker is ready
81
- run: |
82
- ${{ github.workspace }}/.github/scripts/wait_for_looker.sh
83
-
84
- - name: Report Failure
85
- run: |
86
- curl --request POST \
87
- --url https://api.github.com/repos/looker-open-source/sdk-codegen/check-runs \
88
- --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
89
- --header "content-type: application/json" \
90
- --header "Accept: application/vnd.github.v3+json" \
91
- --data '{
92
- "name": "Ruby-CI Tests",
93
- "head_sha": "${{ github.event.pull_request.head.sha || github.sha }}",
94
- "conclusion": "failure"
95
- }' \
96
- --fail
97
- if: failure()
98
-
99
- - name: Run tests
100
- run: bundle exec rake test --trace
101
-
102
- - name: remove mock .netrc
103
- if: ${{ always() }}
104
- run: |
105
- rm -f test/fixtures/.netrc
106
-
107
- - name: Upload ts unit test results
108
- if: ${{ always() }}
109
- uses: actions/upload-artifact@v3.1.2
110
- with:
111
- name: ruby-ci-test-results
112
- path: results/
113
-
114
- publish-test-results:
115
- needs: [test]
116
- if: success() || failure()
117
- runs-on: ubuntu-latest
118
-
119
- steps:
120
- - name: Download Artifacts
121
- uses: actions/download-artifact@v3
122
- with:
123
- name: ruby-ci-test-results
124
- path: artifacts
125
-
126
- - name: Publish Test Results
127
- uses: EnricoMi/publish-unit-test-result-action@v1.12
128
- with:
129
- # Cosmetic issue with `check_name` being associated to the wrong
130
- # workflow: https://github.com/EnricoMi/publish-unit-test-result-action/issues/12
131
- check_name: Ruby-CI Tests
132
- github_token: ${{ secrets.GITHUB_TOKEN }}
133
- report_individual_runs: true
134
- hide_comments: orphaned commits
135
- check_run_annotations: 'none'
136
- compare_to_earlier_commit: false
137
- files: 'artifacts/**/*.xml'
data/.gitignore DELETED
@@ -1,60 +0,0 @@
1
- # Numerous always-ignore extensions
2
- *.diff
3
- *.err
4
- *.orig
5
- *.log
6
- *.rej
7
- *.swo
8
- *.swp
9
- *.vi
10
- *~
11
- *.sass-cache
12
- *.iml
13
- .ruby-version
14
-
15
- # OS or Editor folders
16
- .DS_Store
17
- .cache
18
- .project
19
- .settings
20
- .tmproj
21
- nbproject
22
- Thumbs.db
23
-
24
- # Folders to ignore
25
- intermediate
26
- publish
27
- target
28
- .idea
29
- .direnv
30
- .env
31
- out
32
-
33
- # markdown previews
34
- *.md.html
35
-
36
- # bundler suggested ignores
37
- *.gem
38
- *.rbc
39
- .bundle
40
- .config
41
- .yardoc
42
- Gemfile.optional.lock
43
- InstalledFiles
44
- _yardoc
45
- coverage
46
- doc/
47
- lib/bundler/man
48
- pkg
49
- rdoc
50
- spec/reports
51
- test/tmp
52
- test/version_tmp
53
- tmp
54
- *.netrc
55
-
56
- # credentials for testing
57
- .netrc
58
-
59
- # test output
60
- /test/reports/**
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- looker-sdk-ruby
data/Gemfile DELETED
@@ -1,22 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- group :development do
4
- gem 'awesome_print', '~>1.6.1', :require => 'ap'
5
- gem 'redcarpet', '~>3.5.1', :platforms => :ruby
6
- end
7
-
8
- group :development, :test do
9
- gem 'rake', '~> 13.0.3'
10
- end
11
-
12
- group :test do
13
- # gem 'json', '~> 1.7', :platforms => [:jruby] look TODO needed?
14
- gem 'minitest', '~> 5.11.0'
15
- gem 'mocha', '~> 1.1.0'
16
- gem 'rack', '~> 2.2.7'
17
- gem 'rack-test', '~> 1'
18
- gem 'netrc', '~> 0.7.7'
19
- gem 'simplecov', '~> 0.7.1', :require => false
20
- end
21
-
22
- gemspec
data/Gemfile.lock DELETED
@@ -1,73 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- looker-sdk (0.1.6)
5
- faraday (>= 1.2, < 3.0)
6
- sawyer (~> 0.8)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- addressable (2.8.1)
12
- public_suffix (>= 2.0.2, < 6.0)
13
- awesome_print (1.6.1)
14
- builder (3.2.4)
15
- ci_reporter (2.1.0)
16
- builder (>= 2.1.2)
17
- rexml
18
- ci_reporter_minitest (1.0.0)
19
- ci_reporter (~> 2.0)
20
- minitest (~> 5.0)
21
- faraday (2.7.8)
22
- faraday-net_http (>= 2.0, < 3.1)
23
- ruby2_keywords (>= 0.0.4)
24
- faraday-multipart (1.0.4)
25
- multipart-post (~> 2)
26
- faraday-net_http (3.0.2)
27
- faraday-rack (2.0.0)
28
- faraday (~> 2.0)
29
- metaclass (0.0.4)
30
- minitest (5.11.3)
31
- mocha (1.1.0)
32
- metaclass (~> 0.0.1)
33
- multi_json (1.15.0)
34
- multipart-post (2.3.0)
35
- netrc (0.7.9)
36
- public_suffix (5.0.1)
37
- rack (2.2.7)
38
- rack-test (1.1.0)
39
- rack (>= 1.0, < 3)
40
- rake (13.0.6)
41
- redcarpet (3.5.1)
42
- rexml (3.2.5)
43
- ruby2_keywords (0.0.5)
44
- sawyer (0.9.2)
45
- addressable (>= 2.3.5)
46
- faraday (>= 0.17.3, < 3)
47
- simplecov (0.7.1)
48
- multi_json (~> 1.0)
49
- simplecov-html (~> 0.7.1)
50
- simplecov-html (0.7.1)
51
-
52
- PLATFORMS
53
- arm64-darwin-22
54
- x86_64-linux
55
-
56
- DEPENDENCIES
57
- awesome_print (~> 1.6.1)
58
- ci_reporter_minitest (~> 1.0)
59
- faraday (~> 2.7)
60
- faraday-multipart (~> 1.0)
61
- faraday-rack (~> 2)
62
- looker-sdk!
63
- minitest (~> 5.11.0)
64
- mocha (~> 1.1.0)
65
- netrc (~> 0.7.7)
66
- rack (~> 2.2.7)
67
- rack-test (~> 1)
68
- rake (~> 13.0.3)
69
- redcarpet (~> 3.5.1)
70
- simplecov (~> 0.7.1)
71
-
72
- BUNDLED WITH
73
- 2.4.14
data/Makefile DELETED
@@ -1,81 +0,0 @@
1
- #############################################################################################
2
- # The MIT License (MIT)
3
- #
4
- # Copyright (c) 2014 Zee Spencer
5
- # Copyright (c) 2020 Google LLC
6
- #
7
- # Permission is hereby granted, free of charge, to any person obtaining a copy
8
- # of this software and associated documentation files (the "Software"), to deal
9
- # in the Software without restriction, including without limitation the rights
10
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- # copies of the Software, and to permit persons to whom the Software is
12
- # furnished to do so, subject to the following conditions:
13
- #
14
- # The above copyright notice and this permission notice shall be included in all
15
- # copies or substantial portions of the Software.
16
- #
17
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- # SOFTWARE.
24
- #############################################################################################
25
-
26
- # Allows running (and re-running) of tests against several ruby versions,
27
- # assuming you use rbenv instead of rvm.
28
-
29
- # Uses pattern rules (task-$:) and automatic variables ($*).
30
- # Pattern rules: http://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_10.html#SEC98
31
- # Automatic variables: http://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_10.html#SEC101
32
-
33
- # Rbenv-friendly version identifiers for supported Rubys
34
- 25_version = 2.5.7
35
- jruby_92160_version = jruby-9.2.16.0
36
-
37
- # The ruby version for use in a given rule.
38
- # Requires a matched pattern rule and a supported ruby version.
39
- #
40
- # Given a pattern rule defined as "install-ruby-%"
41
- # When the rule is ran as "install-ruby-193"
42
- # Then the inner addsuffix call evaluates to "193_version"
43
- # And given_ruby_version becomes "1.9.3-p551"
44
- given_ruby_version = $($(addsuffix _version, $*))
45
-
46
- # Instruct rbenv on which Ruby version to use when running a command.
47
- # Requires a pattern rule and a supported ruby version.
48
- #
49
- # Given a pattern rule defined as "test-%"
50
- # When the rule is ran as "test-187"
51
- # Then with_given_ruby becomes "RBENV_VERSION=1.8.7-p375"
52
- with_given_ruby = RBENV_VERSION=$(given_ruby_version)
53
-
54
- # Runs tests for all supported ruby versions.
55
- test: test-25 test-jruby_92160
56
-
57
- # Runs tests against a specific ruby version
58
- test-%:
59
- rm -f Gemfile.lock
60
- $(with_given_ruby) bundle install --quiet
61
- $(with_given_ruby) bundle exec rake
62
-
63
- # Installs all ruby versions and their gems
64
- install: install-25 install-jruby_92160
65
-
66
- # Install a particular ruby version
67
- install-ruby-%:
68
- rm -f Gemfile.lock
69
- rbenv install -s $(given_ruby_version)
70
-
71
- # Install gems into a specific ruby version
72
- install-gems-%:
73
- rm -f Gemfile.lock
74
- $(with_given_ruby) gem update --system
75
- $(with_given_ruby) gem install bundler
76
- $(with_given_ruby) bundle install
77
-
78
- # Installs a specific ruby version and it's gems
79
- # At the bottom so it doesn't match install-gems and install-ruby tasks.
80
- install-%:
81
- make install-ruby-$* install-gems-$*
data/Rakefile DELETED
@@ -1,38 +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 "bundler/gem_tasks"
26
-
27
- require "rake/testtask"
28
- require 'ci/reporter/rake/minitest'
29
-
30
- task :minitest => 'ci:setup:minitest'
31
- task test: 'minitest'
32
- Rake::TestTask.new do |t|
33
- t.libs << "test"
34
- t.test_files = FileList["test/**/test_*.rb"]
35
- t.verbose = true
36
- end
37
-
38
- task :default => :test
data/examples/.netrc DELETED
@@ -1 +0,0 @@
1
- machine localhost login xyYBxzSPYYP29wQJ3Q5k password VY5sj6z5qjxZsvdvf8yNvKcQ
@@ -1,118 +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
- Joe Williams, joe@mycoolcompany.com, Admin
33
- Jane Schumacher, jane@mycoolcompany.com, User SuperDeveloper
34
- Jim Watson, jim@mycoolcompany.com, User
35
- Jim Wu, jimw@mycoolcompany.com, User
36
-
37
- ENDMARK
38
-
39
- ############################################################################################
40
-
41
- def create_users(lines)
42
- # create a hash to use below. role.name => role.id
43
- roles_by_name = Hash[ sdk.all_roles.map{|role| [role.name, role.id] } ]
44
-
45
- # for each line, try to create that user with name, email credentials, and roles
46
- lines.each_line do |line|
47
- line.strip!
48
- next if line.empty?
49
-
50
- # quicky parsing: note lack of error handling!
51
-
52
- name, email, roles = line.split(',')
53
- fname, lname = name.split(' ')
54
- [fname, lname, email, roles].each(&:strip!)
55
-
56
- role_ids = []
57
- roles.split(' ').each do |role_name|
58
- if id = roles_by_name[role_name]
59
- role_ids << id
60
- else
61
- raise "#{role_name} does not exist. ABORTING!"
62
- end
63
- end
64
-
65
- # for display
66
- user_info = "#{fname} #{lname} <#{email}> as #{roles}"
67
-
68
- begin
69
- # call the SDK to create user with names, add email/password login credentials, set user roles
70
- user = sdk.create_user({:first_name => fname, :last_name => lname})
71
- sdk.create_user_credentials_email(user.id, {:email => email})
72
- sdk.set_user_roles(user.id, role_ids)
73
- puts "Created user: #{user_info}"
74
- rescue LookerSDK::Error => e
75
- # if any errors occur above then 'undo' by deleting the given user (if we got that far)
76
- sdk.delete_user(user.id) if user
77
- puts "FAILED to create user: #{user_info} (#{e.message}) "
78
- end
79
- end
80
- end
81
-
82
- ##################################################################
83
-
84
- def delete_users(lines)
85
- # create a hash to use below. user.credentials_email.email => user.id
86
- users_by_email = Hash[ sdk.all_users.map{|user| [user.credentials_email.email, user.id] if user.credentials_email}.compact ]
87
-
88
- lines.each_line do |line|
89
- line.strip!
90
- next if line.empty?
91
-
92
- # quicky parsing: note lack of error handling!
93
- name, email, roles = line.split(',')
94
- fname, lname = name.split(' ')
95
- [fname, lname, email, roles].each(&:strip!)
96
-
97
- # for display
98
- user_info = "#{fname} #{lname} <#{email}>"
99
-
100
- begin
101
- if id = users_by_email[email]
102
- sdk.delete_user(id)
103
- puts "Deleted user: #{user_info}>"
104
- else
105
- puts "Did not find user: #{user_info}>"
106
- end
107
- rescue LookerSDK::Error => e
108
- puts "FAILED to delete user: #{user_info} (#{e.message}) "
109
- end
110
- end
111
- end
112
-
113
- ##################################################################
114
-
115
- # call the methods
116
- create_users(user_list)
117
- puts
118
- delete_users(user_list)
@@ -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
- users = Hash[
28
- sdk.all_users(:fields => 'id, credentials_email').
29
- map{|u| [u.credentials_email.email, u.id] if u.credentials_email }.compact
30
- ]
31
-
32
- $stdin.each_line do |line|
33
- line.chomp!
34
-
35
- _, old_email, new_email = line.split(',', 3).map(&:strip)
36
-
37
- if id = users[old_email]
38
- begin
39
- sdk.update_user_credentials_email(id, {:email => new_email})
40
- puts "Successfully changed '#{old_email}' => '#{new_email}'"
41
- rescue => e
42
- puts "FAILED to changed '#{old_email}' => '#{new_email}' because of: #{e.class}:#{e.message}"
43
- end
44
- else
45
- puts "FAILED: Could not find user with email '#{old_email}'"
46
- end
47
- end
@@ -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