kinetic_sdk 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kinetic_sdk/task/lib/policy_rules.rb +42 -3
- data/lib/kinetic_sdk/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: b7d44ee22259297d53b3443c3e86cc3d8b724cef8ab996f2b3a378900a1a12c5
|
4
|
+
data.tar.gz: '09fbb57c03e9e6a7ab21a0dac2eb104e2fd8917e91bb221083bc4635513110f5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab9121e76bc6f9ec5f6c4ef704fc98c3070ae8d79461087deb173762a6331469b300d66867c513735c4f56da17596675dcf40e2977219b91cc99dfa7459dfa0e
|
7
|
+
data.tar.gz: 2d11b876d8419d4ffd89182cd51e698ce60056227392d229c7b7e9291a32e345577eda84eedcb7b8ef5a131e8df5402b2003de773c41fb42dd49bd83bdcee0b3
|
@@ -18,7 +18,9 @@ module KineticSdk
|
|
18
18
|
#
|
19
19
|
def add_policy_rule(policy, headers=default_headers)
|
20
20
|
@logger.info("Adding policy rule \"#{policy['type']} - #{policy['name']}\"")
|
21
|
-
|
21
|
+
payload = policy
|
22
|
+
payload["consolePolicyRules"] = consoleNames(payload) if payload.has_key?("consolePolicyRules")
|
23
|
+
post("#{@api_url}/policyRules/#{encode(policy['type'])}", payload, headers)
|
22
24
|
end
|
23
25
|
|
24
26
|
# Delete a Policy Rule.
|
@@ -111,7 +113,11 @@ module KineticSdk
|
|
111
113
|
@logger.info("Importing all Policy Rules in Export Directory")
|
112
114
|
Dir["#{@options[:export_directory]}/policyRules/*.json"].sort.each do |file|
|
113
115
|
policy_rule = JSON.parse(File.read(file))
|
114
|
-
|
116
|
+
if find_policy_rule({ "type" => policy_rule["type"], "name" => policy_rule["name"] }).status == 200
|
117
|
+
update_policy_rule({ "type" => policy_rule["type"], "name" => policy_rule["name"] }, policy_rule, headers)
|
118
|
+
else
|
119
|
+
add_policy_rule(policy_rule, headers)
|
120
|
+
end
|
115
121
|
end
|
116
122
|
end
|
117
123
|
|
@@ -172,7 +178,40 @@ module KineticSdk
|
|
172
178
|
#
|
173
179
|
def update_policy_rule(policy_rule, body={}, headers=default_headers)
|
174
180
|
@logger.info("Updating the \"#{policy_rule['type']} - #{policy_rule['name']}\" Policy Rule")
|
175
|
-
|
181
|
+
payload = body
|
182
|
+
payload["consolePolicyRules"] = consoleNames(payload) if payload.has_key?("consolePolicyRules")
|
183
|
+
|
184
|
+
@logger.info("UPDATE: #{payload}")
|
185
|
+
put("#{@api_url}/policyRules/#{encode(policy_rule['type'])}/#{encode(policy_rule['name'])}", payload, headers)
|
186
|
+
end
|
187
|
+
|
188
|
+
private
|
189
|
+
|
190
|
+
# Returns a list of console names from a list of consolePolicyRules hash
|
191
|
+
# objects.
|
192
|
+
#
|
193
|
+
# This is used to convert a console policy hash to a simple string containing
|
194
|
+
# the console name:
|
195
|
+
#
|
196
|
+
# {
|
197
|
+
# "name" => "Foo",
|
198
|
+
# "type" => "Console Access"
|
199
|
+
# }
|
200
|
+
#
|
201
|
+
def consoleNames(policyRule)
|
202
|
+
consoles = nil
|
203
|
+
# if consolePolicyRules are to be applied, change to a list of console names
|
204
|
+
if policyRule.has_key?("consolePolicyRules")
|
205
|
+
consoles = []
|
206
|
+
(policyRule['consolePolicyRules'] || []).each { |console_policy_rule|
|
207
|
+
if console_policy_rule.is_a? Hash
|
208
|
+
consoles << console_policy_rule["name"]
|
209
|
+
else
|
210
|
+
consoles << console_policy_rule
|
211
|
+
end
|
212
|
+
}
|
213
|
+
end
|
214
|
+
consoles
|
176
215
|
end
|
177
216
|
|
178
217
|
end
|
data/lib/kinetic_sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kinetic_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kinetic Data
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|