gazer 0.2.28 → 0.2.30

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
2
  SHA1:
3
- metadata.gz: 6f0cbb4a2a0249acc8a634fb3a813cecdbb60d00
4
- data.tar.gz: a0b2d54e41d164fd34c199107f350b5332bf859b
3
+ metadata.gz: e1d752a6c9ab6c912a7ccabaafe45141f3e70e75
4
+ data.tar.gz: 6907072bde4d5f3150cea70615acb8ae693b3178
5
5
  SHA512:
6
- metadata.gz: 2b7eff72d81f4b892e98b3924c1db00613f3819035d4d551718f74094c48857814f2e49d4bf0aaa744e1b9a920fa0ee13386dc549aa12e77114690fb12c0d174
7
- data.tar.gz: 54aeaaf8808e134eced33969ff8bf78e82b3270d52a59b5cfb2a8298384af73c83aaf0197281d137d7aedce887ab2471c311f68a802e2162c0ee65c0527b4a2a
6
+ metadata.gz: bd7d987e4e78960c739a0b63e10eb16642392e5f4b1baecf3964e755521f2686b186a0951da02be95dd66e722526663132168d7ab1eebc1117da6718a28ca14e
7
+ data.tar.gz: d087140b4ae80317e54289e31d09b89ba859675b18422e51ed28e4d1cc14f0bf90b419fd36d00c3ee253de03fe13b399f9e97250cd95823ee7cbb017209ab7a9
@@ -0,0 +1,29 @@
1
+ ## How to contribute to Gazer
2
+
3
+ Did you read the [code of conduct](https://github.com/looker-open-source/gzr/blob/master/CODE_OF_CONDUCT.md)?
4
+
5
+ #### **Did you find a bug?**
6
+
7
+ * **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/looker-open-source/gzr/issues).
8
+
9
+ * If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/looker-open-source/gzr/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
10
+
11
+ #### **Did you write a patch that fixes a bug?**
12
+
13
+ * Open a new GitHub pull request with the patch.
14
+
15
+ * Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
16
+
17
+ * Depending on the content of the patch, we may need to work out a legal agreement to clarify everyone's rights before the patch is accepted.
18
+
19
+ #### **Do you intend to add a new feature or change an existing one?**
20
+
21
+ * Again please open an issue in GitHub. Larger projects often segregate bugs from new features and enhancements, but we are still small enough that it is not an issue.
22
+
23
+ #### **Do you have questions about the source code?**
24
+
25
+ * Ask any question about how to use Gazer by contacting the [primary developer](mailto:deangelo+gzr@looker.com).
26
+
27
+ Thanks! :heart: :heart: :heart:
28
+
29
+ Gazer Team
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gazer (0.2.28)
4
+ gazer (0.2.30)
5
5
  looker-sdk (~> 0.0.6)
6
6
  netrc (~> 0.11.0)
7
7
  pastel (~> 0.7.2)
@@ -21,11 +21,44 @@
21
21
 
22
22
  # frozen_string_literal: true
23
23
 
24
+ require 'json'
24
25
  require 'pastel'
25
26
  require 'tty-reader'
26
27
 
27
28
  require_relative '../../gzr'
28
29
 
30
+ # monkeypatch login to use /api/3.0/login enpoint instead of /login endpoint
31
+ #
32
+ # Customer has Looker instance that gets both API and UI traffic at 443
33
+ # and then NGINX rule sends to 9999 or 19999. The UI /login and API
34
+ # /login conflict. Same for /logout.
35
+ module LookerSDK
36
+ module Authentication
37
+
38
+ def authenticate
39
+ #puts "Using monkeypatch login to #{URI.parse(api_endpoint).path}/login"
40
+ raise "client_id and client_secret required" unless application_credentials?
41
+
42
+ set_access_token_from_params(nil)
43
+ without_authentication do
44
+ post("#{URI.parse(api_endpoint).path}/login", {}, :query => application_credentials)
45
+ raise "login failure #{last_response.status}" unless last_response.status == 200
46
+ set_access_token_from_params(last_response.data)
47
+ end
48
+ end
49
+
50
+ def logout
51
+ #puts "Using monkeypatch logout to #{URI.parse(api_endpoint).path}/logout"
52
+ without_authentication do
53
+ result = !!@access_token && ((delete("#{URI.parse(api_endpoint).path}/logout") ; delete_succeeded?) rescue false)
54
+ set_access_token_from_params(nil)
55
+ result
56
+ end
57
+ end
58
+
59
+ end
60
+ end
61
+
29
62
  module Gzr
30
63
  module Session
31
64
 
@@ -49,9 +82,9 @@ module Gzr
49
82
  @v3_1_available ||= false
50
83
  end
