chalk_ruby 0.1.1 → 0.1.2
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/README.md +3 -1
- data/lib/chalk_ruby/client.rb +15 -8
- data/lib/chalk_ruby/config.rb +14 -9
- data/lib/chalk_ruby/version.rb +1 -1
- data/sig/chalk_ruby/client.rbs +9 -2
- data/sig/chalk_ruby/config.rbs +3 -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: be35291268749664bfdee468de9a997bd421f3b16683ffb847e12f3089f22e46
|
4
|
+
data.tar.gz: 3670d6543e87f11cee499ed8477729364e57a2072437ed798f1a721d7823e93d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87b9e3a20075fda23a00ba5e38dc91827afcc18922b6b664e1fb31676623ce2d67627cd0d1a56831740fa03eeeaf99439841151073bfd1413b33e9811aa45281
|
7
|
+
data.tar.gz: 908b81be15e3c99571a7195f9464496b0f52bb5447f96728d82e2ed57365b5828dfef48c911a42d850ed9262a1bfb4c26b496cd7649e8a1512605c28a10a4c4f
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Ruby client for ChalkRuby
|
4
4
|
|
5
|
+
https://rubygems.org/gems/chalk_ruby
|
6
|
+
|
5
7
|
## Getting Started
|
6
8
|
|
7
9
|
First, install ChalkRuby Ruby API Client via the [RubyGems](https://rubygems.org/) package manager:
|
@@ -22,4 +24,4 @@ results = client.query(
|
|
22
24
|
|
23
25
|
## License
|
24
26
|
|
25
|
-
The
|
27
|
+
The Chalk Ruby API Client is an open-sourced software licensed under the [Apache 2 License](LICENSE.md).
|
data/lib/chalk_ruby/client.rb
CHANGED
@@ -26,6 +26,9 @@ module ChalkRuby
|
|
26
26
|
# @param api_server [String]
|
27
27
|
# ChalkRuby API server
|
28
28
|
#
|
29
|
+
# @param additional_headers [Hash[String, String]]
|
30
|
+
# Additional headers to be sent with every request. Typically not required.
|
31
|
+
#
|
29
32
|
# @return self
|
30
33
|
#
|
31
34
|
def self.create(
|
@@ -33,14 +36,16 @@ module ChalkRuby
|
|
33
36
|
client_secret = nil,
|
34
37
|
environment = nil,
|
35
38
|
query_server = nil,
|
36
|
-
api_server = nil
|
39
|
+
api_server = nil,
|
40
|
+
additional_headers = {}
|
37
41
|
)
|
38
42
|
config = Config.new(
|
39
43
|
client_id: client_id,
|
40
44
|
client_secret: client_secret,
|
41
45
|
environment: environment,
|
42
46
|
query_server: query_server,
|
43
|
-
api_server: api_server
|
47
|
+
api_server: api_server,
|
48
|
+
additional_headers: additional_headers
|
44
49
|
)
|
45
50
|
create_with_config(config)
|
46
51
|
end
|
@@ -153,7 +158,7 @@ module ChalkRuby
|
|
153
158
|
include_meta: include_meta || false,
|
154
159
|
store_plan_stages: store_plan_stages || false
|
155
160
|
},
|
156
|
-
headers:
|
161
|
+
headers: get_authenticated_engine_headers(branch: branch)
|
157
162
|
)
|
158
163
|
end
|
159
164
|
|
@@ -221,15 +226,17 @@ module ChalkRuby
|
|
221
226
|
)
|
222
227
|
end
|
223
228
|
|
224
|
-
def
|
225
|
-
t
|
226
|
-
{
|
229
|
+
def get_authenticated_engine_headers(branch:)
|
230
|
+
t = valid_token
|
231
|
+
tokens = {
|
227
232
|
'Content-Type': 'application/json',
|
228
233
|
'Accept': 'application/json',
|
229
234
|
'Authorization': 'Bearer ' + t.token,
|
230
235
|
'X-Chalk-Env-Id': @config.environment || t.environment,
|
231
|
-
'X-Chalk-Branch-Id': branch
|
236
|
+
'X-Chalk-Branch-Id': branch,
|
237
|
+
'X-Chalk-Deployment-Type': branch.nil? ? 'engine' : 'branch'
|
232
238
|
}
|
239
|
+
tokens.merge(@config.additional_headers)
|
233
240
|
end
|
234
241
|
|
235
242
|
def get_unauthenticated_headers
|
@@ -237,7 +244,7 @@ module ChalkRuby
|
|
237
244
|
'Content-Type': 'application/json',
|
238
245
|
'Accept': 'application/json',
|
239
246
|
'X-Chalk-Env-Id': @config.environment
|
240
|
-
}
|
247
|
+
}.merge(@config.additional_headers)
|
241
248
|
end
|
242
249
|
|
243
250
|
def query_server_host
|
data/lib/chalk_ruby/config.rb
CHANGED
@@ -10,7 +10,8 @@ module ChalkRuby
|
|
10
10
|
:environment,
|
11
11
|
:query_timeout,
|
12
12
|
:api_timeout,
|
13
|
-
:connect_timeout
|
13
|
+
:connect_timeout,
|
14
|
+
:additional_headers
|
14
15
|
|
15
16
|
# Creates a new ChalkRuby::Config object for use with ChalkRuby::Client.
|
16
17
|
#
|
@@ -39,15 +40,19 @@ module ChalkRuby
|
|
39
40
|
# @option options [Integer?] :connect_timeout
|
40
41
|
# The timeout for connect operations (in seconds).
|
41
42
|
#
|
43
|
+
# @option options [Hash<String, String>?] :additional_headers
|
44
|
+
# Additional headers to be sent with every request. Typically not required.
|
45
|
+
#
|
42
46
|
def initialize(opts = {})
|
43
|
-
@client_id
|
44
|
-
@client_secret
|
45
|
-
@environment
|
46
|
-
@query_server
|
47
|
-
@api_server
|
48
|
-
@query_timeout
|
49
|
-
@api_timeout
|
50
|
-
@connect_timeout
|
47
|
+
@client_id = opts[:client_id] || ENV['CHALK_CLIENT_ID']
|
48
|
+
@client_secret = opts[:client_secret] || ENV['CHALK_CLIENT_SECRET']
|
49
|
+
@environment = opts[:environment] || ENV['CHALK_ACTIVE_ENVIRONMENT']
|
50
|
+
@query_server = opts[:query_server] || ENV['CHALK_QUERY_SERVER'] || Defaults::QUERY_SERVER
|
51
|
+
@api_server = opts[:api_server] || ENV['CHALK_API_SERVER'] || Defaults::API_SERVER
|
52
|
+
@query_timeout = opts[:query_timeout] || Defaults::API_TIMEOUT
|
53
|
+
@api_timeout = opts[:api_timeout] || Defaults::QUERY_TIMEOUT
|
54
|
+
@connect_timeout = opts[:connect_timeout] || Defaults::CONNECT_TIMEOUT
|
55
|
+
@additional_headers = opts[:additional_headers] || {}
|
51
56
|
|
52
57
|
raise ChalkError, 'No Client ID provided, please set :client_id' if @client_id.nil?
|
53
58
|
raise ChalkError, 'No Client Secret provided, please set :client_secret' if @client_secret.nil?
|
data/lib/chalk_ruby/version.rb
CHANGED
data/sig/chalk_ruby/client.rbs
CHANGED
@@ -4,7 +4,14 @@ module ChalkRuby
|
|
4
4
|
@token: Token?
|
5
5
|
@transporter: Http::HttpRequesterChalk
|
6
6
|
|
7
|
-
def self.create:
|
7
|
+
def self.create: (
|
8
|
+
String? client_id,
|
9
|
+
String? client_secret,
|
10
|
+
String? environment,
|
11
|
+
String? query_server,
|
12
|
+
String? api_server,
|
13
|
+
Hash[String, String]? additional_headers
|
14
|
+
) -> Client
|
8
15
|
|
9
16
|
def self.create_with_config: -> Client
|
10
17
|
|
@@ -27,7 +34,7 @@ module ChalkRuby
|
|
27
34
|
|
28
35
|
private
|
29
36
|
|
30
|
-
def
|
37
|
+
def get_authenticated_engine_headers: (String? branch) -> Hash[Symbol, String | nil]
|
31
38
|
|
32
39
|
def get_unauthenticated_headers: -> Hash[Symbol, String | nil]
|
33
40
|
|
data/sig/chalk_ruby/config.rbs
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module ChalkRuby
|
2
2
|
class Config
|
3
|
+
attr_accessor additional_headers: Hash[String, String]?
|
3
4
|
attr_accessor client_id: String
|
4
5
|
attr_accessor client_secret: String
|
5
6
|
|
@@ -22,7 +23,8 @@ module ChalkRuby
|
|
22
23
|
query_timeout: Integer?,
|
23
24
|
api_timeout: Integer?,
|
24
25
|
connect_timeout: Integer?,
|
25
|
-
compression_type: String
|
26
|
+
compression_type: String?,
|
27
|
+
additional_headers: Hash[String, String]?
|
26
28
|
}
|
27
29
|
|
28
30
|
def initialize: (options opts) -> void
|
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.1.
|
4
|
+
version: 0.1.2
|
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: 2024-01-
|
11
|
+
date: 2024-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|