looker-sdk 0.0.7 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 34b933e51a973a90071e6232bf2146b380243f4f
4
- data.tar.gz: 2bd895405ba590ac8c1c5e9a34841c90270b3c51
2
+ SHA256:
3
+ metadata.gz: 1cc7e235cdbbb66fc48144899702643ac22bffcb5b9a9308aff125da08094b3b
4
+ data.tar.gz: 8517bfd25b5330d27486b579c4d8c113786c72553256582f0b4fd7d7ddd1e2f4
5
5
  SHA512:
6
- metadata.gz: e5998b8fa8b0daa43a9e55b8b65d0025b39d030b7593b08daad280c31a99ba7acfbf1fd36c73234be1ccc529ac1d4945db7efdb7860bd02b70db59c7e8086aa1
7
- data.tar.gz: 0e3f84e946e5f6dfa09413188971736ba96a49dbd85c63adcb0328cbdb8f28f2f5acba1d5715b8b1fb7abddb02add35730323ea8afbf97084c22403354f2c264
6
+ metadata.gz: 1e189a7bbfc601e3ba9cbd11826fd80494e6218caf68f2a12d1ba2d281dd66f8995eadf04397d1d814a22c0e5eafdf5045e9dd4064f92b2b0bb3064d7122d0ef
7
+ data.tar.gz: 4e17c8adec821082d10556b2d4122f17c21cbc5db58b3d4f5b4cefdb9022542eab77428256793180d5ab1dda6dccf6dc4604f803a50fa6a8e2c95f9dee698c24
@@ -0,0 +1,35 @@
1
+ #!/bin/sh
2
+
3
+ check_looker() {
4
+ status=$(curl --silent --insecure --write "%{http_code}" \
5
+ --data "client_id=$LOOKERSDK_CLIENT_ID&client_secret=$LOOKERSDK_CLIENT_SECRET"\
6
+ $LOOKERSDK_BASE_URL/api/${LOOKERSDK_API_VERSION:-4.0}/login\
7
+ -o /dev/null)
8
+ }
9
+
10
+ MAX_RETRIES=160
11
+ ATTEMPTS=1
12
+ status=0
13
+ check_looker
14
+ while [ $status -ne 200 ];
15
+ do
16
+ RETRY_MSG="after $ATTEMPTS attempts: $MAX_RETRIES retries remaining."
17
+ if [ $ATTEMPTS -ge $MAX_RETRIES ];
18
+ then
19
+ echo 'Looker took too long to start'
20
+ exit 1
21
+ else
22
+ if [ $status -ne 0 ];
23
+ then
24
+ echo "Received status($status) from Looker $RETRY_MSG"
25
+ else
26
+ echo "Looker server connection rejected $RETRY_MSG"
27
+ fi
28
+ fi
29
+
30
+ sleep 2
31
+ ATTEMPTS=$(( $ATTEMPTS + 1 ))
32
+ check_looker
33
+ done
34
+ echo "Looker ready after $ATTEMPTS attempts"
35
+ exit 0
@@ -0,0 +1,47 @@
1
+ # .github/workflows/release.yml
2
+
3
+ name: release
4
+
5
+ on:
6
+ push:
7
+ branches:
8
+ - main
9
+
10
+ jobs:
11
+ release-please:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: GoogleCloudPlatform/release-please-action@v2
15
+ id: release
16
+ with:
17
+ release-type: ruby
18
+ package-name: looker-sdk
19
+ bump-minor-pre-major: true
20
+ bump-patch-for-minor-pre-major: true
21
+ version-file: "lib/looker-sdk/version.rb"
22
+ token: ${{ secrets.LOS_AUTO_BOT_RP_TOKEN }}
23
+ # Checkout code if release was created
24
+ - uses: actions/checkout@v2
25
+ if: ${{ steps.release.outputs.release_created }}
26
+ # Setup ruby if a release was created
27
+ - uses: ruby/setup-ruby@v1
28
+ with:
29
+ ruby-version: 2.5.8
30
+ if: ${{ steps.release.outputs.release_created }}
31
+ # Bundle install
32
+ - run: bundle install
33
+ if: ${{ steps.release.outputs.release_created }}
34
+ # Publish
35
+ - name: publish gem
36
+ run: |
37
+ mkdir -p $HOME/.gem
38
+ touch $HOME/.gem/credentials
39
+ chmod 0600 $HOME/.gem/credentials
40
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
41
+ gem build *.gemspec
42
+ gem push *.gem
43
+ env:
44
+ # Make sure to update the secret name
45
+ # if yours isn't named RUBYGEMS_AUTH_TOKEN
46
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
47
+ if: ${{ steps.release.outputs.release_created }}
@@ -0,0 +1,60 @@
1
+ name: Ruby-CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ env:
10
+ LOOKERSDK_BASE_URL: https://localhost:20000
11
+ LOOKERSDK_VERIFY_SSL: false
12
+ LOOKERSDK_API_VERSION: "4.0"
13
+ LOOKERSDK_CLIENT_ID: ${{ secrets.LOOKERSDK_CLIENT_ID__21_20 }}
14
+ LOOKERSDK_CLIENT_SECRET: ${{ secrets.LOOKERSDK_CLIENT_SECRET__21_20 }}
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: [2.5.8]
23
+
24
+ steps:
25
+ - uses: actions/checkout@v2
26
+
27
+ - name: Set up Cloud SDK
28
+ uses: google-github-actions/setup-gcloud@v0.2.0
29
+ with:
30
+ project_id: ${{ secrets.GCP_PROJECT_ID }}
31
+ service_account_key: ${{ secrets.GCP_AR_READER_SA_KEY }}
32
+ export_default_credentials: true
33
+
34
+ - name: Authenticate Artifact Repository
35
+ run: gcloud auth configure-docker us-west1-docker.pkg.dev --quiet
36
+
37
+ - name: Pull and run Looker docker image
38
+ # TODO: can we cache some layers of the image for faster download?
39
+ # we probably don't want to cache the final image for IP security...
40
+ run: |
41
+ docker pull --quiet us-west1-docker.pkg.dev/cloud-looker-sdk-codegen-cicd/looker/21_20
42
+ # set $LOOKER_OPTS to --no-ssl if we want to turn off ssl
43
+ 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/21_20
44
+ docker logs -f looker-sdk-codegen-ci --until=30s &
45
+
46
+ - name: Set up Ruby ${{ matrix.ruby-version }}
47
+ uses: ruby/setup-ruby@v1
48
+ with:
49
+ ruby-version: ${{ matrix.ruby-version }}
50
+ bundler-cache: true
51
+
52
+ - name: Install dependencies
53
+ run: bundle install
54
+
55
+ - name: Check that Looker is ready
56
+ run: |
57
+ ${{ github.workspace }}/.github/scripts/wait_for_looker.sh
58
+
59
+ - name: Run tests
60
+ run: bundle exec rake test
data/.gitignore CHANGED
@@ -50,3 +50,6 @@ test/tmp
50
50
  test/version_tmp
