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 +4 -4
- data/CONTRIBUTING.md +29 -0
- data/Gemfile.lock +1 -1
- data/lib/gzr/modules/session.rb +59 -16
- data/lib/gzr/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1d752a6c9ab6c912a7ccabaafe45141f3e70e75
|
4
|
+
data.tar.gz: 6907072bde4d5f3150cea70615acb8ae693b3178
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd7d987e4e78960c739a0b63e10eb16642392e5f4b1baecf3964e755521f2686b186a0951da02be95dd66e722526663132168d7ab1eebc1117da6718a28ca14e
|
7
|
+
data.tar.gz: d087140b4ae80317e54289e31d09b89ba859675b18422e51ed28e4d1cc14f0bf90b419fd36d00c3ee253de03fe13b399f9e97250cd95823ee7cbb017209ab7a9
|
data/CONTRIBUTING.md
ADDED
@@ -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
|
data/Gemfile.lock
CHANGED
data/lib/gzr/modules/session.rb
CHANGED
@@ -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(
|
85
|
+
def build_connection_hash()
|
53
86
|
conn_hash = Hash.new
|
54
|
-
conn_hash[:api_endpoint] = "http#{@options[:ssl] ? "s" : ""}://#{@options[:host]}:#{@options[:port]}/
|
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
|
101
|
-
|
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
|
-
|
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
|
-
#
|
157
|
+
say_warning "endpoint #{conn_hash[:api_endpoint]}/versions was not found"
|
110
158
|
end
|
111
|
-
|
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
|
-
|
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(
|
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.
|
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
|
data/lib/gzr/version.rb
CHANGED
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.
|
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
|
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
|