chalk_ruby 0.1.1 → 0.1.3

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
  SHA256:
3
- metadata.gz: 475cbc00a9b6c9a048e287fdca499ffd257a768c63471598c1db61d8a4757baf
4
- data.tar.gz: bee580988929bc2219c4f6e6778e17eb8c2055ed80799be251d5af21295e32c8
3
+ metadata.gz: d2ede1c8828c78063446a6dde9f51f7b9bc487c5d25a4ffc36d4fa48c200504b
4
+ data.tar.gz: 80d0d2513511d278d9ceeb2b64b71935287d9957c5f9df7e2e4758eea217b25f
5
5
  SHA512:
6
- metadata.gz: 64ea24c0bc3d3ea81f2d32c72a7220c70a5e1c7e88a0dcef1c5907dbccbc40d4f9a9d6d91e1917359ec516c7a864b9ba3a57c2848c98f5dba83a2cf61c8f1d7e
7
- data.tar.gz: f8821a753ba007213b63977d6a0b465944320e20d96728db4edd7e57a4a2aeb9b5f79ef2dc18ce5cfa29e648151a354d90061f19f7dd43a77c85c7bf0e28dfa5
6
+ metadata.gz: 0afdcc9b35ce5ae8a2cc4a1761e958ed844d0e0dc5e36f77192e538018fd420fca7ab0316a2ed4b6a85e4a05db896ace76385db236c5e1075d58ccd854396547
7
+ data.tar.gz: 55ef6712afc0f55785065e19a8ef9392c1319851df453742192703cd4f396c4ae9971b429464b6bd40443956193d9036fa84975eaee37113e22c3fc8971ad654
data/README.md CHANGED
@@ -1,13 +1,17 @@
1
1
  ## ChalkRuby Ruby
2
2
 