51
51
  tmp
52
52
  *.netrc
53
+
54
+ # credentials for testing
55
+ .netrc
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ### [0.1.2](https://www.github.com/looker-open-source/looker-sdk-ruby/compare/v0.1.1...v0.1.2) (2021-11-19)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Add release-please workflow ([8e8de5b](https://www.github.com/looker-open-source/looker-sdk-ruby/commit/8e8de5b9cb0063047a0f92511ce3f5e93237d109))
9
+ * change references from old location github.com/looker to new location github.com/looker-open-source ([baf0f31](https://www.github.com/looker-open-source/looker-sdk-ruby/commit/baf0f315deec45d04d53ca2ba08ad7139beed884))
10
+ * fix api version in CI workflow ([158334b](https://www.github.com/looker-open-source/looker-sdk-ruby/commit/158334bf7675ebbc3293f8fc06b028e0039eddf7))
11
+ * initial implementation of CI ([241b28e](https://www.github.com/looker-open-source/looker-sdk-ruby/commit/241b28ef9569fc4c7b940803537d49c48a4b3224))
12
+ * minor typo in release.yml ([44ea762](https://www.github.com/looker-open-source/looker-sdk-ruby/commit/44ea76282eade774b82750ee2dfa98c603a60733))
13
+ * set proper version of looker in CI workflow ([a452c91](https://www.github.com/looker-open-source/looker-sdk-ruby/commit/a452c91a364ebecd420bf1a110f9b497b3fb0349))
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,46 +1,93 @@
1
- # Contributor Covenant Code of Conduct
1
+ # Code of Conduct
2
2
 
3
3
  ## Our Pledge
4
4
 
5
- In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of
9
+ experience, education, socio-economic status, nationality, personal appearance,
10
+ race, religion, or sexual identity and orientation.
6
11
 
7
12
  ## Our Standards
8
13
 
9
- Examples of behavior that contributes to creating a positive environment include:
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
10
16
 
11
- * Using welcoming and inclusive language
12
- * Being respectful of differing viewpoints and experiences
13
- * Gracefully accepting constructive criticism
14
- * Focusing on what is best for the community
15
- * Showing empathy towards other community members
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
16
22
 
17
23
  Examples of unacceptable behavior by participants include:
18
24
 
19
- * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
- * Trolling, insulting/derogatory comments, and personal or political attacks
21
- * Public or private harassment
22
- * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
- * Other conduct which could reasonably be considered inappropriate in a professional setting
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
24
33
 
25
34
  ## Our Responsibilities
26
35
 
27
- Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
28
39
 
29
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
40
+ Project maintainers have the right and responsibility to remove, edit, or reject
41
+ comments, commits, code, wiki edits, issues, and other contributions that are
42
+ not aligned to this Code of Conduct, or to ban temporarily or permanently any
43
+ contributor for other behaviors that they deem inappropriate, threatening,
44
+ offensive, or harmful.
30
45
 
31
46
  ## Scope
32
47
 
33
- This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
-
35
- ## Enforcement
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at opensource@looker.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
-
39
- Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ This Code of Conduct also applies outside the project spaces when the Project
56
+ Steward has a reasonable belief that an individual's behavior may have a
57
+ negative impact on the project or its community.
58
+
59
+ ## Conflict Resolution
60
+
61
+ We do not believe that all conflict is bad; healthy debate and disagreement
62
+ often yield positive results. However, it is never okay to be disrespectful or
63
+ to engage in behavior that violates the project’s code of conduct.
64
+
65
+ If you see someone violating the code of conduct, you are encouraged to address
66
+ the behavior directly with those involved. Many issues can be resolved quickly
67
+ and easily, and this gives people more control over the outcome of their
68
+ dispute. If you are unable to resolve the matter for any reason, or if the
69
+ behavior is threatening or harassing, report it. We are dedicated to providing
70
+ an environment where participants feel welcome and safe.
71
+
72
+ Reports should be directed to *Mike DeAngelo* drstrangelove@google.com, the
73
+ Project Steward(s) for *looker-sdk-ruby*. It is the Project Steward’s duty to
74
+ receive and address reported violations of the code of conduct. They will then
75
+ work with a committee consisting of representatives from the Open Source
76
+ Programs Office and the Google Open Source Strategy team. If for any reason you
77
+ are uncomfortable reaching out to the Project Steward, please email
78
+ opensource@google.com.
79
+
80
+ We will investigate every complaint, but you may not receive a direct response.
81
+ We will use our discretion in determining when and how to follow up on reported
82
+ incidents, which may range from not taking action to permanent expulsion from
83
+ the project and project-sponsored spaces. We will notify the accused of the
84
+ report and provide them an opportunity to discuss it before any action is taken.
85
+ The identity of the reporter will be omitted from the details of the report
86
+ supplied to the accused. In potentially harmful situations, such as ongoing
87
+ harassment or threats to anyone's safety, we may take action without notice.
40
88
 
41
89
  ## Attribution
42
90
 
43
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
-
45
- [homepage]: http://contributor-covenant.org
46
- [version]: http://contributor-covenant.org/version/1/4/
91
+ This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
92
+ available at
93
+ https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,29 @@
1
+ # How to Contribute
2
+
3
+ We'd love to accept your patches and contributions to this project. There are
4
+ just a few small guidelines you need to follow.
5
+
6
+ ## Contributor License Agreement
7
+
8
+ Contributions to this project must be accompanied by a Contributor License
9
+ Agreement (CLA). You (or your employer) retain the copyright to your
10
+ contribution; this simply gives us permission to use and redistribute your
11
+ contributions as part of the project. Head over to
12
+ <https://cla.developers.google.com/> to see your current agreements on file or
13
+ to sign a new one.
14
+
15
+ You generally only need to submit a CLA once, so if you've already submitted one
16
+ (even if it was for a different project), you probably don't need to do it
17
+ again.
18
+
19
+ ## Code Reviews
20
+
21
+ All submissions, including submissions by project members, require review. We
22
+ use GitHub pull requests for this purpose. Consult
23
+ [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
24
+ information on using pull requests.
25
+
26
+ ## Community Guidelines
27
+
28
+ This project follows
29
+ [Google's Open Source Community Guidelines](https://opensource.google/conduct/).
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  group :test do
13
13
  # gem 'json', '~> 1.7', :platforms => [:jruby] look TODO needed?
14
- gem 'minitest', '5.3.5'
14
+ gem 'minitest', '5.9.1'
15
15
  gem 'mocha', '1.1.0'
16
16
  gem 'rack', '1.6.4'
17
17
  gem 'rack-test', '0.6.2'
data/Makefile ADDED
@@ -0,0 +1,81 @@
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 CHANGED
@@ -22,7 +22,6 @@
22
22
  # THE SOFTWARE.
23
23
  ############################################################################################
24
24
 
25
- require 'bundler'
26
25
  require "bundler/gem_tasks"
27
26
 
28
27
  require "rake/testtask"
@@ -32,30 +31,4 @@ Rake::TestTask.new do |t|
32
31
  t.verbose = true
33
32
  end
34
33
 
35
- namespace :test do
36
- desc "Run tests against all supported Rubies"
37
- task :all do
38
- supported_rubies = %w(ruby-2.0 ruby-2.1 ruby-2.3.1 jruby-1.7.19 jruby-9.1.5.0)
39
- failing_rubies = []
40
-
41
- supported_rubies.each do |ruby|
42
- cmd = "rvm install #{ruby} && rvm #{ruby} exec gem install bundler && rvm #{ruby} exec bundle install && rvm #{ruby} exec bundle exec rake"
43
- system cmd
44
- if $? != 0
45
- failing_rubies << ruby
46
- end
47
- end
48
-
49
- failing_rubies.each do |ruby|
50
- puts "FAIL: #{ruby}. Problem with the tests on #{ruby}."
51
- end
52
-
53
- if failing_rubies
54
- exit 1
55
- else
56
- exit 0
57
- end
58
- end
59
- end
60
-
61
34
  task :default => :test
data/authentication.md CHANGED
@@ -22,7 +22,7 @@ Note that API 3 tokens should be created for 'regular' Looker users and *not* vi
22
22
 
23
23
 
24
24
  ### Ensure that the API is accessible
25
- Looker versions 3.4 (and beyond) expose the 3.0 API via a port different from the port used by the web app.
25
+ Looker versions 3.4 (and beyond) expose the API via a port different from the port used by the web app.
26
26
  The default port is 19999. It may be necessary to have the Ops team managing the looker instance ensure that this
27
27
  port is made accessible network-wise to client software running on non-local hosts.
28
28
 
@@ -78,14 +78,14 @@ Content-Length: 99
78
78
  {"access_token":"4QDkCyCtZzYgj4C2p2cj3csJH7zqS5RzKs2kTnG4","token_type":"Bearer","expires_in":3600}
79
79
 
80
80
  # Use an access_token (the token can be used over and over for API calls until it expires)
81
- > curl -i -H "Authorization: token 4QDkCyCtZzYgj4C2p2cj3csJH7zqS5RzKs2kTnG4" https://localhost:19999/api/3.0/user
81
+ > curl -i -H "Authorization: token 4QDkCyCtZzYgj4C2p2cj3csJH7zqS5RzKs2kTnG4" https://localhost:19999/api/4.0/user
82
82
  HTTP/1.1 200 OK
83
83
  Content-Type: application/json;charset=utf-8
84
84
  Vary: Accept-Encoding
85
85
  X-Content-Type-Options: nosniff
86
86
  Content-Length: 502
87
87
 
88
- {"id":14,"first_name":"Plain","last_name":"User","email":"dude+1@looker.com","models_dir":null,"is_disabled":false,"look_access":[14],"avatar_url":"https://www.gravatar.com/avatar/b7f792a6180a36a4058f36875584bc45?s=156&d=mm","credentials_email":{"email":"dude+1@looker.com","url":"https://localhost:19999/api/3.0/users/14/credentials_email","user_url":"https://localhost:19999/api/3.0/users/14","password_reset_url":"https://localhost:19999/api/3.0"},"url":"https://localhost:19999/api/3.0/users/14"}
88
+ {"id":14,"first_name":"Plain","last_name":"User","email":"dude+1@looker.com","models_dir":null,"is_disabled":false,"look_access":[14],"avatar_url":"https://www.gravatar.com/avatar/b7f792a6180a36a4058f36875584bc45?s=156&d=mm","credentials_email":{"email":"dude+1@looker.com","url":"https://localhost:19999/api/4.0/users/14/credentials_email","user_url":"https://localhost:19999/api/4.0/users/14","password_reset_url":"https://localhost:19999/api/4.0"},"url":"https://localhost:19999/api/4.0/users/14"}
89
89
 
90
90
  # Logout to revoke an access_token
91
91
  > curl -i -X DELETE -H "Authorization: token 4QDkCyCtZzYgj4C2p2cj3csJH7zqS5RzKs2kTnG4" https://localhost:19999/logout
@@ -51,7 +51,7 @@ module LookerSDK
51
51
 
52
52
  set_access_token_from_params(nil)
53
53
  without_authentication do
54
- encoded_auth = Faraday::Utils.build_query application_credentials
54
+ encoded_auth = Faraday::Utils.build_query(application_credentials)
55
55
  post("#{URI.parse(api_endpoint).path}/login", encoded_auth, header: {:'Content-Type' => 'application/x-www-form-urlencoded'})
56
56
  raise "login failure #{last_response.status}" unless last_response.status == 200
57
57
  set_access_token_from_params(last_response.data)
@@ -53,20 +53,17 @@ module LookerSDK
53
53
  @swagger ||= without_authentication { try_load_swagger }
54
54
 
55
55
  unless @swagger
56
- # capture the bits we may need later, avoiding potential buffer reuse in last_response between requests
57
- response_wo_auth_status = last_response&.status
58
- response_wo_auth_data = last_response&.data
59
-
60
56
  # try again, this time with authentication
61
57
  @swagger = try_load_swagger
62
58
  end
63
59
 
64
60
  # in unit tests, @swagger may be nil and last_response nil because no HTTP request was made
65
- if @swagger.nil? && (response_wo_auth_status || last_response)
66
- msg = "Load of swagger.json failed. "
67
- msg << "Without authentication HTTP response status: (#{response_wo_auth_status}) data: #{response_wo_auth_data}. " if response_wo_auth_status
68
- msg << "WITH authentication HTTP response status: (#{last_response.status}) data: #{last_response.data}" if last_response
69
- looker_warn(msg)
61
+ if @swagger.nil?
62
+ if @last_error
63
+ raise @last_error
64
+ else
65
+ raise "Load of swagger.json failed."
66
+ end
70
67
  end
71
68
 
72
69
  @swagger
@@ -75,12 +72,16 @@ module LookerSDK
75
72
  def operations
76
73
  return @@sharable_operations[api_endpoint] if shared_swagger && @@sharable_operations[api_endpoint]
77
74
 
75
+ if !@swagger && @lazy_swagger
76
+ load_swagger
77
+ end
78
+
78
79
  return nil unless @swagger
79
80
  @operations ||= Hash[
80
81
  @swagger[:paths].map do |path_name, path_info|
81
82
  path_info.map do |method, route_info|
82
83
  route = @swagger[:basePath].to_s + path_name.to_s
83
- [route_info[:operationId], {:route => route, :method => method, :info => route_info}]
84
+ [route_info[:operationId].to_sym, {:route => route, :method => method, :info => route_info}]
84
85
  end
85
86
  end.reduce(:+)
86
87
  ].freeze
@@ -113,7 +114,7 @@ module LookerSDK
113
114
  private
114
115
 
115
116
  def find_entry(method_name)
116
- operations && operations[method_name.to_s] if dynamic
117
+ operations && operations[method_name.to_sym] if dynamic
117
118
  end
118
119
 
119
120
  def invoke_remote(entry, method_name, *args, &block)
@@ -128,19 +129,25 @@ module LookerSDK
128
129
  raise ArgumentError.new("wrong number of arguments (#{params_passed} for #{params_required}) in call to '#{method_name}'. See '#{method_link(entry)}'")
129
130
  end
130
131
 
131
- # substitute the actual params into the route template
132
- params.each {|param| route.sub!("{#{param[:name]}}", args.shift.to_s) }
132
+ # substitute the actual params into the route template, encoding if needed
133
+ params.each do |param|
134
+ value = args.shift.to_s
135
+ if value == CGI.unescape(value)
136
+ value = CGI.escape(value)
137
+ end
138
+ route.sub!("{#{param[:name]}}", value)
139
+ end
133
140
 
134
141
  a = args.length > 0 ? args[0] : {}
135
142
  b = args.length > 1 ? args[1] : {}
136
143
 
137
144
  method = entry[:method].to_sym
138
145
  case method
139
- when :get then get(route, a, &block)
140
- when :post then post(route, a, merge_content_type_if_body(a, b), &block)
141
- when :put then put(route, a, merge_content_type_if_body(a, b), &block)
142
- when :patch then patch(route, a, merge_content_type_if_body(a, b), &block)
143
- when :delete then delete(route, a) ; @raw_responses ? last_response : delete_succeeded?
146
+ when :get then get(route, a, true, &block)
147
+ when :post then post(route, a, merge_content_type_if_body(a, b), true, &block)
148
+ when :put then put(route, a, merge_content_type_if_body(a, b), true, &block)
149
+ when :patch then patch(route, a, merge_content_type_if_body(a, b), true, &block)
150
+ when :delete then delete(route, a, true) ; @raw_responses ? last_response : delete_succeeded?
144
151
  else raise "unsupported method '#{method}' in call to '#{method_name}'. See '#{method_link(entry)}'"
145
152
  end
146
153
  end