chef-api 0.10.0 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef-api.rb +17 -18
- data/lib/chef-api/aclable.rb +6 -6
- data/lib/chef-api/authentication.rb +18 -19
- data/lib/chef-api/configurable.rb +14 -14
- data/lib/chef-api/connection.rb +36 -36
- data/lib/chef-api/defaults.rb +25 -24
- data/lib/chef-api/error_collection.rb +1 -1
- data/lib/chef-api/errors.rb +3 -3
- data/lib/chef-api/multipart.rb +17 -17
- data/lib/chef-api/resource.rb +17 -17
- data/lib/chef-api/resources/base.rb +22 -22
- data/lib/chef-api/resources/client.rb +4 -3
- data/lib/chef-api/resources/collection_proxy.rb +4 -3
- data/lib/chef-api/resources/cookbook.rb +2 -2
- data/lib/chef-api/resources/cookbook_version.rb +1 -1
- data/lib/chef-api/resources/data_bag.rb +3 -3
- data/lib/chef-api/resources/data_bag_item.rb +2 -3
- data/lib/chef-api/resources/environment.rb +1 -1
- data/lib/chef-api/resources/group.rb +1 -2
- data/lib/chef-api/resources/node.rb +2 -2
- data/lib/chef-api/resources/organization.rb +2 -2
- data/lib/chef-api/resources/partial_search.rb +4 -4
- data/lib/chef-api/resources/principal.rb +1 -1
- data/lib/chef-api/resources/role.rb +1 -1
- data/lib/chef-api/resources/search.rb +6 -6
- data/lib/chef-api/resources/user.rb +3 -3
- data/lib/chef-api/util.rb +8 -8
- data/lib/chef-api/validator.rb +3 -3
- data/lib/chef-api/validators/base.rb +3 -3
- data/lib/chef-api/validators/required.rb +1 -1
- data/lib/chef-api/validators/type.rb +1 -1
- data/lib/chef-api/version.rb +1 -1
- metadata +2 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
module ChefAPI
|
2
2
|
class Resource::Organization < Resource::Base
|
3
|
-
collection_path
|
3
|
+
collection_path "/organizations"
|
4
4
|
|
5
5
|
schema do
|
6
6
|
attribute :name, type: String, primary: true, required: true
|
@@ -16,7 +16,7 @@ module ChefAPI
|
|
16
16
|
ignore :billing_plan
|
17
17
|
ignore :requester_id
|
18
18
|
ignore :assigned_at
|
19
|
-
ignore
|
19
|
+
ignore "couchrest-type"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ChefAPI
|
2
2
|
class Resource::PartialSearch < Resource::Base
|
3
|
-
collection_path
|
3
|
+
collection_path "/search/:index"
|
4
4
|
|
5
5
|
schema do
|
6
6
|
attribute :total, type: Integer
|
@@ -24,19 +24,19 @@ module ChefAPI
|
|
24
24
|
# @return [self]
|
25
25
|
# the current resource
|
26
26
|
#
|
27
|
-
def query(index, keys, query =
|
27
|
+
def query(index, keys, query = "*:*", options = {})
|
28
28
|
return nil if index.nil?
|
29
29
|
|
30
30
|
params = {}.tap do |o|
|
31
31
|
o[:q] = query
|
32
32
|
o[:rows] = options[:rows] || 1000
|
33
|
-
o[:sort] = options[:sort] ||
|
33
|
+
o[:sort] = options[:sort] || "X_CHEF_id_CHEF_X"
|
34
34
|
o[:start] = options[:start] || 0
|
35
35
|
end
|
36
36
|
|
37
37
|
path = expanded_collection_path(index: index.to_s)
|
38
38
|
response = connection.post(path, keys.to_json, params)
|
39
|
-
response[
|
39
|
+
response["rows"].map! { |row| row["data"] }
|
40
40
|
from_json(response, index: index.to_s)
|
41
41
|
end
|
42
42
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ChefAPI
|
2
2
|
class Resource::Search < Resource::Base
|
3
|
-
collection_path
|
3
|
+
collection_path "/search/:index"
|
4
4
|
|
5
5
|
schema do
|
6
6
|
attribute :total, type: Integer
|
@@ -22,22 +22,22 @@ module ChefAPI
|
|
22
22
|
# @return [self]
|
23
23
|
# the current resource
|
24
24
|
#
|
25
|
-
def query(index, query =
|
25
|
+
def query(index, query = "*:*", options = {})
|
26
26
|
return nil if index.nil?
|
27
27
|
|
28
28
|
params = {}.tap do |o|
|
29
29
|
o[:q] = query
|
30
30
|
o[:rows] = options[:rows] || 1000
|
31
|
-
o[:sort] = options[:sort] ||
|
31
|
+
o[:sort] = options[:sort] || "X_CHEF_id_CHEF_X"
|
32
32
|
o[:start] = options[:start] || 0
|
33
33
|
end
|
34
34
|
|
35
35
|
path = expanded_collection_path(index: index.to_s)
|
36
36
|
|
37
37
|
response = if filter_result = options[:filter_result]
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
connection.post(path, filter_result.to_json, params)
|
39
|
+
else
|
40
|
+
connection.get(path, params)
|
41
41
|
end
|
42
42
|
|
43
43
|
from_json(response, index: index.to_s)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ChefAPI
|
2
2
|
class Resource::User < Resource::Base
|
3
|
-
collection_path
|
3
|
+
collection_path "/users"
|
4
4
|
|
5
5
|
schema do
|
6
6
|
flavor :enterprise do
|
@@ -38,7 +38,7 @@ module ChefAPI
|
|
38
38
|
# HEC/EC returns a slightly different response than OSC/CZ
|
39
39
|
if users.is_a?(Array)
|
40
40
|
users.each do |info|
|
41
|
-
name = URI.escape(info[
|
41
|
+
name = URI.escape(info["user"]["username"])
|
42
42
|
response = connection.get("/users/#{name}")
|
43
43
|
result = from_json(response, prefix)
|
44
44
|
|
@@ -75,7 +75,7 @@ module ChefAPI
|
|
75
75
|
# the parsed JSON response from the server
|
76
76
|
#
|
77
77
|
def authenticate(options = {})
|
78
|
-
connection.post(
|
78
|
+
connection.post("/authenticate_user", options.to_json)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
data/lib/chef-api/util.rb
CHANGED
@@ -14,10 +14,10 @@ module ChefAPI
|
|
14
14
|
def underscore(string)
|
15
15
|
string
|
16
16
|
.to_s
|
17
|
-
.gsub(/::/,
|
18
|
-
.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
19
|
-
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
|
20
|
-
.tr(
|
17
|
+
.gsub(/::/, "/")
|
18
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
19
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
20
|
+
.tr("-", "_")
|
21
21
|
.downcase
|
22
22
|
end
|
23
23
|
|
@@ -32,8 +32,8 @@ module ChefAPI
|
|
32
32
|
def camelize(string)
|
33
33
|
string
|
34
34
|
.to_s
|
35
|
-
.split(
|
36
|
-
.map
|
35
|
+
.split("_")
|
36
|
+
.map(&:capitalize)
|
37
37
|
.join
|
38
38
|
end
|
39
39
|
|
@@ -49,7 +49,7 @@ module ChefAPI
|
|
49
49
|
length = options[:length] || 30
|
50
50
|
|
51
51
|
if string.length > length
|
52
|
-
string[0..length-3] +
|
52
|
+
string[0..length - 3] + "..."
|
53
53
|
else
|
54
54
|
string
|
55
55
|
end
|
@@ -77,7 +77,7 @@ module ChefAPI
|
|
77
77
|
#
|
78
78
|
def safe_read(path)
|
79
79
|
path = File.expand_path(path)
|
80
|
-
name = File.basename(path,
|
80
|
+
name = File.basename(path, ".*")
|
81
81
|
contents = File.read(path)
|
82
82
|
|
83
83
|
[name, contents]
|
data/lib/chef-api/validator.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module ChefAPI
|
2
2
|
module Validator
|
3
|
-
autoload :Base,
|
4
|
-
autoload :Required,
|
5
|
-
autoload :Type,
|
3
|
+
autoload :Base, "chef-api/validators/base"
|
4
|
+
autoload :Required, "chef-api/validators/required"
|
5
|
+
autoload :Type, "chef-api/validators/type"
|
6
6
|
|
7
7
|
#
|
8
8
|
# Find a validator by the given key.
|
@@ -35,7 +35,7 @@ module ChefAPI
|
|
35
35
|
# @return [Symbol]
|
36
36
|
#
|
37
37
|
def key
|
38
|
-
name = self.class.name.split(
|
38
|
+
name = self.class.name.split("::").last
|
39
39
|
Util.underscore(name).to_sym
|
40
40
|
end
|
41
41
|
|
@@ -47,7 +47,7 @@ module ChefAPI
|
|
47
47
|
# the parent resource to validate against
|
48
48
|
#
|
49
49
|
def validate(resource)
|
50
|
-
raise Error::AbstractMethod.new(method:
|
50
|
+
raise Error::AbstractMethod.new(method: "Validators::Base#validate")
|
51
51
|
end
|
52
52
|
|
53
53
|
#
|
@@ -76,7 +76,7 @@ module ChefAPI
|
|
76
76
|
# @return [String]
|
77
77
|
#
|
78
78
|
def classname
|
79
|
-
@classname ||= self.class.name.split(
|
79
|
+
@classname ||= self.class.name.split("::")[1..-1].join("::")
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -15,7 +15,7 @@ module ChefAPI
|
|
15
15
|
value = resource._attributes[attribute]
|
16
16
|
|
17
17
|
if value && !types.any? { |type| value.is_a?(type) }
|
18
|
-
short_name = type.to_s.split(
|
18
|
+
short_name = type.to_s.split("::").last
|
19
19
|
resource.errors.add(attribute, "must be a kind of #{short_name}")
|
20
20
|
end
|
21
21
|
end
|
data/lib/chef-api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Vargo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: logify
|