3
- Ruby client for ChalkRuby
3
+ [![Gem Version](https://badge.fury.io/rb/chalk_ruby.svg)](https://badge.fury.io/rb/chalk_ruby)
4
+
5
+ Ruby client for Chalk!
6
+
7
+ https://rubygems.org/gems/chalk_ruby
4
8
 
5
9
  ## Getting Started
6
10
 
7
- First, install ChalkRuby Ruby API Client via the [RubyGems](https://rubygems.org/) package manager:
11
+ First, install `chalk_ruby` via the [RubyGems](https://rubygems.org/) package manager:
8
12
 
9
13
  ```bash
10
- gem install chalk_ai
14
+ gem install chalk_ruby
11
15
  ```
12
16
 
13
17
  Then, create a new client using your client ID and client secret:
@@ -22,4 +26,4 @@ results = client.query(
22
26
 
23
27
  ## License
24
28
 
25
- The ChalkRuby Ruby API Client is an open-sourced software licensed under the [Apache 2 License](LICENSE.md).
29
+ The Chalk Ruby API Client is an open-sourced software licensed under the [Apache 2 License](LICENSE.md).
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ namespace :test do
17
17
  Rake::TestTask.new(:integration) do |t|
18
18
  t.libs << 'test'
19
19
  t.libs << 'lib'
20
- t.test_files = FileList['test/chalk/integration/**/*_test.rb']
20
+ t.test_files = FileList['test/chalk_ruby/integration/**/*_test.rb']
21
21
  t.verbose = true
22
22
  t.warning = false
23
23
  end
data/SECURITY.md CHANGED
@@ -1,17 +1,17 @@
1
1
  ## Security
2
2
 
3
- If you believe you have found a security vulnerability in ChalkRuby's Ruby package, please report it to us!
3
+ If you believe you have found a security vulnerability in Chalk's Ruby package, please report it to us!
4
4
 
5
5
  ### Reporting Security Issues
6
6
 
7
7
  **Please do not report security vulnerabilities through public GitHub issues.**
8
8
 
9
- Please email security concerns to [security@chalk_ai.ai](mailto:security@chalk_ai.ai).
9
+ Please email security concerns to [security@chalk.ai](mailto:security@chalk.ai).
10
10
 
11
11
  ### Security Overview
12
12
 
13
- https://docs.chalk_ai.ai/docs/security
13
+ https://docs.chalk.ai/docs/security
14
14
 
15
15
  ### SOC-2 Report
16
16
 
17
- To request access to ChalkRuby's SOC-2 report, please email [security@chalk_ai.ai](mailto:security@chalk_ai.ai).
17
+ To request access to ChalkRuby's SOC-2 report, please email [security@chalk.ai](mailto:security@chalk_ruby.ai).
@@ -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: get_authenticated_headers(branch: branch)
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 get_authenticated_headers(branch:)
225
- t = valid_token
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
@@ -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
  #
@@ -30,24 +31,28 @@ module ChalkRuby
30
31
  # The API server to use.
31
32
  # If not provided, it will be read from the CHALK_API_SERVER environment variable.
32
33
  #
33
- # @option options [Integer?] :read_timeout
34
- # The timeout for read operations (in seconds).
34
+ # @option options [Float?] :query_timeout
35
+ # The timeout for query operations (in seconds).
35
36
  #
36
- # @option options [Integer?] :write_timeout
37
- # The timeout for write operations (in seconds).
37
+ # @option options [Float?] :api_timeout
38
+ # The timeout for non-query API operations (in seconds).
38
39
  #
39
- # @option options [Integer?] :connect_timeout
40
+ # @option options [Float?] :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 = opts[:client_id] || ENV['CHALK_CLIENT_ID']
44
- @client_secret = opts[:client_secret] || ENV['CHALK_CLIENT_SECRET']
45
- @environment = opts[:environment] || ENV['CHALK_ACTIVE_ENVIRONMENT']
46
- @query_server = opts[:query_server] || ENV['CHALK_QUERY_SERVER'] || Defaults::QUERY_SERVER
47
- @api_server = opts[:api_server] || ENV['CHALK_API_SERVER'] || Defaults::API_SERVER
48
- @query_timeout = opts[:query_timeout] || Defaults::API_TIMEOUT
49
- @api_timeout = opts[:api_timeout] || Defaults::QUERY_TIMEOUT
50
- @connect_timeout = opts[:connect_timeout] || Defaults::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::QUERY_TIMEOUT
53
+ @api_timeout = opts[:api_timeout] || Defaults::API_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?
@@ -1,3 +1,3 @@
1
1
  module ChalkRuby
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
@@ -4,7 +4,14 @@ module ChalkRuby
4
4
  @token: Token?
5
5
  @transporter: Http::HttpRequesterChalk
6
6
 
7
- def self.create: -> Client
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 get_authenticated_headers: -> Hash[Symbol, String | nil]
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
 
@@ -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.1
4
+ version: 0.1.3
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-08 00:00:00.000000000 Z
11
+ date: 2024-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -236,8 +236,8 @@ files:
236
236
  - sig/chalk_ruby/http/response.rbs
237
237
  - sig/chalk_ruby/token.rbs
238
238
  - sig/chalk_ruby/versions.rbs
239
- - test/chalk_ai/integration/client_test.rb
240
- - test/chalk_ai/test_helper.rb
239
+ - test/chalk_ruby/integration/client_test.rb
240
+ - test/chalk_ruby/test_helper.rb
241
241
  homepage: https://github.com/chalk-ai/chalk-ruby
242
242
  licenses:
243
243
  - Apache-2.0
@@ -265,5 +265,5 @@ signing_key:
265
265
  specification_version: 4
266
266
  summary: A simple Ruby client for Chalk
267
267
  test_files:
268
- - test/chalk_ai/integration/client_test.rb
269
- - test/chalk_ai/test_helper.rb
268
+ - test/chalk_ruby/integration/client_test.rb
269
+ - test/chalk_ruby/test_helper.rb
File without changes