chalk_ruby 0.2.3 → 0.2.4
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.
- checksums.yaml +4 -4
- data/lib/chalk_ruby/config.rb +13 -8
- data/lib/chalk_ruby/defaults.rb +4 -0
- data/lib/chalk_ruby/grpc_client.rb +14 -11
- data/lib/chalk_ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfe57e2b3d1f09eaa9dece4b777788941b347319bca50b3242c52070287aa86f
|
4
|
+
data.tar.gz: '039220d201af61aff4e19fc73ea242a797b8681f87dc449e13187996eae653e6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc1d7cbfcdb2175ee61773918800270f963b136fea24573b06b97a8b22225f5488c9fed440755d964f32577822d61021122469c75c65b7e5271b19cccec03489
|
7
|
+
data.tar.gz: 79b8d14bbf904286f5589542dc85a0ff471b7e79ad675860893bd3e7fdaf9ceb3736a57773ed8bc78da9709a41df34dc6d4badcedad6d0c427a851dfb029aad0
|
data/lib/chalk_ruby/config.rb
CHANGED
@@ -16,6 +16,7 @@ module ChalkRuby
|
|
16
16
|
:query_timeout,
|
17
17
|
:api_timeout,
|
18
18
|
:connect_timeout,
|
19
|
+
:query_service_root_ca_path,
|
19
20
|
:additional_headers
|
20
21
|
|
21
22
|
# Creates a new ChalkRuby::Config object for use with ChalkRuby::Client.
|
@@ -45,18 +46,22 @@ module ChalkRuby
|
|
45
46
|
# @option options [Float?] :connect_timeout
|
46
47
|
# The timeout for connect operations (in seconds).
|
47
48
|
#
|
49
|
+
# @option options [String?] :query_service_root_ca_path
|
50
|
+
# The root ca to use for trusting SSL verifying connections to the query server in grpc.
|
51
|
+
#
|
48
52
|
# @option options [Hash<String, String>?] :additional_headers
|
49
53
|
# Additional headers to be sent with every request. Typically not required.
|
50
54
|
#
|
51
55
|
def initialize(opts = {})
|
52
|
-
@client_id
|
53
|
-
@client_secret
|
54
|
-
@environment
|
55
|
-
@query_server
|
56
|
-
@api_server
|
57
|
-
@query_timeout
|
58
|
-
@api_timeout
|
59
|
-
@connect_timeout
|
56
|
+
@client_id = opts[:client_id] || ENV['CHALK_CLIENT_ID']
|
57
|
+
@client_secret = opts[:client_secret] || ENV['CHALK_CLIENT_SECRET']
|
58
|
+
@environment = opts[:environment] || ENV['CHALK_ACTIVE_ENVIRONMENT']
|
59
|
+
@query_server = opts[:query_server] || ENV['CHALK_QUERY_SERVER'] || Defaults::QUERY_SERVER
|
60
|
+
@api_server = opts[:api_server] || ENV['CHALK_API_SERVER'] || Defaults::API_SERVER
|
61
|
+
@query_timeout = opts[:query_timeout] || Defaults::QUERY_TIMEOUT
|
62
|
+
@api_timeout = opts[:api_timeout] || Defaults::API_TIMEOUT
|
63
|
+
@connect_timeout = opts[:connect_timeout] || Defaults::CONNECT_TIMEOUT
|
64
|
+
@query_service_root_ca_path = opts[:query_service_root_ca_path] || Defaults::ROOT_CA_PATH
|
60
65
|
@additional_headers = opts[:additional_headers] || {}
|
61
66
|
|
62
67
|
raise ChalkError, 'No Client ID provided, please set :client_id' if @client_id.nil?
|
data/lib/chalk_ruby/defaults.rb
CHANGED
@@ -183,18 +183,14 @@ module ChalkRuby
|
|
183
183
|
end
|
184
184
|
|
185
185
|
def get_token
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
body: {
|
191
|
-
client_id: @config.client_id,
|
192
|
-
client_secret: @config.client_secret,
|
193
|
-
grant_type: 'client_credentials'
|
194
|
-
},
|
195
|
-
headers: get_unauthenticated_headers
|
186
|
+
response = @auth_stub.get_token(
|
187
|
+
Chalk::Server::V1::GetTokenRequest.new(
|
188
|
+
client_id: @config.client_id,
|
189
|
+
client_secret: @config.client_secret
|
196
190
|
)
|
197
191
|
)
|
192
|
+
|
193
|
+
response.access_token
|
198
194
|
end
|
199
195
|
|
200
196
|
def get_unauthenticated_headers
|
@@ -280,7 +276,14 @@ module ChalkRuby
|
|
280
276
|
|
281
277
|
def query_service
|
282
278
|
if @query_service.nil?
|
283
|
-
|
279
|
+
channel_creds =
|
280
|
+
if @config.query_service_root_ca_path.nil?
|
281
|
+
GRPC::Core::ChannelCredentials.new
|
282
|
+
else
|
283
|
+
GRPC::Core::ChannelCredentials.new(File.read(@config.query_service_root_ca_path))
|
284
|
+
end
|
285
|
+
|
286
|
+
@query_service = Chalk::Engine::V1::QueryService::Stub.new(query_server_host, channel_creds, interceptors: [engine_interceptor])
|
284
287
|
end
|
285
288
|
|
286
289
|
@query_service
|
data/lib/chalk_ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chalk_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chalk AI, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|