evervault 0.1.2 → 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: 0e666a2b2b7d130e4221e2c25f963fdd6a3e7e986f08127be6f3937ab7f94e52
4
- data.tar.gz: dbd8034681606769295e1a2678b019c02f7600b96918c6bb737a5ad0bb9f0616
3
+ metadata.gz: e3b50c9b63dbb48205dd12e7f25a7df7bde49ccee2945a4a40f999d635d14ca4
4
+ data.tar.gz: d5582b0e9be47496c09d01581a00e6e3cfd6abf824d8bb57275f3fcd7800ac1d
5
5
  SHA512:
6
- metadata.gz: 4830d141e96f9b47a65a581bd214a0cd4d86d440e6f2fdc6f70cd9abd7371f86ef331982d65d3850a19edbc56833994aec8463bc5d55fb0c4ea73c66b6d23abe
7
- data.tar.gz: 6d22b0c92ea74e1679513b53431ac7ebe78ba79b215eaea9ebf84062cb2ec45ba4a6e99a1075e66c93a39f9d8c7b1305f0e717c2f9408f4270a7a74d34ab5ca3
6
+ metadata.gz: c01d3201c76b86f8924c8ee8f90feb77da2d6bca98cebb724c10a75c181f6ab8ac7847686044cdc7e3f57ea84918e7f15d4eb66b6e2d792cffb9b362d5da8988
7
+ data.tar.gz: e0b570280d96839cf6df0cb8c595bc3e9b23b9f60fcb763f75513af4961bd97ffadfae01de40be5c023cc7390d7cead0f8e3c0b8ce6c67bda36e2d62e12b3b7e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- evervault (0.1.1)
4
+ evervault (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  Ruby SDK for [Evervault](https://evervault.com)
13
13
  ### Prerequisites
14
14
 
15
- To get started with the Evervault Ruby SDK, you will need to have created a team on the evervault dashboard.
15
+ To get started with the Evervault Ruby SDK, you will need to have created a team on the Evervault dashboard.
16
16
 
17
17
  We are currently in invite-only early access. You can apply for early access [here](https://evervault.com).
18
18
 
@@ -63,7 +63,7 @@ result = evervault.encrypt_and_run(<CAGE-NAME>, { hello: 'World!' })
63
63
 
64
64
  ### Evervault.encrypt
65
65
 
66
- Encrypt lets you encrypt data for use in any of your evervault cages. You can use it to store encrypted data to be used in a cage at another time.
66
+ Encrypt lets you encrypt data for use in any of your Evervault Cages. You can use it to store encrypted data to be used in a Cage at another time.
67
67
 
68
68
  ```ruby
69
69
  Evervault.encrypt(data = Hash | String)
@@ -75,20 +75,28 @@ Evervault.encrypt(data = Hash | String)
75
75
 
76
76
  ### Evervault.run
77
77
 
78
- Run lets you invoke your evervault cages with a given payload.
78
+ Run lets you invoke your Evervault Cages with a given payload.
79
79
 
80
80
  ```ruby
81
- Evervault.run(cage_name = String, data = Hash)
81
+ Evervault.run(cage_name = String, data = Hash[, options = Hash])
82
82
  ```
83
83
 
84
84
  | Parameter | Type | Description |
85
85
  | --------- | ---- | ----------- |
86
- | cageName | String | Name of the cage to be run |
87
- | data | Hash | Payload for the cage |
86
+ | cageName | String | Name of the Cage to be run |
87
+ | data | Hash | Payload for the Cage |
88
+ | options | Hash | [Options for the Cage run](#Cage-Run-Options) |
89
+
90
+ #### Cage Run Options
91
+
92
+ | Option | Type | Default | Description |
93
+ | ------ | ---- | ------- | ----------- |
94
+ | `async` | `Boolean` | `false` | Run your Cage in async mode. Async Cage runs will be queued for processing. |
95
+ | `version` | `Integer` | `nil` | Specify the version of your Cage to run. By default, the latest version will be run. |
88
96
 
89
97
  ### Evervault.encrypt_and_run
90
98
 
91
- Encrypt your data and use it as the payload to invoke the cage.
99
+ Encrypt your data and use it as the payload to invoke the Cage.
92
100
 
93
101
  ```ruby
94
102
  Evervault.encrypt_and_run(cage_name = String, data = Hash)
@@ -96,7 +104,7 @@ Evervault.encrypt_and_run(cage_name = String, data = Hash)
96
104
 
97
105
  | Parameter | Type | Description |
98
106
  | --------- | ---- | ----------- |
99
- | cageName | String | Name of the cage to be run |
107
+ | cageName | String | Name of the Cage to be run |
100
108
  | data | dict | Data to be encrypted |
101
109
 
102
110
  ### Evervault.cages
@@ -129,7 +137,7 @@ Evervault.cages
129
137
 
130
138
  ### Evervault.cage_list
131
139
 
132
- Return a `CageList` object, containing a list of your team's cages
140
+ Return a `CageList` object, containing a list of your team's Cages
133
141
 
134
142
  ```ruby
135
143
  Evervault.cage_list
@@ -167,7 +175,7 @@ Evervault.cage_list
167
175
 
168
176
  #### CageList.to_hash
169
177
 
170
- Converts a list of cages to a hash with keys of CageName => Cage Model
178
+ Converts a list of Cages to a hash with keys of CageName => Cage Model
171
179
 
172
180
  ```ruby
173
181
  Evervault.cage_list.to_hash
@@ -210,9 +218,9 @@ Evervault.cage_list.to_hash
210
218
 
211
219
  ### Evervault::Models::Cage.run
212
220
 
213
- Each Cage model exposes a `run` method, which allows you to run that particular cage.
221
+ Each Cage model exposes a `run` method, which allows you to run that particular Cage.
214
222
 
215
- *Note*: this does not encrypt data before running the cage
223
+ *Note*: this does not encrypt data before running the Cage
216
224
  ```ruby
217
225
  cage = Evervault.cage_list.cages[0]
218
226
  cage.run({'name': 'testing'})
@@ -221,7 +229,8 @@ cage.run({'name': 'testing'})
221
229
 
222
230
  | Parameter | Type | Description |
223
231
  | --------- | ---- | ----------- |
224
- | data | Hash | Payload for the cage |
232
+ | data | Hash | Payload for the Cage |
233
+ | options | Hash | [Options for the Cage run](#Cage-Run-Options) |
225
234
 
226
235
  ## Development
227
236
 
@@ -29,13 +29,13 @@ module Evervault
29
29
  @crypto_client.encrypt(data)
30
30
  end
31
31
 
32
- def run(cage_name, encrypted_data)
33
- @request.post(cage_name, encrypted_data, cage_run: true)
32
+ def run(cage_name, encrypted_data, options = {})
33
+ @request.post(cage_name, encrypted_data, options: options, cage_run: true)
34
34
  end
35
35
 
36
- def encrypt_and_run(cage_name, data)
36
+ def encrypt_and_run(cage_name, data, options = {})
37
37
  encrypted_data = encrypt(data)
38
- run(cage_name, encrypted_data)
38
+ run(cage_name, encrypted_data, options)
39
39
  end
40
40
 
41
41
  def cages
@@ -25,8 +25,8 @@ module Evervault
25
25
  execute(:delete, build_url(path), params)
26
26
  end
27
27
 
28
- def post(path, params, cage_run: false)
29
- execute(:post, build_url(path, cage_run), params)
28
+ def post(path, params, options: {}, cage_run: false)
29
+ execute(:post, build_url(path, cage_run), params, build_cage_run_headers(options, cage_run))
30
30
  end
31
31
 
32
32
  private def build_url(path, cage_run = false)
@@ -34,23 +34,41 @@ module Evervault
34
34
  "#{@cage_run_url}#{path}"
35
35
  end
36
36
 
37
- def execute(method, url, params)
37
+ def execute(method, url, params, optional_headers = {})
38
38
  resp = Faraday.send(method, url) do |req|
39
39
  req.body = params.nil? || params.empty? ? nil : params.to_json
40
- req.headers = build_headers
40
+ req.headers = build_headers(optional_headers)
41
41
  end
42
42
  return JSON.parse(resp.body) if resp.status >= 200 && resp.status <= 300
43
43
  Evervault::Errors::ErrorMap.raise_errors_on_failure(resp.status, resp.body)
44
44
  end
45
45
 
46
- private def build_headers
47
- {
46
+ private def build_headers(optional_headers)
47
+ optional_headers.merge({
48
48
  "AcceptEncoding": "gzip, deflate",
49
49
  "Accept": "application/json",
50
50
  "Content-Type": "application/json",
51
51
  "User-Agent": "evervault-ruby/#{VERSION}",
52
52
  "Api-Key": @api_key
53
- }
53
+ })
54
+ end
55
+
56
+ private def build_cage_run_headers(options, cage_run = false)
57
+ optional_headers = {}
58
+ return optional_headers unless cage_run
59
+ if options.key?(:async)
60
+ if options[:async]
61
+ optional_headers["x-async"] = "true"
62
+ end
63
+ options.delete(:async)
64
+ end
65
+ if options.key?(:version)
66
+ if options[:version].is_a? Integer
67
+ optional_headers["x-version-id"] = options[:version].to_s
68
+ end
69
+ options.delete(:version)
70
+ end
71
+ optional_headers.merge(options)
54
72
  end
55
73
  end
56
74
  end
@@ -9,8 +9,8 @@ module Evervault
9
9
  @request = request
10
10
  end
11
11
 
12
- def run(params)
13
- @request.post(self.name, params, cage_run: true)
12
+ def run(params, options = {})
13
+ @request.post(self.name, params, options: options, cage_run: true)
14
14
  end
15
15
 
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module Evervault
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evervault
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonny O'Mahony
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-04 00:00:00.000000000 Z
11
+ date: 2020-11-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
65
  - !ruby/object:Gem::Version
66
66
  version: '0'
67
67
  requirements: []
68
- rubygems_version: 3.1.2
68
+ rubygems_version: 3.1.4
69
69
  signing_key:
70
70
  specification_version: 4
71
71
  summary: Ruby SDK to run Evervault Cages