51
84
 
52
- def build_connection_hash(api_version)
85
+ def build_connection_hash()
53
86
  conn_hash = Hash.new
54
- conn_hash[:api_endpoint] = "http#{@options[:ssl] ? "s" : ""}://#{@options[:host]}:#{@options[:port]}/api/#{api_version}"
87
+ conn_hash[:api_endpoint] = "http#{@options[:ssl] ? "s" : ""}://#{@options[:host]}:#{@options[:port]}/"
55
88
  if @options[:http_proxy]
56
89
  conn_hash[:connection_options] ||= {}
57
90
  conn_hash[:connection_options][:proxy] = {
@@ -96,38 +129,48 @@ module Gzr
96
129
 
97
130
  def login(api_version)
98
131
  @secret = nil
132
+ versions = nil
133
+ current_version = nil
99
134
  begin
100
- conn_hash = build_connection_hash("3.0")
101
- sdk = LookerSDK::Client.new(conn_hash)
135
+ conn_hash = build_connection_hash
136
+
137
+ sawyer_options = {
138
+ :links_parser => Sawyer::LinkParsers::Simple.new,
139
+ :serializer => LookerSDK::Client::Serializer.new(JSON),
140
+ :faraday => conn_hash[:faraday] || Faraday.new(conn_hash[:connection_options])
141
+ }
142
+
143
+ agent = Sawyer::Agent.new(conn_hash[:api_endpoint], conn_hash) do |http|
144
+ http.headers[:accept] = 'application/json'
145
+ http.headers[:user_agent] = conn_hash[:user_agent]
146
+ end
147
+
102
148
  begin
103
- sdk.get "/"
149
+ versions_response = agent.call(:get,"/versions")
150
+ versions = versions_response.data.supported_versions
151
+ current_version = versions_response.data.current_version
104
152
  rescue Faraday::SSLError => e
105
153
  raise Gzr::CLI::Error, "SSL Certificate could not be verified\nDo you need the --no-verify-ssl option or the --no-ssl option?"
106
154
  rescue Faraday::ConnectionFailed => cf
107
155
  raise Gzr::CLI::Error, "Connection Failed.\nDid you specify the --no-ssl option for an ssl secured server?"
108
156
  rescue LookerSDK::NotFound => nf
109
- #ignore this
157
+ say_warning "endpoint #{conn_hash[:api_endpoint]}/versions was not found"
110
158
  end
111
- raise Gzr::CLI::Error, "Invalid credentials" unless sdk.authenticated?
112
- sdk.versions.supported_versions.each do |v|
159
+ versions.each do |v|
113
160
  @v3_1_available = true if v.version == "3.1"
114
161
  end
115
- begin
116
- sdk.logout
117
- rescue LookerSDK::Error => e
118
- # eat this error if it occurs
119
- end
120
- end unless @options[:api_version]
162
+ end
121
163
 
122
164
  say_warning "API 3.1 available? #{v3_1_available?}" if @options[:debug]
123
165
 
124
166
  raise Gzr::CLI::Error, "Operation requires API v3.1, but user specified a different version" if (api_version == "3.1") && @options[:api_version] && !("3.1" == @options[:api_version])
125
167
  raise Gzr::CLI::Error, "Operation requires API v3.1, which is not available from this host" if (api_version == "3.1") && !v3_1_available?
126
168
 
127
- conn_hash = build_connection_hash(@options[:api_version] || api_version)
169
+ conn_hash = build_connection_hash()
170
+ conn_hash[:api_endpoint] = "#{conn_hash[:api_endpoint]}api/#{@options[:api_version] || current_version.version}"
128
171
  @secret = nil
129
172
 
130
- say_ok("connecting to #{conn_hash.each { |k,v| "#{k}=>#{(k == :client_secret) ? '*********' : v}" }}") if @options[:debug]
173
+ say_ok("connecting to #{conn_hash.map { |k,v| "#{k}=>#{(k == :client_secret) ? '*********' : v}" }}") if @options[:debug]
131
174
 
132
175
  begin
133
176
  @sdk = LookerSDK::Client.new(conn_hash) unless @sdk
@@ -20,5 +20,5 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  module Gzr
23
- VERSION = "0.2.28"
23
+ VERSION = "0.2.30"
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.28
4
+ version: 0.2.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike DeAngelo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-22 00:00:00.000000000 Z
11
+ date: 2019-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-reader
@@ -191,6 +191,7 @@ files:
191
191
  - ".ruby-version"
192
192
  - ".travis.yml"
193
193
  - CODE_OF_CONDUCT.md
194
+ - CONTRIBUTING.md
194
195
  - Gemfile
195
196
  - Gemfile.lock
196
197
  - LICENSE.txt